itom 1.2.0
D:/git-itom/sources/itom/Qitom/models/breakPointModel.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2013, Institut für Technische Optik (ITO),
00005     Universität Stuttgart, Germany
00006 
00007     This file is part of itom.
00008   
00009     itom is free software; you can redistribute it and/or modify it
00010     under the terms of the GNU Library General Public Licence as published by
00011     the Free Software Foundation; either version 2 of the Licence, or (at
00012     your option) any later version.
00013 
00014     itom is distributed in the hope that it will be useful, but
00015     WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00017     General Public Licence for more details.
00018 
00019     You should have received a copy of the GNU Library General Public License
00020     along with itom. If not, see <http://www.gnu.org/licenses/>.
00021 *********************************************************************** */
00022 
00023 #ifndef BREAKPOINTMODEL_H
00024 #define BREAKPOINTMODEL_H
00025 
00026 #include "../common/sharedStructures.h"
00027 
00028 #include <qabstractitemmodel.h>
00029 #include <qlist.h>
00030 
00031 #include <qstring.h>
00032 #include <QDebug>
00033 
00034 
00035 namespace ito {
00036 
00038 
00042 struct BreakPointItem
00043 {
00045     BreakPointItem(): filename(""), lineno(-1), enabled(true), temporary(false), conditioned(false), condition(""), ignoreCount(0), pythonDbgBpNumber(-1)  {}
00046     QString filename;       
00047     int lineno;             
00048     bool enabled;           
00049     bool temporary;         
00050     bool conditioned;       
00051     QString condition;      
00052     int ignoreCount;        
00053     int pythonDbgBpNumber;  
00054 };
00055 
00056 } //end namespace ito
00057 
00058 Q_DECLARE_METATYPE(ito::BreakPointItem) //must be outside of namespace
00059 
00060 namespace ito
00061 {
00062 
00063 QDataStream &operator<<(QDataStream &out, const BreakPointItem &obj);
00064     
00065 
00066 QDataStream &operator>>(QDataStream &in, BreakPointItem &obj);
00067 
00068 class BreakPointModel : public QAbstractItemModel
00069 {
00070     Q_OBJECT
00071 
00072 public:
00073     BreakPointModel();
00074     ~BreakPointModel();
00075 
00076     RetVal saveState();
00077     RetVal restoreState();
00078 
00079     QVariant data(const QModelIndex &index, int role) const;
00080     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
00081     QModelIndex parent(const QModelIndex &index) const;
00082     int rowCount(const QModelIndex &parent = QModelIndex()) const;
00083     int columnCount(const QModelIndex &parent = QModelIndex()) const;
00084 
00085     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00086 
00087     RetVal addBreakPoint(BreakPointItem bp);
00088     RetVal deleteBreakPoint(QModelIndex index);
00089     RetVal deleteBreakPoints(QModelIndexList indizes);
00090 
00091     
00092 
00093     QModelIndex getFirstBreakPointIndex(const QString &filename, int lineNo) const;
00094     QModelIndexList getBreakPointIndizes(const QString &filename, int lineNo) const;
00095     QModelIndexList getBreakPointIndizes(const QString &filename) const;
00096 
00097     BreakPointItem getBreakPoint(const QString &filename, int lineNo) const;
00098     BreakPointItem getBreakPoint(const QModelIndex &index) const;
00099     QList<BreakPointItem> getBreakPoints(const QModelIndexList indizes) const;
00100 
00101     RetVal changeBreakPoint(const QModelIndex index, BreakPointItem bp, bool emitBreakPointChanged = true);
00102     RetVal changeBreakPoints(const QModelIndexList indizes, QList<BreakPointItem> bps, bool emitBreakPointChanged = true);
00103 
00104     QList<BreakPointItem> const getBreakpoints() { return m_breakpoints; };
00105 
00106     QModelIndexList getAllFileIndexes();
00107 
00108     RetVal resetAllPyBpNumbers();
00109     RetVal setPyBpNumber(const BreakPointItem &item, int pyBpNumber);
00110 
00111 protected:
00112 
00113 private:
00114     int nrOfBreakpointsInFile(const int fileIdx) const;
00115     QModelIndex getFilenameModelIndex(const QString &filename) const;
00116     int getBreakPointIndex(const QModelIndex &index) const;
00117     int getFileIndexFromInternalPtr(const void* ptr) const;
00118 
00120     static inline bool compareRow(QModelIndex a, QModelIndex b) { return a.row()>b.row(); };    
00121 
00122     QList<BreakPointItem> m_breakpoints;    
00123     QList<QString> m_headers;               
00124     QList<QVariant> m_alignment;            
00125     QList<QString> m_scriptFiles;
00126 
00127 signals:
00128     void breakPointAdded(BreakPointItem bp, int row);                       
00129     void breakPointDeleted(QString filename, int lineNo, int pyBpNumber);   
00130     void breakPointChanged(BreakPointItem oldBp, BreakPointItem newBp);     
00131 };
00132 
00133 } //end namespace ito
00134 
00135 
00136 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends