diff options
Diffstat (limited to 'tdefilereplace')
-rw-r--r-- | tdefilereplace/tdefilereplacepart.cpp | 112 | ||||
-rw-r--r-- | tdefilereplace/tdefilereplacepart.h | 9 | ||||
-rw-r--r-- | tdefilereplace/tdefilereplaceview.cpp | 133 | ||||
-rw-r--r-- | tdefilereplace/tdefilereplaceview.h | 11 |
4 files changed, 118 insertions, 147 deletions
diff --git a/tdefilereplace/tdefilereplacepart.cpp b/tdefilereplace/tdefilereplacepart.cpp index 5e08355..804b0f5 100644 --- a/tdefilereplace/tdefilereplacepart.cpp +++ b/tdefilereplace/tdefilereplacepart.cpp @@ -159,7 +159,7 @@ void TDEFileReplacePart::slotSearchingOperation() m_option->m_searchingOnlyMode = true; - resetActions(); + updateGUI(); m_searchingOperation = true; @@ -223,7 +223,7 @@ void TDEFileReplacePart::slotReplacingOperation() m_option->m_searchingOnlyMode = false; - resetActions(); + updateGUI(); m_searchingOperation = false; @@ -242,7 +242,7 @@ void TDEFileReplacePart::slotStop() emit setStatusBarText(i18n("Stopping...")); m_stop = true; TQApplication::restoreOverrideCursor(); - resetActions(); + updateGUI(); } void TDEFileReplacePart::slotCreateReport() @@ -286,13 +286,7 @@ void TDEFileReplacePart::slotCreateReport() Report report(m_option, rv, sv); report.createDocument(documentPath); - //resetActions(); -} - -void TDEFileReplacePart::slotStringsAdd() -{ - m_view->slotStringsAdd(); - resetActions(); + //updateGUI(); } void TDEFileReplacePart::slotQuickStringsAdd() @@ -328,29 +322,6 @@ void TDEFileReplacePart::slotQuickStringsAdd() } } -void TDEFileReplacePart::slotStringsDeleteItem() -{ - m_view->slotStringsDeleteItem(); - resetActions(); -} - -void TDEFileReplacePart::slotStringsEmpty() -{ - m_view->slotStringsEmpty(); - resetActions(); -} - -void TDEFileReplacePart::slotStringsEdit() -{ - m_view->slotStringsEdit(); - resetActions(); -} - -void TDEFileReplacePart::slotStringsSave() -{ - m_view->slotStringsSave(); -} - void TDEFileReplacePart::slotStringsLoad() { // Selects the file to load from @@ -360,19 +331,7 @@ void TDEFileReplacePart::slotStringsLoad() if(!fileName.isEmpty()) loadRulesFile(fileName); - resetActions(); -} - -void TDEFileReplacePart::slotStringsInvertCur() -{ - m_view->stringsInvert(false); - resetActions(); -} - -void TDEFileReplacePart::slotStringsInvertAll() -{ - m_view->stringsInvert(true); - resetActions(); + updateGUI(); } void TDEFileReplacePart::slotOpenRecentStringFile(const KURL& urlFile) @@ -393,50 +352,48 @@ void TDEFileReplacePart::slotOpenRecentStringFile(const KURL& urlFile) } loadRulesFile(fileName); - resetActions(); + updateGUI(); } void TDEFileReplacePart::slotOptionRecursive() { m_option->m_recursive = !m_option->m_recursive; - resetActions(); + updateGUI(); } void TDEFileReplacePart::slotOptionBackup() { m_option->m_backup = !m_option->m_backup; - resetActions(); + updateGUI(); } void TDEFileReplacePart::slotOptionCaseSensitive() { m_option->m_caseSensitive = !m_option->m_caseSensitive; - resetActions(); + updateGUI(); } void TDEFileReplacePart::slotOptionVariables() { m_option->m_variables = !m_option->m_variables; - resetActions(); + updateGUI(); } void TDEFileReplacePart::slotOptionRegularExpressions() { m_option->m_regularExpressions = !m_option->m_regularExpressions; - resetActions(); + updateGUI(); } void TDEFileReplacePart::slotOptionPreferences() { KOptionsDlg dlg(m_option, m_w, 0); - - if(!dlg.exec()) + if (!dlg.exec()) + { return; - - //updating m_view + } m_view->updateOptions(m_option); - - resetActions(); + updateGUI(); } void TDEFileReplacePart::showAboutApplication() @@ -462,7 +419,7 @@ void TDEFileReplacePart::reportBug() dlg.exec(); } -void TDEFileReplacePart::resetActions() +void TDEFileReplacePart::updateGUI() { TDEListView* rv = m_view->getResultsView(), * sv = m_view->getStringsView(); @@ -557,7 +514,7 @@ bool TDEFileReplacePart::openURL(const KURL &url) return launchNewProjectDialog(url); else { - resetActions(); + updateGUI(); return true; } } @@ -580,6 +537,10 @@ void TDEFileReplacePart::initGUI() break; } } + + // GUI + connect(m_view, TQT_SIGNAL(updateGUI()), this, TQT_SLOT(updateGUI())); + // File (void)new TDEAction(i18n("Customize Search/Replace Session..."), "projectopen", TDEShortcut(CTRL + Key_F), TQT_TQOBJECT(this), TQT_SLOT(slotSetNewParameters()), actionCollection(), "new_project"); (void)new TDEAction(i18n("&Search"), "filesearch", 0, TQT_TQOBJECT(this), TQT_SLOT(slotSearchingOperation()), actionCollection(), "search"); @@ -589,16 +550,15 @@ void TDEFileReplacePart::initGUI() (void)new TDEAction(i18n("Cre&ate Report File..."), "document-save-as", 0, TQT_TQOBJECT(this), TQT_SLOT(slotCreateReport()), actionCollection(), "save_results"); // Strings - (void)new TDEAction(i18n("&Add String..."), "editadd", 0, TQT_TQOBJECT(this), TQT_SLOT(slotStringsAdd()), actionCollection(), "strings_add"); - - (void)new TDEAction(i18n("&Delete String"), "editremove", 0, TQT_TQOBJECT(this), TQT_SLOT(slotStringsDeleteItem()), actionCollection(), "strings_del"); - (void)new TDEAction(i18n("&Empty Strings List"), "edit-delete", 0, TQT_TQOBJECT(this), TQT_SLOT(slotStringsEmpty()), actionCollection(), "strings_empty"); - (void)new TDEAction(i18n("Edit Selected String..."), "edit", 0, TQT_TQOBJECT(this), TQT_SLOT(slotStringsEdit()), actionCollection(), "strings_edit"); - (void)new TDEAction(i18n("&Save Strings List to File..."), "document-save-as", 0, TQT_TQOBJECT(this), TQT_SLOT(slotStringsSave()), actionCollection(), "strings_save"); + (void)new TDEAction(i18n("&Add String..."), "editadd", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotStringsAdd()), actionCollection(), "strings_add"); + (void)new TDEAction(i18n("&Delete String"), "editremove", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotStringsDeleteItem()), actionCollection(), "strings_del"); + (void)new TDEAction(i18n("&Empty Strings List"), "edit-delete", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotStringsEmpty()), actionCollection(), "strings_empty"); + (void)new TDEAction(i18n("Edit Selected String..."), "edit", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotStringsEdit()), actionCollection(), "strings_edit"); + (void)new TDEAction(i18n("&Save Strings List to File..."), "document-save-as", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotStringsSave()), actionCollection(), "strings_save"); (void)new TDEAction(i18n("&Load Strings List From File..."), "unsortedList", 0, TQT_TQOBJECT(this), TQT_SLOT(slotStringsLoad()), actionCollection(), "strings_load"); (void)new TDERecentFilesAction(i18n("&Load Recent Strings Files"), "document-open", 0, TQT_TQOBJECT(this), TQT_SLOT(slotOpenRecentStringFile(const KURL&)), actionCollection(),"strings_load_recent"); - (void)new TDEAction(i18n("&Invert Current String (search <--> replace)"), "invert", 0, TQT_TQOBJECT(this), TQT_SLOT(slotStringsInvertCur()), actionCollection(), "strings_invert"); - (void)new TDEAction(i18n("&Invert All Strings (search <--> replace)"), "invert", 0, TQT_TQOBJECT(this), TQT_SLOT(slotStringsInvertAll()), actionCollection(), "strings_invert_all"); + (void)new TDEAction(i18n("&Invert Current String (search <--> replace)"), "invert", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotStringsInvertCur()), actionCollection(), "strings_invert"); + (void)new TDEAction(i18n("&Invert All Strings (search <--> replace)"), "invert", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotStringsInvertAll()), actionCollection(), "strings_invert_all"); // Options (void)new TDEToggleAction(i18n("&Include Sub-Folders"), "recursive_option", 0, TQT_TQOBJECT(this), TQT_SLOT(slotOptionRecursive()), actionCollection(), "options_recursive"); @@ -611,21 +571,21 @@ void TDEFileReplacePart::initGUI() // Results (void)new TDEAction(i18n("&Properties"), "informations", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultProperties()), actionCollection(), "results_infos"); (void)new TDEAction(i18n("&Open"), "document-open", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultOpen()), actionCollection(), "results_openfile"); - (void)new TDEAction(i18n("Open &With..."), "document-open", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultOpen()), actionCollection(), "results_openfilewith"); - + (void)new TDEAction(i18n("Open &With..."), "document-open", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultOpenWith()), actionCollection(), "results_openfilewith"); if(quantaFound) - { - (void)new TDEAction(i18n("&Edit in Quanta"), "quanta", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultEdit()), actionCollection(), "results_editfile"); - } + { + (void)new TDEAction(i18n("&Edit in Quanta"), "quanta", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultEdit()), actionCollection(), "results_editfile"); + } (void)new TDEAction(i18n("Open Parent &Folder"), "go-up", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultDirOpen()), actionCollection(), "results_opendir"); (void)new TDEAction(i18n("Remove &Entry"), "edit-clear", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultRemoveEntry()), actionCollection(), "results_removeentry"); (void)new TDEAction(i18n("&Delete"), "edit-delete", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultDelete()), actionCollection(), "results_delete"); (void)new TDEAction(i18n("E&xpand Tree"), 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultTreeExpand()), actionCollection(), "results_treeexpand"); (void)new TDEAction(i18n("&Reduce Tree"), 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultTreeReduce()), actionCollection(), "results_treereduce"); + + // Help (void)new TDEAction(i18n("&About TDEFileReplace"), "tdefilereplace", 0, TQT_TQOBJECT(this), TQT_SLOT(showAboutApplication()), actionCollection(), "help_about_tdefilereplace"); (void)new TDEAction(i18n("TDEFileReplace &Handbook"), "help", 0, TQT_TQOBJECT(this), TQT_SLOT(appHelpActivated()), actionCollection(), "help_tdefilereplace"); (void)new TDEAction(i18n("&Report Bug"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(reportBug()), actionCollection(), "report_bug"); - } void TDEFileReplacePart::initView() @@ -1648,7 +1608,7 @@ void TDEFileReplacePart::loadRulesFile(const TQString& fileName) m_view->loadMap(docMap); - //resetActions(); + updateGUI(); } bool TDEFileReplacePart::launchNewProjectDialog(const KURL & startURL) @@ -1670,7 +1630,7 @@ bool TDEFileReplacePart::launchNewProjectDialog(const KURL & startURL) m_view->updateOptions(m_option); - resetActions(); + updateGUI(); return true; } diff --git a/tdefilereplace/tdefilereplacepart.h b/tdefilereplace/tdefilereplacepart.h index 45064f7..e135e05 100644 --- a/tdefilereplace/tdefilereplacepart.h +++ b/tdefilereplace/tdefilereplacepart.h @@ -63,15 +63,8 @@ class TDEFileReplacePart: public KParts::ReadOnlyPart void slotSimulatingOperation(); void slotStop(); void slotCreateReport(); - void slotStringsAdd(); void slotQuickStringsAdd(); - void slotStringsDeleteItem(); - void slotStringsEmpty(); - void slotStringsEdit(); - void slotStringsSave(); void slotStringsLoad(); - void slotStringsInvertCur(); - void slotStringsInvertAll(); void slotOpenRecentStringFile(const KURL& urlFile); void slotOptionRecursive(); void slotOptionBackup(); @@ -82,7 +75,7 @@ class TDEFileReplacePart: public KParts::ReadOnlyPart void showAboutApplication(void); void appHelpActivated(); void reportBug(); - void resetActions(); + void updateGUI(); void slotSearchMode(bool b){ m_option->m_searchingOnlyMode = b; } //METHODS diff --git a/tdefilereplace/tdefilereplaceview.cpp b/tdefilereplace/tdefilereplaceview.cpp index 2220c13..e7bfd87 100644 --- a/tdefilereplace/tdefilereplaceview.cpp +++ b/tdefilereplace/tdefilereplaceview.cpp @@ -133,38 +133,46 @@ void TDEFileReplaceView::displayScannedFiles(int foldersNumber, int filesNumber) void TDEFileReplaceView::stringsInvert(bool invertAll) { - TQListViewItem* lviCurItem, - * lviFirst; - TDEListView* sv = getStringsView(); + if (m_option->m_searchingOnlyMode) + { + return; + } - if(invertAll) - lviCurItem = lviFirst = sv->firstChild(); + TDEListView *sv = getStringsView(); + TQListViewItem *lviCurItem; + if (invertAll) + { + lviCurItem = sv->firstChild(); + } else - lviCurItem = lviFirst = sv->currentItem(); - - if(lviCurItem == 0) - return ; + { + lviCurItem = sv->currentItem(); + } + if (!lviCurItem) + { + return; + } do { - TQString searchText = lviCurItem->text(0), - replaceText = lviCurItem->text(1); + TQString searchText = lviCurItem->text(0), replaceText = lviCurItem->text(1); - // Cannot invert the string when search string is empty + // Cannot invert the string when search string is empty if (replaceText.isEmpty()) { - KMessageBox::error(0, i18n("<qt>Cannot invert string <b>%1</b>, because the search string would be empty.</qt>").arg(searchText)); - return; + KMessageBox::error(0, i18n("<qt>Cannot invert string <b>%1</b>, because the search string would be empty.</qt>") + .arg(searchText)); + } + else + { + lviCurItem->setText(0, replaceText); + lviCurItem->setText(1, searchText); } - - lviCurItem->setText(0, replaceText); - lviCurItem->setText(1, searchText); - lviCurItem = lviCurItem->nextSibling(); - if(!invertAll) - break; - } while(lviCurItem && lviCurItem != lviFirst); - setCurrentStringsViewMap(); + } while (invertAll && lviCurItem); + + updateStringMap(); + emit updateGUI(); } void TDEFileReplaceView::changeView(bool searchingOnlyMode) @@ -232,33 +240,33 @@ void TDEFileReplaceView::slotResultProperties() { TQString currItemPath = getItemPath(getCurrItemTopLevelParent()); if (!currItemPath.isEmpty()) - { - KURL url(currItemPath); - (void) new KPropertiesDialog(url); - m_lviCurrent = 0; - } + { + KURL url(currItemPath); + (void) new KPropertiesDialog(url); + m_lviCurrent = 0; + } } void TDEFileReplaceView::slotResultOpen() { TQString currItemPath = getItemPath(getCurrItemTopLevelParent()); if (!currItemPath.isEmpty()) - { - (void) new KRun(KURL(currItemPath), 0, true, true); - m_lviCurrent = 0; - } + { + (void) new KRun(KURL(currItemPath), 0, true, true); + m_lviCurrent = 0; + } } void TDEFileReplaceView::slotResultOpenWith() { TQString currItemPath = getItemPath(getCurrItemTopLevelParent()); if (!currItemPath.isEmpty()) - { - KURL::List kurls; - kurls.append(KURL(currItemPath)); - KRun::displayOpenWithDialog(kurls); - m_lviCurrent = 0; - } + { + KURL::List kurls; + kurls.append(KURL(currItemPath)); + KRun::displayOpenWithDialog(kurls); + m_lviCurrent = 0; + } } void TDEFileReplaceView::slotResultDirOpen() @@ -401,6 +409,7 @@ void TDEFileReplaceView::slotStringsAdd() raiseStringsView(); loadMapIntoView(addedStringsMap); + emit updateGUI(); } void TDEFileReplaceView::slotQuickStringsAdd(const TQString& quickSearch, const TQString& quickReplace) @@ -461,6 +470,7 @@ void TDEFileReplaceView::slotStringsEdit() raiseStringsView(); loadMapIntoView(newMap); + emit updateGUI(); } void TDEFileReplaceView::slotStringsSave() @@ -480,7 +490,6 @@ void TDEFileReplaceView::slotStringsSave() header += "\n\t<mode search=\"false\"/>"; TQListViewItem *lvi = sv->firstChild(); - while (lvi) { body += TQString("\n\t<replacement>" @@ -510,29 +519,34 @@ void TDEFileReplaceView::slotStringsSave() file.close(); } +void TDEFileReplaceView::slotStringsInvertCur() +{ + stringsInvert(false); +} + +void TDEFileReplaceView::slotStringsInvertAll() +{ + stringsInvert(true); +} + void TDEFileReplaceView::slotStringsDeleteItem() { - TQListViewItem* item = m_sv->currentItem(); - if(item != 0) + TQListViewItem *item = m_sv->currentItem(); + if (item) { KeyValueMap m = m_option->m_mapStringsView; m.remove(item->text(0)); m_option->m_mapStringsView = m; delete item; + emit updateGUI(); } } void TDEFileReplaceView::slotStringsEmpty() { - TQListViewItem * myChild = m_sv->firstChild(); - while( myChild ) - { - TQListViewItem* item = myChild; - myChild = myChild->nextSibling(); - delete item; - } - KeyValueMap m; - m_option->m_mapStringsView = m; + m_sv->clear(); + m_option->m_mapStringsView.clear(); + emit updateGUI(); } //PRIVATE @@ -700,19 +714,22 @@ void TDEFileReplaceView::expand(TQListViewItem *lviCurrent, bool b) } } -void TDEFileReplaceView::setMap() +void TDEFileReplaceView::updateStringMap() { - KeyValueMap map; - TQListViewItem* i = m_sv->firstChild(); - while(i != 0) + m_option->m_mapStringsView.clear(); + TQListViewItem *item = m_sv->firstChild(); + while (item) { - if(m_option->m_searchingOnlyMode) - map[i->text(0)] = TQString(); + if (m_option->m_searchingOnlyMode) + { + m_option->m_mapStringsView[item->text(0)] = TQString(); + } else - map[i->text(0)] = i->text(1); - i = i->nextSibling(); + { + m_option->m_mapStringsView[item->text(0)] = item->text(1); + } + item = item->nextSibling(); } - m_option->m_mapStringsView = map; } void TDEFileReplaceView::loadMapIntoView(KeyValueMap map) diff --git a/tdefilereplace/tdefilereplaceview.h b/tdefilereplace/tdefilereplaceview.h index 9a4721f..b97b5af 100644 --- a/tdefilereplace/tdefilereplaceview.h +++ b/tdefilereplace/tdefilereplaceview.h @@ -73,7 +73,6 @@ class TDEFileReplaceView : public TDEFileReplaceViewWdg void updateOptions(RCOptions* info) { m_option = info; } void loadMap(KeyValueMap extMap){ loadMapIntoView(extMap); } KeyValueMap getStringsViewMap()const { return m_option->m_mapStringsView;} - void setCurrentStringsViewMap(){ setMap(); } //void emitSearchingOnlyMode(bool b) { emit searchingOnlyMode(b); } public slots: @@ -95,6 +94,8 @@ class TDEFileReplaceView : public TDEFileReplaceViewWdg void slotStringsEmpty(); void slotStringsEdit(); void slotStringsSave(); + void slotStringsInvertCur(); + void slotStringsInvertAll(); private: void initGUI(); @@ -102,13 +103,13 @@ class TDEFileReplaceView : public TDEFileReplaceViewWdg void raiseResultsView(); coord extractWordCoordinates(TQListViewItem* lvi); void expand(TQListViewItem *lviCurrent, bool b); - void setMap(); + void updateStringMap(); void loadMapIntoView(KeyValueMap map); void whatsThis(); - /*signals: - void resetActions(); - void searchingOnlyMode(bool);*/ + signals: + void updateGUI(); + // void searchingOnlyMode(bool); private: TDEPopupMenu *m_menuResult; |