From a58ed210742d83bf1ce96194083eb925298b02c5 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Thu, 20 Jun 2019 23:02:54 +0900 Subject: tdefilereplace: improved logic for string add/edit/remove dialog. Removed the string edit action which is now no longer required. Signed-off-by: Michele Calgaro --- tdefilereplace/kaddstringdlg.cpp | 58 +++++++++++---------------------- tdefilereplace/kaddstringdlg.h | 13 ++------ tdefilereplace/tdefilereplacepart.cpp | 3 -- tdefilereplace/tdefilereplacepartui.rc | 8 ++--- tdefilereplace/tdefilereplaceview.cpp | 59 ++++------------------------------ tdefilereplace/tdefilereplaceview.h | 1 - 6 files changed, 29 insertions(+), 113 deletions(-) (limited to 'tdefilereplace') diff --git a/tdefilereplace/kaddstringdlg.cpp b/tdefilereplace/kaddstringdlg.cpp index 0e3c5f0..6aa29c6 100644 --- a/tdefilereplace/kaddstringdlg.cpp +++ b/tdefilereplace/kaddstringdlg.cpp @@ -37,10 +37,9 @@ using namespace whatthisNameSpace; -KAddStringDlg::KAddStringDlg(RCOptions* info, bool wantEdit, TQWidget *parent, const char *name) : KAddStringDlgS(parent,name,true) +KAddStringDlg::KAddStringDlg(RCOptions* info, TQWidget *parent, const char *name) : KAddStringDlgS(parent,name,true) { m_option = info; - m_wantEdit = wantEdit; m_currentMap = m_option->m_mapStringsView; initGUI(); @@ -64,53 +63,33 @@ void KAddStringDlg::initGUI() m_stack->addWidget(m_stringView); m_stack->addWidget(m_stringView_2); + if (m_option->m_searchingOnlyMode) + { + m_rbSearchOnly->setChecked(true); + } + else + { + m_rbSearchReplace->setChecked(true); + } if(m_option->m_searchingOnlyMode) { - if(m_wantEdit) - m_rbSearchReplace->setEnabled(false); - m_rbSearchOnly->setChecked(true); - m_edSearch->setEnabled(true); m_edReplace->setEnabled(false); - m_tlSearch->setEnabled(true); m_tlReplace->setEnabled(false); } else { - if(m_wantEdit) - m_rbSearchOnly->setEnabled(false); - m_rbSearchReplace->setChecked(true); - m_edSearch->setEnabled(true); m_edReplace->setEnabled(true); - m_tlSearch->setEnabled(true); m_tlReplace->setEnabled(true); } raiseView(); - - if(m_wantEdit) - loadMapIntoView(); -} - -void KAddStringDlg::eraseViewItems() -{ - TQListViewItem* item = m_sv->firstChild(); - if(item == 0) - return; - else - { - while(item) - { - TQListViewItem* tempItem = item; - item = item->nextSibling(); - delete tempItem; - } - } + loadMapIntoView(); } void KAddStringDlg::raiseView() { - if(m_option->m_searchingOnlyMode) + if (m_option->m_searchingOnlyMode) m_sv = m_stringView_2; else m_sv = m_stringView; @@ -175,38 +154,37 @@ void KAddStringDlg::slotOK() void KAddStringDlg::slotSearchOnly() { m_option->m_searchingOnlyMode = true; + m_currentMap.clear(); m_rbSearchOnly->setChecked(true); - m_edSearch->setEnabled(true); m_edReplace->setEnabled(false); - m_tlSearch->setEnabled(true); m_tlReplace->setEnabled(false); //sets the right view appearance raiseView(); //empties the view content - eraseViewItems(); + + m_sv->clear(); } void KAddStringDlg::slotSearchReplace() { m_option->m_searchingOnlyMode = false; + m_currentMap.clear(); m_rbSearchReplace->setChecked(true); - m_edSearch->setEnabled(true); m_edReplace->setEnabled(true); - m_tlSearch->setEnabled(true); m_tlReplace->setEnabled(true); //sets the right view appearance raiseView(); //empties the view content - eraseViewItems(); + m_sv->clear(); } void KAddStringDlg::slotAddStringToView() { - if(m_option->m_searchingOnlyMode) + if (m_option->m_searchingOnlyMode) { TQString text = m_edSearch->text(); if(!(text.isEmpty() || columnContains(m_sv, text, 0))) @@ -223,7 +201,7 @@ void KAddStringDlg::slotAddStringToView() TQString searchText = m_edSearch->text(), replaceText = m_edReplace->text(); - if(!(searchText.isEmpty() || replaceText.isEmpty() || columnContains(m_sv,searchText,0) || columnContains(m_sv,replaceText,1))) + if (!searchText.isEmpty() && !columnContains(m_sv, searchText, 0)) { TQListViewItem* lvi = new TQListViewItem(m_sv); lvi->setMultiLinesEnabled(true); diff --git a/tdefilereplace/kaddstringdlg.h b/tdefilereplace/kaddstringdlg.h index f39c296..276573e 100644 --- a/tdefilereplace/kaddstringdlg.h +++ b/tdefilereplace/kaddstringdlg.h @@ -2,7 +2,7 @@ KAddStringDlg.h - description ------------------- begin : Sat Oct 16 1999 - copyright : (C) 1999 by François Dupoux + copyright : (C) 1999 by François Dupoux (C) 2004 Emiliano Gulmini email : dupoux@dupoux.com ***************************************************************************/ @@ -33,10 +33,9 @@ class KAddStringDlg : public KAddStringDlgS RCOptions* m_option; TQListView* m_sv; KeyValueMap m_currentMap; - bool m_wantEdit; public: //Constructors - KAddStringDlg(RCOptions* info, bool wantEdit, TQWidget *parent=0, const char *name=0); + KAddStringDlg(RCOptions* info, TQWidget *parent=0, const char *name=0); private slots: void slotOK(); @@ -51,14 +50,6 @@ class KAddStringDlg : public KAddStringDlgS * inits... the GUI :-) */ void initGUI(); - /** - * Deletes all the items of the view - */ - void eraseViewItems(); - /** - * Deletes all the items of the map - */ - void clearMap() { KeyValueMap m; m_option->m_mapStringsView = m; } /** * The view is actually a stack widget that contains two different views widget */ diff --git a/tdefilereplace/tdefilereplacepart.cpp b/tdefilereplace/tdefilereplacepart.cpp index 804b0f5..d562437 100644 --- a/tdefilereplace/tdefilereplacepart.cpp +++ b/tdefilereplace/tdefilereplacepart.cpp @@ -439,7 +439,6 @@ void TDEFileReplacePart::updateGUI() actionCollection()->action("strings_add")->setEnabled(true); actionCollection()->action("strings_del")->setEnabled(hasItems); actionCollection()->action("strings_empty")->setEnabled(hasItems); - actionCollection()->action("strings_edit")->setEnabled(hasItems); actionCollection()->action("strings_save")->setEnabled(hasItems); actionCollection()->action("strings_load")->setEnabled(true); actionCollection()->action("strings_invert")->setEnabled(hasItems && !searchOnlyMode); @@ -553,7 +552,6 @@ void TDEFileReplacePart::initGUI() (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"); @@ -611,7 +609,6 @@ void TDEFileReplacePart::freezeActions() actionCollection()->action("strings_add")->setEnabled(false); actionCollection()->action("strings_del")->setEnabled(false); actionCollection()->action("strings_empty")->setEnabled(false); - actionCollection()->action("strings_edit")->setEnabled(false); actionCollection()->action("strings_save")->setEnabled(false); actionCollection()->action("strings_load")->setEnabled(false); actionCollection()->action("strings_invert")->setEnabled(false); diff --git a/tdefilereplace/tdefilereplacepartui.rc b/tdefilereplace/tdefilereplacepartui.rc index 7616165..ec38719 100644 --- a/tdefilereplace/tdefilereplacepartui.rc +++ b/tdefilereplace/tdefilereplacepartui.rc @@ -12,7 +12,6 @@ - @@ -63,10 +62,9 @@ - - - - + + + diff --git a/tdefilereplace/tdefilereplaceview.cpp b/tdefilereplace/tdefilereplaceview.cpp index e7bfd87..aa73fa8 100644 --- a/tdefilereplace/tdefilereplaceview.cpp +++ b/tdefilereplace/tdefilereplaceview.cpp @@ -68,8 +68,8 @@ TDEFileReplaceView::TDEFileReplaceView(RCOptions* info, TQWidget *parent,const c connect(m_lvResults_2->header(), TQT_SIGNAL(clicked(int)), this,TQT_SLOT(slotResultHeaderClicked(int))); // string listview: connect events - connect(m_lvStrings, TQT_SIGNAL(doubleClicked(TQListViewItem *)), this, TQT_SLOT(slotStringsEdit())); - connect(m_lvStrings_2, TQT_SIGNAL(doubleClicked(TQListViewItem *)), this, TQT_SLOT(slotStringsEdit())); + connect(m_lvStrings, TQT_SIGNAL(doubleClicked(TQListViewItem *)), this, TQT_SLOT(slotStringsAdd())); + connect(m_lvStrings_2, TQT_SIGNAL(doubleClicked(TQListViewItem *)), this, TQT_SLOT(slotStringsAdd())); whatsThis(); } @@ -390,25 +390,14 @@ void TDEFileReplaceView::slotResultHeaderClicked(int sortCol) void TDEFileReplaceView::slotStringsAdd() { - KeyValueMap oldMap(m_option->m_mapStringsView); - - KAddStringDlg addStringDlg(m_option, false); - + KAddStringDlg addStringDlg(m_option); if(!addStringDlg.exec()) + { return; - - KeyValueMap addedStringsMap(m_option->m_mapStringsView); - KeyValueMap::Iterator itMap; - - for(itMap = oldMap.begin(); itMap != oldMap.end(); ++itMap) - addedStringsMap.insert(itMap.key(),itMap.data()); - - m_option->m_mapStringsView = addedStringsMap; - + } raiseResultsView(); raiseStringsView(); - - loadMapIntoView(addedStringsMap); + loadMapIntoView(m_option->m_mapStringsView); emit updateGUI(); } @@ -437,42 +426,6 @@ void TDEFileReplaceView::slotQuickStringsAdd(const TQString& quickSearch, const } } -void TDEFileReplaceView::slotStringsEdit() -{ - KeyValueMap oldMap(m_option->m_mapStringsView); - if(oldMap.isEmpty()) return; - bool oldSearchFlagValue = m_option->m_searchingOnlyMode; - - oldMap.remove(m_sv->currentItem()->text(0)); - - m_option->m_mapStringsView.clear(); - - m_option->m_mapStringsView.insert(m_sv->currentItem()->text(0), m_sv->currentItem()->text(1)); - - KAddStringDlg addStringDlg(m_option, true); - - if(!addStringDlg.exec()) - return; - - KeyValueMap newMap(m_option->m_mapStringsView); - if(oldSearchFlagValue == m_option->m_searchingOnlyMode) - { - KeyValueMap::Iterator itMap; - - //merges the two maps - for(itMap = oldMap.begin(); itMap != oldMap.end(); ++itMap) - newMap.insert(itMap.key(),itMap.data()); - } - - m_option->m_mapStringsView = newMap; - - raiseResultsView(); - raiseStringsView(); - - loadMapIntoView(newMap); - emit updateGUI(); -} - void TDEFileReplaceView::slotStringsSave() { // Check there are strings in the list diff --git a/tdefilereplace/tdefilereplaceview.h b/tdefilereplace/tdefilereplaceview.h index b97b5af..36eaa9c 100644 --- a/tdefilereplace/tdefilereplaceview.h +++ b/tdefilereplace/tdefilereplaceview.h @@ -92,7 +92,6 @@ class TDEFileReplaceView : public TDEFileReplaceViewWdg void slotQuickStringsAdd(const TQString& quickSearch, const TQString& quickReplace); void slotStringsDeleteItem(); void slotStringsEmpty(); - void slotStringsEdit(); void slotStringsSave(); void slotStringsInvertCur(); void slotStringsInvertAll(); -- cgit v1.2.1