//! The Job options are synchronised using the widgetChanged slot, but we still //! need to determine if the options should be printed as part of the job. This //! is based on whether or not the associated control is enabled or not. void InputDialog::finalizeJob(Job* job) { if (!job) return; QWidget* w; QString name; StringMap::const_iterator iter; StringMap s = job->getOptions(); for (iter = s.begin(); iter != s.end(); ++iter) { name = iter.key(); w = findChild<QWidget*>(name.toLower()); // If there is no widget of this name, then we are probably dealing // with something the user wrote into the preview box, so we just // leave things alone. if (w) job->printOption(name, w->isEnabled()); } // Special case code to avoid writing the method keyword when custom is // chosen (for backward compatibility) QComboBox* method(findChild<QComboBox*>("method")); QString m(method->currentText()); if (method && (m == "Custom" || m == "TD-DFT")) { job->printOption("METHOD", false); job->printOption("EXCHANGE", true); } }
PostJob::PostJob(PlatformDependent *internals, const QNetworkRequest &request, const StringMap ¶meters) : BaseJob(internals), m_ioDevice(0), m_request(request) { // Create post data int j = 0; for (StringMap::const_iterator i = parameters.begin(); i != parameters.end(); ++i) { if (j++ > 0) { m_byteArray.append('&'); } m_byteArray.append(QUrl::toPercentEncoding(i.key())); m_byteArray.append('='); m_byteArray.append(QUrl::toPercentEncoding(i.value())); } }
void ImageScanThread<DBFS>::run() { RunProlog(); setPriority(QThread::LowPriority); do { // Process all clears before scanning while (ClearsPending()) { m_mutexQueue.lock(); if (m_clearQueue.isEmpty()) break; ClearTask task = m_clearQueue.takeFirst(); m_mutexQueue.unlock(); int devId = task.first; QString action = task.second; LOG(VB_GENERAL, LOG_INFO, QString("Clearing Filesystem: %1 %2").arg(action).arg(devId)); // Clear Db m_dbfs.ClearDb(devId, action); // Pass on to thumb generator now scanning has stopped m_thumb.ClearThumbs(devId, action); } // Scan requested ? if (IsScanning()) { LOG(VB_GENERAL, LOG_INFO, "Starting scan"); // Load known directories and files from the database if (!m_dbfs.ReadAllImages(m_dbFileMap, m_dbDirMap)) // Abort on any Db error break; bool firstScan = m_dbFileMap.isEmpty(); // Pause thumb generator so that scans are fast as possible m_thumb.PauseBackground(true); // Adapter determines list of dirs to scan StringMap paths = m_dbfs.GetScanDirs(); CountFiles(paths.values()); // Now start the actual syncronization m_seenFile.clear(); m_changedImages.clear(); StringMap::const_iterator i = paths.constBegin(); while (i != paths.constEnd() && IsScanning()) { SyncSubTree(QFileInfo(i.value()), GALLERY_DB_ID, i.key(), i.value()); ++i; } // Release thumb generator asap m_thumb.PauseBackground(false); // Adding or updating directories has been completed. // The maps now only contain old directories & files that are not // in the filesystem anymore. Remove them from the database m_dbfs.RemoveFromDB(m_dbDirMap.values()); m_dbfs.RemoveFromDB(m_dbFileMap.values()); // Cleanup thumbnails QStringList mesg(m_thumb.DeleteThumbs(m_dbFileMap.values())); mesg << m_changedImages.join(","); // Cleanup dirs m_dbFileMap.clear(); m_dbDirMap.clear(); m_seenDir.clear(); m_mutexProgress.lock(); // (count == total) signals scan end Broadcast(m_progressTotalCount); // Must reset counts for scan queries m_progressCount = m_progressTotalCount = 0; m_mutexProgress.unlock(); LOG(VB_GENERAL, LOG_INFO, "Finished scan"); // For initial scans pause briefly to give thumb generator a headstart // before being deluged by client requests if (firstScan) msleep(1000); // Notify clients of completion with removed & changed images m_dbfs.Notify("IMAGE_DB_CHANGED", mesg); ChangeState(false); } } while (ClearsPending()); RunEpilog(); }