annotate data/model/ModelDataTableModel.h @ 1777:d484490cdf69

Split EditableDenseThreeDimensionalModel into explicitly compressed and uncompressed variants. Simplifies the uncompressed version, and we may want to consider whether we need the compressed one at all.
author Chris Cannam
date Tue, 10 Sep 2019 16:34:47 +0100
parents dffc70996f54
children
rev   line source
Chris@413 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@413 2
Chris@413 3 /*
Chris@413 4 Sonic Visualiser
Chris@413 5 An audio file viewer and annotation editor.
Chris@413 6 Centre for Digital Music, Queen Mary, University of London.
Chris@413 7 This file copyright 2008 QMUL.
Chris@413 8
Chris@413 9 This program is free software; you can redistribute it and/or
Chris@413 10 modify it under the terms of the GNU General Public License as
Chris@413 11 published by the Free Software Foundation; either version 2 of the
Chris@413 12 License, or (at your option) any later version. See the file
Chris@413 13 COPYING included with this distribution for more information.
Chris@413 14 */
Chris@413 15
Chris@1455 16 #ifndef SV_MODEL_DATA_TABLE_MODEL_H
Chris@1455 17 #define SV_MODEL_DATA_TABLE_MODEL_H
Chris@413 18
Chris@413 19 #include <QAbstractItemModel>
Chris@413 20
Chris@420 21 #include <vector>
Chris@413 22
Chris@1038 23 #include "base/BaseTypes.h"
Chris@1038 24
Chris@1748 25 #include "TabularModel.h"
Chris@1748 26 #include "Model.h"
Chris@1748 27
Chris@420 28 class TabularModel;
Chris@416 29 class Command;
Chris@416 30
Chris@413 31 class ModelDataTableModel : public QAbstractItemModel
Chris@413 32 {
Chris@413 33 Q_OBJECT
Chris@413 34
Chris@413 35 public:
Chris@1748 36 ModelDataTableModel(ModelId modelId); // a TabularModel
Chris@413 37 virtual ~ModelDataTableModel();
Chris@413 38
Chris@1580 39 QVariant data(const QModelIndex &index, int role) const override;
Chris@413 40
Chris@1580 41 bool setData(const QModelIndex &index, const QVariant &value, int role) override;
Chris@413 42
Chris@427 43 bool insertRow(int row, const QModelIndex &parent = QModelIndex());
Chris@427 44 bool removeRow(int row, const QModelIndex &parent = QModelIndex());
Chris@427 45
Chris@1580 46 Qt::ItemFlags flags(const QModelIndex &index) const override;
Chris@413 47
Chris@413 48 QVariant headerData(int section, Qt::Orientation orientation,
Chris@1580 49 int role = Qt::DisplayRole) const override;
Chris@413 50
Chris@413 51 QModelIndex index(int row, int column,
Chris@1580 52 const QModelIndex &parent = QModelIndex()) const override;
Chris@413 53
Chris@1580 54 QModelIndex parent(const QModelIndex &index) const override;
Chris@413 55
Chris@1580 56 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
Chris@1580 57 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
Chris@413 58
Chris@1038 59 QModelIndex getModelIndexForFrame(sv_frame_t frame) const;
Chris@1038 60 sv_frame_t getFrameForModelIndex(const QModelIndex &) const;
Chris@416 61
Chris@1580 62 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
Chris@413 63
Chris@618 64 QModelIndex findText(QString text) const;
Chris@618 65
Chris@428 66 void setCurrentRow(int row);
Chris@618 67 int getCurrentRow() const;
Chris@428 68
Chris@416 69 signals:
Chris@929 70 void frameSelected(int);
Chris@427 71 void addCommand(Command *);
Chris@428 72 void currentChanged(const QModelIndex &);
Chris@454 73 void modelRemoved();
Chris@416 74
Chris@413 75 protected slots:
Chris@1770 76 void modelChanged(ModelId);
Chris@1770 77 void modelChangedWithin(ModelId, sv_frame_t, sv_frame_t);
Chris@413 78
Chris@413 79 protected:
Chris@1748 80 std::shared_ptr<TabularModel> getTabularModel() const {
Chris@1748 81 return ModelById::getAs<TabularModel>(m_model);
Chris@1748 82 }
Chris@1748 83
Chris@1748 84 ModelId m_model;
Chris@420 85 int m_sortColumn;
Chris@420 86 Qt::SortOrder m_sortOrdering;
Chris@428 87 int m_currentRow;
Chris@420 88 typedef std::vector<int> RowList;
Chris@426 89 mutable RowList m_sort;
Chris@426 90 mutable RowList m_rsort;
Chris@426 91 int getSorted(int row) const;
Chris@426 92 int getUnsorted(int row) const;
Chris@426 93 void resort() const;
Chris@426 94 void resortNumeric() const;
Chris@426 95 void resortAlphabetical() const;
Chris@428 96 void clearSort();
Chris@413 97 };
Chris@413 98
Chris@413 99 #endif