Merge branch 'release' into release_1.1rc1
This commit is contained in:
+15
-24
@@ -257,40 +257,31 @@ class GuiProjectLoad(QDialog):
|
|||||||
def _populateList(self):
|
def _populateList(self):
|
||||||
"""Populate the list box with recent project data.
|
"""Populate the list box with recent project data.
|
||||||
"""
|
"""
|
||||||
listOrder = []
|
dataList = []
|
||||||
listData = {}
|
for projPath in self.mainConf.recentProj:
|
||||||
for projPath in self.mainConf.recentProj.keys():
|
|
||||||
theEntry = self.mainConf.recentProj[projPath]
|
theEntry = self.mainConf.recentProj[projPath]
|
||||||
theTitle = ""
|
theTitle = theEntry.get("title", "")
|
||||||
theTime = 0
|
theTime = theEntry.get("time", 0)
|
||||||
theWords = 0
|
theWords = theEntry.get("words", 0)
|
||||||
if "title" in theEntry.keys():
|
dataList.append([theTitle, theTime, theWords, projPath])
|
||||||
theTitle = theEntry["title"]
|
|
||||||
if "time" in theEntry.keys():
|
|
||||||
theTime = theEntry["time"]
|
|
||||||
if "words" in theEntry.keys():
|
|
||||||
theWords = theEntry["words"]
|
|
||||||
if theTime > 0:
|
|
||||||
listOrder.append(theTime)
|
|
||||||
listData[theTime] = [theTitle, theWords, projPath]
|
|
||||||
|
|
||||||
self.listBox.clear()
|
self.listBox.clear()
|
||||||
hasSelection = False
|
sortList = sorted(dataList, key=lambda x: x[1], reverse=True)
|
||||||
for timeStamp in sorted(listOrder, reverse=True):
|
for theTitle, theTime, theWords, projPath in sortList:
|
||||||
newItem = QTreeWidgetItem([""]*4)
|
newItem = QTreeWidgetItem([""]*4)
|
||||||
newItem.setIcon(self.C_NAME, self.theParent.theTheme.getIcon("proj_nwx"))
|
newItem.setIcon(self.C_NAME, self.theParent.theTheme.getIcon("proj_nwx"))
|
||||||
newItem.setText(self.C_NAME, listData[timeStamp][0])
|
newItem.setText(self.C_NAME, theTitle)
|
||||||
newItem.setData(self.C_NAME, Qt.UserRole, listData[timeStamp][2])
|
newItem.setData(self.C_NAME, Qt.UserRole, projPath)
|
||||||
newItem.setText(self.C_COUNT, formatInt(listData[timeStamp][1]))
|
newItem.setText(self.C_COUNT, formatInt(theWords))
|
||||||
newItem.setText(self.C_TIME, datetime.fromtimestamp(timeStamp).strftime("%x %X"))
|
newItem.setText(self.C_TIME, datetime.fromtimestamp(theTime).strftime("%x %X"))
|
||||||
newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter)
|
newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter)
|
||||||
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight | Qt.AlignVCenter)
|
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight | Qt.AlignVCenter)
|
||||||
newItem.setTextAlignment(self.C_TIME, Qt.AlignRight | Qt.AlignVCenter)
|
newItem.setTextAlignment(self.C_TIME, Qt.AlignRight | Qt.AlignVCenter)
|
||||||
newItem.setFont(self.C_TIME, self.theTheme.guiFontFixed)
|
newItem.setFont(self.C_TIME, self.theTheme.guiFontFixed)
|
||||||
self.listBox.addTopLevelItem(newItem)
|
self.listBox.addTopLevelItem(newItem)
|
||||||
if not hasSelection:
|
|
||||||
newItem.setSelected(True)
|
if self.listBox.topLevelItemCount() > 0:
|
||||||
hasSelection = True
|
self.listBox.topLevelItem(0).setSelected(True)
|
||||||
|
|
||||||
projColWidth = self.mainConf.getProjColWidths()
|
projColWidth = self.mainConf.getProjColWidths()
|
||||||
if len(projColWidth) == 3:
|
if len(projColWidth) == 3:
|
||||||
|
|||||||
@@ -434,6 +434,9 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
logger.error("No project open")
|
logger.error("No project open")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if not self.hasFocus():
|
||||||
|
return False
|
||||||
|
|
||||||
if tHandle is None:
|
if tHandle is None:
|
||||||
tHandle = self.getSelectedHandle()
|
tHandle = self.getSelectedHandle()
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ from PyQt5.QtCore import Qt
|
|||||||
from PyQt5.QtGui import QTextCursor
|
from PyQt5.QtGui import QTextCursor
|
||||||
from PyQt5.QtWidgets import QAction, QMessageBox
|
from PyQt5.QtWidgets import QAction, QMessageBox
|
||||||
|
|
||||||
|
from nw.gui.projtree import GuiProjectTree
|
||||||
from nw.constants import nwItemType, nwDocAction
|
from nw.constants import nwItemType, nwDocAction
|
||||||
|
|
||||||
keyDelay = 2
|
keyDelay = 2
|
||||||
@@ -42,6 +43,7 @@ def testGuiEditor_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj, refDir, outDi
|
|||||||
"""
|
"""
|
||||||
# Block message box
|
# Block message box
|
||||||
monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes)
|
monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes)
|
||||||
|
monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *args: True)
|
||||||
|
|
||||||
# Create new, save, close project
|
# Create new, save, close project
|
||||||
nwGUI.theProject.projTree.setSeed(42)
|
nwGUI.theProject.projTree.setSeed(42)
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ from tools import writeFile
|
|||||||
from PyQt5.QtCore import QItemSelectionModel
|
from PyQt5.QtCore import QItemSelectionModel
|
||||||
from PyQt5.QtWidgets import QAction, QMessageBox
|
from PyQt5.QtWidgets import QAction, QMessageBox
|
||||||
|
|
||||||
|
from nw.guimain import GuiMain
|
||||||
|
from nw.gui.projtree import GuiProjectTree
|
||||||
from nw.constants import nwItemType, nwItemClass
|
from nw.constants import nwItemType, nwItemClass
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
@@ -36,7 +38,8 @@ def testGuiProjTree_TreeItems(qtbot, caplog, monkeypatch, nwGUI, nwMinimal):
|
|||||||
"""
|
"""
|
||||||
# Block message box
|
# Block message box
|
||||||
monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes)
|
monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes)
|
||||||
monkeypatch.setattr("nw.guimain.GuiMain.editItem", lambda *args: None)
|
monkeypatch.setattr(GuiMain, "editItem", lambda *args: None)
|
||||||
|
monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *args: True)
|
||||||
|
|
||||||
nwGUI.theProject.projTree.setSeed(42)
|
nwGUI.theProject.projTree.setSeed(42)
|
||||||
nwTree = nwGUI.treeView
|
nwTree = nwGUI.treeView
|
||||||
|
|||||||
Reference in New Issue
Block a user