annotate data/model/ModelDataTableModel.h @ 427:72ec275e458b

* Basic implementation of add and remove point in data editor * Improve resilience of frame - real-time - frame round-trip conversions
author Chris Cannam
date Mon, 16 Jun 2008 14:48:42 +0000
parents 2386582f67cd
children 3e1d190048f4
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@413 16 #ifndef _MODEL_DATA_TABLE_MODEL_H_
Chris@413 17 #define _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@420 23 class TabularModel;
Chris@416 24 class Command;
Chris@416 25
Chris@413 26 class ModelDataTableModel : public QAbstractItemModel
Chris@413 27 {
Chris@413 28 Q_OBJECT
Chris@413 29
Chris@413 30 public:
Chris@420 31 ModelDataTableModel(TabularModel *m);
Chris@413 32 virtual ~ModelDataTableModel();
Chris@413 33
Chris@413 34 QVariant data(const QModelIndex &index, int role) const;
Chris@413 35
Chris@413 36 bool setData(const QModelIndex &index, const QVariant &value, int role);
Chris@413 37
Chris@427 38 bool insertRow(int row, const QModelIndex &parent = QModelIndex());
Chris@427 39 bool removeRow(int row, const QModelIndex &parent = QModelIndex());
Chris@427 40
Chris@413 41 Qt::ItemFlags flags(const QModelIndex &index) const;
Chris@413 42
Chris@413 43 QVariant headerData(int section, Qt::Orientation orientation,
Chris@413 44 int role = Qt::DisplayRole) const;
Chris@413 45
Chris@413 46 QModelIndex index(int row, int column,
Chris@413 47 const QModelIndex &parent = QModelIndex()) const;
Chris@413 48
Chris@413 49 QModelIndex parent(const QModelIndex &index) const;
Chris@413 50
Chris@413 51 int rowCount(const QModelIndex &parent = QModelIndex()) const;
Chris@413 52 int columnCount(const QModelIndex &parent = QModelIndex()) const;
Chris@413 53
Chris@416 54 QModelIndex getModelIndexForFrame(size_t frame) const;
Chris@419 55 size_t getFrameForModelIndex(const QModelIndex &) const;
Chris@416 56
Chris@420 57 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
Chris@413 58
Chris@416 59 signals:
Chris@416 60 void frameSelected(size_t);
Chris@427 61 void addCommand(Command *);
Chris@416 62
Chris@413 63 protected slots:
Chris@413 64 void modelChanged();
Chris@413 65 void modelChanged(size_t, size_t);
Chris@413 66
Chris@413 67 protected:
Chris@420 68 TabularModel *m_model;
Chris@420 69 int m_sortColumn;
Chris@420 70 Qt::SortOrder m_sortOrdering;
Chris@420 71 typedef std::vector<int> RowList;
Chris@426 72 mutable RowList m_sort;
Chris@426 73 mutable RowList m_rsort;
Chris@426 74 int getSorted(int row) const;
Chris@426 75 int getUnsorted(int row) const;
Chris@426 76 void resort() const;
Chris@426 77 void resortNumeric() const;
Chris@426 78 void resortAlphabetical() const;
Chris@413 79 };
Chris@413 80
Chris@413 81 #endif