forked from VCTLabs/openadams
/
_naf_feature.py
136 lines (116 loc) · 6.08 KB
/
_naf_feature.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# -*- coding: utf-8 -*-
# $Id$
# -------------------------------------------------------------------
# Copyright 2010 Achim Köhler
#
# This file is part of openADAMS.
#
# openADAMS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License,
# or (at your option) any later version.
#
# openADAMS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with openADAMS. If not, see <http://www.gnu.org/licenses/>.
# -------------------------------------------------------------------
import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import Qt
import _naf_commons
import _naf_database as nafdb
import _naf_itemmodel
import _naf_tableview
import _naf_textviewer
class _cFeatureModel(_naf_itemmodel.cItemModel):
def __init__(self):
_naf_itemmodel.cItemModel.__init__(self, 'features')
# simple singleton pattern , see http://code.activestate.com/recipes/52558/
_featureModel = _cFeatureModel()
def cFeatureModel(): return _featureModel
class cFeatureDetailsView(_naf_commons.cArtifactDetailsView):
def __init__(self, parent, readOnly=True):
super(cFeatureDetailsView, self).__init__(parent)
self.mapper = QtGui.QDataWidgetMapper()
self.mapper.setItemDelegate(_naf_itemmodel.cItemDelegate(self))
self.mapper.setModel(cFeatureModel())
self.mapper.setSubmitPolicy(QtGui.QDataWidgetMapper.ManualSubmit)
columns = self.mapper.model().getColumns()
lbl = self.mapper.model().getLabel
layout = QtGui.QGridLayout()
self.setLayout(layout)
layout.addWidget(QtGui.QLabel(lbl("id")), 0, 0)
layout.addWidget(QtGui.QLabel(lbl("title")), 1, 0)
layout.addWidget(QtGui.QLabel(lbl("keywords")), 2, 0)
layout.addWidget(QtGui.QLabel(lbl("priority")), 3, 0)
layout.addWidget(QtGui.QLabel(lbl("risk")), 3, 2)
layout.addWidget(QtGui.QLabel(lbl("status")), 3, 4)
lblDescription = self.makeEditLinkLabel("description", readOnly)
lblDescription.linkActivated.connect(self.sendEditSignal)
layout.addWidget(lblDescription, 4, 0)
ledId = QtGui.QSpinBox(self, maximum=sys.maxint)
ledId.setReadOnly(True) # id is always read only
ledTitle = QtGui.QLineEdit(self, readOnly=readOnly)
cbxKeywords = QtGui.QComboBox(self, enabled=not readOnly, editable=True)
cbxKeywords.setModel(self.mapper.model().getHistoryModel('keywords_view'))
cbxPriority = QtGui.QComboBox(self, enabled=not readOnly)
cbxPriority.setModel(self.mapper.model().getLookupModel('priorityLUT'))
cbxStatus = QtGui.QComboBox(self, enabled=not readOnly)
cbxStatus.setModel(self.mapper.model().getLookupModel('statusLUT'))
cbxRisk = QtGui.QComboBox(self, enabled=not readOnly)
cbxRisk.setModel(self.mapper.model().getLookupModel('riskLUT'))
tedDescription = _naf_textviewer.cTextEditor(self, readOnly=readOnly)
tedDescription.setImageProvider(nafdb.getImageForId)
# addWidget(widget, fromRow, fromColumn, rowSpan, columnSpan, alignment)
layout.addWidget(ledId, 0, 1, 1, 5)
layout.addWidget(ledTitle, 1, 1, 1, 5)
layout.addWidget(cbxKeywords, 2, 1, 1, 5)
layout.addWidget(cbxPriority, 3, 1, 1, 1)
layout.addWidget(cbxRisk, 3, 3, 1, 1)
layout.addWidget(cbxStatus, 3, 5, 1, 1)
layout.addWidget(tedDescription, 4, 1, 1, 5)
layout.setColumnStretch(1, 1)
layout.setColumnStretch(3, 1)
layout.setColumnStretch(5, 1)
layout.setRowStretch(4, 1)
self.mapper.addMapping(ledId, columns.index('id'))
self.mapper.addMapping(ledTitle, columns.index('title'))
self.mapper.addMapping(cbxKeywords, columns.index('keywords'))
self.mapper.addMapping(cbxPriority, columns.index('priority'))
self.mapper.addMapping(cbxStatus, columns.index('status'))
self.mapper.addMapping(cbxRisk, columns.index('risk'))
self.mapper.addMapping(tedDescription, columns.index('description'))
class cFeatureView(QtGui.QTabWidget):
"""View/edit a requirement"""
TYPE_ID = nafdb.TYPE_FEATURE
def __init__(self, parent, isEditable=False):
QtGui.QTabWidget.__init__(self, parent)
self.defaultTitle = self.tr("New Feature")
self.editTitle = self.tr("Edit feature")
self.mapper = _naf_tableview.cNotifier()
self.detailsView = cFeatureDetailsView(self, readOnly=not isEditable)
self.addTab(self.detailsView, self.tr('Feature'))
self.mapper.addObserver(self.detailsView)
relationType = [_naf_tableview.NORMAL_RELATION, _naf_tableview.IGNORE_RELATION][isEditable]
self.requirementTableView = _naf_tableview.cItemTableView(
_naf_tableview.cItemTableModel('requirements', ('id', 'priority', 'status', 'complexity', 'assigned', 'effort', 'category', 'keywords' ,'title'),
relationType=relationType,
itemsCheckable=isEditable),
self)
self.addTab(self.requirementTableView, self.tr('Related Requirements'))
self.mapper.addObserver(self.requirementTableView)
self.usecaseTableView = _naf_tableview.cItemTableView(
_naf_tableview.cItemTableModel('usecases', ('id', 'priority', 'usefrequency', 'actors', 'stakeholders', 'keywords', 'title'),
relationType=relationType,
itemsCheckable=isEditable),
self)
self.addTab(self.usecaseTableView, self.tr('Related Usecases'))
self.mapper.addObserver(self.usecaseTableView)
def model(self):
return self.detailsView.mapper.model()
def submit(self):
self.mapper.submit()