[Tux4kids-commits] r1282 - tux4kids-admin/trunk/tux4kids-admin/src

Michał Świtakowski swistakers-guest at alioth.debian.org
Mon Jul 27 15:43:52 UTC 2009


Author: swistakers-guest
Date: 2009-07-27 15:43:50 +0000 (Mon, 27 Jul 2009)
New Revision: 1282

Added:
   tux4kids-admin/trunk/tux4kids-admin/src/class.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/class.h
Modified:
   tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h
   tux4kids-admin/trunk/tux4kids-admin/src/mainController.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/mainController.h
   tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/src.pro
Log:
work on gui for teachers and classes

Added: tux4kids-admin/trunk/tux4kids-admin/src/class.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/class.cpp	                        (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/class.cpp	2009-07-27 15:43:50 UTC (rev 1282)
@@ -0,0 +1,16 @@
+#include "class.h"
+
+Class::Class(QString name)
+		: m_name(name)
+{
+}
+
+QString Class::name() const
+{
+	return m_name;
+}
+
+void Class::setName(QString name)
+{
+	m_name = name;
+}

Added: tux4kids-admin/trunk/tux4kids-admin/src/class.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/class.h	                        (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/class.h	2009-07-27 15:43:50 UTC (rev 1282)
@@ -0,0 +1,24 @@
+#ifndef CLASS_H
+#define CLASS_H
+
+#include <QList>
+#include <QPointer>
+#include <QString>
+
+class StudentDir;
+
+class Class
+{
+public:
+	Class(QString name = QString());
+
+	QString name() const;
+	void setName(QString name);
+
+protected:
+
+	QString m_name;
+	QList< QPointer<StudentDir> > m_students;
+};
+
+#endif // CLASS_H

Modified: tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp	2009-07-27 14:51:04 UTC (rev 1281)
+++ tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp	2009-07-27 15:43:50 UTC (rev 1282)
@@ -1,6 +1,44 @@
 #include "classTableModel.h"
+#include "schoolDatabase.h"
 
 ClassTableModel::ClassTableModel(QObject *parent)
 		: QAbstractTableModel(parent)
 {
 }
+
+QVariant ClassTableModel::data(const QModelIndex &index, int role) const
+{
+	if (!index.isValid())
+		return QVariant();
+
+	if (index.row() >= rowCount())
+		return QVariant();
+
+	if (index.column() >= columnCount())
+		return QVariant();
+
+	if (role == Qt::DisplayRole) {
+		switch (index.column()) {
+		case ClassName:
+			return m_classes.at(index.row()).name();
+		}
+	}
+
+	return QVariant();
+}
+
+int ClassTableModel::columnCount(const QModelIndex &parent) const
+{
+	return 2;
+}
+
+int ClassTableModel::rowCount(const QModelIndex &parent) const
+{
+	return m_classes.size();
+}
+
+void ClassTableModel::setSchoolDatabase(SchoolDatabase *schoolDatabase)
+{
+	m_schoolDatabase = schoolDatabase;
+}
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h	2009-07-27 14:51:04 UTC (rev 1281)
+++ tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h	2009-07-27 15:43:50 UTC (rev 1282)
@@ -2,12 +2,30 @@
 #define CLASSTABLEMODEL_H
 
 #include <QAbstractTableModel>
+#include <QPointer>
 
+#include "class.h"
+
+class SchoolDatabase;
+
 class ClassTableModel : public QAbstractTableModel
 {
 	Q_OBJECT
 public:
 	ClassTableModel(QObject *parent = 0);
+	QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+	int columnCount(const QModelIndex &parent = QModelIndex()) const;
+	int rowCount(const QModelIndex &parent = QModelIndex()) const;
+
+	void setSchoolDatabase(SchoolDatabase *schoolDatabase);
+private:
+
+	enum ClassField {
+		ClassSelected = 0,
+		ClassName = 1,
+	};
+	QPointer<SchoolDatabase> m_schoolDatabase;
+	QList<Class> m_classes;
 };
 
 #endif // CLASSTABLEMODEL_H

Modified: tux4kids-admin/trunk/tux4kids-admin/src/mainController.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/mainController.cpp	2009-07-27 14:51:04 UTC (rev 1281)
+++ tux4kids-admin/trunk/tux4kids-admin/src/mainController.cpp	2009-07-27 15:43:50 UTC (rev 1282)
@@ -40,4 +40,8 @@
 	return &m_studentTableModel;
 }
 
+ClassTableModel *MainController::classTableModel()
+{
+	return &m_classTableModel;
+}
 

Modified: tux4kids-admin/trunk/tux4kids-admin/src/mainController.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/mainController.h	2009-07-27 14:51:04 UTC (rev 1281)
+++ tux4kids-admin/trunk/tux4kids-admin/src/mainController.h	2009-07-27 15:43:50 UTC (rev 1282)
@@ -6,6 +6,7 @@
 
 #include "pluginManager.h"
 #include "studentTableModel.h"
+#include "classTableModel.h"
 
 class SchoolData;
 
@@ -20,11 +21,13 @@
 	PluginManager *pluginManager();
 	SchoolData *schoolData();
 	StudentTableModel *studentTableModel();
+	ClassTableModel *classTableModel();
 
 private:
 
 	PluginManager m_pluginManager;
 	StudentTableModel m_studentTableModel;
+	ClassTableModel m_classTableModel;
 	QPointer<SchoolData> m_schoolData;
 
 };

Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp	2009-07-27 14:51:04 UTC (rev 1281)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp	2009-07-27 15:43:50 UTC (rev 1282)
@@ -10,6 +10,8 @@
 {
 	m_ui->setupUi(this);
 
+	m_ui->classesTable->setModel(m_mainController->classTableModel());
+
 	connect(m_ui->addClassButton, SIGNAL(clicked()), this, SLOT(addClicked()));
 }
 

Modified: tux4kids-admin/trunk/tux4kids-admin/src/src.pro
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/src.pro	2009-07-27 14:51:04 UTC (rev 1281)
+++ tux4kids-admin/trunk/tux4kids-admin/src/src.pro	2009-07-27 15:43:50 UTC (rev 1282)
@@ -1,5 +1,6 @@
 TARGET = ../tux4kids-admin
 TEMPLATE = app
+QT += sql
 INCLUDEPATH += ../plugins/ \
     ../../libtux4kidsadmin/
 SOURCES += main.cpp \
@@ -15,7 +16,8 @@
     studentTableProxyModel.cpp \
     manageClassesWidget.cpp \
     classTableModel.cpp \
-    manageClassDialog.cpp
+    manageClassDialog.cpp \
+    class.cpp
 HEADERS += mainWindow.h \
     mainController.h \
     pluginManager.h \
@@ -28,7 +30,8 @@
     studentTableProxyModel.h \
     manageClassesWidget.h \
     classTableModel.h \
-    manageClassDialog.h
+    manageClassDialog.h \
+    class.h
 FORMS += mainWindow.ui \
     pluginManagerDialog.ui \
     manageStudentsWidget.ui \




More information about the Tux4kids-commits mailing list