2020-08-31 04:03:41 +08:00
|
|
|
#ifndef TRACEMARKERMODEL_H
|
|
|
|
#define TRACEMARKERMODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
#include "tracemarker.h"
|
|
|
|
#include <vector>
|
|
|
|
#include "tracemodel.h"
|
2020-09-21 20:06:20 +08:00
|
|
|
#include <QStyledItemDelegate>
|
2020-08-31 04:03:41 +08:00
|
|
|
|
2020-10-20 23:03:49 +08:00
|
|
|
class MarkerTraceDelegate : public QStyledItemDelegate
|
2020-08-31 04:03:41 +08:00
|
|
|
{
|
|
|
|
Q_OBJECT;
|
2020-11-03 07:37:06 +08:00
|
|
|
QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const override;
|
2020-08-31 04:03:41 +08:00
|
|
|
QWidget *createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
|
|
|
|
void setEditorData(QWidget * editor, const QModelIndex & index) const override;
|
|
|
|
void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const override;
|
|
|
|
};
|
|
|
|
|
2020-10-20 23:03:49 +08:00
|
|
|
class MarkerTypeDelegate : public QStyledItemDelegate
|
|
|
|
{
|
|
|
|
Q_OBJECT;
|
2020-11-03 07:37:06 +08:00
|
|
|
QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const override;
|
2020-10-20 23:03:49 +08:00
|
|
|
QWidget *createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
|
|
|
|
void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const override;
|
|
|
|
};
|
|
|
|
|
2020-10-21 01:15:06 +08:00
|
|
|
class MarkerSettingsDelegate : public QStyledItemDelegate
|
2020-09-21 20:06:20 +08:00
|
|
|
{
|
|
|
|
Q_OBJECT;
|
2020-11-03 07:37:06 +08:00
|
|
|
QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const override;
|
2020-09-21 20:06:20 +08:00
|
|
|
QWidget *createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
|
|
|
|
void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const override;
|
|
|
|
};
|
|
|
|
|
2020-11-03 07:37:06 +08:00
|
|
|
class TraceMarkerModel : public QAbstractItemModel
|
2020-08-31 04:03:41 +08:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
TraceMarkerModel(TraceModel &model, QObject *parent = 0);
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ColIndexNumber = 0,
|
|
|
|
ColIndexTrace = 1,
|
2020-10-20 23:03:49 +08:00
|
|
|
ColIndexType = 2,
|
2020-10-21 01:15:06 +08:00
|
|
|
ColIndexSettings = 3,
|
2020-10-20 23:03:49 +08:00
|
|
|
ColIndexData = 4,
|
|
|
|
ColIndexLast,
|
2020-08-31 04:03:41 +08:00
|
|
|
};
|
|
|
|
|
2020-11-03 07:37:06 +08:00
|
|
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
QModelIndex parent(const QModelIndex &index) const override;
|
2020-08-31 04:03:41 +08:00
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
|
|
|
|
|
|
|
TraceMarker* createDefaultMarker();
|
|
|
|
TraceMarker *marker(int index);
|
2020-10-20 23:03:49 +08:00
|
|
|
std::vector<TraceMarker*> getMarkers();
|
|
|
|
std::vector<TraceMarker*> getMarkers(Trace *t);
|
2020-08-31 04:03:41 +08:00
|
|
|
TraceModel& getModel();
|
2020-10-20 23:03:49 +08:00
|
|
|
void updateMarkers();
|
2020-11-03 07:37:06 +08:00
|
|
|
TraceMarker *markerFromIndex(const QModelIndex &index) const;
|
2020-08-31 04:03:41 +08:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void addMarker(TraceMarker *t);
|
2020-11-03 07:37:06 +08:00
|
|
|
void removeMarker(unsigned int index);
|
2020-08-31 04:03:41 +08:00
|
|
|
void removeMarker(TraceMarker *m);
|
|
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void markerAdded(TraceMarker *t);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void markerDataChanged(TraceMarker *m);
|
|
|
|
private:
|
|
|
|
std::vector<TraceMarker*> markers;
|
|
|
|
TraceModel &model;
|
2020-11-03 07:37:06 +08:00
|
|
|
TraceMarker *root;
|
2020-08-31 04:03:41 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TRACEMARKERMODEL_H
|