itom  3.0.0
breakPointModel.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2016, 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 
44 {
47  QString filename;
48  int lineno;
49  bool enabled;
50  bool temporary;
51  bool conditioned;
52  QString condition;
55 };
56 
57 } //end namespace ito
58 
59 Q_DECLARE_METATYPE(ito::BreakPointItem) //must be outside of namespace
60 
61 namespace ito
62 {
63 
64 QDataStream &operator<<(QDataStream &out, const BreakPointItem &obj);
65 
66 
67 QDataStream &operator>>(QDataStream &in, BreakPointItem &obj);
68 
69 class BreakPointModel : public QAbstractItemModel
70 {
71  Q_OBJECT
72 
73 public:
75  ~BreakPointModel();
76 
77  RetVal saveState();
78  RetVal restoreState();
79 
80  QVariant data(const QModelIndex &index, int role) const;
81  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
82  QModelIndex parent(const QModelIndex &index) const;
83  int rowCount(const QModelIndex &parent = QModelIndex()) const;
84  int columnCount(const QModelIndex &parent = QModelIndex()) const;
85 
86  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
87 
88  RetVal addBreakPoint(BreakPointItem bp);
89  RetVal deleteBreakPoint(const QModelIndex &index);
90  RetVal deleteBreakPoints(const QModelIndexList &indizes);
91  RetVal deleteAllBreakPoints();
92 
93  QModelIndex getFirstBreakPointIndex(const QString &filename, int lineNo) const;
94  QModelIndexList getBreakPointIndizes(const QString &filename, int lineNo) const;
95  QModelIndexList getBreakPointIndizes(const QString &filename) const;
96  QModelIndexList getAllBreakPointIndizes();
97 
98  BreakPointItem getBreakPoint(const QString &filename, int lineNo) const;
99  BreakPointItem getBreakPoint(const QModelIndex &index) const;
100  QList<BreakPointItem> getBreakPoints(const QModelIndexList indizes) const;
101 
102  RetVal changeBreakPoint(const QModelIndex index, BreakPointItem bp, bool emitBreakPointChanged = true);
103  RetVal changeBreakPoints(const QModelIndexList indizes, QList<BreakPointItem> bps, bool emitBreakPointChanged = true);
104 
105  QList<BreakPointItem> const getBreakpoints() { return m_breakpoints; };
106 
107  QModelIndexList getAllFileIndexes();
108 
109  RetVal resetAllPyBpNumbers();
110  RetVal setPyBpNumber(const BreakPointItem &item, int pyBpNumber);
111 
112 protected:
113 
114 private:
115  int nrOfBreakpointsInFile(const int fileIdx) const;
116  QModelIndex getFilenameModelIndex(const QString &filename) const;
117  int getBreakPointIndex(const QModelIndex &index) const;
118  int getFileIndexFromInternalPtr(const void* ptr) const;
119 
121  static inline bool compareRow(QModelIndex a, QModelIndex b) { return a.row()>b.row(); };
122 
123  QList<BreakPointItem> m_breakpoints;
124  QList<QString> m_headers;
125  QList<QVariant> m_alignment;
126  QStringList m_scriptFiles;
127  Qt::CaseSensitivity m_filenameCaseSensitivity;
128 
129 signals:
130  void breakPointAdded(BreakPointItem bp, int row);
131  void breakPointDeleted(QString filename, int lineNo, int pyBpNumber);
132  void breakPointChanged(BreakPointItem oldBp, BreakPointItem newBp);
133 };
134 
135 } //end namespace ito
136 
137 
138 #endif
BreakPointItem()
Definition: breakPointModel.h:46
model for management of all breakpoints. This model will be displayed by a viewer-widget in the main ...
Class for managing status values (like errors or warning)
Definition: retVal.h:54
bool conditioned
Definition: breakPointModel.h:51
QString condition
Definition: breakPointModel.h:52
Definition: apiFunctionsGraph.cpp:39
bool temporary
Definition: breakPointModel.h:50
int ignoreCount
Definition: breakPointModel.h:53
bool enabled
Definition: breakPointModel.h:49
QString filename
Definition: breakPointModel.h:47
int lineno
Definition: breakPointModel.h:48
int pythonDbgBpNumber
Definition: breakPointModel.h:54
item of BreakPointModel
Definition: breakPointModel.h:43