ScanDialog::ScanDialog( QWidget *parent, const char *name, bool modal ) : KScanDialog( Tabbed, Close|Help, parent, name, modal ), good_scan_connect(false) { QVBox *page = addVBoxPage( i18n("&Scanning") ); splitter = new QSplitter( Horizontal, page, "splitter" ); Q_CHECK_PTR( splitter ); m_scanParams = 0; m_device = new KScanDevice( this ); connect(m_device, SIGNAL(sigNewImage(QImage *, ImgScanInfo*)), this, SLOT(slotFinalImage(QImage *, ImgScanInfo *))); connect( m_device, SIGNAL(sigScanStart(const ImgScanInfo *)), this, SLOT(slotScanStart())); connect( m_device, SIGNAL(sigScanFinished(KScanStat)), this, SLOT(slotScanFinished(KScanStat))); connect( m_device, SIGNAL(sigAcquireStart()), this, SLOT(slotAcquireStart())); /* Create a preview widget to the right side of the splitter */ m_previewer = new Previewer( splitter ); Q_CHECK_PTR(m_previewer ); /* ... and connect to the selector-slots. They communicate user's * selection to the scanner parameter engine */ /* a new preview signal */ connect( m_device, SIGNAL( sigNewPreview( QImage*, ImgScanInfo* )), this, SLOT( slotNewPreview( QImage* ))); m_previewer->setEnabled( false ); // will be enabled in setup() /* Options-page */ createOptionsTab( ); }
LibraryScanner::LibraryScanner(QWidget* pParentWidget, TrackCollection* collection) : m_pCollection(collection), m_libraryHashDao(m_database), m_cueDao(m_database), m_playlistDao(m_database), m_crateDao(m_database), m_directoryDao(m_database), m_analysisDao(m_database, collection->getConfig()), m_trackDao(m_database, m_cueDao, m_playlistDao, m_crateDao, m_analysisDao, m_libraryHashDao, collection->getConfig()) { // Don't initialize m_database here, we need to do it in run() so the DB // conn is in the right thread. qDebug() << "Starting LibraryScanner thread."; // Move LibraryScanner to its own thread so that our signals/slots will // queue to our event loop. moveToThread(this); m_pool.moveToThread(this); unsigned static id = 0; // the id of this LibraryScanner, for debugging purposes setObjectName(QString("LibraryScanner %1").arg(++id)); m_pool.setMaxThreadCount(kScannerThreadPoolSize); // Listen to signals from our public methods (invoked by other threads) and // connect them to our slots to run the command on the scanner thread. connect(this, SIGNAL(startScan()), this, SLOT(slotStartScan())); // Force the GUI thread's TrackInfoObject cache to be cleared when a library // scan is finished, because we might have modified the database directly // when we detected moved files, and the TIOs corresponding to the moved // files would then have the wrong track location. connect(this, SIGNAL(scanFinished()), &(collection->getTrackDAO()), SLOT(clearCache())); connect(this, SIGNAL(trackAdded(TrackPointer)), &(collection->getTrackDAO()), SLOT(databaseTrackAdded(TrackPointer))); connect(this, SIGNAL(tracksMoved(QSet<int>, QSet<int>)), &(collection->getTrackDAO()), SLOT(databaseTracksMoved(QSet<int>, QSet<int>))); connect(this, SIGNAL(tracksChanged(QSet<int>)), &(collection->getTrackDAO()), SLOT(databaseTracksChanged(QSet<int>))); // Parented to pParentWidget so we don't need to delete it. LibraryScannerDlg* pProgress = new LibraryScannerDlg(pParentWidget); connect(this, SIGNAL(progressLoading(QString)), pProgress, SLOT(slotUpdate(QString))); connect(this, SIGNAL(progressHashing(QString)), pProgress, SLOT(slotUpdate(QString))); connect(this, SIGNAL(scanStarted()), pProgress, SLOT(slotScanStarted())); connect(this, SIGNAL(scanFinished()), pProgress, SLOT(slotScanFinished())); connect(pProgress, SIGNAL(scanCancelled()), this, SLOT(cancel())); connect(&m_trackDao, SIGNAL(progressVerifyTracksOutside(QString)), pProgress, SLOT(slotUpdate(QString))); connect(&m_trackDao, SIGNAL(progressCoverArt(QString)), pProgress, SLOT(slotUpdateCover(QString))); start(); }