itom  4.1.0
breakPointModel.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom.
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************** */
22 
23 #ifndef BREAKPOINTMODEL_H
24 #define BREAKPOINTMODEL_H
25 
26 #include "../common/sharedStructures.h"
27 
28 #include <qabstractitemmodel.h>
29 #include <qlist.h>
30 #include <qstringlist.h>
31 
32 #include <qstring.h>
33 #include <QDebug>
34 
35 
36 namespace ito {
37 
39 
43 {
46  QString filename;
47  int lineIdx;
48  bool enabled;
49  bool temporary;
50  bool conditioned;
51  QString condition;
54 };
55 
56 } //end namespace ito
57 
58 Q_DECLARE_METATYPE(ito::BreakPointItem) //must be outside of namespace
59 
60 namespace ito
61 {
62 
63 QDataStream &operator<<(QDataStream &out, const BreakPointItem &obj);
64 
65 
66 QDataStream &operator>>(QDataStream &in, BreakPointItem &obj);
67 
68 class BreakPointModel : public QAbstractItemModel
69 {
70  Q_OBJECT
71 
72 public:
74  ~BreakPointModel();
75 
76  RetVal saveState();
77  RetVal restoreState();
78 
79  QVariant data(const QModelIndex &index, int role) const;
80  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
81  QModelIndex parent(const QModelIndex &index) const;
82  int rowCount(const QModelIndex &parent = QModelIndex()) const;
83  int columnCount(const QModelIndex &parent = QModelIndex()) const;
84 
85  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
86 
87  RetVal addBreakPoint(BreakPointItem bp);
88  RetVal deleteBreakPoint(const QModelIndex &index);
89  RetVal deleteBreakPoints(const QModelIndexList &indizes);
90  RetVal deleteAllBreakPoints();
91 
92  QModelIndex getFirstBreakPointIndex(const QString &filename, int lineIdx) const;
93  QModelIndexList getBreakPointIndizes(const QString &filename, int lineIdx) const;
94  QModelIndexList getBreakPointIndizes(const QString &filename) const;
95  QModelIndexList getAllBreakPointIndizes();
96 
97  BreakPointItem getBreakPoint(const QString &filename, int lineIdx) const;
98  BreakPointItem getBreakPoint(const QModelIndex &index) const;
99  QList<BreakPointItem> getBreakPoints(const QModelIndexList &indizes) const;
100 
101  RetVal changeBreakPoint(const QModelIndex index, BreakPointItem bp, bool emitBreakPointChanged = true);
102  RetVal changeBreakPoints(const QModelIndexList indizes, QList<BreakPointItem> bps, bool emitBreakPointChanged = true);
103 
104  QList<BreakPointItem> const getBreakpoints() { return m_breakpoints; };
105 
106  QModelIndexList getAllFileIndexes();
107 
108  RetVal resetAllPyBpNumbers();
109  RetVal setPyBpNumber(const BreakPointItem &item, int pyBpNumber);
110 
111  QSize span(const QModelIndex &index) const;
112 
113 protected:
114 
115 private:
116  int nrOfBreakpointsInFile(const int fileIdx) const;
117  QModelIndex getFilenameModelIndex(const QString &filename) const;
118  int getBreakPointIndex(const QModelIndex &index) const;
119  int getFileIndexFromInternalPtr(const void* ptr) const;
120 
122  static inline bool compareRow(QModelIndex a, QModelIndex b) { return a.row()>b.row(); };
123 
124  QList<BreakPointItem> m_breakpoints;
125  QList<QString> m_headers;
126  QList<QVariant> m_alignment;
127  QStringList m_scriptFiles;
128  Qt::CaseSensitivity m_filenameCaseSensitivity;
129 
130 signals:
132  void breakPointAdded(BreakPointItem bp, int row);
133 
136  void breakPointDeleted(QString filename, int lineIdx, int pyBpNumber);
137 
139  void breakPointChanged(BreakPointItem oldBp, BreakPointItem newBp);
140 };
141 
142 } //end namespace ito
143 
144 
145 #endif
BreakPointItem()
Definition: breakPointModel.h:45
int lineIdx
Definition: breakPointModel.h:47
model for management of all breakpoints. This model will be displayed by a viewer-widget in the main ...
bool conditioned
Definition: breakPointModel.h:50
QString condition
Definition: breakPointModel.h:51
Definition: apiFunctionsGraph.cpp:39
bool temporary
Definition: breakPointModel.h:49
int ignoreCount
Definition: breakPointModel.h:52
bool enabled
Definition: breakPointModel.h:48
QString filename
Definition: breakPointModel.h:46
int pythonDbgBpNumber
Definition: breakPointModel.h:53
item of BreakPointModel
Definition: breakPointModel.h:42