summaryrefslogtreecommitdiffstats
path: root/tdefilereplace
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2015-02-04 13:39:38 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2015-02-04 13:39:38 +0900
commit61424d335349e0611f1c017d0079553231f1c433 (patch)
tree44ef7d870f47b15097da2a428171b202f7f08d89 /tdefilereplace
parentc9fa04f0848147a4a5cc0210b6f2ed9f7ae8e3fd (diff)
downloadtdeutils-61424d335349e0611f1c017d0079553231f1c433.tar.gz
tdeutils-61424d335349e0611f1c017d0079553231f1c433.zip
Added support to remember search/replace strings used in TDEFileReplace. This resolves bug 2334.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdefilereplace')
-rw-r--r--tdefilereplace/configurationclasses.cpp2
-rw-r--r--tdefilereplace/configurationclasses.h4
-rw-r--r--tdefilereplace/knewprojectdlg.cpp75
-rw-r--r--tdefilereplace/knewprojectdlg.h4
-rw-r--r--tdefilereplace/knewprojectdlgs.ui74
-rw-r--r--tdefilereplace/tdefilereplacepart.cpp45
-rw-r--r--tdefilereplace/tdefilereplacepart.h4
7 files changed, 149 insertions, 59 deletions
diff --git a/tdefilereplace/configurationclasses.cpp b/tdefilereplace/configurationclasses.cpp
index 356d8c4..afc3d85 100644
--- a/tdefilereplace/configurationclasses.cpp
+++ b/tdefilereplace/configurationclasses.cpp
@@ -36,6 +36,8 @@ RCOptions& RCOptions::operator=(const RCOptions& ci)
{
//m_callResetActions = ci.m_callResetActions;
+ m_searchStrings = ci.m_searchStrings;
+ m_replaceStrings = ci.m_replaceStrings;
m_directories = ci.m_directories;
m_filters = ci.m_filters;
m_currentDirectory = ci.m_currentDirectory;
diff --git a/tdefilereplace/configurationclasses.h b/tdefilereplace/configurationclasses.h
index b42bb17..beaa275 100644
--- a/tdefilereplace/configurationclasses.h
+++ b/tdefilereplace/configurationclasses.h
@@ -26,6 +26,8 @@
typedef TQMap<TQString,TQString> KeyValueMap;
// entry strings in the tdefilereplacerc file
+const TQString rcSearchStringsList = "Search strings list";
+const TQString rcReplaceStringsList = "Replace strings list";
const TQString rcDirectoriesList = "Directories list";
const TQString rcFiltersList = "Filters list";
const TQString rcRecentFiles = "Recent files";
@@ -86,6 +88,8 @@ class RCOptions
bool m_askConfirmReplace,
m_dontAskAgain;
+ TQStringList m_searchStrings;
+ TQStringList m_replaceStrings;
TQStringList m_directories;
TQStringList m_filters;
TQString m_currentDirectory;
diff --git a/tdefilereplace/knewprojectdlg.cpp b/tdefilereplace/knewprojectdlg.cpp
index 372ba18..9ba6bbc 100644
--- a/tdefilereplace/knewprojectdlg.cpp
+++ b/tdefilereplace/knewprojectdlg.cpp
@@ -64,7 +64,7 @@ KNewProjectDlg::KNewProjectDlg(RCOptions* info, TQWidget *parent, const char *na
connect(m_pbCancel, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotReject()));
connect(m_pbSearchNow, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotSearchNow()));
connect(m_pbSearchLater, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotSearchLater()));
- connect(m_leSearch, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotSearchLineEdit(const TQString&)));
+ connect(m_cbSearch, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotSearchLineEdit(const TQString&)));
connect(m_chbSizeMin, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotEnableSpinboxSizeMin(bool)));
connect(m_chbSizeMax, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotEnableSpinboxSizeMax(bool)));
connect(m_chbDateMin, TQT_SIGNAL(toggled(bool)), m_dedDateMin, TQT_SLOT(setEnabled(bool)));
@@ -89,7 +89,7 @@ void KNewProjectDlg::saveRCOptions()
saveFileSizeOptions();
saveDateAccessOptions();
saveOwnerOptions();
- saveLocationsList();
+ saveCBLists();
saveFiltersList();
saveBackupExtensionOptions();
}
@@ -104,19 +104,17 @@ void KNewProjectDlg::slotDir()
void KNewProjectDlg::slotOK()
{
// Check that Search text and Filter are not empty
- m_option->m_directories = m_cbLocation->currentText();
- m_option->m_filters = m_cbFilter->currentText();
- if(!m_leSearch->text().isEmpty())
+ if(!m_cbSearch->currentText().isEmpty())
{
- if(m_leReplace->text().isEmpty())
+ if(m_cbReplace->currentText().isEmpty())
m_option->m_searchingOnlyMode = true;
else
m_option->m_searchingOnlyMode = false;
}
- m_option->m_quickSearchString = m_searchNowFlag + m_leSearch->text();
- m_option->m_quickReplaceString = m_searchNowFlag + m_leReplace->text();
+ m_option->m_quickSearchString = m_searchNowFlag + m_cbSearch->currentText();
+ m_option->m_quickReplaceString = m_searchNowFlag + m_cbReplace->currentText();
- if (m_option->m_directories.isEmpty() || m_option->m_filters.isEmpty())
+ if (m_cbLocation->currentText().isEmpty() || m_cbFilter->currentText().isEmpty())
{
KMessageBox::error(this, i18n("You must fill the combo boxes (location and filter) before continuing."));
return;
@@ -166,6 +164,7 @@ void KNewProjectDlg::slotSearchLater()
void KNewProjectDlg::slotSearchLineEdit(const TQString& t)
{
m_pbSearchNow->setEnabled(!t.isEmpty());
+ m_pbSearchLater->setEnabled(!t.isEmpty());
}
void KNewProjectDlg::slotEnableSpinboxSizeMin(bool b)
@@ -225,16 +224,17 @@ void KNewProjectDlg::initGUI()
m_pbLocation->setFixedSize(pixMap.width() + 8, pixMap.height() + 8);
m_pbSearchNow->setEnabled(false);
+ m_pbSearchLater->setEnabled(false);
loadOptions();
loadFileSizeOptions();
loadDateAccessOptions();
loadOwnerOptions();
loadBackupExtensionOptions();
- loadLocationsList();
+ loadCBLists();
loadFiltersList();
- m_leSearch->setFocus();
+ m_cbSearch->setFocus();
}
void KNewProjectDlg::loadOptions()
@@ -363,8 +363,10 @@ void KNewProjectDlg::loadOwnerOptions()
m_edOwnerGroup->setText(m_option->m_ownerGroupValue);
}
-void KNewProjectDlg::loadLocationsList()
+void KNewProjectDlg::loadCBLists()
{
+ m_cbSearch->insertStringList(m_option->m_searchStrings);
+ m_cbReplace->insertStringList(m_option->m_replaceStrings);
m_cbLocation->insertStringList(m_option->m_directories);
}
@@ -467,20 +469,43 @@ void KNewProjectDlg::saveOwnerOptions()
}
}
-void KNewProjectDlg::saveLocationsList()
+void KNewProjectDlg::saveCBLists()
{
- TQString current = m_cbLocation->currentText();
- TQStringList list = current;
-
- int count = m_cbLocation->listBox()->count(),
- i;
- for(i = 0; i < count; i++)
+ // Search list
+ TQString current = m_cbSearch->currentText();
+ m_option->m_searchStrings.clear();
+ m_option->m_searchStrings.append(current);
+ int count = m_cbSearch->listBox()->count();
+ for (int i = 0; i < count; ++i)
{
- TQString text = m_cbLocation->listBox()->item(i)->text();
- if(text != current)
- list.append(text);
+ TQString text = m_cbSearch->listBox()->item(i)->text();
+ if (text != "" && text != current)
+ m_option->m_searchStrings.append(text);
+ }
+
+ // Replace list
+ current = m_cbReplace->currentText();
+ m_option->m_replaceStrings.clear();
+ m_option->m_replaceStrings.append(current);
+ count = m_cbReplace->listBox()->count();
+ for (int i = 0; i < count; ++i)
+ {
+ TQString text = m_cbReplace->listBox()->item(i)->text();
+ if (text != "" && text != current)
+ m_option->m_replaceStrings.append(text);
+ }
+
+ // Location list
+ current = m_cbLocation->currentText();
+ m_option->m_directories.clear();
+ m_option->m_directories.append(current);
+ count = m_cbLocation->listBox()->count();
+ for (int i = 0; i < count; ++i)
+ {
+ TQString text = m_cbLocation->listBox()->item(i)->text();
+ if (text != "" && text != current)
+ m_option->m_directories.append(text);
}
- m_option->m_directories = list;
}
void KNewProjectDlg::saveFiltersList()
@@ -549,8 +574,8 @@ void KNewProjectDlg::whatsThis()
TQWhatsThis::add(m_chbCaseSensitive, chbCaseSensitiveWhatthis);
TQWhatsThis::add(m_chbBackup, chbBackupWhatthis);
TQWhatsThis::add(m_leBackup, chbBackupWhatthis);
- TQWhatsThis::add(m_leSearch, leSearchWhatthis);
- TQWhatsThis::add(m_leReplace, leReplaceWhatthis);
+ TQWhatsThis::add(m_cbSearch, leSearchWhatthis);
+ TQWhatsThis::add(m_cbReplace, leReplaceWhatthis);
}
#include "knewprojectdlg.moc"
diff --git a/tdefilereplace/knewprojectdlg.h b/tdefilereplace/knewprojectdlg.h
index 82e08ad..82d2212 100644
--- a/tdefilereplace/knewprojectdlg.h
+++ b/tdefilereplace/knewprojectdlg.h
@@ -67,7 +67,7 @@ class KNewProjectDlg : public KNewProjectDlgS
void loadFileSizeOptions();
void loadDateAccessOptions();
void loadOwnerOptions();
- void loadLocationsList();
+ void loadCBLists();
void loadFiltersList();
void loadBackupExtensionOptions();
@@ -75,7 +75,7 @@ class KNewProjectDlg : public KNewProjectDlgS
void saveFileSizeOptions();
void saveDateAccessOptions();
void saveOwnerOptions();
- void saveLocationsList();
+ void saveCBLists();
void saveFiltersList();
void saveBackupExtensionOptions();
diff --git a/tdefilereplace/knewprojectdlgs.ui b/tdefilereplace/knewprojectdlgs.ui
index 3f32b6f..d292814 100644
--- a/tdefilereplace/knewprojectdlgs.ui
+++ b/tdefilereplace/knewprojectdlgs.ui
@@ -200,7 +200,7 @@
<number>20</number>
</property>
<property name="maxCount">
- <number>10</number>
+ <number>20</number>
</property>
<property name="insertionPolicy">
<enum>AtTop</enum>
@@ -319,15 +319,67 @@
<property name="name">
<cstring>unnamed</cstring>
</property>
- <widget class="TQLineEdit" row="0" column="1">
- <property name="name">
- <cstring>m_leSearch</cstring>
- </property>
+ <widget class="TQComboBox" row="0" column="1">
+ <property name="name">
+ <cstring>m_cbSearch</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="sizeLimit">
+ <number>20</number>
+ </property>
+ <property name="maxCount">
+ <number>20</number>
+ </property>
+ <property name="insertionPolicy">
+ <enum>AtTop</enum>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Insert a search string here.</string>
+ </property>
</widget>
- <widget class="TQLineEdit" row="1" column="1">
- <property name="name">
- <cstring>m_leReplace</cstring>
- </property>
+ <widget class="TQComboBox" row="1" column="1">
+ <property name="name">
+ <cstring>m_cbReplace</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="sizeLimit">
+ <number>20</number>
+ </property>
+ <property name="maxCount">
+ <number>20</number>
+ </property>
+ <property name="insertionPolicy">
+ <enum>AtTop</enum>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Insert a search string here.</string>
+ </property>
</widget>
<widget class="TQLabel" row="0" column="0">
<property name="name">
@@ -901,8 +953,8 @@
</widget>
<tabstops>
<tabstop>tabWidget2</tabstop>
- <tabstop>m_leSearch</tabstop>
- <tabstop>m_leReplace</tabstop>
+ <tabstop>m_cbSearch</tabstop>
+ <tabstop>m_cbReplace</tabstop>
<tabstop>m_cbLocation</tabstop>
<tabstop>m_pbLocation</tabstop>
<tabstop>m_cbFilter</tabstop>
diff --git a/tdefilereplace/tdefilereplacepart.cpp b/tdefilereplace/tdefilereplacepart.cpp
index f9aec23..69aee28 100644
--- a/tdefilereplace/tdefilereplacepart.cpp
+++ b/tdefilereplace/tdefilereplacepart.cpp
@@ -679,7 +679,7 @@ void TDEFileReplacePart::loadOptionsFromRC()
loadFileSizeOptions();
loadDateAccessOptions();
loadOwnerOptions();
- loadLocationsList();
+ loadCBLists();
loadFiltersList();
loadBackupExtensionOptions();
}
@@ -764,20 +764,21 @@ void TDEFileReplacePart::loadOwnerOptions()
m_option->m_ownerGroupValue = ownerList[3];
}
-void TDEFileReplacePart::loadLocationsList()
+void TDEFileReplacePart::loadCBLists()
{
+ // Search list
+ m_config->setGroup("Search strings");
+ m_option->m_searchStrings = m_config->readPathListEntry(rcSearchStringsList);
+
+ // Replace list
+ m_config->setGroup("Replace strings");
+ m_option->m_replaceStrings = m_config->readPathListEntry(rcReplaceStringsList);
+
+ // Location list
m_config->setGroup("Directories");
- TQStringList locationsEntryList;
- #if KDE_IS_VERSION(3,1,3)
- locationsEntryList = m_config->readPathListEntry(rcDirectoriesList);
- #else
- locationsEntryList = m_config->readListEntry(rcDirectoriesList);
- #endif
-
- if(locationsEntryList.isEmpty())
- locationsEntryList.append(TQDir::current().path());
-
- m_option->m_directories = locationsEntryList;
+ m_option->m_directories = m_config->readPathListEntry(rcDirectoriesList);
+ if (m_option->m_directories.isEmpty())
+ m_option->m_directories.append(TQDir::current().path());
}
void TDEFileReplacePart::loadFiltersList()
@@ -817,7 +818,7 @@ void TDEFileReplacePart::saveOptionsToRC()
saveFileSizeOptions();
saveDateAccessOptions();
saveOwnerOptions();
- saveLocationsList();
+ saveCBLists();
saveFiltersList();
saveBackupExtensionOptions();
}
@@ -909,14 +910,20 @@ void TDEFileReplacePart::saveOwnerOptions()
m_config->sync();
}
-void TDEFileReplacePart::saveLocationsList()
+void TDEFileReplacePart::saveCBLists()
{
+ // Search list
+ m_config->setGroup("Search strings");
+ m_config->writePathEntry(rcSearchStringsList, m_option->m_searchStrings);
+
+ // Replace list
+ m_config->setGroup("Replace strings");
+ m_config->writePathEntry(rcReplaceStringsList, m_option->m_replaceStrings);
+
+ // Location list
m_config->setGroup("Directories");
- #if KDE_IS_VERSION(3,1,3)
m_config->writePathEntry(rcDirectoriesList, m_option->m_directories);
- #else
- m_config->writeEntry(rcDirectoriesList, m_option->m_directories);
- #endif
+
m_config->sync();
}
diff --git a/tdefilereplace/tdefilereplacepart.h b/tdefilereplace/tdefilereplacepart.h
index 27ad916..45064f7 100644
--- a/tdefilereplace/tdefilereplacepart.h
+++ b/tdefilereplace/tdefilereplacepart.h
@@ -114,7 +114,7 @@ class TDEFileReplacePart: public KParts::ReadOnlyPart
void loadFileSizeOptions();
void loadDateAccessOptions();
void loadOwnerOptions();
- void loadLocationsList();
+ void loadCBLists();
void loadFiltersList();
void loadBackupExtensionOptions();
@@ -126,7 +126,7 @@ class TDEFileReplacePart: public KParts::ReadOnlyPart
void saveFileSizeOptions();
void saveDateAccessOptions();
void saveOwnerOptions();
- void saveLocationsList();
+ void saveCBLists();
void saveFiltersList();
void saveBackupExtensionOptions();