[Tux4kids-commits] r1433 - in tux4kids-admin/trunk: libtux4kidsadmin tux4kids-admin/src
Michał Świtakowski
swistakers-guest at alioth.debian.org
Fri Aug 14 21:16:05 UTC 2009
Author: swistakers-guest
Date: 2009-08-14 21:16:04 +0000 (Fri, 14 Aug 2009)
New Revision: 1433
Added:
tux4kids-admin/trunk/libtux4kidsadmin/computerDir.cpp
tux4kids-admin/trunk/libtux4kidsadmin/computerDir.h
tux4kids-admin/trunk/libtux4kidsadmin/computerDir_p.h
Modified:
tux4kids-admin/trunk/libtux4kidsadmin/CMakeLists.txt
tux4kids-admin/trunk/libtux4kidsadmin/libtux4kidsadmin.pro
tux4kids-admin/trunk/libtux4kidsadmin/profileDir.cpp
tux4kids-admin/trunk/libtux4kidsadmin/schoolData.cpp
tux4kids-admin/trunk/libtux4kidsadmin/schoolData.h
tux4kids-admin/trunk/libtux4kidsadmin/schoolData_p.h
tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.cpp
tux4kids-admin/trunk/tux4kids-admin/src/studentTableDelegate.cpp
tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.cpp
tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h
tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.cpp
Log:
beginning of ComputerDir-s implementation
Modified: tux4kids-admin/trunk/libtux4kidsadmin/CMakeLists.txt
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/CMakeLists.txt 2009-08-14 02:45:16 UTC (rev 1432)
+++ tux4kids-admin/trunk/libtux4kidsadmin/CMakeLists.txt 2009-08-14 21:16:04 UTC (rev 1433)
@@ -9,13 +9,15 @@
profileDirFactory.cpp
schoolDatabase.cpp
class.cpp
- teacher.cpp )
+ teacher.cpp
+ computerDir.cpp )
SET(LIBTUX4KIDSADMIN_MOC_HEADERS
profileDir.h
schoolData.h
studentDir.h
- schoolDatabase.h )
+ schoolDatabase.h
+ computerDir.h )
# enable warnings
ADD_DEFINITIONS( -Wall -DLIBTUX4KIDSADMIN_LIBRARY )
Added: tux4kids-admin/trunk/libtux4kidsadmin/computerDir.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/computerDir.cpp (rev 0)
+++ tux4kids-admin/trunk/libtux4kidsadmin/computerDir.cpp 2009-08-14 21:16:04 UTC (rev 1433)
@@ -0,0 +1,34 @@
+#include "computerDir.h"
+#include "computerDir_p.h"
+
+/**************************** ComputerPrivate *************************/
+
+ComputerDirPrivate::ComputerDirPrivate()
+{
+}
+
+ComputerDirPrivate::~ComputerDirPrivate()
+{
+}
+
+/**************************** ComputerDir *************************/
+
+ComputerDir::ComputerDir(QObject *parent)
+ : QObject(parent),
+ d_ptr(new ComputerDirPrivate())
+{
+ Q_D(ComputerDir);
+ d->q_ptr = this;
+}
+
+ComputerDir::ComputerDir(ComputerDirPrivate &dd, QObject *parent)
+ : QObject(parent), d_ptr(&dd)
+{
+ Q_D(ComputerDir);
+ d->q_ptr = this;
+}
+
+ComputerDir::~ComputerDir()
+{
+}
+
Added: tux4kids-admin/trunk/libtux4kidsadmin/computerDir.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/computerDir.h (rev 0)
+++ tux4kids-admin/trunk/libtux4kidsadmin/computerDir.h 2009-08-14 21:16:04 UTC (rev 1433)
@@ -0,0 +1,24 @@
+#ifndef COMPUTERDIR_H
+#define COMPUTERDIR_H
+
+#include <QObject>
+
+class ComputerDirPrivate;
+
+class ComputerDir : public QObject
+{
+ Q_OBJECT
+public:
+ ComputerDir(QObject *parent = 0);
+ ~ComputerDir();
+
+protected:
+ ComputerDirPrivate * const d_ptr;
+ ComputerDir(ComputerDirPrivate &dd, QObject *parent = 0);
+
+private:
+ Q_DECLARE_PRIVATE(ComputerDir)
+ Q_DISABLE_COPY(ComputerDir)
+};
+
+#endif // COMPUTERDIR_H
Added: tux4kids-admin/trunk/libtux4kidsadmin/computerDir_p.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/computerDir_p.h (rev 0)
+++ tux4kids-admin/trunk/libtux4kidsadmin/computerDir_p.h 2009-08-14 21:16:04 UTC (rev 1433)
@@ -0,0 +1,22 @@
+#ifndef COMPUTERDIR_P_H
+#define COMPUTERDIR_P_H
+
+#include <QtGlobal>
+#include <QDir>
+#include "libtux4kidsadmin_global.h"
+
+class LIBTUX4KIDSADMIN_SHARED_EXPORT ComputerDirPrivate
+{
+public:
+ Q_DECLARE_PUBLIC(ComputerDir)
+
+ ComputerDirPrivate();
+ virtual ~ComputerDirPrivate();
+
+ ComputerDir *q_ptr;
+
+ QDir mainDir;
+};
+
+
+#endif // COMPUTERDIR_P_H
Modified: tux4kids-admin/trunk/libtux4kidsadmin/libtux4kidsadmin.pro
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/libtux4kidsadmin.pro 2009-08-14 02:45:16 UTC (rev 1432)
+++ tux4kids-admin/trunk/libtux4kidsadmin/libtux4kidsadmin.pro 2009-08-14 21:16:04 UTC (rev 1433)
@@ -10,7 +10,8 @@
profileDirFactory.cpp \
schoolDatabase.cpp \
class.cpp \
- teacher.cpp
+ teacher.cpp \
+ computerDir.cpp
HEADERS += libtux4kidsadmin.h \
libtux4kidsadmin_global.h \
profileDir.h \
@@ -26,4 +27,6 @@
class.h \
class_p.h \
teacher.h \
- teacher_p.h
+ teacher_p.h \
+ computerDir.h \
+ computerDir_p.h
Modified: tux4kids-admin/trunk/libtux4kidsadmin/profileDir.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/profileDir.cpp 2009-08-14 02:45:16 UTC (rev 1432)
+++ tux4kids-admin/trunk/libtux4kidsadmin/profileDir.cpp 2009-08-14 21:16:04 UTC (rev 1433)
@@ -56,7 +56,8 @@
ProfileDir::ProfileDir(ProfileDirPrivate &dd, QObject *parent)
: QObject(parent), d_ptr(&dd)
{
- d_ptr->q_ptr = this;
+ Q_D(ProfileDir);
+ d->q_ptr = this;
}
ProfileDir::~ProfileDir()
Modified: tux4kids-admin/trunk/libtux4kidsadmin/schoolData.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/schoolData.cpp 2009-08-14 02:45:16 UTC (rev 1432)
+++ tux4kids-admin/trunk/libtux4kidsadmin/schoolData.cpp 2009-08-14 21:16:04 UTC (rev 1433)
@@ -5,6 +5,7 @@
#include <QString>
#include <QDebug>
#include <QSqlDatabase>
+#include <QSettings>
/****************** SchoolDataPrivate *******************/
@@ -15,6 +16,7 @@
if (!mainDir.exists()) {
if (!QDir::root().mkpath(path)) {
status = SchoolData::InitializationError;
+ return;
}
}
mainDir.setPath(path);
@@ -23,15 +25,22 @@
if (!database.open(path + "/school_database.db")) {
status = SchoolData::InitializationError;
+ return;
} else {
database.synchronizeStudents(students);
}
+
+ attributes = new QSettings(mainDir.absoluteFilePath("attributes.ini"), QSettings::IniFormat);
+ if (attributes->status() != QSettings::NoError) {
+ status = SchoolData::InitializationError;
+ }
}
SchoolDataPrivate::~SchoolDataPrivate()
{
+ delete attributes;
}
QString SchoolDataPrivate::nextStudentDir() const
@@ -71,6 +80,8 @@
SchoolData::SchoolData(SchoolDataPrivate &dd, QObject *parent)
: QObject(parent), d_ptr(&dd)
{
+ Q_D(SchoolData);
+ d->q_ptr = this;
}
SchoolData::~SchoolData()
@@ -115,3 +126,14 @@
return &(d->database);
}
+int SchoolData::computerCount() const
+{
+ Q_D(const SchoolData);
+ return d->attributes->value("computer_count", 20).toInt();
+}
+
+int SchoolData::setComputerCount(int computerCount)
+{
+
+}
+
Modified: tux4kids-admin/trunk/libtux4kidsadmin/schoolData.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/schoolData.h 2009-08-14 02:45:16 UTC (rev 1432)
+++ tux4kids-admin/trunk/libtux4kidsadmin/schoolData.h 2009-08-14 21:16:04 UTC (rev 1433)
@@ -28,6 +28,8 @@
//const StudentDir & studentDirAt(int index);
QList< QPointer<StudentDir> > students() const;
SchoolDatabase *schoolDatabase();
+ int computerCount() const;
+ int setComputerCount(int computerCount);
protected:
SchoolDataPrivate * const d_ptr;
Modified: tux4kids-admin/trunk/libtux4kidsadmin/schoolData_p.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/schoolData_p.h 2009-08-14 02:45:16 UTC (rev 1432)
+++ tux4kids-admin/trunk/libtux4kidsadmin/schoolData_p.h 2009-08-14 21:16:04 UTC (rev 1433)
@@ -12,6 +12,7 @@
class QString;
class ProfileDir;
class StudentDir;
+class QSettings;
class SchoolDataPrivate
{
@@ -30,6 +31,7 @@
SchoolData::Status status;
QList< QPointer<StudentDir> > students;
QList< QPointer<ProfileDir> > profiles;
+ QSettings *attributes;
SchoolDatabase database;
};
Modified: tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.cpp 2009-08-14 02:45:16 UTC (rev 1432)
+++ tux4kids-admin/trunk/tux4kids-admin/src/manageStudentsWidget.cpp 2009-08-14 21:16:04 UTC (rev 1433)
@@ -16,7 +16,8 @@
m_ui->setupUi(this);
m_ui->studentsTable->setEditTriggers(QAbstractItemView::SelectedClicked
- | QAbstractItemView::EditKeyPressed);
+ | QAbstractItemView::EditKeyPressed
+ | QAbstractItemView::DoubleClicked);
m_ui->studentsTable->setItemDelegateForColumn(StudentTableModel::StudentComputer,
new StudentTableDelegate(this));
m_studentTableProxyModel.setSourceModel(mainController->studentTableModel());
Modified: tux4kids-admin/trunk/tux4kids-admin/src/studentTableDelegate.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/studentTableDelegate.cpp 2009-08-14 02:45:16 UTC (rev 1432)
+++ tux4kids-admin/trunk/tux4kids-admin/src/studentTableDelegate.cpp 2009-08-14 21:16:04 UTC (rev 1433)
@@ -1,5 +1,6 @@
#include "studentTableDelegate.h"
#include "studentTableModel.h"
+#include "studentTableProxyModel.h"
#include <QComboBox>
#include <QDebug>
@@ -22,9 +23,24 @@
QString data = index.data(Qt::DisplayRole).toString();
QComboBox *comboBox = static_cast<QComboBox *>(editor);
if (comboBox != 0) {
- comboBox->addItem(data);
- comboBox->addItem("Computer 1");
- comboBox->addItem("Computer 2");
+ const StudentTableModel *model = qobject_cast<const StudentTableModel *>( index.model());
+ if (model != 0) {
+ int computerCount = model->computerCount();
+ comboBox->addItem(data);
+ for (int i = 1; i <= computerCount; ++i) {
+ comboBox->addItem(tr("Computer %1").arg(i));
+ }
+ } else {
+ const StudentTableProxyModel *proxyModel = qobject_cast<const StudentTableProxyModel *>(index.model());
+ const StudentTableModel *model = qobject_cast<const StudentTableModel *> (proxyModel->sourceModel());
+ if (model != 0) {
+ int computerCount = model->computerCount();
+ comboBox->addItem(data);
+ for (int i = 1; i <= computerCount; ++i) {
+ comboBox->addItem(tr("Computer %1").arg(i));
+ }
+ }
+ }
}
}
Modified: tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.cpp 2009-08-14 02:45:16 UTC (rev 1432)
+++ tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.cpp 2009-08-14 21:16:04 UTC (rev 1433)
@@ -106,6 +106,7 @@
void StudentTableModel::setSchoolData(SchoolData *schoolData)
{
+ m_schoolData = schoolData;
m_students = schoolData->students();
for (int i = 0; i < m_students.size(); i++) {
@@ -201,3 +202,8 @@
return m_students.at(i);
}
+int StudentTableModel::computerCount() const
+{
+ return m_schoolData->computerCount();
+}
+
Modified: tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h 2009-08-14 02:45:16 UTC (rev 1432)
+++ tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h 2009-08-14 21:16:04 UTC (rev 1433)
@@ -29,6 +29,7 @@
StudentDir *studentAt(int i);
void setSchoolData(SchoolData *schoolData);
+ int computerCount() const;
enum StudentField {
StudentSelected = 0,
@@ -41,6 +42,7 @@
QList< QPointer<StudentDir> > m_students;
QList<bool> m_studentsSelection;
+ QPointer<SchoolData> m_schoolData;
private slots:
void addStudent(StudentDir *newStudent);
Modified: tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.cpp 2009-08-14 02:45:16 UTC (rev 1432)
+++ tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.cpp 2009-08-14 21:16:04 UTC (rev 1433)
@@ -48,6 +48,9 @@
} else if (filterKeyColumn() == LastName) {
return student->lastName().contains(filterRegExp());
} else if (filterKeyColumn() == ClassName) {
+ if (student->classes()->empty()) {
+ return true;
+ }
foreach (Class c, *student->classes()) {
if (c.name().contains(filterRegExp())) {
return true;
@@ -55,6 +58,6 @@
}
return false;
}
-
+ return true;
}
More information about the Tux4kids-commits
mailing list