itom 2.0.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 #include <qstringlist.h>
00031 
00032 #include <qstring.h>
00033 #include <QDebug>
00034 
00035 
00036 namespace ito {
00037 
00039 
00043 struct BreakPointItem
00044 {
00046     BreakPointItem(): filename(""), lineno(-1), enabled(true), temporary(false), conditioned(false), condition(""), ignoreCount(0), pythonDbgBpNumber(-1)  {}
00047     QString filename;       
00048     int lineno;             
00049     bool enabled;           
00050     bool temporary;         
00051     bool conditioned;       
00052     QString condition;      
00053     int ignoreCount;        
00054     int pythonDbgBpNumber;  
00055 };
00056 
00057 } //end namespace ito
00058 
00059 Q_DECLARE_METATYPE(ito::BreakPointItem) //must be outside of namespace
00060 
00061 namespace ito
00062 {
00063 
00064 QDataStream &operator<<(QDataStream &out, const BreakPointItem &obj);
00065     
00066 
00067 QDataStream &operator>>(QDataStream &in, BreakPointItem &obj);
00068 
00069 class BreakPointModel : public QAbstractItemModel
00070 {
00071     Q_OBJECT
00072 
00073 public:
00074     BreakPointModel();
00075     ~BreakPointModel();
00076 
00077     RetVal saveState();
00078     RetVal restoreState();
00079 
00080     QVariant data(const QModelIndex &index, int role) const;
00081     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
00082     QModelIndex parent(const QModelIndex &index) const;
00083     int rowCount(const QModelIndex &parent = QModelIndex()) const;
00084     int columnCount(const QModelIndex &parent = QModelIndex()) const;
00085 
00086     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00087 
00088     RetVal addBreakPoint(BreakPointItem bp);
00089     RetVal deleteBreakPoint(QModelIndex index);
00090     RetVal deleteBreakPoints(QModelIndexList indizes);
00091 
00092     
00093 
00094     QModelIndex getFirstBreakPointIndex(const QString &filename, int lineNo) const;
00095     QModelIndexList getBreakPointIndizes(const QString &filename, int lineNo) const;
00096     QModelIndexList getBreakPointIndizes(const QString &filename) const;
00097     QModelIndexList getAllBreakPointIndizes();
00098 
00099     BreakPointItem getBreakPoint(const QString &filename, int lineNo) const;
00100     BreakPointItem getBreakPoint(const QModelIndex &index) const;
00101     QList<BreakPointItem> getBreakPoints(const QModelIndexList indizes) const;
00102 
00103     RetVal changeBreakPoint(const QModelIndex index, BreakPointItem bp, bool emitBreakPointChanged = true);
00104     RetVal changeBreakPoints(const QModelIndexList indizes, QList<BreakPointItem> bps, bool emitBreakPointChanged = true);
00105 
00106     QList<BreakPointItem> const getBreakpoints() { return m_breakpoints; };
00107 
00108     QModelIndexList getAllFileIndexes();
00109 
00110     RetVal resetAllPyBpNumbers();
00111     RetVal setPyBpNumber(const BreakPointItem &item, int pyBpNumber);
00112 
00113 protected:
00114 
00115 private:
00116     int nrOfBreakpointsInFile(const int fileIdx) const;
00117     QModelIndex getFilenameModelIndex(const QString &filename) const;
00118     int getBreakPointIndex(const QModelIndex &index) const;
00119     int getFileIndexFromInternalPtr(const void* ptr) const;
00120 
00122     static inline bool compareRow(QModelIndex a, QModelIndex b) { return a.row()>b.row(); };    
00123 
00124     QList<BreakPointItem> m_breakpoints;    
00125     QList<QString> m_headers;               
00126     QList<QVariant> m_alignment;            
00127     QStringList m_scriptFiles;
00128     Qt::CaseSensitivity m_filenameCaseSensitivity;
00129 
00130 signals:
00131     void breakPointAdded(BreakPointItem bp, int row);                       
00132     void breakPointDeleted(QString filename, int lineNo, int pyBpNumber);   
00133     void breakPointChanged(BreakPointItem oldBp, BreakPointItem newBp);     
00134 };
00135 
00136 } //end namespace ito
00137 
00138 
00139 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends