")+ ": ");
uiG.pushButton_viewLog -> setToolTip(tr("View the logfile of the selected sync task","'view log' pushbutton tooltip"));
deleteVisible = false;
restoreVisible = false;
uiG.checkBox_viewSource -> setVisible(false);
}
// hide or show the treebrowsers - textbrowser
uiG.textBrowser_snapshot -> setVisible (false);
uiG.treeView_browser -> setVisible (destVisible);
uiG.label_destError -> setVisible (!destVisible);
hideSourceStuff();
//enable/disable the pushbuttons
uiG.pushButton_viewLog -> setEnabled(viewLogVisible);
uiG.pushButton_calculate_diffs -> setEnabled(destVisible);
// Enable the delete button only for the first snapshot in list
if (CurrentSnapshotNo > 0)
deleteVisible = false;
uiG.pushButton_delete -> setEnabled(deleteVisible);
uiG.pushButton_restore -> setEnabled(restoreVisible);
}
// hideSourceStuff =====================================================================================================================
// hides/shows the source treebrowser & label
void manageDialog::hideSourceStuff()
{
// Check the state of the "hide source" checkbox
bool boxState = uiG.checkBox_viewSource -> isChecked();
if (boxState)
{
uiG.label_source -> setVisible(false);
uiG.lineEdit_source -> setVisible(false);
uiG.label_sourceError -> setVisible (false);
uiG.treeView_source -> setVisible (false);
}
else
{
uiG.label_source -> setVisible(true);
uiG.lineEdit_source -> setVisible(true);
uiG.treeView_source -> setVisible (sourceVisible);
uiG.label_sourceError -> setVisible (!sourceVisible);
}
}
// SnapshotsListSelected =====================================================================================================================
// disables pushbuttons when nothing is selected at snapshots listwidget
// Also sets QString CurrentSnapshotString at current snapshot, format YYYY
void manageDialog::SnapshotsListSelected()
{
CurrentSnapshotNo = uiG.listWidget_dates -> currentRow();
// if a snapshot is not selected
if (CurrentSnapshotNo < 0)
{
CurrentSnapshotString = "";
CurrentSnapshotDirectory = "";
}
else
{
CurrentSnapshotString = Operation[currentOperation] -> GetSnapshotsListItem (CurrentSnapshotNo);
if (WINrunning && Operation[currentOperation] -> GetRemote())
CurrentSnapshotDirectory = dest + snapDefaultDir.replace(SLASH,XnixSLASH) + CurrentSnapshotString + XnixSLASH + sourceLast;
else
CurrentSnapshotDirectory = dest + snapDefaultDir + CurrentSnapshotString + SLASH + sourceLast;
if (CurrentSnapshotString == "") // if there is no execution time of the current snapshot
CurrentSnapshotString = "not available";
}
fixGui(); // update the gui
}
// calculateDifferences() ========================================================================================
// calculate differences between source and snapshot
// Calls readDirEntries()
void manageDialog::calculateDifferences()
{
// if the thread is running (meaning: STOP is pressed)
if (calcdiffthread -> isRunning())
{
uiG.textBrowser_snapshot -> setText (tr("Please wait until the thread is terminated"));
uiG.pushButton_calculate_diffs -> setEnabled(false);
calcdiffthread -> setAbort(true);
abortCalcThread = true;
return;
}
// change the gui a bit
if (syncTYPE)
{
uiG.label_source -> setVisible(false);
uiG.lineEdit_source -> setVisible(false);
uiG.treeView_source -> setVisible (false);
}
uiG.treeView_browser -> setVisible (false);
uiG.textBrowser_snapshot -> setVisible (true);
if (!snapCalculated.at(CurrentSnapshotNo)) // if the differences have not been calculated yet
{
//disable some gui stuff during calculations
uiG.pushButton_delete -> setEnabled(false);
uiG.pushButton_restore -> setEnabled(false);
uiG.pushButton_viewLog -> setEnabled(false);
uiG.pushButton_cancel -> setEnabled(false);
uiG.pushButton_calculate_diffs -> setText(tr("STOP"));
uiG.pushButton_calculate_diffs -> setToolTip(tr("Stop calculations NOW"));
calcdiffthread -> passParams(dest, dest, CurrentSnapshotDirectory, CurrentSnapshotString, sourceLast, source, CurrentSnapshotNo, currentSnaps, syncTYPE);
calcdiffthread -> start();
}
else
uiG.textBrowser_snapshot -> setText (calculatedDifferences.at(CurrentSnapshotNo));
}
// calcDiffEnd =====================================================================================================================
// // diffs have been calculated - update viewer with new text
void manageDialog::calcDiffEnd()
{
// Update the textBrowser_snapshot with differences data
calculatedDifferences.replace(CurrentSnapshotNo, calcdiffthread -> returnResult() );
uiG.textBrowser_snapshot -> setText (calculatedDifferences.at(CurrentSnapshotNo));
if (abortCalcThread)
uiG.textBrowser_snapshot -> append ("" + tr("Calculations terminated by user") + "
");
else
snapCalculated.replace(CurrentSnapshotNo, true );
abortCalcThread = false;
calcdiffthread -> setAbort(false);
// re-enable gui stuff
uiG.pushButton_delete -> setEnabled(deleteVisible);
uiG.pushButton_restore -> setEnabled(restoreVisible);
uiG.pushButton_viewLog -> setEnabled(viewLogVisible);
uiG.pushButton_cancel -> setEnabled(true);
uiG.pushButton_calculate_diffs -> setEnabled(true);
uiG.pushButton_calculate_diffs -> setText(tr("Calculate differences"));
uiG.pushButton_calculate_diffs -> setToolTip(tr("Calculate the differences between the source and the selected snapshot"));
}
// FUNCTIONS-------------------------------------------------------------------------------------
// refreshDifWindow =====================================================================================================
//Refresh the calc diff window with text
void manageDialog::refreshDifWindow(const QString &newText, const bool &appendText)
{
if (appendText)
uiG.textBrowser_snapshot -> append(newText);
else
uiG.textBrowser_snapshot -> setText(newText);
// QCoreApplication::processEvents();
}
// updateSnapshots =====================================================================================================================
// update the snapshots date & times listwidget
void manageDialog::updateSnapshots()
{
//clear the listWidget
uiG.listWidget_dates -> clear();
calculatedDifferences.clear(); // this holds the calculated differences text for each snapshot
snapCalculated.clear();
//initialize snapshot variables
currentSnaps = Operation[currentOperation] -> GetSnapshotsListSize(); // this is the current number of snapshots
bool emptySnapList = Operation[currentOperation] -> SnapshotsListIsEmpty(); // Is the list empty ??
// first check if there is a last execution time available but no snapshots are declared
// and add a new snapshot with the last execution date-time
time = ( Operation[currentOperation] -> GetLastExecutionTime() ).toString("yyyyMMddhhmmss");
if ( !(time == "") && (emptySnapList) )
{
Operation[currentOperation] -> AddSnapshotsListItem (time);
currentSnaps = Operation[currentOperation] -> GetSnapshotsListSize(); // this is the current number of snapshots
emptySnapList = Operation[currentOperation] -> SnapshotsListIsEmpty(); // Is the list empty ??
}
//update the listwidget with times from snapshots
count=0;
while (count < currentSnaps)
{
QDateTime currentSnapTime = QDateTime::fromString(Operation[currentOperation]-> GetSnapshotsListItem(count),"yyyyMMddhhmmss");
if ((Operation[currentOperation]-> GetSnapshotsListItem(count)) == "") // if there is no snapshot time for a reason
uiG.listWidget_dates -> addItem (tr("not available","refers to a date-time"));
else
uiG.listWidget_dates -> addItem (currentSnapTime.toString("yyyy/MM/dd - hh:mm:ss"));
calculatedDifferences.append("");
snapCalculated.append(false);
count++;
}
if (emptySnapList)
{
uiG.listWidget_dates -> addItem (tr("not available","refers to a date-time"));
calculatedDifferences.append("");
snapCalculated.append(false);
}
// select the latest snapshot
uiG.listWidget_dates -> setCurrentRow(uiG.listWidget_dates -> count() - 1);
}
// end of manage.cpp ---------------------------------------------------------------------------