summaryrefslogtreecommitdiffstats
path: root/kfilereplace
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite9ae80694875f869892f13f4fcaf1170a00dea41 (patch)
treeaa2f8d8a217e2d376224c8d46b7397b68d35de2d /kfilereplace
downloadtdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz
tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kfilereplace')
-rw-r--r--kfilereplace/ChangeLog211
-rw-r--r--kfilereplace/Makefile.am43
-rw-r--r--kfilereplace/commandengine.cpp213
-rw-r--r--kfilereplace/commandengine.h57
-rw-r--r--kfilereplace/configurationclasses.cpp188
-rw-r--r--kfilereplace/configurationclasses.h165
-rw-r--r--kfilereplace/configure.in.in12
-rw-r--r--kfilereplace/hi22-app-kfilereplace.pngbin0 -> 999 bytes
-rw-r--r--kfilereplace/hi32-app-kfilereplace.pngbin0 -> 1789 bytes
-rw-r--r--kfilereplace/hi48-app-kfilereplace.pngbin0 -> 2835 bytes
-rw-r--r--kfilereplace/kaddstringdlg.cpp273
-rw-r--r--kfilereplace/kaddstringdlg.h75
-rw-r--r--kfilereplace/kaddstringdlgs.ui426
-rw-r--r--kfilereplace/kfilereplace.cpp111
-rw-r--r--kfilereplace/kfilereplace.desktop55
-rw-r--r--kfilereplace/kfilereplace.h45
-rw-r--r--kfilereplace/kfilereplace.kdevelop190
-rw-r--r--kfilereplace/kfilereplaceiface.h30
-rw-r--r--kfilereplace/kfilereplacelib.cpp381
-rw-r--r--kfilereplace/kfilereplacelib.h65
-rw-r--r--kfilereplace/kfilereplacepart.cpp1679
-rw-r--r--kfilereplace/kfilereplacepart.desktop95
-rw-r--r--kfilereplace/kfilereplacepart.h159
-rw-r--r--kfilereplace/kfilereplacepartui.rc75
-rw-r--r--kfilereplace/kfilereplaceui.rc10
-rw-r--r--kfilereplace/kfilereplaceview.cpp672
-rw-r--r--kfilereplace/kfilereplaceview.h116
-rw-r--r--kfilereplace/kfilereplaceviewwdg.ui555
-rw-r--r--kfilereplace/knewprojectdlg.cpp531
-rw-r--r--kfilereplace/knewprojectdlg.h84
-rw-r--r--kfilereplace/knewprojectdlgs.ui898
-rw-r--r--kfilereplace/koptionsdlg.cpp236
-rw-r--r--kfilereplace/koptionsdlg.h58
-rw-r--r--kfilereplace/koptionsdlgs.ui347
-rw-r--r--kfilereplace/main.cpp77
-rw-r--r--kfilereplace/report.cpp282
-rw-r--r--kfilereplace/report.h58
-rw-r--r--kfilereplace/toolbar/Makefile.am3
-rw-r--r--kfilereplace/toolbar/cr22-action-back.pngbin0 -> 1348 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-backup_option.pngbin0 -> 979 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-casesensitive_option.pngbin0 -> 1177 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-command_option.pngbin0 -> 1132 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-editadd.pngbin0 -> 1226 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-editremove.pngbin0 -> 1179 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-filereplace.pngbin0 -> 1115 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-filesearch.pngbin0 -> 1163 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-filesimulate.pngbin0 -> 1113 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-informations.pngbin0 -> 1171 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-invert.pngbin0 -> 1218 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-next.pngbin0 -> 1311 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-projectopen.pngbin0 -> 808 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-recursive_option.pngbin0 -> 615 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-regularexpression_option.pngbin0 -> 959 bytes
-rw-r--r--kfilereplace/toolbar/cr22-action-unsortedList.pngbin0 -> 279 bytes
-rw-r--r--kfilereplace/tutorial.kwdbin0 -> 392373 bytes
-rw-r--r--kfilereplace/whatthis.h101
56 files changed, 8576 insertions, 0 deletions
diff --git a/kfilereplace/ChangeLog b/kfilereplace/ChangeLog
new file mode 100644
index 00000000..9a9c507e
--- /dev/null
+++ b/kfilereplace/ChangeLog
@@ -0,0 +1,211 @@
+2005-02-20: Andras Mantia <amantia@kde.org>
+ * Added the possibility to select the encoding of the files and a warning about
+ the possible damaged result if the wrong encoding is chosen
+
+2005-02-16: Andras Mantia <amantia@kde.org>
+ * Accept paths as command line arguments
+
+2005-01-29 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * Cleaning up.
+
+2005-01-23 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * Some clean up.
+ * Now the text 'captured text "blabla" at line...' etc. is substituted with
+ 'Line:xyz, Col:abc "blabla"'
+ * Fixed a bug in the string view, that cause KFR to crash if the string list is empty
+ and the user click on it with the mouse.
+
+2005-01-17 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * Now it should be possible to handle other characters encoding, like japanese.
+ * Added, but still buggy, a "replace confirmation" option.
+ * Now when open KFilereplace as standalone application it uses
+ this "*.c*;*.h*;*.sh;*.txt*;*.p*;*.java;*.log" string as default filter.
+
+2005-01-14 Andras Mantia <amantia@kde.org>
+ * Don't show the cannot open file dialogs for directories
+ * Don't create a backup for every scanned file, only for those that were modified
+ * Don't update the timestap for every scanned file
+ * Fix installation of the icons (they go to the part's data dir now)
+
+2005-01-13 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * I added some other infos to the docbook manual, I hope to complete it as soon as possible.
+ * I added a new command: [$mathexp:some_expression$]. It uses the bc calculator to
+ compute the result of an expression.
+
+2005-01-11 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * Fixed a bug in KAddStringDlg: now when we want edit a string the search-only mode and search-replace mode
+ don't merge.
+ * Modified KFR file format: I added the tag '<mode search=""/>' just after the root <kfr> to allows
+ kfilereplace to recognize if the list to load is a list of only search strings. I added some lines of code
+ to permit users to load files that don't have this new tag.
+ * I'm writing docbook manual.
+
+2005-01-10 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * The KFilereplaceView widget has been modified. Now it change the layout of kfilereplace depending of the
+ value of m_option->m_searchOnlyMode.
+ * I fixed a bug in the backup file option.
+
+2004-12-13 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * I modified the way we can open files in quanta. Now we can select one or more entries
+ in the QListView that store the results, and open several files, at the same time.
+ For selecting more than one file, we must press CTRL button while clicking with mouse
+ on the entry we want open.
+
+2004-11-10 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * I added a graphical file counter.
+ * I added a semaphore to notify user about the state of the search.
+ * I improved a little the speed.
+ * I made some cleanup.
+
+2004-09-27 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * I fixed a bug that affect some strings in case of translation.
+ * I fixed a bug that affect "Create backup" option, I think that now this feature should work
+ properly.
+
+2004-09-26 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * I did some cleanup.
+
+2004-09-11 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * I added the class ResultViewEntry in configurationclasses.(h,cpp) to make the replace algorithm more clean.
+ * I make multiline text searching more useable.
+ * Now the file entries in the result view are shown with descriptive icons.
+ * I'm trying to write some documentation, in the meanwhile a tutorial is present.
+
+2004-08-13 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * I added CommandEngine class and Report class.
+ In fact I moved the code that do the report document and the
+ code that do commands feature from KFileREplaceLib to these two classes.
+
+2004-08-09 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * I fixed a bug that affected the method "void KFileReplaceView::slotStringsClear()" in kfilereplaceview.cpp file.
+ This bug caused the list of strings not to be correctly erased.
+
+2004-08-07 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * I modified the save-results system(thanks Luciano for the idea of using xml/css tecnology).
+ Now KFR creates a directory with name "NAME" that contains a xml file "NAME.xml"
+ and a css file "NAME.css". These two files are the new "report document"
+ that substitutes the xhtml file. To try it choose "Search/Replace|Results|Create Report File" menu option.
+ * I fixed a bug that causes Quanta to crash when we push Cancel button in new project
+ dialog.
+ * I finished the tutorial.
+
+2004-08-01 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * The line "if(::access(directory.local8Bit(), R_OK | X_OK) == -1)" has been removed,
+ and subtitued with "QFileInfo dirInfo(directory); "
+ "if(not(dirInfo.isReadable() and dirInfo.isExecutable())"
+ " or "
+ " not(dirInfo.isWritable())) "
+ in kfilereplacepart.cpp
+
+2004-07-30 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * The icons have been fixed!!! What a miracle!!!
+
+2004-07-24 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * I added a little feature. When KFR matches a string, it shows the row and the column
+ where that match is, by using a message like this:
+ /my/path/file
+ |
+ |__ string "xyz" found at line:40, column:2
+ |__ string "xyz" found at line:18, column:57
+ |__.............
+ Now if you use "Edit with Quanta" popup menu option, say, on the line:
+ "string "xyz" found at line:40, column:2"
+ of the result view, Quanta will open the file /my/path/file at row 40, column 2.
+
+2004-07-20 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * I fixed a bug that affects the generation of extension of
+ the backup files.
+
+2004-07-17 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * I fixed the bug that causes quanta to crash when KFR is active.
+ * I fixed (I hope!) the simulation feature.
+ * I reorganize the KOptionsDlg UI.
+ * I Added some tool tips.
+ * I' m tired and I go on bed ;-)
+
+2004-07-16 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * The KNewProjectDlg was modified, adding quick search/replace line edit objects
+ * A option in KOptionDlg was added, so that the files that don't
+ contain the strings we are searching for, will not be shown.
+ * Some code clean-up
+ * A bug with KAddStringDlg was fixed.
+ * I found a bug that makes quanta to crash when we close quanta with the x button...
+ I'm trying to fix it.
+
+2004-05-30 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * Well, KFR has been entirely (more or less :-)) rewrote.
+ the files:
+ apistruct.h
+ kernel.(cpp,h)
+ kexpression.(cpp,h)
+ kfilereplacedoc.(cpp,h)
+ kfilereplacepref.(cpp,h)
+
+ were removed and these files are added:
+
+ configurationclasses.h
+
+ . the internal architecture was redesigned, to use QT/KDE tecnologies in particular:
+ . C-like code were removed (where possible).
+ . some system dependent functions were substituted with more portable code.
+ . the apistructs.h file were substituted with one class in configurationclasses.h.
+ . the UIs were modified in particular:
+ . new "add string" dialog were added.
+ . project dialog were modified.
+ . some new features were added in particular:
+ . the variable replace mechanism were modified.
+ . the result view shows the line and column where the string has been found.
+ . now the mechanism of search/replace with wildcards inherits from QT regular expression engine.
+
+ * I wrote a little tutorial(TUTOR.txt), but a more exhaustive tutorial will be released soon.
+ Note: there some bugs to fix and some feature to implement, in particular:
+ . Simulation is not yet implemented.
+ . Some options are presents but disabled.
+ . I want to add more KFR variable commands.
+
+
+2004-03-26 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * Added a feature. Now we can open a file from the result view of KFR in Quanta(thanks Andras).
+
+2004-03-14 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * Replaced two QLineEdit with two QSpinbox in knewprojectdlg.ui
+ * Fixed a bug in the new kfr (XML-based) file format.
+
+2004-03-12 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * Removed KresultView(.h,.cpp). Now KFileReplaceView is a QWidget that contains results and
+ strings view.
+ * Added whatthis.h that contains the "what's this" strings.
+ * Fixed a bug that generate a wrong XHTML result file.
+
+2004-03-06 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * Added kconfirmdlgs.ui.
+ * Fixed a bug in KOptionDlg, now when we select a option, the selection is shown correctly.
+ * Fixed a bug KNewProjectDlg.
+
+2004-02-26 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * I added a method 'editStrings' that fixes tha behaviour when a user
+ chooses edit string option instead of add string option.
+ * I modified the property textFormat of the QTextEdit widgets of
+ KAddstringDlg, from the value 'AutoText' to the value 'PlainText',
+ so the QTextEdit widgets will not try to render a string containing
+ html code.
+
+2004-02-24 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * kfilereplacepref.(h,cpp) were removed.
+ * kernel.(h,cpp) now are a singleton class.
+ * Some macros in kernel.h were replaced with integer constants.
+ * Methods in kernel.h file were renamed.
+ * Some superflous #include lines were removed.
+ * The filelib.(h,cpp) were subtituted with KFilereplaceLib singleton class.
+ * Now kfilereplace logo and icons in the result view appear.
+
+2004-02-18 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ * The icons in toolbar directory were redrawn.
+ * Deleted the KFRHeader struct from apistruct.h.
+ * The mechanism of saving the string rules has been modified: now we can save the rules in a
+ file like this "a_file_name.kfr" that is an XML file.
+ * The file containing the results of the operations is now a XHTML file.
+ * Two new files UI added: now KOptionDlg inherits from KOptionDlgS and KAddstringDlg inherits
+ from KAddstringDlgS.
+ * The klistviewstring.(h,cpp) were removed.
+ * A lot of clean up has been made in all files.
diff --git a/kfilereplace/Makefile.am b/kfilereplace/Makefile.am
new file mode 100644
index 00000000..528a791e
--- /dev/null
+++ b/kfilereplace/Makefile.am
@@ -0,0 +1,43 @@
+## Makefile.am for kfilereplace
+
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes)
+
+# this has all of the subdirectories that make will recurse into. if
+# there are none, comment this out
+SUBDIRS = toolbar
+
+# these are the headers for your project
+noinst_HEADERS = kaddstringdlg.h kfilereplaceiface.h kfilereplacelib.h \
+ knewprojectdlg.h kfilereplaceview.h koptionsdlg.h report.h commandengine.h \
+ configurationclasses.h kfilereplace.h
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+kde_module_LTLIBRARIES = libkfilereplacepart.la
+libkfilereplacepart_la_SOURCES = kfilereplacepart.cpp kfilereplaceview.cpp \
+ kfilereplaceviewwdg.ui kaddstringdlg.cpp kaddstringdlgs.ui knewprojectdlg.cpp \
+ knewprojectdlgs.ui koptionsdlg.cpp koptionsdlgs.ui kfilereplacelib.cpp report.cpp \
+ commandengine.cpp configurationclasses.cpp
+
+libkfilereplacepart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+libkfilereplacepart_la_LIBADD = $(LIB_KFILE) $(LIB_KPARTS) $(LIB_KHTML)
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/kfilereplace.pot
+
+KDE_ICON = AUTO
+kde_services_DATA = kfilereplacepart.desktop
+xdg_apps_DATA = kfilereplace.desktop
+
+# this is where the XML-GUI resource file goes
+partrcdir = $(kde_datadir)/kfilereplacepart
+partrc_DATA = kfilereplacepartui.rc
+
+shellrcdir = $(kde_datadir)/kfilereplace
+shellrc_DATA = kfilereplaceui.rc
+bin_PROGRAMS = kfilereplace
+kfilereplace_LDFLAGS = $(KDE_RPATH) $(all_libraries)
+kfilereplace_LDADD = $(LIB_KPARTS)
+kfilereplace_SOURCES = kfilereplace.cpp main.cpp
diff --git a/kfilereplace/commandengine.cpp b/kfilereplace/commandengine.cpp
new file mode 100644
index 00000000..56cc50b1
--- /dev/null
+++ b/kfilereplace/commandengine.cpp
@@ -0,0 +1,213 @@
+/***************************************************************************
+ commandengine.cpp - kfr commands feature class
+ -------------------
+ begin : fri aug 13 15:29:46 CEST 2004
+
+ copyright : (C) 2004 Emiliano Gulmini
+ email : emi_barbarossa@yahoo.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+// QT
+#include <qdatetime.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qdom.h>
+
+// KDE
+#include <kuser.h>
+#include <krandomsequence.h>
+#include <kprocess.h>
+
+// local
+#include "commandengine.h"
+
+QString CommandEngine::datetime(const QString& opt, const QString& arg)
+{
+ Q_UNUSED(arg);
+ if(opt == "iso")
+ return QDateTime::currentDateTime(Qt::LocalTime).toString(Qt::ISODate);
+ if(opt == "local")
+ return QDateTime::currentDateTime(Qt::LocalTime).toString(Qt::LocalDate);
+ return QString::null;
+}
+
+QString CommandEngine::user(const QString& opt, const QString& arg)
+{
+ Q_UNUSED(arg);
+ KUser u;
+ if(opt == "uid")
+ return QString::number(u.uid(),10);
+ if(opt == "gid")
+ return QString::number(u.gid(),10);
+ if(opt == "loginname")
+ return u.loginName();
+ if(opt == "fullname")
+ return u.fullName();
+ if(opt == "homedir")
+ return u.homeDir();
+ if(opt == "shell")
+ return u.shell();
+ return QString::null;
+}
+
+QString CommandEngine::loadfile(const QString& opt, const QString& arg)
+{
+ Q_UNUSED(arg);
+
+ QFile f(opt);
+ if(!f.open(IO_ReadOnly)) return QString::null;
+
+ QTextStream t(&f);
+
+ QString s = t.read();
+
+ f.close();
+
+ return s;
+}
+
+QString CommandEngine::empty(const QString& opt, const QString& arg)
+{
+ Q_UNUSED(opt);
+ Q_UNUSED(arg);
+ return "";
+}
+
+QString CommandEngine::mathexp(const QString& opt, const QString& arg)
+{
+ /* We will use bc 1.06 by Philip A. Nelson <philnelson@acm.org> */
+ //Q_UNUSED(opt);
+ Q_UNUSED(arg);
+
+ QString tempOpt = opt;
+ tempOpt.replace("ln","l");
+ tempOpt.replace("sin","s");
+ tempOpt.replace("cos","c");
+ tempOpt.replace("arctan","a");
+ tempOpt.replace("exp","e");
+
+ QString program = "var=("+tempOpt+");print var";
+ QString script = "echo '"+program+"' | bc -l;";
+
+ KProcess* proc = new KProcess();
+
+ proc->setUseShell(true);
+
+ *(proc) << script;
+
+ connect(proc, SIGNAL(receivedStdout(KProcess*,char*,int)), this, SLOT(slotGetScriptOutput(KProcess*,char*,int)));
+ connect(proc, SIGNAL(receivedStderr(KProcess*,char*,int)), this, SLOT(slotGetScriptError(KProcess*,char*,int)));
+ connect(proc, SIGNAL(processExited(KProcess*)), this, SLOT(slotProcessExited(KProcess*)));
+
+ //Through slotGetScriptOutput, m_processOutput contains the result of the KProcess call
+ if(!proc->start(KProcess::Block, KProcess::All))
+ {
+ return QString::null;
+ }
+ else
+ {
+ proc->wait();
+ }
+ if(proc)
+ delete proc;
+
+ QString tempbuf = m_processOutput;
+ m_processOutput = QString::null;
+
+ return tempbuf;
+
+}
+
+QString CommandEngine::random(const QString& opt, const QString& arg)
+{
+ Q_UNUSED(arg);
+ long seed;
+ if(opt.isEmpty())
+ {
+ QDateTime dt;
+ seed = dt.toTime_t();
+ }
+ else
+ seed = opt.toLong();
+
+ KRandomSequence seq(seed);
+ return QString::number(seq.getLong(1000000),10);
+}
+
+QString CommandEngine::stringmanip(const QString& opt, const QString& arg)
+{
+ Q_UNUSED(opt);
+ Q_UNUSED(arg);
+ return "";
+}
+
+QString CommandEngine::variableValue(const QString &variable)
+{
+ QString s = variable;
+
+ s.remove("[$").remove("$]").remove(" ");
+
+ if(s.contains(":") == 0)
+ return variable;
+ else
+ {
+ QString leftValue = s.section(":",0,0),
+ midValue = s.section(":",1,1),
+ rightValue = s.section(":",2,2);
+
+ QString opt = midValue;
+ QString arg = rightValue;
+
+ if(leftValue == "stringmanip")
+ return stringmanip(opt, arg);
+ if(leftValue == "datetime")
+ return datetime(opt, arg);
+ if(leftValue == "user")
+ return user(opt, arg);
+ if(leftValue == "loadfile")
+ return loadfile(opt, arg);
+ if(leftValue == "empty")
+ return empty(opt, arg);
+ if(leftValue == "mathexp")
+ return mathexp(opt, arg);
+ if(leftValue == "random")
+ return random(opt, arg);
+
+ return variable;
+ }
+}
+
+//SLOTS
+void CommandEngine::slotGetScriptError(KProcess* proc, char* s, int i)
+{
+ Q_UNUSED(proc);
+ Q_UNUSED(proc);
+ QCString temp(s,i+1);
+ if(temp.isEmpty() || temp == "\n") return;
+}
+
+void CommandEngine::slotGetScriptOutput(KProcess* proc, char* s, int i)
+{
+ Q_UNUSED(proc);
+ QCString temp(s,i+1);
+
+ if(temp.isEmpty() || temp == "\n") return;
+
+ m_processOutput += QString::fromLocal8Bit(temp);
+}
+
+void CommandEngine::slotProcessExited(KProcess* proc)
+{
+ Q_UNUSED(proc);
+}
+
+#include "commandengine.moc"
diff --git a/kfilereplace/commandengine.h b/kfilereplace/commandengine.h
new file mode 100644
index 00000000..cff15b29
--- /dev/null
+++ b/kfilereplace/commandengine.h
@@ -0,0 +1,57 @@
+/***************************************************************************
+ commandengine.h - kfr commands feature class
+ -------------------
+ begin : fri aug 13 15:29:46 CEST 2004
+
+ copyright : (C) 2004 Emiliano Gulmini
+ email : emi_barbarossa@yahoo.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef COMMANDENGINE_H
+#define COMMANDENGINE_H
+
+// QT
+class QString;
+#include <qobject.h>
+
+//KDE
+class KProcess;
+
+class CommandEngine : public QObject
+{
+ Q_OBJECT
+ private:
+ QString m_processOutput;
+ public:
+ CommandEngine() {}
+
+ public:
+
+ /**
+ These functions implement the KFR commands
+ */
+ QString datetime(const QString& opt, const QString& arg);
+ QString user(const QString& opt, const QString& arg);
+ QString loadfile(const QString& opt, const QString& arg);
+ QString empty(const QString& opt, const QString& arg);
+ QString mathexp(const QString& opt, const QString& arg);
+ QString random(const QString& opt, const QString& arg);
+ QString stringmanip(const QString& opt, const QString& arg);
+ QString variableValue(const QString &variable);
+
+ private slots:
+ void slotGetScriptOutput(KProcess*,char*,int);
+ void slotGetScriptError(KProcess*,char*,int);
+ void slotProcessExited(KProcess*);
+};
+
+#endif // COMMANDENGINE_H
diff --git a/kfilereplace/configurationclasses.cpp b/kfilereplace/configurationclasses.cpp
new file mode 100644
index 00000000..848eafdc
--- /dev/null
+++ b/kfilereplace/configurationclasses.cpp
@@ -0,0 +1,188 @@
+/***************************************************************************
+ configurationclasses.cpp - description
+ -------------------
+ begin : Sat Sep 11 2004
+ copyright : (C) 2004 Emiliano Gulmini
+ email : emi_barbarossa@yahoo.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+// QT
+
+// KDE
+
+// local
+#include "configurationclasses.h"
+#include "whatthis.h"
+
+using namespace whatthisNameSpace;
+
+//RCOptions Class
+RCOptions::RCOptions()
+{
+ m_searchingOnlyMode = false;
+}
+
+RCOptions& RCOptions::operator=(const RCOptions& ci)
+{
+ //m_callResetActions = ci.m_callResetActions;
+
+ m_directories = ci.m_directories;
+ m_filters = ci.m_filters;
+ m_currentDirectory = ci.m_currentDirectory;
+ m_minSize = ci.m_minSize;
+ m_maxSize = ci.m_maxSize;
+
+ m_dateAccess = ci.m_dateAccess;
+ m_minDate = ci.m_minDate;
+ m_maxDate = ci.m_maxDate;
+
+ m_caseSensitive = ci.m_caseSensitive;
+ m_recursive = ci.m_recursive;
+ m_followSymLinks = ci.m_followSymLinks;
+ m_allStringsMustBeFound = ci.m_allStringsMustBeFound;
+ m_backup = ci.m_backup;
+ m_backupExtension = ci.m_backupExtension;
+ m_ignoreFiles = ci.m_ignoreFiles;
+ m_regularExpressions = ci.m_regularExpressions;
+
+ m_variables = ci.m_variables;
+ m_haltOnFirstOccur = ci.m_haltOnFirstOccur;
+ m_ignoreHidden = ci.m_ignoreHidden;
+ m_simulation = ci.m_simulation;
+ m_searchingOnlyMode = ci.m_searchingOnlyMode;
+
+ m_ownerUserIsChecked = ci.m_ownerUserIsChecked;
+ m_ownerGroupIsChecked = ci.m_ownerGroupIsChecked;
+
+ m_ownerUserBool = ci.m_ownerUserBool;
+ m_ownerGroupBool = ci.m_ownerGroupBool;
+
+ m_ownerUserType = ci.m_ownerUserType;
+ m_ownerGroupType = ci.m_ownerGroupType;
+
+ m_ownerUserValue = ci.m_ownerUserValue;
+ m_ownerGroupValue = ci.m_ownerGroupValue;
+
+ m_mapStringsView = ci.m_mapStringsView;
+
+ m_quickSearchString = ci.m_quickSearchString;
+ m_quickReplaceString = ci.m_quickReplaceString;
+
+ m_recentStringFileList = ci.m_recentStringFileList;
+
+ m_notifyOnErrors = ci.m_notifyOnErrors;
+
+ return (*this);
+}
+
+//ResultViewEntry Class
+ResultViewEntry::ResultViewEntry(QString nkey, QString ndata, bool regexp, bool caseSensitive)
+{
+ m_caseSensitive = caseSensitive;
+ m_regexp = regexp;
+
+ if(regexp)
+ {
+ m_rxKey = QRegExp("("+nkey+")", caseSensitive, false);
+ }
+ else
+ {
+ m_key = nkey;
+ }
+ m_data = ndata;
+ m_matchedStringsOccurrence = 0;
+ m_pos = 0;
+}
+
+int ResultViewEntry::lineNumber(const QString& line) const
+{
+ return line.mid(0,m_pos).contains('\n')+1;
+}
+
+int ResultViewEntry::columnNumber(const QString& line) const
+{
+ return(m_pos - line.findRev('\n',m_pos));
+}
+
+void ResultViewEntry::incOccurrences()
+{
+ m_matchedStringsOccurrence++;
+}
+
+int ResultViewEntry::occurrences() const
+{
+ return m_matchedStringsOccurrence;
+}
+
+bool ResultViewEntry::regexp()const
+{
+ return m_regexp;
+}
+
+int ResultViewEntry::pos(const QString& line)
+{
+ if(m_regexp)
+ m_pos = m_rxKey.search(line,m_pos);
+ else
+ m_pos = line.find(m_key, m_pos, m_caseSensitive);
+
+ return m_pos;
+}
+
+void ResultViewEntry::incPos()
+{
+ int kl = keyLength(),
+ dl = dataLength();
+
+ if(kl < dl)
+ m_pos += kl;
+ else
+ m_pos += dl;
+
+}
+
+QString ResultViewEntry::capturedText(const QString& line)
+{
+ QString cap;
+
+ if(m_regexp)
+ cap = m_rxKey.cap(1);
+ else
+ cap =line.mid(m_pos,m_key.length());
+
+ return cap;
+}
+
+QString ResultViewEntry::message(const QString& capturedText, int x, int y) const
+{
+ QString data = m_data;
+ //return i18n(" captured text \"%1\" replaced with \"%2\" at line: %3, column: %4 ").arg(capturedText).arg(data).arg(QString::number(x,10)).arg(QString::number(y,10));
+ return i18n(" Line:%3,Col:%4 - \"%1\" -> \"%2\"").arg(capturedText).arg(data).arg(QString::number(x,10)).arg(QString::number(y,10));
+}
+
+int ResultViewEntry::keyLength() const
+{
+ if(m_regexp)
+ return m_rxKey.matchedLength();
+ else
+ return m_key.length();
+}
+
+int ResultViewEntry::dataLength() const
+{
+ return m_data.length();
+}
+
+void ResultViewEntry::updateLine(QString& line)
+{
+ line.insert(m_pos, m_data);
+ line.remove(m_pos + dataLength(), keyLength());
+}
diff --git a/kfilereplace/configurationclasses.h b/kfilereplace/configurationclasses.h
new file mode 100644
index 00000000..82bff991
--- /dev/null
+++ b/kfilereplace/configurationclasses.h
@@ -0,0 +1,165 @@
+/***************************************************************************
+ configurationclasses.h - description
+ -------------------
+ begin : Sat Apr 17 2004
+ copyright : (C) 2004 Emiliano Gulmini
+ email : <emi_barbarossa@yahoo.it>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef CONFIGURATIONCLASSES_H
+#define CONFIGURATIONCLASSES_H
+
+// QT
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qdatetime.h>
+#include <qmap.h>
+#include <qregexp.h>
+
+typedef QMap<QString,QString> KeyValueMap;
+// entry strings in the kfilereplacerc file
+const QString rcDirectoriesList = "Directories list";
+const QString rcFiltersList = "Filters list";
+const QString rcRecentFiles = "Recent files";
+const QString rcAllStringsMustBeFound = "All strings must be found";
+const QString rcEncoding = "Encoding";
+const QString rcCaseSensitive = "Case sensitive";
+const QString rcConfirmStrings = "Confirm strings";
+const QString rcConfirmFiles = "Confirm files";
+const QString rcConfirmDirs = "Confirm directories";
+const QString rcFollowSymLinks = "Follow symbolic links";
+const QString rcHaltOnFirstOccur = "Halt on first occurrence";
+const QString rcIgnoreHidden = "Ignore hidden files";
+const QString rcRecursive = "Search/replace in sub folders";
+const QString rcVariables = "Enable variables";
+const QString rcRegularExpressions = "Enable regular expressions";
+const QString rcMinFileSize = "Minimum file size";
+const QString rcMaxFileSize = "Maximum file size";
+const QString rcValidAccessDate = "Access mode";
+const QString rcMinDate = "Minimum access date";
+const QString rcMaxDate = "Maximum access date";
+const QString rcOwnerUser = "Owner user filters";
+const QString rcOwnerGroup = "Owner group filters";
+const QString rcSearchMode = "Search only mode";
+const QString rcBackupExtension = "Backup file extension";
+const QString rcIgnoreFiles = "Ignore files if there is no match";
+const QString rcNotifyOnErrors = "NotifyOnErrors";
+const QString rcAskConfirmReplace = "Ask confirmation on replace";
+const QString rcDontAskAgain = "Dont ask again";
+// Default configuration options
+const QString EncodingOption = "utf8";
+const bool RecursiveOption = true;
+const bool CaseSensitiveOption = false;
+const bool FollowSymbolicLinksOption = false;
+const bool RegularExpressionsOption = false;
+const bool VariablesOption = false;
+const bool StopWhenFirstOccurenceOption = false;
+const bool IgnoreHiddenOption = false;
+const int FileSizeOption = -1;
+const QString AccessDateOption="unknown";
+const QString ValidAccessDateOption="unknown";
+const QString OwnerOption="false,Name,Equals To";
+const bool SearchModeOption=true;
+const QString BackupExtensionOption="false,~";
+const bool IgnoreFilesOption = true;
+const bool NotifyOnErrorsOption = false;
+const bool AskConfirmReplaceOption = false;
+
+// This class store configuration informations
+class RCOptions
+{
+ public:
+ bool m_callResetActions;
+
+ bool m_askConfirmReplace,
+ m_dontAskAgain;
+
+ QStringList m_directories;
+ QStringList m_filters;
+ QString m_currentDirectory;
+
+ int m_minSize,
+ m_maxSize;
+
+ QString m_dateAccess,
+ m_minDate,
+ m_maxDate;
+
+ QString m_encoding;
+
+ bool m_caseSensitive,
+ m_recursive,
+ m_followSymLinks,
+ m_allStringsMustBeFound,
+ m_backup,
+ m_regularExpressions;
+
+ bool m_variables,
+ m_haltOnFirstOccur,
+ m_ignoreHidden,
+ m_simulation,
+ m_searchingOnlyMode;
+
+ bool m_ownerUserIsChecked,
+ m_ownerGroupIsChecked;
+
+ QString m_ownerUserType,
+ m_ownerGroupType,
+ m_ownerUserValue,
+ m_ownerGroupValue,
+ m_ownerUserBool,
+ m_ownerGroupBool;
+
+ QString m_backupExtension;
+
+ bool m_ignoreFiles;
+
+ KeyValueMap m_mapStringsView;
+
+ QString m_quickSearchString,
+ m_quickReplaceString;
+
+ QStringList m_recentStringFileList;
+
+ bool m_notifyOnErrors;
+
+ public:
+ RCOptions();
+ RCOptions& operator=(const RCOptions& ci);
+};
+
+class ResultViewEntry
+{
+ private:
+ QString m_key;
+ QString m_data;
+ QRegExp m_rxKey;
+ bool m_regexp;
+ bool m_caseSensitive;
+ int m_pos;
+ int m_matchedStringsOccurrence;
+
+ public:
+ ResultViewEntry(QString nkey, QString ndata, bool regexp, bool caseSensitive);
+ int lineNumber(const QString& line) const ;
+ int columnNumber(const QString& line) const ;
+ void incOccurrences();
+ int occurrences() const ;
+ bool regexp()const ;
+ int pos(const QString& line) ;
+ void incPos();
+ QString capturedText(const QString& line) ;
+ QString message(const QString& capturedText, int x, int y) const;
+ int keyLength() const;
+ int dataLength() const;
+ void updateLine(QString& line);
+};
+#endif
diff --git a/kfilereplace/configure.in.in b/kfilereplace/configure.in.in
new file mode 100644
index 00000000..a7f9ec22
--- /dev/null
+++ b/kfilereplace/configure.in.in
@@ -0,0 +1,12 @@
+#MIN_CONFIG
+
+AM_INIT_AUTOMAKE(kfilereplace, 0.8.0)
+
+dnl These are common macros that you might or might not want to use
+
+dnl Checks for header files.
+AC_HEADER_DIRENT
+AC_HEADER_STDC
+AC_HEADER_TIME
+AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h stdlib.h paths.h)
+AC_CHECK_FUNCS(usleep)
diff --git a/kfilereplace/hi22-app-kfilereplace.png b/kfilereplace/hi22-app-kfilereplace.png
new file mode 100644
index 00000000..429a3984
--- /dev/null
+++ b/kfilereplace/hi22-app-kfilereplace.png
Binary files differ
diff --git a/kfilereplace/hi32-app-kfilereplace.png b/kfilereplace/hi32-app-kfilereplace.png
new file mode 100644
index 00000000..8dff2abb
--- /dev/null
+++ b/kfilereplace/hi32-app-kfilereplace.png
Binary files differ
diff --git a/kfilereplace/hi48-app-kfilereplace.png b/kfilereplace/hi48-app-kfilereplace.png
new file mode 100644
index 00000000..c11f34ba
--- /dev/null
+++ b/kfilereplace/hi48-app-kfilereplace.png
Binary files differ
diff --git a/kfilereplace/kaddstringdlg.cpp b/kfilereplace/kaddstringdlg.cpp
new file mode 100644
index 00000000..44b51f30
--- /dev/null
+++ b/kfilereplace/kaddstringdlg.cpp
@@ -0,0 +1,273 @@
+/***************************************************************************
+ KAddStringDlg.cpp - description
+ -------------------
+ begin : Sat Oct 16 1999
+ copyright : (C) 1999 by François Dupoux
+ (C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ email : dupoux@dupoux.com
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+// QT
+#include <qtextedit.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qlistview.h>
+#include <qwhatsthis.h>
+#include <qwidgetstack.h>
+
+// KDE
+#include <kmessagebox.h>
+#include <kiconloader.h>
+#include <kdebug.h>
+#include <kconfig.h>
+#include <kapplication.h>
+
+// local
+#include "kaddstringdlg.h"
+#include "whatthis.h"
+
+using namespace whatthisNameSpace;
+
+KAddStringDlg::KAddStringDlg(RCOptions* info, bool wantEdit, QWidget *parent, const char *name) : KAddStringDlgS(parent,name,true)
+{
+ m_option = info;
+ m_wantEdit = wantEdit;
+ m_currentMap = m_option->m_mapStringsView;
+
+ initGUI();
+
+ connect(m_pbOK, SIGNAL(clicked()), this, SLOT(slotOK()));
+ connect(m_rbSearchOnly, SIGNAL(pressed()), this, SLOT(slotSearchOnly()));
+ connect(m_rbSearchReplace, SIGNAL(pressed()), this, SLOT(slotSearchReplace()));
+ connect(m_pbAdd, SIGNAL(clicked()), this, SLOT(slotAddStringToView()));
+ connect(m_pbDel, SIGNAL(clicked()), this, SLOT(slotDeleteStringFromView()));
+ connect(m_pbHelp, SIGNAL(clicked()), this ,SLOT(slotHelp()));
+
+ whatsThis();
+}
+
+//PRIVATE
+void KAddStringDlg::initGUI()
+{
+ m_pbAdd->setIconSet(SmallIconSet(QString::fromLatin1("forward")));
+ m_pbDel->setIconSet(SmallIconSet(QString::fromLatin1("back")));
+
+ m_stack->addWidget(m_stringView);
+ m_stack->addWidget(m_stringView_2);
+
+
+ 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()
+{
+ QListViewItem* item = m_sv->firstChild();
+ if(item == 0)
+ return;
+ else
+ {
+ while(item)
+ {
+ QListViewItem* tempItem = item;
+ item = item->nextSibling();
+ delete tempItem;
+ }
+ }
+}
+
+void KAddStringDlg::raiseView()
+{
+ if(m_option->m_searchingOnlyMode)
+ m_sv = m_stringView_2;
+ else
+ m_sv = m_stringView;
+
+ m_stack->raiseWidget(m_sv);
+}
+
+bool KAddStringDlg::columnContains(QListView* lv,const QString& s, int column)
+{
+ QListViewItem* i = lv->firstChild();
+ while (i != 0)
+ {
+ if(i->text(column) == s)
+ return true;
+ i = i->nextSibling();
+ }
+ return false;
+}
+
+void KAddStringDlg::saveViewContentIntoMap()
+{
+ QListViewItem* i = m_sv->firstChild();
+ while(i != 0)
+ {
+ if(m_option->m_searchingOnlyMode)
+ m_currentMap[i->text(0)] = QString::null;
+ else
+ m_currentMap[i->text(0)] = i->text(1);
+ i = i->nextSibling();
+ }
+}
+
+void KAddStringDlg::loadMapIntoView()
+{
+ KeyValueMap::Iterator itMap;
+
+ for (itMap = m_currentMap.begin(); itMap != m_currentMap.end(); ++itMap)
+ {
+ QListViewItem* temp = new QListViewItem(m_sv);
+ temp->setText(0,itMap.key());
+ if(!m_option->m_searchingOnlyMode)
+ temp->setText(1,itMap.data());
+ }
+}
+
+void KAddStringDlg::whatsThis()
+{
+ QWhatsThis::add(m_rbSearchOnly, rbSearchOnlyWhatthis);
+ QWhatsThis::add(m_rbSearchReplace, rbSearchReplaceWhatthis);
+ QWhatsThis::add(m_edSearch, edSearchWhatthis);
+ QWhatsThis::add(m_edReplace, edReplaceWhatthis);
+}
+
+//PRIVATE SLOTS
+void KAddStringDlg::slotOK()
+{
+ m_option->m_mapStringsView = m_currentMap;
+
+ accept();
+}
+
+void KAddStringDlg::slotSearchOnly()
+{
+ m_option->m_searchingOnlyMode = true;
+
+ 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();
+}
+
+void KAddStringDlg::slotSearchReplace()
+{
+ m_option->m_searchingOnlyMode = false;
+
+ 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();
+}
+
+void KAddStringDlg::slotAddStringToView()
+{
+ if(m_option->m_searchingOnlyMode)
+ {
+ QString text = m_edSearch->text();
+ if(!(text.isEmpty() || columnContains(m_sv, text, 0)))
+ {
+ QListViewItem* lvi = new QListViewItem(m_sv);
+ lvi->setMultiLinesEnabled(true);
+ lvi->setText(0,text);
+ m_currentMap[text] = QString::null;
+ m_edSearch->clear();
+ }
+ }
+ else
+ {
+ QString searchText = m_edSearch->text(),
+ replaceText = m_edReplace->text();
+
+ if(!(searchText.isEmpty() || replaceText.isEmpty() || columnContains(m_sv,searchText,0) || columnContains(m_sv,replaceText,1)))
+ {
+ QListViewItem* lvi = new QListViewItem(m_sv);
+ lvi->setMultiLinesEnabled(true);
+ lvi->setText(0,searchText);
+ m_edSearch->clear();
+ lvi->setText(1,replaceText);
+ m_currentMap[searchText] = replaceText;
+ m_edReplace->clear();
+ }
+ }
+}
+
+void KAddStringDlg::slotDeleteStringFromView()
+{
+ // Choose current item or selected item
+ QListViewItem* currentItem = m_sv->currentItem();
+
+ // Do nothing if list is empty
+ if(currentItem == 0)
+ return;
+
+ m_currentMap.remove(currentItem->text(0));
+
+ if(m_option->m_searchingOnlyMode)
+ {
+ m_edSearch->setText(currentItem->text(0));
+ m_edReplace->clear();
+ //currentItem->setText(1,m_edReplace->text());
+ }
+ else
+ {
+ m_edSearch->setText(currentItem->text(0));
+ m_edReplace->setText(currentItem->text(1));
+ }
+
+ delete currentItem;
+
+ currentItem = 0;
+}
+
+void KAddStringDlg::slotHelp()
+{
+ kapp->invokeHelp(QString::null, "kfilereplace");
+}
+
+#include "kaddstringdlg.moc"
+
diff --git a/kfilereplace/kaddstringdlg.h b/kfilereplace/kaddstringdlg.h
new file mode 100644
index 00000000..f51e7f77
--- /dev/null
+++ b/kfilereplace/kaddstringdlg.h
@@ -0,0 +1,75 @@
+/***************************************************************************
+ KAddStringDlg.h - description
+ -------------------
+ begin : Sat Oct 16 1999
+ copyright : (C) 1999 by François Dupoux
+ (C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ email : dupoux@dupoux.com
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KADDSTRINGDLG_H
+#define KADDSTRINGDLG_H
+
+// local
+#include "kaddstringdlgs.h"
+#include "configurationclasses.h"
+/**
+ * This is the dialog used to add a list of searching/replacing strings
+ */
+class KAddStringDlg : public KAddStringDlgS
+{
+ Q_OBJECT
+ private:
+ RCOptions* m_option;
+ QListView* m_sv;
+ KeyValueMap m_currentMap;
+ bool m_wantEdit;
+
+ public: //Constructors
+ KAddStringDlg(RCOptions* info, bool wantEdit, QWidget *parent=0, const char *name=0);
+
+ private slots:
+ void slotOK();
+ void slotSearchOnly();
+ void slotSearchReplace();
+ void slotAddStringToView();
+ void slotDeleteStringFromView();
+ void slotHelp();
+
+ private:
+ /**
+ * 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
+ */
+ void raiseView();
+ /**
+ * Verifies whether 'lv' contains 's'
+ */
+ bool columnContains(QListView* lv,const QString& s, int column);
+ void saveViewContentIntoMap();
+ void loadMapIntoView();
+ void whatsThis();
+};
+
+#endif // KADDSTRINGDLG_H
+
diff --git a/kfilereplace/kaddstringdlgs.ui b/kfilereplace/kaddstringdlgs.ui
new file mode 100644
index 00000000..6685e92f
--- /dev/null
+++ b/kfilereplace/kaddstringdlgs.ui
@@ -0,0 +1,426 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>KAddStringDlgS</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>KAddStringDlgS</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>586</width>
+ <height>347</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Insert Searching/Replacing Strings</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout14</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>bgChoose</cstring>
+ </property>
+ <property name="title">
+ <string>Choose String Adding Mode</string>
+ </property>
+ <property name="exclusive">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>m_rbSearchReplace</cstring>
+ </property>
+ <property name="text">
+ <string>Search and replace mode</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>m_rbSearchOnly</cstring>
+ </property>
+ <property name="text">
+ <string>Search only mode</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QFrame">
+ <property name="name">
+ <cstring>frame4</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Raised</enum>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout11</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout13</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>m_tlSearch</cstring>
+ </property>
+ <property name="text">
+ <string>Search for:</string>
+ </property>
+ </widget>
+ <widget class="QTextEdit">
+ <property name="name">
+ <cstring>m_edSearch</cstring>
+ </property>
+ <property name="textFormat">
+ <enum>PlainText</enum>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout14</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>m_tlReplace</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Replace with:</string>
+ </property>
+ </widget>
+ <widget class="QTextEdit">
+ <property name="name">
+ <cstring>m_edReplace</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="textFormat">
+ <enum>PlainText</enum>
+ </property>
+ <property name="autoFormatting">
+ <set>AutoAll</set>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="1">
+ <property name="name">
+ <cstring>layout16</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer8</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>90</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout15</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>m_pbDel</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>m_pbAdd</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer9</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>90</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QWidgetStack" row="0" column="2">
+ <property name="name">
+ <cstring>m_stack</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Search For</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_stringView_2</cstring>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="showSortIndicator">
+ <bool>false</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Search For</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Replace With</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_stringView</cstring>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="showSortIndicator">
+ <bool>false</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>m_pbHelp</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Help</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>90</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>m_pbOK</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>m_pbCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>m_pbCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>KAddStringDlgS</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kfilereplace/kfilereplace.cpp b/kfilereplace/kfilereplace.cpp
new file mode 100644
index 00000000..a6ade0fe
--- /dev/null
+++ b/kfilereplace/kfilereplace.cpp
@@ -0,0 +1,111 @@
+/***************************************************************************
+ kfilereplace.cpp - KFileReplace shell implementation
+ -------------------
+ begin : Thu Sep 16 14:14:09 2004
+ copyright : (C) 2004 by Andras Mantia <amantia@kde.org>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+//kde includes
+#include <kedittoolbar.h>
+#include <klibloader.h>
+#include <klocale.h>
+#include <kkeydialog.h>
+#include <kmessagebox.h>
+
+//app includes
+#include "kfilereplace.h"
+
+KFileReplace::KFileReplace()
+ : KParts::MainWindow(0L, "KFileReplace")
+{
+ KLibFactory *factory = KLibLoader::self()->factory("libkfilereplacepart");
+ if (factory)
+ {
+ m_part = static_cast<KParts::ReadOnlyPart *>(factory->create(this,
+ "kfilereplace_part", "KParts::ReadOnlyPart" ));
+
+ if (m_part)
+ {
+ setCentralWidget(m_part->widget());
+ KStdAction::quit(this, SLOT(close()), actionCollection());
+ KStdAction::keyBindings(this, SLOT(slotConfigureKeys()), actionCollection());
+ KStdAction::configureToolbars(this, SLOT(slotConfigureToolbars()), actionCollection());
+ setStandardToolBarMenuEnabled(true);
+ createGUI(m_part);
+ removeDuplicatedActions();
+ }
+ }
+ else
+ {
+ KMessageBox::error(this, i18n("Could not find the KFileReplace part."));
+ close();
+ return;
+ }
+}
+
+
+KFileReplace::~KFileReplace()
+{
+}
+
+void KFileReplace::openURL(const KURL &url)
+{
+ m_part->openURL(url);
+}
+
+void KFileReplace::slotConfigureKeys()
+{
+ KKeyDialog dlg( false, this );
+ QPtrList<KXMLGUIClient> clients = guiFactory()->clients();
+ for( QPtrListIterator<KXMLGUIClient> it( clients );
+ it.current(); ++it )
+ {
+ dlg.insert( (*it)->actionCollection() );
+ }
+ dlg.configure();
+}
+
+void KFileReplace::slotConfigureToolbars()
+{
+ saveMainWindowSettings(KGlobal::config(), autoSaveGroup());
+ KEditToolbar dlg(factory());
+ connect(&dlg, SIGNAL(newToolbarConfig()),
+ this, SLOT(applyNewToolbarConfig()));
+ dlg.exec();
+}
+
+void KFileReplace::applyNewToolbarConfig()
+{
+ applyMainWindowSettings(KGlobal::config(), autoSaveGroup());
+}
+
+
+void KFileReplace::removeDuplicatedActions()
+{
+ KActionCollection* part_action_collection = m_part->actionCollection();
+ KAction* part_about_action = part_action_collection->action("help_about_kfilereplace");
+ KAction* part_report_action = part_action_collection->action("report_bug");
+ KAction* part_help_action= part_action_collection->action("help_kfilereplace");
+
+ if (!part_about_action || !part_report_action || !part_help_action || !part_action_collection)
+ return;
+
+ QWidget* container = part_about_action->container(0);
+ part_about_action->unplug(container);
+ part_report_action->unplug(container);
+ part_help_action->unplug(container);
+ part_action_collection->remove(part_about_action);
+ part_action_collection->remove(part_report_action);
+ part_action_collection->remove(part_help_action);
+}
+
+#include "kfilereplace.moc"
diff --git a/kfilereplace/kfilereplace.desktop b/kfilereplace/kfilereplace.desktop
new file mode 100644
index 00000000..0e01c478
--- /dev/null
+++ b/kfilereplace/kfilereplace.desktop
@@ -0,0 +1,55 @@
+[Desktop Entry]
+Name=KFileReplace
+Name[hi]=के-फ़ाइल-रिपà¥à¤²à¥‡à¤¸
+Name[ne]=बदलà¥à¤¨à¥‡ केडीई फाइल
+Name[pa]=ਕੇ-ਫਾਇਲ-ਬਦਲੋ
+Name[sk]=KFile zameniť
+Name[sv]=Kfilereplace
+Name[ta]=Kகோபà¯à®ªà¯ இடமாறà¯à®±à¯
+Name[tg]=KФайлро ҷойгузор кардан
+Name[tr]=K Dosya DeÄŸiÅŸtirme
+Exec=kfilereplace %i %m -caption "%c"
+Icon=kfilereplace
+Type=Application
+DocPath=kfilereplace/index.html
+Terminal=false
+GenericName=Search & Replace Tool
+GenericName[bg]=ТърÑене и замÑна
+GenericName[br]=Ostilh klask hag erlec'hiañ
+GenericName[ca]=Eina cerca i substitueix
+GenericName[cs]=Nástroj pro vyhledání a nahrazení
+GenericName[da]=Søg og erstat-værktøj
+GenericName[de]=Suchen & Ersetzen Werkzeug
+GenericName[el]=ΕÏγαλείο αναζήτησης & αντικατάστασης
+GenericName[es]=Herramienta de búsqueda y reemplazo
+GenericName[et]=Otsimise ja asendamise tööriist
+GenericName[eu]=Bilaketa eta ordezkapen tresna
+GenericName[fa]=ابزار جستجو و جایگزینی
+GenericName[fi]=Etsi & korvaa työkalu
+GenericName[fr]=Outil de recherche et de remplacement
+GenericName[gl]=Ferramenta de busca e reemprazo
+GenericName[hu]=Fájlkereső
+GenericName[is]=Tól til að leita að texta og skipta út
+GenericName[it]=Strumento di ricerca e sostituzione
+GenericName[ja]=検索ãŠã‚ˆã³ç½®æ›ãƒ„ール
+GenericName[ka]=ძიების დრჩáƒáƒœáƒáƒªáƒ•áƒšáƒ”ბის ხელსáƒáƒ¬áƒ§áƒ
+GenericName[lt]=Paieškos ir keitimo įrankis
+GenericName[ms]=Alatan Cari & Ganti
+GenericName[nds]=Söök- un Utwesselwarktüüch
+GenericName[ne]=खोजी गरà¥à¤¨à¥‡ र बदलà¥à¤¨à¥‡ उपरकरण
+GenericName[nl]=Gereedschap voor zoeken en vervangen
+GenericName[pa]=ਖੋਜ ਅਤੇ ਤਬਦੀਲ ਸੰਦ
+GenericName[pl]=Narzędzie do wyszukiwania i zamiany
+GenericName[pt]=Ferramenta de Procura e Substituição
+GenericName[pt_BR]=Ferramenta de Procura & Substituição
+GenericName[ru]=ПоиÑк и замена
+GenericName[sk]=Nájsť a zameniť
+GenericName[sl]=Orodje za iskanje in zamenjavo
+GenericName[sr]=Ðлат за претрагу и замену
+GenericName[sr@Latn]=Alat za pretragu i zamenu
+GenericName[sv]=Sök- och ersättningsverktyg
+GenericName[uk]=ЗаÑіб пошуку та заміни
+GenericName[zh_CN]=æœç´¢æ›¿æ¢å·¥å…·
+GenericName[zh_HK]=æœå°‹åŠå–代工具
+GenericName[zh_TW]=æœå°‹åŠå–代工具
+Categories=Qt;KDE;Utility;X-KDE-Utilities-File;
diff --git a/kfilereplace/kfilereplace.h b/kfilereplace/kfilereplace.h
new file mode 100644
index 00000000..2d65d0ed
--- /dev/null
+++ b/kfilereplace/kfilereplace.h
@@ -0,0 +1,45 @@
+/***************************************************************************
+ kfilereplace.h - KFileReplace header
+ -------------------
+ begin : Thu Sep 16 14:14:09 2004
+ copyright : (C) 2004 by Andras Mantia <amantia@kde.org>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef KFILEREPLACE_H
+#define KFILEREPLACE_H
+
+#include <kparts/mainwindow.h>
+
+/**
+Shell application for the KFileReplace part.
+
+@author Andras Mantia
+*/
+class KFileReplace : public KParts::MainWindow
+{
+ Q_OBJECT
+public:
+ KFileReplace();
+ ~KFileReplace();
+ void openURL(const KURL &url);
+
+private slots:
+ void slotConfigureKeys();
+ void slotConfigureToolbars();
+ void applyNewToolbarConfig();
+
+private:
+ void removeDuplicatedActions();
+
+ KParts::ReadOnlyPart *m_part;
+};
+
+#endif
diff --git a/kfilereplace/kfilereplace.kdevelop b/kfilereplace/kfilereplace.kdevelop
new file mode 100644
index 00000000..96834aae
--- /dev/null
+++ b/kfilereplace/kfilereplace.kdevelop
@@ -0,0 +1,190 @@
+<?xml version = '1.0'?>
+<kdevelop>
+ <general>
+ <author/>
+ <email/>
+ <version>$VERSION$</version>
+ <projectmanagement>KDevKDEAutoProject</projectmanagement>
+ <primarylanguage>C++</primarylanguage>
+ <keywords>
+ <keyword>Qt</keyword>
+ <keyword>KDE</keyword>
+ </keywords>
+ <projectdirectory>.</projectdirectory>
+ <absoluteprojectpath>false</absoluteprojectpath>
+ <description/>
+ <ignoreparts/>
+ <secondaryLanguages/>
+ <versioncontrol>kdevcvsservice</versioncontrol>
+ </general>
+ <kdevfileview>
+ <groups>
+ <group pattern="*.cpp;*.cxx;*.h" name="Sources" />
+ <group pattern="*.ui" name="User Interface" />
+ <group pattern="*.png" name="Icons" />
+ <group pattern="*.po;*.ts" name="Translations" />
+ <group pattern="*" name="Others" />
+ <hidenonprojectfiles>false</hidenonprojectfiles>
+ <hidenonlocation>false</hidenonlocation>
+ </groups>
+ <tree>
+ <showvcsfields>false</showvcsfields>
+ <hidenonprojectfiles>false</hidenonprojectfiles>
+ <hidepatterns>*.o,*.lo,CVS</hidepatterns>
+ </tree>
+ </kdevfileview>
+ <kdevdoctreeview>
+ <ignoretocs>
+ <toc>ada</toc>
+ <toc>ada_bugs_gcc</toc>
+ <toc>bash</toc>
+ <toc>bash_bugs</toc>
+ <toc>clanlib</toc>
+ <toc>fortran_bugs_gcc</toc>
+ <toc>gnome1</toc>
+ <toc>gnustep</toc>
+ <toc>gtk</toc>
+ <toc>gtk_bugs</toc>
+ <toc>haskell</toc>
+ <toc>haskell_bugs_ghc</toc>
+ <toc>java_bugs_gcc</toc>
+ <toc>java_bugs_sun</toc>
+ <toc>opengl</toc>
+ <toc>pascal_bugs_fp</toc>
+ <toc>php</toc>
+ <toc>php_bugs</toc>
+ <toc>perl</toc>
+ <toc>perl_bugs</toc>
+ <toc>python</toc>
+ <toc>python_bugs</toc>
+ <toc>ruby</toc>
+ <toc>ruby_bugs</toc>
+ <toc>sdl</toc>
+ <toc>stl</toc>
+ <toc>sw</toc>
+ <toc>w3c-dom-level2-html</toc>
+ <toc>w3c-svg</toc>
+ <toc>w3c-uaag10</toc>
+ <toc>wxwidgets_bugs</toc>
+ </ignoretocs>
+ <ignoreqt_xml>
+ <toc>qmake User Guide</toc>
+ </ignoreqt_xml>
+ </kdevdoctreeview>
+ <kdevdebugger>
+ <general>
+ <dbgshell>libtool</dbgshell>
+ <programargs/>
+ <gdbpath/>
+ <configGdbScript/>
+ <runShellScript/>
+ <runGdbScript/>
+ <breakonloadinglibs>true</breakonloadinglibs>
+ <separatetty>false</separatetty>
+ <floatingtoolbar>false</floatingtoolbar>
+ </general>
+ <display>
+ <staticmembers>false</staticmembers>
+ <demanglenames>true</demanglenames>
+ <outputradix>10</outputradix>
+ </display>
+ </kdevdebugger>
+ <kdevfilecreate>
+ <filetypes/>
+ <useglobaltypes>
+ <type ext="ui" />
+ <type ext="cpp" />
+ <type ext="h" />
+ </useglobaltypes>
+ </kdevfilecreate>
+ <kdevautoproject>
+ <make>
+ <envvars>
+ <envvar value="1" name="WANT_AUTOCONF_2_5" />
+ <envvar value="1" name="WANT_AUTOMAKE_1_6" />
+ </envvars>
+ <abortonerror>true</abortonerror>
+ <numberofjobs>1</numberofjobs>
+ <dontact>false</dontact>
+ <makebin/>
+ <prio>0</prio>
+ </make>
+ <run>
+ <directoryradio>build</directoryradio>
+ <customdirectory>/</customdirectory>
+ <mainprogram>kfilereplace/kfilereplace</mainprogram>
+ <programargs/>
+ <terminal>false</terminal>
+ <autocompile>true</autocompile>
+ <envvars/>
+ </run>
+ <general>
+ <useconfiguration>default</useconfiguration>
+ <activetarget>kfilereplace</activetarget>
+ </general>
+ <configurations>
+ <default>
+ <envvars>
+ <envvar value="kommander klinkstatus kxsldbg kimagemapeditor quanta" name="DO_NOT_COMPILE" />
+ </envvars>
+ <configargs>--enable-debug=full --prefix=/opt/kde3 --enable-editors</configargs>
+ <builddir>/home/andris/development/build/kde-head/kdewebdev</builddir>
+ <topsourcedir>/home/andris/development/sources/kde-head/kdewebdev</topsourcedir>
+ <cppflags>-DKDE_NO_COMPAT -DQT_NO_COMPAT -DDEBUG_PARSER</cppflags>
+ <ldflags/>
+ <ccompiler>kdevgccoptions</ccompiler>
+ <cxxcompiler>kdevgppoptions</cxxcompiler>
+ <f77compiler>kdevpgf77options</f77compiler>
+ <ccompilerbinary/>
+ <cxxcompilerbinary/>
+ <f77compilerbinary/>
+ <cflags/>
+ <cxxflags/>
+ <f77flags/>
+ </default>
+ </configurations>
+ </kdevautoproject>
+ <cppsupportpart>
+ <filetemplates>
+ <interfacesuffix>.h</interfacesuffix>
+ <implementationsuffix>.cpp</implementationsuffix>
+ </filetemplates>
+ </cppsupportpart>
+ <kdevcppsupport>
+ <codecompletion>
+ <includeGlobalFunctions>true</includeGlobalFunctions>
+ <includeTypes>true</includeTypes>
+ <includeEnums>true</includeEnums>
+ <includeTypedefs>false</includeTypedefs>
+ <automaticCodeCompletion>true</automaticCodeCompletion>
+ <automaticArgumentsHint>true</automaticArgumentsHint>
+ <automaticHeaderCompletion>true</automaticHeaderCompletion>
+ <codeCompletionDelay>250</codeCompletionDelay>
+ <argumentsHintDelay>400</argumentsHintDelay>
+ <headerCompletionDelay>250</headerCompletionDelay>
+ </codecompletion>
+ <references/>
+ <creategettersetter>
+ <prefixGet/>
+ <prefixSet>set</prefixSet>
+ <prefixVariable>m_,_</prefixVariable>
+ <parameterName>theValue</parameterName>
+ <inlineGet>true</inlineGet>
+ <inlineSet>true</inlineSet>
+ </creategettersetter>
+ </kdevcppsupport>
+ <kdevdocumentation>
+ <projectdoc>
+ <docsystem/>
+ <docurl/>
+ <usermanualurl/>
+ </projectdoc>
+ </kdevdocumentation>
+ <kdevcvsservice>
+ <recursivewhenupdate>true</recursivewhenupdate>
+ <prunedirswhenupdate>true</prunedirswhenupdate>
+ <createdirswhenupdate>true</createdirswhenupdate>
+ <recursivewhencommitremove>true</recursivewhencommitremove>
+ <revertoptions>-C</revertoptions>
+ </kdevcvsservice>
+</kdevelop>
diff --git a/kfilereplace/kfilereplaceiface.h b/kfilereplace/kfilereplaceiface.h
new file mode 100644
index 00000000..ab7348d2
--- /dev/null
+++ b/kfilereplace/kfilereplaceiface.h
@@ -0,0 +1,30 @@
+/***************************************************************************
+ kfilereplaceif.h - description
+ -------------------
+ copyright : (C) 1999 by François Dupoux
+ (C) 2003 Andras Mantia
+ email : dupoux@dupoux.com, amantia@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef KFILEREPLACEIFACE_H
+#define KFILEREPLACEIFACE_H
+
+#include <dcopobject.h>
+
+class KFileReplaceIface : virtual public DCOPObject
+{
+ K_DCOP
+
+k_dcop:
+ virtual void openURL(const QString& url) = 0;
+};
+
+#endif // KFILEREPLACEIFACE_H
diff --git a/kfilereplace/kfilereplacelib.cpp b/kfilereplace/kfilereplacelib.cpp
new file mode 100644
index 00000000..e57a3a84
--- /dev/null
+++ b/kfilereplace/kfilereplacelib.cpp
@@ -0,0 +1,381 @@
+/***************************************************************************
+ kfilereplacelib.cpp - File library
+ -------------------
+ begin : lun mai 3 20:19:52 CEST 1999
+
+ 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
+
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+//QT
+#include <qstringlist.h>
+#include <qwidget.h>
+#include <qlistview.h>
+#include <qfileinfo.h>
+
+//KDE
+#include <kdebug.h>
+#include <kmessagebox.h>
+#include <klistview.h>
+#include <kiconloader.h>
+
+//needed for malloc/free
+#include <stdlib.h>
+
+// local
+#include "kfilereplacelib.h"
+
+const double kilo = 1024.0;
+const double mega = 1048576.0;//1024^2
+const double giga = 1073741824.0;//1024^3
+const double tera = 1099511627776.0;//1024^4
+
+/**
+ Format a path, from a path and a filename, or another sub-path (avoid double '/' risks)
+ Parameters::.....* basePath: fist path (can be "/" if root, or "/usr/bin/" or "/usr/bin" for example)
+ .................* fileName: second path (can be "/doc/html/", or "doc/html/" or "doc/html/index.html" for example)
+ Return values:...* Full valid path (without double "/")
+*/
+QString KFileReplaceLib::formatFullPath(const QString& basePath, const QString &fileName)
+{
+ QString fullPath = basePath;
+ QString fname = fileName;
+
+ if (fname.startsWith("/")) // skip beginning '/'
+ fname = fname.remove(0,1);
+
+ if (fullPath.endsWith("/"))
+ fullPath.append(fname);
+ else
+ fullPath.append("/"+fname);
+
+ 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
+*/
+QString KFileReplaceLib::addExtension(const QString& fileName, const QString& extension)
+{
+ QString fullExtension = ".";
+ QString 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;
+}
+
+QString KFileReplaceLib::formatFileSize(double size)
+{
+ QString stringSize;
+
+ if(size < kilo)
+ {
+ const int asInt = (int) size;
+ stringSize = i18n("1 byte", "%n bytes", asInt);
+ }
+ else
+ if(size >= kilo && size < mega)
+ {
+ double d = size / kilo;
+ stringSize = i18n("%1 KB").arg(QString::number(d,'f',2));
+ }
+ else
+ if(size >= mega && size < giga)
+ {
+ double d = size / mega;
+ stringSize = i18n("%1 MB").arg(QString::number(d,'f',2));
+ }
+ else
+ if(size >= giga)
+ {
+ double d = size / giga;
+ stringSize = i18n("%1 GB").arg(QString::number(d,'f',2));
+ }
+ return stringSize;
+}
+
+void KFileReplaceLib::convertOldToNewKFRFormat(const QString& fileName, KListView* stringView)
+{
+ //this method convert old format in new XML-based format
+ typedef struct
+ {
+ char pgm[13]; // Must be "KFileReplace" : 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);
+ QString pgm(head.pgm);
+
+ if(!f || (err != 1) || (pgm != "KFileReplace"))
+ {
+ 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;
+ QStringList 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
+ {
+ QListViewItem* lvi = new QListViewItem(stringView);
+ lvi->setText(0,oldString);
+ lvi->setText(1,newString);
+
+ if(newString)
+ free(newString);
+ if(oldString)
+ free(oldString);
+ }
+ }
+ }
+ }
+ }
+ }
+ fclose(f);
+ return ;
+ }
+
+bool KFileReplaceLib::isAnAccessibleFile(const QString& filePath, const QString& fileName, RCOptions* info)
+{
+ QString bkExt = info->m_backupExtension;
+ if(fileName == ".." || fileName == "." || (!bkExt.isEmpty() && fileName.right(bkExt.length()) == bkExt))
+ return false;
+
+ QFileInfo fi;
+ if(filePath.isEmpty())
+ fi.setFile(fileName);
+ else
+ fi.setFile(filePath+"/"+fileName);
+
+ if(fi.isDir())
+ return true;
+
+ int minSize = info->m_minSize,
+ maxSize = info->m_maxSize;
+ QString minDate = info->m_minDate,
+ maxDate = info->m_maxDate,
+ dateAccess = info->m_dateAccess;
+
+ // Avoid files that not match access date requirements
+ QString last = "unknown";
+ if(dateAccess == "Last Writing Access")
+ last = fi.lastModified().toString(Qt::ISODate);
+ if(dateAccess == "Last Reading Access")
+ last = fi.lastRead().toString(Qt::ISODate);
+
+ if(last != "unknown")
+ {
+ if(minDate != "unknown" && maxDate != "unknown")
+ { //If out of range then exit
+ if((minDate > last) || (maxDate < last))
+ return false;
+ }
+ else
+ {
+ if(minDate != "unknown")
+ { //If out of range then exit
+ if(minDate > last)
+ return false;
+ }
+ else
+ {
+ if(maxDate != "unknown")
+ //If out of range then exit
+ if(maxDate < last)
+ return false;
+ }
+ }
+ }
+ // Avoid files that not match size requirements
+ int size = fi.size();
+ if(maxSize != FileSizeOption && minSize != FileSizeOption)
+ if(size > (maxSize*1024) || size < (minSize*1024))
+ return false;
+
+ // Avoid files that not match ownership requirements
+ if(info->m_ownerUserIsChecked)
+ {
+ QString fileOwnerUser;
+ if(info->m_ownerUserType == "Name")
+ fileOwnerUser = fi.owner();
+ else
+ fileOwnerUser = QString::number(fi.ownerId(),10);
+
+ if(info->m_ownerUserBool == "Equals To")
+ {
+ if(info->m_ownerUserValue != fileOwnerUser)
+ return false;
+ }
+ else
+ {
+ if(info->m_ownerUserValue == fileOwnerUser)
+ return false;
+ }
+ }
+
+ if(info->m_ownerGroupIsChecked)
+ {
+ QString fileOwnerGroup;
+ if(info->m_ownerGroupType == "Name")
+ fileOwnerGroup = fi.group();
+ else
+ fileOwnerGroup = QString::number(fi.groupId(),10);
+ if(info->m_ownerGroupBool == "Equals To")
+ {
+ if(info->m_ownerGroupValue != fileOwnerGroup)
+ return false;
+ }
+ else
+ {
+ if(info->m_ownerGroupValue == fileOwnerGroup)
+ return false;
+ }
+ }
+
+ //If we are here then all requirements have been verified
+ return true;
+}
+
+void KFileReplaceLib::setIconForFileEntry(QListViewItem* item, QString path)
+{
+ QFileInfo fi(path);
+ QString extension = fi.extension(),
+ baseName = fi.baseName();
+
+ KeyValueMap extensionMap;
+
+ extensionMap["a"] = "binary";
+ extensionMap["am"] = "shellscript";
+ extensionMap["bz"] = "zip";
+ extensionMap["bz2"] = "zip";
+ extensionMap["c"] = "source_c";
+ extensionMap["cc"] = "source_cpp";
+ extensionMap["cpp"] = "source_cpp";
+ extensionMap["eml"] = "message";
+ extensionMap["exe"] = "exec_wine";
+ extensionMap["gz"] = "zip";
+ extensionMap["h"] = "source_h";
+ extensionMap["htm"] = "html";
+ extensionMap["html"] = "html";
+ extensionMap["in"] = "shellscript";
+ extensionMap["java"] = "source_java";
+ extensionMap["jpg"] = "image";
+ extensionMap["kfr"] = "html";
+ extensionMap["kmdr"] = "widget_doc";
+ extensionMap["kwd"] = "kword_kwd";
+ extensionMap["log"] = "log";
+ extensionMap["moc"] = "source_moc";
+ extensionMap["mp3"] = "sound";
+ extensionMap["o"] = "source_o";
+ extensionMap["pdf"] = "pdf";
+ extensionMap["php"] = "source_php";
+ extensionMap["py"] = "source_py";
+ extensionMap["pl"] = "source_pl";
+ extensionMap["p"] = "source_p";
+ extensionMap["ps"] = "postscript";
+ extensionMap["png"] = "image";
+ extensionMap["sa"] = "binary";
+ extensionMap["sh"] = "shellscript";
+ extensionMap["so"] = "binary";
+ extensionMap["tar"] = "tar";
+ extensionMap["tex"] = "tex";
+ extensionMap["tgz"] = "tgz";
+ extensionMap["txt"] = "txt";
+ extensionMap["ui"] = "widget_doc";
+ extensionMap["uml"] = "umbrellofile";
+ extensionMap["wav"] = "sound";
+ extensionMap["xml"] = "html";
+ extensionMap["xpm"] = "image";
+
+ KeyValueMap::Iterator itExtensionMap;
+
+ for(itExtensionMap = extensionMap.begin(); itExtensionMap != extensionMap.end(); ++itExtensionMap)
+ {
+ if(extension == itExtensionMap.key())
+ {
+ item->setPixmap(0,SmallIcon(itExtensionMap.data()));
+ return;
+ }
+ }
+
+ KeyValueMap baseNameMap;
+
+ baseNameMap["configure"] = "shellscript";
+ baseNameMap["core"] = "core";
+ baseNameMap["makefile"] = "make";
+ baseNameMap["readme"] = "readme";
+ baseNameMap["README"] = "readme";
+ baseNameMap["Readme"] = "readme";
+ baseNameMap["TODO"] = "txt";
+
+ KeyValueMap::Iterator itBaseNameMap;
+
+ for(itBaseNameMap = baseNameMap.begin(); itBaseNameMap != baseNameMap.end(); ++itBaseNameMap)
+ {
+ if(baseName == itBaseNameMap.key())
+ {
+ item->setPixmap(0,SmallIcon(itBaseNameMap.data()));
+ return;
+ }
+ }
+}
diff --git a/kfilereplace/kfilereplacelib.h b/kfilereplace/kfilereplacelib.h
new file mode 100644
index 00000000..e5c14c72
--- /dev/null
+++ b/kfilereplace/kfilereplacelib.h
@@ -0,0 +1,65 @@
+/***************************************************************************
+ kfilereplacelib.h - File library, derived from filelib.h
+ -------------------
+ begin : lun mai 3 20:19:52 CEST 1999
+
+ 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
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KFILEREPLACELIB_H
+#define KFILEREPLACELIB_H
+
+// KDE
+#include <klocale.h>
+class KlistView;
+
+// local
+#include "configurationclasses.h"
+
+class KFileReplaceLib
+{
+ public:
+
+ /**
+ Format a path, from a path and a filename, or another sub-path (avoid double '/' risks)
+ Parameters::.....* basePath: fist path (can be "/" if root, or "/usr/bin/" or "/usr/bin" for example)
+ .................* filename: second path (can be "/doc/html/", or "doc/html/" or "doc/html/index.html" for example)
+ Return values:...* Full valid path (without double "/")
+ */
+ static QString formatFullPath(const QString& basePath, const QString& 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 QString addExtension(const QString& fileName, const QString& extension);
+
+ static QString formatFileSize(double size);
+
+ /**
+ converts the old kfr format file in the new xml-based format.
+ */
+ static void convertOldToNewKFRFormat(const QString& fileName, KListView* stringView);
+ /**
+ Verifies that files, which we are scanning, respect some
+ conditions
+ */
+ static bool isAnAccessibleFile(const QString& filePath, const QString& fileName, RCOptions* info);
+
+ static void setIconForFileEntry(QListViewItem* item, QString path);
+};
+#endif // KFILEREPLACEFILELIB_H
diff --git a/kfilereplace/kfilereplacepart.cpp b/kfilereplace/kfilereplacepart.cpp
new file mode 100644
index 00000000..9e0be192
--- /dev/null
+++ b/kfilereplace/kfilereplacepart.cpp
@@ -0,0 +1,1679 @@
+//
+//
+// C++ Implementation: kfilereplacepart
+//
+// Description:
+//
+//
+// Author: Andras Mantia <amantia@kde.org>, (C) 2003
+// Maintainer: Emiliano Gulmini <emi_barbarossa@yahoo.it>, (C) 2004
+//
+// Copyright: GPL v2. See COPYING file that comes with this distribution
+//
+//
+
+// QT
+#include <qdir.h>
+#include <qdatastream.h>
+#include <qregexp.h>
+#include <qimage.h>
+#include <qtextcodec.h>
+
+// KDE
+#include <dcopclient.h>
+#include <dcopref.h>
+#include <kaboutapplication.h>
+#include <kapplication.h>
+#include <kaction.h>
+#include <kbugreport.h>
+#include <kconfig.h>
+#include <kfiledialog.h>
+#include <kinstance.h>
+#include <kio/netaccess.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kparts/genericfactory.h>
+#include <kstandarddirs.h>
+#include <kiconloader.h>
+#include <kglobal.h>
+#include <kiconeffect.h>
+#include <klistview.h>
+#include <kuser.h>
+#include <kcombobox.h>
+#include <kguiitem.h>
+
+// local
+#include "kfilereplacelib.h"
+#include "kfilereplacepart.h"
+#include "kfilereplaceview.h"
+#include "koptionsdlg.h"
+#include "knewprojectdlg.h"
+#include "report.h"
+#include "commandengine.h"
+#include "whatthis.h"
+
+using namespace whatthisNameSpace;
+
+//PUBLIC CONSTRUCTORS
+// Factory code for KDE 3
+typedef KParts::GenericFactory<KFileReplacePart> FileReplaceFactory;
+
+K_EXPORT_COMPONENT_FACTORY( libkfilereplacepart, FileReplaceFactory )
+
+KFileReplacePart::KFileReplacePart(QWidget* parentWidget, const char* , QObject* parent, const char* name, const QStringList & ) : KParts::ReadOnlyPart(parent,name)
+{
+ setInstance(FileReplaceFactory::instance());
+ KGlobal::locale()->insertCatalogue("kfilereplace");
+ m_parentWidget = parentWidget;
+ m_config = new KConfig("kfilereplacerc");
+ m_aboutDlg = 0;
+ m_stop = false;
+ m_optionMask = QDir::Files;
+ m_w = widget();
+ m_option = 0;
+
+ loadOptionsFromRC();
+ initView();
+ initGUI();
+
+ whatsThis();
+}
+
+KFileReplacePart::~KFileReplacePart()
+{
+ m_view = 0; //it's already deleted, so set it to NULL
+
+ saveOptionsToRC();
+
+ delete m_aboutDlg;
+ m_aboutDlg = 0;
+ delete m_config;
+ m_config = 0;
+ delete m_w;
+ m_w = 0;
+ delete m_option;
+}
+
+//PRIVATE SLOTS
+void KFileReplacePart::slotSetNewParameters()
+{
+ launchNewProjectDialog(KURL());
+ m_view->changeView(m_option->m_searchingOnlyMode);
+ emit setStatusBarText(i18n("Ready."));
+}
+
+void KFileReplacePart::slotSearchingOperation()
+{
+ if(!checkBeforeOperation())
+ return;
+
+ KListView* rv = m_view->getResultsView();
+
+ rv->clear();
+
+ rv->setSorting(-1);
+
+ // show wait cursor
+ QApplication::setOverrideCursor( Qt::waitCursor );
+
+ freezeActions();
+
+ setOptionMask();
+
+ QString currentDirectory = m_option->m_directories[0],
+ currentFilter = m_option->m_filters[0];
+
+ //m_currentDir = currentDirectory;
+
+ m_view->showSemaphore("red");
+
+ uint filesNumber = 0;
+
+ if(m_option->m_recursive)
+ recursiveFileSearch(currentDirectory, currentFilter, filesNumber);
+ else
+ fileSearch(currentDirectory, currentFilter);
+
+ m_view->showSemaphore("yellow");
+
+ kapp->processEvents();
+
+ //disabling and enabling sorting... don't ask me why, but it works!
+ rv->setSorting(0);
+ rv->sort();
+ rv->setSorting(-1);
+
+ // restore false status for stop button
+ m_stop = false;
+
+ QApplication::restoreOverrideCursor();
+
+ emit setStatusBarText(i18n("Search completed."));
+
+ m_option->m_searchingOnlyMode = true;
+
+ resetActions();
+
+ m_searchingOperation = true;
+
+ m_view->showSemaphore("green");
+}
+
+void KFileReplacePart::slotReplacingOperation()
+{
+ if (KMessageBox::warningContinueCancel(m_w, i18n("<qt>You have selected <b>%1</b> as the encoding of the files.<br>Selecting the correct encoding is very important as if you have files that have some other encoding than the selected one, after a replace you may damage those files.<br><br>In case you do not know the encoding of your files, select <i>utf8</i> and <b>enable</b> the creation of backup files. This setting will autodetect <i>utf8</i> and <i>utf16</i> files, but the changed files will be converted to <i>utf8</i>.</qt>").arg(m_option->m_encoding), i18n("File Encoding Warning"), KStdGuiItem::cont(), "ShowEncodingWarning") == KMessageBox::Cancel)
+ return;
+ if(!checkBeforeOperation())
+ return;
+
+ KListView* rv = m_view->getResultsView();
+
+ if(m_option->m_simulation)
+ {
+ emit setStatusBarText(i18n("Replacing files (simulation)..."));
+ rv->setColumnText(4,i18n("Replaced strings (simulation)"));
+ }
+ else
+ {
+ emit setStatusBarText(i18n("Replacing files..."));
+ rv->setColumnText(4,i18n("Replaced strings"));
+ }
+ // show wait cursor
+ QApplication::setOverrideCursor( Qt::waitCursor );
+
+ freezeActions();
+
+ setOptionMask();
+
+ rv->setSorting(-1);
+
+ m_view->showSemaphore("green");
+
+ QString currentDirectory = m_option->m_directories[0];
+
+ m_view->showSemaphore("red");
+
+ if(m_option->m_recursive)
+ {
+ int filesNumber = 0;
+ recursiveFileReplace(currentDirectory, filesNumber);
+ }
+ else
+ {
+ fileReplace();
+ }
+
+ rv->setSorting(0);
+ rv->sort();
+ rv->setSorting(-1);
+
+ // restore false status for stop button
+ m_stop = false;
+
+ QApplication::restoreOverrideCursor();
+
+ m_option->m_searchingOnlyMode = false;
+
+ resetActions();
+
+ m_searchingOperation = false;
+
+ m_view->showSemaphore("green");
+}
+
+void KFileReplacePart::slotSimulatingOperation()
+{
+ m_option->m_simulation = true;
+ slotReplacingOperation();
+ m_option->m_simulation = false;
+}
+
+void KFileReplacePart::slotStop()
+{
+ emit setStatusBarText(i18n("Stopping..."));
+ m_stop = true;
+ QApplication::restoreOverrideCursor();
+ resetActions();
+}
+
+void KFileReplacePart::slotCreateReport()
+{
+ // Check there are results
+ KListView* rv = m_view->getResultsView(),
+ * sv = m_view->getStringsView();
+
+ if(rv->firstChild() == 0)
+ {
+ KMessageBox::error(m_w, i18n("There are no results to save: the result list is empty."));
+ return ;
+ }
+ // Select the file where results will be saved
+ QString documentName = KFileDialog::getSaveFileName(QString::null, "*.xml|XML " + i18n("Files") + " (*.xml)", m_w, i18n("Save Report"));
+ if (documentName.isEmpty())
+ return ;
+
+ // delete a spourious extension
+ documentName.truncate(documentName.length()-4);
+
+ QFileInfo fileInfo(documentName);
+ if(fileInfo.exists())
+ {
+ KMessageBox::error(m_w, i18n("<qt>A folder or a file named <b>%1</b> already exists.</qt>").arg(documentName));
+ return ;
+ }
+
+ QDir directoryName;
+
+ if(!directoryName.mkdir(documentName, true))
+ {
+ KMessageBox::error(m_w, i18n("<qt>Cannot create the <b>%1</b> folder.</qt>").arg(documentName));
+ return ;
+ }
+
+ directoryName.cd(documentName);
+
+ QString documentPath = documentName+"/"+directoryName.dirName();
+
+ Report report(m_option, rv, sv);
+ report.createDocument(documentPath);
+
+ //resetActions();
+}
+
+void KFileReplacePart::slotStringsAdd()
+{
+ m_view->slotStringsAdd();
+ resetActions();
+}
+
+void KFileReplacePart::slotQuickStringsAdd()
+{
+ //this slot handles a pair of strings that come from project dialog,
+ //if the control character 'N' is found at the position 0 of the two strings,
+ //then we start the search now.
+ QString qs = m_option->m_quickSearchString;
+ QStringList map;
+
+ map.append(qs.left(1));
+ map.append(qs.right(qs.length()-1));
+ //in this case there is no string to search for, so return
+ if(map[1].isEmpty())
+ return;
+
+ //in this one instead, we must search for a string
+ qs = m_option->m_quickReplaceString;
+ map.append(qs.left(1));
+ map.append(qs.right(qs.length()-1));
+
+ m_view->updateOptions(m_option);
+
+ m_view->slotQuickStringsAdd(map[1],map[3]);
+
+ //if search-only mode == true and search-now mode == true then
+ //search string
+ if(map[0] == "N")
+ if(m_option->m_searchingOnlyMode)
+ slotSearchingOperation();
+ else
+ slotReplacingOperation();
+}
+
+void KFileReplacePart::slotStringsDeleteItem()
+{
+ m_view->slotStringsDeleteItem();
+ resetActions();
+}
+
+void KFileReplacePart::slotStringsEmpty()
+{
+ m_view->slotStringsEmpty();
+ resetActions();
+}
+
+void KFileReplacePart::slotStringsEdit()
+{
+ m_view->slotStringsEdit();
+ resetActions();
+}
+
+void KFileReplacePart::slotStringsSave()
+{
+ m_view->slotStringsSave();
+}
+
+void KFileReplacePart::slotStringsLoad()
+{
+ // Selects the file to load from
+ QString menu = "*.kfr|" + i18n("KFileReplace strings") + " (*.kfr)\n*|"+i18n("All Files") + " (*)";
+ QString fileName = KFileDialog::getOpenFileName(QString::null, menu, m_w, i18n("Load Strings From File"));
+
+ if(!fileName.isEmpty())
+ loadRulesFile(fileName);
+
+ resetActions();
+}
+
+void KFileReplacePart::slotStringsInvertCur()
+{
+ m_view->stringsInvert(false);
+ resetActions();
+}
+
+void KFileReplacePart::slotStringsInvertAll()
+{
+ m_view->stringsInvert(true);
+ resetActions();
+}
+
+void KFileReplacePart::slotOpenRecentStringFile(const KURL& urlFile)
+{
+ QString fileName;
+
+ // Downloads file if need (if url is "http://...")
+ if (!(KIO::NetAccess::download(urlFile, fileName, 0)))
+ return;
+
+ // Checks it's not a directory
+ QFileInfo fileInfo;
+ fileInfo.setFile(fileName);
+ if(fileInfo.isDir())
+ {
+ KMessageBox::error(m_w, i18n("Cannot open folders."));
+ return;
+ }
+
+ loadRulesFile(fileName);
+ resetActions();
+}
+
+void KFileReplacePart::slotOptionRecursive()
+{
+ m_option->m_recursive = !m_option->m_recursive;
+ resetActions();
+}
+
+void KFileReplacePart::slotOptionBackup()
+{
+ m_option->m_backup = !m_option->m_backup;
+ resetActions();
+}
+
+void KFileReplacePart::slotOptionCaseSensitive()
+{
+ m_option->m_caseSensitive = !m_option->m_caseSensitive;
+ resetActions();
+}
+
+void KFileReplacePart::slotOptionVariables()
+{
+ m_option->m_variables = !m_option->m_variables;
+ resetActions();
+}
+
+void KFileReplacePart::slotOptionRegularExpressions()
+{
+ m_option->m_regularExpressions = !m_option->m_regularExpressions;
+ resetActions();
+}
+
+void KFileReplacePart::slotOptionPreferences()
+{
+ KOptionsDlg dlg(m_option, m_w, 0);
+
+ if(!dlg.exec())
+ return;
+
+ //updating m_view
+ m_view->updateOptions(m_option);
+
+ resetActions();
+}
+
+void KFileReplacePart::showAboutApplication()
+{
+ m_aboutDlg = new KAboutApplication(createAboutData(), (QWidget *)0, (const char *)0, false);
+ if(m_aboutDlg == 0)
+ return;
+
+ if(!m_aboutDlg->isVisible())
+ m_aboutDlg->show();
+ else
+ m_aboutDlg->raise();
+}
+
+void KFileReplacePart::appHelpActivated()
+{
+ kapp->invokeHelp(QString::null, "kfilereplace");
+}
+
+void KFileReplacePart::reportBug()
+{
+ KBugReport dlg(m_w, true, createAboutData());
+ dlg.exec();
+}
+
+void KFileReplacePart::resetActions()
+{
+ KListView* rv = m_view->getResultsView(),
+ * sv = m_view->getStringsView();
+
+ bool hasItems = (sv->firstChild() != 0),
+ 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("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_load")->setEnabled(true);
+ actionCollection()->action("strings_invert")->setEnabled(hasItems && !searchOnlyMode);
+ actionCollection()->action("strings_invert_all")->setEnabled(hasItems && !searchOnlyMode);
+
+ // Options
+ actionCollection()->action("options_recursive")->setEnabled(true);
+ actionCollection()->action("options_backup")->setEnabled(!searchOnlyMode);
+ actionCollection()->action("options_case")->setEnabled(true);
+ actionCollection()->action("options_var")->setEnabled(!searchOnlyMode);
+ actionCollection()->action("options_regularexpressions")->setEnabled(true);
+ actionCollection()->action("configure_kfilereplace")->setEnabled(true);
+
+ hasItems = (rv->firstChild() != 0);
+
+ // Results
+ actionCollection()->action("results_infos")->setEnabled(hasItems);
+ actionCollection()->action("results_openfile")->setEnabled(hasItems);
+ 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);
+
+ // Updates menus and toolbar
+ ((KToggleAction* ) actionCollection()->action("options_recursive"))->setChecked(m_option->m_recursive);
+ ((KToggleAction* ) actionCollection()->action("options_backup"))->setChecked(m_option->m_backup && !searchOnlyMode);
+ ((KToggleAction* ) actionCollection()->action("options_case"))->setChecked(m_option->m_caseSensitive);
+ ((KToggleAction* ) actionCollection()->action("options_var"))->setChecked(m_option->m_variables && !searchOnlyMode);
+ ((KToggleAction* ) actionCollection()->action("options_regularexpressions"))->setChecked(m_option->m_regularExpressions);
+}
+
+//PUBLIC METHODS
+KAboutData* KFileReplacePart::createAboutData()
+{
+ KAboutData * aboutData = new KAboutData("kfilereplacepart",
+ I18N_NOOP("KFileReplacePart"),
+ KFR_VERSION,
+ I18N_NOOP( "Batch search and replace tool."),
+ KAboutData::License_GPL_V2,
+ "(C) 1999-2002 Fran�is Dupoux\n(C) 2003-2004 Andras Mantia\n(C) 2004 Emiliano Gulmini", I18N_NOOP("Part of the KDEWebDev module."), "http://www.kdewebdev.org");
+ aboutData->addAuthor("Fran�is Dupoux",
+ I18N_NOOP("Original author of the KFileReplace tool"),
+ "dupoux@dupoux.com");
+ aboutData->addAuthor("Emiliano Gulmini",
+ I18N_NOOP("Current maintainer, code cleaner and rewriter"),
+ "emi_barbarossa@yahoo.it");
+ aboutData->addAuthor("Andras Mantia",
+ I18N_NOOP("Co-maintainer, KPart creator"),
+ "amantia@kde.org");
+ aboutData->addCredit("Heiko Goller",
+ I18N_NOOP("Original german translator"),
+ "heiko.goller@tuebingen.mpg.de");
+ return aboutData;
+}
+
+//PROTECTED METHODS
+bool KFileReplacePart::openURL(const KURL &url)
+{
+ if(!url.isEmpty() && (url.protocol() != "file"))
+ {
+ KMessageBox::sorry(m_w, i18n("Sorry, currently the KFileReplace part works only for local files."), i18n("Non Local File"));
+ emit canceled("");
+ return false;
+ }
+ if(!url.isEmpty())
+ return launchNewProjectDialog(url);
+ else
+ {
+ resetActions();
+ return true;
+ }
+}
+
+//PRIVATE METHODS
+void KFileReplacePart::initGUI()
+{
+ setXMLFile("kfilereplacepartui.rc");
+
+ actionCollection()->setHighlightingEnabled(true);
+
+ DCOPClient *client = kapp->dcopClient();
+ QCStringList appList = client->registeredApplications();
+ bool quantaFound = false;
+ for(QCStringList::Iterator it = appList.begin(); it != appList.end(); ++it)
+ {
+ if((*it).left(6) == "quanta")
+ {
+ quantaFound = true;
+ break;
+ }
+ }
+ // File
+ (void)new KAction(i18n("Customize Search/Replace Session..."), "projectopen", 0, this, SLOT(slotSetNewParameters()), actionCollection(), "new_project");
+ (void)new KAction(i18n("&Search"), "filesearch", 0, this, SLOT(slotSearchingOperation()), actionCollection(), "search");
+ (void)new KAction(i18n("S&imulate"), "filesimulate", 0, this, SLOT(slotSimulatingOperation()), actionCollection(), "file_simulate");
+ (void)new KAction(i18n("&Replace"), "filereplace", 0, this, SLOT(slotReplacingOperation()), actionCollection(), "replace");
+ (void)new KAction(i18n("Sto&p"), "stop", 0, this, SLOT(slotStop()), actionCollection(), "stop");
+ (void)new KAction(i18n("Cre&ate Report File..."), "filesaveas", 0, this, SLOT(slotCreateReport()), actionCollection(), "save_results");
+
+ // Strings
+ (void)new KAction(i18n("&Add String..."), "editadd", 0, this, SLOT(slotStringsAdd()), actionCollection(), "strings_add");
+
+ (void)new KAction(i18n("&Delete String"), "editremove", 0, this, SLOT(slotStringsDeleteItem()), actionCollection(), "strings_del");
+ (void)new KAction(i18n("&Empty Strings List"), "editdelete", 0, this, SLOT(slotStringsEmpty()), actionCollection(), "strings_empty");
+ (void)new KAction(i18n("Edit Selected String..."), "edit", 0, this, SLOT(slotStringsEdit()), actionCollection(), "strings_edit");
+ (void)new KAction(i18n("&Save Strings List to File..."), "filesaveas", 0, this, SLOT(slotStringsSave()), actionCollection(), "strings_save");
+ (void)new KAction(i18n("&Load Strings List From File..."), "unsortedList", 0, this, SLOT(slotStringsLoad()), actionCollection(), "strings_load");
+ (void)new KRecentFilesAction(i18n("&Load Recent Strings Files"), "fileopen", 0, this, SLOT(slotOpenRecentStringFile(const KURL&)), actionCollection(),"strings_load_recent");
+ (void)new KAction(i18n("&Invert Current String (search <--> replace)"), "invert", 0, this, SLOT(slotStringsInvertCur()), actionCollection(), "strings_invert");
+ (void)new KAction(i18n("&Invert All Strings (search <--> replace)"), "invert", 0, this, SLOT(slotStringsInvertAll()), actionCollection(), "strings_invert_all");
+
+ // Options
+ (void)new KToggleAction(i18n("&Include Sub-Folders"), "recursive_option", 0, this, SLOT(slotOptionRecursive()), actionCollection(), "options_recursive");
+ (void)new KToggleAction(i18n("Create &Backup Files"), "backup_option", 0, this, SLOT(slotOptionBackup()), actionCollection(), "options_backup");
+ (void)new KToggleAction(i18n("Case &Sensitive"), "casesensitive_option", 0, this, SLOT(slotOptionCaseSensitive()), actionCollection(), "options_case");
+ (void)new KToggleAction(i18n("Enable Commands &in Replace String: [$command:option$]"), "command_option", 0, this, SLOT(slotOptionVariables()), actionCollection(), "options_var");
+ (void)new KToggleAction(i18n("Enable &Regular Expressions"), "regularexpression_option", 0, this, SLOT(slotOptionRegularExpressions()), actionCollection(), "options_regularexpressions");
+ (void)new KAction(i18n("Configure &KFileReplace..."), "configure", 0, this, SLOT(slotOptionPreferences()), actionCollection(), "configure_kfilereplace");
+
+ // Results
+ (void)new KAction(i18n("&Properties"), "informations", 0, m_view, SLOT(slotResultProperties()), actionCollection(), "results_infos");
+ (void)new KAction(i18n("&Open"), "filenew", 0, m_view, SLOT(slotResultOpen()), actionCollection(), "results_openfile");
+
+ if(quantaFound)
+ {
+ (void)new KAction(i18n("&Edit in Quanta"), "quanta", 0, m_view, SLOT(slotResultEdit()), actionCollection(), "results_editfile");
+ }
+ (void)new KAction(i18n("Open Parent &Folder"), "fileopen", 0, m_view, SLOT(slotResultDirOpen()), actionCollection(), "results_opendir");
+ (void)new KAction(i18n("&Delete"), "editdelete", 0, m_view, SLOT(slotResultDelete()), actionCollection(), "results_delete");
+ (void)new KAction(i18n("E&xpand Tree"), 0, m_view, SLOT(slotResultTreeExpand()), actionCollection(), "results_treeexpand");
+ (void)new KAction(i18n("&Reduce Tree"), 0, m_view, SLOT(slotResultTreeReduce()), actionCollection(), "results_treereduce");
+ (void)new KAction(i18n("&About KFileReplace"), "kfilereplace", 0, this, SLOT(showAboutApplication()), actionCollection(), "help_about_kfilereplace");
+ (void)new KAction(i18n("KFileReplace &Handbook"), "help", 0, this, SLOT(appHelpActivated()), actionCollection(), "help_kfilereplace");
+ (void)new KAction(i18n("&Report Bug"), 0, 0, this, SLOT(reportBug()), actionCollection(), "report_bug");
+
+}
+
+void KFileReplacePart::initView()
+{
+ m_view = new KFileReplaceView(m_option, m_parentWidget, "view");
+
+ setWidget(m_view);
+
+ m_view->setAcceptDrops(false);
+
+ m_view->showSemaphore("green");
+}
+
+void KFileReplacePart::freezeActions()
+{
+ //Disables actions during search/replace operation
+ actionCollection()->action("new_project")->setEnabled(false);
+ actionCollection()->action("stop")->setEnabled(true);
+
+ actionCollection()->action("file_simulate")->setEnabled(false);
+ actionCollection()->action("replace")->setEnabled(false);
+ actionCollection()->action("search")->setEnabled(false);
+ 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);
+ actionCollection()->action("strings_invert_all")->setEnabled(false);
+ actionCollection()->action("options_recursive")->setEnabled(false);
+ actionCollection()->action("options_backup")->setEnabled(false);
+ actionCollection()->action("options_case")->setEnabled(false);
+ actionCollection()->action("options_var")->setEnabled(false);
+ actionCollection()->action("options_regularexpressions")->setEnabled(false);
+ actionCollection()->action("configure_kfilereplace")->setEnabled(false);
+ 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_delete")->setEnabled(false);
+ actionCollection()->action("results_treeexpand")->setEnabled(false);
+ actionCollection()->action("results_treereduce")->setEnabled(false);
+ ((KToggleAction* ) actionCollection()->action("options_recursive"))->setChecked(false);
+ ((KToggleAction* ) actionCollection()->action("options_backup"))->setChecked(false);
+ ((KToggleAction* ) actionCollection()->action("options_case"))->setChecked(false);
+ ((KToggleAction* ) actionCollection()->action("options_var"))->setChecked(false);
+ ((KToggleAction* ) actionCollection()->action("options_regularexpressions"))->setChecked(false);
+}
+
+void KFileReplacePart::loadOptionsFromRC()
+{
+ m_option = new RCOptions();
+
+ loadOptions();
+ loadFileSizeOptions();
+ loadDateAccessOptions();
+ loadOwnerOptions();
+ loadLocationsList();
+ loadFiltersList();
+ loadBackupExtensionOptions();
+}
+
+void KFileReplacePart::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");
+
+ m_option->m_encoding = m_config->readEntry(rcEncoding, EncodingOption);
+ m_option->m_recursive = m_config->readBoolEntry(rcRecursive, RecursiveOption);
+
+ m_option->m_caseSensitive = m_config->readBoolEntry(rcCaseSensitive, CaseSensitiveOption);
+ m_option->m_variables = m_config->readBoolEntry(rcVariables, VariablesOption);
+ m_option->m_regularExpressions = m_config->readBoolEntry(rcRegularExpressions, RegularExpressionsOption);
+ m_option->m_followSymLinks = m_config->readBoolEntry(rcFollowSymLinks, FollowSymbolicLinksOption);
+
+ m_option->m_haltOnFirstOccur = m_config->readBoolEntry(rcHaltOnFirstOccur, StopWhenFirstOccurenceOption);
+
+ m_option->m_ignoreHidden = m_config->readBoolEntry(rcIgnoreHidden, IgnoreHiddenOption);
+ m_option->m_ignoreFiles = m_config->readBoolEntry(rcIgnoreFiles, IgnoreFilesOption);
+
+ m_config->setGroup("Notification Messages");
+
+ m_option->m_notifyOnErrors = m_config->readBoolEntry(rcNotifyOnErrors, true);
+
+ m_option->m_askConfirmReplace = m_config->readBoolEntry(rcAskConfirmReplace, AskConfirmReplaceOption);
+
+ QString dontAskAgain = m_config->readEntry(rcDontAskAgain, "no");
+
+ if(dontAskAgain == "yes")
+ m_option->m_askConfirmReplace = false;
+}
+
+void KFileReplacePart::loadFileSizeOptions()
+{
+ m_config->setGroup("Size options");
+
+ m_option->m_minSize = m_config->readNumEntry(rcMinFileSize, FileSizeOption);
+ m_option->m_maxSize = m_config->readNumEntry(rcMaxFileSize, FileSizeOption);
+}
+
+void KFileReplacePart::loadDateAccessOptions()
+{
+ m_config->setGroup("Access options");
+
+ m_option->m_dateAccess = m_config->readEntry(rcValidAccessDate, ValidAccessDateOption);
+ m_option->m_minDate = m_config->readEntry(rcMinDate, AccessDateOption);
+ m_option->m_maxDate = m_config->readEntry(rcMaxDate, AccessDateOption);
+}
+
+void KFileReplacePart::loadOwnerOptions()
+{
+ m_config->setGroup("Owner options");
+
+ QStringList ownerList = QStringList::split(',',m_config->readEntry(rcOwnerUser, OwnerOption),true);
+ if(ownerList[0] == "true")
+ m_option->m_ownerUserIsChecked = true;
+ else
+ m_option->m_ownerUserIsChecked = false;
+
+ m_option->m_ownerUserType = ownerList[1];
+ m_option->m_ownerUserBool = ownerList[2];
+ m_option->m_ownerUserValue = ownerList[3];
+
+ ownerList = QStringList::split(',',m_config->readEntry(rcOwnerGroup, OwnerOption),true);
+
+ if(ownerList[0] == "true")
+ m_option->m_ownerGroupIsChecked = true;
+ else
+ m_option->m_ownerGroupIsChecked = false;
+
+ m_option->m_ownerGroupType = ownerList[1];
+ m_option->m_ownerGroupBool = ownerList[2];
+ m_option->m_ownerGroupValue = ownerList[3];
+}
+
+void KFileReplacePart::loadLocationsList()
+{
+ m_config->setGroup("Directories");
+ QStringList locationsEntryList;
+ #if KDE_IS_VERSION(3,1,3)
+ locationsEntryList = m_config->readPathListEntry(rcDirectoriesList);
+ #else
+ locationsEntryList = m_config->readListEntry(rcDirectoriesList);
+ #endif
+
+ if(locationsEntryList.isEmpty())
+ locationsEntryList.append(QDir::current().path());
+
+ m_option->m_directories = locationsEntryList;
+}
+
+void KFileReplacePart::loadFiltersList()
+{
+ QStringList filtersEntryList;
+
+ m_config->setGroup("Filters");
+ #if KDE_IS_VERSION(3,1,3)
+ filtersEntryList = m_config->readPathListEntry(rcFiltersList);
+ #else
+ filtersEntryList = m_config->readListEntry(rcFiltersList);
+ #endif
+
+ if(filtersEntryList.isEmpty())
+ filtersEntryList.append("*.htm;*.html;*.xml;*.xhtml;*.css;*.js;*.php");
+
+ m_option->m_filters = filtersEntryList;
+}
+
+void KFileReplacePart::loadBackupExtensionOptions()
+{
+ m_config->setGroup("Options");
+ QStringList bkList = QStringList::split(',',
+ m_config->readEntry(rcBackupExtension, BackupExtensionOption),
+ true);
+ if(bkList[0] == "true")
+ m_option->m_backup = true;
+ else
+ m_option->m_backup = false;
+
+ m_option->m_backupExtension = bkList[1];
+}
+
+void KFileReplacePart::saveOptionsToRC()
+{
+ saveOptions();
+ saveFileSizeOptions();
+ saveDateAccessOptions();
+ saveOwnerOptions();
+ saveLocationsList();
+ saveFiltersList();
+ saveBackupExtensionOptions();
+}
+
+void KFileReplacePart::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");
+
+ m_config->writeEntry(rcEncoding, m_option->m_encoding);
+ m_config->writeEntry(rcRecursive, m_option->m_recursive);
+ m_config->writeEntry(rcCaseSensitive, m_option->m_caseSensitive);
+ m_config->writeEntry(rcVariables, m_option->m_variables);
+ m_config->writeEntry(rcRegularExpressions, m_option->m_regularExpressions);
+
+ m_config->writeEntry(rcFollowSymLinks, m_option->m_followSymLinks);
+ m_config->writeEntry(rcHaltOnFirstOccur, m_option->m_haltOnFirstOccur);
+
+ m_config->writeEntry(rcIgnoreHidden, m_option->m_ignoreHidden);
+ m_config->writeEntry(rcIgnoreFiles, m_option->m_ignoreFiles);
+
+ m_config->setGroup("Notification Messages");
+ m_config->writeEntry(rcNotifyOnErrors, m_option->m_notifyOnErrors);
+ if(m_config->readEntry(rcDontAskAgain,"no") == "yes")
+ m_config->writeEntry(rcAskConfirmReplace, false);
+ else
+ m_config->writeEntry(rcAskConfirmReplace, m_option->m_askConfirmReplace);
+
+ m_config->sync();
+}
+
+void KFileReplacePart::saveFileSizeOptions()
+{
+ m_config->setGroup("Size options");
+
+ m_config->writeEntry(rcMaxFileSize, m_option->m_maxSize);
+ m_config->writeEntry(rcMinFileSize, m_option->m_minSize);
+
+ m_config->sync();
+}
+
+void KFileReplacePart::saveDateAccessOptions()
+{
+ m_config->setGroup("Access options");
+
+ m_config->writeEntry(rcValidAccessDate, m_option->m_dateAccess);
+ m_config->writeEntry(rcMinDate, m_option->m_minDate);
+ m_config->writeEntry(rcMaxDate, m_option->m_maxDate);
+
+ m_config->sync();
+}
+
+void KFileReplacePart::saveOwnerOptions()
+{
+ m_config->setGroup("Owner options");
+
+ QString list;
+ if(m_option->m_ownerUserIsChecked)
+ list = "true,";
+ else
+ list = "false,";
+
+ list += m_option->m_ownerUserType +
+ "," +
+ m_option->m_ownerUserBool;
+ if(!m_option->m_ownerUserValue.isEmpty())
+ list += "," + m_option->m_ownerUserValue;
+
+ m_config->writeEntry(rcOwnerUser,list);
+
+ if(m_option->m_ownerGroupIsChecked)
+ list = "true,";
+ else
+ list = "false,";
+
+ list += m_option->m_ownerGroupType +
+ "," +
+ m_option->m_ownerGroupBool;
+ if(!m_option->m_ownerGroupValue.isEmpty())
+ list += "," + m_option->m_ownerGroupValue;
+
+ m_config->writeEntry(rcOwnerGroup,list);
+ m_config->sync();
+}
+
+void KFileReplacePart::saveLocationsList()
+{
+ m_config->setGroup("Directories");
+ #if KDE_IS_VERSION(3,1,3)
+ m_config->writePathEntry(rcDirectoriesList, m_option->m_directories);
+ #else
+ m_config->writeEntry(rcDirectoriesList, m_option->m_directories);
+ #endif
+ m_config->sync();
+}
+
+void KFileReplacePart::saveFiltersList()
+{
+ m_config->setGroup("Filters");
+ m_config->writeEntry(rcFiltersList, m_option->m_filters);
+ m_config->sync();
+}
+
+void KFileReplacePart::saveBackupExtensionOptions()
+{
+ m_config->setGroup("Options");
+ QString bkOptions;
+ if(m_option->m_backup)
+ bkOptions = "true," + m_option->m_backupExtension;
+ else
+ bkOptions = "false," + m_option->m_backupExtension;
+
+ m_config->writeEntry(rcBackupExtension, bkOptions);
+ m_config->sync();
+}
+
+void KFileReplacePart::fileReplace()
+{
+ QString directoryName = m_option->m_directories[0];
+ QDir d(directoryName);
+ d.setMatchAllDirs(true);
+ d.setFilter(m_optionMask);
+
+ QString currentFilter = m_option->m_filters[0];
+ QStringList filesList = d.entryList(currentFilter);
+ QStringList::iterator filesIt;
+ int filesNumber = 0;
+
+ m_view->displayScannedFiles(filesNumber);
+
+ for (filesIt = filesList.begin(); filesIt != filesList.end() ; ++filesIt)
+ {
+ QString fileName = (*filesIt);
+
+ // m_stop == true means that we pushed the stop button
+ if(m_stop)
+ break;
+
+ // Avoids files that not match requirements
+ if(!KFileReplaceLib::isAnAccessibleFile(d.canonicalPath(), fileName, m_option))
+ continue;
+ kapp->processEvents();
+ if(m_option->m_backup)
+ replaceAndBackup(d.canonicalPath(), fileName);
+ else
+ replaceAndOverwrite(d.canonicalPath(), fileName);
+
+ filesNumber++;
+ m_view->displayScannedFiles(filesNumber);
+ }
+}
+
+void KFileReplacePart::recursiveFileReplace(const QString& directoryName, int& filesNumber)
+{
+ //if m_stop == true then interrupts recursion
+ if(m_stop)
+ return;
+ else
+ {
+ QDir d(directoryName);
+
+ d.setMatchAllDirs(true);
+ d.setFilter(m_optionMask);
+
+ QString currentFilter = m_option->m_filters[0];
+ QStringList filesList = d.entryList(currentFilter);
+ QStringList::iterator filesIt;
+
+ for(filesIt = filesList.begin(); filesIt != filesList.end(); ++filesIt)
+ {
+ //if m_stop == true then end for-loop
+ if(m_stop)
+ break;
+
+ QString fileName = (*filesIt);
+
+ // Avoids files that not match requirements
+ if(!KFileReplaceLib::isAnAccessibleFile(d.canonicalPath(),fileName, m_option))
+ continue;
+
+ QString filePath = d.canonicalPath()+"/"+fileName;
+
+ QFileInfo qi(filePath);
+
+ m_view->displayScannedFiles(filesNumber);
+
+ //if filePath is a directory then recursion
+ if(qi.isDir())
+ recursiveFileReplace(filePath, filesNumber);
+ else
+ {
+ kapp->processEvents();
+ if(m_option->m_backup)
+ replaceAndBackup(d.canonicalPath(), fileName);
+ else
+ replaceAndOverwrite(d.canonicalPath(), fileName);
+
+ filesNumber++;
+ m_view->displayScannedFiles(filesNumber);
+ }
+ }
+ }
+}
+
+void KFileReplacePart::replaceAndBackup(const QString& currentDir, const QString& oldFileName)
+{
+ //Creates a path string
+ QString oldPathString = currentDir+"/"+oldFileName;
+
+ QFile currentFile(oldPathString);
+ if(!currentFile.open(IO_ReadOnly))
+ {
+ KMessageBox::information(m_w, i18n("<qt>Cannot open file <b>%1</b> for reading.</qt>").arg(oldFileName),QString::null, rcNotifyOnErrors);
+ return ;
+ }
+ QTextStream currentStream(&currentFile);
+ if (m_option->m_encoding == "utf8")
+ currentStream.setEncoding(QTextStream::UnicodeUTF8);
+ else
+ currentStream.setCodec(QTextCodec::codecForName(m_option->m_encoding));
+ QString line = currentStream.read(),
+ backupLine = line;
+
+ QString backupSize = KFileReplaceLib::formatFileSize(currentFile.size());
+
+ currentFile.close();
+
+ QString backupExtension = m_option->m_backupExtension;
+
+ bool atLeastOneStringFound = false;
+ KListViewItem *item = 0;
+ int occurrence = 0;
+
+ replacingLoop(line, &item, atLeastOneStringFound, occurrence, m_option->m_regularExpressions, m_option->m_askConfirmReplace);
+
+ //If we are not performing a simulation creates a backup file
+ if(!m_option->m_simulation)
+ {
+ if(atLeastOneStringFound)
+ {
+ KIO::NetAccess::file_copy(KURL::fromPathOrURL(oldPathString), KURL::fromPathOrURL(oldPathString + backupExtension), -1, true);
+ }
+ }
+
+ if(!m_option->m_simulation)
+ {
+ if(atLeastOneStringFound)
+ {
+ QFile newFile(oldPathString);
+ if(!newFile.open(IO_WriteOnly))
+ {
+ KMessageBox::information(m_w, i18n("<qt>Cannot open file <b>%1</b> for writing.</qt>").arg(oldFileName),QString::null, rcNotifyOnErrors);
+ return ;
+ }
+ QTextStream newStream(&newFile);
+ if (m_option->m_encoding == "utf8")
+ newStream.setEncoding(QTextStream::UnicodeUTF8);
+ else
+ newStream.setCodec(QTextCodec::codecForName(m_option->m_encoding));
+ newStream << line;
+ newFile.close();
+ }
+ }
+
+ if(!m_option->m_ignoreFiles)
+ atLeastOneStringFound = true;
+
+ QFileInfo oldFileInfo(oldPathString);
+
+ if(atLeastOneStringFound && item/* && atLeastOneStringConfirmed*/)
+ {
+ KFileReplaceLib::setIconForFileEntry(item,currentDir+"/"+oldFileName);
+ item->setText(0,oldFileName);
+ item->setText(1,currentDir);
+ QString newSize = KFileReplaceLib::formatFileSize(oldFileInfo.size());
+ if(!m_option->m_simulation)
+ {
+ item->setText(2, backupSize);
+ item->setText(3, newSize);
+ }
+ else
+ {
+ item->setText(2, backupSize);
+ item->setText(3, "-");
+ }
+
+ item->setText(4,QString::number(occurrence,10));
+ item->setText(5,QString("%1[%2]").arg(oldFileInfo.owner()).arg(oldFileInfo.ownerId()));
+ item->setText(6,QString("%1[%2]").arg(oldFileInfo.group()).arg(oldFileInfo.groupId()));
+ }
+}
+
+void KFileReplacePart::replaceAndOverwrite(const QString& currentDir, const QString& oldFileName)
+{
+ QString oldPathString = currentDir+"/"+oldFileName;
+ QFile oldFile(oldPathString);
+ QFileInfo oldFileInfo(oldPathString);
+
+ if (!oldFile.open(IO_ReadOnly))
+ {
+ KMessageBox::information(m_w, i18n("<qt>Cannot open file <b>%1</b> for reading.</qt>").arg(oldFile.name()),QString::null, rcNotifyOnErrors);
+ return ;
+ }
+
+ QString fileSizeBeforeReplacing = KFileReplaceLib::formatFileSize(oldFileInfo.size());
+ KListViewItem *item = 0;
+
+ QTextStream oldStream( &oldFile );
+ if (m_option->m_encoding == "utf8")
+ oldStream.setEncoding(QTextStream::UnicodeUTF8);
+ else
+ oldStream.setCodec(QTextCodec::codecForName(m_option->m_encoding));
+ QString line = oldStream.read();
+
+ oldFile.close();
+
+ bool atLeastOneStringFound = false;
+ int occurrence = 0;
+
+ replacingLoop(line, &item, atLeastOneStringFound, occurrence, m_option->m_regularExpressions, m_option->m_askConfirmReplace);
+
+
+ if(!m_option->m_simulation)
+ {
+ if(atLeastOneStringFound)
+ {
+ QFile newFile(oldPathString);
+ if(!newFile.open(IO_WriteOnly))
+ {
+ KMessageBox::information(m_w, i18n("<qt>Cannot open file <b>%1</b> for writing.</qt>").arg(newFile.name()),QString::null, rcNotifyOnErrors);
+ return ;
+ }
+ QTextStream newStream( &newFile );
+ if (m_option->m_encoding == "utf8")
+ newStream.setEncoding(QTextStream::UnicodeUTF8);
+ else
+ newStream.setCodec(QTextCodec::codecForName(m_option->m_encoding));
+ newStream << line;
+ newFile.close();
+ }
+ }
+
+ QFileInfo nf(oldPathString);
+ QString fileSizeAfterReplacing = KFileReplaceLib::formatFileSize(nf.size());
+
+ //if ignoreFiles == false then every files must be show
+ if(!m_option->m_ignoreFiles)
+ atLeastOneStringFound = true;
+
+ if(atLeastOneStringFound && item/*&& atLeastOneStringConfirmed*/)
+ {
+ KFileReplaceLib::setIconForFileEntry(item,currentDir+"/"+oldFileName);
+ item->setText(0,oldFileName);
+ item->setText(1,currentDir);
+ item->setText(2,fileSizeBeforeReplacing);
+ if(!m_option->m_simulation)
+ item->setText(3,fileSizeAfterReplacing);
+ else
+ item->setText(3,"-");
+
+ item->setText(4,QString::number(occurrence,10));
+ item->setText(5,QString("%1[%2]").arg(oldFileInfo.owner()).arg(oldFileInfo.ownerId()));
+ item->setText(6,QString("%1[%2]").arg(oldFileInfo.group()).arg(oldFileInfo.groupId()));
+ }
+}
+
+void KFileReplacePart::replacingLoop(QString& line, KListViewItem** item, bool& atLeastOneStringFound, int& occur, bool regularExpression, bool& askConfirmReplace)
+{
+ KeyValueMap tempMap = m_replacementMap;
+ KeyValueMap::Iterator it;
+ KListView* rv = m_view->getResultsView();
+
+ for(it = tempMap.begin(); it != tempMap.end(); ++it)
+ {
+ if(m_stop)
+ break;
+
+ ResultViewEntry entry(it.key(), it.data(), regularExpression, m_option->m_caseSensitive);
+ while(entry.pos(line) != -1)
+ {
+ if(m_stop)
+ break;
+
+ if(askConfirmReplace)
+ {
+ int answer = KMessageBox::questionYesNo(0,
+ i18n("<qt>Do you want to replace the string <b>%1</b> with the string <b>%2</b>?</qt>").arg(it.key()).arg(it.data()),
+ i18n("Confirm Replace"),
+ i18n("Replace"),
+ i18n("Do Not Replace"),
+ rcDontAskAgain);
+ if(answer == KMessageBox::Yes)
+ {
+ atLeastOneStringFound = true;
+ QString msg = entry.message(entry.capturedText(line),
+ entry.lineNumber(line),
+ entry.columnNumber(line));
+
+ if(!*item)
+ *item = new KListViewItem(rv);
+ KListViewItem* tempItem = new KListViewItem(*item);
+ tempItem->setMultiLinesEnabled(true);
+ tempItem->setText(0,msg);
+ occur ++;
+ entry.updateLine(line);
+ entry.incPos();
+ }
+ else
+ {
+ entry.incPos();
+ }
+ if(dontAskAgain()) askConfirmReplace = false;
+ }
+ else
+ {
+ atLeastOneStringFound = true;
+ QString msg = entry.message(entry.capturedText(line),
+ entry.lineNumber(line),
+ entry.columnNumber(line));
+
+ if(!*item)
+ *item = new KListViewItem(rv);
+ KListViewItem* tempItem = new KListViewItem(*item);
+ tempItem->setMultiLinesEnabled(true);
+ tempItem->setText(0,msg);
+ occur ++;
+ entry.updateLine(line);
+ entry.incPos();
+ }
+
+ }
+ }
+}
+
+void KFileReplacePart::fileSearch(const QString& directoryName, const QString& filters)
+{
+ QDir d(directoryName);
+
+ d.setMatchAllDirs(true);
+ d.setFilter(m_optionMask);
+
+ QStringList filesList = d.entryList(filters);
+ QString filePath = d.canonicalPath();
+ QStringList::iterator filesIt;
+ uint filesNumber = 0;
+
+ m_view->displayScannedFiles(filesNumber);
+
+ for (filesIt = filesList.begin(); filesIt != filesList.end() ; ++filesIt)
+ {
+ // We pushed stop button
+ if(m_stop)
+ break;
+
+ QString fileName = (*filesIt);
+
+ // Avoids files that not match
+ if(!KFileReplaceLib::isAnAccessibleFile(filePath, fileName, m_option))
+ continue;
+
+ QFileInfo fileInfo(filePath+"/"+fileName);
+ if(fileInfo.isDir())
+ continue;
+ kapp->processEvents();
+ search(filePath, fileName);
+ filesNumber++;
+ m_view->displayScannedFiles(filesNumber);
+ }
+}
+
+void KFileReplacePart::recursiveFileSearch(const QString& directoryName, const QString& filters, uint& filesNumber)
+{
+ // if m_stop == true then interrupt recursion
+ if(m_stop)
+ return;
+ else
+ {
+ QDir d(directoryName);
+
+ d.setMatchAllDirs(true);
+ d.setFilter(m_optionMask);
+
+ QStringList filesList = d.entryList(filters);
+ QString filePath = d.canonicalPath();
+ QStringList::iterator filesIt;
+
+ for(filesIt = filesList.begin(); filesIt != filesList.end(); ++filesIt)
+ {
+ // stop polling
+ if(m_stop)
+ break;
+
+ QString fileName = (*filesIt);
+ // Avoids files that not match
+ if(!KFileReplaceLib::isAnAccessibleFile(filePath, fileName, m_option))
+ continue;
+
+ // Composes file path string
+ QFileInfo fileInfo(filePath+"/"+fileName);
+
+ m_view->displayScannedFiles(filesNumber);
+
+ // Searchs recursively if "filePath" is a directory
+ if(fileInfo.isDir())
+ recursiveFileSearch(filePath+"/"+fileName, filters, filesNumber);
+ else
+ {
+ kapp->processEvents();
+ search(filePath, fileName);
+ filesNumber++;
+ m_view->displayScannedFiles(filesNumber);
+ }
+ }
+ }
+}
+
+void KFileReplacePart::search(const QString& currentDir, const QString& fileName)
+{
+ QFile file(currentDir+"/"+fileName);
+
+ if(!file.open(IO_ReadOnly))
+ {
+ KMessageBox::information(m_w, i18n("<qt>Cannot open file <b>%1</b> for reading.</qt>").arg(fileName), QString::null, rcNotifyOnErrors);
+ return ;
+ }
+ // Creates a stream with the file
+ QTextStream stream( &file );
+ if (m_option->m_encoding == "utf8")
+ stream.setEncoding(QTextStream::UnicodeUTF8);
+ else
+ stream.setCodec(QTextCodec::codecForName(m_option->m_encoding));
+ QString line = stream.read();
+ file.close();
+
+ QFileInfo fileInfo(currentDir+"/"+fileName);
+
+ KListViewItem *item = 0;
+
+ //Counts occurrences
+ int occurrence = 0;
+
+ //This map contains strings to search
+ KeyValueMap tempMap = m_replacementMap;
+ //If no strings has been found, then no lines will be added to the result view
+ bool atLeastOneStringFound = false;
+
+ KeyValueMap::Iterator it = tempMap.begin();
+
+ KListView* rv = m_view->getResultsView();
+
+ while(it != tempMap.end())
+ {
+ //stop polling
+ if(m_stop)
+ break;
+
+ QString key = it.key();
+ QString strKey;
+ QRegExp rxKey;
+
+ if(m_option->m_regularExpressions)
+ rxKey = QRegExp("("+key+")", m_option->m_caseSensitive, false);
+ else
+ strKey = key;
+ /* If this option is true then for any string in
+ * the map we search for the first match*/
+ if(m_option->m_haltOnFirstOccur)
+ {
+ int pos;
+
+ if(m_option->m_regularExpressions)
+ pos = line.find(rxKey);
+ else
+ pos = line.find(strKey, 0 ,m_option->m_caseSensitive);
+
+ if(pos != -1)
+ {
+ atLeastOneStringFound = true;
+ int lineNumber = line.mid(0,pos).contains('\n')+1;
+ int columnNumber = pos - line.findRev('\n',pos);
+
+ if (!item)
+ item = new KListViewItem(rv);
+
+ KListViewItem* tempItem= new KListViewItem(item);
+ QString msg,
+ capturedText;
+
+ if(m_option->m_regularExpressions)
+ capturedText = rxKey.cap(1);
+ else
+ capturedText = line.mid(pos,strKey.length());
+
+ msg = i18n(" Line:%2, Col:%3 - \"%1\"").arg(capturedText).arg(QString::number(lineNumber,10)).arg(QString::number(columnNumber,10));
+ tempItem->setMultiLinesEnabled(true);
+ tempItem->setText(0,msg);
+ occurrence = 1;
+ }
+ }// ends m_option->m_haltOnFirstOccur if-block
+ else
+ {
+ /* This point of the code is reached when we must search for all
+ * occurrences of all the strings*/
+
+ int pos = 0;
+ if(m_option->m_regularExpressions)
+ pos = rxKey.search(line,pos);
+ else
+ pos = line.find(strKey, pos ,m_option->m_caseSensitive);
+
+ while(pos != -1)
+ {
+ //stop polling
+ if(m_stop)
+ break;
+
+ atLeastOneStringFound = true;
+ QString msg,
+ capturedText;
+ int lineNumber = line.mid(0,pos).contains('\n')+1;
+ int columnNumber = pos - line.findRev('\n',pos);
+
+ if(m_option->m_regularExpressions)
+ {
+ capturedText = rxKey.cap(1);
+ pos = rxKey.search(line, pos+rxKey.matchedLength());
+ }
+ else
+ {
+ capturedText = line.mid(pos,strKey.length());
+ pos = line.find(strKey,pos+strKey.length());
+ }
+
+ msg = i18n(" Line:%2, Col:%3 - \"%1\"").arg(capturedText).arg(QString::number(lineNumber,10)).arg(QString::number(columnNumber,10));
+
+ if(!item)
+ item = new KListViewItem(rv);
+ KListViewItem* tempItem = new KListViewItem(item);
+ tempItem->setMultiLinesEnabled(true);
+ tempItem->setText(0,msg);
+ occurrence++;
+ //we push stop button
+ if(m_stop)
+ break;
+ }
+ }
+ //Advances of one position in the strings map
+ ++it;
+
+ //we push stop button
+ if(m_stop)
+ break;
+ }
+
+ //if ignoreFiles == false then every files must be show
+ if(!m_option->m_ignoreFiles)
+ atLeastOneStringFound = true;
+
+ if(atLeastOneStringFound && item)
+ {
+ KFileReplaceLib::setIconForFileEntry(item,currentDir+"/"+fileName);
+ item->setText(0,fileName);
+ item->setText(1,currentDir);
+ item->setText(2,KFileReplaceLib::formatFileSize(fileInfo.size()));
+ item->setText(3,QString::number(occurrence,10));
+ item->setText(4,QString("%1[%2]").arg(fileInfo.owner()).arg(fileInfo.ownerId()));
+ item->setText(5,QString("%1[%2]").arg(fileInfo.group()).arg(fileInfo.groupId()));
+ }
+}
+
+void KFileReplacePart::loadViewContent()
+{
+ /* Maps the content of the strings view to a QMap */
+ KeyValueMap tempMap;
+ CommandEngine command;
+
+ QListViewItemIterator itlv(m_view->getStringsView());
+ while(itlv.current())
+ {
+ QListViewItem *item = itlv.current();
+ if(m_option->m_variables)
+ tempMap[item->text(0)] = command.variableValue(item->text(1));
+ else
+ tempMap[item->text(0)] = item->text(1);
+ ++itlv;
+ }
+ m_replacementMap = tempMap;
+}
+
+void KFileReplacePart::loadRulesFile(const QString& fileName)
+{
+ /* Loads a file with kfr extension.
+ * creates a xml document and browses it*/
+ QDomDocument doc("mydocument");
+ QFile file(fileName);
+ KListView* 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 kfilereplace.</qt>").arg(fileName),i18n("Warning"));
+
+ KFileReplaceLib::convertOldToNewKFRFormat(fileName, sv);
+
+ return;
+ }
+ else
+ file.close();
+
+ //clears view
+ sv->clear();
+
+ QDomElement docElem = doc.documentElement();
+ QDomNode n = docElem.firstChild();
+ QString 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())
+ {
+ QDomElement e = n.toElement(); // tries to convert the node to an element.
+ if(!e.isNull())
+ {
+ QString oldString = e.firstChild().toElement().text(),
+ newString = e.lastChild().toElement().text();
+ docMap[oldString] = newString;
+ }
+ n = n.nextSibling();
+ }
+
+ // Adds file to "load strings form file" menu
+ QStringList fileList = m_option->m_recentStringFileList;
+ if(!fileList.contains(fileName))
+ {
+ fileList.append(fileName);
+ ((KRecentFilesAction* ) 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 KFileReplacePart::launchNewProjectDialog(const KURL & startURL)
+{
+ if(!startURL.isEmpty())
+ m_option->m_directories.prepend(startURL.path());
+
+ /* This dlg reads options from m_option, then execs, finally returns options.*/
+ KNewProjectDlg dlg(m_option);
+
+ if(!dlg.exec())
+ return false;
+
+ dlg.saveRCOptions();
+
+ m_config->sync();
+
+ slotQuickStringsAdd();
+
+ m_view->updateOptions(m_option);
+
+ resetActions();
+
+ return true;
+}
+
+void KFileReplacePart::setOptionMask()
+{
+ m_optionMask |= QDir::Dirs;
+
+ if(!m_option->m_ignoreHidden)
+ m_optionMask |= QDir::Hidden;
+
+ if(!m_option->m_followSymLinks)
+ m_optionMask |= QDir::NoSymLinks;
+}
+
+bool KFileReplacePart::checkBeforeOperation()
+{
+ loadViewContent();
+ KListView* sv = m_view->getStringsView();
+
+ // Checks if there are strings to replace (not need in search operation)
+ if (sv->childCount() == 0)
+ {
+ KMessageBox::error(m_w, i18n("There are no strings to search and replace."));
+ return false;
+ }
+
+ // Checks if the main directory can be accessed
+ QString currentDirectory = m_option->m_directories[0];
+ QDir dir;
+
+ dir.setPath(currentDirectory);
+ QString directory = dir.absPath();
+
+ if(!dir.exists())
+ {
+ KMessageBox::error(m_w, i18n("<qt>The main folder of the project <b>%1</b> does not exist.</qt>").arg(directory));
+ return false;
+ }
+
+ QFileInfo dirInfo(directory);
+ if(!(dirInfo.isReadable() && dirInfo.isExecutable())
+ || (!m_option->m_searchingOnlyMode && !m_option->m_simulation && !(dirInfo.isWritable())))
+ {
+ KMessageBox::error(m_w, i18n("<qt>Access denied in the main folder of the project:<br><b>%1</b></qt>").arg(directory));
+ return false;
+ }
+
+ // Clears the list view
+ m_view->getResultsView()->clear();
+
+ return true;
+}
+
+bool KFileReplacePart::dontAskAgain()
+{
+ m_config->setGroup("Notification Messages");
+ QString dontAskAgain = m_config->readEntry(rcDontAskAgain, "no");
+ if(dontAskAgain == "yes")
+ return true;
+ else
+ return false;
+}
+
+void KFileReplacePart::whatsThis()
+{
+ actionCollection()->action("options_backup")->setWhatsThis(optionsBackupWhatthis);
+ actionCollection()->action("options_case")->setWhatsThis(optionsCaseWhatthis);
+ actionCollection()->action("options_var")->setWhatsThis(optionsVarWhatthis);
+ actionCollection()->action("options_recursive")->setWhatsThis(optionsRecursiveWhatthis);
+ actionCollection()->action("options_regularexpressions")->setWhatsThis(optionsRegularExpressionsWhatthis);
+}
+
+#include "kfilereplacepart.moc"
diff --git a/kfilereplace/kfilereplacepart.desktop b/kfilereplace/kfilereplacepart.desktop
new file mode 100644
index 00000000..388f6579
--- /dev/null
+++ b/kfilereplace/kfilereplacepart.desktop
@@ -0,0 +1,95 @@
+[Desktop Entry]
+Type=Service
+MimeType=inode/directory
+Icon=kfilereplace.png
+ServiceTypes=KParts/ReadOnlyPart
+X-KDE-Library=libkfilereplacepart
+Comment=A batch search and replace tool
+Comment[bg]=ТърÑене и замÑна във фонов режим
+Comment[ca]=Una eina per a la cerca i substitució per lots
+Comment[cs]=Dávkový nástroj pro hledání a nahrazování
+Comment[da]=Søg- og erstat-gruppekørselsværktøj
+Comment[de]=Ein Werkzeug zum Suchen und Ersetzen im Stapelbetrieb
+Comment[el]= ΕÏγαλείο πολλαπλής αναζήτησης και αντικατάστασης
+Comment[es]=Una herramienta de búsqueda y reemplazo por lotes
+Comment[et]=Otsimise ja asendamise tööriist
+Comment[eu]=Bilaketa eta ordezkapen tresna
+Comment[fa]=ابزار جستجو و جایگزینی دسته‌ای
+Comment[fi]=Batchien etsintä- ja korvaustyökalu
+Comment[fr]=Un outil de recherche et de remplacement de texte en série.
+Comment[gl]=Unha utilidade de busca e reemprazo por lotes
+Comment[hi]=à¤à¤• खोज तथा बदल उपकरण
+Comment[hu]=Sok fájl kezelésére alkalmas kereső- és cserélőprogram
+Comment[is]=Tól til að leita að texta og skipta út
+Comment[it]=Uno strumento per la ricerca e la sostituzione in sequenza
+Comment[ja]=ãƒãƒƒãƒæ¤œç´¢ãŠã‚ˆã³ç½®æ›ãƒ„ール
+Comment[ka]=ჯგუფური ძიების დრჩáƒáƒœáƒáƒªáƒ•áƒšáƒ”ბის ხელსáƒáƒ¬áƒ§áƒ
+Comment[lt]=Paketinis paieškos ir keitimo įrankis
+Comment[ms]=Gugusan alatan cari dan ganti
+Comment[nds]=En Söök- un Utwesselwarktüüch för Stapelbedrief
+Comment[ne]=à¤à¤‰à¤Ÿà¤¾ समूह खोजी गरà¥à¤¨à¥‡ र बदलà¥à¤¨à¥‡ उपकरण
+Comment[nl]=Een gereedschap voor zoeken en vervangen
+Comment[pl]=Narzędzie do wyszukiwania i zamiany
+Comment[pt]=Uma ferramenta de procura e substituição por atacado
+Comment[pt_BR]=Uma ferramenta de substituição e pesquisa batch
+Comment[ru]=Пакетный поиÑк и замена
+Comment[sk]=Dávkovací nástroj pre nájsť a zameniť
+Comment[sl]=Orodje serijskega iskanja in zamenjevanja
+Comment[sr]=Ðлат за пакетну претрагу и замену
+Comment[sr@Latn]=Alat za paketnu pretragu i zamenu
+Comment[sv]=Ett sök- och ersättningsverktyg
+Comment[ta]=தொகà¯à®¤à®¿ தேடல௠மறà¯à®±à¯à®®à¯ கரà¯à®µà®¿ இடமாறà¯à®±à®²à¯
+Comment[tg]=ҶуÑтуҷӯи пакет ва ивази аÑбоб
+Comment[tr]=Bir toplu arama ve değiştirme aracı
+Comment[uk]=ЗаÑіб пакетного пошуку та заміни
+Comment[zh_CN]=批é‡æœç´¢æ›¿æ¢å·¥å…·
+Comment[zh_HK]=批次æœå°‹åŠå–代工具
+Comment[zh_TW]=批次æœå°‹åŠå–代工具
+Name=KFileReplace
+Name[hi]=के-फ़ाइल-रिपà¥à¤²à¥‡à¤¸
+Name[ne]=बदलà¥à¤¨à¥‡ केडीई फाइल
+Name[pa]=ਕੇ-ਫਾਇਲ-ਬਦਲੋ
+Name[sk]=KFile zameniť
+Name[sv]=Kfilereplace
+Name[ta]=Kகோபà¯à®ªà¯ இடமாறà¯à®±à¯
+Name[tg]=KФайлро ҷойгузор кардан
+Name[tr]=K Dosya DeÄŸiÅŸtirme
+GenericName=File Replace View
+GenericName[bg]=Преглед на файловете за замÑна
+GenericName[ca]=Vista per a substituir fitxers
+GenericName[cs]=Nahrazení souborů
+GenericName[da]=Filerstatningsvisning
+GenericName[de]=KFileReplace
+GenericName[el]=ΠÏοβολή αντικατάστασης αÏχείου
+GenericName[es]=Vista de reemplazo de archivo
+GenericName[et]=Failide asendamise vaade
+GenericName[eu]=Fitxategi ordezkapen ikuspegia
+GenericName[fa]=نمای جایگزینی پرونده
+GenericName[fi]=Tiedoston korvausnäyttö
+GenericName[fr]=Remplacement de fichiers
+GenericName[gl]=Vista de reemprazo de ficheiro
+GenericName[hu]=Fájlcserélő nézet
+GenericName[is]=Texta útskiptingarsýn
+GenericName[it]=Vista di sostituzione file
+GenericName[ja]=ファイル置æ›ãƒ“ュー
+GenericName[ka]=ფáƒáƒ˜áƒšáƒ˜áƒ¡ ჩáƒáƒœáƒáƒªáƒ•áƒšáƒ”ბის ხედი
+GenericName[lt]=Keitimų bylose vaizdas
+GenericName[ms]=Paparan Ganti Fail
+GenericName[nds]=Datei-Utwesselansicht
+GenericName[ne]=फाइल बदलà¥à¤¨à¥‡ दृशà¥à¤¯
+GenericName[nl]=Weergave van bestanden vervangen
+GenericName[pa]=ਫਾਇਲ ਤਬਦੀਲ à¨à¨²à¨•
+GenericName[pl]=Widok zamiany w plikach
+GenericName[pt]=Vista de Substituição de Ficheiros
+GenericName[pt_BR]=Visão de Substituição de Arquivos
+GenericName[ru]=СредÑтво поиÑка и замены в файлах
+GenericName[sk]=Pohľad zámeny súboru
+GenericName[sl]=Prikaz zamenjave datotek
+GenericName[sr]=Приказ замена у фајловима
+GenericName[sr@Latn]=Prikaz zamena u fajlovima
+GenericName[sv]=Filersättningsvy
+GenericName[ta]=கோபà¯à®ªà¯ இடமாறà¯à®±à¯ காடà¯à®šà®¿
+GenericName[uk]=ПереглÑд заміни в файлах
+GenericName[zh_CN]=文件替æ¢è§†å›¾
+GenericName[zh_HK]=檔案å–代檢視模å¼
+GenericName[zh_TW]=檔案å–代檢視
diff --git a/kfilereplace/kfilereplacepart.h b/kfilereplace/kfilereplacepart.h
new file mode 100644
index 00000000..1c133cb5
--- /dev/null
+++ b/kfilereplace/kfilereplacepart.h
@@ -0,0 +1,159 @@
+//
+//
+// C++ Interface: kfilereplacepart
+//
+// Description:
+//
+//
+// Author: Andras Mantia <amantia@kde.org>, (C) 2003
+// Maintainer: Emiliano Gulmini <emi_barbarossa@yahoo.it>, (C) 2004
+//
+// Copyright: GPL v2. See COPYING file that comes with this distribution
+//
+//
+
+#ifndef KFILEREPLACEPART_H
+#define KFILEREPLACEPART_H
+
+// QT
+
+// KDE
+#include <kparts/part.h>
+class KAboutApplication;
+class KAboutData;
+class KConfig;
+
+// local
+#include "configurationclasses.h"
+class KFileReplaceView;
+
+#define KFR_VERSION "0.8.1"
+
+class KFileReplacePart: public KParts::ReadOnlyPart
+{
+ Q_OBJECT
+
+ private: //MEMBERS
+ KFileReplaceView* m_view;
+ QWidget* m_parentWidget,
+ * m_w;
+ KConfig* m_config;
+ KAboutApplication* m_aboutDlg;
+ KeyValueMap m_replacementMap;
+ RCOptions* m_option;
+ bool m_stop,
+ m_searchingOperation;
+ int m_optionMask;
+
+ public://Constructors
+ KFileReplacePart(QWidget *parentWidget,
+ const char *widgetName,
+ QObject *parent,
+ const char *name,
+ const QStringList &args);
+ ~KFileReplacePart();
+
+ //SLOTS
+ private slots:
+ void slotSetNewParameters();
+ void slotSearchingOperation();
+ void slotReplacingOperation();
+ 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();
+ void slotOptionVariables();
+ void slotOptionRegularExpressions();
+ void slotOptionPreferences();
+ void showAboutApplication(void);
+ void appHelpActivated();
+ void reportBug();
+ void resetActions();
+ void slotSearchMode(bool b){ m_option->m_searchingOnlyMode = b; }
+
+ //METHODS
+ public:
+ static KAboutData* createAboutData();
+ KConfig *config(){ return m_config; }
+
+ protected:
+ virtual bool openFile() { return false; }
+ virtual bool openURL (const KURL &url);
+
+ private:
+ /**
+ * Initialization methods
+ */
+ void initGUI();
+ void initView();
+
+ /**
+ * This method freezes the GUI of kfilereplace during searching
+ */
+ void freezeActions();
+
+ /**
+ * These methods load the resources from kfilereplacerc
+ */
+ void loadOptionsFromRC();
+ void loadOptions();
+ void loadFileSizeOptions();
+ void loadDateAccessOptions();
+ void loadOwnerOptions();
+ void loadLocationsList();
+ void loadFiltersList();
+ void loadBackupExtensionOptions();
+
+ /**
+ * These methods save the resources to kfilereplacerc
+ */
+ void saveOptionsToRC();
+ void saveOptions();
+ void saveFileSizeOptions();
+ void saveDateAccessOptions();
+ void saveOwnerOptions();
+ void saveLocationsList();
+ void saveFiltersList();
+ void saveBackupExtensionOptions();
+
+ /**
+ * Replacing methods
+ */
+ void fileReplace();
+ void recursiveFileReplace(const QString& dirName, int& filesNumber);
+ void replaceAndBackup(const QString& currentDir, const QString& oldFileName);
+ void replaceAndOverwrite(const QString& currentDir, const QString& oldFileName);
+ void replacingLoop(QString& line, KListViewItem** item, bool& atLeastOneStringFound, int& occur, bool regularExpression, bool& askConfirmReplace);
+
+ /**
+ * Searching methods
+ */
+ void fileSearch(const QString& dirName, const QString& filters);
+ void recursiveFileSearch(const QString& dirName, const QString& filters, uint& filesNumber);
+ void search(const QString& currentDir, const QString& fileName);
+
+ /**
+ * Others methods
+ */
+ void loadViewContent();
+ void loadRulesFile(const QString& fileName);
+ bool launchNewProjectDialog(const KURL& startURL);
+ void setOptionMask();
+ bool checkBeforeOperation();
+ bool dontAskAgain();
+ void whatsThis();
+};
+
+#endif// KFileReplacePart
diff --git a/kfilereplace/kfilereplacepartui.rc b/kfilereplace/kfilereplacepartui.rc
new file mode 100644
index 00000000..66946878
--- /dev/null
+++ b/kfilereplace/kfilereplacepartui.rc
@@ -0,0 +1,75 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="kfilereplace" version="6">
+<MenuBar>
+ <Menu name="kfilerepace"><text>Search/&amp;Replace</text>
+ <Action name="new_project"/>
+ <Action name="search"/>
+ <Action name="file_simulate"/>
+ <Action name="replace"/>
+ <Action name="stop"/>
+ <Separator/>
+ <Menu name="strings"><text>&amp;Strings</text>
+ <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_editfile"/>
+ <Action name="results_delete"/>
+ <Action name="results_infos"/>
+ <Separator/>
+ <Action name="save_results"/>
+ <Separator/>
+ <Action name="results_treeexpand"/>
+ <Action name="results_treereduce"/>
+ </Menu>
+ <Menu name="options"><text>&amp;Options</text>
+ <Action name="options_recursive"/>
+ <Action name="options_backup"/>
+ <Action name="options_case"/>
+ <Action name="options_var"/>
+ <Action name="options_regularexpressions"/>
+ </Menu>
+ </Menu>
+ <Menu name="settings"><text>&amp;Settings</text>
+ <Action name="configure_kfilereplace"/>
+ </Menu>
+ <Menu name="help"><text>&amp;Help</text>
+ <Separator/>
+ <Action name="help_kfilereplace" />
+ <Action name="report_bug" />
+ <Action name="help_about_kfilereplace" />
+ </Menu>
+</MenuBar>
+<ToolBar noMerge="1" name="mainToolBar">
+<text>KFileReplace Main Toolbar</text>
+ <Action name="new_project" />
+ <Action name="search"/>
+ <Action name="file_simulate"/>
+ <Action name="replace"/>
+ <Action name="stop"/>
+ <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"/>
+ <Separator/>
+ <Action name="options_recursive"/>
+ <Action name="options_backup"/>
+ <Action name="options_case"/>
+ <Action name="options_var"/>
+ <Action name="options_regularexpressions"/>
+</ToolBar>
+</kpartgui>
diff --git a/kfilereplace/kfilereplaceui.rc b/kfilereplace/kfilereplaceui.rc
new file mode 100644
index 00000000..2f645413
--- /dev/null
+++ b/kfilereplace/kfilereplaceui.rc
@@ -0,0 +1,10 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="kfilereplace" version="1">
+<MenuBar>
+ <Menu noMerge="1" name="file"><text>&amp;File</text>
+ <Action name="file_quit"/>
+ </Menu>
+ <Menu name="kfilerepace"><text>Search/&amp;Replace</text>
+ </Menu>
+</MenuBar>
+</kpartgui>
diff --git a/kfilereplace/kfilereplaceview.cpp b/kfilereplace/kfilereplaceview.cpp
new file mode 100644
index 00000000..16ca82da
--- /dev/null
+++ b/kfilereplace/kfilereplaceview.cpp
@@ -0,0 +1,672 @@
+/*****************************************************************************
+ kfilereplaceview.cpp - description
+ -------------------
+ begin : sam oct 16 15:28:00 CEST 1999
+ copyright : (C) 1999 by Fran�is Dupoux <dupoux@dupoux.com>
+ (C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+*****************************************************************************/
+
+/*****************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *****************************************************************************/
+
+// Qt
+#include <qwhatsthis.h>
+#include <qmap.h>
+#include <qfileinfo.h>
+
+// KDE
+#include <klistview.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kpopupmenu.h>
+#include <krun.h>
+#include <kpropertiesdialog.h>
+#include <kapplication.h>
+#include <dcopclient.h>
+#include <dcopref.h>
+//#include <kdebug.h>
+#include <kiconloader.h>
+#include <kled.h>
+#include <kfiledialog.h>
+
+// local
+#include "kfilereplaceview.h"
+#include "kfilereplacelib.h"
+#include "kaddstringdlg.h"
+#include "whatthis.h"
+
+using namespace whatthisNameSpace;
+
+KFileReplaceView::KFileReplaceView(RCOptions* info, QWidget *parent,const char *name):KFileReplaceViewWdg(parent,name)
+{
+ m_option = info;
+
+ initGUI();
+
+ // connect events
+ connect(m_lvResults, SIGNAL(mouseButtonClicked(int, QListViewItem *, const QPoint &, int)), this, SLOT(slotMouseButtonClicked(int, QListViewItem *, const QPoint &)));
+ connect(m_lvResults_2, SIGNAL(mouseButtonClicked(int, QListViewItem *, const QPoint &, int)), this, SLOT(slotMouseButtonClicked(int, QListViewItem *, const QPoint &)));
+ connect(m_lvStrings, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(slotStringsEdit()));
+ connect(m_lvStrings_2, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(slotStringsEdit()));
+
+ whatsThis();
+}
+
+QString KFileReplaceView::currentPath()
+{
+ QListViewItem *lvi;
+
+ if(! m_lviCurrent) lvi = m_rv->currentItem();
+ else lvi = (QListViewItem*) m_lviCurrent;
+
+ while (lvi->parent())
+ lvi = lvi->parent();
+
+ return QString(lvi->text(1)+"/"+lvi->text(0));
+}
+
+void KFileReplaceView::showSemaphore(QString s)
+{
+ if(s == "green")
+ {
+ m_ledGo->setState(KLed::On);
+ m_ledWait->setState(KLed::Off);
+ m_ledStop->setState(KLed::Off);
+ }
+ else
+ if(s == "yellow")
+ {
+ m_ledGo->setState(KLed::Off);
+ m_ledWait->setState(KLed::On);
+ m_ledStop->setState(KLed::Off);
+ }
+ else
+ if(s == "red")
+ {
+ m_ledGo->setState(KLed::Off);
+ m_ledWait->setState(KLed::Off);
+ m_ledStop->setState(KLed::On);
+ }
+}
+
+void KFileReplaceView::stringsInvert(bool invertAll)
+{
+ QListViewItem* lviCurItem,
+ * lviFirst;
+ KListView* sv = getStringsView();
+
+ if(invertAll)
+ lviCurItem = lviFirst = sv->firstChild();
+ else
+ lviCurItem = lviFirst = sv->currentItem();
+
+ if(lviCurItem == 0)
+ return ;
+
+ do
+ {
+ QString searchText = lviCurItem->text(0),
+ replaceText = lviCurItem->text(1);
+
+ // 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;
+ }
+
+ lviCurItem->setText(0, replaceText);
+ lviCurItem->setText(1, searchText);
+
+ lviCurItem = lviCurItem->nextSibling();
+ if(!invertAll)
+ break;
+ } while(lviCurItem && lviCurItem != lviFirst);
+ setCurrentStringsViewMap();
+}
+
+void KFileReplaceView::changeView(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;
+ }
+ else
+ {
+ m_stackResults->raiseWidget(m_lvResults);
+ m_stackStrings->raiseWidget(m_lvStrings);
+ m_rv = m_lvResults;
+ m_sv = m_lvStrings;
+ }
+}
+
+KListView* KFileReplaceView::getResultsView()
+{
+ if(m_option->m_searchingOnlyMode)
+ m_rv = m_lvResults_2;
+ else
+ m_rv = m_lvResults;
+
+ return m_rv;
+}
+
+KListView* KFileReplaceView::getStringsView()
+{
+ if(m_option->m_searchingOnlyMode)
+ m_sv = m_lvStrings_2;
+ else
+ m_sv = m_lvStrings;
+ return m_sv;
+}
+
+//PUBLIC SLOTS
+void KFileReplaceView::slotMouseButtonClicked (int button, QListViewItem *lvi, const QPoint &pos)
+{
+ if (lvi == 0) // No item selected
+ return;
+
+ // RIGHT BUTTON
+ if (button == QMouseEvent::RightButton)
+ {
+ m_lviCurrent = static_cast<KListViewItem*>(lvi);
+ m_menuResult->popup(pos);
+ }
+}
+
+void KFileReplaceView::slotResultProperties()
+{
+ QString currItem = currentPath();
+ if(! currItem.isEmpty())
+ {
+ KURL url(currItem);
+ (void) new KPropertiesDialog(url);
+ m_lviCurrent = 0;
+ }
+}
+
+void KFileReplaceView::slotResultOpen()
+{
+ QString currItem = currentPath();
+ if(!currItem.isEmpty())
+ {
+ (void) new KRun(KURL(currItem), 0, true, true);
+ m_lviCurrent = 0;
+ }
+}
+
+void KFileReplaceView::slotResultOpenWith()
+{
+ QString currItem = currentPath();
+ if(!currItem.isEmpty())
+ {
+ KURL::List kurls;
+ kurls.append(KURL(currItem));
+ KRun::displayOpenWithDialog(kurls);
+ m_lviCurrent = 0;
+ }
+}
+
+void KFileReplaceView::slotResultDirOpen()
+{
+ QString currItem = currentPath();
+ if(!currItem.isEmpty())
+ {
+ QFileInfo fi;
+ fi.setFile(currItem);
+ (void) new KRun (KURL::fromPathOrURL(fi.dirPath()), 0, true, true);
+ m_lviCurrent = 0;
+ }
+}
+
+void KFileReplaceView::slotResultEdit()
+{
+ QListViewItem *lvi = m_rv->firstChild();
+
+ while (lvi)
+ {
+ DCOPClient *client = kapp->dcopClient();
+ DCOPRef quanta(client->appId(),"WindowManagerIf");
+ QString path = QString(lvi->text(1)+"/"+lvi->text(0));
+ QListViewItem *lviChild = lvi;
+
+ while(lviChild)
+ {
+ if(lviChild->isSelected())
+ {
+ coord c;
+ if(lviChild == lvi)
+ {
+ c.line = 0;
+ c.column = 0;
+ }
+ else
+ {
+ c= extractWordCoordinates(lviChild);
+ }
+ bool success = quanta.send("openFile", path, c.line, c.column);
+
+ if(!success)
+ {
+ QString message = i18n("File %1 cannot be opened. Might be a DCOP problem.").arg(path);
+ KMessageBox::error(parentWidget(), message);
+ }
+ }
+ if (lviChild == lvi)
+ lviChild = lviChild->firstChild();
+ else
+ lviChild = lviChild->nextSibling();
+ }
+
+ lvi = lvi->nextSibling();
+ }
+
+ m_lviCurrent = 0;
+}
+
+void KFileReplaceView::slotResultDelete()
+{
+ QString currItem = currentPath();
+ if (!currItem.isEmpty())
+ {
+ QFile fi;
+ int answer = KMessageBox::warningContinueCancel(this, i18n("Do you really want to delete %1?").arg(currItem),
+ QString::null,KStdGuiItem::del());
+
+ if(answer == KMessageBox::Continue)
+ {
+ fi.setName(currItem);
+ fi.remove();
+
+ delete m_lviCurrent;
+ m_lviCurrent = 0;
+ }
+ }
+}
+
+void KFileReplaceView::slotResultTreeExpand()
+{
+ QListViewItem *lviRoot = getResultsView()->firstChild();
+
+ if(lviRoot)
+ expand(lviRoot, true);
+}
+
+void KFileReplaceView::slotResultTreeReduce()
+{
+ QListViewItem *lviRoot = getResultsView()->firstChild();
+
+ if(lviRoot)
+ expand(lviRoot, false);
+}
+
+void KFileReplaceView::slotStringsAdd()
+{
+ KeyValueMap oldMap(m_option->m_mapStringsView);
+
+ KAddStringDlg addStringDlg(m_option, false);
+
+ 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);
+}
+
+void KFileReplaceView::slotQuickStringsAdd(const QString& quickSearch, const QString& quickReplace)
+{
+ if(!quickSearch.isEmpty())
+ {
+ KeyValueMap map;
+ if(quickReplace.isEmpty())
+ {
+ map[quickSearch] = QString::null;
+ m_option->m_searchingOnlyMode = true;
+ }
+ else
+ {
+ map[quickSearch] = quickReplace;
+ m_option->m_searchingOnlyMode = false;
+ }
+
+ m_option->m_mapStringsView = map;
+
+ raiseResultsView();
+ raiseStringsView();
+
+ loadMapIntoView(map);
+ }
+}
+
+void KFileReplaceView::slotStringsEdit()
+{
+ KeyValueMap oldMap(m_option->m_mapStringsView);
+ if(oldMap.isEmpty()) return;
+ bool oldSearchFlagValue = m_option->m_searchingOnlyMode;
+
+ oldMap.remove(m_sv->currentItem()->text(0));
+
+ m_option->m_mapStringsView.clear();
+
+ m_option->m_mapStringsView.insert(m_sv->currentItem()->text(0), m_sv->currentItem()->text(1));
+
+ KAddStringDlg addStringDlg(m_option, true);
+
+ if(!addStringDlg.exec())
+ return;
+
+ KeyValueMap newMap(m_option->m_mapStringsView);
+ if(oldSearchFlagValue == m_option->m_searchingOnlyMode)
+ {
+ KeyValueMap::Iterator itMap;
+
+ //merges the two maps
+ for(itMap = oldMap.begin(); itMap != oldMap.end(); ++itMap)
+ newMap.insert(itMap.key(),itMap.data());
+ }
+
+ m_option->m_mapStringsView = newMap;
+
+ raiseResultsView();
+ raiseStringsView();
+
+ loadMapIntoView(newMap);
+}
+
+void KFileReplaceView::slotStringsSave()
+{
+ // Check there are strings in the list
+ KListView* sv = getStringsView();
+
+ if (sv->firstChild() == 0)
+ {
+ KMessageBox::error(0, i18n("No strings to save as the list is empty."));
+ return ;
+ }
+
+ QString 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\"/>";
+
+ QListViewItem* lvi = sv->firstChild();
+
+ while( lvi )
+ {
+ body += QString("\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));
+ lvi = lvi->nextSibling();
+ }
+
+ // Selects the file where strings will be saved
+ QString menu = "*.kfr|" + i18n("KFileReplace Strings") + " (*.kfr)\n*|" + i18n("All Files") + " (*)";
+ QString fileName = KFileDialog::getSaveFileName(QString::null, menu, 0, i18n("Save Strings to File"));
+ if (fileName.isEmpty())
+ return;
+
+ // Forces the extension to be "kfr" == KFileReplace extension
+
+ fileName = KFileReplaceLib::addExtension(fileName, "kfr");
+
+ QFile file( fileName );
+ if(!file.open( IO_WriteOnly ))
+ {
+ KMessageBox::error(0, i18n("File %1 cannot be saved.").arg(fileName));
+ return ;
+ }
+ QTextStream oTStream( &file );
+ oTStream.setEncoding(QTextStream::UnicodeUTF8);
+ oTStream << header
+ << body
+ << footer;
+ file.close();
+}
+
+void KFileReplaceView::slotStringsDeleteItem()
+{
+ QListViewItem* item = m_sv->currentItem();
+ if(item != 0)
+ {
+ KeyValueMap m = m_option->m_mapStringsView;
+ m.remove(item->text(0));
+ m_option->m_mapStringsView = m;
+ delete item;
+ }
+}
+
+void KFileReplaceView::slotStringsEmpty()
+{
+ QListViewItem * myChild = m_sv->firstChild();
+ while( myChild )
+ {
+ QListViewItem* item = myChild;
+ myChild = myChild->nextSibling();
+ delete item;
+ }
+ KeyValueMap m;
+ m_option->m_mapStringsView = m;
+}
+
+//PRIVATE
+void KFileReplaceView::initGUI()
+{
+ m_option->m_searchingOnlyMode = true;
+
+ m_stackResults->addWidget(m_lvResults);
+ m_stackResults->addWidget(m_lvResults_2);
+ m_stackStrings->addWidget(m_lvStrings);
+ m_stackStrings->addWidget(m_lvStrings_2);
+
+ DCOPClient *client = kapp->dcopClient();
+ QCStringList appList = client->registeredApplications();
+ bool quantaFound = false;
+
+
+ for(QCStringList::Iterator it = appList.begin(); it != appList.end(); ++it)
+ {
+ if((*it).left(6) == "quanta")
+ {
+ quantaFound = true;
+ break;
+ }
+ }
+
+ m_menuResult = new KPopupMenu(this, "ResultPopup");
+
+
+
+ m_menuResult->insertItem(SmallIconSet(QString::fromLatin1("fileopen")),
+ i18n("&Open"),
+ this,
+ SLOT(slotResultOpen()));
+ if(!quantaFound)
+ {
+ m_menuResult->insertItem(i18n("Open &With..."),
+ this,
+ SLOT(slotResultOpenWith()));
+ }
+
+ if(quantaFound)
+ {
+ m_menuResult->insertItem(SmallIconSet("quanta"),
+ i18n("&Edit in Quanta"),
+ this,
+ SLOT(slotResultEdit()));
+ }
+
+ m_menuResult->insertItem(SmallIconSet(QString::fromLatin1("up")),
+ i18n("Open Parent &Folder"),
+ this,
+ SLOT(slotResultDirOpen()));
+ m_menuResult->insertItem(SmallIconSet(QString::fromLatin1("editdelete")),
+ i18n("&Delete"),
+ this,
+ SLOT(slotResultDelete()));
+ m_menuResult->insertSeparator();
+ m_menuResult->insertItem(SmallIconSet(QString::fromLatin1("info")),
+ i18n("&Properties"),
+ this,
+ SLOT(slotResultProperties()));
+ raiseResultsView();
+ raiseStringsView();
+}
+
+void KFileReplaceView::raiseStringsView()
+{
+ if(m_option->m_searchingOnlyMode)
+ m_sv = m_lvStrings_2;
+ else
+ m_sv = m_lvStrings;
+
+ m_stackStrings->raiseWidget(m_sv);
+}
+
+void KFileReplaceView::raiseResultsView()
+{
+ if(m_option->m_searchingOnlyMode)
+ m_rv = m_lvResults_2;
+ else
+ m_rv = m_lvResults;
+
+ m_stackResults->raiseWidget(m_rv);
+}
+
+coord KFileReplaceView::extractWordCoordinates(QListViewItem* lvi)
+{
+ //get coordinates of the first string of the current selected file
+ coord c;
+ c.line = 0;
+ c.column = 0;
+ QString s = lvi->text(0);
+ //qWarning("WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW=%s",s.latin1());
+ /* if(lvi->parent()) s = lvi->text(0);
+ else return c;*/
+
+ QString temp;
+ int i = 0;
+
+ //extracts line and column from lvi->text(0)
+ //FIXME: Don't get the line and column number from the text as it's translated and it will
+ //fail for non-English languages!
+
+ //EMILIANO: This is not a good fixing but for now it should reduce the problems
+ while(true)
+ {
+ if(s[i] < '0' || s[i] > '9')
+ i++;
+ else
+ break;
+ }
+ while(true)
+ {
+ if(s[i] >= '0' && s[i] <= '9')
+ {
+ temp += s[i];
+ i++;
+ }
+ else
+ break;
+ }
+ c.line = temp.toInt();
+ temp = QString::null;
+
+ while(true)
+ {
+ if(s[i] < '0' || s[i] > '9')
+ i++;
+ else
+ break;
+ }
+ while(true)
+ {
+ if(s[i] >= '0' && s[i] <= '9')
+ {
+ temp += s[i];
+ i++;
+ }
+ else
+ break;
+ }
+ c.column = temp.toInt();
+
+ if(c.line > 0) c.line--;
+ if(c.column > 0) c.column--;
+
+ return c;
+}
+
+void KFileReplaceView::expand(QListViewItem *lviCurrent, bool b)
+{
+ // current item
+ lviCurrent->setOpen(b);
+
+ // recursivity
+ while((lviCurrent = lviCurrent->nextSibling()) != 0)
+ {
+ lviCurrent->setOpen(b);
+
+ if (lviCurrent->firstChild())
+ expand(lviCurrent->firstChild(), b);
+ }
+}
+
+void KFileReplaceView::setMap()
+{
+ KeyValueMap map;
+ QListViewItem* i = m_sv->firstChild();
+ while(i != 0)
+ {
+ if(m_option->m_searchingOnlyMode)
+ map[i->text(0)] = QString::null;
+ else
+ map[i->text(0)] = i->text(1);
+ i = i->nextSibling();
+ }
+ m_option->m_mapStringsView = map;
+}
+
+void KFileReplaceView::loadMapIntoView(KeyValueMap map)
+{
+ m_sv->clear();
+ KeyValueMap::Iterator itMap;
+
+ for(itMap = map.begin(); itMap != map.end(); ++itMap)
+ {
+ QListViewItem* lvi = new QListViewItem(m_sv);
+ lvi->setMultiLinesEnabled(true);
+ lvi->setText(0,itMap.key());
+ if(!m_option->m_searchingOnlyMode)
+ lvi->setText(1,itMap.data());
+ }
+
+}
+
+void KFileReplaceView::whatsThis()
+{
+ QWhatsThis::add(getResultsView(), lvResultWhatthis);
+ QWhatsThis::add(getStringsView(), lvStringsWhatthis);
+}
+#include "kfilereplaceview.moc"
diff --git a/kfilereplace/kfilereplaceview.h b/kfilereplace/kfilereplaceview.h
new file mode 100644
index 00000000..21ac6a29
--- /dev/null
+++ b/kfilereplace/kfilereplaceview.h
@@ -0,0 +1,116 @@
+/***************************************************************************
+ kfilereplaceview.h - description
+ -------------------
+ begin : sam oct 16 15:28:00 CEST 1999
+ copyright : (C) 1999 by François Dupoux <dupoux@dupoux.com>
+ (C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KFILEREPLACEVIEW_H
+#define KFILEREPLACEVIEW_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+//QT
+#include <qlcdnumber.h>
+#include <qwidgetstack.h>
+class QPixMap;
+
+//KDE
+class KPopupMenu;
+class KListView;
+
+//local
+#include "kfilereplaceviewwdg.h"
+#include "configurationclasses.h"
+
+class coord
+{
+ public:
+ int line,
+ column;
+ public:
+ coord(){ line = 1;
+ column = 1;}
+ coord(const coord& c) { line = c.line;
+ column = c.column;}
+ coord operator=(const coord& c) { line = c.line;
+ column = c.column;
+ return (*this);}
+};
+
+
+/**
+ * The view of KFilereplace.
+ */
+class KFileReplaceView : public KFileReplaceViewWdg
+{
+ Q_OBJECT
+ private:
+ KPopupMenu* m_menuResult;
+ RCOptions* m_option;
+ KListViewItem* m_lviCurrent;
+ KListView* m_rv,
+ * m_sv;
+
+ public://Constructors
+ KFileReplaceView(RCOptions* info, QWidget *parent,const char *name);
+
+ public:
+ QString currentPath();
+ void showSemaphore(QString s);
+ void displayScannedFiles(int filesNumber) { m_lcdFilesNumber->display(QString::number(filesNumber,10)); }
+ void stringsInvert(bool invertAll);
+ void changeView(bool searchingOnlyMode);
+ KListView* getResultsView();
+ KListView* 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:
+ void slotMouseButtonClicked (int button, QListViewItem *lvi, const QPoint &pos);
+ void slotResultProperties();
+ void slotResultOpen();
+ void slotResultOpenWith();
+ void slotResultDirOpen();
+ void slotResultEdit();
+ void slotResultDelete();
+ void slotResultTreeExpand();
+ void slotResultTreeReduce();
+ void slotStringsAdd();
+ void slotQuickStringsAdd(const QString& quickSearch, const QString& quickReplace);
+ void slotStringsDeleteItem();
+ void slotStringsEmpty();
+ void slotStringsEdit();
+ void slotStringsSave();
+
+ private:
+ void initGUI();
+ void raiseStringsView();
+ void raiseResultsView();
+ coord extractWordCoordinates(QListViewItem* lvi);
+ void expand(QListViewItem *lviCurrent, bool b);
+ void setMap();
+ void loadMapIntoView(KeyValueMap map);
+ void whatsThis();
+
+ /*signals:
+ void resetActions();
+ void searchingOnlyMode(bool);*/
+};
+
+#endif // KFILEREPLACEVIEW_H
diff --git a/kfilereplace/kfilereplaceviewwdg.ui b/kfilereplace/kfilereplaceviewwdg.ui
new file mode 100644
index 00000000..17be7441
--- /dev/null
+++ b/kfilereplace/kfilereplaceviewwdg.ui
@@ -0,0 +1,555 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>KFileReplaceViewWdg</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>KFileReplaceViewWdg</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>635</width>
+ <height>370</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QSplitter" row="0" column="0">
+ <property name="name">
+ <cstring>splitter3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <widget class="QWidgetStack">
+ <property name="name">
+ <cstring>m_stackResults</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="KListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Folder</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Old Size</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Size</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Replaced Strings</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Owner User</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Owner Group</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_lvResults</cstring>
+ </property>
+ <property name="selectionMode" stdset="0">
+ <enum>Extended</enum>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="showSortIndicator">
+ <bool>true</bool>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ <property name="itemsMovable">
+ <bool>false</bool>
+ </property>
+ <property name="alternateBackground">
+ <color>
+ <red>238</red>
+ <green>246</green>
+ <blue>255</blue>
+ </color>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="KListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Folder</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Size</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Found Strings</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Owner User</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Owner Group</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_lvResults_2</cstring>
+ </property>
+ <property name="selectionMode" stdset="0">
+ <enum>Extended</enum>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="showSortIndicator">
+ <bool>true</bool>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ <property name="itemsMovable">
+ <bool>false</bool>
+ </property>
+ <property name="alternateBackground">
+ <color>
+ <red>238</red>
+ <green>246</green>
+ <blue>255</blue>
+ </color>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ <widget class="QWidgetStack">
+ <property name="name">
+ <cstring>m_stackStrings</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="KListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Search For</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Replace With</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_lvStrings</cstring>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>false</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ <property name="itemsMovable">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="KListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Search For</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_lvStrings_2</cstring>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>false</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ <property name="itemsMovable">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KLed">
+ <property name="name">
+ <cstring>m_ledGo</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="state">
+ <enum>On</enum>
+ </property>
+ <property name="color">
+ <color>
+ <red>170</red>
+ <green>255</green>
+ <blue>0</blue>
+ </color>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Green means ready</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Ready</string>
+ </property>
+ </widget>
+ <widget class="KLed">
+ <property name="name">
+ <cstring>m_ledWait</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="state">
+ <enum>On</enum>
+ </property>
+ <property name="color">
+ <color>
+ <red>255</red>
+ <green>255</green>
+ <blue>0</blue>
+ </color>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Yellow means wait while sorting list</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Please wait while sorting list</string>
+ </property>
+ </widget>
+ <widget class="KLed">
+ <property name="name">
+ <cstring>m_ledStop</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="color">
+ <color>
+ <red>255</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Red means scanning files</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>354</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>m_tlFilesNumber</cstring>
+ </property>
+ <property name="text">
+ <string>Scanned files:</string>
+ </property>
+ </widget>
+ <widget class="QLCDNumber">
+ <property name="name">
+ <cstring>m_lcdFilesNumber</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>LineEditPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Raised</enum>
+ </property>
+ <property name="numDigits">
+ <number>7</number>
+ </property>
+ <property name="mode">
+ <enum>Dec</enum>
+ </property>
+ <property name="segmentStyle">
+ <enum>Flat</enum>
+ </property>
+ <property name="intValue" stdset="0">
+ <number>0</number>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klistview.h</includehint>
+ <includehint>klistview.h</includehint>
+ <includehint>klistview.h</includehint>
+ <includehint>klistview.h</includehint>
+ <includehint>kled.h</includehint>
+ <includehint>kled.h</includehint>
+ <includehint>kled.h</includehint>
+</includehints>
+</UI>
diff --git a/kfilereplace/knewprojectdlg.cpp b/kfilereplace/knewprojectdlg.cpp
new file mode 100644
index 00000000..5428473b
--- /dev/null
+++ b/kfilereplace/knewprojectdlg.cpp
@@ -0,0 +1,531 @@
+/***************************************************************************
+ knewprojectdlg.cpp - description
+ -------------------
+ begin : Tue Dec 28 1999
+ copyright : (C) 1999 by Fran�is Dupoux
+ (C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ email : dupoux@dupoux.com
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+//QT
+#include <qwhatsthis.h>
+#include <qcheckbox.h>
+#include <qspinbox.h>
+#include <qdatetimeedit.h>
+#include <qlabel.h>
+#include <qradiobutton.h>
+#include <qtextedit.h>
+#include <qlistview.h>
+
+//KDE
+#include <kseparator.h>
+#include <kmessagebox.h>
+#include <kcharsets.h>
+#include <kcombobox.h>
+#include <kconfig.h>
+#include <kfiledialog.h>
+#include <klineedit.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kpushbutton.h>
+#include <kstandarddirs.h>
+#include <kdeversion.h>
+#include <kiconloader.h>
+#include <kdebug.h>
+#include <kapplication.h>
+
+// local
+#include "knewprojectdlg.h"
+#include "whatthis.h"
+
+using namespace whatthisNameSpace;
+
+
+KNewProjectDlg::KNewProjectDlg(RCOptions* info, QWidget *parent, const char *name) : KNewProjectDlgS(parent, name)
+{
+ m_searchNowFlag = "";
+ m_option = info;
+
+ initGUI();
+
+ connect(m_pbLocation, SIGNAL(clicked()), this, SLOT(slotDir()));
+ connect(m_pbCancel, SIGNAL(clicked()), this, SLOT(slotReject()));
+ connect(m_pbSearchNow, SIGNAL(clicked()), this, SLOT(slotSearchNow()));
+ connect(m_pbSearchLater, SIGNAL(clicked()), this, SLOT(slotSearchLater()));
+ connect(m_leSearch, SIGNAL(textChanged(const QString&)), this, SLOT(slotSearchLineEdit(const QString&)));
+ connect(m_chbSizeMin, SIGNAL(toggled(bool)), this, SLOT(slotEnableSpinboxSizeMin(bool)));
+ connect(m_chbSizeMax, SIGNAL(toggled(bool)), this, SLOT(slotEnableSpinboxSizeMax(bool)));
+ connect(m_chbDateMin, SIGNAL(toggled(bool)), m_dedDateMin, SLOT(setEnabled(bool)));
+ connect(m_chbDateMax, SIGNAL(toggled(bool)), m_dedDateMax, SLOT(setEnabled(bool)));
+ connect(m_chbDateMin,SIGNAL(toggled(bool)),this, SLOT(slotEnableCbValidDate(bool)));
+ connect(m_chbDateMax,SIGNAL(toggled(bool)),this, SLOT(slotEnableCbValidDate(bool)));
+ connect(m_chbOwnerUser, SIGNAL(toggled(bool)), this, SLOT(slotEnableChbUser(bool)));
+ connect(m_chbOwnerGroup, SIGNAL(toggled(bool)), this, SLOT(slotEnableChbGroup(bool)));
+ connect(m_chbBackup, SIGNAL(toggled(bool)), this, SLOT(slotEnableChbBackup(bool)));
+ connect(m_pbHelp, SIGNAL(clicked()), this, SLOT(slotHelp()));
+
+ whatsThis();
+}
+
+KNewProjectDlg::~KNewProjectDlg()
+{
+}
+
+void KNewProjectDlg::saveRCOptions()
+{
+ saveOptions();
+ saveFileSizeOptions();
+ saveDateAccessOptions();
+ saveOwnerOptions();
+ saveLocationsList();
+ saveFiltersList();
+ saveBackupExtensionOptions();
+}
+
+void KNewProjectDlg::slotDir()
+{
+ QString directoryString = KFileDialog::getExistingDirectory(QString::null, this, i18n("Project Directory"));
+ if(!directoryString.isEmpty())
+ m_cbLocation->setEditText(directoryString);
+}
+
+void KNewProjectDlg::slotOK()
+{
+ // Check that Search text and Filter are not empty
+ m_option->m_directories = m_cbLocation->currentText();
+ m_option->m_filters = m_cbFilter->currentText();
+ if(!m_leSearch->text().isEmpty())
+ {
+ if(m_leReplace->text().isEmpty())
+ m_option->m_searchingOnlyMode = true;
+ else
+ m_option->m_searchingOnlyMode = false;
+ }
+ m_option->m_quickSearchString = m_searchNowFlag + m_leSearch->text();
+ m_option->m_quickReplaceString = m_searchNowFlag + m_leReplace->text();
+
+ if (m_option->m_directories.isEmpty() || m_option->m_filters.isEmpty())
+ {
+ KMessageBox::error(this, i18n("You must fill the combo boxes (location and filter) before continuing."));
+ return;
+ }
+
+ // OWNER OPTIONS
+ if ((m_chbOwnerUser->isChecked() && m_edOwnerUser->text().isEmpty()) ||
+ (m_chbOwnerGroup->isChecked() && m_edOwnerGroup->text().isEmpty()))
+ {
+ KMessageBox::error(this, i18n("Some edit boxes are empty in the <b>Owner</b> page."));
+ return ;
+ }
+
+ // Check option "Size Min/Max": check MinSize is not greater than MaxSize
+ int minSize = m_spbSizeMin->value(),
+ maxSize = m_spbSizeMax->value();
+ if ((minSize != FileSizeOption) && (maxSize != FileSizeOption))
+ if (minSize > maxSize)
+ {
+ KMessageBox::error(this, i18n("The minimum size is greater than the maximum size."));
+ return ;
+ }
+
+ accept();
+}
+
+void KNewProjectDlg::slotReject()
+{
+ m_option->m_quickSearchString = m_searchNowFlag;
+ m_option->m_quickReplaceString = m_searchNowFlag;
+
+ reject();
+}
+
+void KNewProjectDlg::slotSearchNow()
+{ //Add a 'N' to represent the status search-now
+ m_searchNowFlag = "N";
+ slotOK();
+}
+
+void KNewProjectDlg::slotSearchLater()
+{ //Add a 'L' to represent the status search-later
+ m_searchNowFlag = "L";
+ slotOK();
+}
+
+void KNewProjectDlg::slotSearchLineEdit(const QString& t)
+{
+ m_pbSearchNow->setEnabled(!t.isEmpty());
+}
+
+void KNewProjectDlg::slotEnableSpinboxSizeMin(bool b)
+{
+ m_spbSizeMin->setEnabled(b);
+}
+
+void KNewProjectDlg::slotEnableSpinboxSizeMax(bool b)
+{
+ m_spbSizeMax->setEnabled(b);
+}
+
+void KNewProjectDlg::slotEnableCbValidDate(bool b)
+{
+ Q_UNUSED(b);
+ m_cbDateValid->setEnabled(m_chbDateMax->isChecked() || m_chbDateMin->isChecked());
+}
+
+void KNewProjectDlg::slotEnableChbUser(bool b)
+{
+ m_cbOwnerUserType->setEnabled(b);
+ m_cbOwnerUserBool->setEnabled(b);
+ m_edOwnerUser->setEnabled(b);
+}
+
+void KNewProjectDlg::slotEnableChbGroup(bool b)
+{
+ m_cbOwnerGroupType->setEnabled(b);
+ m_cbOwnerGroupBool->setEnabled(b);
+ m_edOwnerGroup->setEnabled(b);
+}
+
+void KNewProjectDlg::slotEnableChbBackup(bool b)
+{
+ m_leBackup->setEnabled(b);
+ m_tlBackup->setEnabled(b);
+}
+
+//PRIVATE
+void KNewProjectDlg::initGUI()
+{
+ QIconSet iconSet = SmallIconSet("fileopen");
+ QPixmap pixMap = iconSet.pixmap( QIconSet::Small, QIconSet::Normal );
+
+ m_pbLocation->setIconSet(iconSet);
+ m_pbLocation->setFixedSize(pixMap.width() + 8, pixMap.height() + 8);
+
+ m_pbSearchNow->setEnabled(false);
+
+ loadOptions();
+ loadFileSizeOptions();
+ loadDateAccessOptions();
+ loadOwnerOptions();
+ loadBackupExtensionOptions();
+ loadLocationsList();
+ loadFiltersList();
+}
+
+void KNewProjectDlg::loadOptions()
+{
+ QStringList availableEncodingNames(KGlobal::charsets()->availableEncodingNames());
+ m_cbEncoding->insertStringList(availableEncodingNames);
+ int idx = -1;
+ int utf8Idx = -1;
+ for (uint i = 0; i < availableEncodingNames.count(); i++)
+ {
+ if (availableEncodingNames[i] == m_option->m_encoding)
+ {
+ idx = i;
+ break;
+ }
+ if (availableEncodingNames[i] == "utf8")
+ {
+ utf8Idx = i;
+ }
+ }
+ if (idx != -1)
+ m_cbEncoding->setCurrentItem(idx);
+ else
+ m_cbEncoding->setCurrentItem(utf8Idx);
+
+ m_chbIncludeSubfolders->setChecked(m_option->m_recursive);
+ m_chbCaseSensitive->setChecked(m_option->m_caseSensitive);
+ m_chbEnableVariables->setChecked(m_option->m_variables);
+ m_chbRegularExpressions->setChecked(m_option->m_regularExpressions);
+}
+
+void KNewProjectDlg::loadFileSizeOptions()
+{
+ int size = m_option->m_minSize;
+ if(size == FileSizeOption)
+ {
+ m_chbSizeMin->setChecked(false);
+ m_spbSizeMin->setEnabled(false);
+ m_spbSizeMin->setValue(0);
+ }
+ else
+ {
+ m_chbSizeMin->setChecked(true);
+ m_spbSizeMin->setEnabled(true);
+ m_spbSizeMin->setValue(size);
+ }
+
+ size = m_option->m_maxSize;
+ if(size == FileSizeOption)
+ {
+ m_chbSizeMax->setChecked(false);
+ m_spbSizeMax->setEnabled(false);
+ m_spbSizeMax->setValue(0);
+ }
+ else
+ {
+ m_chbSizeMax->setChecked(true);
+ m_spbSizeMax->setEnabled(true);
+ m_spbSizeMax->setValue(size);
+ }
+}
+
+void KNewProjectDlg::loadDateAccessOptions()
+{
+ // ================== DATE OPTIONS ========================
+
+ QString date = m_option->m_minDate;
+ if(date == AccessDateOption)
+ {
+ m_chbDateMin->setChecked(false);
+ m_dedDateMin->setDate(m_dedDateMin->minValue());
+ m_dedDateMin->setEnabled(false);
+ }
+ else
+ {
+ m_chbDateMin->setChecked(true);
+ m_dedDateMin->setDate(QDate::fromString(date,Qt::ISODate));
+ m_dedDateMin->setEnabled(true);
+ }
+
+ date = m_option->m_maxDate;
+ if(date == AccessDateOption)
+ {
+ m_chbDateMax->setChecked(false);
+ m_dedDateMax->setDate(m_dedDateMax->maxValue());
+ m_dedDateMax->setEnabled(false);
+ }
+ else
+ {
+ m_chbDateMax->setChecked(true);
+ m_dedDateMax->setDate(QDate::fromString(date,Qt::ISODate));
+ m_dedDateMax->setEnabled(true);
+ }
+
+ m_cbDateValid->setEnabled(m_chbDateMax->isChecked() || m_chbDateMin->isChecked());
+
+}
+
+void KNewProjectDlg::loadOwnerOptions()
+{
+ bool enableOwner = m_option->m_ownerUserIsChecked;
+
+ m_chbOwnerUser->setChecked(enableOwner);
+ m_cbOwnerUserType->setEnabled(enableOwner);
+ m_cbOwnerUserBool->setEnabled(enableOwner);
+ m_edOwnerUser->setEnabled(enableOwner);
+
+ m_cbOwnerUserType->setCurrentText(m_option->m_ownerUserType);
+ m_cbOwnerUserBool->setCurrentText(m_option->m_ownerUserBool);
+
+ m_edOwnerUser->setText(m_option->m_ownerUserValue);
+
+ enableOwner = m_option->m_ownerGroupIsChecked;
+
+ m_chbOwnerGroup->setChecked(enableOwner);
+ m_cbOwnerGroupType->setEnabled(enableOwner);
+ m_cbOwnerGroupBool->setEnabled(enableOwner);
+ m_edOwnerGroup->setEnabled(enableOwner);
+
+ m_cbOwnerGroupType->setCurrentText(m_option->m_ownerGroupType);
+ m_cbOwnerGroupBool->setCurrentText(m_option->m_ownerGroupBool);
+ m_edOwnerGroup->setText(m_option->m_ownerGroupValue);
+}
+
+void KNewProjectDlg::loadLocationsList()
+{
+ m_cbLocation->insertStringList(m_option->m_directories);
+}
+
+void KNewProjectDlg::loadFiltersList()
+{
+ m_cbFilter->insertStringList(m_option->m_filters);
+}
+
+void KNewProjectDlg::loadBackupExtensionOptions()
+{
+ bool enableBackup = m_option->m_backup;
+
+ m_chbBackup->setChecked(enableBackup);
+ m_leBackup->setEnabled(enableBackup);
+ m_tlBackup->setEnabled(enableBackup);
+ m_leBackup->setText(m_option->m_backupExtension);
+}
+
+void KNewProjectDlg::saveOptions()
+{
+ m_option->m_encoding = m_cbEncoding->currentText();
+ m_option->m_recursive = m_chbIncludeSubfolders->isChecked();
+ m_option->m_caseSensitive = m_chbCaseSensitive->isChecked();
+ m_option->m_variables = m_chbEnableVariables->isChecked();
+ m_option->m_regularExpressions = m_chbRegularExpressions->isChecked();
+}
+
+void KNewProjectDlg::saveFileSizeOptions()
+{
+ if(m_chbSizeMax->isChecked())
+ m_option->m_maxSize = m_spbSizeMax->value();
+ else
+ m_option->m_maxSize = FileSizeOption;
+
+ if(m_chbSizeMin->isChecked())
+ m_option->m_minSize = m_spbSizeMin->value();
+ else
+ m_option->m_minSize = FileSizeOption;
+}
+
+void KNewProjectDlg::saveDateAccessOptions()
+{
+ if(m_chbDateMin->isChecked() || m_chbDateMax->isChecked())
+ m_option->m_dateAccess = m_cbDateValid->currentText();
+ else
+ m_option->m_dateAccess = ValidAccessDateOption;
+
+ if(m_chbDateMin->isChecked())
+ {
+ QString date = m_dedDateMin->date().toString(Qt::ISODate);
+ m_option->m_minDate = date;
+ }
+ else
+ m_option->m_minDate = AccessDateOption;
+
+ if(m_chbDateMax->isChecked())
+ {
+ QString date = m_dedDateMax->date().toString(Qt::ISODate);
+ m_option->m_maxDate = date;
+ }
+ else
+ m_option->m_maxDate = AccessDateOption;
+}
+
+void KNewProjectDlg::saveOwnerOptions()
+{
+ bool isChecked = m_chbOwnerUser->isChecked();
+ if(isChecked)
+ {
+ m_option->m_ownerUserIsChecked = true;
+ m_option->m_ownerUserType = m_cbOwnerUserType->currentText();
+ m_option->m_ownerUserBool = m_cbOwnerUserBool->currentText();
+ m_option->m_ownerUserValue = m_edOwnerUser->text();
+ }
+ else
+ {
+ m_option->m_ownerUserIsChecked = false;
+ m_option->m_ownerUserType = "Name";
+ m_option->m_ownerUserBool = "Equals To";
+ m_option->m_ownerUserValue = "";
+ }
+
+ isChecked = m_chbOwnerGroup->isChecked();
+ if(isChecked)
+ {
+ m_option->m_ownerGroupIsChecked = true;
+ m_option->m_ownerGroupType = m_cbOwnerGroupType->currentText();
+ m_option->m_ownerGroupBool = m_cbOwnerGroupBool->currentText();
+ m_option->m_ownerGroupValue = m_edOwnerGroup->text();
+ }
+ else
+ {
+ m_option->m_ownerGroupIsChecked = false;
+ m_option->m_ownerGroupType = "Name";
+ m_option->m_ownerGroupBool = "Equals To";
+ m_option->m_ownerGroupValue = "";
+ }
+}
+
+void KNewProjectDlg::saveLocationsList()
+{
+ QString current = m_cbLocation->currentText();
+ QStringList list = current;
+
+ int count = m_cbLocation->listBox()->count(),
+ i;
+ for(i = 0; i < count; i++)
+ {
+ QString text = m_cbLocation->listBox()->item(i)->text();
+ if(text != current)
+ list.append(text);
+ }
+ m_option->m_directories = list;
+}
+
+void KNewProjectDlg::saveFiltersList()
+{
+ QString current = m_cbFilter->currentText();
+ QStringList list = current;
+
+ int count = m_cbFilter->listBox()->count(),
+ i;
+ for(i = 0; i < count; i++)
+ {
+ QString text = m_cbFilter->listBox()->item(i)->text();
+ if(text != current)
+ list.append(text);
+ }
+ m_option->m_filters = list;
+}
+
+void KNewProjectDlg::saveBackupExtensionOptions()
+{
+ QString backupExt = m_leBackup->text();
+ m_option->m_backup = (m_chbBackup->isChecked() && !backupExt.isEmpty());
+ m_option->m_backupExtension = backupExt;
+}
+
+void KNewProjectDlg::setDatas(const QString& directoryString, const QString& filterString)
+{
+ if (!directoryString.isEmpty())
+ m_cbLocation->setEditText(directoryString);
+
+ if (!filterString.isEmpty())
+ m_cbFilter->setEditText(filterString);
+}
+
+bool KNewProjectDlg::contains(QListView* lv,const QString& s, int column)
+{
+ QListViewItem* i = lv->firstChild();
+ while (i != 0)
+ {
+ if(i->text(column) == s)
+ return true;
+ i = i->nextSibling();
+ }
+ return false;
+}
+
+void KNewProjectDlg::whatsThis()
+{
+ QWhatsThis::add(m_cbLocation, cbLocationWhatthis);
+ QWhatsThis::add(m_cbFilter, cbFilterWhatthis);
+
+ QWhatsThis::add(m_spbSizeMin, edSizeMinWhatthis);
+ QWhatsThis::add(m_spbSizeMax, edSizeMaxWhatthis);
+
+ QWhatsThis::add(m_cbDateValid, cbDateValidWhatthis);
+ QWhatsThis::add(m_chbDateMin, chbDateMinWhatthis);
+ QWhatsThis::add(m_chbDateMax, chbDateMaxWhatthis);
+
+ QWhatsThis::add(m_chbIncludeSubfolders, chbRecursiveWhatthis);
+ QWhatsThis::add(m_chbRegularExpressions, chbRegularExpressionsWhatthis);
+ QWhatsThis::add(m_chbEnableVariables, chbVariablesWhatthis);
+ QWhatsThis::add(m_chbCaseSensitive, chbCaseSensitiveWhatthis);
+ QWhatsThis::add(m_chbBackup, chbBackupWhatthis);
+ QWhatsThis::add(m_leBackup, chbBackupWhatthis);
+ QWhatsThis::add(m_leSearch, leSearchWhatthis);
+ QWhatsThis::add(m_leReplace, leReplaceWhatthis);
+}
+
+#include "knewprojectdlg.moc"
+
diff --git a/kfilereplace/knewprojectdlg.h b/kfilereplace/knewprojectdlg.h
new file mode 100644
index 00000000..e4852cb8
--- /dev/null
+++ b/kfilereplace/knewprojectdlg.h
@@ -0,0 +1,84 @@
+/***************************************************************************
+ knewprojectdlg.h - description
+ -------------------
+ begin : Tue Dec 28 1999
+ copyright : (C) 1999 by François Dupoux
+ (C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ email : dupoux@dupoux.com
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KNEWPROJECTDLG_H
+#define KNEWPROJECTDLG_H
+
+//KDE
+class KConfig;
+
+//local
+#include "knewprojectdlgs.h"
+#include "configurationclasses.h"
+
+class KNewProjectDlg : public KNewProjectDlgS
+{
+ Q_OBJECT
+
+ private:
+ QString m_searchNowFlag;
+ RCOptions* m_option;
+
+ public:
+ KNewProjectDlg(RCOptions* info, QWidget *parent=0, const char *name=0);
+ ~KNewProjectDlg();
+
+ public:
+ //void updateOptions(const RCOptions& info);
+ void saveRCOptions();
+
+ protected slots:
+ void slotDir();
+ void slotOK();
+ void slotReject();
+ void slotSearchNow();
+ void slotSearchLater();
+ void slotSearchLineEdit(const QString& t);
+ void slotEnableSpinboxSizeMin(bool b);
+ void slotEnableSpinboxSizeMax(bool b);
+ void slotEnableCbValidDate(bool b);
+ void slotEnableChbUser(bool b);
+ void slotEnableChbGroup(bool b);
+ void slotEnableChbBackup(bool b);
+ void slotHelp(){ kapp->invokeHelp(QString::null, "kfilereplace"); }
+
+ private:
+ void initGUI();
+
+ void loadOptions();
+ void loadFileSizeOptions();
+ void loadDateAccessOptions();
+ void loadOwnerOptions();
+ void loadLocationsList();
+ void loadFiltersList();
+ void loadBackupExtensionOptions();
+
+ void saveOptions();
+ void saveFileSizeOptions();
+ void saveDateAccessOptions();
+ void saveOwnerOptions();
+ void saveLocationsList();
+ void saveFiltersList();
+ void saveBackupExtensionOptions();
+
+ bool contains(QListView* lv,const QString& s, int column);
+ void setDatas(const QString& directoryString, const QString& filterString);
+ void whatsThis();
+};
+
+#endif // KNewProjectDlg
diff --git a/kfilereplace/knewprojectdlgs.ui b/kfilereplace/knewprojectdlgs.ui
new file mode 100644
index 00000000..238a003f
--- /dev/null
+++ b/kfilereplace/knewprojectdlgs.ui
@@ -0,0 +1,898 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KNewProjectDlgS</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>KNewProjectDlgS</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>568</width>
+ <height>609</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Search &amp; Replace in Files</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="modal">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout28</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>m_pbHelp</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>70</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>&amp;Help</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>150</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>m_pbSearchNow</cstring>
+ </property>
+ <property name="text">
+ <string>Search Now</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>m_pbSearchLater</cstring>
+ </property>
+ <property name="text">
+ <string>Search Later</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>m_pbCancel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>70</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QTabWidget" row="0" column="0">
+ <property name="name">
+ <cstring>tabWidget2</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;General</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBox5</cstring>
+ </property>
+ <property name="title">
+ <string>Startup Folder Options</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>m_tlFilter</cstring>
+ </property>
+ <property name="text">
+ <string>Filter:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>cbFilter</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>m_tlLocation</cstring>
+ </property>
+ <property name="text">
+ <string>Location:</string>
+ </property>
+ <property name="textFormat">
+ <enum>AutoText</enum>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>cbLocation</cstring>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="0" column="1">
+ <property name="name">
+ <cstring>m_cbLocation</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="sizeLimit">
+ <number>20</number>
+ </property>
+ <property name="maxCount">
+ <number>10</number>
+ </property>
+ <property name="insertionPolicy">
+ <enum>AtTop</enum>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Insert a search path here. You can use the search path button.</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="2">
+ <property name="name">
+ <cstring>m_pbLocation</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="1" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>m_cbFilter</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="sizeLimit">
+ <number>20</number>
+ </property>
+ <property name="maxCount">
+ <number>10</number>
+ </property>
+ <property name="insertionPolicy">
+ <enum>AtTop</enum>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_chbIncludeSubfolders</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Include subfolders</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupBox6</cstring>
+ </property>
+ <property name="title">
+ <string>Search/Replace Strings</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>m_leSearch</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>m_leReplace</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>m_tlSearch</cstring>
+ </property>
+ <property name="text">
+ <string>Search:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>m_tlReplace</cstring>
+ </property>
+ <property name="text">
+ <string>Replace:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="2" column="0">
+ <property name="name">
+ <cstring>groupBox4</cstring>
+ </property>
+ <property name="title">
+ <string>General Options</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_chbRegularExpressions</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Enable &amp;regular expressions</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="4" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_chbBackup</cstring>
+ </property>
+ <property name="text">
+ <string>Do &amp;backup copy instead of overwrite</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_chbCaseSensitive</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Case sensitive</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="3" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_chbEnableVariables</cstring>
+ </property>
+ <property name="text">
+ <string>Enable co&amp;mmands in the replace string</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="5" column="0">
+ <property name="name">
+ <cstring>m_tlBackup</cstring>
+ </property>
+ <property name="text">
+ <string>Backup copy suffix:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="5" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>m_leBackup</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="0" column="2">
+ <property name="name">
+ <cstring>m_cbEncoding</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Encoding of the files:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;Advanced</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox" row="2" column="0">
+ <property name="name">
+ <cstring>gbOwnership</cstring>
+ </property>
+ <property name="title">
+ <string>Ownership Filtering</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>m_chbOwnerUser</cstring>
+ </property>
+ <property name="text">
+ <string>User: </string>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="0" column="1">
+ <item>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>ID (Number)</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>m_cbOwnerUserType</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizeLimit">
+ <number>2</number>
+ </property>
+ <property name="maxCount">
+ <number>2</number>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="0" column="2">
+ <item>
+ <property name="text">
+ <string>Equals To</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Is Not</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>m_cbOwnerUserBool</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizeLimit">
+ <number>2</number>
+ </property>
+ <property name="maxCount">
+ <number>2</number>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="1" column="2">
+ <item>
+ <property name="text">
+ <string>Equals To</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Is Not</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>m_cbOwnerGroupBool</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizeLimit">
+ <number>2</number>
+ </property>
+ <property name="maxCount">
+ <number>2</number>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="1" column="1">
+ <item>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>ID (Number)</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>m_cbOwnerGroupType</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizeLimit">
+ <number>2</number>
+ </property>
+ <property name="maxCount">
+ <number>2</number>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>m_chbOwnerGroup</cstring>
+ </property>
+ <property name="text">
+ <string>Group:</string>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="0" column="3">
+ <property name="name">
+ <cstring>m_edOwnerUser</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="1" column="3">
+ <property name="name">
+ <cstring>m_edOwnerGroup</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>gbAccessDate</cstring>
+ </property>
+ <property name="title">
+ <string>Access Date Filtering</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout8</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout18</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>m_tlDateValid</cstring>
+ </property>
+ <property name="text">
+ <string>Dates valid for:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_chbDateMin</cstring>
+ </property>
+ <property name="text">
+ <string>Accessed after:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_chbDateMax</cstring>
+ </property>
+ <property name="text">
+ <string>Accessed before: </string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout19</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KComboBox">
+ <item>
+ <property name="text">
+ <string>Last Writing Access</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Last Reading Access</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>m_cbDateValid</cstring>
+ </property>
+ <property name="sizeLimit">
+ <number>2</number>
+ </property>
+ <property name="maxCount">
+ <number>2</number>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QDateEdit">
+ <property name="name">
+ <cstring>m_dedDateMin</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="date">
+ <date>
+ <year>2000</year>
+ <month>1</month>
+ <day>1</day>
+ </date>
+ </property>
+ <property name="autoAdvance">
+ <bool>true</bool>
+ </property>
+ <property name="maxValue">
+ <date>
+ <year>2100</year>
+ <month>12</month>
+ <day>31</day>
+ </date>
+ </property>
+ <property name="minValue">
+ <date>
+ <year>1900</year>
+ <month>12</month>
+ <day>31</day>
+ </date>
+ </property>
+ </widget>
+ <widget class="QDateEdit">
+ <property name="name">
+ <cstring>m_dedDateMax</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="date">
+ <date>
+ <year>2000</year>
+ <month>1</month>
+ <day>1</day>
+ </date>
+ </property>
+ <property name="autoAdvance">
+ <bool>true</bool>
+ </property>
+ <property name="maxValue">
+ <date>
+ <year>2100</year>
+ <month>12</month>
+ <day>31</day>
+ </date>
+ </property>
+ <property name="minValue">
+ <date>
+ <year>1900</year>
+ <month>9</month>
+ <day>14</day>
+ </date>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>190</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>gbSize</cstring>
+ </property>
+ <property name="title">
+ <string>Size Filtering</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout32</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout31</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_chbSizeMin</cstring>
+ </property>
+ <property name="text">
+ <string>Minimum si&amp;ze:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_chbSizeMax</cstring>
+ </property>
+ <property name="text">
+ <string>Maximum size:</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout30</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>m_spbSizeMin</cstring>
+ </property>
+ <property name="maxValue">
+ <number>4000000</number>
+ </property>
+ <property name="minValue">
+ <number>0</number>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>m_spbSizeMax</cstring>
+ </property>
+ <property name="maxValue">
+ <number>4000000</number>
+ </property>
+ <property name="minValue">
+ <number>0</number>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout31</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>m_tlSizeMin</cstring>
+ </property>
+ <property name="text">
+ <string>KB</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>m_tlSizeMax</cstring>
+ </property>
+ <property name="text">
+ <string>KB</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>330</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<tabstops>
+ <tabstop>tabWidget2</tabstop>
+ <tabstop>m_leSearch</tabstop>
+ <tabstop>m_leReplace</tabstop>
+ <tabstop>m_cbLocation</tabstop>
+ <tabstop>m_pbLocation</tabstop>
+ <tabstop>m_cbFilter</tabstop>
+ <tabstop>m_chbIncludeSubfolders</tabstop>
+ <tabstop>m_cbEncoding</tabstop>
+ <tabstop>m_chbCaseSensitive</tabstop>
+ <tabstop>m_chbRegularExpressions</tabstop>
+ <tabstop>m_chbEnableVariables</tabstop>
+ <tabstop>m_chbBackup</tabstop>
+ <tabstop>m_leBackup</tabstop>
+ <tabstop>m_pbSearchNow</tabstop>
+ <tabstop>m_pbSearchLater</tabstop>
+ <tabstop>m_pbCancel</tabstop>
+ <tabstop>m_pbHelp</tabstop>
+ <tabstop>m_chbSizeMin</tabstop>
+ <tabstop>m_spbSizeMin</tabstop>
+ <tabstop>m_chbSizeMax</tabstop>
+ <tabstop>m_spbSizeMax</tabstop>
+ <tabstop>m_cbDateValid</tabstop>
+ <tabstop>m_chbDateMin</tabstop>
+ <tabstop>m_chbDateMax</tabstop>
+ <tabstop>m_chbOwnerUser</tabstop>
+ <tabstop>m_cbOwnerUserType</tabstop>
+ <tabstop>m_cbOwnerUserBool</tabstop>
+ <tabstop>m_edOwnerUser</tabstop>
+ <tabstop>m_chbOwnerGroup</tabstop>
+ <tabstop>m_cbOwnerGroupType</tabstop>
+ <tabstop>m_cbOwnerGroupBool</tabstop>
+ <tabstop>m_edOwnerGroup</tabstop>
+ <tabstop>m_dedDateMin</tabstop>
+ <tabstop>m_dedDateMax</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kfilereplace/koptionsdlg.cpp b/kfilereplace/koptionsdlg.cpp
new file mode 100644
index 00000000..3980a7a6
--- /dev/null
+++ b/kfilereplace/koptionsdlg.cpp
@@ -0,0 +1,236 @@
+/***************************************************************************
+ koptionsdlg.cpp - description
+ -------------------
+ begin : Tue Dec 28 1999
+ copyright : (C) 1999 by Fran�is Dupoux
+ (C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ email : dupoux@dupoux.com
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+// QT
+#include <qcheckbox.h>
+#include <qspinbox.h>
+#include <qwhatsthis.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+
+// KDE
+#include <kcharsets.h>
+#include <kcombobox.h>
+#include <kconfig.h>
+#include <kglobal.h>
+#include <kstandarddirs.h>
+#include <kapplication.h>
+//#include <kdebug.h>
+
+// local
+#include "whatthis.h"
+#include "koptionsdlg.h"
+
+
+using namespace whatthisNameSpace;
+
+
+KOptionsDlg::KOptionsDlg(RCOptions* info, QWidget *parent, const char *name) : KOptionsDlgS(parent,name,true)
+{
+ m_config = new KConfig("kfilereplacerc");
+ m_option = info;
+
+ initGUI();
+
+ connect(m_pbOK, SIGNAL(clicked()), this, SLOT(slotOK()));
+ connect(m_pbDefault, SIGNAL(clicked()),this,SLOT(slotDefaults()));
+ connect(m_chbBackup, SIGNAL(toggled(bool)), this, SLOT(slotChbBackup(bool)));
+ connect(m_pbHelp, SIGNAL(clicked()), this, SLOT(slotHelp()));
+ connect(m_chbConfirmStrings, SIGNAL(toggled(bool)), this, SLOT(slotChbConfirmStrings(bool)));
+ connect(m_chbShowConfirmDialog, SIGNAL(toggled(bool)), this, SLOT(slotChbShowConfirmDialog(bool)));
+
+ whatsThis();
+}
+
+KOptionsDlg::~KOptionsDlg()
+{
+}
+
+//PRIVATE SLOTS
+void KOptionsDlg::slotOK()
+{
+ saveRCOptions();
+ accept();
+}
+
+/** Set defaults values for all options of the dialog */
+void KOptionsDlg::slotDefaults()
+{
+ m_chbCaseSensitive->setChecked(CaseSensitiveOption);
+ m_chbRecursive->setChecked(RecursiveOption);
+ m_chbHaltOnFirstOccurrence->setChecked(StopWhenFirstOccurenceOption);
+
+ m_chbFollowSymLinks->setChecked(FollowSymbolicLinksOption);
+ m_chbIgnoreHidden->setChecked(IgnoreHiddenOption);
+ m_chbRegularExpressions->setChecked(RegularExpressionsOption);
+ m_chbIgnoreFiles->setChecked(IgnoreFilesOption);
+ m_chbConfirmStrings->setChecked(AskConfirmReplaceOption);
+
+ QStringList bkList = QStringList::split(",",BackupExtensionOption,true);
+
+ bool enableBackup = (bkList[0] == "true" ? true : false);
+
+ m_chbBackup->setChecked(enableBackup);
+ m_leBackup->setEnabled(enableBackup);
+ m_tlBackup->setEnabled(enableBackup);
+
+ m_leBackup->setText(bkList[1]);
+
+ m_chbVariables->setChecked(VariablesOption);
+
+ m_chbNotifyOnErrors->setChecked(NotifyOnErrorsOption);
+}
+
+void KOptionsDlg::slotChbBackup(bool b)
+{
+ m_leBackup->setEnabled(b);
+ m_tlBackup->setEnabled(b);
+}
+
+void KOptionsDlg::slotChbConfirmStrings(bool b)
+{
+ if(b)
+ {
+ m_chbShowConfirmDialog->setEnabled(true);
+ m_chbShowConfirmDialog->setChecked(true);
+ m_config->setGroup("Notification Messages");
+ m_config->writeEntry(rcDontAskAgain,"no");
+ }
+ else
+ {
+ m_chbShowConfirmDialog->setEnabled(false);
+ m_chbShowConfirmDialog->setChecked(false);
+ m_config->setGroup("Notification Messages");
+ m_config->writeEntry(rcDontAskAgain,"yes");
+ }
+}
+
+void KOptionsDlg::slotChbShowConfirmDialog(bool b)
+{
+ m_config->setGroup("Notification Messages");
+ if(b)
+ {
+ m_config->writeEntry(rcDontAskAgain,"no");
+ }
+ else
+ {
+ m_config->writeEntry(rcDontAskAgain,"yes");
+ }
+}
+
+//PRIVATE
+void KOptionsDlg::initGUI()
+{
+ m_config->sync();
+ m_config->setGroup("Notification Messages");
+ m_option->m_notifyOnErrors = m_config->readBoolEntry(rcNotifyOnErrors, true);
+
+ QString dontAskAgain = m_config->readEntry(rcDontAskAgain,"no");
+
+ m_chbConfirmStrings->setChecked(m_option->m_askConfirmReplace);
+
+ if(m_chbConfirmStrings->isChecked())
+ {
+ if(dontAskAgain == "yes")
+ m_chbShowConfirmDialog->setChecked(false);
+ else
+ m_chbShowConfirmDialog->setChecked(true);
+ }
+
+ QStringList availableEncodingNames(KGlobal::charsets()->availableEncodingNames());
+ m_cbEncoding->insertStringList( availableEncodingNames );
+ int idx = -1;
+ int utf8Idx = -1;
+ for (uint i = 0; i < availableEncodingNames.count(); i++)
+ {
+ if (availableEncodingNames[i] == m_option->m_encoding)
+ {
+ idx = i;
+ break;
+ }
+ if (availableEncodingNames[i] == "utf8")
+ {
+ utf8Idx = i;
+ }
+ }
+ if (idx != -1)
+ m_cbEncoding->setCurrentItem(idx);
+ else
+ m_cbEncoding->setCurrentItem(utf8Idx);
+
+ m_chbCaseSensitive->setChecked(m_option->m_caseSensitive);
+ m_chbRecursive->setChecked(m_option->m_recursive);
+
+ bool enableBackup = m_option->m_backup;
+
+ m_chbBackup->setChecked(enableBackup);
+ m_leBackup->setEnabled(enableBackup);
+ m_tlBackup->setEnabled(enableBackup);
+
+ m_leBackup->setText(m_option->m_backupExtension);
+
+ m_chbVariables->setChecked(m_option->m_variables);
+ m_chbRegularExpressions->setChecked(m_option->m_regularExpressions);
+ m_chbHaltOnFirstOccurrence->setChecked(m_option->m_haltOnFirstOccur);
+ m_chbFollowSymLinks->setChecked(m_option->m_followSymLinks);
+ m_chbIgnoreHidden->setChecked(m_option->m_ignoreHidden);
+ m_chbIgnoreFiles->setChecked(m_option->m_ignoreFiles);
+
+ m_chbNotifyOnErrors->setChecked(m_option->m_notifyOnErrors);
+}
+
+void KOptionsDlg::saveRCOptions()
+{
+ m_option->m_encoding = m_cbEncoding->currentText();
+ m_option->m_caseSensitive = m_chbCaseSensitive->isChecked();
+ m_option->m_recursive = m_chbRecursive->isChecked();
+ QString backupExt = m_leBackup->text();
+ m_option->m_backup = (m_chbBackup->isChecked() && !backupExt.isEmpty());
+ m_option->m_backupExtension = backupExt;
+ m_option->m_variables = m_chbVariables->isChecked();
+ m_option->m_regularExpressions = m_chbRegularExpressions->isChecked();
+ m_option->m_haltOnFirstOccur = m_chbHaltOnFirstOccurrence->isChecked();
+ m_option->m_followSymLinks = m_chbFollowSymLinks->isChecked();
+ m_option->m_ignoreHidden = m_chbIgnoreHidden->isChecked();
+ m_option->m_ignoreFiles = m_chbIgnoreFiles->isChecked();
+ m_option->m_askConfirmReplace = m_chbConfirmStrings->isChecked();
+ m_option->m_notifyOnErrors = m_chbNotifyOnErrors->isChecked();
+
+ m_config->setGroup("Notification Messages");
+ m_config->writeEntry(rcNotifyOnErrors, m_option->m_notifyOnErrors);
+
+ m_config->sync();
+}
+
+void KOptionsDlg::whatsThis()
+{
+ // Create help QWhatsThis
+ QWhatsThis::add(m_chbCaseSensitive, chbCaseSensitiveWhatthis);
+ QWhatsThis::add(m_chbRecursive, chbRecursiveWhatthis);
+ QWhatsThis::add(m_chbHaltOnFirstOccurrence, chbHaltOnFirstOccurrenceWhatthis);
+ QWhatsThis::add(m_chbFollowSymLinks, chbFollowSymLinksWhatthis);
+ QWhatsThis::add(m_chbIgnoreHidden, chbIgnoreHiddenWhatthis);
+ QWhatsThis::add(m_chbIgnoreFiles, chbIgnoreFilesWhatthis);
+ QWhatsThis::add(m_chbRegularExpressions, chbRegularExpressionsWhatthis);
+ QWhatsThis::add(m_chbVariables, chbVariablesWhatthis);
+ QWhatsThis::add(m_chbBackup, chbBackupWhatthis);
+ QWhatsThis::add(m_chbConfirmStrings, chbConfirmStringsWhatthis);
+}
+
+#include "koptionsdlg.moc"
diff --git a/kfilereplace/koptionsdlg.h b/kfilereplace/koptionsdlg.h
new file mode 100644
index 00000000..993f2c7d
--- /dev/null
+++ b/kfilereplace/koptionsdlg.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ koptionsdlg.h - description
+ -------------------
+ begin : Tue Dec 28 1999
+ copyright : (C) 1999 by François Dupoux
+ (C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
+ email : dupoux@dupoux.com
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KOPTIONSDLG_H
+#define KOPTIONSDLG_H
+
+// KDE
+class KConfig;
+
+//local
+#include "configurationclasses.h"
+#include "koptionsdlgs.h"
+
+/**
+ *@author François Dupoux
+ */
+
+class KOptionsDlg : public KOptionsDlgS
+{
+ Q_OBJECT
+ public:
+ KOptionsDlg(RCOptions* info, QWidget *parent, const char *name);
+ ~KOptionsDlg();
+
+ private:
+ RCOptions* m_option;
+ KConfig *m_config;
+
+ private slots:
+ void slotOK();
+ void slotDefaults();
+ void slotChbBackup(bool b);
+ void slotChbConfirmStrings(bool b);
+ void slotChbShowConfirmDialog(bool b);
+ void slotHelp(){ kapp->invokeHelp(QString::null, "kfilereplace"); }
+
+ private:
+ void initGUI();
+ void saveRCOptions();
+ void whatsThis();
+};
+
+#endif // KOPTIONSDLG_H
diff --git a/kfilereplace/koptionsdlgs.ui b/kfilereplace/koptionsdlgs.ui
new file mode 100644
index 00000000..88f0d8f8
--- /dev/null
+++ b/kfilereplace/koptionsdlgs.ui
@@ -0,0 +1,347 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KOptionsDlgS</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>KOptionsDlgS</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>572</width>
+ <height>420</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Options</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QTabWidget" row="0" column="0" rowspan="1" colspan="5">
+ <property name="name">
+ <cstring>tabWidget2</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab1</cstring>
+ </property>
+ <attribute name="title">
+ <string>General</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupBox7</cstring>
+ </property>
+ <property name="title">
+ <string>General Options</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="4" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_chbVariables</cstring>
+ </property>
+ <property name="text">
+ <string>Enable commands in replace strings</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="7" column="0">
+ <property name="name">
+ <cstring>m_tlBackup</cstring>
+ </property>
+ <property name="text">
+ <string>Backup copy suffix:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="7" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>m_leBackup</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="5" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_chbNotifyOnErrors</cstring>
+ </property>
+ <property name="text">
+ <string>Notif&amp;y on errors</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_chbCaseSensitive</cstring>
+ </property>
+ <property name="text">
+ <string>Case sensitive</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_chbRecursive</cstring>
+ </property>
+ <property name="text">
+ <string>Recursive (search/replace in all sub folders)</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="3" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_chbRegularExpressions</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Enable regular e&amp;xpressions</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="6" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_chbBackup</cstring>
+ </property>
+ <property name="text">
+ <string>Do &amp;backup copy</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Encoding of the files:</string>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="0" column="2">
+ <property name="name">
+ <cstring>m_cbEncoding</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>Tab3</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;Advanced</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>gbxConfirm</cstring>
+ </property>
+ <property name="title">
+ <string>Advanced Options</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="5" column="0">
+ <property name="name">
+ <cstring>m_chbIgnoreHidden</cstring>
+ </property>
+ <property name="text">
+ <string>Ignore hidden files and folders</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="4" column="0">
+ <property name="name">
+ <cstring>m_chbFollowSymLinks</cstring>
+ </property>
+ <property name="text">
+ <string>Follow s&amp;ymbolic links</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="3" column="0">
+ <property name="name">
+ <cstring>m_chbHaltOnFirstOccurrence</cstring>
+ </property>
+ <property name="text">
+ <string>When searching, stop on first string found (faster but no details)</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>m_chbIgnoreFiles</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Do not show file if no strings are found or replaced</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout9</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_chbShowConfirmDialog</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Show confirmation dialog</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>m_chbConfirmStrings</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Confirm before replace each string</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ <widget class="QPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>m_pbHelp</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Help</string>
+ </property>
+ </widget>
+ <spacer row="1" column="1">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>202</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton" row="1" column="2">
+ <property name="name">
+ <cstring>m_pbDefault</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Default Values</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="3">
+ <property name="name">
+ <cstring>m_pbOK</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="4">
+ <property name="name">
+ <cstring>m_pbCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>m_pbCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>KOptionsDlgS</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>tabWidget2</tabstop>
+ <tabstop>m_cbEncoding</tabstop>
+ <tabstop>m_chbCaseSensitive</tabstop>
+ <tabstop>m_chbRecursive</tabstop>
+ <tabstop>m_chbRegularExpressions</tabstop>
+ <tabstop>m_chbVariables</tabstop>
+ <tabstop>m_chbNotifyOnErrors</tabstop>
+ <tabstop>m_chbBackup</tabstop>
+ <tabstop>m_leBackup</tabstop>
+ <tabstop>m_pbDefault</tabstop>
+ <tabstop>m_pbOK</tabstop>
+ <tabstop>m_pbCancel</tabstop>
+ <tabstop>m_pbHelp</tabstop>
+ <tabstop>m_chbConfirmStrings</tabstop>
+ <tabstop>m_chbShowConfirmDialog</tabstop>
+ <tabstop>m_chbIgnoreFiles</tabstop>
+ <tabstop>m_chbHaltOnFirstOccurrence</tabstop>
+ <tabstop>m_chbFollowSymLinks</tabstop>
+ <tabstop>m_chbIgnoreHidden</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kfilereplace/main.cpp b/kfilereplace/main.cpp
new file mode 100644
index 00000000..4ce9b742
--- /dev/null
+++ b/kfilereplace/main.cpp
@@ -0,0 +1,77 @@
+/***************************************************************************
+ main.cpp - Main file for the KFileReplace shell
+ -------------------
+ begin : Thu Sep 16 14:14:09 2004
+ copyright : (C) 2004 by Andras Mantia <amantia@kde.org>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "kfilereplace.h"
+
+#include <kapplication.h>
+#include <kaboutdata.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+
+static const char description[] =
+ I18N_NOOP("Batch search and replace tool");
+
+static const char version[] = "0.1";
+
+static KCmdLineOptions options[] =
+ {
+ { "+[PATH]", I18N_NOOP( "Starting folder" ), 0 },
+ KCmdLineLastOption
+ };
+
+int main(int argc, char *argv[])
+{
+ KAboutData about("kfilereplace", I18N_NOOP("KFileReplace"), version, description,
+ KAboutData::License_GPL_V2, "(C) 2004-2005 Andras Mantia\n(C) 2004-2005 Emiliano Gulmini\n(C) 1999-2002 Francois Dupoux", I18N_NOOP("Part of the KDEWebDev module."),
+ "http://www.kdewebdev.org");
+
+ about.addAuthor("Andras Mantia", I18N_NOOP("Shell author, KPart creator, co-maintainer"), "amantia@kde.org");
+ about.addAuthor("Emiliano Gulmini", I18N_NOOP("Current maintainer, code cleaner and rewriter"),"emi_barbarossa@yahoo.it");
+ about.addAuthor("Francois Dupou",
+ I18N_NOOP("Original author of the KFileReplace tool"),
+ "dupoux@dupoux.com");
+
+ KCmdLineArgs::init(argc, argv, &about);
+ KCmdLineArgs::addCmdLineOptions( options );
+
+ KApplication app;
+
+ // see if we are starting with session management
+ if (app.isRestored())
+ {
+ RESTORE(KFileReplace);
+ }
+ else
+ {
+ // no session.. just start up normally
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ KFileReplace *kfr = new KFileReplace;
+ kfr->show();
+
+ if (args->count() == 0)
+ {
+ kfr->openURL(KURL());
+ }
+ else
+ {
+ kfr->openURL(args->url(0));
+ }
+ args->clear();
+ }
+
+ return app.exec();
+}
diff --git a/kfilereplace/report.cpp b/kfilereplace/report.cpp
new file mode 100644
index 00000000..cae0dfe4
--- /dev/null
+++ b/kfilereplace/report.cpp
@@ -0,0 +1,282 @@
+/***************************************************************************
+ report.cpp - Report document class
+ -------------------
+ begin : fri aug 13 15:29:46 CEST 2004
+
+ copyright : (C) 2004 Emiliano Gulmini
+ email : emi_barbarossa@yahoo.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+// QT
+#include <qstring.h>
+#include <qfile.h>
+
+// KDE
+#include <klistview.h>
+#include <kmessagebox.h>
+#include <kuser.h>
+
+// local
+#include "report.h"
+#include "configurationclasses.h"
+
+void Report::createReportFile()
+{
+ QString xmlFileName = m_docPath + ".xml",
+ cssFileName = m_docPath + ".css";
+
+ // Generates a report file
+ // a) Open the file
+ QFile report(xmlFileName);
+ if (!report.open( IO_WriteOnly ))
+ {
+ KMessageBox::error(0, i18n("<qt>Cannot open the file <b>%1</b>.</qt>").arg(xmlFileName));
+ return ;
+ }
+
+ // b) Write the header of the XML file
+
+ QDateTime datetime = QDateTime::currentDateTime(Qt::LocalTime);
+ QString dateString = datetime.toString(Qt::LocalDate);
+ KUser user;
+ QString columnTextFour,
+ columnReplaceWith;
+ if(!m_isSearchFlag)
+ {
+ columnTextFour = i18n("Replaced Strings");
+ columnReplaceWith = i18n("Replace with");
+ }
+ else
+ {
+ columnTextFour = i18n("Total number occurrences");
+ columnReplaceWith = i18n("-");
+ }
+
+ QString css = cssFileName.mid(cssFileName.findRev("/")+1,cssFileName.length()-(cssFileName.findRev("/")+1));
+ QTextStream oTStream( &report );
+ oTStream << "<?xml version=\"1.0\"?>\n"
+ "<?xml-stylesheet href=\""+css+"\" type=\"text/css\"?>"
+ "<report>\n"
+ " <title> "+i18n("KFileReplace Report")+" </title>\n"
+ " <createdby>"+user.fullName()+"("+user.loginName()+")"+"</createdby>\n"
+ " <date>"+dateString+"</date>\n"
+ "<hr/>\n"
+ " <table>\n"
+ " <tablecaption> "+i18n("Searching/Replacing Strings Table")+" </tablecaption>\n"
+ " <header>\n"
+ " <row>\n"
+ " <searchfor class=\"header\">"+i18n("Search for")+"</searchfor>\n";
+
+ if(!m_isSearchFlag)
+ oTStream<< " <replacewith class=\"header\" >"+columnReplaceWith+"</replacewith>\n";
+
+ oTStream<< " </row>\n"
+ " </header>\n";
+ // c) Write the strings list
+ QListViewItem *lviCurItem,
+ *lviFirst;
+
+ lviCurItem = lviFirst = m_stringsView->firstChild();
+
+ if(lviCurItem == 0)
+ return ;
+
+ QString rowType="a1";
+
+ do
+ { QString rowTag = "<row >\n"
+ " <searchfor class=\""+rowType+"\"><![CDATA["+lviCurItem->text(0)+"]]></searchfor>\n"
+ " <replacewith class=\""+rowType+"\"><![CDATA["+lviCurItem->text(1)+"]]></replacewith>\n"
+ "</row>\n";
+
+ oTStream << rowTag;
+
+ rowType = ((rowType == "a1") ? "a2" : "a1");
+
+ lviCurItem = lviCurItem->nextSibling();
+ } while(lviCurItem && lviCurItem != lviFirst);
+
+ oTStream<< "</table>\n";
+
+ oTStream<< "<whiteline/>\n"
+ " <table>\n"
+ " <tablecaption> "+i18n("Results Table")+ " </tablecaption>"
+ " <header>\n"
+ " <row>\n"
+ " <name class=\"header\">"+i18n("Name")+"</name>\n"
+ " <folder class=\"header\">"+i18n("Folder")+"</folder>\n";
+ if(m_isSearchFlag)
+ {
+ oTStream<< " <oldsize class=\"header\">"+i18n("Size")+"</oldsize>\n";
+ }
+ else
+ {
+ oTStream<< " <oldsize class=\"header\">"+i18n("Old Size")+"</oldsize>\n"
+ " <newsize class=\"header\">"+i18n("New Size")+"</newsize>\n";
+ }
+ oTStream<< " <replacedstrings class=\"header\" >"+columnTextFour+"</replacedstrings>\n"
+ " <owneruser class=\"header\">"+i18n("Owner User")+"</owneruser>\n"
+ " <ownergroup class=\"header\">"+i18n("Owner Group")+"</ownergroup>\n"
+ " </row>\n"
+ " </header>\n";
+
+ // d) Write the result list
+
+ lviCurItem = lviFirst = m_resultsView->firstChild();
+
+ if(lviCurItem == 0)
+ return ;
+
+ unsigned int totalOccurrences = 0;
+
+ rowType="a1";
+
+ do
+ { QString rowTag = " <row >\n"
+ " <name class=\""+rowType+"\"><![CDATA["+lviCurItem->text(0)+"]]></name>\n"
+ " <folder class=\""+rowType+"\"><![CDATA["+lviCurItem->text(1)+"]]></folder>\n";
+ if(m_isSearchFlag)
+ {
+ rowTag += " <oldsize class=\""+rowType+"\"><![CDATA["+lviCurItem->text(2)+"]]></oldsize>\n"
+ " <replacedstrings class=\""+rowType+"\"><![CDATA["+lviCurItem->text(3)+"]]></replacedstrings>\n"
+ " <owneruser class=\""+rowType+"\"><![CDATA["+lviCurItem->text(4)+"]]></owneruser>\n"
+ " <ownergroup class=\""+rowType+"\"><![CDATA["+lviCurItem->text(5)+"]]></ownergroup>\n"
+ " </row>\n";
+ }
+ else
+ {
+ rowTag += " <oldsize class=\""+rowType+"\"><![CDATA["+lviCurItem->text(2)+"]]></oldsize>\n"
+ " <newsize class=\""+rowType+"\"><![CDATA["+lviCurItem->text(3)+"]]></newsize>\n"
+ " <replacedstrings class=\""+rowType+"\"><![CDATA["+lviCurItem->text(4)+"]]></replacedstrings>\n"
+ " <owneruser class=\""+rowType+"\"><![CDATA["+lviCurItem->text(5)+"]]></owneruser>\n"
+ " <ownergroup class=\""+rowType+"\"><![CDATA["+lviCurItem->text(6)+"]]></ownergroup>\n"
+ " </row>\n";
+ }
+
+ oTStream << rowTag;
+
+ rowType = ((rowType == "a1") ? "a2" : "a1");
+
+ if(m_isSearchFlag)
+ totalOccurrences += lviCurItem->text(3).toInt();
+ else
+ totalOccurrences += lviCurItem->text(4).toInt();
+
+ lviCurItem = lviCurItem->nextSibling();
+ } while(lviCurItem && lviCurItem != lviFirst);
+
+
+ // e) Write the end of the file
+
+ oTStream<< " </table>\n"
+ "<totaloccurrences>"
+ << totalOccurrences
+ << "</totaloccurrences>\n"
+ "</report>\n";
+
+ report.close();
+}
+
+void Report::createStyleSheet()
+{
+ QString cssFileName = m_docPath +".css";
+ QFile styleSheet(cssFileName);
+ if (!styleSheet.open( IO_WriteOnly ))
+ {
+ KMessageBox::error(0, i18n("<qt>Cannot open the file <b>%1</b>.</qt>").arg(cssFileName));
+ return ;
+ }
+
+ QTextStream oTStream( &styleSheet );
+
+ QString css = "title { display:block;font:40px bold sans-serif; }\n\n"
+ "createdby:before { content :\""+i18n("Created by")+": \"; }\n"
+ "createdby { display:inline; }\n\n"
+ "date:before { content :\"-"+i18n("date")+": \"; }\n"
+ "date { display:inline; }\n\n"
+ "totaloccurrences:before { content :\""+i18n("Total occurrences")+": \"; }\n"
+ "totaloccurrences { display:block;text-align:right; font-weight:bold;margin-top:5px;margin-right:5px;}\n"
+ "tablecaption {display:table-caption;font:20px bold sans-serif;}\n\n"
+ "hr {display:block;background:black;height:1px;margin:5px 0px 5px;}\n"
+ "whiteline {display:block;height:16px;}\n\n"
+ "searchfor {\n"
+ " display:table-cell;\n"
+ " border:1px solid black;\n"
+ " padding:0 7px 0; }\n\n";
+
+ if(!m_isSearchFlag)
+ {
+ css += "replacewith {\n"
+ " display:table-cell;\n"
+ " border:1px solid black;\n"
+ " padding:0 7px 0; }\n\n";
+ }
+
+ css += "folder {\n"
+ " display:table-cell;\n"
+ " border:1px solid black;\n"
+ " padding:0 7px 0; }\n\n"
+ "header { display: table-header-group; }\n\n"
+ "name {\n"
+ " display:table-cell;\n"
+ " border:1px solid black;\n"
+ " padding:0 7px 0; }\n\n"
+ "newsize {\n"
+ " display:table-cell;\n"
+ " border:1px solid black;\n"
+ " padding:0 7px 0;\n"
+ " text-align:right; }\n\n"
+ "oldsize {\n"
+ " display:table-cell;\n"
+ " border:1px solid black;\n"
+ " padding:0 7px 0;\n"
+ " text-align:right; }\n\n"
+ "ownergroup {\n"
+ " display:table-cell;\n"
+ " border:1px solid black;\n"
+ " padding:0 7px 0; }\n\n"
+ "owneruser {\n"
+ " display:table-cell;\n"
+ " border:1px solid black;\n"
+ " padding:0 7px 0; }\n\n"
+ "replacedstrings {\n"
+ " text-align:right;\n"
+ " display:table-cell;\n"
+ " border:1px solid black;\n"
+ " padding:0 7px 0; }\n\n"
+ "*[class~=header] {\n"
+ " background : lightgray;\n"
+ " text-align : center; }\n\n"
+ "row { display : table-row; }\n\n"
+ "table {\n"
+ " display:table;\n"
+ " border-collapse: collapse; }\n\n"
+ "*[class~=a1] {\n"
+ " background-color:aliceblue;\n"
+ " font-weight : bold;font-size:15px; }\n\n"
+ "*[class~=a2] {\n"
+ " background-color:khaki;\n"
+ " font-weight : bold;\n"
+ " font-size:15px; }\n\n";
+
+ oTStream << css;
+
+ styleSheet.close();
+}
+
+void Report::createDocument(const QString& docPath)
+{
+ m_docPath = docPath;
+
+ createStyleSheet();
+ createReportFile();
+}
+
diff --git a/kfilereplace/report.h b/kfilereplace/report.h
new file mode 100644
index 00000000..98996f92
--- /dev/null
+++ b/kfilereplace/report.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ report.h - Report document class
+ -------------------
+ begin : fri aug 13 15:29:46 CEST 2004
+
+ copyright : (C) 2004 Emiliano Gulmini
+ email : emi_barbarossa@yahoo.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef REPORT_H
+#define REPORT_H
+
+// QT
+class QString;
+
+// KDE
+#include <klocale.h>
+#include "configurationclasses.h"
+class KListView;
+
+/** Report class is used to create a pair of files (a xml and a css file) which are
+ * a short statistical report of the operations.
+ */
+
+class Report
+{
+ private:
+ KListView* m_stringsView,
+ * m_resultsView;
+ QString m_docPath;
+ bool m_isSearchFlag;
+ RCOptions* m_option;
+
+ public:
+ Report(RCOptions* info, KListView* rv, KListView* sv) { m_option = info;
+ m_resultsView = rv;
+ m_stringsView = sv;
+ m_isSearchFlag = m_option->m_searchingOnlyMode;
+ }
+ ~Report() { m_option = 0; }
+ private:
+ void createReportFile();
+ void createStyleSheet();
+
+ public:
+ void createDocument(const QString& docPath);
+};
+
+#endif // REPORT_H
diff --git a/kfilereplace/toolbar/Makefile.am b/kfilereplace/toolbar/Makefile.am
new file mode 100644
index 00000000..1b5627ad
--- /dev/null
+++ b/kfilereplace/toolbar/Makefile.am
@@ -0,0 +1,3 @@
+appdir = $(kde_datadir)/kfilereplacepart/icons
+app_ICON = AUTO
+
diff --git a/kfilereplace/toolbar/cr22-action-back.png b/kfilereplace/toolbar/cr22-action-back.png
new file mode 100644
index 00000000..3e8f12fe
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-back.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-backup_option.png b/kfilereplace/toolbar/cr22-action-backup_option.png
new file mode 100644
index 00000000..a0e1e02f
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-backup_option.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-casesensitive_option.png b/kfilereplace/toolbar/cr22-action-casesensitive_option.png
new file mode 100644
index 00000000..6302c0f2
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-casesensitive_option.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-command_option.png b/kfilereplace/toolbar/cr22-action-command_option.png
new file mode 100644
index 00000000..1da3688b
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-command_option.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-editadd.png b/kfilereplace/toolbar/cr22-action-editadd.png
new file mode 100644
index 00000000..5eb6f503
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-editadd.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-editremove.png b/kfilereplace/toolbar/cr22-action-editremove.png
new file mode 100644
index 00000000..50117f6d
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-editremove.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-filereplace.png b/kfilereplace/toolbar/cr22-action-filereplace.png
new file mode 100644
index 00000000..c3692e11
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-filereplace.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-filesearch.png b/kfilereplace/toolbar/cr22-action-filesearch.png
new file mode 100644
index 00000000..1be59c49
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-filesearch.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-filesimulate.png b/kfilereplace/toolbar/cr22-action-filesimulate.png
new file mode 100644
index 00000000..7cc5b284
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-filesimulate.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-informations.png b/kfilereplace/toolbar/cr22-action-informations.png
new file mode 100644
index 00000000..daeb5b80
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-informations.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-invert.png b/kfilereplace/toolbar/cr22-action-invert.png
new file mode 100644
index 00000000..f3ab8be6
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-invert.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-next.png b/kfilereplace/toolbar/cr22-action-next.png
new file mode 100644
index 00000000..cfab7cfb
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-next.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-projectopen.png b/kfilereplace/toolbar/cr22-action-projectopen.png
new file mode 100644
index 00000000..607e6aa8
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-projectopen.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-recursive_option.png b/kfilereplace/toolbar/cr22-action-recursive_option.png
new file mode 100644
index 00000000..bc98df90
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-recursive_option.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-regularexpression_option.png b/kfilereplace/toolbar/cr22-action-regularexpression_option.png
new file mode 100644
index 00000000..f74c7b56
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-regularexpression_option.png
Binary files differ
diff --git a/kfilereplace/toolbar/cr22-action-unsortedList.png b/kfilereplace/toolbar/cr22-action-unsortedList.png
new file mode 100644
index 00000000..bed281f1
--- /dev/null
+++ b/kfilereplace/toolbar/cr22-action-unsortedList.png
Binary files differ
diff --git a/kfilereplace/tutorial.kwd b/kfilereplace/tutorial.kwd
new file mode 100644
index 00000000..2183e53b
--- /dev/null
+++ b/kfilereplace/tutorial.kwd
Binary files differ
diff --git a/kfilereplace/whatthis.h b/kfilereplace/whatthis.h
new file mode 100644
index 00000000..c91356dd
--- /dev/null
+++ b/kfilereplace/whatthis.h
@@ -0,0 +1,101 @@
+/***************************************************************************
+ whatthis.h - description
+ -------------------
+ begin : fri 12 march CEST 2004
+ copyright : (C) 2004 Emiliano Gulmini
+ email : <emi_barbarossa@yahoo.it>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef WHATTHIS_H
+#define WHATTHIS_H
+
+// QT
+#include <qstring.h>
+
+// KDE
+#include <klocale.h>
+
+namespace whatthisNameSpace
+{
+ //KFileReplaceView messages
+ const QString lvResultWhatthis = i18n("Shows the statistics of your operations. Note that the columns content changes depending on what kind of operation you are performing.");
+
+ const QString lvStringsWhatthis = i18n("Shows a list of strings to search for (and if you specified it, a list of strings to replace with). Use the \"add strings\" dialog to edit your string list or double click on a string.");
+
+ //KNewProjectDlg messages
+ const QString cbLocationWhatthis = i18n("Base folder for operations of search/replace. Insert path string here by hand or use the search button.");
+
+ const QString cbFilterWhatthis = i18n("Shell-like wildcards. Example: \"*.html;*.txt;*.xml\".");
+
+ const QString edSizeMinWhatthis = i18n("Insert the minimum file size you want to search, or leave it unchecked if you don't want minimum size limit.");
+
+ const QString edSizeMaxWhatthis = i18n("Insert the maximum file size you want to search, or leave it unchecked if you don't want maximum size limit.");
+
+ const QString edDateMinWhatthis = i18n("Insert the minimum value for file access date that you want to search, or leave it unchecked if you don't a minimum limit.");
+
+ const QString edDateMaxWhatthis = i18n("Insert the maximum value for file access date that you want to search, or leave it unchecked if you don't a maximum limit.");
+
+ const QString cbDateValidWhatthis = i18n("Select \"writing\" if you want to use the date of the last modification, or \"reading\" to use the the date of the last access.");
+
+ const QString chbDateMinWhatthis = i18n("Minimum value for access date.");
+
+ const QString chbDateMaxWhatthis = i18n("Maximum value for access date.");
+
+ const QString leSearchWhatthis = i18n("Insert here the string to search for.");
+
+ const QString leReplaceWhatthis = i18n("Insert here the string to replace with.");
+
+ //KOptionsDlg messages
+ const QString chbCaseSensitiveWhatthis = i18n("Enable this option if your search is case sensitive.");
+
+ const QString chbRecursiveWhatthis = i18n("Enable this option to search in sub folders too.");
+
+ const QString chbHaltOnFirstOccurrenceWhatthis = i18n("Enable this option when you are searching for a string and you are only interested to know if the string is present or not in the current file.");
+
+ const QString chbIgnoreWhitespacesWhatthis ="";
+
+ const QString chbFollowSymLinksWhatthis = i18n("If kfilereplace encounters a symbolic link treats it like a normal folder or file.");
+
+ const QString chbIgnoreHiddenWhatthis = i18n("Enable this option to ignore hidden files or folders.");
+
+ const QString chbIgnoreFilesWhatthis = i18n("If this option is enabled, KFR will show even the names of the files in which no string has been found or replaced.");
+
+ const QString chbRegularExpressionsWhatthis = i18n("Allows you to apply QT-like regular expressions on the search string. Note that a complex regular expression could affect speed performance");
+
+ const QString chbVariablesWhatthis = i18n("Enable \"commands\". For example: if search string is \"user\" and replace string is the command \"[$user:uid$]\", KFR will substitute \"user\" with the uid of the user.");
+
+ const QString chbBackupWhatthis = i18n("Enable this option if you want leave original files untouched.");
+
+ const QString chbConfirmStringsWhatthis = i18n("Enable this option if you want to be asked for single string replacement confirmation.");
+
+ //KFileReplacePart
+ const QString fileSimulateWhatthis = i18n("Enable this option to perform replacing as a simulation, i.e. without make any changes in files.");
+
+ const QString optionsRegularExpressionsWhatthis = chbRegularExpressionsWhatthis;
+
+ const QString optionsBackupWhatthis = chbBackupWhatthis;
+
+ const QString optionsCaseWhatthis = chbCaseSensitiveWhatthis;
+
+ const QString optionsVarWhatthis = chbVariablesWhatthis;
+
+ const QString optionsRecursiveWhatthis = chbRecursiveWhatthis;
+
+ //KAddStringDlg
+ const QString rbSearchOnlyWhatthis = i18n("Select search-only mode.");
+
+ const QString rbSearchReplaceWhatthis = i18n("Select search-and-replace mode.");
+
+ const QString edSearchWhatthis = i18n("Insert here a string you want search for.");
+
+ const QString edReplaceWhatthis = i18n("Insert here the string that KFR will use to replace the search string.");
+}
+#endif