From 807d2b93bf41682ec1093598f30abe74866e5994 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 28 Apr 2008 14:22:19 +0000 Subject: [FIX] De-inlined some methods [FIX] More mounds checking [FIX] RootModel inherits GroupModel [FIX] Tree displays correctly (though segfaults on some expansion) [FIX] Some more header cleanup git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@113 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemodr/models/RootModel.cpp | 65 +++++-------------------------------------- 1 file changed, 7 insertions(+), 58 deletions(-) (limited to 'pokemodr/models/RootModel.cpp') 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 RootModel::RootModel(const QList& 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 ""; -} -- cgit