summaryrefslogtreecommitdiffstats
path: root/pokemodr/models/BaseModel.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-24 18:46:14 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-24 18:46:14 +0000
commitd7b6b0627a7d5e0875a263bf9501506a3d8da450 (patch)
tree4347a259fa97a8e34b6dbc57cd658bb70c55f2dd /pokemodr/models/BaseModel.cpp
parent8178711f67288bf43eeb80dce15eaa65a1d840f7 (diff)
downloadsigen-d7b6b0627a7d5e0875a263bf9501506a3d8da450.tar.gz
sigen-d7b6b0627a7d5e0875a263bf9501506a3d8da450.tar.xz
sigen-d7b6b0627a7d5e0875a263bf9501506a3d8da450.zip
[ADD] New classes for the models
[FIX] Stuff cleaned up for better profiling (no inlining until profiler says so) git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@105 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/models/BaseModel.cpp')
-rw-r--r--pokemodr/models/BaseModel.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/pokemodr/models/BaseModel.cpp b/pokemodr/models/BaseModel.cpp
new file mode 100644
index 00000000..bb0392ff
--- /dev/null
+++ b/pokemodr/models/BaseModel.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2008 Ben Boeckel <MathStuf@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// Header include
+#include "BaseModel.h"
+
+BaseModel::BaseModel(BaseModel* parent, Object* object, const QString& name) :
+ m_object(object),
+ m_name(name),
+ m_parent(parent)
+{
+}
+
+BaseModel* BaseModel::parent()
+{
+ return m_parent;
+}
+
+// Qt::DropActions BaseModel::supportedDragActions()
+// {
+// return Qt::CopyAction | Qt::MoveAction;
+// }
+//
+// Qt::DropActions BaseModel::supportedDropActions()
+// {
+// return Qt::CopyAction | Qt::MoveAction;
+// }
+
+ObjectModel::ObjectModel(BaseModel* parent, Object* object) :
+ BaseModel(parent, object, "")
+{
+}
+
+Qt::ItemFlags ObjectModel::flags() const
+{
+ return Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled;
+}
+
+GroupModel::GroupModel(BaseModel* parent, Object* object, const QString& name) :
+ BaseModel(parent, object, name)
+{
+}
+
+GroupModel::~GroupModel()
+{
+ foreach (ObjectModel* model, m_objects)
+ delete model;
+}
+
+QVariant GroupModel::data(int role) const
+{
+ if (role == Qt::DisplayRole)
+ return m_name;
+ return QVariant();
+}
+
+Qt::ItemFlags GroupModel::flags() const
+{
+ return Qt::ItemIsDropEnabled | Qt::ItemIsEnabled;
+}
+
+bool GroupModel::setData(const QVariant& /*value*/, int /*role = Qt::EditRole*/)
+{
+ return false;
+}
+
+bool GroupModel::canInsertRows() const
+{
+ return true;
+}
+
+bool GroupModel::canRemoveRows() const
+{
+ return true;
+}