コード例 #1
0
 def __installQtDoc(self, name, engine):
     """
     Private method to install/update a Qt help document.
     
     @param name name of the Qt help document (string or QString)
     @param engine reference to the help engine (QHelpEngineCore)
     @return flag indicating success (boolean)
     """
     versionKey = QString("qt_version_%1@@%2").arg(qVersion()).arg(name)
     info = engine.customValue(versionKey, QVariant("")).toString()
     lst = info.split('|')
     
     dt = QDateTime()
     if len(lst) and not lst[0].isEmpty():
         dt = QDateTime.fromString(lst[0], Qt.ISODate)
     
     qchFile = QString()
     if len(lst) == 2:
         qchFile = lst[1]
     
     docsPath = QDir(QLibraryInfo.location(QLibraryInfo.DocumentationPath) + \
                QDir.separator() + "qch")
     
     files = docsPath.entryList(QStringList("*.qch"))
     if files.isEmpty():
         engine.setCustomValue(versionKey, 
             QVariant(QDateTime().toString(Qt.ISODate) + '|'))
         return False
     
     for f in files:
         if f.startsWith(name):
             fi = QFileInfo(docsPath.absolutePath() + QDir.separator() + f)
             namespace = QHelpEngineCore.namespaceName(fi.absoluteFilePath())
             if namespace.isEmpty():
                 continue
             
             if dt.isValid() and \
                namespace in engine.registeredDocumentations() and \
                fi.lastModified().toString(Qt.ISODate) == dt.toString(Qt.ISODate) and \
                qchFile == fi.absoluteFilePath():
                 return False
             
             if namespace in engine.registeredDocumentations():
                 engine.unregisterDocumentation(namespace)
             
             if not engine.registerDocumentation(fi.absoluteFilePath()):
                 self.emit(SIGNAL("errorMessage(const QString&)"), 
                     self.trUtf8("""<p>The file <b>%1</b> could not be registered."""
                                 """<br/>Reason: %2</p>""")\
                         .arg(fi.absoluteFilePath)\
                         .arg(engine.error())
                 )
                 return False
             
             engine.setCustomValue(versionKey, 
                 QVariant(fi.lastModified().toString(Qt.ISODate) + '|' + \
                 fi.absoluteFilePath()))
             return True
     
     return False
コード例 #2
0
 def run(self):
     """
     Protected method executed by the thread.
     """
     engine = QHelpEngineCore(self.__collection)
     engine.setupData()
     changes = False
     
     qtDocs = ["designer", "linguist", "qt"]
     for doc in qtDocs:
         changes |= self.__installQtDoc(doc, engine)
         self.__mutex.lock()
         if self.__abort:
             engine = None
             self.__mutex.unlock()
             return
         self.__mutex.unlock()
     
     changes |= self.__installEric4Doc(engine)
     engine = None
     del engine
     self.emit(SIGNAL("docsInstalled(bool)"), changes)
コード例 #3
0
 def on_addButton_clicked(self):
     """
     Private slot to add documents to the help database.
     """
     fileNames = KQFileDialog.getOpenFileNames(\
         self,
         self.trUtf8("Add Documentation"),
         QString(),
         self.trUtf8("Qt Compressed Help Files (*.qch)"),
         None)
     if fileNames.isEmpty():
         return
     
     for fileName in fileNames:
         ns = QHelpEngineCore.namespaceName(fileName)
         if ns.isEmpty():
             KQMessageBox.warning(self,
                 self.trUtf8("Add Documentation"),
                 self.trUtf8("""The file <b>%1</b> is not a valid Qt Help File.""")\
                     .arg(fileName)
             )
             continue
         
         if len(self.documentsList.findItems(ns, Qt.MatchFixedString)):
             KQMessageBox.warning(self,
                 self.trUtf8("Add Documentation"),
                 self.trUtf8("""The namespace <b>%1</b> is already registered.""")\
                     .arg(ns)
             )
             continue
         
         self.__engine.registerDocumentation(fileName)
         self.documentsList.addItem(ns)
         self.__registeredDocs.append(ns)
         if ns in self.__unregisteredDocs:
             self.__unregisteredDocs.remove(ns)
コード例 #4
0
 def __init__(self, engine, parent = None):
     """
     Constructor
     
     @param engine reference to the help engine (QHelpEngine)
     @param parent reference to the parent widget (QWidget)
     """
     QDialog.__init__(self, parent)
     self.setupUi(self)
     
     self.__engine = engine
     
     self.attributesList.header().hide()
     
     self.filtersList.clear()
     self.attributesList.clear()
     
     help = QHelpEngineCore(self.__engine.collectionFile())
     help.setupData()
     
     self.__removedFilters = []
     self.__filterMap = {}
     self.__filterMapBackup = {}
     self.__removedAttributes = []
     
     for filter in help.customFilters():
         atts = help.filterAttributes(filter)
         ufilter = unicode(filter)
         self.__filterMapBackup[ufilter] = atts
         if ufilter not in self.__filterMap:
             self.__filterMap[ufilter] = atts
     
     self.filtersList.addItems(sorted(self.__filterMap.keys()))
     for attr in help.filterAttributes():
         QTreeWidgetItem(self.attributesList, QStringList(attr))
     
     if self.__filterMap:
         self.filtersList.setCurrentRow(0)