00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#ifndef INC_DLGADDMATCHFILES_HPP
00026
#define INC_DLGADDMATCHFILES_HPP
00027
00028
00029
00030
#include <wx/wxprec.h>
00031
00032
#ifdef __BORLANDC__
00033
#pragma hdrstop
00034
#endif
00035
00036
#ifndef WX_PRECOMP
00037
00038
#include <wx/wx.h>
00039
#endif
00040
00041
#include <wx/spinctrl.h>
00042
00043
#include "fdftlmk.hpp"
00044
#include "slstview.hpp"
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 class dlgAddMatchFiles :
public wxDialog
00055 {
00056
public:
00057
00058
class MatchPattern;
00059
00060
00061
class ArrayMatchPattern;
00062
00063
public:
00064
00065
dlgAddMatchFiles();
00066
00067
00068
dlgAddMatchFiles(wxWindow* parent,
const wxString&
checksumsFileName = wxEmptyString);
00069
00070
00071
virtual ~dlgAddMatchFiles();
00072
00073
00074
void createControls();
00075
00076
protected:
00077
00078
void setDialogTitle();
00079
00080
protected:
00081
static long idGen;
00082 wxSortableListView*
lvwPatterns;
00083 ArrayMatchPattern*
matchPatterns;
00084 wxButton*
btnRemove;
00085 wxRadioBox*
rbxSortBy;
00086 wxRadioBox*
rbxSortOrder;
00087 wxButton*
btnAddPattern;
00088 wxComboBox*
cboPattern;
00089 wxComboBox*
cboDirectory;
00090 wxSpinCtrl*
spnDepth;
00091 wxString
checksumsFileName;
00092
00093
00094
static long getID();
00095
00096
00097
void btnRemoveClick(wxCommandEvent& event);
00098
00099
void btnAddListClick(wxCommandEvent& event);
00100
00101
void btnLoadListClick(wxCommandEvent& event);
00102
00103
void btnSaveListClick(wxCommandEvent& event);
00104
00105
void btnBrowseClick(wxCommandEvent& event);
00106
00107
void btnAddPatternClick(wxCommandEvent& event);
00108
00109
00110
void lvwPatternsSelectItem(wxListEvent& event);
00111
00112
void lvwPatternsDeselectItem(wxListEvent& event);
00113
00114
void lvwPatternsKeyDown(wxListEvent& event);
00115
00116
void lvwPatternsColumnClick(wxListEvent& event);
00117
00118
00119
void rbxSortBySelect(wxCommandEvent& event);
00120
00121
void rbxSortOrderSelect(wxCommandEvent& event);
00122
00123
00124
void cboAddTextEnter(wxCommandEvent& event);
00125
00126
00127
void btnAddClick(wxCommandEvent& event);
00128
00129
00130
enum
00131 {
00132 LVW_FILES = wxID_HIGHEST + 1,
00133 BTN_REMOVE,
00134 BTN_ADDLIST,
00135 BTN_LOADLIST,
00136 BTN_SAVELIST,
00137 CBO_PATTERN,
00138 CBO_DIRECTORY,
00139 BTN_BROWSE,
00140 BTN_ADD_PATTERN,
00141 SPN_DEPTH,
00142 RBX_SORT_BY,
00143 RBX_SORT_ORDER,
00144 BTN_ADD
00145 };
00146
00147
00148
void addPatternToListView(
const MatchPattern& pattern);
00149
00150
00151
class PatternsListValidator;
00152
00153
friend class PatternsListValidator;
00154
00155 DECLARE_EVENT_TABLE()
00156
00157 private:
00158 DECLARE_DYNAMIC_CLASS(
dlgAddMatchFiles)
00159
00160 public:
00161
00162
void getMatchPatterns(ArrayMatchPattern& patterns) const;
00163
00164
00165 wxString getChecksumsFileName() const;
00166
00167
00168
void setChecksumsFileName(const wxString& fileName);
00169
00170 public:
00171
00172 static wxString getRootConfigKey();
00173
00174
00175 static wxString getMatchPatternConfigKey(const
int n);
00176
00177
00178 static wxString getDirectoryConfigKey(const
int n);
00179
00180
00181 static
int getHistoryMaxSize();
00182
00183 protected:
00184
00185 enum PreferencesKey
00186 {
00187 prGUI_ADD_MATCH_FILES_SORT_BY = 0,
00188 prGUI_ADD_MATCH_FILES_SORT_ORDER,
00189 prGUI_ADD_MATCH_FILES_DIRECTORY_WIDTH,
00190 prGUI_ADD_MATCH_FILES_PATTERN_WIDTH,
00191 prGUI_ADD_MATCH_FILES_DEPTH_WIDTH,
00192 prGUI_ADD_MATCH_FILES_WINDOW_SIZE
00193 };
00194
00195
00196
static wxString getConfigKey(
const PreferencesKey pk);
00197
00198
private:
00199
00200
static void addLineToComboBox(wxComboBox* cboBox,
const int maxLines);
00201
00202
00203
static void getLastDirectoryAndFilter(
const wxString& configKey, wxString& lastDirKey, wxString& lastDir,
wxFileDialogFilterMaker& fltMaker);
00204
00205
00206
static void readMatchPatternsFile(
const wxString& fileName, ArrayMatchPattern& patterns);
00207 };
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 class dlgAddMatchFiles::MatchPattern
00220 {
00221
protected:
00222 wxString
directory;
00223 wxString
pattern;
00224 int depth;
00225
00226
00227
void clone(
const MatchPattern& source);
00228
00229
public:
00230
00231 MatchPattern() :
depth(0) {}
00232
00233
00234
MatchPattern(
const wxString& dir,
const wxString& pat,
const int dep);
00235
00236
00237
00238
00239
00240
00241 MatchPattern(
const MatchPattern& source)
00242 {
00243 clone(source);
00244 }
00245
00246
00247
MatchPattern& operator=(
const MatchPattern& source);
00248
00249
00250
00251
00252
00253
00254
00255 wxString
getDirectory()
const
00256
{
00257
return directory;
00258 }
00259
00260
00261
00262
00263
00264
00265 void setDirectory(
const wxString& newDir)
00266 {
00267
directory = newDir;
00268 }
00269
00270
00271
00272
00273
00274
00275 wxString
getPattern()
const
00276
{
00277
return pattern;
00278 }
00279
00280
00281
00282
00283
00284
00285 void setPattern(
const wxString& newPattern)
00286 {
00287
pattern = newPattern;
00288 }
00289
00290
00291
00292
00293
00294
00295 int getDepth()
const
00296
{
00297
return depth;
00298 }
00299
00300
00301
00302
00303
00304
00305 void setDepth(
const int newDepth)
00306 {
00307
depth = newDepth;
00308 }
00309
00310
00311
00312 wxArrayString
getPatterns() const;
00313
00314
00315
void addPatterns(const wxString& patterns);
00316
00317
00318
void removePatterns(const wxString& patterns);
00319
00320
00321
bool isIncludingAllPatterns(const wxString& patterns) const;
00322
00323
00324
int compareDepth(const
MatchPattern& cmp) const;
00325
00326
00327
bool operator==(const
MatchPattern& cmp) const;
00328 };
00329
00330
00331
00332
00333
00334
00335 class
dlgAddMatchFiles::
ArrayMatchPattern
00336 {
00337
protected:
00338 typedef MatchPattern*
pMatchPattern;
00339
static const size_t ALLOC_NEW;
00340 size_t allocated;
00341 size_t used;
00342 pMatchPattern* patterns;
00343
00344
00345
void clone(
const ArrayMatchPattern& source);
00346
00347
public:
00348
00349 ArrayMatchPattern();
00350
00351
00352 ArrayMatchPattern(size_t count);
00353
00354
00355 ArrayMatchPattern(
const ArrayMatchPattern& source);
00356
00357
00358 ArrayMatchPattern& operator=(
const ArrayMatchPattern& source);
00359
00360
00361 ~ArrayMatchPattern();
00362
00363
00364
void add(
MatchPattern pattern);
00365
00366
00367
void alloc(size_t count);
00368
00369
00370
void clear();
00371
00372
00373 size_t getCount() const;
00374
00375
00376
MatchPattern& item(size_t index) const;
00377
00378
00379
MatchPattern& operator[](size_t index) const;
00380 };
00381
00382
00383
00384 #endif