summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/tdefilereplace/index.docbook103
-rw-r--r--doc/tdefilereplace/kfr_standalone_main_window_1.pngbin67688 -> 0 bytes
-rw-r--r--doc/tdefilereplace/optionsdialog_main_window_1.pngbin44797 -> 42990 bytes
-rw-r--r--doc/tdefilereplace/optionsdialog_main_window_2.pngbin36955 -> 40309 bytes
-rw-r--r--doc/tdefilereplace/report_example.pngbin48533 -> 99195 bytes
-rw-r--r--doc/tdefilereplace/results_view.pngbin54949 -> 84787 bytes
-rw-r--r--doc/tdefilereplace/strings_view.pngbin9506 -> 7424 bytes
-rw-r--r--doc/tdefilereplace/tfr_standalone_main_window_1.pngbin0 -> 112486 bytes
-rw-r--r--doc/tdefilereplace/toolbar.pngbin8217 -> 10487 bytes
-rw-r--r--kgpg/kgpg.kcfg2
-rw-r--r--ksim/ksimpref.cpp2
-rw-r--r--ksim/monitors/filesystem/DFree.desktop2
-rw-r--r--ksim/monitors/filesystem/filesystemwidget.cpp2
-rw-r--r--tdefilereplace/configurationclasses.cpp2
-rw-r--r--tdefilereplace/configurationclasses.h3
-rw-r--r--tdefilereplace/kaddstringdlg.cpp58
-rw-r--r--tdefilereplace/kaddstringdlg.h13
-rw-r--r--tdefilereplace/tdefilereplacelib.cpp103
-rw-r--r--tdefilereplace/tdefilereplacelib.h14
-rw-r--r--tdefilereplace/tdefilereplacepart.cpp308
-rw-r--r--tdefilereplace/tdefilereplacepart.h12
-rw-r--r--tdefilereplace/tdefilereplacepartui.rc19
-rw-r--r--tdefilereplace/tdefilereplaceview.cpp613
-rw-r--r--tdefilereplace/tdefilereplaceview.h25
-rw-r--r--tdefilereplace/tdefilereplaceviewwdg.ui4
-rw-r--r--tdewallet/konfigurator/konfigurator.cpp2
26 files changed, 575 insertions, 712 deletions
diff --git a/doc/tdefilereplace/index.docbook b/doc/tdefilereplace/index.docbook
index 571b6ff..4db26f9 100644
--- a/doc/tdefilereplace/index.docbook
+++ b/doc/tdefilereplace/index.docbook
@@ -57,7 +57,7 @@
<chapter id="introduction">
<title>Introduction</title>
- <para>&tdefilereplace; is an application used to search and replace a list of strings in a file tree. The strings may be literal or Qt-like regular expressions. There are also other options to tune your search.
+ <para>&tdefilereplace; is an application used to search and replace a list of strings in a file tree. The strings may be literal or TQt-like regular expressions. There are also other options to tune your search.
</para>
</chapter>
@@ -69,7 +69,7 @@
<screeninfo>&tdefilereplace; in its standalone incarnation</screeninfo>
<mediaobject>
<imageobject>
- <imagedata fileref="kfr_standalone_main_window_1.png" format="PNG"/>
+ <imagedata fileref="tfr_standalone_main_window_1.png" format="PNG"/>
</imageobject>
<textobject>
<phrase>&tdefilereplace; in its standalone incarnation</phrase>
@@ -89,9 +89,6 @@
<imageobject>
<imagedata fileref="toolbar.png" format="PNG"/>
</imageobject>
- <imageobject>
- <imagedata fileref="toolbar.eps" format="EPS"/>
- </imageobject>
<textobject>
<phrase>&tdefilereplace;'s toolbar</phrase>
</textobject>
@@ -128,18 +125,6 @@
</varlistentry>
<varlistentry>
- <term>
- <inlinemediaobject>
- <imageobject>
- <imagedata fileref="filereplace.png" format="PNG"/>
- </imageobject>
- </inlinemediaobject><guiicon>Replace</guiicon></term>
- <listitem>
- <para>This button starts a search&amp;replace loop. When a string has been found, &tdefilereplace; replaces it with another string.</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
<term>
<inlinemediaobject>
<imageobject>
@@ -152,6 +137,18 @@
</varlistentry>
<varlistentry>
+ <term>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="filereplace.png" format="PNG"/>
+ </imageobject>
+ </inlinemediaobject><guiicon>Replace</guiicon></term>
+ <listitem>
+ <para>This button starts a search&amp;replace loop. When a string has been found, &tdefilereplace; replaces it with another string.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term>
<inlinemediaobject>
<imageobject>
@@ -189,18 +186,6 @@
<varlistentry>
<term>
- <inlinemediaobject>
- <imageobject>
- <imagedata fileref="edit.png" format="PNG"/>
- </imageobject>
- </inlinemediaobject><guiicon>Edit Strings</guiicon></term>
- <listitem>
- <para>This button edits a selected string.</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
<inlinemediaobject>
<imageobject>
<imagedata fileref="eraser.png" format="PNG"/>
@@ -251,18 +236,6 @@
<term>
<inlinemediaobject>
<imageobject>
- <imagedata fileref="recursive_option.png" format="PNG"/>
- </imageobject>
- </inlinemediaobject><guiicon>Search in Subfolders</guiicon></term>
- <listitem>
- <para>This button allows you to search/replace recursively in the subfolders of your base directory.</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <inlinemediaobject>
- <imageobject>
<imagedata fileref="backup_option.png" format="PNG"/>
</imageobject>
</inlinemediaobject><guiicon>Make Backup Files</guiicon></term>
@@ -320,17 +293,14 @@
<imageobject>
<imagedata fileref="results_view.png" format="PNG"/>
</imageobject>
- <imageobject>
- <imagedata fileref="results_view.eps" format="EPS"/>
- </imageobject>
<textobject>
<phrase>&tdefilereplace;'s Results view</phrase>
</textobject>
</mediaobject>
</screenshot>
- <para>The <guilabel>Results</guilabel> view shows the name of the files that contain the strings you have to retrieve (and replace), their path, their size, the number of strings found and the user id of the files. This view also provides the exact position of each match. The columns can be sorted either ascending or descending by clicking on the column headers.</para>
+ <para>The <guilabel>Results</guilabel> view shows the name of the files that contain the strings that match the search criterias, their path, their size, the number of strings found, the user and group of the files owner. This view also provides the exact position of each match. The columns can be sorted either ascending or descending by clicking on the column headers.</para>
<para>You can open a file by clicking with the &RMB; on a list entry, by single/double clicking (depending on your mouse settings) on an entry or alternatively by selecting an item and pressing Enter.</para>
-
+ <para>You can inspect the file properties using <guilabel>Properties</guilabel> from the &RMB; menu. You can also delete a file from the file system using <guilabel>Delete</guilabel> or simply remove the item from the results list using the <guilabel>Remove Entry</guilabel> command.</para>
</sect1>
<sect1 id="tdefilereplace-the-strings-view">
@@ -350,8 +320,7 @@
</screenshot>
</para>
- <para>The <guilabel>Strings</guilabel> view visualizes the list of strings you want search/replace. Please note that in search mode the <guilabel>Results</guilabel> view and the <guilabel>Strings</guilabel> view have a different layout.</para>
-
+ <para>The <guilabel>Strings</guilabel> view visualizes the list of strings you want to search for and eventually replace with. Please note that the layout of both the <guilabel>Results</guilabel> view and the <guilabel>Strings</guilabel> view is different if you are only searching or if you are searching and replacing.</para>
</sect1>
<sect1 id="tdefilereplace-the-project-dialog">
@@ -373,7 +342,7 @@
</mediaobject>
</screenshot>
<para>When you want to begin a new session the first step is to click on the <link linkend="tdefilereplace-the-toolbar"><guiicon>Customize Search/Replace Session</guiicon> button</link>. Then you must enter the base path and a sequence of shell-like wildcards to use as filter.</para>
- <para>Then you could set some useful options, like searching in all the subfolders, doing a case-sensitive search, enabling commands and/or regular expressions<footnote id="performancewarning"><para>Please note that regular expressions and commands could slow down the speed performances.</para></footnote>, doing a backup copy of each file before replacing.</para>
+ <para>Then you could set some useful options, like searching in all the subfolders including limiting the max depth of searching, doing a case-sensitive search, enabling commands and/or regular expressions<footnote id="performancewarning"><para>Please note that regular expressions and commands could slow down the speed performances.</para></footnote>, doing a backup copy of each file before replacing.</para>
<para>If you want to start searching, you can put a string in the search box and press <guibutton>Search Now</guibutton>, otherwise leave the search box empty and press <guibutton>Search Later</guibutton>.</para>
</sect2>
@@ -390,7 +359,7 @@
</textobject>
</mediaobject>
</screenshot>
- <para>The <guilabel>Advanced</guilabel> tab allows you to set up some useful options to restrict the search to a subset of your target file tree. If you want to run &tdefilereplace; only over files that have a size in the range of 10KB - 100KB, then you could use the size options. There is also a date option that restricts the search in a temporal range, and a last option that allows you to only search for files owned (or not owned) by a particular user (this may be more useful to the system administrators).</para>
+ <para>The <guilabel>Advanced</guilabel> tab allows you to set up some useful options to restrict the search to a subset of your target file tree. You can set restrictions on the size, access date and ownership of the files to be searched for.</para>
</sect2>
</sect1>
@@ -400,7 +369,7 @@
</para>
<sect2 id="tdefilereplace-the-options-dialog-general-page">
<title>General options</title>
- <para>These options have been presented in the <link linkend="tdefilereplace-the-toolbar">Toolbar</link> section.
+ <para>These options have been presented in the <link linkend="tdefilereplace-the-toolbar">Toolbar</link> section. In addition to those, you can specify the default file encoding to use and the suffix for backing up files.
<screenshot>
<screeninfo>The General tab of the Options window</screeninfo>
<mediaobject>
@@ -429,11 +398,13 @@
</mediaobject>
</screenshot>
<segmentedlist>
+ <segtitle>Confirm before replace each string</segtitle>
<segtitle>Do not show files if no strings are found or replaced</segtitle>
<segtitle>When searching, stop on first string found</segtitle>
<segtitle>Follow symbolic links</segtitle>
<segtitle>Ignore hidden files and directories</segtitle>
<seglistitem>
+ <seg>choose whether to confirm the replacement of each string or not.</seg>
<seg>shows only the files that match some of your strings. This will speed up the search.</seg>
<seg>&tdefilereplace; will stop when it finds a matching string, and will continue to search for other strings or, if you search for only one string, it will continue with the next file.</seg>
<seg>if a file is a link to another one, then search in the real file.</seg>
@@ -465,29 +436,26 @@
<para>This chapter provides informations about some useful capabilities of &tdefilereplace;.</para>
<sect1 id="tdefilereplace-the-kfr-file">
<title>How to save your string list</title>
- <para>When you want to reuse a list of strings you can save it in a <literal role="extension">xml</literal> file. To do this select from the menubar <menuchoice><guimenu>Search/Replace</guimenu><guisubmenu>Strings</guisubmenu><guimenuitem>Save Strings List to File</guimenuitem></menuchoice>. When you save a list, a simple <literal role="extension">xml</literal> file with extension <literal role="extension">kfr</literal> is created. To load a <literal role="extension">kfr</literal> file select from menubar <menuchoice><guimenu>Search/Replace</guimenu><guisubmenu>Strings</guisubmenu><guimenuitem>Load Strings List from File</guimenuitem></menuchoice>. The actual file looks like this:</para>
+ <para>When you want to reuse a list of strings you can save it in a <literal role="extension">xml</literal> file. To do this select from the menubar <menuchoice><guimenu>Search/Replace</guimenu><guisubmenu>Strings</guisubmenu><guimenuitem>Save Strings List to File...</guimenuitem></menuchoice>. When you save a list, a simple <literal role="extension">xml</literal> file with extension <literal role="extension">kfr</literal> is created. To load a <literal role="extension">kfr</literal> file select from menubar <menuchoice><guimenu>Search/Replace</guimenu><guisubmenu>Strings</guisubmenu><guimenuitem>Load Strings List from File...</guimenuitem></menuchoice>. The actual file looks like this:</para>
<screen>
&lt;?xml version="1.0" ?>
&lt;kfr>
&lt;mode search="false"/>
&lt;replacement>
- &lt;oldstring>&lt;![CDATA[SEARCH_STRING_1]&#93; >&lt;/oldstring>
- &lt;newstring>&lt;![CDATA[REPLACE_STRING_1]&#93;>&lt;/newstring>
+ &lt;oldstring>&lt;SEARCH_STRING_1>&lt;/oldstring>
+ &lt;newstring>&lt;REPLACE_STRING_1>&lt;/newstring>
&lt;/replacement>
&lt;replacement>
- &lt;oldstring>&lt;![CDATA[SEARCH_STRING_2]&#93;>&lt;/oldstring>
- &lt;newstring>&lt;![CDATA[REPLACE_STRING_2]&#93;>&lt;/newstring>
+ &lt;oldstring>&lt;SEARCH_STRING_2>&lt;/oldstring>
+ &lt;newstring>&lt;REPLACE_STRING_2>&lt;/newstring>
&lt;/replacement>
-
-
+ ...
+ ...
&lt;replacement>
- &lt;oldstring>&lt;![CDATA[SEARCH_STRING_N]&#93;>&lt;/oldstring>
- &lt;newstring>&lt;![CDATA[REPLACE_STRING_N]&#93;>&lt;/newstring>
+ &lt;oldstring>&lt;SEARCH_STRING_N>&lt;/oldstring>
+ &lt;newstring>&lt;REPLACE_STRING_N>&lt;/newstring>
&lt;/replacement>
-
&lt;/kfr></screen>
-
- <para>If you are using a previous format, you can update by hand your file by simply modifying it according to the above scheme. Alternatively, you can load the file written in the old format and save it again with &tdefilereplace; in the way explained before.</para>
</sect1>
<sect1 id="tdefilereplace-the-report-file">
@@ -499,15 +467,13 @@
<imageobject>
<imagedata fileref="report_example.png" format="PNG"/>
</imageobject>
- <imageobject>
- <imagedata fileref="report_example.eps" format="EPS"/>
- </imageobject>
<textobject>
<phrase>&tdefilereplace;'s Report feature</phrase>
</textobject>
</mediaobject>
</screenshot>
</para>
+ <para>You can also save and load the results list contents to/from file using the <menuchoice><guimenu>Search/Replace</guimenu><guisubmenu>Results</guisubmenu><guimenuitem>Save Results List to file...</guimenuitem></menuchoice> and <menuchoice><guimenu>Search/Replace</guimenu><guisubmenu>Results</guisubmenu><guimenuitem>Load Results List from file...</guimenuitem></menuchoice>. This is very useful if you are searching over a lot of files and for many strings, so you can save and resume your checks across multiple days.</para>
</sect1>
<sect1 id="tdefilereplace-QT-regexp">
@@ -524,7 +490,8 @@
<sect1 id="tdefilereplace-open-file">
<title>How to Open a File</title>
- <para>If you want to open a file that matches some of your strings, you have to select a line in the result view and click on it with the &RMB;. A context menu will appear from which you can open the file. If you use &tdefilereplace; embedded in &quantaplus;, you can open the file directly in it at the specified line and column.</para>
+ <para>You can open a file by clicking with the &RMB; on a list entry, by single/double clicking (depending on your mouse settings) on an entry or alternatively by selecting an item and pressing Enter. If you use &tdefilereplace; embedded in &quantaplus;, you can open the file directly in it at the specified line and column.</para>
+ <para></para>
</sect1>
<sect1 id="tdefilereplace-commands">
@@ -589,7 +556,7 @@ Documentation Copyright &copy; 2004 Emiliano Gulmini <email>emi_barbarossa&#64;y
<segtitle>[$random:$]</segtitle>
<segtitle>[$mathexp:<replaceable>bc-expression</replaceable>$]</segtitle>
<seglistitem>
- <seg>this command return the current date and time in Qt ISO format.</seg>
+ <seg>this command return the current date and time in TQt ISO format.</seg>
<seg>like above but in local format.</seg>
<seg>return the UID of the current user.</seg>
<seg>return the GID of the current user.</seg>
diff --git a/doc/tdefilereplace/kfr_standalone_main_window_1.png b/doc/tdefilereplace/kfr_standalone_main_window_1.png
deleted file mode 100644
index 9807894..0000000
--- a/doc/tdefilereplace/kfr_standalone_main_window_1.png
+++ /dev/null
Binary files differ
diff --git a/doc/tdefilereplace/optionsdialog_main_window_1.png b/doc/tdefilereplace/optionsdialog_main_window_1.png
index 892dd9b..b9ab36d 100644
--- a/doc/tdefilereplace/optionsdialog_main_window_1.png
+++ b/doc/tdefilereplace/optionsdialog_main_window_1.png
Binary files differ
diff --git a/doc/tdefilereplace/optionsdialog_main_window_2.png b/doc/tdefilereplace/optionsdialog_main_window_2.png
index 805a234..d457491 100644
--- a/doc/tdefilereplace/optionsdialog_main_window_2.png
+++ b/doc/tdefilereplace/optionsdialog_main_window_2.png
Binary files differ
diff --git a/doc/tdefilereplace/report_example.png b/doc/tdefilereplace/report_example.png
index db95360..b07f865 100644
--- a/doc/tdefilereplace/report_example.png
+++ b/doc/tdefilereplace/report_example.png
Binary files differ
diff --git a/doc/tdefilereplace/results_view.png b/doc/tdefilereplace/results_view.png
index c3ba24f..3cada52 100644
--- a/doc/tdefilereplace/results_view.png
+++ b/doc/tdefilereplace/results_view.png
Binary files differ
diff --git a/doc/tdefilereplace/strings_view.png b/doc/tdefilereplace/strings_view.png
index 91f5a53..ea7d670 100644
--- a/doc/tdefilereplace/strings_view.png
+++ b/doc/tdefilereplace/strings_view.png
Binary files differ
diff --git a/doc/tdefilereplace/tfr_standalone_main_window_1.png b/doc/tdefilereplace/tfr_standalone_main_window_1.png
new file mode 100644
index 0000000..71deccf
--- /dev/null
+++ b/doc/tdefilereplace/tfr_standalone_main_window_1.png
Binary files differ
diff --git a/doc/tdefilereplace/toolbar.png b/doc/tdefilereplace/toolbar.png
index a71f327..8368cf0 100644
--- a/doc/tdefilereplace/toolbar.png
+++ b/doc/tdefilereplace/toolbar.png
Binary files differ
diff --git a/kgpg/kgpg.kcfg b/kgpg/kgpg.kcfg
index 6ee2417..00bd746 100644
--- a/kgpg/kgpg.kcfg
+++ b/kgpg/kgpg.kcfg
@@ -115,7 +115,7 @@
<default>false</default>
</entry>
<entry name="AutoStart" type="Bool">
- <label>Start KGpg automatically at KDE startup.</label>
+ <label>Start KGpg automatically at TDE startup.</label>
<default>false</default>
</entry>
<entry name="RemoteFileWarn" type="Bool" key="remote_file_warn">
diff --git a/ksim/ksimpref.cpp b/ksim/ksimpref.cpp
index 1c1efbd..746c810 100644
--- a/ksim/ksimpref.cpp
+++ b/ksim/ksimpref.cpp
@@ -84,7 +84,7 @@ KSim::ConfigDialog::ConfigDialog(KSim::Config *config,
list << ' ' + i18n("Miscellaneous") << ' ' + i18n("Swap");
TQFrame *swap = addHBoxPage(list, i18n("Swap Options"),
- SmallIcon("drive-harddisk"));
+ SmallIcon("drive-harddisk-unmounted"));
m_swapPage = new KSim::SwapPrefs(swap);
TQFrame *theme = addHBoxPage(' ' + i18n("Themes"),
diff --git a/ksim/monitors/filesystem/DFree.desktop b/ksim/monitors/filesystem/DFree.desktop
index d6f23b1..3b7cb9e 100644
--- a/ksim/monitors/filesystem/DFree.desktop
+++ b/ksim/monitors/filesystem/DFree.desktop
@@ -1,5 +1,5 @@
[Desktop Entry]
-Icon=drive-harddisk
+Icon=drive-harddisk-mounted
Name=DFree
Name[af]=Dfree
Name[bg]=Дялове
diff --git a/ksim/monitors/filesystem/filesystemwidget.cpp b/ksim/monitors/filesystem/filesystemwidget.cpp
index 1435195..2fb77e1 100644
--- a/ksim/monitors/filesystem/filesystemwidget.cpp
+++ b/ksim/monitors/filesystem/filesystemwidget.cpp
@@ -217,7 +217,7 @@ void FilesystemWidget::showMenu(uint id)
TQPopupMenu menu;
menu.insertItem(SmallIcon("drive-harddisk-mounted"), i18n("&Mount Device"), 1);
- menu.insertItem(SmallIcon("drive-harddisk"), i18n("&Unmount Device"), 2);
+ menu.insertItem(SmallIcon("drive-harddisk-unmounted"), i18n("&Unmount Device"), 2);
switch (menu.exec(TQCursor::pos())) {
case 1:
diff --git a/tdefilereplace/configurationclasses.cpp b/tdefilereplace/configurationclasses.cpp
index afc3d85..964226b 100644
--- a/tdefilereplace/configurationclasses.cpp
+++ b/tdefilereplace/configurationclasses.cpp
@@ -83,8 +83,6 @@ RCOptions& RCOptions::operator=(const RCOptions& ci)
m_quickSearchString = ci.m_quickSearchString;
m_quickReplaceString = ci.m_quickReplaceString;
- m_recentStringFileList = ci.m_recentStringFileList;
-
m_notifyOnErrors = ci.m_notifyOnErrors;
return (*this);
diff --git a/tdefilereplace/configurationclasses.h b/tdefilereplace/configurationclasses.h
index beaa275..41b0ba9 100644
--- a/tdefilereplace/configurationclasses.h
+++ b/tdefilereplace/configurationclasses.h
@@ -30,7 +30,6 @@ 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";
const TQString rcAllStringsMustBeFound = "All strings must be found";
const TQString rcEncoding = "Encoding";
const TQString rcCaseSensitive = "Case sensitive";
@@ -138,8 +137,6 @@ class RCOptions
TQString m_quickSearchString,
m_quickReplaceString;
- TQStringList m_recentStringFileList;
-
bool m_notifyOnErrors;
public:
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 Franois Dupoux
+ copyright : (C) 1999 by François Dupoux
(C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
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/tdefilereplacelib.cpp b/tdefilereplace/tdefilereplacelib.cpp
index cf9b578..90c8ef4 100644
--- a/tdefilereplace/tdefilereplacelib.cpp
+++ b/tdefilereplace/tdefilereplacelib.cpp
@@ -3,7 +3,7 @@
-------------------
begin : lun mai 3 20:19:52 CEST 1999
- copyright : (C) 1999 by Franois Dupoux
+ copyright : (C) 1999 by François Dupoux
(C) 2003 Andras Mantia <amantia@kde.org>
(C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
email : dupoux@dupoux.com
@@ -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;
@@ -119,82 +94,6 @@ TQString TDEFileReplaceLib::formatFileSize(double size)
return stringSize;
}
-void TDEFileReplaceLib::convertOldToNewKFRFormat(const TQString& fileName, TDEListView* stringView)
-{
- //this method convert old format in new XML-based format
- typedef struct
- {
- char pgm[13]; // Must be "TDEFileReplace" : like MZ for EXE files
- int stringNumber; // Number of strings in file
- char reserved[64]; // Reserved for future use
- } KFRHeader;
-
- KFRHeader head;
-
- FILE* f = fopen(fileName.ascii(),"rb");
- int err = fread(&head, sizeof(KFRHeader), 1, f);
- TQString pgm(head.pgm);
-
- if(!f || (err != 1) || (pgm != "TDEFileReplace"))
- {
- KMessageBox::error(0, i18n("<qt>Cannot open the file <b>%1</b> and load the string list. This file seems not to be a valid old kfr file or it is broken.</qt>").arg(fileName));
- return ;
- }
-
- stringView->clear();
-
- int oldTextSize,
- newTextSize,
- errors = 0,
- stringSize;
- TQStringList l;
-
- int i ;
- for (i=0; i < head.stringNumber; i++)
- {
- errors += (fread(&oldTextSize, sizeof(int), 1, f)) != 1;
- errors += (fread(&newTextSize, sizeof(int), 1, f)) != 1;
- if(errors > 0)
- KMessageBox::error(0, i18n("Cannot read data."));
- else
- {
- stringSize = ((oldTextSize > newTextSize) ? oldTextSize : newTextSize) + 2;
- char* oldString = (char*) malloc(stringSize+10),
- * newString = (char*) malloc(stringSize+10);
- memset(oldString, 0, stringSize);
- memset(newString,0, stringSize);
- if (oldString == 0 || newString == 0)
- KMessageBox::error(0, i18n("Out of memory."));
- else
- {
- if (fread(oldString, oldTextSize, 1, f) != 1)
- KMessageBox::error(0, i18n("Cannot read data."));
- else
- {
- if (newTextSize > 0) // If there is a Replace text
- {
- if (fread(newString, newTextSize, 1, f) != 1)
- KMessageBox::error(0, i18n("Cannot read data."));
- else
- {
- TQListViewItem* lvi = new TQListViewItem(stringView);
- lvi->setText(0,oldString);
- lvi->setText(1,newString);
-
- if(newString)
- free(newString);
- if(oldString)
- free(oldString);
- }
- }
- }
- }
- }
- }
- fclose(f);
- return ;
- }
-
bool TDEFileReplaceLib::isAnAccessibleFile(const TQString& filePath, const TQString& fileName, RCOptions* info)
{
TQString bkExt = info->m_backupExtension;
diff --git a/tdefilereplace/tdefilereplacelib.h b/tdefilereplace/tdefilereplacelib.h
index d04f8a3..45dd0a4 100644
--- a/tdefilereplace/tdefilereplacelib.h
+++ b/tdefilereplace/tdefilereplacelib.h
@@ -3,7 +3,7 @@
-------------------
begin : lun mai 3 20:19:52 CEST 1999
- copyright : (C) 1999 by Franois Dupoux
+ copyright : (C) 1999 by François Dupoux
(C) 2003 Andras Mantia <amantia@kde.org>
(C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
email : dupoux@dupoux.com
@@ -40,21 +40,9 @@ 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);
/**
- converts the old kfr format file in the new xml-based format.
- */
- static void convertOldToNewKFRFormat(const TQString& fileName, TDEListView* stringView);
- /**
Verifies that files, which we are scanning, respect some
conditions
*/
diff --git a/tdefilereplace/tdefilereplacepart.cpp b/tdefilereplace/tdefilereplacepart.cpp
index 455b69c..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."));
}
@@ -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,115 +322,45 @@ 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
- TQString menu = "*.kfr|" + i18n("TDEFileReplace strings") + " (*.kfr)\n*|"+i18n("All Files") + " (*)";
- TQString fileName = KFileDialog::getOpenFileName(TQString(), menu, m_w, i18n("Load Strings From File"));
-
- if(!fileName.isEmpty())
- loadRulesFile(fileName);
-
- resetActions();
-}
-
-void TDEFileReplacePart::slotStringsInvertCur()
-{
- m_view->stringsInvert(false);
- resetActions();
-}
-
-void TDEFileReplacePart::slotStringsInvertAll()
-{
- m_view->stringsInvert(true);
- resetActions();
-}
-
-void TDEFileReplacePart::slotOpenRecentStringFile(const KURL& urlFile)
-{
- TQString fileName;
-
- // Downloads file if need (if url is "http://...")
- if (!(TDEIO::NetAccess::download(urlFile, fileName, 0)))
- return;
-
- // Checks it's not a directory
- TQFileInfo fileInfo;
- fileInfo.setFile(fileName);
- if(fileInfo.isDir())
- {
- KMessageBox::error(m_w, i18n("Cannot open folders."));
- return;
- }
-
- loadRulesFile(fileName);
- resetActions();
-}
-
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,31 +386,30 @@ void TDEFileReplacePart::reportBug()
dlg.exec();
}
-void TDEFileReplacePart::resetActions()
+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_edit")->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);
@@ -496,30 +419,35 @@ void TDEFileReplacePart::resetActions()
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_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_opendir")->setEnabled(hasItems);
- actionCollection()->action("results_delete")->setEnabled(hasItems);
- actionCollection()->action("results_treeexpand")->setEnabled(hasItems);
- actionCollection()->action("results_treereduce")->setEnabled(hasItems);
+ {
+ actionCollection()->action("results_editfile")->setEnabled(hasResults);
+ }
+ 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."),
@@ -553,7 +481,7 @@ bool TDEFileReplacePart::openURL(const KURL &url)
return launchNewProjectDialog(url);
else
{
- resetActions();
+ updateGUI();
return true;
}
}
@@ -576,25 +504,28 @@ 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");
(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(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("&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("&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("&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(m_view), TQT_SLOT(slotStringsLoad()), actionCollection(), "strings_load");
+ (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");
@@ -606,20 +537,22 @@ 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-new", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultOpen()), actionCollection(), "results_openfile");
-
+ (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(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("Open Parent &Folder"), "document-open", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultDirOpen()), actionCollection(), "results_opendir");
+ {
+ (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()
@@ -645,7 +578,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);
@@ -659,8 +591,11 @@ void TDEFileReplacePart::freezeActions()
actionCollection()->action("results_infos")->setEnabled(false);
actionCollection()->action("results_openfile")->setEnabled(false);
if (actionCollection()->action("results_editfile"))
+ {
actionCollection()->action("results_editfile")->setEnabled(false);
+ }
actionCollection()->action("results_opendir")->setEnabled(false);
+ actionCollection()->action("results_removeentry")->setEnabled(false);
actionCollection()->action("results_delete")->setEnabled(false);
actionCollection()->action("results_treeexpand")->setEnabled(false);
actionCollection()->action("results_treereduce")->setEnabled(false);
@@ -688,8 +623,6 @@ void TDEFileReplacePart::loadOptions()
{
m_config->setGroup("General Options");
- m_option->m_recentStringFileList = m_config->readListEntry(rcRecentFiles);
-
m_option->m_searchingOnlyMode = m_config->readBoolEntry(rcSearchMode,SearchModeOption);
m_config->setGroup("Options");
@@ -827,7 +760,6 @@ void TDEFileReplacePart::saveOptions()
{
m_config->setGroup("General Options");
- m_config->writeEntry(rcRecentFiles, m_option->m_recentStringFileList);
m_config->writeEntry(rcSearchMode,m_option->m_searchingOnlyMode);
m_config->setGroup("Options");
@@ -1463,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;
@@ -1503,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);
@@ -1559,90 +1491,6 @@ void TDEFileReplacePart::loadViewContent()
m_replacementMap = tempMap;
}
-void TDEFileReplacePart::loadRulesFile(const TQString& fileName)
-{
- /* Loads a file with kfr extension.
- * creates a xml document and browses it*/
- TQDomDocument doc("mydocument");
- TQFile file(fileName);
- TDEListView* sv = m_view->getStringsView();
-
- if(!file.open(IO_ReadOnly))
- {
- KMessageBox::error(m_w, i18n("<qt>Cannot open the file <b>%1</b> and load the string list.</qt>").arg(fileName));
- return ;
- }
-
- if(!doc.setContent(&file))
- {
- file.close();
-
- KMessageBox::information(m_w, i18n("<qt>File <b>%1</b> seems not to be written in new kfr format. Remember that the old kfr format will be soon abandoned. You can convert your old rules files by simply saving them with tdefilereplace.</qt>").arg(fileName),i18n("Warning"));
-
- TDEFileReplaceLib::convertOldToNewKFRFormat(fileName, sv);
-
- return;
- }
- else
- file.close();
-
- //clears view
- sv->clear();
-
- TQDomElement docElem = doc.documentElement();
- TQDomNode n = docElem.firstChild();
- TQString searchAttribute = n.toElement().attribute("search").latin1();
-
- KeyValueMap docMap;
-
- if(searchAttribute.isNull() || searchAttribute.isEmpty())
- {
- int answer = KMessageBox::warningYesNo(m_w, i18n("<qt>The format of kfr files has been changed; attempting to load <b>%1</b>. Please see the KFilereplace manual for details. Do you want to load a search-and-replace list of strings?</qt>").arg(fileName),i18n("Warning"),i18n("Load"),i18n("Do Not Load"));
-
- if(answer == KMessageBox::Yes)
- searchAttribute = "false";
- else
- searchAttribute = "true";
- }
- //Verifies the search mode
- if(searchAttribute == "true")
- m_option->m_searchingOnlyMode = true;
- else
- m_option->m_searchingOnlyMode = false;
-
- //Refreshes the view appearances
- m_view->changeView(m_option->m_searchingOnlyMode);
- //Goes to next tag
- n = n.nextSibling();
- //Reads the string list
- while(!n.isNull())
- {
- TQDomElement e = n.toElement(); // tries to convert the node to an element.
- if(!e.isNull())
- {
- TQString oldString = e.firstChild().toElement().text(),
- newString = e.lastChild().toElement().text();
- docMap[oldString] = newString;
- }
- n = n.nextSibling();
- }
-
- // Adds file to "load strings form file" menu
- TQStringList fileList = m_option->m_recentStringFileList;
- if(!fileList.contains(fileName))
- {
- fileList.append(fileName);
- ((TDERecentFilesAction* ) actionCollection()->action("strings_load_recent"))->setItems(fileList);
- m_option->m_recentStringFileList = fileList;
- }
-
- m_view->changeView(m_option->m_searchingOnlyMode);
-
- m_view->loadMap(docMap);
-
- //resetActions();
-}
-
bool TDEFileReplacePart::launchNewProjectDialog(const KURL & startURL)
{
if(!startURL.isEmpty())
@@ -1662,7 +1510,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..4495ae9 100644
--- a/tdefilereplace/tdefilereplacepart.h
+++ b/tdefilereplace/tdefilereplacepart.h
@@ -63,16 +63,7 @@ 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();
void slotOptionCaseSensitive();
@@ -82,7 +73,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
@@ -152,7 +143,6 @@ class TDEFileReplacePart: public KParts::ReadOnlyPart
* Others methods
*/
void loadViewContent();
- void loadRulesFile(const TQString& fileName);
bool launchNewProjectDialog(const KURL& startURL);
void setOptionMask();
bool checkBeforeOperation();
diff --git a/tdefilereplace/tdefilereplacepartui.rc b/tdefilereplace/tdefilereplacepartui.rc
index e946144..4779bd7 100644
--- a/tdefilereplace/tdefilereplacepartui.rc
+++ b/tdefilereplace/tdefilereplacepartui.rc
@@ -1,5 +1,5 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="tdefilereplace" version="6">
+<kpartgui name="tdefilereplace" version="8">
<MenuBar>
<Menu name="tdefilerepace"><text>Search/&amp;Replace</text>
<Action name="new_project"/>
@@ -12,23 +12,25 @@
<Action name="strings_add"/>
<Action name="strings_del"/>
<Action name="strings_empty"/>
- <Action name="strings_edit"/>
<Separator/>
<Action name="strings_save"/>
<Action name="strings_load"/>
- <Action name="strings_load_recent"/>
<Separator/>
<Action name="strings_invert"/>
<Action name="strings_invert_all"/>
</Menu>
<Menu name="results"><text>&amp;Results</text>
<Action name="results_openfile"/>
- <Action name="results_opendir"/>
+ <Action name="results_openfilewith"/>
<Action name="results_editfile"/>
+ <Action name="results_opendir"/>
+ <Action name="results_removeentry"/>
<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"/>
@@ -61,10 +63,9 @@
<Separator/>
<Action name="strings_add"/>
<Action name="strings_del"/>
- <Action name="strings_edit"/>
- <Action name="strings_empty"/>
- <Action name="strings_invert"/>
- <Action name="strings_load"/>
+ <Action name="strings_empty"/>
+ <Action name="strings_invert"/>
+ <Action name="strings_load"/>
<Separator/>
<Action name="options_recursive"/>
<Action name="options_backup"/>
diff --git a/tdefilereplace/tdefilereplaceview.cpp b/tdefilereplace/tdefilereplaceview.cpp
index 4bf7319..9e41d7a 100644
--- a/tdefilereplace/tdefilereplaceview.cpp
+++ b/tdefilereplace/tdefilereplaceview.cpp
@@ -19,6 +19,7 @@
#include <tqwhatsthis.h>
#include <tqmap.h>
#include <tqfileinfo.h>
+#include <tqdom.h>
// KDE
#include <tdelistview.h>
@@ -68,23 +69,29 @@ 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();
}
-TQString TDEFileReplaceView::currentPath()
+TQString TDEFileReplaceView::getItemPath(const TQListViewItem *lvi)
{
- TQListViewItem *lvi;
-
- if(! m_lviCurrent) lvi = m_rv->currentItem();
- else lvi = (TQListViewItem*) m_lviCurrent;
+ if (!lvi)
+ {
+ return TQString::null;
+ }
+ return TQString(lvi->text(1)+"/"+lvi->text(0));
+}
- while (lvi->parent())
+TQListViewItem* TDEFileReplaceView::getCurrItemTopLevelParent()
+{
+ TQListViewItem *lvi = m_rv->currentItem();
+ while (lvi && lvi->parent())
+ {
lvi = lvi->parent();
-
- return TQString(lvi->text(1)+"/"+lvi->text(0));
+ }
+ return lvi;
}
void TDEFileReplaceView::showSemaphore(TQString s)
@@ -119,61 +126,78 @@ 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 = lviCurItem->nextSibling();
+ } while (invertAll && lviCurItem);
- lviCurItem->setText(0, replaceText);
- lviCurItem->setText(1, searchText);
+ updateStringMap();
+ emit updateGUI();
+}
- lviCurItem = lviCurItem->nextSibling();
- if(!invertAll)
- break;
- } while(lviCurItem && lviCurItem != lviFirst);
- setCurrentStringsViewMap();
+void TDEFileReplaceView::changeViews()
+{
+ changeViews(m_option->m_searchingOnlyMode);
}
-void TDEFileReplaceView::changeView(bool 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;
- }
+ 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;
@@ -183,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;
@@ -199,7 +223,6 @@ void TDEFileReplaceView::slotResultMouseButtonClicked(int button, TQListViewItem
if (button == Qt::RightButton)
{
// Right mouse button: open popup menub
- m_lviCurrent = static_cast<TDEListViewItem*>(lvi);
m_menuResult->popup(pos);
}
}
@@ -210,52 +233,47 @@ void TDEFileReplaceView::slotResultReturnPressed (TQListViewItem *lvi)
return;
// Left mouse button: open item in default view
- m_lviCurrent = static_cast<TDEListViewItem*>(lvi);
slotResultOpen();
}
void TDEFileReplaceView::slotResultProperties()
{
- TQString currItem = currentPath();
- if(! currItem.isEmpty())
- {
- KURL url(currItem);
- (void) new KPropertiesDialog(url);
- m_lviCurrent = 0;
- }
+ TQString currItemPath = getItemPath(getCurrItemTopLevelParent());
+ if (!currItemPath.isEmpty())
+ {
+ KURL url(currItemPath);
+ (void) new KPropertiesDialog(url);
+ }
}
void TDEFileReplaceView::slotResultOpen()
{
- TQString currItem = currentPath();
- if(!currItem.isEmpty())
- {
- (void) new KRun(KURL(currItem), 0, true, true);
- m_lviCurrent = 0;
- }
+ TQString currItemPath = getItemPath(getCurrItemTopLevelParent());
+ if (!currItemPath.isEmpty())
+ {
+ (void) new KRun(KURL(currItemPath), 0, true, true);
+ }
}
void TDEFileReplaceView::slotResultOpenWith()
{
- TQString currItem = currentPath();
- if(!currItem.isEmpty())
- {
- KURL::List kurls;
- kurls.append(KURL(currItem));
- KRun::displayOpenWithDialog(kurls);
- m_lviCurrent = 0;
- }
+ TQString currItemPath = getItemPath(getCurrItemTopLevelParent());
+ if (!currItemPath.isEmpty())
+ {
+ KURL::List kurls;
+ kurls.append(KURL(currItemPath));
+ KRun::displayOpenWithDialog(kurls);
+ }
}
void TDEFileReplaceView::slotResultDirOpen()
{
- TQString currItem = currentPath();
- if(!currItem.isEmpty())
+ TQString currItemPath = getItemPath(getCurrItemTopLevelParent());
+ if (!currItemPath.isEmpty())
{
TQFileInfo fi;
- fi.setFile(currItem);
+ fi.setFile(currItemPath);
(void) new KRun (KURL::fromPathOrURL(fi.dirPath()), 0, true, true);
- m_lviCurrent = 0;
}
}
@@ -300,28 +318,36 @@ void TDEFileReplaceView::slotResultEdit()
lvi = lvi->nextSibling();
}
+}
- m_lviCurrent = 0;
+void TDEFileReplaceView::slotResultRemoveEntry()
+{
+ TQListViewItem *currItem = getCurrItemTopLevelParent();
+ if (currItem)
+ {
+ delete currItem;
+ }
+ emit updateGUI();
}
void TDEFileReplaceView::slotResultDelete()
{
- TQString currItem = currentPath();
- if (!currItem.isEmpty())
+ TQListViewItem *currItem = getCurrItemTopLevelParent();
+ TQString currItemPath = getItemPath(currItem);
+ if (currItem)
{
TQFile fi;
- int answer = KMessageBox::warningContinueCancel(this, i18n("Do you really want to delete %1?").arg(currItem),
+ int answer = KMessageBox::warningContinueCancel(this, i18n("Do you really want to delete %1?").arg(currItemPath),
TQString(),KStdGuiItem::del());
if(answer == KMessageBox::Continue)
{
- fi.setName(currItem);
+ fi.setName(currItemPath);
fi.remove();
-
- delete m_lviCurrent;
- m_lviCurrent = 0;
+ delete currItem;
}
}
+ emit updateGUI();
}
void TDEFileReplaceView::slotResultTreeExpand()
@@ -340,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();
@@ -357,25 +552,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);
+ }
+ changeViews();
+ loadMapIntoView(m_option->m_mapStringsView);
+ emit updateGUI();
}
void TDEFileReplaceView::slotQuickStringsAdd(const TQString& quickSearch, const TQString& quickReplace)
@@ -396,125 +580,161 @@ void TDEFileReplaceView::slotQuickStringsAdd(const TQString& quickSearch, const
m_option->m_mapStringsView = map;
- raiseResultsView();
- raiseStringsView();
-
+ changeViews();
loadMapIntoView(map);
}
}
-void TDEFileReplaceView::slotStringsEdit()
+void TDEFileReplaceView::slotStringsLoad()
{
- 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();
+ // Selects the file to load from
+ TQString menu = "*.kfr|" + i18n("TDEFileReplace strings") + " (*.kfr)\n*|"+i18n("All Files") + " (*)";
+ TQString fileName = KFileDialog::getOpenFileName(TQString(), menu, this, i18n("Load Strings From File"));
+ if (fileName.isEmpty())
+ {
+ return;
+ }
- m_option->m_mapStringsView.insert(m_sv->currentItem()->text(0), m_sv->currentItem()->text(1));
+ // Creates a xml document and browses it
+ TQDomDocument doc("strings");
+ TQFile file(fileName);
+ 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;
+ }
- KAddStringDlg addStringDlg(m_option, true);
+ if (!doc.setContent(&file))
+ {
+ file.close();
- if(!addStringDlg.exec())
+ KMessageBox::information(this, i18n("<qt>File <b>%1</b> seems not to be written in a valid kfr format.</qt>").arg(fileName), i18n("Warning"));
return;
-
- KeyValueMap newMap(m_option->m_mapStringsView);
- if(oldSearchFlagValue == m_option->m_searchingOnlyMode)
+ }
+ else
{
- KeyValueMap::Iterator itMap;
+ file.close();
+ }
- //merges the two maps
- for(itMap = oldMap.begin(); itMap != oldMap.end(); ++itMap)
- newMap.insert(itMap.key(),itMap.data());
+ TQDomElement docElem = doc.documentElement();
+ TQDomNode n = docElem.firstChild();
+ 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"));
+ if (answer == KMessageBox::Yes)
+ {
+ m_option->m_searchingOnlyMode = false;
+ }
+ else
+ {
+ m_option->m_searchingOnlyMode = true;
+ }
}
+ else
+ {
+ m_option->m_searchingOnlyMode = (searchAttribute == "true");
+ }
+ changeViews();
- m_option->m_mapStringsView = newMap;
+ // Clears view
+ TDEListView *sv = getStringsView();
+ sv->clear();
- raiseResultsView();
- raiseStringsView();
+ // Reads the string list
+ KeyValueMap docMap;
+ n = n.nextSibling();
+ while (!n.isNull())
+ {
+ TQDomElement e = n.toElement();
+ if (!e.isNull())
+ {
+ TQString searchString = e.firstChild().toElement().text();
+ TQString replaceString = e.lastChild().toElement().text();
+ docMap[searchString] = replaceString;
+ }
+ n = n.nextSibling();
+ }
+ loadMap(docMap);
- loadMapIntoView(newMap);
+ emit updateGUI();
}
void TDEFileReplaceView::slotStringsSave()
{
// Check there are strings in the list
- TDEListView* sv = getStringsView();
-
- if (sv->firstChild() == 0)
+ TDEListView *sv = getStringsView();
+ if (!sv->firstChild())
{
KMessageBox::error(0, i18n("No strings to save as the list is empty."));
+ 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;
+ TQString header("<?xml version=\"1.0\" ?>\n<kfr>"), footer("\n</kfr>"), body;
if(m_option->m_searchingOnlyMode)
header += "\n\t<mode search=\"true\"/>";
else
header += "\n\t<mode search=\"false\"/>";
- TQListViewItem* lvi = sv->firstChild();
-
- while( lvi )
+ TQListViewItem *lvi = sv->firstChild();
+ while (lvi)
{
body += TQString("\n\t<replacement>"
- "\n\t\t<oldstring><![CDATA[%1]]></oldstring>"
- "\n\t\t<newstring><![CDATA[%2]]></newstring>"
- "\n\t</replacement>").arg(lvi->text(0)).arg(lvi->text(1));
+ "\n\t\t<oldstring>%1</oldstring>"
+ "\n\t\t<newstring>%2</newstring>"
+ "\n\t</replacement>").arg(lvi->text(0)).arg(lvi->text(1));
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, 0, 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 );
+ TQTextStream oTStream(&file);
oTStream.setEncoding(TQTextStream::UnicodeUTF8);
- oTStream << header
- << body
- << footer;
+ oTStream << header << body << footer;
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
@@ -549,12 +769,10 @@ void TDEFileReplaceView::initGUI()
i18n("&Open"),
this,
TQT_SLOT(slotResultOpen()));
- if(!quantaFound)
- {
- m_menuResult->insertItem(i18n("Open &With..."),
- this,
- TQT_SLOT(slotResultOpenWith()));
- }
+ m_menuResult->insertItem(SmallIconSet(TQString::fromLatin1("document-open")),
+ i18n("Open &With..."),
+ this,
+ TQT_SLOT(slotResultOpenWith()));
if(quantaFound)
{
@@ -568,6 +786,10 @@ void TDEFileReplaceView::initGUI()
i18n("Open Parent &Folder"),
this,
TQT_SLOT(slotResultDirOpen()));
+ m_menuResult->insertItem(SmallIconSet(TQString::fromLatin1("edit-clear")),
+ i18n("Remove &Entry"),
+ this,
+ TQT_SLOT(slotResultRemoveEntry()));
m_menuResult->insertItem(SmallIconSet(TQString::fromLatin1("edit-delete")),
i18n("&Delete"),
this,
@@ -577,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)
@@ -680,26 +881,28 @@ 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)
{
m_sv->clear();
KeyValueMap::Iterator itMap;
-
for(itMap = map.begin(); itMap != map.end(); ++itMap)
{
TQListViewItem* lvi = new TQListViewItem(m_sv);
diff --git a/tdefilereplace/tdefilereplaceview.h b/tdefilereplace/tdefilereplaceview.h
index 6eae3d4..bbd7b09 100644
--- a/tdefilereplace/tdefilereplaceview.h
+++ b/tdefilereplace/tdefilereplaceview.h
@@ -62,17 +62,17 @@ class TDEFileReplaceView : public TDEFileReplaceViewWdg
TDEFileReplaceView(RCOptions* info, TQWidget *parent,const char *name);
public:
- TQString currentPath();
+ TQString getItemPath(const TQListViewItem *lvi);
+ TQListViewItem* getCurrItemTopLevelParent();
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; }
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:
@@ -83,35 +83,38 @@ class TDEFileReplaceView : public TDEFileReplaceViewWdg
void slotResultOpenWith();
void slotResultDirOpen();
void slotResultEdit();
+ void slotResultRemoveEntry();
void slotResultDelete();
void slotResultTreeExpand();
void slotResultTreeReduce();
+ void slotResultLoad();
+ void slotResultSave();
void slotResultHeaderClicked(int sortCol);
void slotStringsAdd();
void slotQuickStringsAdd(const TQString& quickSearch, const TQString& quickReplace);
void slotStringsDeleteItem();
void slotStringsEmpty();
- void slotStringsEdit();
+ void slotStringsLoad();
void slotStringsSave();
+ void slotStringsInvertCur();
+ void slotStringsInvertAll();
private:
void initGUI();
- void raiseStringsView();
- void raiseResultsView();
+ void changeViews();
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;
RCOptions *m_option;
- TDEListViewItem *m_lviCurrent;
TDEListView *m_rv, * m_sv;
};
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>
diff --git a/tdewallet/konfigurator/konfigurator.cpp b/tdewallet/konfigurator/konfigurator.cpp
index 43b7732..9dcb4c7 100644
--- a/tdewallet/konfigurator/konfigurator.cpp
+++ b/tdewallet/konfigurator/konfigurator.cpp
@@ -307,7 +307,7 @@ void TDEWalletConfig::defaults() {
TQString TDEWalletConfig::quickHelp() const {
- return i18n("This configuration module allows you to configure the KDE wallet system.");
+ return i18n("This configuration module allows you to configure the TDE wallet system.");
}