void ImageImporter::slotImport() { //first save all slotSaveSettings(); //then init the regular expression QRegExp re(m_txtSourceFilename->text(), !m_chkIgnoreCase->isChecked()); //first find all possible files //listdir is used as a stack containing the directories to parse QStringList lstDirs = m_cmbSourceFolder->currentText(); //the list of files found in the directories QFileInfoList lstFiles; lstFiles.setAutoDelete(true); DlgImageImporterStatus* dlgStatus = new DlgImageImporterStatus(this, "StatusDialog"); dlgStatus->enableImageArchive(m_groupArchive->isChecked()); dlgStatus->show(); dlgStatus->appendStatusMessage(i18n("Starting...")); dlgStatus->setCurrentMode( DlgImageImporterStatus::ModeImport, i18n("Scanning for available Images...")); //now go thru all folders and collect all files that match the file regexp... while (!lstDirs.isEmpty()) { QDir d( lstDirs.front() ); lstDirs.pop_front(); dlgStatus->addFolder(); d.setMatchAllDirs(true); const QFileInfoList* list = d.entryInfoList(); if (list) { QFileInfoListIterator it( *list ); QFileInfo* fi; for ( ; ( fi = it.current() ) != 0; ++it ) { if ( fi->fileName() == "." || fi->fileName() == ".." ) { continue; } else if ( fi->isDir() && m_chkSrcIncludeSubfolders->isChecked()) { lstDirs.append(fi->absFilePath()); } else if( fi->isFile() ) { dlgStatus->addFile(); if (re.exactMatch(fi->fileName())) { dlgStatus->addMatch(); //save a copy of all FileInfos lstFiles.append(new QFileInfo(*fi)); } } // we return here and break all importing! if (dlgStatus->wasCanceled()) { return; } } } // we return here and break all importing! if (dlgStatus->wasCanceled()) { return; } } //archive the images, if requested ... if (m_groupArchive->isChecked()) { dlgStatus->setCurrentMode(DlgImageImporterStatus::ModeArchive, i18n("Archiving found images...")); importFiles(&lstFiles, m_txtArchiveBaseFolder->text(), m_txtArchiveSubfolders->text(), m_txtArchiveFilename->text(), m_chkArchiveLowercase->isChecked(), false, dlgStatus); if (dlgStatus->wasCanceled()) { //either canceled by user or error return; } } else { dlgStatus->appendStatusMessage(i18n("Archiving found images... skipped")); } QString msg = i18n("Moving found images..."); if (!m_chkSrcRemoveFilesFromSrc->isChecked()) { msg = i18n("Copying found images..."); } dlgStatus->setCurrentMode(DlgImageImporterStatus::ModeDestination, msg); // ... then copy/ move the images to their destinaion importFiles(&lstFiles, m_cmbDestBasefolder->currentText(), m_txtDestSubfolders->text(), m_txtDestFilename->text(), m_chkDestLowercase->isChecked(), m_chkSrcRemoveFilesFromSrc->isChecked(), dlgStatus); if (dlgStatus->wasCanceled()) { //either canceled by user or error return; } //yes, we are done :) dlgStatus->setCurrentMode( DlgImageImporterStatus::ModeFinished, i18n("Done.")); //now tell, that new images have arrived emit newImagesImported(m_cmbDestBasefolder->currentText()); }