1/***************************************************************************
2 configurationclasses.cpp - description
3 -------------------
4 begin : Sat Sep 11 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// QT
18
19// KDE
20
21// local
22#include "configurationclasses.h"
23#include "whatthis.h"
24
25using namespace whatthisNameSpace;
26
27//RCOptions Class
28RCOptions::RCOptions()
29{
30 m_searchingOnlyMode = false;
31}
32
33RCOptions& RCOptions::operator=(const RCOptions& ci)
34{
35 //m_callResetActions = ci.m_callResetActions;
36
37 m_directories = ci.m_directories;
38 m_filters = ci.m_filters;
39 m_currentDirectory = ci.m_currentDirectory;
40 m_minSize = ci.m_minSize;
41 m_maxSize = ci.m_maxSize;
42
43 m_dateAccess = ci.m_dateAccess;
44 m_minDate = ci.m_minDate;
45 m_maxDate = ci.m_maxDate;
46
47 m_caseSensitive = ci.m_caseSensitive;
48 m_recursive = ci.m_recursive;
49 m_followSymLinks = ci.m_followSymLinks;
50 m_allStringsMustBeFound = ci.m_allStringsMustBeFound;
51 m_backup = ci.m_backup;
52 m_backupExtension = ci.m_backupExtension;
53 m_ignoreFiles = ci.m_ignoreFiles;
54 m_regularExpressions = ci.m_regularExpressions;
55
56 m_variables = ci.m_variables;
57 m_haltOnFirstOccur = ci.m_haltOnFirstOccur;
58 m_ignoreHidden = ci.m_ignoreHidden;
59 m_simulation = ci.m_simulation;
60 m_searchingOnlyMode = ci.m_searchingOnlyMode;
61
62 m_ownerUserIsChecked = ci.m_ownerUserIsChecked;
63 m_ownerGroupIsChecked = ci.m_ownerGroupIsChecked;
64
65 m_ownerUserBool = ci.m_ownerUserBool;
66 m_ownerGroupBool = ci.m_ownerGroupBool;
67
68 m_ownerUserType = ci.m_ownerUserType;
69 m_ownerGroupType = ci.m_ownerGroupType;
70
71 m_ownerUserValue = ci.m_ownerUserValue;
72 m_ownerGroupValue = ci.m_ownerGroupValue;
73
74 m_mapStringsView = ci.m_mapStringsView;
75
76 m_quickSearchString = ci.m_quickSearchString;
77 m_quickReplaceString = ci.m_quickReplaceString;
78
79 m_recentStringFileList = ci.m_recentStringFileList;
80
81 m_notifyOnErrors = ci.m_notifyOnErrors;
82
83 return (*this);
84}
85
86//ResultViewEntry Class
87ResultViewEntry::ResultViewEntry(const QString &nkey, const QString &ndata, bool regexp, bool caseSensitive)
88{
89 m_caseSensitive = caseSensitive;
90 m_regexp = regexp;
91
92 if(regexp)
93 {
94 m_rxKey = QRegExp('('+nkey+')', caseSensitive, false);
95 }
96 else
97 {
98 m_key = nkey;
99 }
100 m_data = ndata;
101 m_matchedStringsOccurrence = 0;
102 m_pos = 0;
103}
104
105int ResultViewEntry::lineNumber(const QString& line) const
106{
107 return line.mid(0,m_pos).count('\n')+1;
108}
109
110int ResultViewEntry::columnNumber(const QString& line) const
111{
112 return(m_pos - line.lastIndexOf('\n',m_pos));
113}
114
115void ResultViewEntry::incOccurrences()
116{
117 m_matchedStringsOccurrence++;
118}
119
120int ResultViewEntry::occurrences() const
121{
122 return m_matchedStringsOccurrence;
123}
124
125bool ResultViewEntry::regexp()const
126{
127 return m_regexp;
128}
129
130int ResultViewEntry::pos(const QString& line)
131{
132 if(m_regexp)
133 m_pos = m_rxKey.search(line,m_pos);
134 else
135 m_pos = line.find(m_key, m_pos, m_caseSensitive);
136
137 return m_pos;
138}
139
140void ResultViewEntry::incPos()
141{
142 int kl = keyLength(),
143 dl = dataLength();
144
145 if(kl < dl)
146 m_pos += kl;
147 else
148 m_pos += dl;
149
150}
151
152QString ResultViewEntry::capturedText(const QString& line)
153{
154 QString cap;
155
156 if(m_regexp)
157 cap = m_rxKey.cap(1);
158 else
159 cap =line.mid(m_pos,m_key.length());
160
161 return cap;
162}
163
164QString ResultViewEntry::message(const QString& capturedText, int x, int y) const
165{
166 QString data = m_data;
167 //return i18n(" captured text \"%1\" replaced with \"%2\" at line: %3, column: %4 ", capturedText, data, x, y);
168 return i18n(" Line:%3,Col:%4 - \"%1\" -> \"%2\"", capturedText, data, x, y);
169}
170
171int ResultViewEntry::keyLength() const
172{
173 if(m_regexp)
174 return m_rxKey.matchedLength();
175 else
176 return m_key.length();
177}
178
179int ResultViewEntry::dataLength() const
180{
181 return m_data.length();
182}
183
184void ResultViewEntry::updateLine(QString& line)
185{
186 line.insert(m_pos, m_data);
187 line.remove(m_pos + dataLength(), keyLength());
188}
189