コード例 #1
0
 def populate_repositories_widget(self):
     """Populate the current dictionary repositories to the tree widget."""
     # Clear the current tree widget
     self.tree_repositories.clear()
     installed_collections = \
         self.collection_manager.get_installed_collections()
     # Export the updated ones from the repository manager
     for repo_name in self.repository_manager.directories:
         url = self.repository_manager.directories[repo_name]['url']
         item = QTreeWidgetItem(self.tree_repositories, REPOSITORY_ITEM)
         item.setText(0, repo_name)
         item.setText(1, url)
         for coll_id in config.COLLECTIONS:
             if ('repository_name' in config.COLLECTIONS[coll_id].keys()
                     and config.COLLECTIONS[coll_id]['repository_name']
                     == repo_name):
                 coll_name = config.COLLECTIONS[coll_id]['name']
                 coll_tags = config.COLLECTIONS[coll_id]['tags']
                 collectionItem = QTreeWidgetItem(item, COLLECTION_ITEM)
                 collitemtext = coll_name
                 if installed_collections and coll_id in installed_collections.keys(
                 ):
                     collitemtext = coll_name + ' (installed)'
                     collectionFont = QFont()
                     collectionFont.setWeight(60)
                     collectionItem.setFont(0, collectionFont)
                 collectionItem.setText(0, collitemtext)
                 collectionItem.setText(1, coll_tags)
     self.tree_repositories.resizeColumnToContents(0)
     self.tree_repositories.resizeColumnToContents(1)
     self.tree_repositories.sortItems(1, Qt.AscendingOrder)
コード例 #2
0
 def reload_collections_model(self):
     """Reload the collections model with the current collections."""
     self.collections_model.clear()
     installed_collections = \
         self.collection_manager.get_installed_collections()
     for id in config.COLLECTIONS:
         collection_name = config.COLLECTIONS[id]['name']
         collection_author = config.COLLECTIONS[id]['author']
         collection_tags = config.COLLECTIONS[id]['tags']
         collection_description = config.COLLECTIONS[id]['description']
         collection_status = config.COLLECTIONS[id]['status']
         repository_name = ''
         if 'repository_name' in config.COLLECTIONS[id].keys():
             repository_name = config.COLLECTIONS[id]['repository_name']
         item = QStandardItem(collection_name + ' (' + repository_name +
                              ')')
         item.setEditable(False)
         item.setData(id, COLLECTION_ID_ROLE)
         item.setData(collection_name, COLLECTION_NAME_ROLE)
         item.setData(collection_description, COLLECTION_DESCRIPTION_ROLE)
         item.setData(collection_author, COLLECTION_AUTHOR_ROLE)
         item.setData(collection_tags, COLLECTION_TAGS_ROLE)
         item.setData(collection_status, COLLECTION_STATUS_ROLE)
         # Make installed collections stand out
         if installed_collections and id in installed_collections.keys():
             collectionFont = QFont()
             collectionFont.setWeight(60)
             item.setFont(collectionFont)
         self.collections_model.appendRow(item)
     self.collections_model.sort(0, Qt.AscendingOrder)
コード例 #3
0
 def populate_repositories_widget(self):
     """Populate the current dictionary repositories to the tree widget."""
     # Clear the current tree widget
     self.tree_repositories.clear()
     installed_collections = \
         self.collection_manager.get_installed_collections()
     # Export the updated ones from the repository manager
     repo_Font = QFont()
     repo_with_installed_Font = QFont()
     repo_with_installed_Font.setWeight(60)
     collection_brush = QBrush(Qt.darkGray)
     installed_collection_brush = QBrush(QColor(60, 25, 10))
     for repo_name in self.repository_manager.directories:
         url = self.repository_manager.directories[repo_name]['url']
         item = QTreeWidgetItem(self.tree_repositories, REPOSITORY_ITEM)
         # Is the repository in the QGIS resource directory?
         if url in self.repository_manager._online_directories.values():
             repo_with_installed_Font.setUnderline(True)
             repo_Font.setUnderline(True)
         else:
             repo_with_installed_Font.setUnderline(False)
             repo_Font.setUnderline(False)
         item.setText(0, repo_name)
         item.setText(1, url)
         item.setFont(0, repo_Font)
         for coll_id in config.COLLECTIONS:
             if ('repository_name' in config.COLLECTIONS[coll_id].keys()
                     and config.COLLECTIONS[coll_id]['repository_name']
                     == repo_name):
                 coll_name = config.COLLECTIONS[coll_id]['name']
                 coll_tags = config.COLLECTIONS[coll_id]['tags']
                 collectionItem = QTreeWidgetItem(item, COLLECTION_ITEM)
                 brush = collection_brush
                 collectionFont = QFont()
                 collectionFont.setStyle(QFont.StyleItalic)
                 collitemtext = coll_name
                 if (installed_collections
                         and coll_id in installed_collections.keys()):
                     collitemtext = coll_name + ' (installed)'
                     brush = installed_collection_brush
                     item.setFont(0, repo_with_installed_Font)
                     item.setForeground(0, brush)
                     item.setForeground(1, brush)
                 collectionItem.setFont(0, collectionFont)
                 collectionItem.setForeground(0, brush)
                 collectionItem.setText(0, collitemtext)
                 collectionItem.setFont(1, collectionFont)
                 collectionItem.setForeground(1, brush)
                 collectionItem.setText(1, coll_tags)
     self.tree_repositories.resizeColumnToContents(0)
     self.tree_repositories.resizeColumnToContents(1)
     self.tree_repositories.sortItems(1, Qt.AscendingOrder)