itom
Loading...
Searching...
No Matches
breakPointModel.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität 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
36namespace ito {
37
39
55
56} //end namespace ito
57
58Q_DECLARE_METATYPE(ito::BreakPointItem) //must be outside of namespace
59
60namespace ito
61{
62
63QDataStream &operator<<(QDataStream &out, const BreakPointItem &obj);
64
65
66QDataStream &operator>>(QDataStream &in, BreakPointItem &obj);
67
68class BreakPointModel : public QAbstractItemModel
69{
70 Q_OBJECT
71
72public:
75
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
88 RetVal deleteBreakPoint(const QModelIndex &index);
89 RetVal deleteBreakPoints(const QModelIndexList &indizes);
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
109 RetVal setPyBpNumber(const BreakPointItem &item, int pyBpNumber);
110
111 QSize span(const QModelIndex &index) const;
112
113protected:
114
115private:
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
130signals:
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
model for management of all breakpoints. This model will be displayed by a viewer-widget in the main ...
Definition breakPointModel.h:69
void breakPointAdded(BreakPointItem bp, int row)
BreakPointModel()
constructor
Definition breakPointModel.cpp:64
QList< BreakPointItem > getBreakPoints(const QModelIndexList &indizes) const
returns list of BreakPointItem corresponding to given list of model indices
Definition breakPointModel.cpp:943
QModelIndexList getAllFileIndexes()
This function returns a list of all files that contain breakpoints.
Definition breakPointModel.cpp:836
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
returns QModelIndex for given row and column
Definition breakPointModel.cpp:474
int getBreakPointIndex(const QModelIndex &index) const
returns the index for given QModelIndex
Definition breakPointModel.cpp:800
QModelIndex getFilenameModelIndex(const QString &filename) const
This function returns the QModelindex of the given File.
Definition breakPointModel.cpp:631
static bool compareRow(QModelIndex a, QModelIndex b)
helper-method for sorting different breakpoints with respect to row-index of both given QModelIndex
Definition breakPointModel.h:122
RetVal deleteAllBreakPoints()
delete all breakpoints
Definition breakPointModel.cpp:297
RetVal addBreakPoint(BreakPointItem bp)
adds given breakpoint to model
Definition breakPointModel.cpp:165
int columnCount(const QModelIndex &parent=QModelIndex()) const
counts number of columns in this model (corresponds to number of header-elements)
Definition breakPointModel.cpp:337
void breakPointDeleted(QString filename, int lineIdx, int pyBpNumber)
QModelIndex getFirstBreakPointIndex(const QString &filename, int lineIdx) const
returns QModelIndex for first breakpoint which is found in given filename and at given line number.
Definition breakPointModel.cpp:650
RetVal restoreState()
Restores the breakpoint model from the settings.
Definition breakPointModel.cpp:128
BreakPointItem getBreakPoint(const QString &filename, int lineIdx) const
returns BreakPointItem for breakpoint being in given file and at given line number
Definition breakPointModel.cpp:752
QList< QString > m_headers
Definition breakPointModel.h:125
QList< QVariant > m_alignment
Definition breakPointModel.h:126
~BreakPointModel()
destructor
Definition breakPointModel.cpp:85
QModelIndexList getAllBreakPointIndizes()
returns a List of all Breakpoints, doesn't matter in which file they are.
Definition breakPointModel.cpp:734
QModelIndex parent(const QModelIndex &index) const
returns parent of given QModelIndex
Definition breakPointModel.cpp:526
RetVal deleteBreakPoint(const QModelIndex &index)
delete breakpoint given by its QModelIndex
Definition breakPointModel.cpp:215
int nrOfBreakpointsInFile(const int fileIdx) const
This function returns the number of breakpoints in the given File.
Definition breakPointModel.cpp:606
RetVal setPyBpNumber(const BreakPointItem &item, int pyBpNumber)
set python breakpoint number of breakpoint at given row in the model
Definition breakPointModel.cpp:1014
QList< BreakPointItem > m_breakpoints
Definition breakPointModel.h:124
int rowCount(const QModelIndex &parent=QModelIndex()) const
counts number of breakpoints in this model
Definition breakPointModel.cpp:316
RetVal resetAllPyBpNumbers()
resets all python breakpoint numbers to -1.
Definition breakPointModel.cpp:992
RetVal changeBreakPoints(const QModelIndexList indizes, QList< BreakPointItem > bps, bool emitBreakPointChanged=true)
change multiple breakpoints to data, given by list of BreakPointItem
Definition breakPointModel.cpp:967
QModelIndexList getBreakPointIndizes(const QString &filename, int lineIdx) const
returns a list of QModelIndex for all breakpoints, which are registered in given file and at given li...
Definition breakPointModel.cpp:693
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
returns header element at given position
Definition breakPointModel.cpp:569
RetVal changeBreakPoint(const QModelIndex index, BreakPointItem bp, bool emitBreakPointChanged=true)
changes breakpoint, given by its QModelIndex to values, determined by BreakPointItem
Definition breakPointModel.cpp:857
RetVal deleteBreakPoints(const QModelIndexList &indizes)
delete multiple breakpoints given by a list of QModelIndex
Definition breakPointModel.cpp:269
RetVal saveState()
Saves the breakpoint model into the settings.
Definition breakPointModel.cpp:98
QVariant data(const QModelIndex &index, int role) const
overwritten data method of QAbstractItemModel
Definition breakPointModel.cpp:350
Class for managing status values (like errors or warning)
Definition retVal.h:54
Definition apiFunctionsGraph.cpp:40
item of BreakPointModel
Definition breakPointModel.h:43
int lineIdx
Definition breakPointModel.h:47
bool temporary
Definition breakPointModel.h:49
QString filename
Definition breakPointModel.h:46
int ignoreCount
Definition breakPointModel.h:52
bool enabled
Definition breakPointModel.h:48
QString condition
Definition breakPointModel.h:51
int pythonDbgBpNumber
Definition breakPointModel.h:53
BreakPointItem()
Definition breakPointModel.h:45
bool conditioned
Definition breakPointModel.h:50