Skip to content

Commit

Permalink
extract duplicate code to importDataFromFile method
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzy69 committed May 13, 2017
1 parent 5d63ba1 commit 3cd08e5
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions application/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 3cd08e5

Please sign in to comment.