summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tdefilereplace/tdefilereplacelib.cpp25
-rw-r--r--tdefilereplace/tdefilereplacelib.h8
-rw-r--r--tdefilereplace/tdefilereplacepart.cpp71
-rw-r--r--tdefilereplace/tdefilereplacepartui.rc6
-rw-r--r--tdefilereplace/tdefilereplaceview.cpp303
-rw-r--r--tdefilereplace/tdefilereplaceview.h7
-rw-r--r--tdefilereplace/tdefilereplaceviewwdg.ui4
7 files changed, 277 insertions, 147 deletions
diff --git a/tdefilereplace/tdefilereplacelib.cpp b/tdefilereplace/tdefilereplacelib.cpp
index 4246fc8..90c8ef4 100644
--- a/tdefilereplace/tdefilereplacelib.cpp
+++ b/tdefilereplace/tdefilereplacelib.cpp
@@ -64,31 +64,6 @@ TQString TDEFileReplaceLib::formatFullPath(const TQString& basePath, const TQStr
return fullPath;
}
-/**
- Add an extension to a filename, or a filepath
- Parameters::.....* fileName: filename or filepath (it can have already the extension)
- .................* extension: extension to add without "." (ex: "html", "kfr")
- Return values:...* Filename / Filepath with the extension
-*/
-TQString TDEFileReplaceLib::addExtension(const TQString& fileName, const TQString& extension)
-{
- TQString fullExtension = ".";
- TQString fname = fileName;
-
- fullExtension.append(extension);
-
- // filename cannot contain ".ext" ==> Add it
- if(fname.length() <= fullExtension.length())
- fname.append(fullExtension);
- else // filename can contain ".ext"
- {
- if (fname.right(fullExtension.length()) != fullExtension)
- fname.append(fullExtension);
- }
-
- return fname;
-}
-
TQString TDEFileReplaceLib::formatFileSize(double size)
{
TQString stringSize;
diff --git a/tdefilereplace/tdefilereplacelib.h b/tdefilereplace/tdefilereplacelib.h
index b0273ac..45dd0a4 100644
--- a/tdefilereplace/tdefilereplacelib.h
+++ b/tdefilereplace/tdefilereplacelib.h
@@ -40,14 +40,6 @@ class TDEFileReplaceLib
*/
static TQString formatFullPath(const TQString& basePath, const TQString& fileName);
- /**
- Add an extension to a filename, or a filepath
- Parameters::.....* filename: filename or filepath (it can have already the extension)
- .................* extension: extension to add without "." (ex: "html", "kfr")
- Return values:...* Filename / Filepath with the extension
- */
- static TQString addExtension(const TQString& fileName, const TQString& extension);
-
static TQString formatFileSize(double size);
/**
diff --git a/tdefilereplace/tdefilereplacepart.cpp b/tdefilereplace/tdefilereplacepart.cpp
index 766366f..c193573 100644
--- a/tdefilereplace/tdefilereplacepart.cpp
+++ b/tdefilereplace/tdefilereplacepart.cpp
@@ -102,7 +102,7 @@ TDEFileReplacePart::~TDEFileReplacePart()
void TDEFileReplacePart::slotSetNewParameters()
{
launchNewProjectDialog(KURL());
- m_view->changeView(m_option->m_searchingOnlyMode);
+ m_view->changeViews(m_option->m_searchingOnlyMode);
emit setStatusBarText(i18n("Ready."));
}
@@ -388,28 +388,28 @@ void TDEFileReplacePart::reportBug()
void TDEFileReplacePart::updateGUI()
{
- TDEListView* rv = m_view->getResultsView(),
- * sv = m_view->getStringsView();
+ TDEListView *rv = m_view->getResultsView();
+ TDEListView *sv = m_view->getStringsView();
- bool hasItems = (sv->firstChild() != 0),
- searchOnlyMode = m_option->m_searchingOnlyMode;
+ bool hasResults = (rv->firstChild() != 0);
+ bool hasStrings = (sv->firstChild() != 0);
+ bool searchOnlyMode = m_option->m_searchingOnlyMode;
// File
actionCollection()->action("new_project")->setEnabled(true);
- actionCollection()->action("search")->setEnabled(hasItems && searchOnlyMode);
- actionCollection()->action("file_simulate")->setEnabled(hasItems && !searchOnlyMode);
- actionCollection()->action("replace")->setEnabled(hasItems && !searchOnlyMode);
- actionCollection()->action("save_results")->setEnabled(hasItems);
+ actionCollection()->action("search")->setEnabled(hasStrings && searchOnlyMode);
+ actionCollection()->action("file_simulate")->setEnabled(hasStrings && !searchOnlyMode);
+ actionCollection()->action("replace")->setEnabled(hasStrings && !searchOnlyMode);
actionCollection()->action("stop")->setEnabled(false);
// Strings
actionCollection()->action("strings_add")->setEnabled(true);
- actionCollection()->action("strings_del")->setEnabled(hasItems);
- actionCollection()->action("strings_empty")->setEnabled(hasItems);
- actionCollection()->action("strings_save")->setEnabled(hasItems);
+ actionCollection()->action("strings_del")->setEnabled(hasStrings);
+ actionCollection()->action("strings_empty")->setEnabled(hasStrings);
+ actionCollection()->action("strings_save")->setEnabled(hasStrings);
actionCollection()->action("strings_load")->setEnabled(true);
- actionCollection()->action("strings_invert")->setEnabled(hasItems && !searchOnlyMode);
- actionCollection()->action("strings_invert_all")->setEnabled(hasItems && !searchOnlyMode);
+ actionCollection()->action("strings_invert")->setEnabled(hasStrings && !searchOnlyMode);
+ actionCollection()->action("strings_invert_all")->setEnabled(hasStrings && !searchOnlyMode);
// Options
actionCollection()->action("options_recursive")->setEnabled(true);
@@ -419,34 +419,35 @@ void TDEFileReplacePart::updateGUI()
actionCollection()->action("options_regularexpressions")->setEnabled(true);
actionCollection()->action("configure_tdefilereplace")->setEnabled(true);
- hasItems = (rv->firstChild() != 0);
-
// Results
- actionCollection()->action("results_infos")->setEnabled(hasItems);
- actionCollection()->action("results_openfile")->setEnabled(hasItems);
- actionCollection()->action("results_openfilewith")->setEnabled(hasItems);
+ actionCollection()->action("results_infos")->setEnabled(hasResults);
+ actionCollection()->action("results_openfile")->setEnabled(hasResults);
+ actionCollection()->action("results_openfilewith")->setEnabled(hasResults);
if (actionCollection()->action("results_editfile"))
{
- actionCollection()->action("results_editfile")->setEnabled(hasItems);
+ actionCollection()->action("results_editfile")->setEnabled(hasResults);
}
- actionCollection()->action("results_opendir")->setEnabled(hasItems);
- actionCollection()->action("results_removeentry")->setEnabled(hasItems);
- actionCollection()->action("results_delete")->setEnabled(hasItems);
- actionCollection()->action("results_treeexpand")->setEnabled(hasItems);
- actionCollection()->action("results_treereduce")->setEnabled(hasItems);
+ actionCollection()->action("results_opendir")->setEnabled(hasResults);
+ actionCollection()->action("results_removeentry")->setEnabled(hasResults);
+ actionCollection()->action("results_delete")->setEnabled(hasResults);
+ actionCollection()->action("results_treeexpand")->setEnabled(hasResults);
+ actionCollection()->action("results_treereduce")->setEnabled(hasResults);
+ actionCollection()->action("results_create_report")->setEnabled(hasResults);
+ actionCollection()->action("results_save")->setEnabled(hasResults);
+ actionCollection()->action("results_load")->setEnabled(true);
// Updates menus and toolbar
- ((TDEToggleAction* ) actionCollection()->action("options_recursive"))->setChecked(m_option->m_recursive);
- ((TDEToggleAction* ) actionCollection()->action("options_backup"))->setChecked(m_option->m_backup && !searchOnlyMode);
- ((TDEToggleAction* ) actionCollection()->action("options_case"))->setChecked(m_option->m_caseSensitive);
- ((TDEToggleAction* ) actionCollection()->action("options_var"))->setChecked(m_option->m_variables && !searchOnlyMode);
- ((TDEToggleAction* ) actionCollection()->action("options_regularexpressions"))->setChecked(m_option->m_regularExpressions);
+ ((TDEToggleAction*) actionCollection()->action("options_recursive"))->setChecked(m_option->m_recursive);
+ ((TDEToggleAction*) actionCollection()->action("options_backup"))->setChecked(m_option->m_backup && !searchOnlyMode);
+ ((TDEToggleAction*) actionCollection()->action("options_case"))->setChecked(m_option->m_caseSensitive);
+ ((TDEToggleAction*) actionCollection()->action("options_var"))->setChecked(m_option->m_variables && !searchOnlyMode);
+ ((TDEToggleAction*) actionCollection()->action("options_regularexpressions"))->setChecked(m_option->m_regularExpressions);
}
//PUBLIC METHODS
TDEAboutData* TDEFileReplacePart::createAboutData()
{
- TDEAboutData * aboutData = new TDEAboutData("tdefilereplacepart",
+ TDEAboutData *aboutData = new TDEAboutData("tdefilereplacepart",
I18N_NOOP("TDEFileReplacePart"),
KFR_VERSION,
I18N_NOOP( "Batch search and replace tool."),
@@ -513,7 +514,9 @@ void TDEFileReplacePart::initGUI()
(void)new TDEAction(i18n("S&imulate"), "filesimulate", 0, TQT_TQOBJECT(this), TQT_SLOT(slotSimulatingOperation()), actionCollection(), "file_simulate");
(void)new TDEAction(i18n("&Replace"), "filereplace", 0, TQT_TQOBJECT(this), TQT_SLOT(slotReplacingOperation()), actionCollection(), "replace");
(void)new TDEAction(i18n("Sto&p"), "process-stop", 0, TQT_TQOBJECT(this), TQT_SLOT(slotStop()), actionCollection(), "stop");
- (void)new TDEAction(i18n("Cre&ate Report File..."), "document-save-as", 0, TQT_TQOBJECT(this), TQT_SLOT(slotCreateReport()), actionCollection(), "save_results");
+ (void)new TDEAction(i18n("Cre&ate Report File..."), "document-save-as", 0, TQT_TQOBJECT(this), TQT_SLOT(slotCreateReport()), actionCollection(), "results_create_report");
+ (void)new TDEAction(i18n("&Save Results List to File..."), "document-save-as", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultSave()), actionCollection(), "results_save");
+ (void)new TDEAction(i18n("&Load Results List From File..."), "unsortedList", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultLoad()), actionCollection(), "results_load");
// Strings
(void)new TDEAction(i18n("&Add String..."), "editadd", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotStringsAdd()), actionCollection(), "strings_add");
@@ -1392,7 +1395,7 @@ void TDEFileReplacePart::search(const TQString& currentDir, const TQString& file
else
capturedText = line.mid(pos,strKey.length());
- msg = i18n(" Line:%2, Col:%3 - \"%1\"").arg(capturedText).arg(TQString::number(lineNumber,10)).arg(TQString::number(columnNumber,10));
+ msg = i18n("Line:%2, Col:%3 - \"%1\"").arg(capturedText).arg(TQString::number(lineNumber,10)).arg(TQString::number(columnNumber,10));
tempItem->setMultiLinesEnabled(true);
tempItem->setText(0,msg);
occurrence = 1;
@@ -1432,7 +1435,7 @@ void TDEFileReplacePart::search(const TQString& currentDir, const TQString& file
pos = line.find(strKey,pos+strKey.length());
}
- msg = i18n(" Line:%2, Col:%3 - \"%1\"").arg(capturedText).arg(TQString::number(lineNumber,10)).arg(TQString::number(columnNumber,10));
+ msg = i18n("Line:%2, Col:%3 - \"%1\"").arg(capturedText).arg(TQString::number(lineNumber,10)).arg(TQString::number(columnNumber,10));
if(!item)
item = new TDEListViewItem(rv);
diff --git a/tdefilereplace/tdefilereplacepartui.rc b/tdefilereplace/tdefilereplacepartui.rc
index 414fe26..4779bd7 100644
--- a/tdefilereplace/tdefilereplacepartui.rc
+++ b/tdefilereplace/tdefilereplacepartui.rc
@@ -1,5 +1,5 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="tdefilereplace" version="7">
+<kpartgui name="tdefilereplace" version="8">
<MenuBar>
<Menu name="tdefilerepace"><text>Search/&amp;Replace</text>
<Action name="new_project"/>
@@ -28,7 +28,9 @@
<Action name="results_delete"/>
<Action name="results_infos"/>
<Separator/>
- <Action name="save_results"/>
+ <Action name="results_create_report"/>
+ <Action name="results_save"/>
+ <Action name="results_load"/>
<Separator/>
<Action name="results_treeexpand"/>
<Action name="results_treereduce"/>
diff --git a/tdefilereplace/tdefilereplaceview.cpp b/tdefilereplace/tdefilereplaceview.cpp
index ca6587f..9e41d7a 100644
--- a/tdefilereplace/tdefilereplaceview.cpp
+++ b/tdefilereplace/tdefilereplaceview.cpp
@@ -168,27 +168,36 @@ void TDEFileReplaceView::stringsInvert(bool invertAll)
emit updateGUI();
}
-void TDEFileReplaceView::changeView(bool searchingOnlyMode)
+void TDEFileReplaceView::changeViews()
{
- if(searchingOnlyMode)
- {
- m_stackResults->raiseWidget(m_lvResults_2);
- m_stackStrings->raiseWidget(m_lvStrings_2);
- m_rv = m_lvResults_2;
- m_sv = m_lvStrings_2;
- }
+ changeViews(m_option->m_searchingOnlyMode);
+}
+
+void TDEFileReplaceView::changeViews(bool searchingOnlyMode)
+{
+ if (searchingOnlyMode)
+ {
+ m_stackResults->raiseWidget(m_lvResults_2);
+ m_stackStrings->raiseWidget(m_lvStrings_2);
+ m_rv = m_lvResults_2;
+ m_sv = m_lvStrings_2;
+ m_lvResults->clear();
+ m_lvStrings->clear();
+ }
else
- {
- m_stackResults->raiseWidget(m_lvResults);
- m_stackStrings->raiseWidget(m_lvStrings);
- m_rv = m_lvResults;
- m_sv = m_lvStrings;
- }
+ {
+ m_stackResults->raiseWidget(m_lvResults);
+ m_stackStrings->raiseWidget(m_lvStrings);
+ m_rv = m_lvResults;
+ m_sv = m_lvStrings;
+ m_lvResults_2->clear();
+ m_lvStrings_2->clear();
+ }
}
TDEListView* TDEFileReplaceView::getResultsView()
{
- if(m_option->m_searchingOnlyMode)
+ if (m_option->m_searchingOnlyMode)
m_rv = m_lvResults_2;
else
m_rv = m_lvResults;
@@ -198,7 +207,7 @@ TDEListView* TDEFileReplaceView::getResultsView()
TDEListView* TDEFileReplaceView::getStringsView()
{
- if(m_option->m_searchingOnlyMode)
+ if (m_option->m_searchingOnlyMode)
m_sv = m_lvStrings_2;
else
m_sv = m_lvStrings;
@@ -315,9 +324,10 @@ void TDEFileReplaceView::slotResultRemoveEntry()
{
TQListViewItem *currItem = getCurrItemTopLevelParent();
if (currItem)
- {
- delete currItem;
- }
+ {
+ delete currItem;
+ }
+ emit updateGUI();
}
void TDEFileReplaceView::slotResultDelete()
@@ -337,6 +347,7 @@ void TDEFileReplaceView::slotResultDelete()
delete currItem;
}
}
+ emit updateGUI();
}
void TDEFileReplaceView::slotResultTreeExpand()
@@ -355,6 +366,175 @@ void TDEFileReplaceView::slotResultTreeReduce()
expand(lviRoot, false);
}
+void TDEFileReplaceView::slotResultLoad()
+{
+ // Selects the file to load from
+ TQString menu = "*.tfr_results|" + i18n("TDEFileReplace Results") + " (*.tfr_results)\n*|" + i18n("All Files") + " (*)";
+ TQString fileName = KFileDialog::getOpenFileName(TQString(), menu, this, i18n("Load Results From File"));
+ if (fileName.isEmpty())
+ {
+ return;
+ }
+
+ // Creates a xml document and browses it
+ TQDomDocument doc("results");
+ TQFile file(fileName);
+ if (!file.open(IO_ReadOnly))
+ {
+ KMessageBox::error(this, i18n("<qt>Cannot open the file <b>%1</b> and load the results list.</qt>").arg(fileName));
+ return;
+ }
+
+ if (!doc.setContent(&file))
+ {
+ file.close();
+
+ KMessageBox::information(this, i18n("<qt>File <b>%1</b> seems not to be valid.</qt>").arg(fileName), i18n("Warning"));
+ return;
+ }
+ else
+ {
+ file.close();
+ }
+
+ TQDomElement docElem = doc.documentElement();
+ TQDomNode tln = docElem.firstChild(); // top level node
+ TQString searchAttribute = tln.toElement().attribute("search");
+ if (searchAttribute.isNull() || searchAttribute.isEmpty())
+ {
+ int answer = KMessageBox::warningYesNo(this, i18n("<qt>Missing search type. Is this a search-and-replace list of results?</qt>").arg(fileName),i18n("Warning"),i18n("Yes"),i18n("No"));
+ if (answer == KMessageBox::Yes)
+ {
+ m_option->m_searchingOnlyMode = false;
+ }
+ else
+ {
+ m_option->m_searchingOnlyMode = true;
+ }
+ }
+ else
+ {
+ m_option->m_searchingOnlyMode = (searchAttribute == "true");
+ }
+ changeViews();
+
+ // Clears view
+ TDEListView *rv = getResultsView();
+ rv->clear();
+
+ // Reads the result list
+ KeyValueMap docMap;
+ tln = tln.nextSibling();
+ if (!tln.isNull())
+ {
+ tln = tln.firstChild();
+ }
+ while (!tln.isNull())
+ {
+ TQDomElement fileEle = tln.toElement();
+ if (!fileEle.isNull())
+ {
+ TDEListViewItem *fileItem = new TDEListViewItem(rv);
+ fileItem->setText(0, fileEle.attribute("name", "!ERROR!"));
+ fileItem->setText(1, fileEle.attribute("folder"));
+ if (m_option->m_searchingOnlyMode)
+ {
+ fileItem->setText(2, fileEle.attribute("size"));
+ fileItem->setText(3, fileEle.attribute("matches"));
+ fileItem->setText(4, fileEle.attribute("user"));
+ fileItem->setText(5, fileEle.attribute("group"));
+ }
+ else
+ {
+ fileItem->setText(2, fileEle.attribute("old_size"));
+ fileItem->setText(3, fileEle.attribute("new_size"));
+ fileItem->setText(4, fileEle.attribute("matches"));
+ fileItem->setText(5, fileEle.attribute("user"));
+ fileItem->setText(6, fileEle.attribute("group"));
+ }
+ TQDomNode lineNode = fileEle.firstChild();
+ while (!lineNode.isNull())
+ {
+ TQDomElement lineEle = lineNode.toElement();
+ TDEListViewItem *lineItem = new TDEListViewItem(fileItem);
+ lineItem->setText(0, lineEle.text());
+ lineNode = lineNode.nextSibling();
+ }
+ }
+ tln = tln.nextSibling();
+ }
+
+ emit updateGUI();
+}
+
+void TDEFileReplaceView::slotResultSave()
+{
+ // Check there are results in the list
+ TDEListView *rv = getResultsView();
+ if (!rv->firstChild())
+ {
+ KMessageBox::error(0, i18n("There are no results to save."));
+ return;
+ }
+
+ // Selects the file where results will be saved
+ TQString menu = "*.tfr_results|" + i18n("TDEFileReplace Results") + " (*.tfr_results)\n*|" + i18n("All Files") + " (*)";
+ TQString fileName = KFileDialog::getSaveFileName(TQString(), menu, this, i18n("Save Results to File"));
+ if (fileName.isEmpty())
+ {
+ return;
+ }
+
+ TQFile file(fileName);
+ if (!file.open(IO_WriteOnly))
+ {
+ KMessageBox::error(0, i18n("File %1 cannot be saved.").arg(fileName));
+ return;
+ }
+ TQTextStream filestream(&file);
+ filestream.setEncoding(TQTextStream::UnicodeUTF8);
+
+ filestream << "<?xml version=\"1.0\" ?>\n<kfr>\n";
+ if (m_option->m_searchingOnlyMode)
+ {
+ filestream << "\t<mode search=\"true\"/>\n";
+ }
+ else
+ {
+ filestream << "\t<mode search=\"false\"/>\n";
+ }
+ filestream << "\t<results>\n";
+
+ TQListViewItem *lvi = rv->firstChild();
+ while (lvi)
+ {
+ // File
+ filestream << TQString("\t\t<file name=\"%1\" folder=\"%2\" ").arg(lvi->text(0)).arg(lvi->text(1));
+ if (m_option->m_searchingOnlyMode)
+ {
+ filestream << TQString("size=\"%1\" matches=\"%2\" user=\"%3\" group=\"%4\">\n")
+ .arg(lvi->text(2)).arg(lvi->text(3)).arg(lvi->text(4)).arg(lvi->text(5));
+ }
+ else
+ {
+ filestream << TQString("old_size=\"%1\" new_size=\"%2\" matches=\"%3\" user=\"%4\" group=\"%5\">\n")
+ .arg(lvi->text(2)).arg(lvi->text(3)).arg(lvi->text(4)).arg(lvi->text(5)).arg(lvi->text(6));
+ }
+ // File entries
+ TQListViewItem *lvsubi = lvi->firstChild();
+ while (lvsubi)
+ {
+ filestream << TQString("\t\t\t<line>%1</line>\n").arg(lvsubi->text(0));
+ lvsubi = lvsubi->nextSibling();
+ }
+ filestream << "\t\t</file>\n";
+ lvi = lvi->nextSibling();
+ }
+
+ filestream << "\t</results>\n</kfr>\n";
+ file.close();
+}
+
void TDEFileReplaceView::slotResultHeaderClicked(int sortCol)
{
TDEListView *lv = getResultsView();
@@ -377,8 +557,7 @@ void TDEFileReplaceView::slotStringsAdd()
{
return;
}
- raiseResultsView();
- raiseStringsView();
+ changeViews();
loadMapIntoView(m_option->m_mapStringsView);
emit updateGUI();
}
@@ -401,9 +580,7 @@ void TDEFileReplaceView::slotQuickStringsAdd(const TQString& quickSearch, const
m_option->m_mapStringsView = map;
- raiseResultsView();
- raiseStringsView();
-
+ changeViews();
loadMapIntoView(map);
}
}
@@ -418,17 +595,16 @@ void TDEFileReplaceView::slotStringsLoad()
return;
}
- // Loads a file with kfr extension, creates a xml document and browses it
- TQDomDocument doc("mydocument");
+ // Creates a xml document and browses it
+ TQDomDocument doc("strings");
TQFile file(fileName);
- TDEListView *sv = getStringsView();
if (!file.open(IO_ReadOnly))
{
KMessageBox::error(this, i18n("<qt>Cannot open the file <b>%1</b> and load the string list.</qt>").arg(fileName));
return;
}
- if(!doc.setContent(&file))
+ if (!doc.setContent(&file))
{
file.close();
@@ -440,12 +616,9 @@ void TDEFileReplaceView::slotStringsLoad()
file.close();
}
- //clears view
- sv->clear();
-
TQDomElement docElem = doc.documentElement();
TQDomNode n = docElem.firstChild();
- TQString searchAttribute = n.toElement().attribute("search").latin1();
+ TQString searchAttribute = n.toElement().attribute("search");
if (searchAttribute.isNull() || searchAttribute.isEmpty())
{
int answer = KMessageBox::warningYesNo(this, i18n("<qt>Missing search type. Is this a search-and-replace list of strings?</qt>").arg(fileName),i18n("Warning"),i18n("Yes"),i18n("No"));
@@ -458,16 +631,22 @@ void TDEFileReplaceView::slotStringsLoad()
m_option->m_searchingOnlyMode = true;
}
}
+ else
+ {
+ m_option->m_searchingOnlyMode = (searchAttribute == "true");
+ }
+ changeViews();
- // Refreshes the view appearances
- changeView(m_option->m_searchingOnlyMode);
+ // Clears view
+ TDEListView *sv = getStringsView();
+ sv->clear();
// Reads the string list
KeyValueMap docMap;
n = n.nextSibling();
while (!n.isNull())
{
- TQDomElement e = n.toElement(); // tries to convert the node to an element.
+ TQDomElement e = n.toElement();
if (!e.isNull())
{
TQString searchString = e.firstChild().toElement().text();
@@ -476,8 +655,6 @@ void TDEFileReplaceView::slotStringsLoad()
}
n = n.nextSibling();
}
-
- changeView(m_option->m_searchingOnlyMode);
loadMap(docMap);
emit updateGUI();
@@ -493,6 +670,21 @@ void TDEFileReplaceView::slotStringsSave()
return;
}
+ // Selects the file where strings will be saved
+ TQString menu = "*.kfr|" + i18n("TDEFileReplace Strings") + " (*.kfr)\n*|" + i18n("All Files") + " (*)";
+ TQString fileName = KFileDialog::getSaveFileName(TQString(), menu, this, i18n("Save Strings to File"));
+ if (fileName.isEmpty())
+ {
+ return;
+ }
+
+ TQFile file(fileName);
+ if (!file.open(IO_WriteOnly))
+ {
+ KMessageBox::error(0, i18n("File %1 cannot be saved.").arg(fileName));
+ return ;
+ }
+
TQString header("<?xml version=\"1.0\" ?>\n<kfr>"), footer("\n</kfr>"), body;
if(m_option->m_searchingOnlyMode)
header += "\n\t<mode search=\"true\"/>";
@@ -509,20 +701,6 @@ void TDEFileReplaceView::slotStringsSave()
lvi = lvi->nextSibling();
}
- // Selects the file where strings will be saved
- TQString menu = "*.kfr|" + i18n("TDEFileReplace Strings") + " (*.kfr)\n*|" + i18n("All Files") + " (*)";
- TQString fileName = KFileDialog::getSaveFileName(TQString(), menu, this, i18n("Save Strings to File"));
- if (fileName.isEmpty())
- return;
-
- // Forces the extension to be "kfr" == TDEFileReplace extension
- fileName = TDEFileReplaceLib::addExtension(fileName, "kfr");
- TQFile file(fileName);
- if(!file.open(IO_WriteOnly))
- {
- KMessageBox::error(0, i18n("File %1 cannot be saved.").arg(fileName));
- return ;
- }
TQTextStream oTStream(&file);
oTStream.setEncoding(TQTextStream::UnicodeUTF8);
oTStream << header << body << footer;
@@ -621,28 +799,7 @@ void TDEFileReplaceView::initGUI()
i18n("&Properties"),
this,
TQT_SLOT(slotResultProperties()));
- raiseResultsView();
- raiseStringsView();
-}
-
-void TDEFileReplaceView::raiseStringsView()
-{
- if(m_option->m_searchingOnlyMode)
- m_sv = m_lvStrings_2;
- else
- m_sv = m_lvStrings;
-
- m_stackStrings->raiseWidget(m_sv);
-}
-
-void TDEFileReplaceView::raiseResultsView()
-{
- if(m_option->m_searchingOnlyMode)
- m_rv = m_lvResults_2;
- else
- m_rv = m_lvResults;
-
- m_stackResults->raiseWidget(m_rv);
+ changeViews();
}
coord TDEFileReplaceView::extractWordCoordinates(TQListViewItem* lvi)
diff --git a/tdefilereplace/tdefilereplaceview.h b/tdefilereplace/tdefilereplaceview.h
index e763cc5..bbd7b09 100644
--- a/tdefilereplace/tdefilereplaceview.h
+++ b/tdefilereplace/tdefilereplaceview.h
@@ -67,7 +67,7 @@ class TDEFileReplaceView : public TDEFileReplaceViewWdg
void showSemaphore(TQString s);
void displayScannedFiles(int foldersNumber, int filesNumber);
void stringsInvert(bool invertAll);
- void changeView(bool searchingOnlyMode);
+ void changeViews(bool searchingOnlyMode);
TDEListView* getResultsView();
TDEListView* getStringsView();
void updateOptions(RCOptions* info) { m_option = info; }
@@ -87,6 +87,8 @@ class TDEFileReplaceView : public TDEFileReplaceViewWdg
void slotResultDelete();
void slotResultTreeExpand();
void slotResultTreeReduce();
+ void slotResultLoad();
+ void slotResultSave();
void slotResultHeaderClicked(int sortCol);
void slotStringsAdd();
void slotQuickStringsAdd(const TQString& quickSearch, const TQString& quickReplace);
@@ -99,8 +101,7 @@ class TDEFileReplaceView : public TDEFileReplaceViewWdg
private:
void initGUI();
- void raiseStringsView();
- void raiseResultsView();
+ void changeViews();
coord extractWordCoordinates(TQListViewItem* lvi);
void expand(TQListViewItem *lviCurrent, bool b);
void updateStringMap();
diff --git a/tdefilereplace/tdefilereplaceviewwdg.ui b/tdefilereplace/tdefilereplaceviewwdg.ui
index cb08e45..59d87ae 100644
--- a/tdefilereplace/tdefilereplaceviewwdg.ui
+++ b/tdefilereplace/tdefilereplaceviewwdg.ui
@@ -99,7 +99,7 @@
</column>
<column>
<property name="text">
- <string>Replaced Strings</string>
+ <string>Matches</string>
</property>
<property name="clickable">
<bool>true</bool>
@@ -211,7 +211,7 @@
</column>
<column>
<property name="text">
- <string>Found Strings</string>
+ <string>Matches</string>
</property>
<property name="clickable">
<bool>true</bool>