19 @signal dataAboutToBeChanged(QModelIndex, QModelIndex) emitted to indicate |
19 @signal dataAboutToBeChanged(QModelIndex, QModelIndex) emitted to indicate |
20 a change of the data |
20 a change of the data |
21 """ |
21 """ |
22 dataAboutToBeChanged = pyqtSignal(QModelIndex, QModelIndex) |
22 dataAboutToBeChanged = pyqtSignal(QModelIndex, QModelIndex) |
23 |
23 |
24 def __init__(self, parent=None): |
24 def __init__(self, project, parent=None): |
25 """ |
25 """ |
26 Constructor |
26 Constructor |
27 |
27 |
|
28 @param project reference to the project object |
|
29 @type Project |
28 @param parent reference to the parent widget |
30 @param parent reference to the parent widget |
29 @type QObject |
31 @type QObject |
30 """ |
32 """ |
31 super(BreakPointModel, self).__init__(parent) |
33 super(BreakPointModel, self).__init__(parent) |
|
34 |
|
35 self.__project = project |
32 |
36 |
33 self.breakpoints = [] |
37 self.breakpoints = [] |
34 self.header = [ |
38 self.header = [ |
35 self.tr("Filename"), |
39 self.tr("Filename"), |
36 self.tr("Line"), |
40 self.tr("Line"), |
87 """ |
91 """ |
88 if not index.isValid(): |
92 if not index.isValid(): |
89 return None |
93 return None |
90 |
94 |
91 if role == Qt.DisplayRole: |
95 if role == Qt.DisplayRole: |
92 if index.column() in [0, 1, 2, 5]: |
96 if index.column() == 0: |
|
97 filename = self.breakpoints[index.row()][0] |
|
98 if self.__project.isOpen(): |
|
99 return self.__project.getRelativePath(filename) |
|
100 else: |
|
101 return filename |
|
102 elif index.column() in (1, 2, 5): |
93 return self.breakpoints[index.row()][index.column()] |
103 return self.breakpoints[index.row()][index.column()] |
94 |
104 |
95 if role == Qt.CheckStateRole: |
105 if role == Qt.CheckStateRole: |
96 if index.column() in [3, 4]: |
106 if index.column() in (3, 4): |
97 return self.breakpoints[index.row()][index.column()] |
107 return self.breakpoints[index.row()][index.column()] |
98 |
108 |
99 if role == Qt.ToolTipRole: |
109 if role == Qt.ToolTipRole: |
100 if index.column() in [0, 2]: |
110 if index.column() in (0, 2): |
101 return self.breakpoints[index.row()][index.column()] |
111 return self.breakpoints[index.row()][index.column()] |
102 |
112 |
103 if role == Qt.TextAlignmentRole: |
113 if role == Qt.TextAlignmentRole: |
104 if index.column() < len(self.alignments): |
114 if index.column() < len(self.alignments): |
105 return self.alignments[index.column()] |
115 return self.alignments[index.column()] |