//=========================================== // Lumina-DE source code // Copyright (c) 2014, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== #include "FODialog.h" #include "ui_FODialog.h" #include FODialog::FODialog(QWidget *parent) : QDialog(parent), ui(new Ui::FODialog){ ui->setupUi(this); //load the designer file ui->label->setText(tr("Calculating")); ui->progressBar->setVisible(false); ui->push_stop->setIcon( LXDG::findIcon("edit-delete","") ); //Now set the internal defaults isRM = isCP = isRESTORE = isMV = stopped = noerrors = false; overwrite = -1; //set to automatic by default this->show(); } FODialog::~FODialog(){ stopped = true; //just in case it might still be running when closed } void FODialog::setOverwrite(bool ovw){ if(ovw){ overwrite = 1; } else{ overwrite = 0; } } //Public "start" functions void FODialog::RemoveFiles(QStringList paths){ ofiles = paths; isRM = true; QTimer::singleShot(10,this, SLOT(slotStartOperations())); } void FODialog::CopyFiles(QStringList oldPaths, QStringList newPaths){ //same permissions as old files if(oldPaths.length() == newPaths.length()){ ofiles = oldPaths; nfiles = newPaths; } isCP=true; QTimer::singleShot(10,this, SLOT(slotStartOperations())); } void FODialog::RestoreFiles(QStringList oldPaths, QStringList newPaths){ //user/group rw permissions if(oldPaths.length() == newPaths.length()){ ofiles = oldPaths; nfiles = newPaths; } isRESTORE = true; QTimer::singleShot(10,this, SLOT(slotStartOperations())); } void FODialog::MoveFiles(QStringList oldPaths, QStringList newPaths){ //no change in permissions if(oldPaths.length() == newPaths.length()){ ofiles = oldPaths; nfiles = newPaths; } isMV=true; QTimer::singleShot(10,this, SLOT(slotStartOperations())); } // ==== PRIVATE ==== QStringList FODialog::subfiles(QString dirpath, bool dirsfirst){ //NOTE: dirpath (input) is always the first/last item in the output as well! QStringList out; if(dirsfirst){ out << dirpath; } if( QFileInfo(dirpath).isDir() ){ QDir dir(dirpath); if(dirsfirst){ //Now recursively add any subdirectories and their contents QStringList subdirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden, QDir::NoSort); for(int i=0; i