Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

htmllistview: re-order classes, no code change

View, Model, Delegate is a more natural class order

Changeset 814b5175e85d

Parent b7ce64bf3caf

by Steve Borho

Changes to one file · Browse files at 814b5175e85d Showing diff from parent b7ce64bf3caf Diff from another changeset...

 
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
 
85
86
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
89
90
 
12
13
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
16
17
 
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
@@ -12,33 +12,6 @@
   from tortoisehg.hgqt import qtlib   -class HtmlModel(QAbstractListModel): - - def __init__(self, strings): - QAbstractTableModel.__init__(self) - self.strings = strings - - def rowCount(self, parent): - if not parent.isValid(): - return len(self.strings) - return 0 - - def data(self, index, role): - if not index.isValid() or role != Qt.DisplayRole: - return QVariant() - if index.row() < 0 or index.row() >= len(self.strings): - return QVariant() - return QVariant(self.strings[index.row()]) - - def headerData(self, col, orientation, role): - if col != 0 or role != Qt.DisplayRole or orientation != Qt.Horizontal: - return QVariant() - else: - return QVariant("Multiline Rich-Text List") - - def flags(self, index): - return Qt.ItemIsSelectable | Qt.ItemIsEnabled -  class HtmlListView(QListView):   def __init__(self, model):   QListView.__init__(self) @@ -85,6 +58,33 @@
  QApplication.clipboard().setText(selectionText, mode)     +class HtmlModel(QAbstractListModel): + def __init__(self, strings): + QAbstractTableModel.__init__(self) + self.strings = strings + + def rowCount(self, parent): + if not parent.isValid(): + return len(self.strings) + return 0 + + def data(self, index, role): + if not index.isValid() or role != Qt.DisplayRole: + return QVariant() + if index.row() < 0 or index.row() >= len(self.strings): + return QVariant() + return QVariant(self.strings[index.row()]) + + def headerData(self, col, orientation, role): + if col != 0 or role != Qt.DisplayRole or orientation != Qt.Horizontal: + return QVariant() + else: + return QVariant("Multiline Rich-Text List") + + def flags(self, index): + return Qt.ItemIsSelectable | Qt.ItemIsEnabled + +  class HTMLDelegate(QStyledItemDelegate):   def __init__(self, parent=0, cols=None):   QStyledItemDelegate.__init__(self, parent)