Chris@413: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@413: Chris@413: /* Chris@413: Sonic Visualiser Chris@413: An audio file viewer and annotation editor. Chris@413: Centre for Digital Music, Queen Mary, University of London. Chris@413: This file copyright 2008 QMUL. Chris@413: Chris@413: This program is free software; you can redistribute it and/or Chris@413: modify it under the terms of the GNU General Public License as Chris@413: published by the Free Software Foundation; either version 2 of the Chris@413: License, or (at your option) any later version. See the file Chris@413: COPYING included with this distribution for more information. Chris@413: */ Chris@413: Chris@413: #ifndef _MODEL_DATA_TABLE_MODEL_H_ Chris@413: #define _MODEL_DATA_TABLE_MODEL_H_ Chris@413: Chris@413: #include Chris@413: Chris@420: #include Chris@413: Chris@420: class TabularModel; Chris@416: class Command; Chris@416: Chris@413: class ModelDataTableModel : public QAbstractItemModel Chris@413: { Chris@413: Q_OBJECT Chris@413: Chris@413: public: Chris@420: ModelDataTableModel(TabularModel *m); Chris@413: virtual ~ModelDataTableModel(); Chris@413: Chris@413: QVariant data(const QModelIndex &index, int role) const; Chris@413: Chris@413: bool setData(const QModelIndex &index, const QVariant &value, int role); Chris@413: Chris@427: bool insertRow(int row, const QModelIndex &parent = QModelIndex()); Chris@427: bool removeRow(int row, const QModelIndex &parent = QModelIndex()); Chris@427: Chris@413: Qt::ItemFlags flags(const QModelIndex &index) const; Chris@413: Chris@413: QVariant headerData(int section, Qt::Orientation orientation, Chris@413: int role = Qt::DisplayRole) const; Chris@413: Chris@413: QModelIndex index(int row, int column, Chris@413: const QModelIndex &parent = QModelIndex()) const; Chris@413: Chris@413: QModelIndex parent(const QModelIndex &index) const; Chris@413: Chris@413: int rowCount(const QModelIndex &parent = QModelIndex()) const; Chris@413: int columnCount(const QModelIndex &parent = QModelIndex()) const; Chris@413: Chris@929: QModelIndex getModelIndexForFrame(int frame) const; Chris@929: int getFrameForModelIndex(const QModelIndex &) const; Chris@416: Chris@420: void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); Chris@413: Chris@618: QModelIndex findText(QString text) const; Chris@618: Chris@428: void setCurrentRow(int row); Chris@618: int getCurrentRow() const; Chris@428: Chris@416: signals: Chris@929: void frameSelected(int); Chris@427: void addCommand(Command *); Chris@428: void currentChanged(const QModelIndex &); Chris@454: void modelRemoved(); Chris@416: Chris@413: protected slots: Chris@413: void modelChanged(); Chris@947: void modelChangedWithin(int, int); Chris@454: void modelAboutToBeDeleted(); Chris@413: Chris@413: protected: Chris@420: TabularModel *m_model; Chris@420: int m_sortColumn; Chris@420: Qt::SortOrder m_sortOrdering; Chris@428: int m_currentRow; Chris@420: typedef std::vector RowList; Chris@426: mutable RowList m_sort; Chris@426: mutable RowList m_rsort; Chris@426: int getSorted(int row) const; Chris@426: int getUnsorted(int row) const; Chris@426: void resort() const; Chris@426: void resortNumeric() const; Chris@426: void resortAlphabetical() const; Chris@428: void clearSort(); Chris@413: }; Chris@413: Chris@413: #endif