From dadf14518d418be602ff3740a562c7edcfb91268 Mon Sep 17 00:00:00 2001 From: Olivier Keshavjee Date: Wed, 17 Jun 2015 12:23:26 +0200 Subject: [PATCH] Properly shows wordcount and goal for rootItem --- src/models/outlineModel.py | 2 +- src/ui/editors/editorWidget.py | 13 ++++- test_project/outline.xml | 98 ++++++++++++++++----------------- test_project/settings.pickle | Bin 472 -> 472 bytes 4 files changed, 60 insertions(+), 53 deletions(-) diff --git a/src/models/outlineModel.py b/src/models/outlineModel.py index d99952f7..37456b82 100644 --- a/src/models/outlineModel.py +++ b/src/models/outlineModel.py @@ -522,7 +522,7 @@ class outlineItem(): item = ET.Element("outlineItem") # We don't want to write some datas (computed) - exclude = [Outline.goal, Outline.goalPercentage] + exclude = [Outline.wordCount, Outline.goal, Outline.goalPercentage] # We want to force some data even if they're empty force = [Outline.compile] diff --git a/src/ui/editors/editorWidget.py b/src/ui/editors/editorWidget.py index a8eeb58f..c56f4434 100644 --- a/src/ui/editors/editorWidget.py +++ b/src/ui/editors/editorWidget.py @@ -171,7 +171,7 @@ class editorWidget(QWidget, Ui_editorWidget_ui): else: - self.stack.setCurrentIndex(0) + self.stack.setCurrentIndex(0) # Single text item self._model.dataChanged.connect(self.modelDataChanged) self.updateStatusBar() @@ -194,8 +194,15 @@ class editorWidget(QWidget, Ui_editorWidget_ui): def updateStatusBar(self): # Update progress - if self.currentIndex and self.currentIndex.isValid(): - item = self.currentIndex.internalPointer() + #if self.currentIndex and self.currentIndex.isValid(): + if self._model: + if self.currentIndex: + item = self.currentIndex.internalPointer() + else: + item = self._model.rootItem + + if not item: + item = self._model.rootItem wc = item.data(Outline.wordCount.value) goal = item.data(Outline.goal.value) diff --git a/test_project/outline.xml b/test_project/outline.xml index 3060a356..2047bc7f 100644 --- a/test_project/outline.xml +++ b/test_project/outline.xml @@ -1,63 +1,63 @@ - - - + + + - - - + + + - - - + + + - - + + - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + - + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - + + + + + + + - + diff --git a/test_project/settings.pickle b/test_project/settings.pickle index a3ed079db3c0ca93ca066f20ba1fefb29138a5e1..69b20beaf16467ffcc8c3a735e356b0136941e2b 100644 GIT binary patch literal 472 zcmY*V%T5A85M1SrJjD0=b>ielfFU6mQ6Xe*X4q}n&5k?tFoS5aiAVfvduKVgx31}` z>YDn=#ptwI-f(Sr zSJ(9XWMXt&R(2d`!I#hvUyabXvt~tNxY24rEbgvZmas28jTx4sauU6F-Z0B*RC_9# z4a7HexTjTwxgKo%<{+gPfH%YZuVp4m`Vfr-d}4tWXi^z1MF?1AB|?%fbT{;2g(XJN z!Lk)4^pKBnua{?4qW@Dpg5+OV>E&33*d@6RKx+|B7g&w4=Gw?@%7*(f9=I$|s+Ni< z0Ulc8XQcy@z;LwWJLpS)SUnJn=C|JhKyBPlb4% znz%3)_P5WzjPc41(voIS51K)PWhm`Se}va&vpxdAn;35seewaDO?O*$a?G~+m