Debian Codegraph @

src/modifyDialog.cpp

raw symbols SCIP
1 /* ---------------------------------- modifyDialog.cpp ---------------------------------------------------------------------------
2 Display a dialog. Adds a new or modifies an existing operation
3
4 ===============================================================================================================================
5 ===============================================================================================================================
6 This file is part of "luckyBackup" project
7 Copyright, Loukas Avgeriou
8 luckyBackup is distributed under the terms of the GNU General Public License
9 luckyBackup is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 luckyBackup is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with luckyBackup. If not, see <http://www.gnu.org/licenses/>.
21
22
23 project version : Please see "main.cpp" for project version
24
25 developer : luckyb
26 last modified : 05 Oct 2017
27
28 ===============================================================================================================================
29 ===============================================================================================================================
30 */
31
32 #include "modifyDialog.h"
33
34 #include <QSignalMapper>
35 #include <QCompleter>
36 #include <QDirModel>
37 #include <QFileDialog>
38
39 #include "global.h"
40
41 #include "textDialog.h"
42
43 // class modifyDialog Constructor=================================================================================================
44 // modify or create an operation
45 modifyDialog::modifyDialog (int ItemNo, QDialog *parent) : QDialog (parent)
46 {
47 uiM.setupUi(this);
48
49 stdWindowWidth = 540;
50 minWindowHeight = 265; //old value=245
51 maxWindowHeight = 690; //old value=565
52
53 uiM.tabWidget_advanced -> setVisible(false);
54 uiM.comboBox_Type -> setCurrentIndex(0);
55 this -> resize(stdWindowWidth,minWindowHeight);
56 ArrayPosition = ItemNo;
57 validation = false;
58 listItemEditMode = false;
59
60 alsoExecuteTooltip = tr("Leave the box checked, to <b>STOP</b> the execution of running task if this command exits with an error");
61 QString comLabel= tr("use boxes to <b>STOP</b> task execution on error", "Please leave the bold tags <b></b> intact and surrounding the word STOP translated");
62 uiM.label_executeBeforeList -> setText ("<font color=red>" + comLabel + "</font>");
63 uiM.label_executeAfterList -> setText ("<font color=red>" + comLabel + "</font>");
64
65 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66 // Various gui initialization
67 //uiM.toolBox_options ->setItemEnabled (0,false); // different backend
68
69 //Disable some stuff when windows is NOT running
70 if (!WINrunning)
71 {
72 uiM.checkBox_vss -> setVisible(false);
73 uiM.checkBox_restorent -> setVisible(false);
74 uiM.lineEdit_sshPasswordStr -> setVisible(false);
75 uiM.lineEdit_sshOptions -> setVisible(false);
76 uiM.label_sshPassword_2 -> setVisible(false);
77 uiM.label_sshPassword_2 -> setVisible(false);
78 }
79 else
80 uiM.checkBox_vss -> setEnabled(false); // disable VSS until a better solution is found
81
82 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83
84 //connections ----------------------------------------------------------------------------------------------------
85 connect(uiM.pushButton_advanced, SIGNAL( toggled(bool) ), this, SLOT(advancedPressed(bool) ) ); //advanced pushButton
86 connect(uiM.pushButton_cancel, SIGNAL( pressed() ), this, SLOT(cancelPressed() ) ); //cancel pushButton
87 connect(uiM.pushButton_okay, SIGNAL( pressed() ), this, SLOT(okayPressed() ) ); //okay pushButton
88 connect(uiM.pushButton_command, SIGNAL( pressed() ), this, SLOT(commandPressed() ) ); //show command pushButton
89 connect(uiM.comboBox_Type, SIGNAL( currentIndexChanged(int) ), this, SLOT(TaskTypeChanged(int) ) ); //Actions when task type combo changes (hide/show stuff)
90
91 //Connect all include tab stuff changes with the disableExcludeTab SLOT
92 connect (uiM.checkBox_includeFile, SIGNAL (stateChanged(int) ), this , SLOT(disableExcludeTab()));
93 connect (uiM.lineEdit_includeFile, SIGNAL (textChanged(QString) ), this , SLOT(disableExcludeTab()));
94 connect (uiM.radioButton_includeOnly, SIGNAL (toggled(bool)), this , SLOT(disableExcludeTab()));
95 connect (uiM.radioButton_includeNormal, SIGNAL (toggled(bool)), this , SLOT(disableExcludeTab()));
96
97 //Connect all add list items buttons with the addListItem SLOT
98 //Map all the pushButton signals and transmit a different integer depending on the pushbutton
99 QSignalMapper *signalMapper2 = new QSignalMapper(this);
100 signalMapper2 -> setMapping ( uiM.pushButton_excludeAdd, 0 );
101 connect(uiM.pushButton_excludeAdd, SIGNAL( pressed() ), signalMapper2, SLOT(map() ) ); //excludAdd pushButton
102 signalMapper2 -> setMapping ( uiM.pushButton_includeAdd, 1 );
103 connect(uiM.pushButton_includeAdd, SIGNAL( pressed() ), signalMapper2, SLOT(map() ) ); //includeAdd pushButton
104 signalMapper2 -> setMapping ( uiM.pushButton_optionsAdd, 2 );
105 connect(uiM.pushButton_optionsAdd, SIGNAL( pressed() ), signalMapper2, SLOT(map() ) ); //optionsAdd pushButton
106 signalMapper2 -> setMapping ( uiM.pushButton_executeBeforeAdd, 3 );
107 connect(uiM.pushButton_executeBeforeAdd, SIGNAL( pressed() ), signalMapper2, SLOT(map() ) ); //executeBeforeAdd pushButton
108 signalMapper2 -> setMapping ( uiM.pushButton_executeAfterAdd, 4 );
109 connect(uiM.pushButton_executeAfterAdd, SIGNAL( pressed() ), signalMapper2, SLOT(map() ) ); //executeAftereAdd pushButton
110 connect(signalMapper2, SIGNAL(mapped( const int)), this, SLOT( addListItem( const int) ) );
111
112 //Connect all Remove list items buttons with the RemoveListItem SLOT
113 //Map all the pushButton signals and transmit a different integer depending on the pushbutton
114 QSignalMapper *signalMapper3 = new QSignalMapper(this);
115 signalMapper3 -> setMapping ( uiM.pushButton_excludeRemove, 0 );
116 connect(uiM.pushButton_excludeRemove, SIGNAL( pressed() ), signalMapper3, SLOT(map() ) ); //excludeRemove pushButton
117 signalMapper3 -> setMapping ( uiM.pushButton_includeRemove, 1 );
118 connect(uiM.pushButton_includeRemove, SIGNAL( pressed() ), signalMapper3, SLOT(map() ) ); //includeRemove pushButton
119 signalMapper3 -> setMapping ( uiM.pushButton_optionsRemove, 2 );
120 connect(uiM.pushButton_optionsRemove, SIGNAL( pressed() ), signalMapper3, SLOT(map() ) ); //optionsRemove pushButton
121 signalMapper3 -> setMapping ( uiM.pushButton_executeBeforeRemove, 3 );
122 connect(uiM.pushButton_executeBeforeRemove, SIGNAL( pressed() ), signalMapper3, SLOT(map() ) ); //executeBeforeRemove pushButton
123 signalMapper3 -> setMapping ( uiM.pushButton_executeAfterRemove, 4 );
124 connect(uiM.pushButton_executeAfterRemove, SIGNAL( pressed() ), signalMapper3, SLOT(map() ) ); //executeAfterRemove pushButton
125 connect(signalMapper3, SIGNAL(mapped( const int)), this, SLOT( removeListItem( const int) ) );
126
127 //Connect all edit list items buttons with the editListItem SLOT
128 //Map all the pushButton signals and transmit a different integer depending on the pushbutton
129 QSignalMapper *signalMapper5 = new QSignalMapper(this);
130 signalMapper5 -> setMapping ( uiM.pushButton_editExclude, 0 );
131 connect(uiM.pushButton_editExclude, SIGNAL( pressed() ), signalMapper5, SLOT(map() ) ); //EditExclude pushButton
132 signalMapper5 -> setMapping ( uiM.pushButton_editInclude, 1 );
133 connect(uiM.pushButton_editInclude, SIGNAL( pressed() ), signalMapper5, SLOT(map() ) ); //EditInclude pushButton
134 signalMapper5 -> setMapping ( uiM.pushButton_editOptions, 2 );
135 connect(uiM.pushButton_editOptions, SIGNAL( pressed() ), signalMapper5, SLOT(map() ) ); //EditOptiions pushButton
136 signalMapper5 -> setMapping ( uiM.pushButton_editExecuteBefore, 3 );
137 connect(uiM.pushButton_editExecuteBefore, SIGNAL( pressed() ), signalMapper5, SLOT(map() ) ); //EditExecuteBefore pushButton
138 signalMapper5 -> setMapping ( uiM.pushButton_editExecuteAfter, 4 );
139 connect(uiM.pushButton_editExecuteAfter, SIGNAL( pressed() ), signalMapper5, SLOT(map() ) ); //EditExecuteAfter pushButton
140 connect(signalMapper5, SIGNAL(mapped( const int)), this, SLOT( editListItem( const int) ) );
141
142 //Connect all "move up" list items buttons with the editListItem SLOT
143 //Map all the pushButton signals and transmit a different integer depending on the pushbutton
144 QSignalMapper *signalMapper6 = new QSignalMapper(this);
145 signalMapper6 -> setMapping ( uiM.pushButton_moveUpExclude, 0 );
146 connect(uiM.pushButton_moveUpExclude, SIGNAL( pressed() ), signalMapper6, SLOT(map() ) );
147 signalMapper6 -> setMapping ( uiM.pushButton_moveUpInclude, 1 );
148 connect(uiM.pushButton_moveUpInclude, SIGNAL( pressed() ), signalMapper6, SLOT(map() ) );
149 signalMapper6 -> setMapping ( uiM.pushButton_moveUpOptions, 2 );
150 connect(uiM.pushButton_moveUpOptions, SIGNAL( pressed() ), signalMapper6, SLOT(map() ) );
151 signalMapper6 -> setMapping ( uiM.pushButton_moveUpExecuteBefore, 3 );
152 connect(uiM.pushButton_moveUpExecuteBefore, SIGNAL( pressed() ), signalMapper6, SLOT(map() ) );
153 signalMapper6 -> setMapping ( uiM.pushButton_moveUpExecuteAfter, 4 );
154 connect(uiM.pushButton_moveUpExecuteAfter, SIGNAL( pressed() ), signalMapper6, SLOT(map() ) );
155 connect(signalMapper6, SIGNAL(mapped( const int)), this, SLOT( moveListItemUp( const int) ) );
156
157 //Connect all "move down" list items buttons with the editListItem SLOT
158 //Map all the pushButton signals and transmit a different integer depending on the pushbutton
159 QSignalMapper *signalMapper7 = new QSignalMapper(this);
160 signalMapper7 -> setMapping ( uiM.pushButton_moveDownExclude, 0 );
161 connect(uiM.pushButton_moveDownExclude, SIGNAL( pressed() ), signalMapper7, SLOT(map() ) );
162 signalMapper7 -> setMapping ( uiM.pushButton_moveDownInclude, 1 );
163 connect(uiM.pushButton_moveDownInclude, SIGNAL( pressed() ), signalMapper7, SLOT(map() ) );
164 signalMapper7 -> setMapping ( uiM.pushButton_moveDownOptions, 2 );
165 connect(uiM.pushButton_moveDownOptions, SIGNAL( pressed() ), signalMapper7, SLOT(map() ) );
166 signalMapper7 -> setMapping ( uiM.pushButton_moveDownExecuteBefore, 3 );
167 connect(uiM.pushButton_moveDownExecuteBefore, SIGNAL( pressed() ), signalMapper7, SLOT(map() ) );
168 signalMapper7 -> setMapping ( uiM.pushButton_moveDownExecuteAfter, 4 );
169 connect(uiM.pushButton_moveDownExecuteAfter, SIGNAL( pressed() ), signalMapper7, SLOT(map() ) );
170 connect(signalMapper7, SIGNAL(mapped( const int)), this, SLOT( moveListItemDown( const int) ) );
171
172 //Connect all toolButtons with the browse SLOT
173 //Map all the toolButton signals and transmit a different integer depending on the toolbutton
174 QSignalMapper *signalMapper = new QSignalMapper(this);
175 signalMapper -> setMapping ( uiM.toolButton_sourceBrowse, 0 );
176 connect (uiM.toolButton_sourceBrowse, SIGNAL (clicked() ), signalMapper , SLOT (map()));
177 signalMapper -> setMapping ( uiM.toolButton_destinationBrowse, 1 );
178 connect (uiM.toolButton_destinationBrowse, SIGNAL (clicked() ), signalMapper , SLOT (map()));
179 signalMapper -> setMapping ( uiM.toolButton_rsyncPassword, 4 );
180 connect (uiM.toolButton_rsyncPassword, SIGNAL (clicked() ), signalMapper , SLOT (map()));
181 signalMapper -> setMapping ( uiM.toolButton_sshPassword, 5 );
182 connect (uiM.toolButton_sshPassword, SIGNAL (clicked() ), signalMapper , SLOT (map()));
183 signalMapper -> setMapping ( uiM.toolButton_executeBeforeBrowse, 6 );
184 connect (uiM.toolButton_executeBeforeBrowse, SIGNAL (clicked() ), signalMapper , SLOT (map()));
185 signalMapper -> setMapping ( uiM.toolButton_executeAfterBrowse, 7 );
186 connect (uiM.toolButton_executeAfterBrowse, SIGNAL (clicked() ), signalMapper , SLOT (map()));
187 signalMapper -> setMapping ( uiM.toolButton_includeFile, 8 );
188 connect (uiM.toolButton_includeFile, SIGNAL (clicked() ), signalMapper , SLOT (map()));
189 signalMapper -> setMapping ( uiM.toolButton_excludeFile, 9 );
190 connect (uiM.toolButton_excludeFile, SIGNAL (clicked() ), signalMapper , SLOT (map()));
191 connect(signalMapper, SIGNAL(mapped( const int)), this, SLOT( browse( const int) ) );
192
193 //Connect all pattern toolButtons with the getPattern SLOT
194 //Map all the toolButton signals and transmit a different integer depending on the toolbutton
195 QSignalMapper *signalMapper4 = new QSignalMapper(this);
196 signalMapper4 -> setMapping ( uiM.toolButton_excludeAddPattern, 0 );
197 connect (uiM.toolButton_excludeAddPattern, SIGNAL (clicked() ), signalMapper4 , SLOT (map()));
198 signalMapper4 -> setMapping ( uiM.toolButton_includeAddPattern, 1 );
199 connect (uiM.toolButton_includeAddPattern, SIGNAL (clicked() ), signalMapper4 , SLOT (map()));
200 connect(signalMapper4, SIGNAL(mapped( const int)), this, SLOT( getPattern( const int) ) );
201
202 // ssh password file default value
203 // I do not consider this a good idea, because the default option should be a blank field (no ssh key file)
204 // If the user clicks the browse button , he/she will be transfered to the ~/.ssh dir as default
205 /*
206 if ( (uiM.lineEdit_sshPassword -> text() == "" ) && (!WINrunning) )
207 {
208 if (!WINrunning)
209 uiM.lineEdit_sshPassword -> setText( myHome + SLASH +".ssh" + SLASH +"id_rsa");
210 else
211 uiM.lineEdit_sshPassword -> setText(luckyBackupDir+"id_rsa");
212 }
213 */
214
215 if (ArrayPosition < TotalOperations) //if modify is pressed fill the fields first with existing operation data
216 fillModifyWindow(Operation[ArrayPosition]);
217
218 disableExcludeTab(); // disable the exclude tab or nothing
219
220 StdArguments << "-h" << "--progress" << "--stats"; //These are the standard arguments used by rsync
221
222 //initialize a completer for the lineEdits
223 QCompleter *completer = new QCompleter(this);
224 completer -> setModel(new QDirModel(completer));
225 uiM.lineEdit_source -> setCompleter(completer);
226 uiM.lineEdit_destination -> setCompleter(completer);
227 uiM.lineEdit_excludeAdd -> setCompleter(completer);
228 uiM.lineEdit_rsyncPassword -> setCompleter(completer);
229 uiM.lineEdit_sshPassword -> setCompleter(completer);
230 uiM.lineEdit_executeBeforeAdd -> setCompleter(completer);
231 uiM.lineEdit_executeAfterAdd -> setCompleter(completer);
232 uiM.lineEdit_excludeFile -> setCompleter(completer);
233 uiM.lineEdit_includeFile -> setCompleter(completer);
234 }
235 //===================================================================================================================================================
236 //------------------------------------------------------------------SLOTS----------------------------------------------------------------------------
237 //===================================================================================================================================================
238
239 // advanced button pressed=====================================================================================================
240 // hides or shows part of the widget
241 void modifyDialog::advancedPressed(bool advanced)
242 {
243 int windowWidth = (this -> size()).width();
244 if (advanced)
245 {
246 uiM.tabWidget_advanced -> setVisible(true);
247 uiM.pushButton_advanced -> setText(tr("simple"));
248 this -> resize(windowWidth,maxWindowHeight);
249 }
250 else
251 {
252 uiM.tabWidget_advanced -> setVisible(false);
253 uiM.pushButton_advanced -> setText(tr("advanced"));
254 this -> resize(windowWidth,minWindowHeight);
255 }
256 }
257
258 // cancel button pressed=====================================================================================================
259 void modifyDialog::cancelPressed()
260 {
261 modifyOK = false;
262 modifyConnected = false;
263 close(); //emmit a QcloseEvent
264 }
265
266 //window closebutton pressed or QcloseEvent emitted==========================================================================
267 void modifyDialog::closeEvent(QCloseEvent *event)
268 {
269 event->accept();
270 }
271
272 // browse button pressed=====================================================================================================
273 //opens a QFileDialog to browse for files/folders locally
274 void modifyDialog::browse(const int type)
275 {
276 QString newLineEdit;
277 switch (type)
278 {
279 //source browse button
280 case 0: newLineEdit = QFileDialog::getExistingDirectory (this, tr("Select source directory",
281 "file selection dialog title"),uiM.lineEdit_source -> text());
282 if (newLineEdit != "") //if something is selected indeed
283 uiM.lineEdit_source -> setText(modifyOS2Slashes(newLineEdit));
284 break;
285 //destination browse button
286 case 1: newLineEdit = QFileDialog::getExistingDirectory (this, tr("Select destination directory",
287 "file selection dialog title"),uiM.lineEdit_destination -> text());
288 if (newLineEdit != "") //if something is selected indeed
289 uiM.lineEdit_destination -> setText(modifyOS2Slashes(newLineEdit));
290 break;
291 //rsync password file browse button
292 case 4: newLineEdit = QFileDialog::getOpenFileName (this, tr("Select rsync password file",
293 "file selection dialog title"), myHome);
294 if (newLineEdit != "") //if something is selected indeed
295 uiM.lineEdit_rsyncPassword -> setText(modifyOS2Slashes(newLineEdit));
296 break;
297 //ssh password file browse button
298 case 5: if (!WINrunning)
299 newLineEdit = QFileDialog::getOpenFileName (this, tr("Select ssh keyfile", "file selection dialog title"), myHome + SLASH +".ssh");
300 else
301 newLineEdit = QFileDialog::getOpenFileName (this, tr("Select ssh keyfile", "file selection dialog title"), luckyBackupDir);
302 if (newLineEdit != "") //if something is selected indeed
303 uiM.lineEdit_sshPassword -> setText(modifyOS2Slashes(newLineEdit));
304 break;
305 //execute before browse button
306 case 6: newLineEdit = QFileDialog::getOpenFileName (this, tr("Select command to be executed",
307 "file selection dialog title"),SLASH);
308 if (newLineEdit != "") //if something is selected indeed
309 uiM.lineEdit_executeBeforeAdd -> setText(modifyOS2Slashes(newLineEdit));
310 break;
311 //execute after browse button
312 case 7: newLineEdit = QFileDialog::getOpenFileName (this, tr("Select command to be executed",
313 "file selection dialog title"),SLASH);
314 if (newLineEdit != "") //if something is selected indeed
315 uiM.lineEdit_executeAfterAdd -> setText(modifyOS2Slashes(newLineEdit));
316 break;
317 //include from file browse button
318 case 8: newLineEdit = QFileDialog::getOpenFileName (this, tr("Select file to read include patterns",
319 "file selection dialog title"),myHome);
320 if (newLineEdit != "") //if something is selected indeed
321 uiM.lineEdit_includeFile -> setText(modifyOS2Slashes(newLineEdit));
322 break;
323 //exclude from file browse button
324 case 9: newLineEdit = QFileDialog::getOpenFileName (this, tr("Select file to read exclude patterns",
325 "file selection dialog title"),myHome);
326 if (newLineEdit != "") //if something is selected indeed
327 uiM.lineEdit_excludeFile -> setText(modifyOS2Slashes(newLineEdit));
328 break;
329 }
330
331 }
332
333 // pattern button pressed=====================================================================================================
334 //launches the pattern editor
335 void modifyDialog::getPattern(const int type)
336 {
337 if (uiM.lineEdit_source -> text() == "") //if the source isn't defined yet
338 {
339 textDialog textdialogW ("QtWarning", tr("Please define the source before launching the pattern editor","message box, message")+" !!", this);
340 textdialogW.exec();
341 return;
342 }
343
344 modifyTrailing(); // first modify the trailing of the source & destination directories
345
346 QString NewPattern = "";
347
348 patternEditor patterneditor(uiM.lineEdit_source -> text(), this);
349 patterneditor.exec();
350
351 NewPattern = patterneditor.getPattern();
352 if (NewPattern == "no pattern defined yet") // cancel pressed at the pattern editor
353 return;
354 switch (type)
355 {
356 // insert the pattern to the exclude lineEdit
357 case 0: uiM.lineEdit_excludeAdd -> setText(NewPattern);
358 break;
359 // insert the pattern to the incude lineEdit
360 case 1: uiM.lineEdit_includeAdd -> setText(NewPattern);
361 break;
362 }
363 }
364 // okay button pressed=======================================================================================================
365 // Read all fields of modify operation dialog and fill appropriate variables
366 // ...after performing some checks & changes !!
367 void modifyDialog::okayPressed()
368 {
369 modifyOK = true;
370 message = "";
371
372 // Strip off invalid characters from task name
373 uiM.lineEdit_name -> setText(stripInvalidCharacters(uiM.lineEdit_name -> text()));
374
375 //if name or source or destination is missing do not proceed -----------------------------------------------------------
376 if ( (uiM.lineEdit_name -> text() == "") || (uiM.lineEdit_destination -> text() == "") || (uiM.lineEdit_source -> text() == "") )
377 {
378 modifyOK = false;
379 message.append(/*"<b>"+tr("ERROR","message box message")+":</b> "+*/
380 tr("Please specify the following before proceeding:","message box, message"));
381 if (uiM.lineEdit_name -> text() == "")
382 message.append("<br>"+tr("Task name"));
383 if (uiM.lineEdit_destination -> text() == "")
384 message.append("<br>"+tr("Destination"));
385 if (uiM.lineEdit_source -> text() == "")
386 message.append("<br>"+tr("Source"));
387 message.append("<br><br>");
388 }
389
390 //check if / is declared as source and backup dir by name as operation type ------------------------------------------------
391 if ((uiM.lineEdit_source -> text() == "/") && (uiM.comboBox_Type -> currentIndex()==0) && (!uiM.checkBox_backupContents -> isChecked()))
392 {
393 modifyOK = false;
394 message.append(/*"<b>"+tr("ERROR","message box message - line1")+":</b> "+*/
395 tr("You have declared the '/' (root) directory as source and have NOT checked the 'Do NOT create extra directory' box","message box message - line1")+"<br>"+
396 tr("That is not allowed because '/' does not have an actual name","message box message - line2")+" !!<br>"
397 "..."+tr("Please check the relevant box before proceeding","message box message - line3")+"<br><br>");
398 }
399 //same for OS2 or win
400 if (((uiM.lineEdit_source -> text()).endsWith(":\\")) && (uiM.comboBox_Type -> currentIndex()==0) && (!uiM.checkBox_backupContents -> isChecked())
401 && (notXnixRunning) )
402 {
403 modifyOK = false;
404 message.append(/*"<b>"+tr("ERROR","message box message - line1")+":</b> "+*/
405 tr("You have declared the root directory of an entire partition as source and have NOT checked the 'Do NOT create extra directory' box","message box message - line1")+"<br>"+
406 tr("That is not allowed because the root partition does not have an actual name","message box message - line2")+" !!<br>"
407 "..."+tr("Please check the relevant box before proceeding","message box message - line3")+"<br><br>");
408 }
409
410 //check if the operation name already exists to proceed --------------------------------------------------------------------
411 count=0;
412 while (count < TotalOperations)
413 {
414 if ( ((uiM.lineEdit_name -> text()) == (Operation[count] -> GetName()) ) && (count != ArrayPosition) )
415 {
416 modifyOK = false;
417 message.append(/*"<b>"+tr("ERROR","message box message - line1")+":</b> "+*/
418 tr("The name of the task you requested already exists","message box message - line1")+" !!<br>"
419 "..."+tr("Please specify a different name before proceeding","message box message - line2")+"<br><br>");
420 break;
421 }
422 count++;
423 }
424
425 modifyTrailing(); //do some changes according to radio button "operation type"
426
427 //perform this if both source & destination are not empty
428 if ( ((uiM.lineEdit_source -> text()) != "") && ((uiM.lineEdit_destination -> text()) != "" ) )
429 {
430 //check if source & destination are the same to proceed ------------------------------------------------------------------
431 if ((( (uiM.lineEdit_source -> text()) == (uiM.lineEdit_destination -> text()) )
432 || ( (uiM.lineEdit_source -> text() + SLASH) == (uiM.lineEdit_destination -> text()) ) ) && (!uiM.groupBox_remote -> isChecked()) )
433 {
434 modifyOK = false;
435 message.append(/*"<b>"+tr("ERROR","message box message - line1")+":</b> "+*/
436 tr("The source you have declared is identical to the destination","message box message - line1")+" !!<br>"
437 "..."+tr("Please modify at least one of them","message box message - line2")+"<br><br>");
438 }
439 else //check if the destination is part of the source directory structure ------------------------------------------------
440 if ( ((uiM.lineEdit_destination -> text()).contains(uiM.lineEdit_source -> text(), Qt::CaseSensitive) )
441 || ((uiM.lineEdit_destination -> text()).contains(uiM.lineEdit_source -> text() + SLASH, Qt::CaseSensitive)) )
442 message.prepend(/*"<b>"+tr("WARNING","message box message - line1")+":</b> "+*/
443 tr("You have declared a destination that is part of the source directory structure",
444 "message box message - line1")+"<br>"
445 +tr("<b>Do not forget</b> to define a directory at the 'exclude' groupbox that will contain the destination",
446 "message box message - line2. Please leave tag <b>,</b> intact and surrounding 'do not forget' translated")+"<br><br>");
447 }
448
449 //"recursive" has to be checked for --delete-after to operate -------------------------------------------------------------
450 if ( (uiM.checkBox_deleteAfter -> isChecked()) && !(uiM.checkBox_recurse -> isChecked()) )
451 {
452 modifyOK = false;
453 message.append(/*"<b>"+tr("ERROR","message box message - line1")+":</b> "+*/
454 tr("You have checked the 'delete files on the destination' option","message box message - line2") + "<br>" +
455 tr("without having checked 'Recurse into directories' which is required","message box message - line3")+"<br><br>");
456 }
457
458 //check if "remote" is checked and no hostname is declared -----------------------------------------------------------------
459 if ( (uiM.groupBox_remote -> isChecked()) && (uiM.lineEdit_remoteHost -> text() == "") )
460 {
461 modifyOK = false;
462 message.append(/*"<b>"+tr("ERROR","message box message - line1")+":</b>"+*/
463 tr("'Remote Host' is checked, but no remote host name is declared","message box message - line2")+"<br>"+
464 tr("Please specify a remote host name","message box message - line3")+"<br>"+
465 tr("Otherwise uncheck 'Remote Host' to operate locally","message box message - line4")+"<br><br>");
466 }
467
468 bool tempCloneWarning = true;
469 //use this cause the next command will set CloneWARNING to true by creating a new operation
470 // only perform this if "modify is pressed, not "new/duplicate/restore" task
471 if (!newTaskThisIs)
472 tempCloneWarning = Operation[ArrayPosition] -> GetCloneWARNING ();
473
474 Operation[ArrayPosition] = fillOperationArray(); //fill the operation array item with data from the modify dialog
475 Operation[ArrayPosition] -> SetCloneWARNING (tempCloneWarning);
476
477 if (!validation) //if "done" pressed and not "validation check"
478 {
479 if (modifyOK) //if all "data filling" went ok
480 {
481 //check if the user has selected "delete files on the destination" & "backup the contents of a source directory" and WARN
482 if ( (uiM.comboBox_Type -> currentIndex()==0) && (uiM.checkBox_deleteAfter -> isChecked()) &&
483 (Operation[ArrayPosition] -> GetCloneWARNING()) && (uiM.checkBox_backupContents -> isChecked()) )
484 {
485 textDialog textdialog ("CloneWarning", "", this);
486 textdialog.exec();
487 if (textdialog.getGoOn() == 4) //okay with "Do not show this again" checked
488 {
489 Operation[ArrayPosition] -> SetCloneWARNING (false);
490 close();
491 }
492 if (textdialog.getGoOn() == 2) //okay with "Do not show this again" NOT checked
493 close(); //emmit a QcloseEvent
494 }
495 else
496 close(); //emmit a QcloseEvent
497 }
498 else //display a warning message
499 {
500 textDialog textdialogW ("QtWarning", message, this);
501 textdialogW.exec();
502 }
503 }
504 }
505
506 // validate button pressed=======================================================================================================
507 // Pops up a dialog with the rsync command & arguments, also displays error messages
508 void modifyDialog::commandPressed()
509 {
510 validation = true;
511
512 okayPressed();
513
514 QStringList arguments = Operation[ArrayPosition] -> GetArgs(); QString tempArgs = ""; count=0; QString source, dest;
515 source=arguments[arguments.size()-2];
516 dest=arguments[arguments.size()-1];
517 while (count < arguments.size()-2)
518 {
519 if (arguments[count].contains("-e "+sshCommandPath+" "))
520 {
521 tempArgs.append("-e \"" + arguments[count].remove(0,3) + "\" ");
522 }
523 else
524 tempArgs.append(arguments[count]+" ");
525 count++;
526 }
527
528 if (modifyOK)
529 message.prepend(tr("All declared fields of the task properties window seem to be ok","message box message first line")+"<br><br>");
530 else
531 message.prepend("<b>"+tr("Errors have been found","message box message first line")+"...</b><br><br>");
532
533 message.append("<b>"+tr("command to be executed","full phrase: command to be executed: <COMMAND>")+":</b><br>");
534
535 textDialog textdialog ("ValidateDialog", message + "<font color=red>rsync </font><font color=blue>" + tempArgs +
536 "</font><br><font color=magenta>"+ source + " </font><br><font color=magenta>" + dest + "</font><br>", this);
537 textdialog.exec();
538
539 validation = false;
540 //==========================================================================================================================
541 }
542
543 // List item Add button pressed=====================================================================================================
544 // adds an item in the excluded,included,options list
545 void modifyDialog::addListItem(const int type)
546 {
547 QString text="", selectedText="";
548 QList<QListWidgetItem*> temp;
549 temp.clear();
550
551 switch (type)
552 {
553 //exclude list add button
554 case 0:
555 text = uiM.lineEdit_excludeAdd -> text(); // This is the text in the lineEdit
556 if (text == "") // if there is nothing typed just return
557 return;
558
559 if (uiM.listWidget_exclude -> count() == 0) // if this is the first entry, just add it (to avoid segfault)
560 {
561 uiM.listWidget_exclude -> addItem(text);
562 uiM.lineEdit_excludeAdd -> clear();
563 return;
564 }
565
566 if (listItemEditMode)
567 selectedText = (uiM.listWidget_exclude -> currentItem()) -> text(); // The selected list item text (used for listItemEdit)
568 temp = uiM.listWidget_exclude -> findItems (text, Qt::MatchExactly) ; // list with all other items that are the same with the lineedit
569
570 // If the text in the lineedit already exists
571 if ((temp.size() > 0) && (text != selectedText))
572 {
573 textDialog textdialogw ("QtWarning", tr("You have already added this exclude item","message box message")+" !!<br>" , this);
574 textdialogw.exec();
575 return;
576 }
577
578 if (listItemEditMode)
579 {
580 //change the value of the selected list item
581 int selectedItem = uiM.listWidget_exclude -> currentRow();
582 uiM.listWidget_exclude -> takeItem(selectedItem); //take out the selected item from the list
583 uiM.listWidget_exclude -> insertItem(selectedItem, text); //insert a new one at the same position with the new text
584 uiM.listWidget_exclude -> setCurrentRow(selectedItem); //highlight this row
585
586 // set the gui back to its original form
587 uiM.pushButton_excludeAdd -> setText(origAddText);
588 uiM.pushButton_excludeAdd -> setToolTip(origAddToolTip);
589 uiM.pushButton_excludeAdd -> setIcon(QIcon(":/luckyPrefix/add.png"));
590 uiM.pushButton_excludeRemove -> setText(origRemoveText);
591 uiM.pushButton_excludeRemove -> setToolTip(origRemoveToolTip);
592 uiM.pushButton_excludeRemove -> setIcon(QIcon(":/luckyPrefix/remove.png"));
593
594 uiM.pushButton_editExclude -> setEnabled (true);
595 uiM.pushButton_moveUpExclude -> setEnabled (true);
596 uiM.pushButton_moveDownExclude -> setEnabled (true);
597
598 // set this bool var to false - end of list edit mode
599 listItemEditMode = false;
600 }
601 else
602 uiM.listWidget_exclude -> addItem(text);
603 uiM.lineEdit_excludeAdd -> clear();
604
605 break;
606
607 //include list add button
608 case 1:
609 text = uiM.lineEdit_includeAdd -> text();
610 if (text == "") // if there is nothing typed just return
611 return;
612
613 if (uiM.listWidget_include -> count() == 0) // if this is the first entry, just add it (to avoid segfault)
614 {
615 uiM.listWidget_include -> addItem(text);
616 uiM.lineEdit_includeAdd -> clear();
617 disableExcludeTab(); // disable the exclude tab or not
618 return;
619 }
620
621 if (listItemEditMode)
622 selectedText = (uiM.listWidget_include -> currentItem()) -> text(); // The selected list item text (used for listItemEdit)
623 temp = uiM.listWidget_include -> findItems (text, Qt::MatchExactly) ; // list with all other items that are the same with the lineedit
624
625 // If the text in the lineedit already exists
626 if ((temp.size() > 0) && (text != selectedText))
627 {
628 textDialog textdialogw ("QtWarning", tr("You have already added this include item","message box message")+" !!<br>" , this);
629 textdialogw.exec();
630 return;
631 }
632
633 if (listItemEditMode)
634 {
635 //change the value of the selected list item
636 int selectedItem = uiM.listWidget_include -> currentRow();
637 uiM.listWidget_include -> takeItem(selectedItem); //take out the selected item from the list
638 uiM.listWidget_include -> insertItem(selectedItem, text); //insert a new one at the same position with the new text
639 uiM.listWidget_include -> setCurrentRow(selectedItem); //highlight this row
640
641 // set the gui back to its original form
642 uiM.pushButton_includeAdd -> setText(origAddText);
643 uiM.pushButton_includeAdd -> setToolTip(origAddToolTip);
644 uiM.pushButton_includeAdd -> setIcon(QIcon(":/luckyPrefix/add.png"));
645 uiM.pushButton_includeRemove -> setText(origRemoveText);
646 uiM.pushButton_includeRemove -> setToolTip(origRemoveToolTip);
647 uiM.pushButton_includeRemove -> setIcon(QIcon(":/luckyPrefix/remove.png"));
648
649 uiM.pushButton_editInclude -> setEnabled (true);
650 uiM.pushButton_moveUpInclude -> setEnabled (true);
651 uiM.pushButton_moveDownInclude -> setEnabled (true);
652
653 // set this bool var to false - end of list edit mode
654 listItemEditMode = false;
655 }
656 else
657 uiM.listWidget_include -> addItem(text);
658 uiM.lineEdit_includeAdd -> clear();
659 disableExcludeTab(); // disable the exclude tab or not
660 break;
661
662 //options list add button
663 case 2:
664 text = uiM.lineEdit_optionsAdd -> text();
665 if (text == "") // if there is nothing typed just return
666 return;
667 if (uiM.listWidget_options -> count() == 0) // if this is the first entry, just add it (to avoid segfault)
668 {
669 uiM.listWidget_options -> addItem(text);
670 uiM.lineEdit_optionsAdd -> clear();
671 return;
672 }
673
674 if (listItemEditMode)
675 selectedText = (uiM.listWidget_options -> currentItem()) -> text(); // The selected list item text (used for listItemEdit)
676 temp = uiM.listWidget_options -> findItems (text, Qt::MatchExactly) ; // list with all other items that are the same with the lineedit
677
678 // If the text in the lineedit already exist
679 if ((temp.size() > 0) && (text != selectedText))
680 {
681 textDialog textdialogW ("QtWarning", tr("You have already added this option","message box message")+" !!<br>", this);
682 textdialogW.exec();
683 return;
684 }
685
686 if (listItemEditMode)
687 {
688 //change the value of the selected list item
689 int selectedItem = uiM.listWidget_options -> currentRow();
690 uiM.listWidget_options -> takeItem(selectedItem); //take out the selected item from the list
691 uiM.listWidget_options -> insertItem(selectedItem, text); //insert a new one at the same position with the new text
692 uiM.listWidget_options -> setCurrentRow(selectedItem); //highlight this row
693
694 // set the gui back to its original form
695 uiM.pushButton_optionsAdd -> setText(origAddText);
696 uiM.pushButton_optionsAdd -> setToolTip(origAddToolTip);
697 uiM.pushButton_optionsAdd -> setIcon(QIcon(":/luckyPrefix/add.png"));
698 uiM.pushButton_optionsRemove -> setText(origRemoveText);
699 uiM.pushButton_optionsRemove -> setToolTip(origRemoveToolTip);
700 uiM.pushButton_optionsRemove -> setIcon(QIcon(":/luckyPrefix/remove.png"));
701
702 uiM.pushButton_editOptions -> setEnabled (true);
703 uiM.pushButton_moveUpOptions -> setEnabled (true);
704 uiM.pushButton_moveDownOptions -> setEnabled (true);
705
706 // set this bool var to false - end of list edit mode
707 listItemEditMode = false;
708 }
709 else
710 uiM.listWidget_options -> addItem(text);
711
712 uiM.lineEdit_optionsAdd -> clear();
713
714 break;
715
716 //Execute before list add button
717 case 3:
718 text = uiM.lineEdit_executeBeforeAdd -> text();
719 if (text != "")
720 {
721 if (listItemEditMode)
722 {
723 //change the value of the selected list item
724 int selectedItem = uiM.listWidget_executeBefore -> currentRow();
725 uiM.listWidget_executeBefore -> takeItem(selectedItem); //take out the selected item from the list
726 //insert a new one at the same position with the new text
727 uiM.listWidget_executeBefore -> insertItem(selectedItem, text);
728 uiM.listWidget_executeBefore -> setCurrentRow(selectedItem); //highlight this row
729 uiM.listWidget_executeBefore -> currentItem() -> setCheckState(alsoExecuteState); // set its state to what it was
730 uiM.listWidget_executeBefore -> currentItem() -> setToolTip (alsoExecuteTooltip); // set the tooltip
731
732 // set the gui back to its original form
733 uiM.pushButton_executeBeforeAdd -> setText(origAddText);
734 uiM.pushButton_executeBeforeAdd -> setToolTip(origAddToolTip);
735 uiM.pushButton_executeBeforeAdd -> setIcon(QIcon(":/luckyPrefix/add.png"));
736 uiM.pushButton_executeBeforeRemove -> setText(origRemoveText);
737 uiM.pushButton_executeBeforeRemove -> setToolTip(origRemoveToolTip);
738 uiM.pushButton_executeBeforeRemove -> setIcon(QIcon(":/luckyPrefix/remove.png"));
739
740 uiM.pushButton_editExecuteBefore -> setEnabled (true);
741 uiM.pushButton_moveUpExecuteBefore -> setEnabled (true);
742 uiM.pushButton_moveDownExecuteBefore -> setEnabled (true);
743
744 // set this bool var to false - end of list edit mode
745 listItemEditMode = false;
746 }
747 else
748 {
749 uiM.listWidget_executeBefore -> addItem(text);
750 uiM.listWidget_executeBefore -> setCurrentRow(uiM.listWidget_executeBefore -> count()-1);
751 uiM.listWidget_executeBefore -> currentItem() -> setCheckState(Qt::Checked);
752 uiM.listWidget_executeBefore -> currentItem() -> setToolTip (alsoExecuteTooltip);
753 }
754
755 uiM.lineEdit_executeBeforeAdd -> clear();
756 }
757 break;
758 //Execute after list add button
759 case 4:
760 text = uiM.lineEdit_executeAfterAdd -> text();
761 if (text != "")
762 {
763 if (listItemEditMode)
764 {
765 //change the value of the selected list item
766 int selectedItem = uiM.listWidget_executeAfter -> currentRow();
767 uiM.listWidget_executeAfter -> takeItem(selectedItem); //take out the selected item from the list
768 //insert a new one at the same position with the new text
769 uiM.listWidget_executeAfter -> insertItem(selectedItem, text);
770 uiM.listWidget_executeAfter -> setCurrentRow(selectedItem); //highlight this row
771 uiM.listWidget_executeAfter -> currentItem() -> setCheckState(alsoExecuteState); // set its state to what it was
772 uiM.listWidget_executeAfter -> currentItem() -> setToolTip (alsoExecuteTooltip);
773
774 // set the gui back to its original form
775 uiM.pushButton_executeAfterAdd -> setText(origAddText);
776 uiM.pushButton_executeAfterAdd -> setToolTip(origAddToolTip);
777 uiM.pushButton_executeAfterAdd -> setIcon(QIcon(":/luckyPrefix/add.png"));
778 uiM.pushButton_executeAfterRemove -> setText(origRemoveText);
779 uiM.pushButton_executeAfterRemove -> setToolTip(origRemoveToolTip);
780 uiM.pushButton_executeAfterRemove -> setIcon(QIcon(":/luckyPrefix/remove.png"));
781
782 uiM.pushButton_editExecuteAfter -> setEnabled (true);
783 uiM.pushButton_moveUpExecuteAfter -> setEnabled (true);
784 uiM.pushButton_moveDownExecuteAfter -> setEnabled (true);
785
786 // set this bool var to false - end of list edit mode
787 listItemEditMode = false;
788 }
789 else
790 {
791 uiM.listWidget_executeAfter -> addItem(text);
792 uiM.listWidget_executeAfter -> setCurrentRow(uiM.listWidget_executeAfter -> count()-1);
793 uiM.listWidget_executeAfter -> currentItem() -> setCheckState(Qt::Checked);
794 uiM.listWidget_executeAfter -> currentItem() -> setToolTip (alsoExecuteTooltip);
795 }
796
797 uiM.lineEdit_executeAfterAdd -> clear();
798 }
799 break;
800 }
801 }
802
803 // List item Remove button pressed=====================================================================================================
804 // Removes an item from the excluded,included,options list
805 void modifyDialog::removeListItem(const int type)
806 {
807 int selected;
808 switch (type)
809 {
810 //exclude list remove button
811 case 0:
812 if (listItemEditMode) // do not proceed further if this is just a cancel from list item edit mode
813 {
814 // set the gui back to its original form
815 uiM.pushButton_excludeAdd -> setText(origAddText);
816 uiM.pushButton_excludeAdd -> setToolTip(origAddToolTip);
817 uiM.pushButton_excludeAdd -> setIcon(QIcon(":/luckyPrefix/add.png"));
818 uiM.pushButton_excludeRemove -> setText(origRemoveText);
819 uiM.pushButton_excludeRemove -> setToolTip(origRemoveToolTip);
820 uiM.pushButton_excludeRemove -> setIcon(QIcon(":/luckyPrefix/remove.png"));
821 uiM.pushButton_editExclude -> setEnabled (true);
822 uiM.pushButton_moveUpExclude -> setEnabled (true);
823 uiM.pushButton_moveDownExclude -> setEnabled (true);
824 listItemEditMode = false; // set this bool var to false - end of list edit mode
825 return;
826 }
827
828 selected = uiM.listWidget_exclude -> currentRow(); //current list row number
829 if (selected < 0) //if nothing is selected do nothing
830 return;
831 uiM.listWidget_exclude-> takeItem(selected);
832 break;
833 //include list remove button
834 case 1:
835 if (listItemEditMode) // do not proceed further if this is just a cancel from list item edit mode
836 {
837 // set the gui back to its original form
838 uiM.pushButton_includeAdd -> setText(origAddText);
839 uiM.pushButton_includeAdd -> setToolTip(origAddToolTip);
840 uiM.pushButton_includeAdd -> setIcon(QIcon(":/luckyPrefix/add.png"));
841 uiM.pushButton_includeRemove -> setText(origRemoveText);
842 uiM.pushButton_includeRemove -> setToolTip(origRemoveToolTip);
843 uiM.pushButton_includeRemove -> setIcon(QIcon(":/luckyPrefix/remove.png"));
844 uiM.pushButton_editInclude -> setEnabled (true);
845 uiM.pushButton_moveUpInclude -> setEnabled (true);
846 uiM.pushButton_moveDownInclude -> setEnabled (true);
847 listItemEditMode = false; // set this bool var to false - end of list edit mode
848 return;
849 }
850
851 selected = uiM.listWidget_include -> currentRow(); //current list row number
852 if (selected < 0) //if nothing is selected do nothing
853 return;
854 uiM.listWidget_include-> takeItem(selected);
855 disableExcludeTab(); // disable the exclude tab or not
856 break;
857 //options list remove button
858 case 2:
859 if (listItemEditMode) // do not proceed further if this is just a cancel from list item edit mode
860 {
861 // set the gui back to its original form
862 uiM.pushButton_optionsAdd -> setText(origAddText);
863 uiM.pushButton_optionsAdd -> setToolTip(origAddToolTip);
864 uiM.pushButton_optionsAdd -> setIcon(QIcon(":/luckyPrefix/add.png"));
865 uiM.pushButton_optionsRemove -> setText(origRemoveText);
866 uiM.pushButton_optionsRemove -> setToolTip(origRemoveToolTip);
867 uiM.pushButton_optionsRemove -> setIcon(QIcon(":/luckyPrefix/remove.png"));
868 uiM.pushButton_editOptions -> setEnabled (true);
869 uiM.pushButton_moveUpOptions -> setEnabled (true);
870 uiM.pushButton_moveDownOptions -> setEnabled (true);
871 listItemEditMode = false; // set this bool var to false - end of list edit mode
872 return;
873 }
874
875 selected = uiM.listWidget_options -> currentRow(); //current list row number
876 if (selected < 0) //if nothing is selected do nothing
877 return;
878 uiM.listWidget_options-> takeItem(selected);
879 break;
880 //execute before list remove button
881 case 3:
882 if (listItemEditMode) // do not proceed further if this is just a cancel from list item edit mode
883 {
884 // set the gui back to its original form
885 uiM.pushButton_executeBeforeAdd -> setText(origAddText);
886 uiM.pushButton_executeBeforeAdd -> setToolTip(origAddToolTip);
887 uiM.pushButton_executeBeforeAdd -> setIcon(QIcon(":/luckyPrefix/add.png"));
888 uiM.pushButton_executeBeforeRemove -> setText(origRemoveText);
889 uiM.pushButton_executeBeforeRemove -> setToolTip(origRemoveToolTip);
890 uiM.pushButton_executeBeforeRemove -> setIcon(QIcon(":/luckyPrefix/remove.png"));
891 uiM.pushButton_editExecuteBefore -> setEnabled (true);
892 uiM.pushButton_moveUpExecuteBefore -> setEnabled (true);
893 uiM.pushButton_moveDownExecuteBefore -> setEnabled (true);
894 listItemEditMode = false; // set this bool var to false - end of list edit mode
895 return;
896 }
897
898 selected = uiM.listWidget_executeBefore -> currentRow(); //current list row number
899 if (selected < 0) //if nothing is selected do nothing
900 return;
901 uiM.listWidget_executeBefore -> takeItem(selected);
902 break;
903 //execute after list remove button
904 case 4:
905 if (listItemEditMode) // do not proceed further if this is just a cancel from list item edit mode
906 {
907 // set the gui back to its original form
908 uiM.pushButton_executeAfterAdd -> setText(origAddText);
909 uiM.pushButton_executeAfterAdd -> setToolTip(origAddToolTip);
910 uiM.pushButton_executeAfterAdd -> setIcon(QIcon(":/luckyPrefix/add.png"));
911 uiM.pushButton_executeAfterRemove -> setText(origRemoveText);
912 uiM.pushButton_executeAfterRemove -> setToolTip(origRemoveToolTip);
913 uiM.pushButton_executeAfterRemove -> setIcon(QIcon(":/luckyPrefix/remove.png"));
914 uiM.pushButton_editExecuteAfter -> setEnabled (true);
915 uiM.pushButton_moveUpExecuteAfter -> setEnabled (true);
916 uiM.pushButton_moveDownExecuteAfter -> setEnabled (true);
917 listItemEditMode = false; // set this bool var to false - end of list edit mode
918 return;
919 }
920
921 selected = uiM.listWidget_executeAfter -> currentRow(); //current list row number
922 if (selected < 0) //if nothing is selected do nothing
923 return;
924 uiM.listWidget_executeAfter -> takeItem(selected);
925 break;
926 }
927
928 }
929
930 // List item edit button pressed=====================================================================================================
931 // Edits an item from the excluded,included,options or "also execute" list
932 void modifyDialog::editListItem(const int type)
933 {
934 int selected;
935 QString selectedText = "";
936 switch (type)
937 {
938 //exclude list
939 case 0: selected = uiM.listWidget_exclude -> currentRow(); //current list row number
940 if (selected < 0) //if nothing is selected do nothing
941 return;
942 listItemEditMode = true;
943 origAddText = uiM.pushButton_excludeAdd -> text();
944 origAddToolTip = uiM.pushButton_excludeAdd -> toolTip();
945 origRemoveText = uiM.pushButton_excludeRemove -> text();
946 origRemoveToolTip = uiM.pushButton_excludeRemove -> toolTip();
947 uiM.pushButton_excludeAdd -> setText(tr("done"));
948 uiM.pushButton_excludeAdd -> setToolTip(tr("done editing"));
949 uiM.pushButton_excludeAdd -> setIcon(QIcon(":/luckyPrefix/okay.png"));
950 uiM.pushButton_excludeRemove -> setText(tr("cancel"));
951 uiM.pushButton_excludeRemove -> setToolTip(tr("cancel editing"));
952 uiM.pushButton_excludeRemove -> setIcon(QIcon(":/luckyPrefix/cancel.png"));
953
954 uiM.pushButton_editExclude -> setEnabled (false);
955 uiM.pushButton_moveUpExclude -> setEnabled (false);
956 uiM.pushButton_moveDownExclude -> setEnabled (false);
957
958 selectedText = (uiM.listWidget_exclude -> currentItem()) -> text(); //current list item text
959 uiM.lineEdit_excludeAdd -> setText (selectedText);
960 uiM.lineEdit_excludeAdd -> setFocus();
961 uiM.lineEdit_excludeAdd -> selectAll();
962 break;
963 //include list
964 case 1: selected = uiM.listWidget_include -> currentRow(); //current list row number
965 if (selected < 0) //if nothing is selected do nothing
966 return;
967 listItemEditMode = true;
968 origAddText = uiM.pushButton_includeAdd -> text();
969 origAddToolTip = uiM.pushButton_includeAdd -> toolTip();
970 origRemoveText = uiM.pushButton_includeRemove -> text();
971 origRemoveToolTip = uiM.pushButton_includeRemove -> toolTip();
972 uiM.pushButton_includeAdd -> setText(tr("done"));
973 uiM.pushButton_includeAdd -> setToolTip(tr("done editing"));
974 uiM.pushButton_includeAdd -> setIcon(QIcon(":/luckyPrefix/okay.png"));
975 uiM.pushButton_includeRemove -> setText(tr("cancel"));
976 uiM.pushButton_includeRemove -> setToolTip(tr("cancel editing"));
977 uiM.pushButton_includeRemove -> setIcon(QIcon(":/luckyPrefix/cancel.png"));
978
979 uiM.pushButton_editInclude -> setEnabled (false);
980 uiM.pushButton_moveUpInclude -> setEnabled (false);
981 uiM.pushButton_moveDownInclude -> setEnabled (false);
982
983 selectedText = (uiM.listWidget_include -> currentItem()) -> text(); //current list item text
984 uiM.lineEdit_includeAdd -> setText (selectedText);
985 uiM.lineEdit_includeAdd -> setFocus();
986 uiM.lineEdit_includeAdd -> selectAll();
987 break;
988 //options list
989 case 2: selected = uiM.listWidget_options -> currentRow(); //current list row number
990 if (selected < 0) //if nothing is selected do nothing
991 return;
992 listItemEditMode = true;
993 origAddText = uiM.pushButton_optionsAdd -> text();
994 origAddToolTip = uiM.pushButton_optionsAdd -> toolTip();
995 origRemoveText = uiM.pushButton_optionsRemove -> text();
996 origRemoveToolTip = uiM.pushButton_optionsRemove -> toolTip();
997 uiM.pushButton_optionsAdd -> setText(tr("done"));
998 uiM.pushButton_optionsAdd -> setToolTip(tr("done editing"));
999 uiM.pushButton_optionsAdd -> setIcon(QIcon(":/luckyPrefix/okay.png"));
1000 uiM.pushButton_optionsRemove -> setText(tr("cancel"));
1001 uiM.pushButton_optionsRemove -> setToolTip(tr("cancel editing"));
1002 uiM.pushButton_optionsRemove -> setIcon(QIcon(":/luckyPrefix/cancel.png"));
1003
1004 uiM.pushButton_editOptions -> setEnabled (false);
1005 uiM.pushButton_moveUpOptions -> setEnabled (false);
1006 uiM.pushButton_moveDownOptions -> setEnabled (false);
1007
1008 selectedText = (uiM.listWidget_options -> currentItem()) -> text(); //current list item text
1009 uiM.lineEdit_optionsAdd -> setText (selectedText);
1010 uiM.lineEdit_optionsAdd -> setFocus();
1011 uiM.lineEdit_optionsAdd -> selectAll();
1012 break;
1013 //execute before list
1014 case 3: selected = uiM.listWidget_executeBefore -> currentRow(); //current list row number
1015 if (selected < 0) //if nothing is selected do nothing
1016 return;
1017 listItemEditMode = true;
1018 origAddText = uiM.pushButton_executeBeforeAdd -> text();
1019 origAddToolTip = uiM.pushButton_executeBeforeAdd -> toolTip();
1020 origRemoveText = uiM.pushButton_executeBeforeRemove -> text();
1021 origRemoveToolTip = uiM.pushButton_executeBeforeRemove -> toolTip();
1022 uiM.pushButton_executeBeforeAdd -> setText(tr("done"));
1023 uiM.pushButton_executeBeforeAdd -> setToolTip(tr("done editing"));
1024 uiM.pushButton_executeBeforeAdd -> setIcon(QIcon(":/luckyPrefix/okay.png"));
1025 uiM.pushButton_executeBeforeRemove -> setText(tr("cancel"));
1026 uiM.pushButton_executeBeforeRemove -> setToolTip(tr("cancel editing"));
1027 uiM.pushButton_executeBeforeRemove -> setIcon(QIcon(":/luckyPrefix/cancel.png"));
1028
1029 uiM.pushButton_editExecuteBefore -> setEnabled (false);
1030 uiM.pushButton_moveUpExecuteBefore -> setEnabled (false);
1031 uiM.pushButton_moveDownExecuteBefore -> setEnabled (false);
1032
1033 selectedText = (uiM.listWidget_executeBefore -> currentItem()) -> text(); //current list item text
1034 alsoExecuteState = uiM.listWidget_executeBefore -> currentItem() -> checkState(); // current list item check state
1035 uiM.lineEdit_executeBeforeAdd -> setText (selectedText);
1036 uiM.lineEdit_executeBeforeAdd -> setFocus();
1037 uiM.lineEdit_executeBeforeAdd -> selectAll();
1038 break;
1039 //execute after
1040 case 4: selected = uiM.listWidget_executeAfter -> currentRow(); //current list row number
1041 if (selected < 0) //if nothing is selected do nothing
1042 return;
1043 listItemEditMode = true;
1044 origAddText = uiM.pushButton_executeAfterAdd -> text();
1045 origAddToolTip = uiM.pushButton_executeAfterAdd -> toolTip();
1046 origRemoveText = uiM.pushButton_executeAfterRemove -> text();
1047 origRemoveToolTip = uiM.pushButton_executeAfterRemove -> toolTip();
1048 uiM.pushButton_executeAfterAdd -> setText(tr("done"));
1049 uiM.pushButton_executeAfterAdd -> setToolTip(tr("done editing"));
1050 uiM.pushButton_executeAfterAdd -> setIcon(QIcon(":/luckyPrefix/okay.png"));
1051 uiM.pushButton_executeAfterRemove -> setText(tr("cancel"));
1052 uiM.pushButton_executeAfterRemove -> setToolTip(tr("cancel editing"));
1053 uiM.pushButton_executeAfterRemove -> setIcon(QIcon(":/luckyPrefix/cancel.png"));
1054
1055 uiM.pushButton_editExecuteAfter -> setEnabled (false);
1056 uiM.pushButton_moveUpExecuteAfter -> setEnabled (false);
1057 uiM.pushButton_moveDownExecuteAfter -> setEnabled (false);
1058
1059 selectedText = (uiM.listWidget_executeAfter -> currentItem()) -> text(); //current list item text
1060 alsoExecuteState = uiM.listWidget_executeAfter -> currentItem() -> checkState(); // current list item check state
1061 uiM.lineEdit_executeAfterAdd -> setText (selectedText);
1062 uiM.lineEdit_executeAfterAdd -> setFocus();
1063 uiM.lineEdit_executeAfterAdd -> selectAll();
1064 break;
1065 }
1066 }
1067
1068 // List item move up button pressed=====================================================================================================
1069 // Moves an item within list, up one position
1070 void modifyDialog::moveListItemUp(const int type)
1071 {
1072 int selected;
1073 QListWidgetItem *tempItem;
1074 switch (type)
1075 {
1076 //exclude list
1077 case 0: selected = uiM.listWidget_exclude -> currentRow(); //current list row number
1078 if (selected < 0) //if nothing is selected do nothing
1079 return;
1080 if (selected > 0) //if this is not the first row proceed with swapping items
1081 {
1082 tempItem = uiM.listWidget_exclude -> takeItem(selected);
1083 uiM.listWidget_exclude -> insertItem (selected-1, tempItem);
1084 uiM.listWidget_exclude -> setCurrentRow (selected-1);
1085 }
1086 break;
1087 //include list
1088 case 1: selected = uiM.listWidget_include -> currentRow(); //current list row number
1089 if (selected < 0) //if nothing is selected do nothing
1090 return;
1091 if (selected > 0) //if this is not the first row proceed with swapping items
1092 {
1093 tempItem = uiM.listWidget_include -> takeItem(selected);
1094 uiM.listWidget_include -> insertItem (selected-1, tempItem);
1095 uiM.listWidget_include -> setCurrentRow (selected-1);
1096 }
1097 break;
1098 //options list
1099 case 2: selected = uiM.listWidget_options -> currentRow(); //current list row number
1100 if (selected < 0) //if nothing is selected do nothing
1101 return;
1102 if (selected > 0) //if this is not the first row proceed with swapping items
1103 {
1104 tempItem = uiM.listWidget_options -> takeItem(selected);
1105 uiM.listWidget_options -> insertItem (selected-1, tempItem);
1106 uiM.listWidget_options -> setCurrentRow (selected-1);
1107 }
1108 break;
1109 //execute before
1110 case 3: selected = uiM.listWidget_executeBefore -> currentRow(); //current list row number
1111 if (selected < 0) //if nothing is selected do nothing
1112 return;
1113 if (selected > 0) //if this is not the first row proceed with swapping items
1114 {
1115 tempItem = uiM.listWidget_executeBefore -> takeItem(selected);
1116 uiM.listWidget_executeBefore -> insertItem (selected-1, tempItem);
1117 uiM.listWidget_executeBefore -> setCurrentRow (selected-1);
1118 }
1119 break;
1120 //execute after
1121 case 4: selected = uiM.listWidget_executeAfter -> currentRow(); //current list row number
1122 if (selected < 0) //if nothing is selected do nothing
1123 return;
1124 if (selected > 0) //if this is not the first row proceed with swapping items
1125 {
1126 tempItem = uiM.listWidget_executeAfter -> takeItem(selected);
1127 uiM.listWidget_executeAfter -> insertItem (selected-1, tempItem);
1128 uiM.listWidget_executeAfter -> setCurrentRow (selected-1);
1129 }
1130 break;
1131 }
1132
1133 }
1134
1135 // List item move down button pressed=====================================================================================================
1136 // Moves an item within list, down one position
1137 void modifyDialog::moveListItemDown(const int type)
1138 {
1139 int selected, totalListItems;
1140 QListWidgetItem *tempItem;
1141 switch (type)
1142 {
1143 //exclude list
1144 case 0: selected = uiM.listWidget_exclude -> currentRow(); //current list row number
1145 totalListItems = uiM.listWidget_exclude -> count(); //total no of list items
1146 if (selected < 0) //if nothing is selected do nothing
1147 return;
1148 if (selected < totalListItems-1) //if this is not the last row proceed with swapping items
1149 {
1150 tempItem = uiM.listWidget_exclude -> takeItem(selected);
1151 uiM.listWidget_exclude -> insertItem (selected+1, tempItem);
1152 uiM.listWidget_exclude -> setCurrentRow (selected+1);
1153 }
1154 break;
1155 //include list
1156 case 1: selected = uiM.listWidget_include -> currentRow(); //current list row number
1157 totalListItems = uiM.listWidget_include -> count(); //total no of list items
1158 if (selected < 0) //if nothing is selected do nothing
1159 return;
1160 if (selected < totalListItems-1) //if this is not the last row proceed with swapping items
1161 {
1162 tempItem = uiM.listWidget_include -> takeItem(selected);
1163 uiM.listWidget_include -> insertItem (selected+1, tempItem);
1164 uiM.listWidget_include -> setCurrentRow (selected+1);
1165 }
1166 break;
1167 //options list
1168 case 2: selected = uiM.listWidget_options -> currentRow(); //current list row number
1169 totalListItems = uiM.listWidget_options -> count(); //total no of list items
1170 if (selected < 0) //if nothing is selected do nothing
1171 return;
1172 if (selected < totalListItems-1) //if this is not the last row proceed with swapping items
1173 {
1174 tempItem = uiM.listWidget_options -> takeItem(selected);
1175 uiM.listWidget_options -> insertItem (selected+1, tempItem);
1176 uiM.listWidget_options -> setCurrentRow (selected+1);
1177 }
1178 break;
1179 //execute before
1180 case 3: selected = uiM.listWidget_executeBefore -> currentRow(); //current list row number
1181 totalListItems = uiM.listWidget_executeBefore -> count(); //total no of list items
1182 if (selected < 0) //if nothing is selected do nothing
1183 return;
1184 if (selected < totalListItems-1) //if this is not the last row proceed with swapping items
1185 {
1186 tempItem = uiM.listWidget_executeBefore -> takeItem(selected);
1187 uiM.listWidget_executeBefore -> insertItem (selected+1, tempItem);
1188 uiM.listWidget_executeBefore -> setCurrentRow (selected+1);
1189 }
1190 break;
1191 //execute after
1192 case 4: selected = uiM.listWidget_executeAfter -> currentRow(); //current list row number
1193 totalListItems = uiM.listWidget_executeAfter -> count(); //total no of list items
1194 if (selected < 0) //if nothing is selected do nothing
1195 return;
1196 if (selected < totalListItems-1) //if this is not the last row proceed with swapping items
1197 {
1198 tempItem = uiM.listWidget_executeAfter -> takeItem(selected);
1199 uiM.listWidget_executeAfter -> insertItem (selected+1, tempItem);
1200 uiM.listWidget_executeAfter -> setCurrentRow (selected+1);
1201 }
1202 break;
1203 }
1204
1205 }
1206
1207 // Task type combobox changed=====================================================================================================
1208 // Enable/disable the "keep snapshots" spinbox
1209 void modifyDialog::TaskTypeChanged(int type)
1210 {
1211 if (type == 1)
1212 {
1213 uiM.label_snapshotsKeep -> setVisible(false);
1214 uiM.spinBox_snapshotsKeep -> setVisible(false);
1215 uiM.checkBox_backupContents -> setVisible(false);
1216 uiM.checkBox_deleteAfter -> setEnabled (false);
1217 }
1218 else
1219 {
1220 uiM.label_snapshotsKeep -> setVisible(true);
1221 uiM.spinBox_snapshotsKeep -> setVisible(true);
1222 uiM.checkBox_backupContents -> setVisible(true);
1223 uiM.checkBox_deleteAfter -> setEnabled (true);
1224 }
1225 }
1226 // Include tab stuff changed=====================================================================================================
1227 // Enable/disable the "exclude" tab
1228 void modifyDialog::disableExcludeTab()
1229 {
1230 bool enableIt = true;
1231
1232 // conditions to disable the exclude tab
1233 if ( ( (uiM.listWidget_include -> count() > 0) ||
1234 ((uiM.checkBox_includeFile->isChecked()) && ((uiM.lineEdit_includeFile->text()).size() >0)) ) &&
1235 (uiM.radioButton_includeOnly -> isChecked()) )
1236
1237 enableIt = false;
1238
1239 uiM.toolBox_exclude -> setEnabled (enableIt);
1240 }
1241
1242 //===================================================================================================================================================
1243 //------------------------------------------------------------------FUNCTIONS------------------------------------------------------------------------
1244 //===================================================================================================================================================
1245
1246 // fillOperationArray =====================================================================================================
1247 //function to fill the data of an operation array item from the window fields
1248 operation *modifyDialog::fillOperationArray()
1249 {
1250 operation *pTask = new operation;
1251
1252 //Before doing any changes, inherit last execution time & error as well as snapshots list from the existing task
1253 //if this is not a new task (modify task. NOT new/duplicate/restore task)
1254 if (!newTaskThisIs)
1255 {
1256 pTask -> SetLastExecutionTime (Operation[ArrayPosition] -> GetLastExecutionTime());
1257 pTask -> SetLastExecutionErrors (Operation[ArrayPosition] -> GetLastExecutionErrors());
1258 pTask -> SetSnapshotsList (Operation[ArrayPosition] -> GetSnapshotsList());
1259 }
1260
1261 //set operation name --------------------------------------------------------------------------------------------------------
1262 pTask -> SetName ( uiM.lineEdit_name -> text() );
1263
1264 // set connection ----------------------------------------------------------------------------
1265 pTask -> SetConnectRestore ("");
1266
1267 //set task description --------------------------------------------------------------------------------------------------------
1268 pTask -> SetDescription ( uiM.textEdit_Description -> toPlainText() );
1269
1270 // set operation type ------------------------------------------------------------------------------
1271 if (uiM.comboBox_Type -> currentIndex()==0)
1272 {
1273 if (uiM.checkBox_backupContents -> isChecked())
1274 {
1275 pTask -> SetTypeDirContents ( true );
1276 pTask -> SetTypeDirName ( false );
1277 pTask -> SetTypeSync ( false );
1278 }
1279 else
1280 {
1281 pTask -> SetTypeDirContents ( false );
1282 pTask -> SetTypeDirName ( true );
1283 pTask -> SetTypeSync ( false );
1284 }
1285 }
1286 if (uiM.comboBox_Type -> currentIndex()==1)
1287 {
1288 pTask -> SetTypeDirContents ( false );
1289 pTask -> SetTypeDirName ( false );
1290 pTask -> SetTypeSync ( true );
1291 uiM.spinBox_snapshotsKeep -> setValue (1); // also set the keep snapshots spinbox to "1" if it is a sync task
1292 }
1293
1294 // also set the keep snapshots spinbox to "1" if remote destination is used
1295 // Commended bacause remote snapshots are now supported - safely delete this
1296 //if ( (uiM.groupBox_remote -> isChecked()) && (uiM.radioButton_remoteDestination -> isChecked()) )
1297 // uiM.spinBox_snapshotsKeep -> setValue (1);
1298
1299 //set source & destination ------------------------------------------------------------------------------------------------
1300 pTask -> SetSource ( uiM.lineEdit_source -> text() );
1301 pTask -> SetDestination ( uiM.lineEdit_destination -> text() );
1302
1303 //set number of snapshots ------------------------------------------------------------------------------------------------
1304 pTask -> SetKeepSnapshots ( uiM.spinBox_snapshotsKeep -> value() );
1305
1306 //set exclude groupbox & all the info in there -----------------------------------------------------------------------------
1307 pTask -> SetExcludeTemp ( uiM.checkBox_excludeTemp -> isChecked() );
1308 pTask -> SetExcludeFromFile ( uiM.checkBox_excludeFile -> isChecked() );
1309 pTask -> SetExcludeFile ( uiM.lineEdit_excludeFile -> text() );
1310 pTask -> SetExcludeCache ( uiM.checkBox_excludeCache -> isChecked() );
1311 pTask -> SetExcludeBackup ( uiM.checkBox_excludeBackup -> isChecked() );
1312 pTask -> SetExcludeMount ( uiM.checkBox_excludeMount -> isChecked() );
1313 pTask -> SetExcludeLostFound ( uiM.checkBox_excludeLostFound -> isChecked() );
1314 pTask -> SetExcludeSystem ( uiM.checkBox_excludeSystem -> isChecked() );
1315 pTask -> SetExcludeTrash ( uiM.checkBox_excludeTrash -> isChecked() );
1316 pTask -> SetExcludeGVFS ( uiM.checkBox_excludeGVFS -> isChecked() );
1317
1318 count = 0; //read exclude list one by one
1319 while ( count < (uiM.listWidget_exclude -> count()) )
1320 {
1321 uiM.listWidget_exclude -> setCurrentRow(count);
1322 pTask -> AddExcludeListItem((uiM.listWidget_exclude -> currentItem()) -> text());
1323 count++;
1324 }
1325 pTask -> SetExclude ();
1326
1327 //set include groupbox & all the info in there -----------------------------------------------------------------------------
1328 pTask -> SetIncludeFromFile ( uiM.checkBox_includeFile -> isChecked() );
1329 pTask -> SetIncludeFile ( uiM.lineEdit_includeFile -> text() );
1330 pTask -> SetIncludeModeNormal ( uiM.radioButton_includeNormal -> isChecked() );
1331 count = 0; //read include list one by one
1332 while ( count < (uiM.listWidget_include -> count()) )
1333 {
1334 uiM.listWidget_include -> setCurrentRow(count);
1335 pTask -> AddIncludeListItem((uiM.listWidget_include -> currentItem()) -> text());
1336 count++;
1337 }
1338 pTask -> SetInclude();
1339
1340 //set remote groupbox & all the info in there -----------------------------------------------------------------------------
1341 pTask -> SetRemote ( uiM.groupBox_remote -> isChecked() );
1342 pTask -> SetRemoteModule ( uiM.checkBox_remoteModule -> isChecked() );
1343 pTask -> SetRemoteDestination ( uiM.radioButton_remoteDestination -> isChecked() );
1344 pTask -> SetRemoteSource ( uiM.radioButton_remoteSource -> isChecked() );
1345 pTask -> SetRemoteHost ( uiM.lineEdit_remoteHost -> text() );
1346 pTask -> SetRemoteUser ( uiM.lineEdit_remoteUser -> text() );
1347 pTask -> SetRemotePassword ( uiM.lineEdit_rsyncPassword -> text() );
1348 pTask -> SetRemoteSSH ( uiM.checkBox_ssh -> isChecked() );
1349 pTask -> SetRemoteSSHPassword ( uiM.lineEdit_sshPassword -> text() );
1350 pTask -> SetRemoteSSHPort ( (uiM.lineEdit_sshPort -> text()).toInt() );
1351 pTask -> SetRemoteSSHPasswordStr( uiM.lineEdit_sshPasswordStr -> text());
1352 pTask -> SetRemoteSSHOptions ( uiM.lineEdit_sshOptions -> text());
1353
1354 //set rsync options checkboxes -----------------------------------------------------------------------------------------------
1355 pTask -> SetOptionsUpdate ( uiM.checkBox_update -> isChecked() );
1356 pTask -> SetOptionsOwnership ( uiM.checkBox_ownership -> isChecked() );
1357 pTask -> SetOptionsSymlinks ( uiM.checkBox_symlinks -> isChecked() );
1358 pTask -> SetOptionsPermissions ( uiM.checkBox_permissions -> isChecked() );
1359 pTask -> SetOptionsDevices ( uiM.checkBox_devices -> isChecked() );
1360 pTask -> SetOptionsCVS ( uiM.checkBox_cvs -> isChecked() );
1361 pTask -> SetOptionsHardLinks ( uiM.checkBox_hardLinks -> isChecked() );
1362 pTask -> SetOptionsFATntfs ( uiM.checkBox_FATntfs -> isChecked() );
1363 pTask -> SetOptionsDelete ( uiM.checkBox_deleteAfter -> isChecked() );
1364 pTask -> SetOptionsRecurse ( uiM.checkBox_recurse -> isChecked() );
1365 pTask -> SetOptionsSuper ( uiM.checkBox_super -> isChecked() );
1366 pTask -> SetOptionsNumericIDs ( uiM.checkBox_numericIDs -> isChecked() );
1367 // windows related rsync options
1368 pTask -> SetOptionsRestorent ( uiM.checkBox_restorent -> isChecked() );
1369 pTask -> SetOptionsVss ( uiM.checkBox_vss -> isChecked() );
1370 pTask -> SetTempPath(tempDirPath);
1371 pTask -> SetLuckyBackupDir (luckyBackupDir);
1372 pTask -> SetVshadowDir (vshadowDir);
1373 pTask -> SetDosdevCommand (dosdevCommand);
1374 pTask -> SetCygpathCommand (cygpathCommand);
1375 pTask -> SetRsyncCommand (rsyncCommandPath);
1376 pTask -> SetSshCommand (sshCommandPath);
1377
1378 count = 0; //read options list one by one
1379 while ( count < (uiM.listWidget_options -> count()) )
1380 {
1381 uiM.listWidget_options -> setCurrentRow(count);
1382 pTask -> AddOptionsListItem((uiM.listWidget_options -> currentItem()) -> text());
1383 count++;
1384 }
1385 count = 0; //read execute before list one by one
1386 bool tempState;
1387 while ( count < (uiM.listWidget_executeBefore -> count()) )
1388 {
1389 uiM.listWidget_executeBefore -> setCurrentRow(count);
1390 pTask -> AddExecuteBeforeListItem((uiM.listWidget_executeBefore -> currentItem()) -> text());
1391 if ((uiM.listWidget_executeBefore -> currentItem()) -> checkState() == Qt::Checked)
1392 tempState = true; else tempState = false;
1393 pTask -> AddExecuteBeforeListItemState(tempState);
1394 count++;
1395 }
1396 count = 0; //read execute after list one by one
1397 while ( count < (uiM.listWidget_executeAfter -> count()) )
1398 {
1399 uiM.listWidget_executeAfter -> setCurrentRow(count);
1400 pTask -> AddExecuteAfterListItem((uiM.listWidget_executeAfter -> currentItem()) -> text());
1401 if ((uiM.listWidget_executeAfter -> currentItem()) -> checkState() == Qt::Checked)
1402 tempState = true; else tempState = false;
1403 pTask -> AddExecuteAfterListItemState(tempState);
1404 count++;
1405 }
1406 pTask -> SetByPassWARNING ( uiM.checkBox_byPassWarning -> isChecked() );
1407 pTask -> SetRepeatOnFail ( uiM.spinBox_repeatOnFail -> value() );
1408
1409 //append aguments -----------------------------------------------------------------------------------------------------------
1410 pTask -> SetArgs ( AppendArguments(pTask) );
1411
1412 return pTask;
1413 }
1414
1415 // fillModifyWindow =======================================================================================================
1416 //function to fill the window fields from the data of an operation array item
1417 void modifyDialog::fillModifyWindow(operation *pTask)
1418 {
1419 uiM.lineEdit_name -> setText (pTask -> GetName() );
1420
1421 uiM.textEdit_Description -> setPlainText (pTask -> GetDescription() );
1422
1423 if (pTask -> GetTypeDirContents())
1424 {
1425 uiM.comboBox_Type -> setCurrentIndex(0);
1426 uiM.checkBox_backupContents -> setCheckState(Qt::Checked);
1427 uiM.checkBox_deleteAfter -> setEnabled (true);
1428 }
1429 if (pTask -> GetTypeDirName())
1430 {
1431 uiM.comboBox_Type -> setCurrentIndex(0);
1432 uiM.checkBox_backupContents -> setCheckState(Qt::Unchecked);
1433 uiM.checkBox_deleteAfter -> setEnabled (true);
1434 }
1435 if (pTask -> GetTypeSync())
1436 {
1437 uiM.comboBox_Type -> setCurrentIndex(1);
1438 uiM.checkBox_deleteAfter -> setEnabled (false);
1439 }
1440
1441 uiM.lineEdit_source -> setText (pTask -> GetSource() );
1442 uiM.lineEdit_destination -> setText (pTask -> GetDestination() );
1443
1444 uiM.spinBox_snapshotsKeep -> setValue (pTask -> GetKeepSnapshots());
1445
1446 uiM.checkBox_excludeFile -> setChecked (pTask -> GetExcludeFromFile() );
1447 uiM.lineEdit_excludeFile -> setText (pTask -> GetExcludeFile() );
1448 uiM.checkBox_excludeTemp -> setChecked (pTask -> GetExcludeTemp() );
1449 uiM.checkBox_excludeCache -> setChecked (pTask -> GetExcludeCache() );
1450 uiM.checkBox_excludeBackup -> setChecked (pTask -> GetExcludeBackup() );
1451 uiM.checkBox_excludeMount -> setChecked (pTask -> GetExcludeMount() );
1452 uiM.checkBox_excludeLostFound -> setChecked (pTask -> GetExcludeLostFound() );
1453 uiM.checkBox_excludeSystem -> setChecked (pTask -> GetExcludeSystem() );
1454 uiM.checkBox_excludeTrash -> setChecked (pTask -> GetExcludeTrash() );
1455 uiM.checkBox_excludeGVFS -> setChecked (pTask -> GetExcludeGVFS() );
1456 count=0;
1457 while ( count < (pTask -> GetExcludeListSize()) )
1458 {
1459 uiM.listWidget_exclude -> addItem (pTask -> GetExcludeListItem(count));
1460 count++;
1461 }
1462
1463 uiM.checkBox_includeFile -> setChecked (pTask -> GetIncludeFromFile() );
1464 uiM.radioButton_includeNormal -> setChecked (pTask -> GetIncludeModeNormal() );
1465 uiM.radioButton_includeOnly -> setChecked (!pTask -> GetIncludeModeNormal() );
1466 uiM.lineEdit_includeFile -> setText (pTask -> GetIncludeFile() );
1467 count=0;
1468 while ( count < (pTask -> GetIncludeListSize()) )
1469 {
1470 uiM.listWidget_include -> addItem (pTask -> GetIncludeListItem(count));
1471 count++;
1472 }
1473
1474 uiM.groupBox_remote -> setChecked (pTask -> GetRemote() );
1475 uiM.checkBox_remoteModule -> setChecked (pTask -> GetRemoteModule() );
1476 uiM.radioButton_remoteDestination-> setChecked (pTask -> GetRemoteDestination() );
1477 uiM.radioButton_remoteSource -> setChecked (pTask -> GetRemoteSource() );
1478 uiM.lineEdit_remoteHost -> setText (pTask -> GetRemoteHost() );
1479 uiM.lineEdit_remoteUser -> setText (pTask -> GetRemoteUser() );
1480 uiM.lineEdit_rsyncPassword -> setText (pTask -> GetRemotePassword() );
1481 uiM.checkBox_ssh -> setChecked (pTask -> GetRemoteSSH() );
1482 uiM.lineEdit_sshPassword -> setText (pTask -> GetRemoteSSHPassword() );
1483 uiM.lineEdit_sshPasswordStr -> setText (pTask -> GetRemoteSSHPasswordStr() );
1484 uiM.lineEdit_sshOptions -> setText (pTask -> GetRemoteSSHOptions() );
1485 if (pTask -> GetRemoteSSHPort() == 0)
1486 uiM.lineEdit_sshPort -> setText ("");
1487 else
1488 uiM.lineEdit_sshPort -> setText (countStr.setNum(pTask -> GetRemoteSSHPort()) );
1489
1490 uiM.checkBox_update -> setChecked (pTask -> GetOptionsUpdate() );
1491 uiM.checkBox_deleteAfter -> setChecked (pTask -> GetOptionsDelete() );
1492 uiM.checkBox_recurse -> setChecked (pTask -> GetOptionsRecurse() );
1493 uiM.checkBox_ownership -> setChecked (pTask -> GetOptionsOwnership() );
1494 uiM.checkBox_symlinks -> setChecked (pTask -> GetOptionsSymlinks() );
1495 uiM.checkBox_permissions -> setChecked (pTask -> GetOptionsPermissions() );
1496 uiM.checkBox_devices -> setChecked (pTask -> GetOptionsDevices() );
1497 uiM.checkBox_cvs -> setChecked (pTask -> GetOptionsCVS() );
1498 uiM.checkBox_hardLinks -> setChecked (pTask -> GetOptionsHardLinks() );
1499 uiM.checkBox_FATntfs -> setChecked (pTask -> GetOptionsFATntfs() );
1500 uiM.checkBox_super -> setChecked (pTask -> GetOptionsSuper() );
1501 uiM.checkBox_numericIDs -> setChecked (pTask -> GetOptionsNumericIDs() );
1502
1503 uiM.checkBox_vss -> setChecked (pTask -> GetOptionsVss() );
1504 uiM.checkBox_restorent -> setChecked (pTask -> GetOptionsRestorent() );
1505
1506 count=0;
1507 while ( count < (pTask -> GetOptionsListSize()) )
1508 {
1509 uiM.listWidget_options -> addItem (pTask -> GetOptionsListItem(count));
1510 count++;
1511 }
1512 count=0;
1513 while ( count < (pTask -> GetExecuteBeforeListSize()) )
1514 {
1515 uiM.listWidget_executeBefore -> addItem (pTask -> GetExecuteBeforeListItem(count));
1516 uiM.listWidget_executeBefore -> setCurrentRow(uiM.listWidget_executeBefore -> count()-1);
1517 uiM.listWidget_executeBefore -> currentItem() -> setToolTip (alsoExecuteTooltip);
1518 if (pTask -> GetExecuteBeforeListItemState(count) == true)
1519 uiM.listWidget_executeBefore -> currentItem() -> setCheckState(Qt::Checked);
1520 else
1521 uiM.listWidget_executeBefore -> currentItem() -> setCheckState(Qt::Unchecked);
1522 count++;
1523 }
1524 count=0;
1525 while ( count < (pTask -> GetExecuteAfterListSize()) )
1526 {
1527 uiM.listWidget_executeAfter -> addItem (pTask -> GetExecuteAfterListItem(count));
1528 uiM.listWidget_executeAfter -> setCurrentRow(uiM.listWidget_executeAfter -> count()-1);
1529 uiM.listWidget_executeAfter -> currentItem() -> setToolTip (alsoExecuteTooltip);
1530 if (pTask -> GetExecuteAfterListItemState(count) == true)
1531 uiM.listWidget_executeAfter -> currentItem() -> setCheckState(Qt::Checked);
1532 else
1533 uiM.listWidget_executeAfter -> currentItem() -> setCheckState(Qt::Unchecked);
1534 count++;
1535 }
1536 uiM.checkBox_byPassWarning -> setChecked ( pTask -> GetByPassWARNING() );
1537 uiM.spinBox_repeatOnFail -> setValue ( pTask -> GetRepeatOnFail() );
1538 }
1539
1540 // modifyTrailing ===========================================================================================================
1541 // adds or removes a trailing "/" at the source & destination directory
1542 void modifyDialog::modifyTrailing()
1543 {
1544 // SLASH is "/" for *nix and windows and "\\" for OS2
1545
1546 QString sourceDir = uiM.lineEdit_source -> text();
1547 QString destDir = uiM.lineEdit_destination -> text();
1548
1549 // Check if a drive letter is declared at OS/2 or win (eg c:) and add a trailing slash
1550 if (notXnixRunning)
1551 {
1552 if (sourceDir.endsWith(":")) sourceDir.append(SLASH);
1553 if (destDir.endsWith(":")) destDir.append(SLASH);
1554 }
1555
1556 //Directory by contents - trailing slash at source & dest paths
1557 if ((uiM.comboBox_Type -> currentIndex()==0) && (uiM.checkBox_backupContents -> isChecked()))
1558 {
1559 if ( (!sourceDir.endsWith(XnixSLASH)) && (!sourceDir.endsWith(SLASH)) && (sourceDir != ""))
1560 {
1561 if (uiM.groupBox_remote -> isChecked() && uiM.radioButton_remoteSource -> isChecked())
1562 sourceDir.append(XnixSLASH);
1563 else
1564 sourceDir.append(SLASH);
1565 }
1566 if ( (!destDir.endsWith(XnixSLASH)) &&(!destDir.endsWith(SLASH)) && (destDir != ""))
1567 {
1568 if (uiM.groupBox_remote -> isChecked() && uiM.radioButton_remoteDestination -> isChecked())
1569 destDir.append(XnixSLASH);
1570 else
1571 destDir.append(SLASH);
1572 }
1573 }
1574
1575 //Directory by name - trailing slash only at dest path not source
1576 if ((uiM.comboBox_Type -> currentIndex()==0) && (!uiM.checkBox_backupContents -> isChecked()))
1577 {
1578 if (notXnixRunning) //OS2 & win
1579 {
1580 if ( (sourceDir.endsWith(SLASH)) && (!sourceDir.endsWith(":"+SLASH)) ) sourceDir.chop(1);
1581 if ( (!destDir.endsWith(XnixSLASH)) && (!destDir.endsWith(SLASH)) && (destDir != "") )
1582 {
1583 if (uiM.groupBox_remote -> isChecked() && uiM.radioButton_remoteDestination -> isChecked())
1584 destDir.append(XnixSLASH);
1585 else
1586 destDir.append(SLASH);
1587 }
1588 }
1589 else //linux-unix
1590 {
1591 if ( (sourceDir.endsWith(SLASH)) && (sourceDir != SLASH) ) sourceDir.chop(1);
1592 if ( (!destDir.endsWith(SLASH)) && (destDir != "") ) destDir.append(SLASH);
1593 }
1594 }
1595
1596 if (uiM.comboBox_Type -> currentIndex()==1) //sync Directories - both paths have to have a trailing slash
1597 {
1598 if ((!sourceDir.endsWith(XnixSLASH)) && (!sourceDir.endsWith(SLASH)) && (sourceDir != ""))
1599 {
1600 if (uiM.groupBox_remote -> isChecked() && uiM.radioButton_remoteSource -> isChecked())
1601 sourceDir.append(XnixSLASH);
1602 else
1603 sourceDir.append(SLASH);
1604 }
1605 if ( (!destDir.endsWith(XnixSLASH)) &&(!destDir.endsWith(SLASH)) && (destDir != ""))
1606 {
1607 if (uiM.groupBox_remote -> isChecked() && uiM.radioButton_remoteDestination -> isChecked())
1608 destDir.append(XnixSLASH);
1609 else
1610 destDir.append(SLASH);
1611 }
1612
1613 uiM.checkBox_deleteAfter -> setChecked (false);
1614 uiM.checkBox_update -> setChecked (true);
1615 uiM.checkBox_ownership -> setChecked (true);
1616 uiM.checkBox_permissions -> setChecked (true);
1617 }
1618
1619 /*if (WINrunning) // some more adjustments for windows when the user wants to declare directly paths with "/" instead of "\" (normally for remote)
1620 {
1621 if (sourceDir.contains("/")) sourceDir.replace(SLASH,"/");
1622 if (sourceDir.endsWith("//")) sourceDir.chop(1);
1623 if (destDir.contains("/")) destDir.replace(SLASH,"/");
1624 if (destDir.endsWith("//")) destDir.chop(1);
1625 }*/
1626
1627 uiM.lineEdit_source -> setText(sourceDir);
1628 uiM.lineEdit_destination -> setText(destDir);
1629 }
1630
1631 // modifyOS2Slashes ===========================================================================================================
1632 // function to change / to \ for OS2 (normaly when file dialog is used)
1633 QString modifyDialog::modifyOS2Slashes(QString pathToModify)
1634 {
1635 if ( (notXnixRunning) && !pathToModify.startsWith("/") )
1636 pathToModify.replace("/",SLASH);
1637
1638 return pathToModify;
1639 }
1640
1641
1642 // stripInvalidCharacters =============================================================================================================================
1643 // Replaces all invalid filename characters from a QString with "-"
1644 QString modifyDialog::stripInvalidCharacters(QString stringToStrip)
1645 {
1646 QString stripedString = stringToStrip;
1647 QStringList invalidChars;
1648 invalidChars << "/" << "\\" << ":" << "*" << "?" << "\"" << "<" << ">" << "|";
1649
1650 foreach (QString charToRemove, invalidChars)
1651 stripedString.replace(charToRemove, "", Qt::CaseSensitive);
1652
1653 return stripedString;
1654 }
1655 // end of modifyDialog.cpp ---------------------------------------------------------------------------
1656