diff options
Diffstat (limited to 'pokemodr/models/RootModel.cpp')
| -rw-r--r-- | pokemodr/models/RootModel.cpp | 65 |
1 files changed, 7 insertions, 58 deletions
diff --git a/pokemodr/models/RootModel.cpp b/pokemodr/models/RootModel.cpp index 7413ece5..851286d1 100644 --- a/pokemodr/models/RootModel.cpp +++ b/pokemodr/models/RootModel.cpp @@ -28,67 +28,31 @@ #include <QFile> RootModel::RootModel(const QList<QVariant>& pokemods) : - BaseModel(NULL, NULL, "") + GroupModel(NULL, NULL) { QFile fin("full.pmod"); fin.open(QIODevice::ReadOnly); QDomDocument xml; xml.setContent(&fin); fin.close(); - m_pokemods.append(new PokemodModel(this, new Pokemod(xml.documentElement()))); + m_objects.append(new PokemodModel(this, new Pokemod(xml.documentElement()))); + m_objects.append(new PokemodModel(this, new Pokemod(xml.documentElement()))); // TODO: make sub models from data } RootModel::~RootModel() { - foreach (PokemodModel* model, m_pokemods) - delete model; -} - -QVariant RootModel::data(const int /*role = Qt::DisplayRole*/) const -{ - return QVariant(); -} - -int RootModel::rowCount() const -{ - return m_pokemods.size(); -} - -Qt::ItemFlags RootModel::flags() const -{ - return Qt::ItemIsDropEnabled | Qt::ItemIsEnabled; -} - -bool RootModel::setData(const QVariant& /*value*/, const int /*role*/) -{ - return false; -} - -BaseModel* RootModel::childItem(const int row) -{ - return m_pokemods[row]; } int RootModel::indexNumber() const { - return 0; -} - -bool RootModel::canInsertRows() const -{ - return true; + return -1; } bool RootModel::insertRows(const int rows) { for (int i = 0; i < rows; ++i) - m_pokemods.append(new PokemodModel(this, new Pokemod())); - return true; -} - -bool RootModel::canRemoveRows() const -{ + m_objects.append(new PokemodModel(this, new Pokemod())); return true; } @@ -96,23 +60,8 @@ bool RootModel::removeRows(const int position, const int rows) { for (int i = 0; i < rows; ++i) { - delete m_pokemods[position]; - m_pokemods.removeAt(position); + delete m_objects[position]; + m_objects.removeAt(position); } return true; } - -Qt::DropActions RootModel::supportedDragActions() -{ - return 0; -} - -Qt::DropActions RootModel::supportedDropActions() -{ - return Qt::CopyAction | Qt::MoveAction; -} - -QString RootModel::type() const -{ - return ""; -} |
