1//
2//
3// C++ Interface: kfilereplacepart
4//
5// Description:
6//
7//
8// Author: Andras Mantia <amantia@kde.org>, (C) 2003
9// Maintainer: Emiliano Gulmini <emi_barbarossa@yahoo.it>, (C) 2004
10//
11// Copyright: GPL v2. See COPYING file that comes with this distribution
12//
13//
14
15#ifndef KFILEREPLACEPART_H
16#define KFILEREPLACEPART_H
17
18// QT
19#include <QDir>
20
21// KDE
22#include <kparts/part.h>
23#include <k3listview.h>
24
25class KAboutApplicationDialog;
26class KAboutData;
27class KConfig;
28
29// local
30#include "configurationclasses.h"
31class KFileReplaceView;
32
33#define KFR_VERSION "0.8.1"
34
35class KFileReplacePart: public KParts::ReadOnlyPart
36{
37 Q_OBJECT
38
39 private: //MEMBERS
40 KFileReplaceView* m_view;
41 QWidget* m_parentWidget,
42 * m_w;
43 KConfig* m_config;
44 KAboutApplicationDialog* m_aboutDlg;
45 KeyValueMap m_replacementMap;
46 RCOptions* m_option;
47 bool m_stop,
48 m_searchingOperation;
49 QFlags<QDir::Filter> m_optionMask;
50
51 public://Constructors
52 KFileReplacePart(QWidget *parentWidget,
53 QObject *parent,
54 const QStringList &args);
55 ~KFileReplacePart();
56
57 //SLOTS
58 private slots:
59 void slotSetNewParameters();
60 void slotSearchingOperation();
61 void slotReplacingOperation();
62 void slotSimulatingOperation();
63 void slotStop();
64 void slotCreateReport();
65 void slotStringsAdd();
66 void slotQuickStringsAdd();
67 void slotStringsDeleteItem();
68 void slotStringsEmpty();
69 void slotStringsEdit();
70 void slotStringsSave();
71 void slotStringsLoad();
72 void slotStringsInvertCur();
73 void slotStringsInvertAll();
74 void slotOpenRecentStringFile(const KUrl& urlFile);
75 void slotOptionRecursive();
76 void slotOptionBackup();
77 void slotOptionCaseSensitive();
78 void slotOptionVariables();
79 void slotOptionRegularExpressions();
80 void slotOptionPreferences();
81 void showAboutApplication(void);
82 void appHelpActivated();
83 void reportBug();
84 void resetActions();
85 void slotSearchMode(bool b){ m_option->m_searchingOnlyMode = b; }
86
87 //METHODS
88 public:
89 static KAboutData* createAboutData();
90 KConfig *config(){ return m_config; }
91 virtual bool openURL (const KUrl &url);
92
93 protected:
94 virtual bool openFile() { return false; }
95
96 private:
97 /**
98 * Initialization methods
99 */
100 void initGUI();
101 void initView();
102
103 /**
104 * This method freezes the GUI of kfilereplace during searching
105 */
106 void freezeActions();
107
108 /**
109 * These methods load the resources from kfilereplacerc
110 */
111 void loadOptionsFromRC();
112 void loadOptions();
113 void loadFileSizeOptions();
114 void loadDateAccessOptions();
115 void loadOwnerOptions();
116 void loadLocationsList();
117 void loadFiltersList();
118 void loadBackupExtensionOptions();
119
120 /**
121 * These methods save the resources to kfilereplacerc
122 */
123 void saveOptionsToRC();
124 void saveOptions();
125 void saveFileSizeOptions();
126 void saveDateAccessOptions();
127 void saveOwnerOptions();
128 void saveLocationsList();
129 void saveFiltersList();
130 void saveBackupExtensionOptions();
131
132 /**
133 * Replacing methods
134 */
135 void fileReplace();
136 void recursiveFileReplace(const QString& dirName, int& filesNumber);
137 void replaceAndBackup(const QString& currentDir, const QString& oldFileName);
138 void replaceAndOverwrite(const QString& currentDir, const QString& oldFileName);
139 void replacingLoop(QString& line, K3ListViewItem** item, bool& atLeastOneStringFound, int& occur, bool regularExpression, bool& askConfirmReplace);
140
141 /**
142 * Searching methods
143 */
144 void fileSearch(const QString& dirName, const QString& filters);
145 void recursiveFileSearch(const QString& dirName, const QString& filters, uint& filesNumber);
146 void search(const QString& currentDir, const QString& fileName);
147
148 /**
149 * Others methods
150 */
151 void loadViewContent();
152 void loadRulesFile(const QString& fileName);
153 bool launchNewProjectDialog(const KUrl& startURL);
154 void setOptionMask();
155 bool checkBeforeOperation();
156 bool dontAskAgain();
157 void whatsThis();
158};
159
160#endif// KFileReplacePart
161