[Tux4kids-commits] r1298 - in tux4kids-admin/trunk/tux4kids-admin: . src
Michał Świtakowski
swistakers-guest at alioth.debian.org
Fri Jul 31 01:16:16 UTC 2009
Author: swistakers-guest
Date: 2009-07-31 01:16:16 +0000 (Fri, 31 Jul 2009)
New Revision: 1298
Added:
tux4kids-admin/trunk/tux4kids-admin/manageTeachersWidget.cpp
tux4kids-admin/trunk/tux4kids-admin/manageTeachersWidget.h
tux4kids-admin/trunk/tux4kids-admin/manageTeachersWidget.ui
tux4kids-admin/trunk/tux4kids-admin/teacherTableModel.cpp
tux4kids-admin/trunk/tux4kids-admin/teacherTableModel.h
Modified:
tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt
tux4kids-admin/trunk/tux4kids-admin/src/src.pro
Log:
some teacher-management code
Added: tux4kids-admin/trunk/tux4kids-admin/manageTeachersWidget.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/manageTeachersWidget.cpp (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/manageTeachersWidget.cpp 2009-07-31 01:16:16 UTC (rev 1298)
@@ -0,0 +1,14 @@
+#include "manageTeachersWidget.h"
+#include "ui_manageTeachersWidget.h"
+
+ManageTeachersWidget::ManageTeachersWidget(QWidget *parent) :
+ QWidget(parent),
+ m_ui(new Ui::ManageTeachersWidget)
+{
+ m_ui->setupUi(this);
+}
+
+ManageTeachersWidget::~ManageTeachersWidget()
+{
+ delete m_ui;
+}
Added: tux4kids-admin/trunk/tux4kids-admin/manageTeachersWidget.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/manageTeachersWidget.h (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/manageTeachersWidget.h 2009-07-31 01:16:16 UTC (rev 1298)
@@ -0,0 +1,21 @@
+#ifndef MANAGETEACHERSWIDGET_H
+#define MANAGETEACHERSWIDGET_H
+
+#include <QtGui/QWidget>
+
+namespace Ui {
+ class ManageTeachersWidget;
+}
+
+class ManageTeachersWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ ManageTeachersWidget(QWidget *parent = 0);
+ ~ManageTeachersWidget();
+
+private:
+ Ui::ManageTeachersWidget *m_ui;
+};
+
+#endif // MANAGETEACHERSWIDGET_H
Added: tux4kids-admin/trunk/tux4kids-admin/manageTeachersWidget.ui
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/manageTeachersWidget.ui (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/manageTeachersWidget.ui 2009-07-31 01:16:16 UTC (rev 1298)
@@ -0,0 +1,21 @@
+<ui version="4.0" >
+ <author/>
+ <comment/>
+ <exportmacro/>
+ <class>ManageTeachersWidget</class>
+ <widget class="QWidget" name="ManageTeachersWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ </widget>
+ <pixmapfunction/>
+ <connections/>
+</ui>
Modified: tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt 2009-07-31 00:18:52 UTC (rev 1297)
+++ tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt 2009-07-31 01:16:16 UTC (rev 1298)
@@ -15,7 +15,9 @@
studentTableProxyModel.cpp
manageClassesWidget.cpp
classTableModel.cpp
- manageClassDialog.cpp )
+ manageClassDialog.cpp
+ manageTeachersWidget.cpp
+ teacherTableModel.cpp )
SET(TUX4KIDS-ADMIN_MOC_HEADERS
mainWindow.h
@@ -28,7 +30,9 @@
studentTableProxyModel.h
manageClassesWidget.h
classTableModel.h
- manageClassDialog.h )
+ manageClassDialog.h
+ manageTeachersWidget.h
+ teacherTableModel.h )
SET(TUX4KIDS-ADMIN_UIS
mainWindow.ui
@@ -36,7 +40,8 @@
manageStudentsWidget.ui
addStudentDialog.ui
manageClassesWidget.ui
- manageClassDialog.ui )
+ manageClassDialog.ui
+ manageTeachersWidget.ui )
# enable warnings
ADD_DEFINITIONS( -Wall )
Modified: tux4kids-admin/trunk/tux4kids-admin/src/src.pro
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/src.pro 2009-07-31 00:18:52 UTC (rev 1297)
+++ tux4kids-admin/trunk/tux4kids-admin/src/src.pro 2009-07-31 01:16:16 UTC (rev 1298)
@@ -16,7 +16,9 @@
studentTableProxyModel.cpp \
manageClassesWidget.cpp \
classTableModel.cpp \
- manageClassDialog.cpp
+ manageClassDialog.cpp \
+ ../manageTeachersWidget.cpp \
+ ../teacherTableModel.cpp
HEADERS += mainWindow.h \
mainController.h \
pluginManager.h \
@@ -29,12 +31,15 @@
studentTableProxyModel.h \
manageClassesWidget.h \
classTableModel.h \
- manageClassDialog.h
+ manageClassDialog.h \
+ ../manageTeachersWidget.h \
+ ../teacherTableModel.h
FORMS += mainWindow.ui \
pluginManagerDialog.ui \
manageStudentsWidget.ui \
addStudentDialog.ui \
manageClassesWidget.ui \
- manageClassDialog.ui
+ manageClassDialog.ui \
+ ../manageTeachersWidget.ui
LIBS += -ltux4kidsadmin \
-L../../libtux4kidsadmin
Added: tux4kids-admin/trunk/tux4kids-admin/teacherTableModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/teacherTableModel.cpp (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/teacherTableModel.cpp 2009-07-31 01:16:16 UTC (rev 1298)
@@ -0,0 +1,52 @@
+#include "teacherTableModel.h"
+#include "schoolDatabase.h"
+
+TeacherTableModel::TeacherTableModel(QObject *parent)
+ : QAbstractTableModel(parent)
+{
+}
+
+int TeacherTableModel::columnCount(const QModelIndex &parent) const
+{
+ return m_teachers.size();
+}
+
+int TeacherTableModel::rowCount(const QModelIndex &parent) const
+{
+ return 3;
+}
+
+void TeacherTableModel::setSchoolDatabase(SchoolDatabase *schoolDatabase)
+{
+ m_schoolDatabase = schoolDatabase;
+ m_teachers = m_schoolDatabase->teacherList();
+ connect(m_schoolDatabase, SIGNAL(teacherAdded(const Teacher &)),
+ this, SLOT(teacherAdded(const Teacher &)));
+ connect(m_schoolDatabase, SIGNAL(teacherUpdated(const Teacher &)),
+ this, SLOT(updateTeacher(const Teacher &)));
+ connect(m_schoolDatabase, SIGNAL(teacherDeleted(const Teacher &)),
+ this, SLOT(deleteTeacher(const Teacher &)));
+
+}
+
+void TeacherTableModel::addTeacher(const Teacher &teacher)
+{
+ beginInsertRows(QModelIndex(), m_teachers.size(), m_teachers.size());
+ m_teachers.append(teacher);
+ endInsertRows();
+}
+
+void TeacherTableModel::updateTeacher(const Teacher &teacher)
+{
+ int pos = m_teachers.indexOf(teacher);
+ m_teachers[pos] = teacher;
+ emit dataChanged(index(pos, 0), index(pos, columnCount() - 1));
+}
+
+void TeacherTableModel::deleteTeacher(const Teacher &teacher)
+{
+ int pos = m_teachers.indexOf(teacher);
+ beginRemoveRows(QModelIndex(), pos, pos);
+ m_teachers.removeAt(pos);
+ endRemoveRows();
+}
Added: tux4kids-admin/trunk/tux4kids-admin/teacherTableModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/teacherTableModel.h (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/teacherTableModel.h 2009-07-31 01:16:16 UTC (rev 1298)
@@ -0,0 +1,38 @@
+#ifndef TEACHERTABLEMODEL_H
+#define TEACHERTABLEMODEL_H
+
+#include <QAbstractTableModel>
+#include <QPointer>
+
+#include "teacher.h"
+
+class SchoolDatabase;
+
+class TeacherTableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+public:
+ TeacherTableModel(QObject *parent = 0);
+ void setSchoolDatabase(SchoolDatabase *schoolDatabase);
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+
+protected:
+
+ enum TeacherField {
+ TeacherSelected = 0,
+ TeacherFirstName = 1,
+ TeacherLastName = 2
+ };
+
+ QPointer<SchoolDatabase> m_schoolDatabase;
+ QList<Teacher> m_teachers;
+
+private slots:
+ void addTeacher(const Teacher &teacher);
+ void updateTeacher(const Teacher &teacher);
+ void deleteTeacher(const Teacher &teacher);
+
+};
+
+#endif // TEACHERTABLEMODEL_H
More information about the Tux4kids-commits
mailing list