Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • app
  • src
predefinedsetmodel.h
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU 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
24struct PredefinedKeySet
25{
26 Q_DECLARE_TR_FUNCTIONS(PredefinedKeySet)
27public:
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
73private:
74 QList<QString> mFilePaths;
75 QList<int> mKeyframeIndexes;
76 QString mLayerName;
77
78};
79
80class PredefinedSetModel : public QAbstractTableModel
81{
82 Q_OBJECT
83public:
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
90private:
91 const PredefinedKeySet mKeySet;
92};
93
94#endif // PREDEFINEDSETMODEL_H
PredefinedSetModel
Definition: predefinedsetmodel.h:81
QAbstractTableModel
QAbstractTableModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
QList
QList::append
void append(const T &value)
QList::at
const T & at(int i) const const
QList::contains
bool contains(const T &value) const const
QList::isEmpty
bool isEmpty() const const
QList::size
int size() const const
QModelIndex
QObject
QObject::Q_OBJECT
Q_OBJECTQ_OBJECT
QObject::parent
QObject * parent() const const
QString
Qt::DisplayRole
DisplayRole
Qt::Orientation
Orientation
QVariant
PredefinedKeySet
Definition: predefinedsetmodel.h:25
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39