[Tux4kids-commits] r1324 - in tux4kids-admin/trunk: libtux4kidsadmin tux4kids-admin/src

Michał Świtakowski swistakers-guest at alioth.debian.org
Sat Aug 1 21:33:18 UTC 2009


Author: swistakers-guest
Date: 2009-08-01 21:33:18 +0000 (Sat, 01 Aug 2009)
New Revision: 1324

Added:
   tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.h
   tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.ui
   tux4kids-admin/trunk/tux4kids-admin/src/editTeacherDialog.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/editTeacherDialog.h
   tux4kids-admin/trunk/tux4kids-admin/src/editTeacherDialog.ui
Modified:
   tux4kids-admin/trunk/libtux4kidsadmin/class.cpp
   tux4kids-admin/trunk/libtux4kidsadmin/class.h
   tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt
   tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h
   tux4kids-admin/trunk/tux4kids-admin/src/src.pro
   tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.cpp
Log:
added dialogs, corrected teacher model

Modified: tux4kids-admin/trunk/libtux4kidsadmin/class.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/class.cpp	2009-08-01 19:32:39 UTC (rev 1323)
+++ tux4kids-admin/trunk/libtux4kidsadmin/class.cpp	2009-08-01 21:33:18 UTC (rev 1324)
@@ -101,3 +101,16 @@
 	return *this;
 }
 
+bool Class::operator==(const Class &other) const
+{
+	Q_D(const Class);
+
+	if (d->id >= 0 && other.d_ptr->id >= 0) {
+		return d->id == other.d_ptr->id;
+	} else {
+		return d->name == other.d_ptr->name
+			&& d->students == other.d_ptr->students
+			&& d->teachers == other.d_ptr->teachers;
+	}
+}
+

Modified: tux4kids-admin/trunk/libtux4kidsadmin/class.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/class.h	2009-08-01 19:32:39 UTC (rev 1323)
+++ tux4kids-admin/trunk/libtux4kidsadmin/class.h	2009-08-01 21:33:18 UTC (rev 1324)
@@ -26,6 +26,7 @@
 	QList<Teacher> teachers() const;
 	void setTeachers(const QList<Teacher> &teachers);
 	Class &operator=(const Class&);
+	bool operator==(const Class &other) const;
 
 protected:
 

Modified: tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt	2009-08-01 19:32:39 UTC (rev 1323)
+++ tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt	2009-08-01 21:33:18 UTC (rev 1324)
@@ -19,7 +19,9 @@
 	manageTeachersWidget.cpp 
 	teacherTableModel.cpp 
 	classTableProxyModel.cpp 
-	teacherTableProxyModel.cpp )
+	teacherTableProxyModel.cpp 
+	editClassDialog.cpp 
+	editTeacherDialog.cpp )
 
 SET(TUX4KIDS-ADMIN_MOC_HEADERS 
 	mainWindow.h
@@ -36,7 +38,9 @@
 	manageTeachersWidget.h
 	teacherTableModel.h 
 	classTableProxyModel.h 
-	teacherTableProxyModel.h )
+	teacherTableProxyModel.h 
+	editClassDialog.h 
+	editTeacherDialog.h )
 
 SET(TUX4KIDS-ADMIN_UIS 
 	mainWindow.ui 
@@ -45,7 +49,9 @@
 	addStudentDialog.ui
 	manageClassesWidget.ui 
 	manageClassDialog.ui 
-	manageTeachersWidget.ui )
+	manageTeachersWidget.ui 
+	editClassDialog.ui 
+	editTeacherDialog.ui )
 
 # enable warnings
 ADD_DEFINITIONS( -Wall )

Modified: tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp	2009-08-01 19:32:39 UTC (rev 1323)
+++ tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp	2009-08-01 21:33:18 UTC (rev 1324)
@@ -90,6 +90,43 @@
 	for (int i = 0; i < m_classes.size(); i++) {
 		m_classesSelection.append(false);
 	}
+
+	void classAdded(const Class &newClass);
+	void classUpdated(const Class &updatedClass);
+	void classDeleted(const Class &deletedClass);
+
+	connect(m_schoolDatabase, SIGNAL(classAdded(const Class &)), this, SLOT(addClass(const Class &)));
+	connect(m_schoolDatabase, SIGNAL(classUpdated(const Class &)), this, SLOT(updateClass(const Class &)));
+	connect(m_schoolDatabase, SIGNAL(classDeleted(const Class &)), this, SLOT(deleteClass(const Class &)));
+
 	reset();
 }
 
+void ClassTableModel::addClass(const Class & newClass)
+{
+	beginInsertRows(QModelIndex(), m_classes.size(), m_classes.size());
+	m_classes.append(newClass);
+	m_classesSelection.append(false);
+	endInsertRows();
+}
+
+void ClassTableModel::updateClass(const Class &updatedClass)
+{
+	int pos = m_classes.indexOf(updatedClass);
+	if (pos != -1) {
+		m_classes[pos] = updatedClass;
+		emit dataChanged(index(pos, 0) , index(pos, columnCount() - 1));
+	}
+}
+
+void ClassTableModel::deleteClass(const Class &deletedClass)
+{
+	int pos = m_classes.indexOf(deletedClass);
+	if (pos != -1) {
+		beginRemoveRows(QModelIndex(), pos, pos);
+		m_classes.removeAt(pos);
+		m_classesSelection.removeAt(pos);
+		endRemoveRows();
+	}
+}
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h	2009-08-01 19:32:39 UTC (rev 1323)
+++ tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h	2009-08-01 21:33:18 UTC (rev 1324)
@@ -27,10 +27,14 @@
 		ClassName = 1,
 	};
 private:
-
 	QPointer<SchoolDatabase> m_schoolDatabase;
 	QList<Class> m_classes;
 	QList<bool> m_classesSelection;
+
+private slots:
+	void addClass(const Class & newClass);
+	void updateClass(const Class &updatedClass);
+	void deleteClass(const Class &deletedClass);
 };
 
 #endif // CLASSTABLEMODEL_H

Added: tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.cpp	                        (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.cpp	2009-08-01 21:33:18 UTC (rev 1324)
@@ -0,0 +1,14 @@
+#include "editClassDialog.h"
+#include "ui_editClassDialog.h"
+
+EditClassDialog::EditClassDialog(QWidget *parent) :
+		QDialog(parent),
+		m_ui(new Ui::EditClassDialog)
+{
+	m_ui->setupUi(this);
+}
+
+EditClassDialog::~EditClassDialog()
+{
+	delete m_ui;
+}

Added: tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.h	                        (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.h	2009-08-01 21:33:18 UTC (rev 1324)
@@ -0,0 +1,21 @@
+#ifndef EDITCLASSDIALOG_H
+#define EDITCLASSDIALOG_H
+
+#include <QtGui/QDialog>
+
+namespace Ui {
+	class EditClassDialog;
+}
+
+class EditClassDialog : public QDialog
+{
+	Q_OBJECT
+public:
+	EditClassDialog(QWidget *parent = 0);
+	~EditClassDialog();
+
+private:
+	Ui::EditClassDialog *m_ui;
+};
+
+#endif // EDITCLASSDIALOG_H

Added: tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.ui
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.ui	                        (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.ui	2009-08-01 21:33:18 UTC (rev 1324)
@@ -0,0 +1,18 @@
+<ui version="4.0" >
+ <class>EditClassDialog</class>
+ <widget class="QDialog" name="EditClassDialog" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Dialog</string>
+  </property>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

Added: tux4kids-admin/trunk/tux4kids-admin/src/editTeacherDialog.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/editTeacherDialog.cpp	                        (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/editTeacherDialog.cpp	2009-08-01 21:33:18 UTC (rev 1324)
@@ -0,0 +1,14 @@
+#include "editTeacherDialog.h"
+#include "ui_editTeacherDialog.h"
+
+EditTeacherDialog::EditTeacherDialog(QWidget *parent) :
+		QDialog(parent),
+		m_ui(new Ui::EditTeacherDialog)
+{
+	m_ui->setupUi(this);
+}
+
+EditTeacherDialog::~EditTeacherDialog()
+{
+	delete m_ui;
+}

Added: tux4kids-admin/trunk/tux4kids-admin/src/editTeacherDialog.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/editTeacherDialog.h	                        (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/editTeacherDialog.h	2009-08-01 21:33:18 UTC (rev 1324)
@@ -0,0 +1,21 @@
+#ifndef EDITTEACHERDIALOG_H
+#define EDITTEACHERDIALOG_H
+
+#include <QtGui/QDialog>
+
+namespace Ui {
+	class EditTeacherDialog;
+}
+
+class EditTeacherDialog : public QDialog
+{
+	Q_OBJECT
+public:
+	EditTeacherDialog(QWidget *parent = 0);
+	~EditTeacherDialog();
+
+private:
+	Ui::EditTeacherDialog *m_ui;
+};
+
+#endif // EDITTEACHERDIALOG_H

Added: tux4kids-admin/trunk/tux4kids-admin/src/editTeacherDialog.ui
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/editTeacherDialog.ui	                        (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/editTeacherDialog.ui	2009-08-01 21:33:18 UTC (rev 1324)
@@ -0,0 +1,18 @@
+<ui version="4.0" >
+ <class>EditTeacherDialog</class>
+ <widget class="QDialog" name="EditTeacherDialog" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Dialog</string>
+  </property>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

Modified: tux4kids-admin/trunk/tux4kids-admin/src/src.pro
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/src.pro	2009-08-01 19:32:39 UTC (rev 1323)
+++ tux4kids-admin/trunk/tux4kids-admin/src/src.pro	2009-08-01 21:33:18 UTC (rev 1324)
@@ -20,7 +20,9 @@
     manageTeachersWidget.cpp \
     teacherTableModel.cpp \
     classTableProxyModel.cpp \
-    teacherTableProxyModel.cpp
+    teacherTableProxyModel.cpp \
+    editTeacherDialog.cpp \
+    editClassDialog.cpp
 HEADERS += mainWindow.h \
     mainController.h \
     pluginManager.h \
@@ -37,13 +39,17 @@
     manageTeachersWidget.h \
     teacherTableModel.h \
     classTableProxyModel.h \
-    teacherTableProxyModel.h
+    teacherTableProxyModel.h \
+    editTeacherDialog.h \
+    editClassDialog.h
 FORMS += mainWindow.ui \
     pluginManagerDialog.ui \
     manageStudentsWidget.ui \
     addStudentDialog.ui \
     manageClassesWidget.ui \
     manageClassDialog.ui \
-    manageTeachersWidget.ui
+    manageTeachersWidget.ui \
+    editTeacherDialog.ui \
+    editClassDialog.ui
 LIBS += -ltux4kidsadmin \
     -L../../libtux4kidsadmin

Modified: tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.cpp	2009-08-01 19:32:39 UTC (rev 1323)
+++ tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.cpp	2009-08-01 21:33:18 UTC (rev 1324)
@@ -116,15 +116,19 @@
 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));
+	if (pos != -1) {
+		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);
-	m_teachersSelection.removeAt(pos);
-	endRemoveRows();
+	if (pos != -1) {
+		beginRemoveRows(QModelIndex(), pos, pos);
+		m_teachers.removeAt(pos);
+		m_teachersSelection.removeAt(pos);
+		endRemoveRows();
+	}
 }




More information about the Tux4kids-commits mailing list