annotate data/model/ModelDataTableModel.h @ 1406:09751743647e

Untabify!
author Chris Cannam
date Tue, 07 Mar 2017 13:52:37 +0000
parents 2f49be7d4264
children ec9e65fcf749
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@1038 23 #include "base/BaseTypes.h"
Chris@1038 24
Chris@420 25 class TabularModel;
Chris@416 26 class Command;
Chris@416 27
Chris@413 28 class ModelDataTableModel : public QAbstractItemModel
Chris@413 29 {
Chris@413 30 Q_OBJECT
Chris@413 31
Chris@413 32 public:
Chris@420 33 ModelDataTableModel(TabularModel *m);
Chris@413 34 virtual ~ModelDataTableModel();
Chris@413 35
Chris@413 36 QVariant data(const QModelIndex &index, int role) const;
Chris@413 37
Chris@413 38 bool setData(const QModelIndex &index, const QVariant &value, int role);
Chris@413 39
Chris@427 40 bool insertRow(int row, const QModelIndex &parent = QModelIndex());
Chris@427 41 bool removeRow(int row, const QModelIndex &parent = QModelIndex());
Chris@427 42
Chris@413 43 Qt::ItemFlags flags(const QModelIndex &index) const;
Chris@413 44
Chris@413 45 QVariant headerData(int section, Qt::Orientation orientation,
Chris@413 46 int role = Qt::DisplayRole) const;
Chris@413 47
Chris@413 48 QModelIndex index(int row, int column,
Chris@413 49 const QModelIndex &parent = QModelIndex()) const;
Chris@413 50
Chris@413 51 QModelIndex parent(const QModelIndex &index) const;
Chris@413 52
Chris@413 53 int rowCount(const QModelIndex &parent = QModelIndex()) const;
Chris@413 54 int columnCount(const QModelIndex &parent = QModelIndex()) const;
Chris@413 55
Chris@1038 56 QModelIndex getModelIndexForFrame(sv_frame_t frame) const;
Chris@1038 57 sv_frame_t getFrameForModelIndex(const QModelIndex &) const;
Chris@416 58
Chris@420 59 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
Chris@413 60
Chris@618 61 QModelIndex findText(QString text) const;
Chris@618 62
Chris@428 63 void setCurrentRow(int row);
Chris@618 64 int getCurrentRow() const;
Chris@428 65
Chris@416 66 signals:
Chris@929 67 void frameSelected(int);
Chris@427 68 void addCommand(Command *);
Chris@428 69 void currentChanged(const QModelIndex &);
Chris@454 70 void modelRemoved();
Chris@416 71
Chris@413 72 protected slots:
Chris@413 73 void modelChanged();
Chris@1046 74 void modelChangedWithin(sv_frame_t, sv_frame_t);
Chris@454 75 void modelAboutToBeDeleted();
Chris@413 76
Chris@413 77 protected:
Chris@420 78 TabularModel *m_model;
Chris@420 79 int m_sortColumn;
Chris@420 80 Qt::SortOrder m_sortOrdering;
Chris@428 81 int m_currentRow;
Chris@420 82 typedef std::vector<int> RowList;
Chris@426 83 mutable RowList m_sort;
Chris@426 84 mutable RowList m_rsort;
Chris@426 85 int getSorted(int row) const;
Chris@426 86 int getUnsorted(int row) const;
Chris@426 87 void resort() const;
Chris@426 88 void resortNumeric() const;
Chris@426 89 void resortAlphabetical() const;
Chris@428 90 void clearSort();
Chris@413 91 };
Chris@413 92
Chris@413 93 #endif