+ connectSignals();
+}
+
+void MediaImagePathMainDialog::initProgressDialog()
+{
+ progressDialog = new QProgressDialog(this);
+ progressDialog->setWindowTitle(tr("Scanning files"));
+ progressDialog->setCancelButtonText(tr("Abort"));
+ progressDialog->setWindowModality(Qt::WindowModal);
+}
+
+void MediaImagePathMainDialog::connectSignals()
+{
+ DbObjectDialog::connectSignals();
+ connect(scanButton, SIGNAL(clicked()), this, SLOT(beginScanFilePath()));
+ connect(fileUtil, SIGNAL(dbUpdateFinished()), this, SLOT(hideDbUpdating()));
+ connect(fileUtil, SIGNAL(dbUpdateInProgress()), this, SLOT(showDbUpdating()));
+}
+
+void MediaImagePathMainDialog::showDbUpdating()
+{
+ qDebug() << "DB updating";
+ // TODO: the following is not currently working
+ progressDialog->setWindowTitle(tr("Updating DB... please wait!"));
+ progressDialog->setEnabled(false);
+}
+
+void MediaImagePathMainDialog::hideDbUpdating()
+{
+ qDebug() << "DB update finished";
+ // TODO: the following is not currently working
+ progressDialog->setEnabled(true);
+ progressDialog->setWindowTitle(tr("Scanning files"));
+}
+
+
+void MediaImagePathMainDialog::initEditDialog()
+{
+ nameDialog = new MediaImagePathDialog(this, dynamic_cast<FilePathObject*>(dbObject));
+ connectNameDialogSignals();
+}
+
+void MediaImagePathMainDialog::beginScanFilePath()
+{
+ QModelIndex index = objectList->currentIndex();
+ if (!index.isValid()) return;
+ if (QMessageBox::question(this,
+ tr("Confirm"),
+ tr("Do you want to continue? "
+ "If you have tons of huge files this may take even hours! "
+ "If you are low on battery power, consider carefully!"),
+ QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton ) == QMessageBox::No) {
+ return;
+ }
+ FilePathObject *fpo = 0;
+ try
+ {
+ EmuFrontObject *ob = dbManager->getDataObjectFromModel(&index); // throws EmuFrontException
+ if (!ob) return;
+ fpo = dynamic_cast<FilePathObject*>(ob);
+ if (!fpo) return;
+ QStringList l;
+ l << "*.zip"; // TODO set filters in a global constant class
+
+ dbMediaImageContainer->removeFromFilePath(fpo->getId());
+
+ progressDialog->show();
+ progressDialog->setEnabled(true);
+
+ setUIEnabled(false);
+ int count = fileUtil->scanFilePath(fpo, l, dbMediaImageContainer, progressDialog);
+ progressDialog->hide();
+
+ QMessageBox msgBox;
+ msgBox.setText(tr("Scanned %1 files to database.").arg(count));
+ msgBox.exec();
+ DbFilePath *dbfp = dynamic_cast<DbFilePath*>(dbManager);
+ if (!(dbfp && dbfp->setScanned(fpo)))
+ throw EmuFrontException(tr("Failed updating the last scanned time stamp for selected file path!"));
+ else updateList();
+ }
+ catch (EmuFrontException s)
+ {
+ errorMessage->showMessage( s.what() );
+ }
+ setUIEnabled(true);
+ delete fpo;
+ fpo = 0;