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
00026
00027
00028
#include <wx/wxprec.h>
00029
00030
#ifdef __BORLANDC__
00031
#pragma hdrstop
00032
#endif
00033
00034
#ifndef WX_PRECOMP
00035
00036
#include <wx/wx.h>
00037
#endif
00038
00039
#include <wx/config.h>
00040
#include <wx/valgen.h>
00041
00042
#include "dlgBatchCreateConf.hpp"
00043
#include "appprefs.hpp"
00044
#include "checksumfactory.hpp"
00045
#include "comdefs.hpp"
00046
#include "fdftlmk.hpp"
00047
00048
#include "compat.hpp"
00049
00050
00051
00052
00053
using namespace std;
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 class dlgBatchCreationConfOptions :
public wxDialog
00064 {
00065
public:
00066
00067 dlgBatchCreationConfOptions() : wxDialog() {
createControls(); }
00068
00069
00070
dlgBatchCreationConfOptions(wxWindow* parent,
const dlgBatchCreation::Options& options);
00071
00072
00073
virtual ~dlgBatchCreationConfOptions();
00074
00075
protected:
00076
00077
void createControls();
00078
00079 int verbosity;
00080
00081
00082
00083
00084 bool ovrCkFileWhenItExists;
00085
00086
00087
00088
00089
00090
00091
00092 bool replaceExtension;
00093
00094
public:
00095
00096
dlgBatchCreation::Options getOptions() const;
00097
00098 private:
00099 DECLARE_DYNAMIC_CLASS(
dlgBatchCreationConfOptions)
00100 };
00101
00102
00103 IMPLEMENT_DYNAMIC_CLASS(dlgBatchCreationConfOptions, wxDialog)
00104
00105
00106
00107
00108
00109
00110
00111
00112 dlgBatchCreationConfOptions::dlgBatchCreationConfOptions(wxWindow* parent,
00113 const
dlgBatchCreation::Options& options) :
00114 wxDialog(parent, -1, wxString(_("Options of the batch creation of checksums' files")))
00115 {
00116
00117
ovrCkFileWhenItExists = options.ovrCkFileWhenItExists;
00118
replaceExtension = options.replaceExtension;
00119
verbosity = options.getVerbosity();
00120
00121
00122
createControls();
00123
00124
00125 Fit();
00126 Centre();
00127 }
00128
00129
00130
00131
00132
00133
00134 void dlgBatchCreationConfOptions::createControls()
00135 {
00136
00137 wxStaticBox* fraBCCkFileExists =
new wxStaticBox(
this, -1, _(
"When a checksums' file alrealdy exists:"));
00138 wxRadioButton* rbxBCSkipExistingCkFile =
new wxRadioButton(
this, -1, _(
"S&kip the creation"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
00139 wxRadioButton* rbxBCOverwriteExistingCkFile =
new wxRadioButton(
this, -1, _(
"&Overwrite it"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&
ovrCkFileWhenItExists));
00140
00141
00142 wxStaticBox* fraBCChecksumsFileName =
new wxStaticBox(
this, -1, _(
"Create the name of the checksums' file by:"));
00143 wxRadioButton* rbxBCReplaceFileExtension =
new wxRadioButton(
this, -1, _(
"&Replacing the extension of the source file with the extension of the type of the checksums' file."), wxDefaultPosition, wxDefaultSize, wxRB_GROUP, wxGenericValidator(&
replaceExtension));
00144 wxRadioButton* rbxBCAddFileExtension =
new wxRadioButton(
this, -1, _(
"&Adding the extension of the type of the checksums' file to the name of the source file."), wxDefaultPosition, wxDefaultSize);
00145
00146
00147 wxStaticBox* fraBCVerbosityLevel =
new wxStaticBox(
this, -1, _(
"Level of &verbosity of the report:"));
00148
const wxString strVerbosityLevels[] = { _(
"Errors only"), _(
"Errors and warnings"), _(
"Normal"), _(
"Talkative") };
00149 wxChoice* cboBCVerbosityLevel =
new wxChoice(
this, -1, wxDefaultPosition, wxDefaultSize,
00150 4, strVerbosityLevels, 0, wxGenericValidator(&
verbosity));
00151
if (verbosity < dlgBatchCreation::Verbosity_Min || verbosity > dlgBatchCreation::Verbosity_Max)
00152
verbosity = dlgBatchCreation::vNormal;
00153
00154 wxButton* btnOK =
new wxButton(
this, wxID_OK, _(
"&OK"));
00155 btnOK->SetDefault();
00156 wxButton* btnCancel =
new wxButton(
this, wxID_CANCEL, _(
"&Cancel"));
00157
00158
00159
00160 wxBoxSizer* dlgBatchCreationConfOptionsSizer2 =
new wxBoxSizer(wxVERTICAL);
00161 this->SetSizer(dlgBatchCreationConfOptionsSizer2);
00162 wxBoxSizer* dlgBatchCreationConfOptionsSizer =
new wxBoxSizer(wxVERTICAL);
00163 dlgBatchCreationConfOptionsSizer2->Add(dlgBatchCreationConfOptionsSizer, 1, wxALL | wxGROW,
CONTROL_SPACE);
00164
00165
00166 wxStaticBoxSizer* fraBCCkFileExistsSizer2 =
new wxStaticBoxSizer(fraBCCkFileExists, wxVERTICAL);
00167 dlgBatchCreationConfOptionsSizer->Add(fraBCCkFileExistsSizer2, 0, wxGROW);
00168 wxBoxSizer* fraBCCkFileExistsSizer =
new wxBoxSizer(wxVERTICAL);
00169 fraBCCkFileExistsSizer2->Add(fraBCCkFileExistsSizer, 0, wxALL | wxGROW,
CONTROL_SPACE / 2);
00170
00171 fraBCCkFileExistsSizer->Add(rbxBCSkipExistingCkFile);
00172 fraBCCkFileExistsSizer->Add(rbxBCOverwriteExistingCkFile, 0, wxTOP,
CONTROL_SPACE / 2);
00173
00174
00175 wxStaticBoxSizer* fraBCChecksumsFileNameSizer2 =
new wxStaticBoxSizer(fraBCChecksumsFileName, wxVERTICAL);
00176 dlgBatchCreationConfOptionsSizer->Add(fraBCChecksumsFileNameSizer2, 0, wxGROW | wxTOP,
CONTROL_SPACE);
00177 wxBoxSizer* fraBCChecksumsFileNameSizer =
new wxBoxSizer(wxVERTICAL);
00178 fraBCChecksumsFileNameSizer2->Add(fraBCChecksumsFileNameSizer, 0, wxALL | wxGROW,
CONTROL_SPACE / 2);
00179
00180 fraBCChecksumsFileNameSizer->Add(rbxBCReplaceFileExtension);
00181 fraBCChecksumsFileNameSizer->Add(rbxBCAddFileExtension, 0, wxTOP,
CONTROL_SPACE / 2);
00182
00183
00184 wxStaticBoxSizer* fraBCVerbosityLevelSizer2 =
new wxStaticBoxSizer(fraBCVerbosityLevel, wxVERTICAL);
00185 dlgBatchCreationConfOptionsSizer->Add(fraBCVerbosityLevelSizer2, 0, wxGROW | wxTOP,
CONTROL_SPACE);
00186 wxBoxSizer* fraBCVerbosityLevelSizer =
new wxBoxSizer(wxVERTICAL);
00187 fraBCVerbosityLevelSizer2->Add(fraBCVerbosityLevelSizer, 0, wxALL | wxGROW,
CONTROL_SPACE / 2);
00188
00189 fraBCVerbosityLevelSizer->Add(cboBCVerbosityLevel);
00190
00191
00192 wxGridSizer* buttonsSizer =
new wxGridSizer(2, 0, 2 *
CONTROL_SPACE);
00193 buttonsSizer->Add(btnOK);
00194 buttonsSizer->Add(btnCancel);
00195 dlgBatchCreationConfOptionsSizer->Add(buttonsSizer, 0, wxTOP | wxALIGN_RIGHT, 2 *
CONTROL_SPACE);
00196
00197
00198 this->SetAutoLayout(
true);
00199 this->Layout();
00200
00201
00202 this->TransferDataToWindow();
00203
00204
00205
if (
ovrCkFileWhenItExists)
00206 rbxBCOverwriteExistingCkFile->SetValue(
true);
00207
else
00208 rbxBCSkipExistingCkFile->SetValue(
true);
00209
00210
if (
replaceExtension)
00211 rbxBCReplaceFileExtension->SetValue(
true);
00212
else
00213 rbxBCAddFileExtension->SetValue(
true);
00214
00215 }
00216
00217
00218
00219
00220
00221
00222 dlgBatchCreationConfOptions::~dlgBatchCreationConfOptions()
00223 {
00224 }
00225
00226
00227
00228
00229
00230
00231
00232
00233 dlgBatchCreation::Options dlgBatchCreationConfOptions::getOptions()
const
00234
{
00235
return dlgBatchCreation::Options(
ovrCkFileWhenItExists,
replaceExtension,
00236 static_cast<dlgBatchCreation::Verbosity>(
verbosity));
00237 }
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 IMPLEMENT_DYNAMIC_CLASS(
dlgBatchCreationConf,
dlgFilesSelector)
00248
00249
00250
00251
00252
00253 dlgBatchCreationConf::
dlgBatchCreationConf() :
dlgFilesSelector()
00254 {
00255 }
00256
00257
00258
00259
00260
00261
00262
00263
00264 dlgBatchCreationConf::dlgBatchCreationConf(wxWindow* parent) :
00265
dlgFilesSelector(parent, true)
00266 {
00267 }
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277 void dlgBatchCreationConf::initialize()
00278 {
00279
dlgFilesSelector::initialize();
00280
00281
createControls();
00282
00283
00284
00285 Fit();
00286
00287
00288 wxSize s;
00289
if (PreferenceValue::read(getConfigKey(prGUI_WINDOW_SIZE), &s))
00290 SetSize(s);
00291
00292 Centre();
00293
00294
00295
options =
dlgBatchCreation::Options(AppPrefs::get()->readBool(prBC_OVERWRITE_WHEN_CKFILE_EXISTS),
00296 AppPrefs::get()->readBool(prBC_REPLACE_FILE_EXTENSION),
00297 static_cast<dlgBatchCreation::Verbosity>(AppPrefs::get()->readLong(prBC_VERBOSITY_LEVEL)));
00298 }
00299
00300
00301
00302
00303
00304
00305 void dlgBatchCreationConf::createControls()
00306 {
00307
int i;
00308
00309
00310 wxStaticBox* fraCkFileTypes =
new wxStaticBox(
this, -1, _(
"Create the following types of checks&ums' file:"));
00311
btnOptions =
new wxButton(
this, BTN_OPTIONS, _(
"O&ptions..."));
00312
for (i = 0; i <
SumFileFactory::getSumFilesCount(); i++)
00313
chkCkFileTypes.Add(
new wxCheckBox(
this, -1, SumFileFactory::getSumFileName(i)));
00314
00315
00316
00317
00318
00319
00320 wxStaticBoxSizer* fraCkFileTypesSizer2 =
new wxStaticBoxSizer(fraCkFileTypes, wxVERTICAL);
00321 extendSizer->Add(fraCkFileTypesSizer2, 1, wxGROW | wxTOP,
CONTROL_SPACE);
00322 wxBoxSizer* fraCkFileTypesSizer =
new wxBoxSizer(wxHORIZONTAL);
00323 fraCkFileTypesSizer2->Add(fraCkFileTypesSizer, 1, wxALL | wxGROW,
CONTROL_SPACE / 2);
00324
00325
00326 wxBoxSizer* ckFileTypeSizer =
new wxBoxSizer(wxHORIZONTAL);
00327 fraCkFileTypesSizer->Add(ckFileTypeSizer, 1, wxGROW | wxALIGN_CENTER_VERTICAL);
00328
for (i = 0; i <
SumFileFactory::getSumFilesCount(); i++)
00329
if (i == 0)
00330 ckFileTypeSizer->Add(
chkCkFileTypes[i], 0, wxALIGN_CENTER_VERTICAL);
00331
else
00332 ckFileTypeSizer->Add(
chkCkFileTypes[i], 0, wxLEFT | wxALIGN_CENTER_VERTICAL,
CONTROL_SPACE);
00333
00334
00335 fraCkFileTypesSizer->Add(
btnOptions, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxLEFT,
CONTROL_SPACE);
00336
00337 this->Layout();
00338
00339
00340
00341
00342
for (i = 0; i <
SumFileFactory::getSumFilesCount(); i++)
00343 {
00344
bool value;
00345 wxConfig::Get()->Read(
getCkFileTypeCreateConfigKey(i), &value,
true);
00346
chkCkFileTypes[i]->SetValue(value);
00347 }
00348 }
00349
00350
00351
00352
00353
00354
00355 dlgBatchCreationConf::~dlgBatchCreationConf()
00356 {
00357 }
00358
00359
00360
00361
00362
00363
00364
00365
00366 void dlgBatchCreationConf::btnOptionsClick(wxCommandEvent& event)
00367 {
00368
dlgBatchCreationConfOptions dlg(
this,
options);
00369
if (dlg.ShowModal() == wxID_OK)
00370
options = dlg.
getOptions();
00371 }
00372
00373
00374
00375
00376
00377
00378
00379
00380 void dlgBatchCreationConf::btnOKClick(wxCommandEvent& event)
00381 {
00382
ckFileTypes.Empty();
00383
for (
int i = 0; i <
SumFileFactory::getSumFilesCount(); i++)
00384 {
00385
if (
chkCkFileTypes[i]->GetValue())
00386
ckFileTypes.Add(i);
00387 wxConfig::Get()->Write(
getCkFileTypeCreateConfigKey(i),
chkCkFileTypes[i]->GetValue());
00388 }
00389
00390
if (
ckFileTypes.IsEmpty())
00391 {
00392 ::wxMessageBox(_(
"Select as least a type of checksums' file."), _(
"Warning"), wxOK | wxICON_EXCLAMATION);
00393
return;
00394 }
00395
else
00396 event.Skip();
00397 }
00398
00399
00400
00401
00402
00403
00404
00405
00406 wxArrayInt
dlgBatchCreationConf::getChecksumsFileTypeToCreate()
const
00407
{
00408
return ckFileTypes;
00409 }
00410
00411
00412
00413
00414
00415
00416
00417
00418 dlgBatchCreation::Options dlgBatchCreationConf::getOptions()
const
00419
{
00420
return options;
00421 }
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432 wxString
dlgBatchCreationConf::getRootConfigKey()
00433 {
00434
return wxT(
"GUI/BatchCreationConfigDlg/");
00435 }
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450 wxString
dlgBatchCreationConf::getCkFileTypeCreateConfigKey(
const int sumFileType)
00451 {
00452
if (sumFileType < 0 || sumFileType >=
SumFileFactory::getSumFilesCount())
00453
return wxEmptyString;
00454
00455
return getRootConfigKey() + wxT(
"CreateChecksumsFileType/") + SumFileFactory::getSumFileName(sumFileType);
00456 }
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467 wxString
dlgBatchCreationConf::getUIString(UIStrings
id)
00468 {
00469 wxString res;
00470
switch (
id)
00471 {
00472
case uiDialogTitle :
00473 res = _(
"Batch creation of checksums' files");
break;
00474
case uiBtnOK :
00475 res = _(
"&Create");
break;
00476
case uiFraFilesList :
00477 res = _(
"List of files from which the c&hecksums' files will be created:");
break;
00478
case uiFraSearchFiles :
00479 res = _(
"Search &for some files:");
break;
00480
case uiOpenDlgAddFiles :
00481 res = _(
"Select the files to be added");
break;
00482
case uiOpenDlgAddList :
00483 res = _(
"Add a list of files");
break;
00484
case uiOpenDlgLoadList :
00485 res = _(
"Load a list of files");
break;
00486
case uiSaveDlgAddList :
00487 res = _(
"Save a list of files");
break;
00488 };
00489
00490
return res;
00491 }
00492
00493
00494
00495
00496
00497
00498
00499
00500 wxFileDialogFilterMaker dlgBatchCreationConf::getFiltersForAddFilesDialog()
00501 {
00502
wxFileDialogFilterMaker fltMaker;
00503 fltMaker.
AddFilter(_(
"All the files"), wxT(
"*"));
00504
00505
return fltMaker;
00506 }
00507
00508
00509
00510
00511 BEGIN_EVENT_TABLE(
dlgBatchCreationConf,
dlgFilesSelector)
00512 EVT_BUTTON(BTN_OPTIONS,
dlgBatchCreationConf::btnOptionsClick)
00513 EVT_BUTTON(BTN_OK,
dlgBatchCreationConf::btnOKClick)
00514 END_EVENT_TABLE()
00515
00516