2015-06-09 22:32:43 +12:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#--!-- coding: utf8 --!--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from qt import *
|
|
|
|
from enums import *
|
|
|
|
from functions import *
|
|
|
|
from ui.views.treeOutlineDelegates import *
|
|
|
|
from ui.views.dndView import *
|
2015-06-10 01:52:20 +12:00
|
|
|
from ui.views.outlineBasics import *
|
2015-06-09 22:32:43 +12:00
|
|
|
|
2015-06-10 01:52:20 +12:00
|
|
|
class outlineView(QTreeView, dndView, outlineBasics):
|
2015-06-09 22:32:43 +12:00
|
|
|
|
2015-06-10 00:03:22 +12:00
|
|
|
def __init__(self, parent=None, modelPersos=None, modelLabels=None):
|
2015-06-09 22:32:43 +12:00
|
|
|
QTreeView.__init__(self, parent)
|
2015-06-09 22:47:29 +12:00
|
|
|
dndView.__init__(self)
|
2015-06-10 01:52:20 +12:00
|
|
|
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-09 22:32:43 +12:00
|
|
|
self.header().setStretchLastSection(False)
|
|
|
|
|
|
|
|
def setModelPersos(self, model):
|
|
|
|
# This is used by treeOutlinePersoDelegate to select character
|
|
|
|
self.modelPersos = model
|
|
|
|
|
2015-06-10 00:03:22 +12:00
|
|
|
def setModelLabels(self, model):
|
|
|
|
# This is used by treeOutlineLabelDelegate to display labels
|
|
|
|
self.modelLabels = model
|
|
|
|
|
2015-06-09 22:32:43 +12:00
|
|
|
def setModel(self, model):
|
|
|
|
QTreeView.setModel(self, model)
|
|
|
|
|
|
|
|
# Setting delegates
|
|
|
|
self.treePlanOutlinePersoDelegate = treeOutlinePersoDelegate(self.modelPersos)
|
|
|
|
self.setItemDelegateForColumn(Outline.POV.value, self.treePlanOutlinePersoDelegate)
|
|
|
|
self.treePlanOutlineCompileDelegate = treeOutlineCompileDelegate()
|
|
|
|
self.setItemDelegateForColumn(Outline.compile.value, self.treePlanOutlineCompileDelegate)
|
|
|
|
self.treePlanOutlineStatusDelegate = treeOutlineStatusDelegate()
|
|
|
|
self.setItemDelegateForColumn(Outline.status.value, self.treePlanOutlineStatusDelegate)
|
|
|
|
self.treePlanOutlineGoalPercentageDelegate = treeOutlineGoalPercentageDelegate()
|
|
|
|
self.setItemDelegateForColumn(Outline.goalPercentage.value, self.treePlanOutlineGoalPercentageDelegate)
|
2015-06-10 00:03:22 +12:00
|
|
|
self.treePlanOutlineLabelDelegate = treeOutlineLabelDelegate(self.modelLabels)
|
|
|
|
self.setItemDelegateForColumn(Outline.label.value, self.treePlanOutlineLabelDelegate)
|
2015-06-09 22:32:43 +12:00
|
|
|
|
|
|
|
# Hiding columns
|
|
|
|
for c in range(1, self.model().columnCount()):
|
|
|
|
self.hideColumn(c)
|
|
|
|
for c in [Outline.POV.value, Outline.status.value, Outline.compile.value,
|
2015-06-10 00:03:22 +12:00
|
|
|
Outline.wordCount.value, Outline.goal.value, Outline.goalPercentage.value,
|
|
|
|
Outline.label.value]:
|
2015-06-09 22:32:43 +12:00
|
|
|
self.showColumn(c)
|
|
|
|
|
|
|
|
self.header().setSectionResizeMode(Outline.title.value, QHeaderView.Stretch)
|
|
|
|
self.header().setSectionResizeMode(Outline.POV.value, QHeaderView.ResizeToContents)
|
|
|
|
self.header().setSectionResizeMode(Outline.status.value, QHeaderView.ResizeToContents)
|
|
|
|
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)
|
|
|
|
|
|
|
|
def setRootIndex(self, index):
|
|
|
|
QTreeView.setRootIndex(self, index)
|
|
|
|
self.treePlanOutlineGoalPercentageDelegate = treeOutlineGoalPercentageDelegate(index)
|
|
|
|
self.setItemDelegateForColumn(Outline.goalPercentage.value, self.treePlanOutlineGoalPercentageDelegate)
|
|
|
|
|
|
|
|
def dragMoveEvent(self, event):
|
|
|
|
dndView.dragMoveEvent(self, event)
|
|
|
|
QTreeView.dragMoveEvent(self, event)
|
2015-06-10 01:52:20 +12:00
|
|
|
|
|
|
|
def mouseReleaseEvent(self, event):
|
|
|
|
QTreeView.mouseReleaseEvent(self, event)
|
|
|
|
outlineBasics.mouseReleaseEvent(self, event)
|
2015-06-09 22:32:43 +12:00
|
|
|
|