1 | /*************************************************************************** |
2 | configurationclasses.h - description |
3 | ------------------- |
4 | begin : Sat Apr 17 2004 |
5 | copyright : (C) 2004 Emiliano Gulmini |
6 | email : <emi_barbarossa@yahoo.it> |
7 | ***************************************************************************/ |
8 | |
9 | /*************************************************************************** |
10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * |
15 | * * |
16 | ***************************************************************************/ |
17 | #ifndef CONFIGURATIONCLASSES_H |
18 | #define CONFIGURATIONCLASSES_H |
19 | |
20 | // QT |
21 | #include <qstring.h> |
22 | #include <qstringlist.h> |
23 | #include <qdatetime.h> |
24 | #include <qmap.h> |
25 | #include <qregexp.h> |
26 | |
27 | typedef QMap<QString,QString> KeyValueMap; |
28 | // entry strings in the kfilereplacerc file |
29 | const QString rcDirectoriesList = "Directories list" ; |
30 | const QString rcFiltersList = "Filters list" ; |
31 | const QString rcRecentFiles = "Recent files" ; |
32 | const QString rcAllStringsMustBeFound = "All strings must be found" ; |
33 | const char rcEncoding[] = "Encoding" ; |
34 | const QString rcCaseSensitive = "Case sensitive" ; |
35 | const QString rcConfirmStrings = "Confirm strings" ; |
36 | const QString rcConfirmFiles = "Confirm files" ; |
37 | const QString rcConfirmDirs = "Confirm directories" ; |
38 | const QString rcFollowSymLinks = "Follow symbolic links" ; |
39 | const QString rcHaltOnFirstOccur = "Halt on first occurrence" ; |
40 | const QString rcIgnoreHidden = "Ignore hidden files" ; |
41 | const QString rcRecursive = "Search/replace in sub folders" ; |
42 | const QString rcVariables = "Enable variables" ; |
43 | const QString rcRegularExpressions = "Enable regular expressions" ; |
44 | const QString rcMinFileSize = "Minimum file size" ; |
45 | const QString rcMaxFileSize = "Maximum file size" ; |
46 | const QString rcValidAccessDate = "Access mode" ; |
47 | const QString rcMinDate = "Minimum access date" ; |
48 | const QString rcMaxDate = "Maximum access date" ; |
49 | const QString rcOwnerUser = "Owner user filters" ; |
50 | const QString rcOwnerGroup = "Owner group filters" ; |
51 | const QString rcSearchMode = "Search only mode" ; |
52 | const QString rcBackupExtension = "Backup file extension" ; |
53 | const QString rcIgnoreFiles = "Ignore files if there is no match" ; |
54 | const QString rcNotifyOnErrors = "NotifyOnErrors" ; |
55 | const QString rcAskConfirmReplace = "Ask confirmation on replace" ; |
56 | const QString rcDontAskAgain = "Don't ask again" ; |
57 | // Default configuration options |
58 | const QString EncodingOption = "utf8" ; |
59 | const bool RecursiveOption = true; |
60 | const bool CaseSensitiveOption = false; |
61 | const bool FollowSymbolicLinksOption = false; |
62 | const bool RegularExpressionsOption = false; |
63 | const bool VariablesOption = false; |
64 | const bool StopWhenFirstOccurenceOption = false; |
65 | const bool IgnoreHiddenOption = false; |
66 | const int FileSizeOption = -1; |
67 | const QString AccessDateOption="unknown" ; |
68 | const QString ValidAccessDateOption="unknown" ; |
69 | const QString OwnerOption="false,Name,Equals To" ; |
70 | const bool SearchModeOption=true; |
71 | const QString BackupExtensionOption="false,~" ; |
72 | const bool IgnoreFilesOption = true; |
73 | const bool NotifyOnErrorsOption = false; |
74 | const bool AskConfirmReplaceOption = false; |
75 | |
76 | // This class stores configuration information |
77 | class RCOptions |
78 | { |
79 | public: |
80 | bool m_callResetActions; |
81 | |
82 | bool m_askConfirmReplace, |
83 | m_dontAskAgain; |
84 | |
85 | QString m_directories, |
86 | m_filters, |
87 | m_currentDirectory; |
88 | |
89 | int m_minSize, |
90 | m_maxSize; |
91 | |
92 | QString m_dateAccess, |
93 | m_minDate, |
94 | m_maxDate; |
95 | |
96 | QString m_encoding; |
97 | |
98 | bool m_caseSensitive, |
99 | m_recursive, |
100 | m_followSymLinks, |
101 | m_allStringsMustBeFound, |
102 | m_backup, |
103 | m_regularExpressions; |
104 | |
105 | bool m_variables, |
106 | m_haltOnFirstOccur, |
107 | m_ignoreHidden, |
108 | m_simulation, |
109 | m_searchingOnlyMode; |
110 | |
111 | bool m_ownerUserIsChecked, |
112 | m_ownerGroupIsChecked; |
113 | |
114 | QString m_ownerUserType, |
115 | m_ownerGroupType, |
116 | m_ownerUserValue, |
117 | m_ownerGroupValue, |
118 | m_ownerUserBool, |
119 | m_ownerGroupBool; |
120 | |
121 | QString m_backupExtension; |
122 | |
123 | bool m_ignoreFiles; |
124 | |
125 | KeyValueMap m_mapStringsView; |
126 | |
127 | QString m_quickSearchString, |
128 | m_quickReplaceString; |
129 | |
130 | QStringList m_recentStringFileList; |
131 | |
132 | bool m_notifyOnErrors; |
133 | |
134 | public: |
135 | RCOptions(); |
136 | RCOptions& operator=(const RCOptions& ci); |
137 | }; |
138 | |
139 | class ResultViewEntry |
140 | { |
141 | private: |
142 | QString m_key; |
143 | QString m_data; |
144 | QRegExp m_rxKey; |
145 | bool m_regexp; |
146 | bool m_caseSensitive; |
147 | int m_pos; |
148 | int m_matchedStringsOccurrence; |
149 | |
150 | public: |
151 | ResultViewEntry(const QString &nkey, const QString &ndata, bool regexp, bool caseSensitive); |
152 | int lineNumber(const QString& line) const ; |
153 | int columnNumber(const QString& line) const ; |
154 | void incOccurrences(); |
155 | int occurrences() const ; |
156 | bool regexp()const ; |
157 | int pos(const QString& line) ; |
158 | void incPos(); |
159 | QString capturedText(const QString& line) ; |
160 | QString message(const QString& capturedText, int x, int y) const; |
161 | int keyLength() const; |
162 | int dataLength() const; |
163 | void updateLine(QString& line); |
164 | }; |
165 | #endif |
166 | |