All Classes Namespaces Functions Variables Enumerations Properties Pages
predefinedsetmodel.h
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2020 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 */
17 #ifndef PREDEFINEDSETMODEL_H
18 #define PREDEFINEDSETMODEL_H
19 
20 // predefinedsetmodel.h
21 #include <QAbstractTableModel>
22 
24 {
25  int size() const { return mKeyframeIndexes.size(); }
26  void insert(const int& keyFrameIndex, const QString& filePath)
27  {
28  mKeyframeIndexes.append(keyFrameIndex);
29  mFilePaths.append(filePath);
30  }
31 
32  int keyFrameIndexAt(const int& index) const
33  {
34  return mKeyframeIndexes.at(index);
35  }
36 
37  QString filePathAt(const int& index) const
38  {
39  return mFilePaths.at(index);
40  }
41 
42  bool contains(const QString& path) const {
43  return mFilePaths.contains(path);
44  }
45 
46  bool isEmpty() const {
47  return mFilePaths.isEmpty();
48  }
49 
50  enum ColumnType {
51  FILES,
52  KEYFRAMEPOS
53  };
54 
55  const QString layerName() { return mLayerName; }
56  void setLayerName(const QString& layerName) { mLayerName = layerName; }
57 
58  QString type(const int& index) const {
59  switch(index)
60  {
61  case 0:
62  return QObject::tr("Files");
63  case 1:
64  return QObject::tr("KeyFrame Pos");
65  default:
66  return "";
67  }
68  }
69 
70 private:
71  QList<QString> mFilePaths;
72  QList<int> mKeyframeIndexes;
73  QString mLayerName;
74 
75 };
76 
78 {
79  Q_OBJECT
80 public:
81  PredefinedSetModel(QObject *parent, const PredefinedKeySet& keyFrameSet);
82  int rowCount(const QModelIndex &parent = QModelIndex()) const ;
83  int columnCount(const QModelIndex &parent = QModelIndex()) const;
84  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
85  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
86 
87 private:
88  const PredefinedKeySet mKeySet;
89 };
90 
91 #endif // PREDEFINEDSETMODEL_H
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
const T & at(int i) const const
QString tr(const char *sourceText, const char *disambiguation, int n)
int size() const const
void append(const T &value)
Q_OBJECTQ_OBJECT
bool isEmpty() const const
DisplayRole
bool contains(const T &value) const const
Orientation
QObject * parent() const const