Added buttons to rebuild index and timeline view

This commit is contained in:
Veronica K. B. Olsen
2019-06-01 17:19:03 +02:00
parent 915d9807f7
commit bcd3cf5bcd
2 changed files with 39 additions and 13 deletions
+18 -7
View File
@@ -22,9 +22,6 @@ logger = logging.getLogger(__name__)
class Config:
WIN_WIDTH = 0
WIN_HEIGHT = 1
CNF_STR = 0
CNF_INT = 1
CNF_BOOL = 2
@@ -58,6 +55,9 @@ class Config:
self.mainPanePos = [300, 800]
self.docPanePos = [400, 400]
## Dialogs
self.dlgTimeLine = [600, 400]
## Project
self.autoSaveProj = 60
self.autoSaveDoc = 30
@@ -143,6 +143,7 @@ class Config:
self.treeColWidth = self._parseLine(cnfParse, cnfSec, "treecols", self.CNF_LIST, self.treeColWidth)
self.mainPanePos = self._parseLine(cnfParse, cnfSec, "mainpane", self.CNF_LIST, self.mainPanePos)
self.docPanePos = self._parseLine(cnfParse, cnfSec, "docpane", self.CNF_LIST, self.docPanePos)
self.dlgTimeLine = self._parseLine(cnfParse, cnfSec, "timeline", self.CNF_LIST, self.dlgTimeLine)
## Project
cnfSec = "Project"
@@ -192,6 +193,7 @@ class Config:
cnfParse.set(cnfSec,"treecols", self._packList(self.treeColWidth))
cnfParse.set(cnfSec,"mainpane", self._packList(self.mainPanePos))
cnfParse.set(cnfSec,"docpane", self._packList(self.docPanePos))
cnfParse.set(cnfSec,"timeline", self._packList(self.dlgTimeLine))
## Project
cnfSec = "Project"
@@ -254,11 +256,20 @@ class Config:
return True
def setWinSize(self, newWidth, newHeight):
if abs(self.winGeometry[self.WIN_WIDTH] - newWidth) >= 10:
self.winGeometry[self.WIN_WIDTH] = newWidth
if abs(self.winGeometry[0] - newHeight) > 5:
self.winGeometry[0] = newWidth
self.confChanged = True
if abs(self.winGeometry[self.WIN_HEIGHT] - newHeight) >= 10:
self.winGeometry[self.WIN_HEIGHT] = newHeight
if abs(self.winGeometry[1] - newHeight) > 5:
self.winGeometry[1] = newHeight
self.confChanged = True
return True
def setTLineSize(self, newWidth, newHeight):
if abs(self.dlgTimeLine[0] - newHeight) > 5:
self.dlgTimeLine[0] = newWidth
self.confChanged = True
if abs(self.dlgTimeLine[1] - newHeight) > 5:
self.dlgTimeLine[1] = newHeight
self.confChanged = True
return True
+21 -6
View File
@@ -15,7 +15,10 @@ import nw
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon, QColor, QBrush, QPixmap
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QTableWidget, QTableWidgetItem, QDialogButtonBox, QLabel
from PyQt5.QtWidgets import (
QDialog, QVBoxLayout, QHBoxLayout, QTableWidget, QTableWidgetItem,
QDialogButtonBox, QLabel, QPushButton
)
logger = logging.getLogger(__name__)
@@ -35,23 +38,33 @@ class GuiTimeLineView(QDialog):
self.numCols = 0
self.outerBox = QVBoxLayout()
self.bottomBox = QHBoxLayout()
self.setWindowTitle("Timeline View")
self.setMinimumSize(*self.mainConf.dlgTimeLine)
self.mainTable = QTableWidget()
self.mainTable.setGridStyle(Qt.NoPen)
self.setLayout(self.outerBox)
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Close)
self.buttonBox.rejected.connect(self._doClose)
self.btnRebuild = QPushButton("Rebuild Index")
self.btnRebuild.clicked.connect(self.theParent.rebuildIndex)
self.btnRefresh = QPushButton("Refresh Table")
self.btnRefresh.clicked.connect(self._buildNovelList)
self.setLayout(self.outerBox)
self.outerBox.addWidget(self.mainTable)
self.outerBox.addWidget(self.buttonBox)
self.outerBox.addLayout(self.bottomBox)
self.bottomBox.addWidget(self.btnRebuild)
self.bottomBox.addWidget(self.btnRefresh)
self.bottomBox.addStretch()
self.bottomBox.addWidget(self.buttonBox)
self._buildNovelList()
self.setMinimumSize(600,400)
self.buttonBox.setFocus()
self.show()
@@ -65,6 +78,7 @@ class GuiTimeLineView(QDialog):
self.numRows = len(self.theIndex.novelList)
self.numCols = len(self.theIndex.tagIndex.keys())
self.mainTable.clear()
self.mainTable.setRowCount(self.numRows)
self.mainTable.setColumnCount(self.numCols)
@@ -101,6 +115,7 @@ class GuiTimeLineView(QDialog):
return
def _doClose(self):
self.mainConf.setTLineSize(self.width(), self.height())
self.close()
return