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.cpp
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// PredefinedSetModel.cpp
18#include "predefinedsetmodel.h"
19
20PredefinedSetModel::PredefinedSetModel(QObject *parent, const PredefinedKeySet& mKeySet)
21 :QAbstractTableModel(parent), mKeySet(mKeySet)
22{
23}
24
25int PredefinedSetModel::rowCount(const QModelIndex & /*parent*/) const
26{
27 return mKeySet.size();
28}
29
30int PredefinedSetModel::columnCount(const QModelIndex & /*parent*/) const
31{
32 return 2;
33}
34
35QVariant PredefinedSetModel::headerData(int section, Qt::Orientation orientation, int role) const
36{
37 if (role == Qt::DisplayRole)
38 {
39 if (orientation == Qt::Horizontal) {
40 return mKeySet.type(section);
41 }
42 }
43 return QVariant();
44}
45
46QVariant PredefinedSetModel::data(const QModelIndex &index, int role) const
47{
48 if (role == Qt::DisplayRole)
49 {
50 const int row = index.row();
51 const int column = index.column();
52
53 if (column == PredefinedKeySet::ColumnType::FILES)
54 {
55 return mKeySet.filePathAt(row);
56 }
57 else if (column == PredefinedKeySet::ColumnType::KEYFRAMEPOS)
58 {
59 return QString::number(mKeySet.keyFrameIndexAt(row));
60 }
61 }
62 return QVariant();
63}
QAbstractTableModel
QAbstractTableModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
QModelIndex
QModelIndex::column
int column() const const
QModelIndex::row
int row() const const
QObject
QString::number
QString number(int n, int base)
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