[Tux4kids-commits] r1313 - tux4kids-admin/trunk/tux4kids-admin/src
Michał Świtakowski
swistakers-guest at alioth.debian.org
Fri Jul 31 20:49:25 UTC 2009
Author: swistakers-guest
Date: 2009-07-31 20:49:25 +0000 (Fri, 31 Jul 2009)
New Revision: 1313
Added:
tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.cpp
tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.h
Modified:
tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt
tux4kids-admin/trunk/tux4kids-admin/src/classTableProxyModel.cpp
tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.cpp
tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.h
tux4kids-admin/trunk/tux4kids-admin/src/src.pro
tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h
tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.cpp
tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.h
Log:
work on proxy models, sorting works
Modified: tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt 2009-07-31 20:30:06 UTC (rev 1312)
+++ tux4kids-admin/trunk/tux4kids-admin/src/CMakeLists.txt 2009-07-31 20:49:25 UTC (rev 1313)
@@ -18,7 +18,8 @@
manageClassDialog.cpp
manageTeachersWidget.cpp
teacherTableModel.cpp
- classTableProxyModel.cpp )
+ classTableProxyModel.cpp
+ teacherTableProxyModel.cpp )
SET(TUX4KIDS-ADMIN_MOC_HEADERS
mainWindow.h
@@ -34,7 +35,8 @@
manageClassDialog.h
manageTeachersWidget.h
teacherTableModel.h
- classTableProxyModel.h )
+ classTableProxyModel.h
+ teacherTableProxyModel.h )
SET(TUX4KIDS-ADMIN_UIS
mainWindow.ui
Modified: tux4kids-admin/trunk/tux4kids-admin/src/classTableProxyModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/classTableProxyModel.cpp 2009-07-31 20:30:06 UTC (rev 1312)
+++ tux4kids-admin/trunk/tux4kids-admin/src/classTableProxyModel.cpp 2009-07-31 20:49:25 UTC (rev 1313)
@@ -10,19 +10,16 @@
bool ClassTableProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
- switch(left.column()) {
- case ClassTableModel::ClassSelected:
+ if (left.column() == ClassTableModel::ClassSelected) {
if ((sourceModel()->data(left, Qt::CheckStateRole).toInt() == Qt::Checked) && (sourceModel()->data(right, Qt::CheckStateRole).toInt() == Qt::Unchecked)) {
return true;
} else {
return false;
};
- case ClassTableModel::ClassName: {
+ } else {
QVariant leftData = sourceModel()->data(left);
QVariant rightData = sourceModel()->data(right);
return QString::localeAwareCompare(leftData.toString(),
rightData.toString()) < 0;
- }
}
- return false;
}
Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.cpp 2009-07-31 20:30:06 UTC (rev 1312)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.cpp 2009-07-31 20:49:25 UTC (rev 1313)
@@ -10,7 +10,8 @@
{
m_ui->setupUi(this);
- m_ui->teachersTable->setModel(m_mainController->teacherTableModel());
+ m_teacherTableProxyModel.setSourceModel(m_mainController->teacherTableModel());
+ m_ui->teachersTable->setModel(&m_teacherTableProxyModel);
}
ManageTeachersWidget::~ManageTeachersWidget()
Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.h 2009-07-31 20:30:06 UTC (rev 1312)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageTeachersWidget.h 2009-07-31 20:49:25 UTC (rev 1313)
@@ -4,6 +4,8 @@
#include <QtGui/QWidget>
#include <QPointer>
+#include "teacherTableProxyModel.h"
+
namespace Ui {
class ManageTeachersWidget;
}
@@ -20,6 +22,7 @@
private:
Ui::ManageTeachersWidget *m_ui;
QPointer<MainController> m_mainController;
+ TeacherTableProxyModel m_teacherTableProxyModel;
};
#endif // MANAGETEACHERSWIDGET_H
Modified: tux4kids-admin/trunk/tux4kids-admin/src/src.pro
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/src.pro 2009-07-31 20:30:06 UTC (rev 1312)
+++ tux4kids-admin/trunk/tux4kids-admin/src/src.pro 2009-07-31 20:49:25 UTC (rev 1313)
@@ -19,7 +19,8 @@
manageClassDialog.cpp \
manageTeachersWidget.cpp \
teacherTableModel.cpp \
- classTableProxyModel.cpp
+ classTableProxyModel.cpp \
+ teacherTableProxyModel.cpp
HEADERS += mainWindow.h \
mainController.h \
pluginManager.h \
@@ -35,7 +36,8 @@
manageClassDialog.h \
manageTeachersWidget.h \
teacherTableModel.h \
- classTableProxyModel.h
+ classTableProxyModel.h \
+ teacherTableProxyModel.h
FORMS += mainWindow.ui \
pluginManagerDialog.ui \
manageStudentsWidget.ui \
Modified: tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h 2009-07-31 20:30:06 UTC (rev 1312)
+++ tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h 2009-07-31 20:49:25 UTC (rev 1313)
@@ -24,14 +24,14 @@
void setSchoolData(const SchoolData *schoolData);
-protected:
-
enum StudentField {
StudentSelected = 0,
StudentFirstName = 1,
StudentLastName = 2
};
+protected:
+
QList< QPointer<StudentDir> > m_students;
QList<bool> m_studentsSelection;
Modified: tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.cpp 2009-07-31 20:30:06 UTC (rev 1312)
+++ tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.cpp 2009-07-31 20:49:25 UTC (rev 1313)
@@ -1,4 +1,5 @@
#include "studentTableProxyModel.h"
+#include "studentTableModel.h"
#include "studentDir.h"
StudentTableProxyModel::StudentTableProxyModel(QObject *parent)
@@ -8,9 +9,17 @@
bool StudentTableProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
- QVariant leftData = sourceModel()->data(left);
- QVariant rightData = sourceModel()->data(right);
- return QString::localeAwareCompare(leftData.toString(),
+ if (left.column() == StudentTableModel::StudentSelected) {
+ if ((sourceModel()->data(left, Qt::CheckStateRole).toInt() == Qt::Checked) && (sourceModel()->data(right, Qt::CheckStateRole).toInt() == Qt::Unchecked)) {
+ return true;
+ } else {
+ return false;
+ };
+ } else {
+ QVariant leftData = sourceModel()->data(left);
+ QVariant rightData = sourceModel()->data(right);
+ return QString::localeAwareCompare(leftData.toString(),
rightData.toString()) < 0;
+ }
}
Modified: tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.h 2009-07-31 20:30:06 UTC (rev 1312)
+++ tux4kids-admin/trunk/tux4kids-admin/src/teacherTableModel.h 2009-07-31 20:49:25 UTC (rev 1313)
@@ -21,14 +21,14 @@
Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole);
-protected:
-
enum TeacherField {
TeacherSelected = 0,
TeacherFirstName = 1,
TeacherLastName = 2
};
+protected:
+
QPointer<SchoolDatabase> m_schoolDatabase;
QList<Teacher> m_teachers;
QList<bool> m_teachersSelection;
Added: tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.cpp (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.cpp 2009-07-31 20:49:25 UTC (rev 1313)
@@ -0,0 +1,24 @@
+#include "teacherTableProxyModel.h"
+#include "teacherTableModel.h"
+
+TeacherTableProxyModel::TeacherTableProxyModel(QObject *parent)
+ : QSortFilterProxyModel(parent)
+{
+}
+
+bool TeacherTableProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
+{
+ if (left.column() ==TeacherTableModel::TeacherSelected) {
+ if ((sourceModel()->data(left, Qt::CheckStateRole).toInt() == Qt::Checked) && (sourceModel()->data(right, Qt::CheckStateRole).toInt() == Qt::Unchecked)) {
+ return true;
+ } else {
+ return false;
+ };
+ } else {
+ QVariant leftData = sourceModel()->data(left);
+ QVariant rightData = sourceModel()->data(right);
+ return QString::localeAwareCompare(leftData.toString(),
+ rightData.toString()) < 0;
+ }
+}
+
Added: tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.h (rev 0)
+++ tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.h 2009-07-31 20:49:25 UTC (rev 1313)
@@ -0,0 +1,15 @@
+#ifndef TEACHERTABLEPROXYMODEL_H
+#define TEACHERTABLEPROXYMODEL_H
+
+#include <QSortFilterProxyModel>
+
+class TeacherTableProxyModel : public QSortFilterProxyModel
+{
+ Q_OBJECT
+public:
+ TeacherTableProxyModel(QObject *parent = 0);
+
+ bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
+};
+
+#endif // TEACHERTABLEPROXYMODEL_H
More information about the Tux4kids-commits
mailing list