manuskript/manuskript/ui/views/outlineView.py

87 lines
3.7 KiB
Python
Raw Normal View History

2015-06-09 22:32:43 +12:00
#!/usr/bin/env python
#--!-- coding: utf8 --!--
from qt import *
from enums import *
from functions import *
2015-06-18 03:15:13 +12:00
from ui.views.outlineDelegates import *
2015-06-09 22:32:43 +12:00
from ui.views.dndView import *
from ui.views.outlineBasics import *
2015-06-09 22:32:43 +12:00
class outlineView(QTreeView, dndView, outlineBasics):
2015-06-09 22:32:43 +12:00
2015-06-11 01:57:44 +12:00
def __init__(self, parent=None, modelPersos=None, modelLabels=None, modelStatus=None):
2015-06-09 22:32:43 +12:00
QTreeView.__init__(self, parent)
dndView.__init__(self)
outlineBasics.__init__(self, parent)
2015-06-09 22:32:43 +12:00
self.modelPersos = modelPersos
2015-06-10 00:03:22 +12:00
self.modelLabels = modelLabels
2015-06-11 01:57:44 +12:00
self.modelStatus = modelStatus
2015-06-09 22:32:43 +12:00
self.header().setStretchLastSection(False)
def setModelPersos(self, model):
2015-06-18 03:15:13 +12:00
# This is used by outlinePersoDelegate to select character
2015-06-09 22:32:43 +12:00
self.modelPersos = model
2015-06-10 00:03:22 +12:00
def setModelLabels(self, model):
2015-06-18 03:15:13 +12:00
# This is used by outlineLabelDelegate to display labels
2015-06-10 00:03:22 +12:00
self.modelLabels = model
2015-06-11 01:57:44 +12:00
def setModelStatus(self, model):
2015-06-18 03:15:13 +12:00
# This is used by outlineStatusDelegate to display statuses
2015-06-11 01:57:44 +12:00
self.modelStatus = model
2015-06-09 22:32:43 +12:00
def setModel(self, model):
QTreeView.setModel(self, model)
# Setting delegates
2015-06-22 23:11:45 +12:00
self.outlineTitleDelegate = outlineTitleDelegate(self)
#self.outlineTitleDelegate.setView(self)
2015-06-18 03:15:13 +12:00
self.setItemDelegateForColumn(Outline.title.value, self.outlineTitleDelegate)
self.outlinePersoDelegate = outlinePersoDelegate(self.modelPersos)
self.setItemDelegateForColumn(Outline.POV.value, self.outlinePersoDelegate)
self.outlineCompileDelegate = outlineCompileDelegate()
self.setItemDelegateForColumn(Outline.compile.value, self.outlineCompileDelegate)
self.outlineStatusDelegate = outlineStatusDelegate(self.modelStatus)
self.setItemDelegateForColumn(Outline.status.value, self.outlineStatusDelegate)
self.outlineGoalPercentageDelegate = outlineGoalPercentageDelegate()
self.setItemDelegateForColumn(Outline.goalPercentage.value, self.outlineGoalPercentageDelegate)
self.outlineLabelDelegate = outlineLabelDelegate(self.modelLabels)
self.setItemDelegateForColumn(Outline.label.value, self.outlineLabelDelegate)
2015-06-09 22:32:43 +12:00
# Hiding columns
2015-06-18 04:40:55 +12:00
self.hideColumns()
2015-06-09 22:32:43 +12:00
self.header().setSectionResizeMode(Outline.title.value, QHeaderView.Stretch)
self.header().setSectionResizeMode(Outline.POV.value, QHeaderView.ResizeToContents)
self.header().setSectionResizeMode(Outline.status.value, QHeaderView.ResizeToContents)
2015-06-11 05:45:42 +12:00
self.header().setSectionResizeMode(Outline.label.value, QHeaderView.ResizeToContents)
2015-06-09 22:32:43 +12:00
self.header().setSectionResizeMode(Outline.compile.value, QHeaderView.ResizeToContents)
self.header().setSectionResizeMode(Outline.wordCount.value, QHeaderView.ResizeToContents)
self.header().setSectionResizeMode(Outline.goal.value, QHeaderView.ResizeToContents)
self.header().setSectionResizeMode(Outline.goalPercentage.value, QHeaderView.ResizeToContents)
2015-06-18 04:40:55 +12:00
def hideColumns(self):
for c in range(self.model().columnCount()):
self.hideColumn(c)
for c in settings.outlineViewColumns:
self.showColumn(c)
2015-06-09 22:32:43 +12:00
def setRootIndex(self, index):
QTreeView.setRootIndex(self, index)
2015-06-18 03:15:13 +12:00
self.outlineGoalPercentageDelegate = outlineGoalPercentageDelegate(index)
self.setItemDelegateForColumn(Outline.goalPercentage.value, self.outlineGoalPercentageDelegate)
2015-06-09 22:32:43 +12:00
def dragMoveEvent(self, event):
dndView.dragMoveEvent(self, event)
QTreeView.dragMoveEvent(self, event)
def mouseReleaseEvent(self, event):
QTreeView.mouseReleaseEvent(self, event)
outlineBasics.mouseReleaseEvent(self, event)
2015-06-09 22:32:43 +12:00