summaryrefslogtreecommitdiffstats
path: root/tdefilereplace/configurationclasses.h
blob: 206de1c4ca83fb92fa5628b0e71a395e636d548d (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
/***************************************************************************
                          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 <tqstring.h>
#include <tqstringlist.h>
#include <tqdatetime.h>
#include <tqmap.h>
#include <tqregexp.h>

typedef TQMap<TQString,TQString> KeyValueMap;
// entry strings in the tdefilereplacerc file
const TQString rcDirectoriesList = "Directories list";
const TQString rcFiltersList = "Filters list";
const TQString rcRecentFiles = "Recent files";
const TQString rcAllStringsMustBeFound = "All strings must be found";
const TQString rcEncoding = "Encoding";
const TQString rcCaseSensitive = "Case sensitive";
const TQString rcConfirmStrings = "Confirm strings";
const TQString rcConfirmFiles = "Confirm files";
const TQString rcConfirmDirs = "Confirm directories";
const TQString rcFollowSymLinks = "Follow symbolic links";
const TQString rcHaltOnFirstOccur = "Halt on first occurrence";
const TQString rcIgnoreHidden = "Ignore hidden files";
const TQString rcRecursive = "Search/replace in sub folders";
const TQString rcVariables = "Enable variables";
const TQString rcRegularExpressions = "Enable regular expressions";
const TQString rcMinFileSize = "Minimum file size";
const TQString rcMaxFileSize = "Maximum file size";
const TQString rcValidAccessDate = "Access mode";
const TQString rcMinDate = "Minimum access date";
const TQString rcMaxDate = "Maximum access date";
const TQString rcOwnerUser = "Owner user filters";
const TQString rcOwnerGroup = "Owner group filters";
const TQString rcSearchMode = "Search only mode";
const TQString rcBackupExtension = "Backup file extension";
const TQString rcIgnoreFiles = "Ignore files if there is no match";
const TQString rcNotifyOnErrors = "NotifyOnErrors";
const TQString rcAskConfirmReplace = "Ask confirmation on replace";
const TQString rcDontAskAgain = "Dont ask again";
// Default configuration options
const TQString 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 TQString AccessDateOption="unknown";
const TQString ValidAccessDateOption="unknown";
const TQString OwnerOption="false,Name,Equals To";
const bool SearchModeOption=true;
const TQString 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;

    TQStringList m_directories;
    TQStringList m_filters;
    TQString m_currentDirectory;

    int m_minSize,
        m_maxSize;

    TQString m_dateAccess,
            m_minDate,
            m_maxDate;
            
    TQString 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;

    TQString m_ownerUserType,
            m_ownerGroupType,
            m_ownerUserValue,
            m_ownerGroupValue,
            m_ownerUserBool,
            m_ownerGroupBool;

    TQString m_backupExtension;

    bool m_ignoreFiles;

    KeyValueMap m_mapStringsView;

    TQString m_quickSearchString,
            m_quickReplaceString;

    TQStringList m_recentStringFileList;

    bool m_notifyOnErrors;

  public:
    RCOptions();
    RCOptions& operator=(const RCOptions& ci);
};

class ResultViewEntry
{
  private:
    TQString m_key;
    TQString m_data;
    TQRegExp m_rxKey;
    bool m_regexp;
    bool m_caseSensitive;
    int m_pos;
    int m_matchedStringsOccurrence;

  public:
    ResultViewEntry(TQString nkey, TQString ndata, bool regexp, bool caseSensitive);
    int lineNumber(const TQString& line) const ;
    int columnNumber(const TQString& line) const ;
    void incOccurrences();
    int occurrences() const ;
    bool regexp()const ;
    int pos(const TQString& line) ;
    void incPos();
    TQString capturedText(const TQString& line)  ;
    TQString message(const TQString& capturedText, int x, int y) const;
    int keyLength() const;
    int dataLength() const;
    void updateLine(TQString& line);
};
#endif