diff --git a/application/mainwindow.py b/application/mainwindow.py index a18abae..ca02328 100644 --- a/application/mainwindow.py +++ b/application/mainwindow.py @@ -126,14 +126,7 @@ def resizeTableColumns(self): def importUrls(self): filePath, fileType = QtWidgets.QFileDialog.getOpenFileName(self, "Import URLs", filter="Text files (*.txt)") if filePath: - text = readTextFile(filePath) - for url in text.strip().splitlines(): - if url in self._urls: - continue - self._urls.append(url) - rankCell = QStandardItem("") - rankCell.setTextAlignment(Qt.AlignCenter) - self.sitesModel.appendRow([QStandardItem(url), rankCell,QStandardItem("")]) + self.importDataFromFile(filePath) self.updateRecentFiles(filePath) def sitesTableView_doubleClicked(self, modelIndex): @@ -189,6 +182,9 @@ def updateRecentFilesActions(self): def openRecentFile(self): filePath = str(self.sender().data()) + self.importDataFromFile(filePath) + + def importDataFromFile(self, filePath): if os.path.exists(filePath): text = readTextFile(filePath) for url in text.strip().splitlines():