def __loadListOfDocuments(self): """ The UI doesn't contain any predefined items in the .ui file - these are based on the platform. We load these, as well as the user-defined directories into the list. The user-defined items are stored in the QSettings based storage. """ for value in default_paths(): item = addNewListItemCalled([os.path.normpath(value)], self.ui.listWidget) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) t = item.font() t.setItalic(True) item.setFont(t) # load up state from storage... paths = QSettings().value("paths").toList() for value in paths: str = os.path.normpath(value.toString()) if str not in default_paths(): addNewListItemCalled([str], self.ui.listWidget, mutable=True)
def __onAddClicked(self): """ Creates a new item in the list and begins editing it. The item is selected by choosing a directory using the file dialog. """ dir_name = QFileDialog.getExistingDirectory(self, "Select a directory") if dir_name is not None: theItem = addNewListItemCalled([dir_name], self.ui.listWidget, mutable=True) if theItem is not None: theItem.setSelected(True)