Working on plots

This commit is contained in:
Olivier Keshavjee 2015-06-22 13:11:45 +02:00
parent 09754166f0
commit 28ba9f812d
11 changed files with 535 additions and 199 deletions

View file

@ -32,6 +32,7 @@ class Plot(Enum):
description = 4
result = 5
subplots = 6
summary = 7
class Outline(Enum):
title = 0

View file

@ -6,7 +6,7 @@ from qt import *
_version = "0.1"
import faulthandler
faulthandler.enable()
#faulthandler.enable()
def run():
app = QApplication(sys.argv)

View file

@ -69,8 +69,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# Persos
self.mdlPersos = QStandardItemModel(0, 0)
self.mdlPersosProxy = None # persosProxyModel() # None
#self.mdlPersosProxy = persosProxyModel()
#self.mdlPersosProxy = None # persosProxyModel() # None
self.mdlPersosProxy = persosProxyModel(self)
self.mdlPersosInfos = QStandardItemModel(1, 0)
self.mdlPersosInfos.insertColumn(0, [QStandardItem("ID")])
@ -287,6 +287,57 @@ class MainWindow(QMainWindow, Ui_MainWindow):
px.fill(color)
self.mdlPersos.item(row, Perso.name.value).setIcon(QIcon(px))
####################################################################################################
# PLOTS #
####################################################################################################
def changeCurrentPlot(self):
index = self.lstPlots.currentIndex()
if not index.isValid():
self.tabPlot.setEnabled(False)
return
self.tabPlot.setEnabled(True)
self.txtPlotName.setCurrentModelIndex(index)
self.txtPlotDescription.setCurrentModelIndex(index)
self.txtPlotResult.setCurrentModelIndex(index)
self.sldPlotImportance.setCurrentModelIndex(index)
self.lstPlotPerso.setRootIndex(index.sibling(index.row(), Plot.persos.value))
self.lstSubPlots.setRootIndex(index.sibling(index.row(), Plot.subplots.value))
#self.txtSubPlotSummary.setCurrentModelIndex(QModelIndex())
self.txtSubPlotSummary.setEnabled(False)
self.txtSubPlotSummary.setPlainText("")
def changeCurrentSubPlot(self, index):
# Got segfaults when using my textEditView model system, so ad hoc stuff.
index = index.sibling(index.row(), 3)
item = self.mdlPlots.itemFromIndex(index)
if not item:
self.txtSubPlotSummary.setEnabled(False)
return
self.txtSubPlotSummary.setEnabled(True)
txt = item.text()
self._updatingSubPlot = True
self.txtSubPlotSummary.setPlainText(txt)
self._updatingSubPlot = False
self.txtSubPlotSummary.document().contentsChanged.connect(self.updateSubPlotSummary)
def updateSubPlotSummary(self):
if self._updatingSubPlot:
return
index = self.lstSubPlots.currentIndex()
if not index.isValid():
return
index = index.sibling(index.row(), 3)
item = self.mdlPlots.itemFromIndex(index)
self._updatingSubPlot = True
item.setText(self.txtSubPlotSummary.toPlainText())
self._updatingSubPlot = False
####################################################################################################
# GENERAL #
@ -297,7 +348,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# Load data
self.loadDatas()
self.makeConnections()
# Load settings
@ -386,7 +436,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
widget.setCurrentModelIndex(self.mdlFlatData.index(0, col))
# Persos
if self.mdlPersosProxy:
self.mdlPersosProxy.setSourceModel(self.mdlPersos)
self.lstPersos.setModel(self.mdlPersosProxy)
@ -425,9 +474,14 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.tabPersos.currentChanged.connect(self.resizePersosInfos)
# Plots
self.lstPlots.setModel(self.mdlPlots.viewModel())
self.lstPlotPerso.setModel(self.mdlPlots.viewModel())
self.lstSubPlots.setModel(self.mdlPlots.viewModel())
self.lstPlots.setPlotModel(self.mdlPlots)
self.txtPlotFilter.textChanged.connect(self.lstPlots.setFilter)
self.lstPlots.currentRowChanged.connect(self.changeCurrentPlot)
self.lstPlotPerso.setModel(self.mdlPlots)
self.lstSubPlots.setModel(self.mdlPlots)
#self.txtSubPlotSummary.setModel(self.mdlPlots)
#self.txtSubPlotSummary.setColumn(1)
self.lstSubPlots.selectionModel().currentChanged.connect(self.changeCurrentSubPlot)
self.btnAddPlot.clicked.connect(self.mdlPlots.addPlot)
self.btnRmPlot.clicked.connect(lambda: self.mdlPlots.removePlot(self.lstPlots.currentIndex()))
self.btnAddSubPlot.clicked.connect(self.mdlPlots.addSubPlot)
@ -442,29 +496,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
]:
w.setModel(self.mdlPlots)
w.setColumn(c)
self.lstPlots.selectionModel().currentChanged.connect(w.setCurrentModelIndex)
self.tabPlot.setEnabled(False)
self.lstPlots.selectionModel().currentChanged.connect(lambda: self.tabPlot.setEnabled(self.lstPlots.selectionModel().currentIndex().isValid()))
# sets persos view
self.lstPlots.selectionModel().currentChanged.connect(
lambda: self.lstPlotPerso.setRootIndex(self.mdlPlots.index(
self.lstPlots.selectionModel().currentIndex().row(),
Plot.persos.value)))
# sets subplots view
self.lstPlots.selectionModel().currentChanged.connect(
lambda: self.lstSubPlots.setRootIndex(self.mdlPlots.index(
self.lstPlots.selectionModel().currentIndex().row(),
Plot.subplots.value)))
# Subplot mapper
self.mprSubPlots = QDataWidgetMapper()
self.mprSubPlots.setModel(self.mdlPlots)
self.mprSubPlots.addMapping(self.txtSubPlotSummary, 2)
self.lstPlots.selectionModel().currentChanged.connect(self.mprSubPlots.setRootIndex)
self.lstSubPlots.selectionModel().currentChanged.connect(self.mprSubPlots.setCurrentModelIndex)
# Outline
self.treeRedacOutline.setModel(self.mdlOutline)
self.treePlanOutline.setModelPersos(self.mdlPersos)
self.treePlanOutline.setModelLabels(self.mdlLabels)

View file

@ -1,24 +1,20 @@
#!/usr/bin/env python
#--!-- coding: utf8 --!--
from qt import *
from enums import *
from models.outlineModel import *
from enum import Enum
from lxml import etree as ET
class persosProxyModel(QAbstractProxyModel):
class persosProxyModel(QSortFilterProxyModel):
newStatuses = pyqtSignal()
def __init__(self, parent=None):
QAbstractProxyModel.__init__(self, parent)
QSortFilterProxyModel.__init__(self, parent)
self.rootItem = QStandardItem()
#self.rootItem = QStandardItem()
self.p1 = QStandardItem(self.tr("Main"))
self.p2 = QStandardItem(self.tr("Secundary"))
self.p3 = QStandardItem(self.tr("Minors"))
@ -29,13 +25,13 @@ class persosProxyModel(QAbstractProxyModel):
self.p3
]
def mapFromSource(self, sourceIndex):
if not sourceIndex.isValid():
return QModelIndex()
row = self._map.index(sourceIndex.row())
item = sourceIndex.internalPointer()
#item = sourceIndex.internalPointer()
item = self.sourceModel().itemFromIndex(sourceIndex)
return self.createIndex(row, sourceIndex.column(), item)
@ -49,20 +45,21 @@ class persosProxyModel(QAbstractProxyModel):
return Qt.ItemIsEnabled | Qt.ItemIsSelectable
def mapToSource(self, proxyIndex):
#if not proxyIndex.isValid():
#return QModelIndex()
if not proxyIndex.isValid():
return QModelIndex()
row = self._map[proxyIndex.row()]
if type(row) != int:
return QModelIndex()
item = proxyIndex.internalPointer()
#item = proxyIndex.internalPointer()
item = self.sourceModel().item(row, proxyIndex.column())
return self.sourceModel().createIndex(row, proxyIndex.column(), item)
return self.sourceModel().indexFromItem(item)
def setSourceModel(self, model):
QAbstractProxyModel.setSourceModel(self, model)
QSortFilterProxyModel.setSourceModel(self, model)
self.sourceModel().dataChanged.connect(self.mapModelMaybe)
self.sourceModel().rowsInserted.connect(self.mapModel)
self.sourceModel().rowsRemoved.connect(self.mapModel)
@ -98,9 +95,10 @@ class persosProxyModel(QAbstractProxyModel):
def data(self, index, role=Qt.DisplayRole):
row = index.row()
if index.isValid() and not self.mapToSource(index).isValid():
row = index.row()
if role == Qt.DisplayRole:
return self._map[row].text()

View file

@ -4,6 +4,7 @@
from qt import *
from enums import *
from functions import *
from models.plotsProxyModel import *
class plotModel(QStandardItemModel):
@ -11,15 +12,56 @@ class plotModel(QStandardItemModel):
QStandardItemModel.__init__(self, 0, 3)
self.setHorizontalHeaderLabels([i.name for i in Plot])
self.mw = mainWindow()
#self._proxy = plotsProxyModel()
#self._proxy.setSourceModel(self)
self.updatePlotPersoButton()
self.mw.mdlPersos.dataChanged.connect(self.updatePlotPersoButton)
####################################################################################################
# QUERIES #
####################################################################################################
def getPlotsByImportance(self):
plots = [[], [], []]
for i in range(self.rowCount()):
importance = self.item(i, Plot.importance.value).text()
ID = self.item(i, Plot.ID.value).text()
plots[2-toInt(importance)].append(ID)
return plots
def getNameByID(self, ID):
for i in range(self.rowCount()):
_ID = self.item(i, Plot.ID.value).text()
if _ID == ID or toInt(_ID) == ID:
name = self.item(i, Plot.name.value).text()
return name
return None
def getIndexFromID(self, ID):
for i in range(self.rowCount()):
_ID = self.item(i, Plot.ID.value).text()
if _ID == ID or toInt(_ID) == ID:
return self.index(i, 0)
return QModelIndex()
def currentIndex(self):
i = self.mw.lstPlots.selectionModel().currentIndex()
if i .isValid():
return i
else:
return None
####################################################################################################
# ADDING / REMOVING #
####################################################################################################
def addPlot(self):
p = QStandardItem(self.tr("New plot"))
_id = QStandardItem(self.getUniqueID())
importance = QStandardItem(str(0))
self.appendRow([p, _id, importance])
self.appendRow([p, _id, importance, QStandardItem("Persos"),
QStandardItem(), QStandardItem(), QStandardItem("Subplots")])
def getUniqueID(self, parent=QModelIndex()):
"Returns an unused ID"
@ -37,24 +79,28 @@ class plotModel(QStandardItemModel):
def removePlot(self, index):
self.takeRow(index.row())
def currentIndex(self):
i = self.mw.lstPlots.selectionModel().currentIndex()
if i .isValid():
return i
else:
return None
####################################################################################################
# SUBPLOTS #
####################################################################################################
def addSubPlot(self):
index = self.currentIndex()
if not index:
index = self.mw.lstPlots.currentIndex()
if not index.isValid():
return
parent = index.sibling(index.row(), Plot.subplots.value)
parentItem = self.itemFromIndex(parent)
parentItem = self.item(index.row(), Plot.subplots.value)
if not parentItem:
return
p = QStandardItem(self.tr("New subplot"))
_id = QStandardItem(self.getUniqueID(parent))
summary = QStandardItem()
parentItem.appendRow([p, _id, summary])
# Don't know why, if summary is in third position, then drag/drop deletes it...
parentItem.appendRow([p, _id, QStandardItem(), summary])
def removeSubPlot(self):
index = self.mw.lstSubPlots.currentIndex()
@ -63,12 +109,25 @@ class plotModel(QStandardItemModel):
parent = index.parent()
parentItem = self.itemFromIndex(parent)
parentItem.takeRow(index.row())
def flags(self, index):
parent = index.parent()
if parent.isValid(): # this is a subitem
return Qt.ItemIsEnabled | Qt.ItemIsEditable | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled
else:
return QStandardItemModel.flags(self, index)
####################################################################################################
# PLOT PERSOS #
####################################################################################################
def addPlotPerso(self, v):
if self.currentIndex():
if not self.item(self.currentIndex().row(), Plot.persos.value):
self.setItem(self.currentIndex().row(), Plot.persos.value, QStandardItem())
item = self.item(self.currentIndex().row(), Plot.persos.value)
index = self.mw.lstPlots.currentIndex()
if index.isValid():
if not self.item(index.row(), Plot.persos.value):
self.setItem(index.row(), Plot.persos.value, QStandardItem())
item = self.item(index.row(), Plot.persos.value)
# We check that the PersoID is not in the list yet
for i in range(item.rowCount()):
@ -111,14 +170,20 @@ class plotModel(QStandardItemModel):
mpr.mapped.connect(self.addPlotPerso)
self.mw.btnAddPlotPerso.setMenu(menu)
####################################################################################################
# PROXY MODEL (UNUSED) #
####################################################################################################
def viewModel(self):
"Returns proxy model if any, else self"
return self
def flags(self, index):
parent = index.parent()
if parent.isValid(): # this is a subitem
return Qt.ItemIsEnabled | Qt.ItemIsEditable | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled
if self._proxy:
return self._proxy
else:
return QStandardItemModel.flags(self, index)
return self
def toSource(self, index):
if self._proxy:
return self._proxy.mapToSource(index)
else:
return index

View file

@ -0,0 +1,141 @@
#!/usr/bin/env python
#--!-- coding: utf8 --!--
from qt import *
from enums import *
from enum import Enum
from lxml import etree as ET
class plotsProxyModel(QSortFilterProxyModel):
newStatuses = pyqtSignal()
def __init__(self, parent=None):
QSortFilterProxyModel.__init__(self, parent)
#self.rootItem = QStandardItem()
self.p1 = QStandardItem(self.tr("Main"))
self.p2 = QStandardItem(self.tr("Secundary"))
self.p3 = QStandardItem(self.tr("Minors"))
self._cats = [
self.p1,
self.p2,
self.p3
]
def mapFromSource(self, sourceIndex):
if not sourceIndex.isValid():
return QModelIndex()
row = self._map.index(sourceIndex.row())
#item = sourceIndex.internalPointer()
item = self.sourceModel().itemFromIndex(sourceIndex)
return self.createIndex(row, sourceIndex.column(), item)
def flags(self, index):
if not index.isValid():
return Qt.NoItemFlags
if index.isValid() and not self.mapToSource(index).isValid():
return Qt.NoItemFlags#Qt.ItemIsEnabled
else:
return Qt.ItemIsEnabled | Qt.ItemIsSelectable
def mapToSource(self, proxyIndex):
if not proxyIndex.isValid():
return QModelIndex()
row = self._map[proxyIndex.row()]
if type(row) != int:
return QModelIndex()
#item = proxyIndex.internalPointer()
item = self.sourceModel().item(row, proxyIndex.column())
return self.sourceModel().indexFromItem(item)
def setSourceModel(self, model):
QSortFilterProxyModel.setSourceModel(self, model)
self.sourceModel().dataChanged.connect(self.mapModelMaybe)
self.sourceModel().rowsInserted.connect(self.mapModel)
self.sourceModel().rowsRemoved.connect(self.mapModel)
self.sourceModel().rowsMoved.connect(self.mapModel)
self.mapModel()
def mapModelMaybe(self, topLeft, bottomRight):
if topLeft.column() <= Plot.importance.value <= bottomRight.column():
self.mapModel()
def mapModel(self):
self.beginResetModel()
src = self.sourceModel()
self._map = []
for i in range(len(self._cats)):
self._map.append(self._cats[i])
for p in range(src.rowCount()):
item = src.item(p, Plot.importance.value)
if item:
imp = int(item.text())
else:
imp = 0
if 2-imp == i:
self._map.append(p)
self.endResetModel()
def data(self, index, role=Qt.DisplayRole):
if index.isValid() and not self.mapToSource(index).isValid():
row = index.row()
if role == Qt.DisplayRole:
return self._map[row].text()
elif role == Qt.ForegroundRole:
return QBrush(Qt.darkBlue)
elif role == Qt.BackgroundRole:
return QBrush(QColor(Qt.blue).lighter(190))
elif role == Qt.TextAlignmentRole:
return Qt.AlignCenter
elif role == Qt.FontRole:
f = QFont()
#f.setPointSize(f.pointSize() + 1)
f.setWeight(QFont.Bold)
return f
else:
#FIXME: sometimes, the name of the character is not displayed
return self.sourceModel().data(self.mapToSource(index), role)
def index(self, row, column, parent):
i = self._map[row]
if type(i) != int:
return self.createIndex(row, column, i)
else:
return self.mapFromSource(self.sourceModel().index(i, column, QModelIndex()))
def parent(self, index=QModelIndex()):
return QModelIndex()
def rowCount(self, parent=QModelIndex()):
return len(self._map)
def columnCount(self, parent=QModelIndex()):
return self.sourceModel().columnCount(QModelIndex())
def item(self, row, col, parent=QModelIndex()):
idx = self.mapToSource(self.index(row, col, parent))
return self.sourceModel().item(idx.row(), idx.column())

View file

@ -487,14 +487,7 @@ class Ui_MainWindow(object):
self.groupBox_2.setObjectName("groupBox_2")
self.verticalLayout_10 = QtWidgets.QVBoxLayout(self.groupBox_2)
self.verticalLayout_10.setObjectName("verticalLayout_10")
self.lstPlots = QtWidgets.QListView(self.groupBox_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lstPlots.sizePolicy().hasHeightForWidth())
self.lstPlots.setSizePolicy(sizePolicy)
self.lstPlots.setDragEnabled(True)
self.lstPlots.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
self.lstPlots = plotListView(self.groupBox_2)
self.lstPlots.setObjectName("lstPlots")
self.verticalLayout_10.addWidget(self.lstPlots)
self.horizontalLayout_15 = QtWidgets.QHBoxLayout()
@ -511,10 +504,10 @@ class Ui_MainWindow(object):
self.btnRmPlot.setIcon(icon)
self.btnRmPlot.setObjectName("btnRmPlot")
self.horizontalLayout_15.addWidget(self.btnRmPlot)
self.lineEdit_7 = QtWidgets.QLineEdit(self.groupBox_2)
self.lineEdit_7.setProperty("clearButtonEnabled", True)
self.lineEdit_7.setObjectName("lineEdit_7")
self.horizontalLayout_15.addWidget(self.lineEdit_7)
self.txtPlotFilter = QtWidgets.QLineEdit(self.groupBox_2)
self.txtPlotFilter.setProperty("clearButtonEnabled", True)
self.txtPlotFilter.setObjectName("txtPlotFilter")
self.horizontalLayout_15.addWidget(self.txtPlotFilter)
self.btnPlotShowSummary = QtWidgets.QPushButton(self.groupBox_2)
self.btnPlotShowSummary.setText("")
icon = QtGui.QIcon.fromTheme("text-x-generic")
@ -597,16 +590,21 @@ class Ui_MainWindow(object):
self.tabPlot.addTab(self.infos_2, "")
self.tab_15 = QtWidgets.QWidget()
self.tab_15.setObjectName("tab_15")
self.verticalLayout_11 = QtWidgets.QVBoxLayout(self.tab_15)
self.verticalLayout_11.setObjectName("verticalLayout_11")
self.verticalLayout_28 = QtWidgets.QVBoxLayout(self.tab_15)
self.verticalLayout_28.setObjectName("verticalLayout_28")
self.lstSubPlots = QtWidgets.QListView(self.tab_15)
self.lstSubPlots.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
self.lstSubPlots.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
self.lstSubPlots.setObjectName("lstSubPlots")
self.verticalLayout_11.addWidget(self.lstSubPlots)
self.txtSubPlotSummary = textEditView(self.tab_15)
self.verticalLayout_28.addWidget(self.lstSubPlots)
self.grpSubPlotSummary = QtWidgets.QGroupBox(self.tab_15)
self.grpSubPlotSummary.setObjectName("grpSubPlotSummary")
self.verticalLayout_11 = QtWidgets.QVBoxLayout(self.grpSubPlotSummary)
self.verticalLayout_11.setObjectName("verticalLayout_11")
self.txtSubPlotSummary = textEditView(self.grpSubPlotSummary)
self.txtSubPlotSummary.setObjectName("txtSubPlotSummary")
self.verticalLayout_11.addWidget(self.txtSubPlotSummary)
self.verticalLayout_28.addWidget(self.grpSubPlotSummary)
self.horizontalLayout_17 = QtWidgets.QHBoxLayout()
self.horizontalLayout_17.setObjectName("horizontalLayout_17")
self.btnAddSubPlot = QtWidgets.QPushButton(self.tab_15)
@ -665,7 +663,7 @@ class Ui_MainWindow(object):
self.btnShowSubPlotSummary.setChecked(True)
self.btnShowSubPlotSummary.setObjectName("btnShowSubPlotSummary")
self.horizontalLayout_17.addWidget(self.btnShowSubPlotSummary)
self.verticalLayout_11.addLayout(self.horizontalLayout_17)
self.verticalLayout_28.addLayout(self.horizontalLayout_17)
self.tabPlot.addTab(self.tab_15, "")
self.grpPlotSummary = QtWidgets.QGroupBox(self.splitterPlot)
self.grpPlotSummary.setObjectName("grpPlotSummary")
@ -1120,7 +1118,7 @@ class Ui_MainWindow(object):
self.tabMain.setCurrentIndex(3)
self.tabSummary.setCurrentIndex(0)
self.tabPersos.setCurrentIndex(0)
self.tabPlot.setCurrentIndex(0)
self.tabPlot.setCurrentIndex(1)
self.comboBox_2.setCurrentIndex(0)
self.stkPlotSummary.setCurrentIndex(0)
self.tabRedacInfos.setCurrentIndex(0)
@ -1132,6 +1130,7 @@ class Ui_MainWindow(object):
self.btnRedacShowOutline.toggled['bool'].connect(self.widget.setVisible)
self.cmbSummary.currentIndexChanged['int'].connect(self.tabSummary.setCurrentIndex)
self.tabSummary.currentChanged['int'].connect(self.cmbSummary.setCurrentIndex)
self.btnShowSubPlotSummary.toggled['bool'].connect(self.grpSubPlotSummary.setVisible)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
@ -1187,13 +1186,14 @@ class Ui_MainWindow(object):
self.tabPersos.setTabText(self.tabPersos.indexOf(self.tab_12), _translate("MainWindow", "Detailed infos"))
self.tabMain.setTabText(self.tabMain.indexOf(self.lytTabPersos), _translate("MainWindow", "Characters"))
self.groupBox_2.setTitle(_translate("MainWindow", "Plots"))
self.lineEdit_7.setPlaceholderText(_translate("MainWindow", "Filter"))
self.txtPlotFilter.setPlaceholderText(_translate("MainWindow", "Filter"))
self.label_25.setText(_translate("MainWindow", "Plot"))
self.label_31.setText(_translate("MainWindow", "Importance"))
self.label_26.setText(_translate("MainWindow", "Character(s)"))
self.label_27.setText(_translate("MainWindow", "Description"))
self.label_28.setText(_translate("MainWindow", "Result"))
self.tabPlot.setTabText(self.tabPlot.indexOf(self.infos_2), _translate("MainWindow", "Basic infos"))
self.grpSubPlotSummary.setTitle(_translate("MainWindow", "Summary:"))
self.tabPlot.setTabText(self.tabPlot.indexOf(self.tab_15), _translate("MainWindow", "Resolution steps"))
self.grpPlotSummary.setTitle(_translate("MainWindow", "Summary"))
self.comboBox_2.setItemText(0, _translate("MainWindow", "One paragraph"))
@ -1272,11 +1272,12 @@ class Ui_MainWindow(object):
self.actSettings.setText(_translate("MainWindow", "Settings"))
self.actSettings.setShortcut(_translate("MainWindow", "F8"))
from ui.editors.editorWidget import editorWidget
from ui.views.outlineView import outlineView
from ui.views.treeView import treeView
from ui.views.textEditView import textEditView
from ui.views.lineEditView import lineEditView
from ui.sldImportance import sldImportance
from ui.views.metadataView import metadataView
from ui.views.basicItemView import basicItemView
from ui.views.lineEditView import lineEditView
from ui.views.plotListView import plotListView
from ui.views.outlineView import outlineView
from ui.editors.editorWidget import editorWidget
from ui.views.metadataView import metadataView
from ui.sldImportance import sldImportance
from ui.views.treeView import treeView

View file

@ -499,8 +499,7 @@
</property>
<property name="icon">
<iconset theme="go-next">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -511,8 +510,7 @@
</property>
<property name="icon">
<iconset theme="go-next">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -523,8 +521,7 @@
</property>
<property name="icon">
<iconset theme="go-next">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -535,8 +532,7 @@
</property>
<property name="icon">
<iconset theme="go-next">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -594,8 +590,7 @@
</property>
<property name="icon">
<iconset theme="list-add">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -606,8 +601,7 @@
</property>
<property name="icon">
<iconset theme="list-remove">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -733,8 +727,7 @@
</property>
<property name="icon">
<iconset theme="go-next">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -796,8 +789,7 @@
</property>
<property name="icon">
<iconset theme="go-next">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -839,8 +831,7 @@
</property>
<property name="icon">
<iconset theme="list-add">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -851,8 +842,7 @@
</property>
<property name="icon">
<iconset theme="emblem-favorite">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="checkable">
<bool>true</bool>
@ -866,8 +856,7 @@
</property>
<property name="icon">
<iconset theme="list-remove">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -898,8 +887,7 @@
</property>
<property name="icon">
<iconset theme="go-next">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -928,20 +916,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QListView" name="lstPlots">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
</widget>
<widget class="plotListView" name="lstPlots"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_15">
@ -952,8 +927,7 @@
</property>
<property name="icon">
<iconset theme="list-add">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -964,13 +938,12 @@
</property>
<property name="icon">
<iconset theme="list-remove">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_7">
<widget class="QLineEdit" name="txtPlotFilter">
<property name="placeholderText">
<string>Filter</string>
</property>
@ -986,8 +959,7 @@
</property>
<property name="icon">
<iconset theme="text-x-generic">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="checkable">
<bool>true</bool>
@ -1003,7 +975,7 @@
</widget>
<widget class="QTabWidget" name="tabPlot">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<property name="documentMode">
<bool>true</bool>
@ -1094,8 +1066,7 @@
</property>
<property name="icon">
<iconset theme="list-add">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -1106,8 +1077,7 @@
</property>
<property name="icon">
<iconset theme="list-remove">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -1137,7 +1107,7 @@
<attribute name="title">
<string>Resolution steps</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_11">
<layout class="QVBoxLayout" name="verticalLayout_28">
<item>
<widget class="QListView" name="lstSubPlots">
<property name="dragDropMode">
@ -1149,7 +1119,16 @@
</widget>
</item>
<item>
<widget class="textEditView" name="txtSubPlotSummary"/>
<widget class="QGroupBox" name="grpSubPlotSummary">
<property name="title">
<string>Summary:</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="textEditView" name="txtSubPlotSummary"/>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
@ -1160,8 +1139,7 @@
</property>
<property name="icon">
<iconset theme="list-add">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -1172,8 +1150,7 @@
</property>
<property name="icon">
<iconset theme="list-remove">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -1191,8 +1168,7 @@
</property>
<property name="icon">
<iconset theme="go-top">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -1203,8 +1179,7 @@
</property>
<property name="icon">
<iconset theme="go-up">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -1215,8 +1190,7 @@
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -1227,8 +1201,7 @@
</property>
<property name="icon">
<iconset theme="go-bottom">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -1259,8 +1232,7 @@
</property>
<property name="icon">
<iconset theme="text-x-generic">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="checkable">
<bool>true</bool>
@ -1445,8 +1417,7 @@
</property>
<property name="icon">
<iconset theme="folder-new">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -1457,8 +1428,7 @@
</property>
<property name="icon">
<iconset theme="document-new">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -1469,8 +1439,7 @@
</property>
<property name="icon">
<iconset theme="list-remove">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -1494,8 +1463,7 @@
</property>
<property name="icon">
<iconset theme="text-x-generic">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="checkable">
<bool>true</bool>
@ -1540,8 +1508,7 @@
</property>
<property name="icon">
<iconset theme="folder-new">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -1552,8 +1519,7 @@
</property>
<property name="icon">
<iconset theme="document-new">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -1564,8 +1530,7 @@
</property>
<property name="icon">
<iconset theme="list-remove">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
@ -1600,8 +1565,7 @@
</property>
<property name="icon">
<iconset theme="text-x-generic">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="checkable">
<bool>true</bool>
@ -1733,8 +1697,7 @@
</property>
<property name="icon">
<iconset theme="view-fullscreen">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="shortcut">
<string>F11</string>
@ -1748,8 +1711,7 @@
</property>
<property name="icon">
<iconset theme="edit-find">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="checkable">
<bool>true</bool>
@ -2020,8 +1982,7 @@
<action name="actOpen">
<property name="icon">
<iconset theme="document-open">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="text">
<string>Open</string>
@ -2033,8 +1994,7 @@
<action name="actRecents">
<property name="icon">
<iconset theme="document-open-recent">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="text">
<string>Recents</string>
@ -2046,8 +2006,7 @@
<action name="actSave">
<property name="icon">
<iconset theme="document-save">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="text">
<string>Save</string>
@ -2059,8 +2018,7 @@
<action name="actSaveAs">
<property name="icon">
<iconset theme="document-save-as">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="text">
<string>Save as...</string>
@ -2072,8 +2030,7 @@
<action name="actQuit">
<property name="icon">
<iconset theme="application-exit">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="text">
<string>Quit</string>
@ -2085,8 +2042,7 @@
<action name="actNew">
<property name="icon">
<iconset theme="document-new">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="text">
<string>New</string>
@ -2104,8 +2060,7 @@
</property>
<property name="icon">
<iconset theme="system-help">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="text">
<string>Show help texts</string>
@ -2123,8 +2078,7 @@
</property>
<property name="icon">
<iconset theme="tools-check-spelling">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="text">
<string>Spellcheck</string>
@ -2188,8 +2142,7 @@
<action name="actSettings">
<property name="icon">
<iconset theme="preferences-system">
<normaloff/>
</iconset>
<normaloff>../../../../../../../.designer/backup</normaloff>../../../../../../../.designer/backup</iconset>
</property>
<property name="text">
<string>Settings</string>
@ -2244,6 +2197,11 @@
<header>ui.views.basicItemView.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>plotListView</class>
<extends>QListWidget</extends>
<header>ui.views.plotListView.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
@ -2254,8 +2212,8 @@
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>331</x>
<y>762</y>
<x>325</x>
<y>787</y>
</hint>
<hint type="destinationlabel">
<x>860</x>
@ -2359,6 +2317,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>btnShowSubPlotSummary</sender>
<signal>toggled(bool)</signal>
<receiver>grpSubPlotSummary</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>742</x>
<y>762</y>
</hint>
<hint type="destinationlabel">
<x>742</x>
<y>749</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="buttonGroup"/>

View file

@ -40,8 +40,8 @@ class outlineView(QTreeView, dndView, outlineBasics):
QTreeView.setModel(self, model)
# Setting delegates
self.outlineTitleDelegate = outlineTitleDelegate()
self.outlineTitleDelegate.setView(self)
self.outlineTitleDelegate = outlineTitleDelegate(self)
#self.outlineTitleDelegate.setView(self)
self.setItemDelegateForColumn(Outline.title.value, self.outlineTitleDelegate)
self.outlinePersoDelegate = outlinePersoDelegate(self.modelPersos)
self.setItemDelegateForColumn(Outline.POV.value, self.outlinePersoDelegate)

View file

@ -0,0 +1,113 @@
#!/usr/bin/env python
#--!-- coding: utf8 --!--
from qt import *
from enums import *
from functions import *
import settings
class plotListView(QListWidget):
def __init__(self, parent=None):
QListWidget.__init__(self, parent)
self._model = None
self._catRow = [-1, -1, -1]
self._catCheckedState = [True, True, True]
self._filter = ""
self._lastID = 1
self._updating = False
self.currentItemChanged.connect(self._currentItemChanged)
def setPlotModel(self, model):
self._model = model
self._model.dataChanged.connect(self.updateMaybe)
self._model.rowsInserted.connect(self.updateMaybe2)
self._model.rowsRemoved.connect(self.updateMaybe2)
self.updateItems()
def setFilter(self, text):
self._filter = text
self.updateItems()
def updateMaybe(self, topLeft, bottomRight):
if topLeft.parent() != QModelIndex():
return
if topLeft.column() <= Plot.name.value <= bottomRight.column():
# Update name
self.updateNames()
elif topLeft.column() <= Plot.importance.value <= bottomRight.column():
# Importance changed
self.updateItems()
def updateMaybe2(self, parent, first, last):
"Rows inserted or removed"
if parent == QModelIndex():
self.updateItems()
def updateNames(self):
for i in range(self.count()):
ID = self.item(i).data(Qt.UserRole)
if ID:
name = self._model.getNameByID(ID)
self.item(i).setText(name)
def updateItems(self):
self._updating = True
self.clear()
plots = self._model.getPlotsByImportance()
h = [self.tr("Main"), self.tr("Secondary"), self.tr("Minor")]
for i in range(3):
b = QPushButton(h[i])
b.setCheckable(True)
#b.setFlat(True)
b.setChecked(self._catCheckedState[i])
b.toggled.connect(self.updateCatState)
if self._catCheckedState[i]:
b.setStyleSheet("background:#e6e6ff; color:darkBlue; border-radius:0px; font:bold;")
else:
b.setStyleSheet("background:#EEE; color:333; border-radius:0px; font:bold;")
self.addItem(h[i])
self.setItemWidget(self.item(self.count()-1), b)
self._catRow[i] = self.count()-1
if self._catCheckedState[i]:
for ID in plots[i]:
name = self._model.getNameByID(ID)
if not self._filter.lower() in name.lower():
continue
item = QListWidgetItem(name)
item.setData(Qt.UserRole, ID)
self.addItem(item)
self.setCurrentItem(self.getItemByID(self._lastID))
self._updating = False
def updateCatState(self):
for i in range(3):
row = self._catRow[i]
b = self.itemWidget(self.item(row))
self._catCheckedState[i] = b.isChecked()
self.updateItems()
def _currentItemChanged(self, current, previous):
if self._updating:
return
if current.data(Qt.UserRole):
self._lastID = current.data(Qt.UserRole)
def getItemByID(self, ID):
for i in range(self.count()):
if self.item(i).data(Qt.UserRole) == ID:
return self.item(i)
def currentIndex(self):
ID = None
if self.currentItem():
ID = self.currentItem().data(Qt.UserRole)
return self._model.getIndexFromID(ID)

View file

@ -86,6 +86,14 @@ class textEditView(QTextEdit):
if self._highlighting and not self.highlighter:
self.highlighter = t2tHighlighter(self)
self.highlighter.setDefaultBlockFormat(self._defaultBlockFormat)
else:
self._index = QModelIndex()
try:
self.document().contentsChanged.disconnect(self.submit)
self._model.dataChanged.disconnect(self.update)
except:
pass
self.setPlainText("")
def setCurrentModelIndexes(self, indexes):
self._index = None