Songbook-Client  0.7
This application is a manager of customguitar songbooks
 All Classes Files Functions Variables Enumerations Enumerator Pages
chord-table-model.hh
Go to the documentation of this file.
1 // Copyright (C) 2009-2012, Romain Goffe <romain.goffe@gmail.com>
2 // Copyright (C) 2009-2012, Alexandre Dupas <alexandre.dupas@gmail.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License as
6 // published by the Free Software Foundation; either version 2 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 // 02110-1301, USA.
18 //******************************************************************************
19 #ifndef __CHORD_TABLE_MODEL_HH__
20 #define __CHORD_TABLE_MODEL_HH__
21 
22 #include <QAbstractTableModel>
23 #include <QModelIndex>
24 #include <QString>
25 #include <QVector>
26 
27 class CChord;
28 
65 class CChordTableModel : public QAbstractTableModel
66 {
67  Q_OBJECT
68 
69  public:
75  enum ChordRoles {
76  NameRole = Qt::UserRole + 1,
77  StringsRole = Qt::UserRole + 2,
78  InstrumentRole = Qt::UserRole + 3,
79  ImportantRole = Qt::UserRole + 4,
80  MaxRole = ImportantRole
81  };
82 
84  CChordTableModel(QObject *parent=0);
85 
88 
93  virtual int columnCount(const QModelIndex & index = QModelIndex()) const;
94 
101  virtual void setColumnCount(int value);
102 
107  virtual int rowCount(const QModelIndex & index = QModelIndex()) const;
108 
115  virtual void setRowCount(int value);
116 
117  /* drag and drop */
118  Qt::DropActions supportedDropActions() const;
119  Qt::DropActions supportedDragActions() const;
120  Qt::ItemFlags flags(const QModelIndex &index) const;
121  QStringList mimeTypes() const;
122  QMimeData * mimeData(const QModelIndexList &indexes) const;
123  bool dropMimeData(const QMimeData *data, Qt::DropAction action,
124  int row, int column, const QModelIndex &parent);
125 
131  QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
132 
138  bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
139 
140 
145  CChord * getChord(const QModelIndex & index) const;
146 
147 public slots:
148  void insertItem(const QModelIndex & index, const QString & value);
149  void removeItem(const QModelIndex & index);
150  void addItem(const QString & value);
151 
152 private:
153  QModelIndex indexFromPosition(int position);
154  int positionFromIndex(const QModelIndex & index) const;
155 
156 private:
157  bool m_fixedColumnCount;
158  bool m_fixedRowCount;
159  int m_columnCount;
160  int m_rowCount;
161  QVector<CChord*> m_data;
162 };
163 
164 #endif //__CHORD_TABLE_MODEL_HH__