Ejemplo n.º 1
0
 def slotOptimiseDatabase(self):
     self.loadDatabaseBuilder()
     dbBuild = self.renderThread.getObjectInstance(build.DatabaseBuilder)
     if dbBuild.isOptimizable():
         if KMessageBox.warningContinueCancel(self,
             i18n("This operation might take some time."),
             i18n("Optimise Database"), KStandardGuiItem.cont(),
             KStandardGuiItem.cancel(), 'database_optimise') \
                 == KMessageBox.Continue:
             QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
             self.currentJob = self.renderThread.enqueue(
                 build.DatabaseBuilder, 'optimize')
Ejemplo n.º 2
0
    def installDictionary(self):
        if self.currentDictionary in self.dictionaryHasNewer \
            and not self.dictionaryHasNewer[self.currentDictionary] \
            and KMessageBox.warningContinueCancel(self,
                i18n("Local version is already up-to-date.\n\nInstall anyway?"),
                i18n("Reinstall"), KStandardGuiItem.cont(),
                KStandardGuiItem.cancel(), 'reinstall_confirmation') \
                == KMessageBox.Cancel:
            return

        downloader = self.getDownloader(self.currentDictionary)

        link = downloader.getDownloadLink()
        if not link:
            self.statusLabel.setText(i18n('Error getting download page "%1"',
                downloader.lastError))
            return

        self.statusLabel.setText(i18n('Downloading from %1...', link))
        self.checkVersionButton.setEnabled(False)
        self.dictionaryCombo.setEnabled(False)
        self.removeButton.setEnabled(False)
        self.installButton.setEnabled(False)
        self.setWorking(True)

        filePath, fileType = downloader.download()
        if filePath:
            self.statusLabel.setText(i18n('Installing...', link))

            dbBuild = self.renderThread.getObjectInstance(build.DatabaseBuilder)
            builderClass = dbBuild.getTableBuilder(self.currentDictionary)
            dbBuild.setBuilderOptions(builderClass, 
                {'filePath': unicode(filePath), 'fileType': unicode(fileType)})

            tables = [self.currentDictionary]

            # look for related tables and install them, too
            relatedKey = self.currentDictionary + '_related'
            if relatedKey in EclectusCommandLineBuilder.BUILD_GROUPS:
                tables.extend(
                    EclectusCommandLineBuilder.BUILD_GROUPS[relatedKey])
            # TODO UpdateVersion might be installed later
            # TODO if for the first time a new language is installed check if
            #  tables in BUILD_GROUPS (zh-cmn, ja) need to be installed

            self.currentJob = self.renderThread.enqueue(build.DatabaseBuilder,
                'build', tables)
        else:
            self.statusLabel.setText(i18n('Error downloading from "%1": "%2"',
                link, downloader.lastError))
            self.dictionaryCombo.setEnabled(True)
            self.setWorking(False)
Ejemplo n.º 3
0
 def validate(self):
     """Checks if the input is acceptable.
     
     If this method returns True, the dialog is accepted when OK is clicked.
     Otherwise a messagebox could be displayed, and the dialog will remain
     visible.
     """
     # strip off whitespace
     name = self.name.text().strip()
     self.name.setText(name)
     
     if not name:
         self.setCurrentPage(self.firstPage)
         self.name.setFocus()
         KMessageBox.error(self, i18n("Please enter a session name."))
         if self._originalName:
             self.name.setText(self._originalName)
         return False
     
     if name == 'none':
         self.setCurrentPage(self.firstPage)
         self.name.setFocus()
         KMessageBox.error(self, i18n(
             "Please do not use the name '%1'.", "none"))
         return False
     
     if '&' in name:
         self.setCurrentPage(self.firstPage)
         self.name.setFocus()
         KMessageBox.error(self, i18n(
             "Please do not use the ampersand (&) character "
             "in a session name."))
         return False
         
     if self._originalName != name and name in self.sm.names():
         self.setCurrentPage(self.firstPage)
         self.name.setFocus()
         if KMessageBox.warningContinueCancel(self, i18n(
             "Another session with the name %1 exists already.\n\n"
             "Do you want to overwrite it?", name), None,
             KStandardGuiItem.overwrite(), KStandardGuiItem.cancel(),
             "session_overwrite") == KMessageBox.Cancel:
             return False
         
     return True