diff options
Diffstat (limited to 'plugins/CopyEngine/Ultracopier-0.3/factory.cpp')
-rw-r--r-- | plugins/CopyEngine/Ultracopier-0.3/factory.cpp | 188 |
1 files changed, 178 insertions, 10 deletions
diff --git a/plugins/CopyEngine/Ultracopier-0.3/factory.cpp b/plugins/CopyEngine/Ultracopier-0.3/factory.cpp index be53272..642a05b 100644 --- a/plugins/CopyEngine/Ultracopier-0.3/factory.cpp +++ b/plugins/CopyEngine/Ultracopier-0.3/factory.cpp @@ -9,8 +9,6 @@ #include "factory.h" -/// \todo connect in global options the change - Factory::Factory() : ui(new Ui::options()) { @@ -18,6 +16,8 @@ Factory::Factory() : ui->setupUi(tempWidget); errorFound=false; optionsEngine=NULL; + filters=new Filters(tempWidget); + renamingRules=new RenamingRules(tempWidget); #if defined (Q_OS_WIN32) QFileInfoList temp=QDir::drives(); for (int i = 0; i < temp.size(); ++i) { @@ -31,23 +31,41 @@ Factory::Factory() : connect(&mount,SIGNAL(readyReadStandardError()), this,SLOT(readyReadStandardError())); mount.start("mount"); #endif - connect(ui->doRightTransfer, SIGNAL(toggled(bool)), this,SLOT(setDoRightTransfer(bool))); - connect(ui->keepDate, SIGNAL(toggled(bool)), this,SLOT(setKeepDate(bool))); - connect(ui->blockSize, SIGNAL(valueChanged(int)), this,SLOT(setBlockSize(int))); - connect(ui->autoStart, SIGNAL(toggled(bool)), this,SLOT(setAutoStart(bool))); + connect(ui->doRightTransfer, SIGNAL(toggled(bool)), this,SLOT(setDoRightTransfer(bool))); + connect(ui->keepDate, SIGNAL(toggled(bool)), this,SLOT(setKeepDate(bool))); + connect(ui->blockSize, SIGNAL(valueChanged(int)), this,SLOT(setBlockSize(int))); + connect(ui->autoStart, SIGNAL(toggled(bool)), this,SLOT(setAutoStart(bool))); + connect(ui->doChecksum, SIGNAL(toggled(bool)), this,SLOT(doChecksum_toggled(bool))); + connect(ui->checksumIgnoreIfImpossible, SIGNAL(toggled(bool)), this,SLOT(checksumIgnoreIfImpossible_toggled(bool))); + connect(ui->checksumOnlyOnError, SIGNAL(toggled(bool)), this,SLOT(checksumOnlyOnError_toggled(bool))); + connect(ui->osBuffer, SIGNAL(toggled(bool)), this,SLOT(osBuffer_toggled(bool))); + connect(ui->osBufferLimited, SIGNAL(toggled(bool)), this,SLOT(osBufferLimited_toggled(bool))); + connect(ui->osBufferLimit, SIGNAL(editingFinished()), this,SLOT(osBufferLimit_editingFinished())); + + connect(filters,SIGNAL(sendNewFilters(QStringList,QStringList,QStringList,QStringList)),this,SLOT(sendNewFilters(QStringList,QStringList,QStringList,QStringList))); + connect(ui->filters,SIGNAL(clicked()),this,SLOT(showFilterDialog())); + connect(renamingRules,SIGNAL(sendNewRenamingRules(QString,QString)),this,SLOT(sendNewRenamingRules(QString,QString))); + connect(ui->renamingRules,SIGNAL(clicked()),this,SLOT(showRenamingRules())); + + ui->osBufferLimit->setEnabled(ui->osBuffer->isChecked() && ui->osBufferLimited->isChecked()); } Factory::~Factory() { + delete renamingRules; + delete filters; delete ui; } PluginInterface_CopyEngine * Factory::getInstance() { copyEngine *realObject=new copyEngine(facilityEngine); + #ifdef ULTRACOPIER_PLUGIN_DEBUG + connect(realObject,SIGNAL(debugInformation(DebugLevel,QString,QString,QString,int)),this,SIGNAL(debugInformation(DebugLevel,QString,QString,QString,int))); + #endif + realObject->connectTheSignalsSlots(); realObject->setDrive(mountSysPoint); PluginInterface_CopyEngine * newTransferEngine=realObject; - connect(newTransferEngine,SIGNAL(debugInformation(DebugLevel,QString,QString,QString,int)),this,SIGNAL(debugInformation(DebugLevel,QString,QString,QString,int))); connect(this,SIGNAL(reloadLanguage()),newTransferEngine,SLOT(newLanguageLoaded())); realObject->setRightTransfer( optionsEngine->getOptionValue("doRightTransfer").toBool()); realObject->setKeepDate( optionsEngine->getOptionValue("keepDate").toBool()); @@ -56,6 +74,19 @@ PluginInterface_CopyEngine * Factory::getInstance() realObject->on_comboBoxFolderColision_currentIndexChanged(ui->comboBoxFolderColision->currentIndex()); realObject->on_comboBoxFolderError_currentIndexChanged(ui->comboBoxFolderError->currentIndex()); realObject->setCheckDestinationFolderExists( optionsEngine->getOptionValue("checkDestinationFolder").toBool()); + + realObject->set_doChecksum(optionsEngine->getOptionValue("doChecksum").toBool()); + realObject->set_checksumIgnoreIfImpossible(optionsEngine->getOptionValue("checksumIgnoreIfImpossible").toBool()); + realObject->set_checksumOnlyOnError(optionsEngine->getOptionValue("checksumOnlyOnError").toBool()); + realObject->set_osBuffer(optionsEngine->getOptionValue("osBuffer").toBool()); + realObject->set_osBufferLimited(optionsEngine->getOptionValue("osBufferLimited").toBool()); + realObject->set_osBufferLimit(optionsEngine->getOptionValue("osBufferLimit").toUInt()); + realObject->set_setFilters(optionsEngine->getOptionValue("includeStrings").toStringList(), + optionsEngine->getOptionValue("includeOptions").toStringList(), + optionsEngine->getOptionValue("excludeStrings").toStringList(), + optionsEngine->getOptionValue("excludeOptions").toStringList() + ); + realObject->setRenamingRules(optionsEngine->getOptionValue("firstRenamingRule").toString(),optionsEngine->getOptionValue("otherRenamingRule").toString()); return newTransferEngine; } @@ -95,6 +126,22 @@ void Factory::setResources(OptionInterface * options,const QString &writePath,co KeysList.append(qMakePair(QString("folderError"),QVariant(0))); KeysList.append(qMakePair(QString("folderColision"),QVariant(0))); KeysList.append(qMakePair(QString("checkDestinationFolder"),QVariant(true))); + KeysList.append(qMakePair(QString("includeStrings"),QVariant(QStringList()))); + KeysList.append(qMakePair(QString("includeOptions"),QVariant(QStringList()))); + KeysList.append(qMakePair(QString("excludeStrings"),QVariant(QStringList()))); + KeysList.append(qMakePair(QString("excludeOptions"),QVariant(QStringList()))); + KeysList.append(qMakePair(QString("doChecksum"),QVariant(true))); + KeysList.append(qMakePair(QString("checksumIgnoreIfImpossible"),QVariant(true))); + KeysList.append(qMakePair(QString("checksumOnlyOnError"),QVariant(true))); + KeysList.append(qMakePair(QString("osBuffer"),QVariant(true))); + KeysList.append(qMakePair(QString("firstRenamingRule"),QVariant(""))); + KeysList.append(qMakePair(QString("otherRenamingRule"),QVariant(""))); + #ifdef Q_OS_WIN32 + KeysList.append(qMakePair(QString("osBufferLimited"),QVariant(true))); + #else + KeysList.append(qMakePair(QString("osBufferLimited"),QVariant(false))); + #endif + KeysList.append(qMakePair(QString("osBufferLimit"),QVariant(512))); optionsEngine->addOptionGroup(KeysList); #if ! defined (Q_CC_GNU) ui->keepDate->setEnabled(false); @@ -102,11 +149,23 @@ void Factory::setResources(OptionInterface * options,const QString &writePath,co #endif ui->doRightTransfer->setChecked(optionsEngine->getOptionValue("doRightTransfer").toBool()); ui->keepDate->setChecked(optionsEngine->getOptionValue("keepDate").toBool()); - ui->blockSize->setValue(optionsEngine->getOptionValue("blockSize").toInt()); + ui->blockSize->setValue(optionsEngine->getOptionValue("blockSize").toUInt()); ui->autoStart->setChecked(optionsEngine->getOptionValue("autoStart").toBool()); - ui->comboBoxFolderError->setCurrentIndex(optionsEngine->getOptionValue("folderError").toInt()); - ui->comboBoxFolderColision->setCurrentIndex(optionsEngine->getOptionValue("folderColision").toInt()); + ui->comboBoxFolderError->setCurrentIndex(optionsEngine->getOptionValue("folderError").toUInt()); + ui->comboBoxFolderColision->setCurrentIndex(optionsEngine->getOptionValue("folderColision").toUInt()); ui->checkBoxDestinationFolderExists->setChecked(optionsEngine->getOptionValue("checkDestinationFolder").toBool()); + ui->doChecksum->setChecked(optionsEngine->getOptionValue("doChecksum").toBool()); + ui->checksumIgnoreIfImpossible->setChecked(optionsEngine->getOptionValue("checksumIgnoreIfImpossible").toBool()); + ui->checksumOnlyOnError->setChecked(optionsEngine->getOptionValue("checksumOnlyOnError").toBool()); + ui->osBuffer->setChecked(optionsEngine->getOptionValue("osBuffer").toBool()); + ui->osBufferLimited->setChecked(optionsEngine->getOptionValue("osBufferLimited").toBool()); + ui->osBufferLimit->setValue(optionsEngine->getOptionValue("osBufferLimit").toUInt()); + filters->setFilters(optionsEngine->getOptionValue("includeStrings").toStringList(), + optionsEngine->getOptionValue("includeOptions").toStringList(), + optionsEngine->getOptionValue("excludeStrings").toStringList(), + optionsEngine->getOptionValue("excludeOptions").toStringList() + ); + renamingRules->setRenamingRules(optionsEngine->getOptionValue("firstRenamingRule").toString(),optionsEngine->getOptionValue("otherRenamingRule").toString()); } } @@ -233,7 +292,116 @@ void Factory::newLanguageLoaded() { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start, retranslate the widget options"); ui->retranslateUi(tempWidget); + if(optionsEngine!=NULL) + { + filters->newLanguageLoaded(); + renamingRules->newLanguageLoaded(); + } emit reloadLanguage(); } Q_EXPORT_PLUGIN2(copyEngine, Factory); + +void Factory::doChecksum_toggled(bool doChecksum) +{ + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"the checkbox have changed"); + if(optionsEngine!=NULL) + optionsEngine->setOptionValue("doChecksum",doChecksum); + else + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"internal error, crash prevented"); +} + +void Factory::checksumOnlyOnError_toggled(bool checksumOnlyOnError) +{ + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"the checkbox have changed"); + if(optionsEngine!=NULL) + optionsEngine->setOptionValue("checksumOnlyOnError",checksumOnlyOnError); + else + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"internal error, crash prevented"); +} + +void Factory::osBuffer_toggled(bool osBuffer) +{ + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"the checkbox have changed"); + if(optionsEngine!=NULL) + optionsEngine->setOptionValue("osBuffer",osBuffer); + else + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"internal error, crash prevented"); + ui->osBufferLimit->setEnabled(ui->osBuffer->isChecked() && ui->osBufferLimited->isChecked()); +} + +void Factory::osBufferLimited_toggled(bool osBufferLimited) +{ + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"the checkbox have changed"); + if(optionsEngine!=NULL) + optionsEngine->setOptionValue("osBufferLimited",osBufferLimited); + else + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"internal error, crash prevented"); + ui->osBufferLimit->setEnabled(ui->osBuffer->isChecked() && ui->osBufferLimited->isChecked()); +} + +void Factory::osBufferLimit_editingFinished() +{ + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"the spinbox have changed"); + if(optionsEngine!=NULL) + optionsEngine->setOptionValue("osBufferLimit",ui->osBufferLimit->value()); + else + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"internal error, crash prevented"); +} + +void Factory::showFilterDialog() +{ + if(optionsEngine==NULL) + { + QMessageBox::critical(NULL,tr("Options error"),tr("Options engine is not loaded, can't access to the filters")); + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"options not loaded"); + return; + } + filters->exec(); +} + +void Factory::sendNewFilters(QStringList includeStrings,QStringList includeOptions,QStringList excludeStrings,QStringList excludeOptions) +{ + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"new filter"); + if(optionsEngine!=NULL) + { + optionsEngine->setOptionValue("includeStrings",includeStrings); + optionsEngine->setOptionValue("includeOptions",includeOptions); + optionsEngine->setOptionValue("excludeStrings",excludeStrings); + optionsEngine->setOptionValue("excludeOptions",excludeOptions); + } + else + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"internal error, crash prevented"); +} + +void Factory::sendNewRenamingRules(QString firstRenamingRule,QString otherRenamingRule) +{ + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"new filter"); + if(optionsEngine!=NULL) + { + optionsEngine->setOptionValue("firstRenamingRule",firstRenamingRule); + optionsEngine->setOptionValue("otherRenamingRule",otherRenamingRule); + } + else + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"internal error, crash prevented"); +} + +void Factory::showRenamingRules() +{ + if(optionsEngine==NULL) + { + QMessageBox::critical(NULL,tr("Options error"),tr("Options engine is not loaded, can't access to the filters")); + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"options not loaded"); + return; + } + renamingRules->exec(); +} + +void Factory::checksumIgnoreIfImpossible_toggled(bool checksumIgnoreIfImpossible) +{ + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"the checkbox have changed"); + if(optionsEngine!=NULL) + optionsEngine->setOptionValue("checksumIgnoreIfImpossible",checksumIgnoreIfImpossible); + else + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"internal error, crash prevented"); +} |