def on_actionDbScanBookDir_triggered(self): dirname = QtGui.QFileDialog.getExistingDirectory( self, self.tr("Select directory"), QtCore.QDir.homePath(), QtGui.QFileDialog.ShowDirsOnly) if not dirname.isEmpty(): self._db.finishActiveQueries() dlg = ImportDialog(QtCore.QDir(dirname).absolutePath(), self) dlg.exec_() for widget in self.findChildren(QtGui.QTableView): widget.model().refresh() QtGui.qApp.processEvents()
def on_actionDbScanBookDir_triggered(self): dirname = QtGui.QFileDialog.getExistingDirectory(self, self.tr("Select directory"), QtCore.QDir.homePath(), QtGui.QFileDialog.ShowDirsOnly) if not dirname.isEmpty(): self._db.finishActiveQueries() dlg = ImportDialog(QtCore.QDir(dirname).absolutePath(), self) dlg.exec_() for widget in self.findChildren(QtGui.QTableView): widget.model().refresh() QtGui.qApp.processEvents()
def import_dialog(self): """ Open the database import window allowing the user to import and delete entries. """ logger.info('Opening database import window') if (not ImportDialog.singleton): ImportDialog(self.__root, self). \ wm_iconbitmap(ICO) else: logger.warning('Found existing import window, canceling')
def __init__(self, src, baseDst): QObject.__init__(self) self.src = src self.dlg = ImportDialog(KUrl(baseDst))
class Controller(QObject): def __init__(self, src, baseDst): QObject.__init__(self) self.src = src self.dlg = ImportDialog(KUrl(baseDst)) def run(self): if not self.dlg.exec_(): return False self.dstDirUrl = self.dlg.dstUrl() self.progressDlg = KProgressDialog() self.progressDlg.setLabelText(i18n("Initializing...")) self.progressDlg.setMinimumDuration(0) qApp.processEvents() dir = unicode(self.dstDirUrl.path()) if not os.path.exists(dir): os.makedirs(dir) self.progressDlg.setLabelText(i18n("Importing pictures...")) self.urlList = listImages(self.src) if not self.urlList: KMessageBox.information(None, i18n("No picture to import.")) return False self.progressDlg.progressBar().setRange(0, len(self.urlList)) self.jobList = self.urlList[:] self.copyOneUrl() return True def copyOneUrl(self): url = self.jobList.pop() name = getNameForUrl(url) dstUrl = KUrl(self.dstDirUrl) dstUrl.addPath(name) job = KIO.copy(url, dstUrl, KIO.HideProgressInfo) QObject.connect(job, SIGNAL("result(KJob*)"), self.slotJobResult) def slotJobResult(self, job): if job.error() != 0: job.uiDelegate().showErrorMessage() self.progressDlg.close() return bar = self.progressDlg.progressBar() bar.setValue(bar.value() + 1) if self.jobList: self.copyOneUrl() else: self.progressDlg.close() self.deleteFromCard() def deleteFromCard(self): answer = KMessageBox.questionYesNo( None, i18n("Pictures have been imported. Delete them from card?"), QString(), KStandardGuiItem.del_(), KStandardGuiItem.close()) if answer == KMessageBox.Yes: job = KIO.del_(KUrl.List(self.urlList)) job.exec_() os.execlp("gwenview", "gwenview", unicode(self.dstDirUrl.url()))