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 #include <QCoreApplication>
23 
25 {
26  Q_DECLARE_TR_FUNCTIONS(PredefinedKeySet)
27 public:
28  int size() const { return mKeyframeIndexes.size(); }
29  void insert(const int& keyFrameIndex, const QString& filePath)
30  {
31  mKeyframeIndexes.append(keyFrameIndex);
32  mFilePaths.append(filePath);
33  }
34 
35  int keyFrameIndexAt(const int& index) const
36  {
37  return mKeyframeIndexes.at(index);
38  }
39 
40  QString filePathAt(const int& index) const
41  {
42  return mFilePaths.at(index);
43  }
44 
45  bool contains(const QString& path) const {
46  return mFilePaths.contains(path);
47  }
48 
49  bool isEmpty() const {
50  return mFilePaths.isEmpty();
51  }
52 
53  enum ColumnType {
54  FILES,
55  KEYFRAMEPOS
56  };
57 
58  const QString layerName() { return mLayerName; }
59  void setLayerName(const QString& layerName) { mLayerName = layerName; }
60 
61  QString type(const int& index) const {
62  switch(index)
63  {
64  case 0:
65  return tr("Files");
66  case 1:
67  return tr("KeyFrame Pos");
68  default:
69  return "";
70  }
71  }
72 
73 private:
74  QList<QString> mFilePaths;
75  QList<int> mKeyframeIndexes;
76  QString mLayerName;
77 
78 };
79 
81 {
82  Q_OBJECT
83 public:
84  PredefinedSetModel(QObject *parent, const PredefinedKeySet& keyFrameSet);
85  int rowCount(const QModelIndex &parent = QModelIndex()) const ;
86  int columnCount(const QModelIndex &parent = QModelIndex()) const;
87  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
88  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
89 
90 private:
91  const PredefinedKeySet mKeySet;
92 };
93 
94 #endif // PREDEFINEDSETMODEL_H
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
const T & at(int i) const const
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