summaryrefslogtreecommitdiffstats
path: root/tdefilereplace/configurationclasses.cpp
blob: f0c6bcc4d982db043e02b817fedfd916993e7830 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/***************************************************************************
                          configurationclasses.cpp  -  description
                             -------------------
    begin                : Sat Sep 11 2004
    copyright            : (C) 2004 Emiliano Gulmini
    email                : [email protected]
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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(TQString nkey, TQString ndata, bool regexp, bool caseSensitive)
{
  m_caseSensitive = caseSensitive;
  m_regexp = regexp;

  if(regexp)
    {
      m_rxKey = TQRegExp("("+nkey+")", caseSensitive, false);
    }
  else
    {
      m_key = nkey;
    }
  m_data = ndata;
  m_matchedStringsOccurrence = 0;
  m_pos = 0;
}

int ResultViewEntry::lineNumber(const TQString& line) const
{
  return line.mid(0,m_pos).contains('\n')+1;
}

int ResultViewEntry::columnNumber(const TQString& 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 TQString& 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;

}

TQString ResultViewEntry::capturedText(const TQString& line)
{
  TQString cap;

  if(m_regexp)
    cap = m_rxKey.cap(1);
  else
    cap =line.mid(m_pos,m_key.length());

  return cap;
}

TQString ResultViewEntry::message(const TQString& capturedText, int x, int y) const
{
  TQString data = m_data;
  //return i18n(" captured text \"%1\" replaced with \"%2\" at line: %3, column: %4 ").arg(capturedText).arg(data).arg(TQString::number(x,10)).arg(TQString::number(y,10));
  return i18n(" Line:%3,Col:%4 - \"%1\" -> \"%2\"").arg(capturedText).arg(data).arg(TQString::number(x,10)).arg(TQString::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(TQString& line)
{
  line.insert(m_pos, m_data);
  line.remove(m_pos + dataLength(), keyLength());
}