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

Michał Świtakowski swistakers-guest at alioth.debian.org
Tue Aug 4 19:29:56 UTC 2009


Author: swistakers-guest
Date: 2009-08-04 19:29:56 +0000 (Tue, 04 Aug 2009)
New Revision: 1360

Added:
   tux4kids-admin/trunk/tux4kids-admin/src/selectTeacherWidget.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/selectTeacherWidget.h
   tux4kids-admin/trunk/tux4kids-admin/src/selectTeacherWidget.ui
Modified:
   tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt
   tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.h
   tux4kids-admin/trunk/tux4kids-admin/src/src.pro
   tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h
   tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.h
Log:
a few functions in GUI + SelectTeacherWidget

Modified: tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt	2009-08-04 18:25:04 UTC (rev 1359)
+++ tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt	2009-08-04 19:29:56 UTC (rev 1360)
@@ -21,7 +21,8 @@
 	teacherTableProxyModel.cpp 
 	editClassDialog.cpp 
 	editTeacherDialog.cpp
-	selectStudentWidget.cpp )
+	selectStudentWidget.cpp
+	selectTeacherWidget.cpp )
 
 SET(TUX4KIDS-ADMIN_MOC_HEADERS 
 	mainWindow.h
@@ -40,7 +41,8 @@
 	teacherTableProxyModel.h 
 	editClassDialog.h 
 	editTeacherDialog.h
-	selectStudentWidget.h )
+	selectStudentWidget.h
+	selectTeacherWidget.h )
 
 SET(TUX4KIDS-ADMIN_UIS 
 	mainWindow.ui 
@@ -51,7 +53,8 @@
 	manageTeachersWidget.ui 
 	editClassDialog.ui 
 	editTeacherDialog.ui
-	selectStudentWidget.ui )
+	selectStudentWidget.ui
+	selectTeacherWidget.ui )
 
 # enable warnings
 ADD_DEFINITIONS( -Wall )

Modified: tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.cpp	2009-08-04 18:25:04 UTC (rev 1359)
+++ tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.cpp	2009-08-04 19:29:56 UTC (rev 1360)
@@ -1,6 +1,7 @@
 #include "editClassDialog.h"
 #include "ui_editClassDialog.h"
 #include "selectStudentWidget.h"
+#include "class.h"
 
 #include <QPushButton>
 
@@ -10,7 +11,8 @@
 {
 	m_ui->setupUi(this);
 
-	m_ui->verticalLayout->insertWidget(1, new SelectStudentWidget(this));
+	m_selectStudentWidget = new SelectStudentWidget(this);
+	m_ui->verticalLayout->insertWidget(1, m_selectStudentWidget);
 
 	connect(m_ui->nameEdit, SIGNAL(textEdited(QString)), this, SLOT(validate()));
 	connect(m_ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));
@@ -38,3 +40,19 @@
 	}
 }
 
+Class EditClassDialog::getClass() const
+{
+	Class result;
+
+	result.setName(m_ui->nameEdit->text());
+	result.setStudents(m_selectStudentWidget->studentTableModel()->selectedStudentsDirNames());
+	//result.setTeachers();
+
+	return result;
+}
+
+void EditClassDialog::setClass(const Class & newClass)
+{
+	m_ui->nameEdit->setText(newClass.name());
+}
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.h	2009-08-04 18:25:04 UTC (rev 1359)
+++ tux4kids-admin/trunk/tux4kids-admin/src/editClassDialog.h	2009-08-04 19:29:56 UTC (rev 1360)
@@ -10,6 +10,9 @@
 	class EditClassDialog;
 }
 
+class Class;
+class SelectStudentWidget;
+
 class EditClassDialog : public QDialog
 {
 	Q_OBJECT
@@ -17,8 +20,12 @@
 	EditClassDialog(QWidget *parent = 0);
 	~EditClassDialog();
 
+	Class getClass() const;
+	void setClass(const Class & newClass);
+
 private:
 	Ui::EditClassDialog *m_ui;
+	SelectStudentWidget *m_selectStudentWidget;
 
 	bool isValid() const;
 

Added: tux4kids-admin/trunk/tux4kids-admin/src/selectTeacherWidget.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/selectTeacherWidget.cpp	                        (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/selectTeacherWidget.cpp	2009-08-04 19:29:56 UTC (rev 1360)
@@ -0,0 +1,36 @@
+#include "selectTeacherWidget.h"
+#include "ui_selectTeacherWidget.h"
+
+SelectTeacherWidget::SelectTeacherWidget(QWidget *parent)
+		: QWidget(parent),
+		m_ui(new Ui::SelectTeacherWidget)
+{
+	m_ui->setupUi(this);
+
+	m_teacherTableProxyModel.setSourceModel(&m_teacherTableModel);
+	m_ui->teacherTable->setModel(&m_teacherTableProxyModel);
+	connect(m_ui->clearButton, SIGNAL(clicked()), m_ui->searchEdit, SLOT(clear()));
+	connect(m_ui->searchEdit, SIGNAL(textEdited(QString)), this, SLOT(searchEdited()));
+	connect(&m_searchTimer, SIGNAL(timeout()), this, SLOT(updateFilter()));
+}
+
+SelectTeacherWidget::~SelectTeacherWidget()
+{
+	delete m_ui;
+}
+
+TeacherTableModel *SelectTeacherWidget::studentTableModel()
+{
+	return &m_teacherTableModel;
+}
+
+void SelectTeacherWidget::searchEdited()
+{
+	m_searchTimer.start(250);
+}
+
+void SelectTeacherWidget::updateFilter()
+{
+	m_teacherTableProxyModel.setFilterRegExp(m_ui->searchEdit->text());
+}
+

Added: tux4kids-admin/trunk/tux4kids-admin/src/selectTeacherWidget.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/selectTeacherWidget.h	                        (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/selectTeacherWidget.h	2009-08-04 19:29:56 UTC (rev 1360)
@@ -0,0 +1,34 @@
+#ifndef SELECTTEACHERWIDGET_H
+#define SELECTTEACHERWIDGET_H
+
+#include <QtGui/QWidget>
+#include <QTimer>
+
+#include "teacherTableModel.h"
+#include "teacherTableProxyModel.h"
+
+namespace Ui {
+	class SelectTeacherWidget;
+}
+
+class SelectTeacherWidget : public QWidget
+{
+	Q_OBJECT
+public:
+	SelectTeacherWidget(QWidget *parent = 0);
+	~SelectTeacherWidget();
+	TeacherTableModel *studentTableModel();
+
+private:
+	Ui::SelectTeacherWidget *m_ui;
+
+	TeacherTableModel m_teacherTableModel;
+	TeacherTableProxyModel m_teacherTableProxyModel;
+	QTimer m_searchTimer;
+
+private slots:
+	void searchEdited();
+	void updateFilter();
+};
+
+#endif // SELECTTEACHERWIDGET_H

Added: tux4kids-admin/trunk/tux4kids-admin/src/selectTeacherWidget.ui
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/selectTeacherWidget.ui	                        (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/selectTeacherWidget.ui	2009-08-04 19:29:56 UTC (rev 1360)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SelectTeacherWidget</class>
+ <widget class="QWidget" name="SelectTeacherWidget">
+  <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>
+  <layout class="QVBoxLayout" name="verticalLayout_2">
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout">
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout">
+       <item>
+        <widget class="QPushButton" name="clearButton">
+         <property name="text">
+          <string>Clear</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLineEdit" name="searchEdit"/>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <widget class="QTableView" name="teacherTable"/>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

Modified: tux4kids-admin/trunk/tux4kids-admin/src/src.pro
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/src.pro	2009-08-04 18:25:04 UTC (rev 1359)
+++ tux4kids-admin/trunk/tux4kids-admin/src/src.pro	2009-08-04 19:29:56 UTC (rev 1360)
@@ -22,7 +22,8 @@
     teacherTableProxyModel.cpp \
     editTeacherDialog.cpp \
     editClassDialog.cpp \
-    selectStudentWidget.cpp
+    selectStudentWidget.cpp \
+    selectTeacherWidget.cpp
 HEADERS += mainWindow.h \
     mainController.h \
     pluginManager.h \
@@ -41,7 +42,8 @@
     teacherTableProxyModel.h \
     editTeacherDialog.h \
     editClassDialog.h \
-    selectStudentWidget.h
+    selectStudentWidget.h \
+    selectTeacherWidget.h
 FORMS += mainWindow.ui \
     pluginManagerDialog.ui \
     manageStudentsWidget.ui \
@@ -50,6 +52,7 @@
     manageTeachersWidget.ui \
     editTeacherDialog.ui \
     editClassDialog.ui \
-    selectStudentWidget.ui
+    selectStudentWidget.ui \
+    selectTeacherWidget.ui
 LIBS += -ltux4kidsadmin \
     -L../../libtux4kidsadmin

Modified: tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.cpp	2009-08-04 18:25:04 UTC (rev 1359)
+++ tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.cpp	2009-08-04 19:29:56 UTC (rev 1360)
@@ -1,7 +1,9 @@
 #include "studentTableModel.h"
 #include "schoolData.h"
 #include "studentDir.h"
+
 #include <QDebug>
+#include <QStringList>
 
 StudentTableModel::StudentTableModel(QObject *parent)
 		: QAbstractTableModel(parent)
@@ -111,3 +113,15 @@
 	m_students.append(newStudent);
 	endInsertRows();
 }
+
+QStringList StudentTableModel::selectedStudentsDirNames() const
+{
+	QStringList result;
+	for(int i = 0; i < m_studentsSelection.size(); i++) {
+		if (m_studentsSelection.at(i)) {
+			result.append(m_students.at(i)->dirName());
+		}
+	}
+	return result;
+}
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h	2009-08-04 18:25:04 UTC (rev 1359)
+++ tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h	2009-08-04 19:29:56 UTC (rev 1360)
@@ -21,6 +21,7 @@
 	QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
 	Qt::ItemFlags flags(const QModelIndex &index) const;
 	bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+	QStringList selectedStudentsDirNames() const;
 
 	void setSchoolData(const SchoolData *schoolData);
 

Modified: tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.cpp	2009-08-04 18:25:04 UTC (rev 1359)
+++ tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.cpp	2009-08-04 19:29:56 UTC (rev 1360)
@@ -132,3 +132,27 @@
 		endRemoveRows();
 	}
 }
+
+QList<Teacher> TeacherTableModel::selectedTeachers() const
+{
+	QList<Teacher> result;
+	for (int i = 0; i < m_teachersSelection.size(); ++i) {
+		if (m_teachersSelection.at(i)) {
+			result.append(m_teachers.at(i));
+		}
+	}
+	return result;
+}
+
+void TeacherTableModel::setSelectedTeachers(const QList<Teacher> &selectedTeachers)
+{
+	for (int i = 0; i < m_teachers.size(); ++i) {
+		if (selectedTeachers.contains(m_teachers.at(i))) {
+			m_teachersSelection[i] = true;
+		} else {
+			m_teachersSelection[i] = false;
+		}
+	}
+	emit dataChanged(index(0, TeacherSelected), index(rowCount() - 1, TeacherSelected));
+}
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.h	2009-08-04 18:25:04 UTC (rev 1359)
+++ tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.h	2009-08-04 19:29:56 UTC (rev 1360)
@@ -20,6 +20,8 @@
 	QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
 	Qt::ItemFlags flags(const QModelIndex &index) const;
 	bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole);
+	QList<Teacher> selectedTeachers() const;
+	void setSelectedTeachers(const QList<Teacher> &selectedTeachers);
 
 	enum TeacherField {
 		TeacherSelected = 0,




More information about the Tux4kids-commits mailing list