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

Michał Świtakowski swistakers-guest at alioth.debian.org
Fri Aug 7 21:41:13 UTC 2009


Author: swistakers-guest
Date: 2009-08-07 21:41:13 +0000 (Fri, 07 Aug 2009)
New Revision: 1393

Modified:
   tux4kids-admin/trunk/libtux4kidsadmin/schoolDatabase.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h
   tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.h
Log:
edit dialog filled with data, still some bugs there

Modified: tux4kids-admin/trunk/libtux4kidsadmin/schoolDatabase.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/schoolDatabase.cpp	2009-08-07 21:17:17 UTC (rev 1392)
+++ tux4kids-admin/trunk/libtux4kidsadmin/schoolDatabase.cpp	2009-08-07 21:41:13 UTC (rev 1393)
@@ -535,7 +535,7 @@
 	if (error) {
 		return QList<Class>();
 	}
-qDebug() << "aaaa";
+
 	QSqlQuery classTeachers;
 	classTeachers.prepare("SELECT id_class, id_teacher FROM class_teachers ORDER BY id_class ASC;");
 	classTeachers.exec();
@@ -544,7 +544,7 @@
 		lastError = classTeachers.lastError().text();
 		return QList<Class>();
 	}
-qDebug() << "bbb";
+
 	QSqlRecord classTeachersRecord = classTeachers.record();
 	int oldClassId = -1;
 	int classIndex = 0;
@@ -570,7 +570,7 @@
 			}
 		}
 	}
-qDebug() << "cccc";
+
 	QSqlQuery students;
 	students.prepare("SELECT id, profile_name FROM students;");
 	students.exec();
@@ -579,7 +579,7 @@
 		lastError = students.lastError().text();
 		return QList<Class>();
 	}
-qDebug() << "dddd";
+
 	QSqlQuery classStudents;
 	classStudents.prepare("SELECT id_class, id_student FROM class_students ORDER BY id_class ASC;");
 	classStudents.exec();
@@ -588,7 +588,7 @@
 		lastError = classStudents.lastError().text();
 		return QList<Class>();
 	}
-qDebug() << "eeee";
+
 	QSqlRecord classStudentsRecord = classStudents.record();
 	QSqlRecord studentsRecord = students.record();
 	oldClassId = -1;
@@ -665,7 +665,7 @@
 	if (error) {
 		return QList<Teacher>();
 	}
-qDebug() << "AAA";
+
 	QSqlQuery classTeachers;
 	classTeachers.prepare("SELECT id_class, id_teacher FROM class_teachers ORDER BY id_teacher ASC;");
 	classTeachers.exec();
@@ -674,7 +674,7 @@
 		lastError = classTeachers.lastError().text();
 		return QList<Teacher>();
 	}
-qDebug() << "BBBB";
+
 	QSqlRecord classTeachersRecord = classTeachers.record();
 
 	int oldTeacherId = -1;

Modified: tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp	2009-08-07 21:17:17 UTC (rev 1392)
+++ tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.cpp	2009-08-07 21:41:13 UTC (rev 1393)
@@ -161,8 +161,8 @@
 	emit dataChanged(index(0, ClassSelected), index(rowCount() - 1, ClassSelected));
 }
 
-const Class &ClassTableModel::at(int i)
+Class &ClassTableModel::at(int i)
 {
-	return m_classes.at(i);
+	return m_classes[i];
 }
 

Modified: tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h	2009-08-07 21:17:17 UTC (rev 1392)
+++ tux4kids-admin/trunk/tux4kids-admin/src/classTableModel.h	2009-08-07 21:41:13 UTC (rev 1393)
@@ -22,7 +22,7 @@
 	QList<Class> selectedClasses() const;
 	void setSelectedClasses(const QList<Class> &selectedClasses);
 	void clearSelection();
-	const Class &at(int i);
+	Class &at(int i);
 
 	void setSchoolDatabase(SchoolDatabase *schoolDatabase);
 

Modified: tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.cpp	2009-08-07 21:17:17 UTC (rev 1392)
+++ tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.cpp	2009-08-07 21:41:13 UTC (rev 1393)
@@ -5,6 +5,7 @@
 #include "schoolData.h"
 #include "class.h"
 
+#include <QDebug>
 #include <QPushButton>
 
 EditClassDialog::EditClassDialog(SchoolData *schoolData, QWidget *parent) :
@@ -62,8 +63,15 @@
 	return result;
 }
 
-void EditClassDialog::setClass(Class & newClass)
+void EditClassDialog::setClass(Class &newClass)
 {
+	qDebug() << "setting" << newClass.name();
+	foreach(Teacher t, *newClass.teachers()) {
+		qDebug() << t.firstName();
+	}
+	foreach(QString s, *newClass.students()) {
+		qDebug() << s;
+	}
 	m_ui->nameEdit->setText(newClass.name());
 	m_teacherTableModel.setSelectedTeachers(*newClass.teachers());
 	m_studentTableModel.setSelectedStudents(*newClass.students());

Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp	2009-08-07 21:17:17 UTC (rev 1392)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageClassesWidget.cpp	2009-08-07 21:41:13 UTC (rev 1393)
@@ -53,7 +53,9 @@
 		connect(m_editClassDialog, SIGNAL(accepted()), this, SLOT(editAccepted()));
 		connect(m_editClassDialog, SIGNAL(rejected()), this, SLOT(editRejected()));
 	}
-	//m_editClassDialog->setClass(editedClass);
+
+	QModelIndex classIndex = m_selectClassWidget->selectedClassIndex();
+	m_editClassDialog->setClass(m_mainController->classTableModel()->at(classIndex.row()));
 	m_editClassDialog->showNormal();
 }
 

Modified: tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.cpp	2009-08-07 21:17:17 UTC (rev 1392)
+++ tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.cpp	2009-08-07 21:41:13 UTC (rev 1393)
@@ -38,3 +38,9 @@
 	m_classTableProxyModel.setFilterRegExp(m_ui->searchEdit->text());
 }
 
+QModelIndex SelectClassWidget::selectedClassIndex()
+{
+	QModelIndex proxyIndex = m_ui->classTable->selectionModel()->selectedIndexes().first();
+	return m_classTableProxyModel.mapToSource(proxyIndex);
+}
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.h	2009-08-07 21:17:17 UTC (rev 1392)
+++ tux4kids-admin/trunk/tux4kids-admin/src/selectClassWidget.h	2009-08-07 21:41:13 UTC (rev 1393)
@@ -22,6 +22,7 @@
 
 	void setClassTableModel(ClassTableModel *classTableModel);
 	QTableView *classTable();
+	QModelIndex selectedClassIndex();
 
 private:
 	Ui::SelectClassWidget *m_ui;




More information about the Tux4kids-commits mailing list