[Tux4kids-commits] r1415 - in tux4kids-admin/trunk: libtux4kidsadmin libtux4kidsadmin_tuxmath tux4kids-admin/plugins/tuxmathPlugin tux4kids-admin/src
Michał Świtakowski
swistakers-guest at alioth.debian.org
Tue Aug 11 21:25:18 UTC 2009
Author: swistakers-guest
Date: 2009-08-11 21:25:18 +0000 (Tue, 11 Aug 2009)
New Revision: 1415
Modified:
tux4kids-admin/trunk/libtux4kidsadmin/profileDir.cpp
tux4kids-admin/trunk/libtux4kidsadmin/studentDir.cpp
tux4kids-admin/trunk/libtux4kidsadmin/studentDir.h
tux4kids-admin/trunk/libtux4kidsadmin/studentDir_p.h
tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.cpp
tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.h
tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/tuxmathOptions.cpp
tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/tuxmathOptions.h
tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/CMakeLists.txt
tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/editTuxmathOptions.cpp
tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/editTuxmathOptions.h
tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/editTuxmathOptions.ui
tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/tuxmathMainWidget.cpp
tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/tuxmathMainWidget.h
tux4kids-admin/trunk/tux4kids-admin/src/mainWindow.cpp
tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.cpp
tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h
Log:
editing options file in tuxmath works
Modified: tux4kids-admin/trunk/libtux4kidsadmin/profileDir.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/profileDir.cpp 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/libtux4kidsadmin/profileDir.cpp 2009-08-11 21:25:18 UTC (rev 1415)
@@ -22,9 +22,11 @@
status = ProfileDir::InitializationError;
return;
}*/
- if (!mainDir.mkdir("data")) {
- status = ProfileDir::InitializationError;
- return;
+ if (!mainDir.exists("data")) {
+ if (!mainDir.mkdir("data")) {
+ status = ProfileDir::InitializationError;
+ return;
+ }
}
dataDir = QDir(mainDir.absoluteFilePath("data"));
@@ -54,6 +56,7 @@
ProfileDir::ProfileDir(ProfileDirPrivate &dd, QObject *parent)
: QObject(parent), d_ptr(&dd)
{
+ d_ptr->q_ptr = this;
}
ProfileDir::~ProfileDir()
@@ -70,7 +73,7 @@
QString ProfileDir::profileType(QString path)
{
- QSettings tmp(path + "/attributes.ini");
+ QSettings tmp(path + "/attributes.ini", QSettings::IniFormat);
return tmp.value("profile_type", "unknown").toString();
}
Modified: tux4kids-admin/trunk/libtux4kidsadmin/studentDir.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/studentDir.cpp 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/libtux4kidsadmin/studentDir.cpp 2009-08-11 21:25:18 UTC (rev 1415)
@@ -25,6 +25,8 @@
status = StudentDir::InitializationError;
return;
}
+
+ loadProfileDirs();
}
StudentDirPrivate::~StudentDirPrivate()
@@ -41,7 +43,8 @@
QString path = mainDir.filePath(dirName);
QString profileType = ProfileDir::profileType(path);
- profiles.append(ProfileDirFactory::instance().create(profileType, path, q));
+ qDebug() << path << profileType;
+ profiles.append(ProfileDirFactory::instance().create(profileType, path, 0));
}
}
@@ -138,6 +141,12 @@
return &d->classes;
}
+QList<ProfileDir *> StudentDir::profiles()
+{
+ Q_D(StudentDir);
+ return d->profiles;
+}
+
/*void StudentDir::setClasses(const QList<Class> &classes)
{
Q_D(StudentDir);
Modified: tux4kids-admin/trunk/libtux4kidsadmin/studentDir.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/studentDir.h 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/libtux4kidsadmin/studentDir.h 2009-08-11 21:25:18 UTC (rev 1415)
@@ -32,6 +32,7 @@
void addProfileDir(ProfileDir *profileDir);
ProfileDir *addProfileDir(QString profileType);
QList<Class> *classes();
+ QList<ProfileDir *> profiles();
//void setClasses(const QList<Class>& classes);
protected:
Modified: tux4kids-admin/trunk/libtux4kidsadmin/studentDir_p.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/studentDir_p.h 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/libtux4kidsadmin/studentDir_p.h 2009-08-11 21:25:18 UTC (rev 1415)
@@ -28,7 +28,7 @@
StudentDir::Status status;
QSettings *attributes;
QDir mainDir;
- QList< QPointer<ProfileDir> > profiles;
+ QList<ProfileDir *> profiles;
QList<Class> classes;
};
Modified: tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.cpp 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.cpp 2009-08-11 21:25:18 UTC (rev 1415)
@@ -36,3 +36,9 @@
ProfileDirTuxmath::~ProfileDirTuxmath()
{
}
+
+TuxmathOptions *ProfileDirTuxmath::tuxmathOptions()
+{
+ Q_D(ProfileDirTuxmath);
+ return d->tuxmathOptions;
+}
Modified: tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.h 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.h 2009-08-11 21:25:18 UTC (rev 1415)
@@ -5,6 +5,7 @@
#include "libtux4kidsadmin_tuxmath_global.h"
class ProfileDirTuxmathPrivate;
+class TuxmathOptions;
class LIBTUX4KIDSADMIN_TUXMATH_SHARED_EXPORT ProfileDirTuxmath : public ProfileDir
{
@@ -12,6 +13,9 @@
public:
ProfileDirTuxmath(QString path, QObject *parent = 0);
~ProfileDirTuxmath();
+
+ TuxmathOptions *tuxmathOptions();
+
protected:
ProfileDirTuxmath(ProfileDirTuxmathPrivate &dd, QObject *parent);
Modified: tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/tuxmathOptions.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/tuxmathOptions.cpp 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/tuxmathOptions.cpp 2009-08-11 21:25:18 UTC (rev 1415)
@@ -33,8 +33,10 @@
if (!line.startsWith("#") && !line.isEmpty()) {
line = line.simplified();
QStringList fields = line.split("=", QString::SkipEmptyParts);
- fields[0] = fields[0].simplified();
- linePos[fields[0]] = lines.size();
+ if (fields.size() == 2) {
+ fields[0] = fields[0].simplified();
+ linePos[fields[0]] = lines.size();
+ }
//qDebug() << "found" << fields[0] << fields[1];
}
lines.append(line);
Modified: tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/tuxmathOptions.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/tuxmathOptions.h 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/tuxmathOptions.h 2009-08-11 21:25:18 UTC (rev 1415)
@@ -19,7 +19,7 @@
void setSubstractionAllowed(bool allow);
protected:
- TuxmathOptionsPrivate *d_ptr;
+ TuxmathOptionsPrivate * const d_ptr;
TuxmathOptions(TuxmathOptionsPrivate &dd);
private:
Modified: tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/CMakeLists.txt
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/CMakeLists.txt 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/CMakeLists.txt 2009-08-11 21:25:18 UTC (rev 1415)
@@ -10,14 +10,17 @@
SET(TUXMATH_PLUGIN_MOC_HEADERS
tuxmathPlugin.h
- tuxmathMainWidget.h )
+ tuxmathMainWidget.h
+ editTuxmathOptions.h )
SET(TUXMATH_PLUGIN_SOURCES
tuxmathPlugin.cpp
- tuxmathMainWidget.cpp )
+ tuxmathMainWidget.cpp
+ editTuxmathOptions.cpp )
SET(TUXMATH_PLUGIN_UIS
- tuxmathMainWidget.ui )
+ tuxmathMainWidget.ui
+ editTuxmathOptions.ui )
FIND_PACKAGE( Qt4 REQUIRED )
INCLUDE( ${QT_USE_FILE} )
Modified: tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/editTuxmathOptions.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/editTuxmathOptions.cpp 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/editTuxmathOptions.cpp 2009-08-11 21:25:18 UTC (rev 1415)
@@ -1,14 +1,30 @@
#include "editTuxmathOptions.h"
#include "ui_editTuxmathOptions.h"
+#include <QPushButton>
+
EditTuxmathOptions::EditTuxmathOptions(QWidget *parent) :
- QDialog(parent),
- m_ui(new Ui::EditTuxmathOptions)
+ QDialog(parent),
+ m_ui(new Ui::EditTuxmathOptions)
{
- m_ui->setupUi(this);
+ m_ui->setupUi(this);
+
+ connect(m_ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));
+ connect(m_ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
}
EditTuxmathOptions::~EditTuxmathOptions()
{
- delete m_ui;
+ delete m_ui;
}
+
+bool EditTuxmathOptions::allowAddition() const
+{
+ return m_ui->includeAddition->isChecked();
+}
+
+bool EditTuxmathOptions::allowSubstraction() const
+{
+ return m_ui->includeSubstraction->isChecked();
+}
+
Modified: tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/editTuxmathOptions.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/editTuxmathOptions.h 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/editTuxmathOptions.h 2009-08-11 21:25:18 UTC (rev 1415)
@@ -1,18 +1,22 @@
#ifndef EDITTUXMATHOPTIONS_H
-a#define EDITTUXMATHOPTIONS_H
+#define EDITTUXMATHOPTIONS_H
#include <QtGui/QDialog>
- namespace Ui {
+namespace Ui {
class EditTuxmathOptions;
}
-class EditTuxmathOptions : public QDialog {
+class EditTuxmathOptions : public QDialog
+{
Q_OBJECT
public:
EditTuxmathOptions(QWidget *parent = 0);
~EditTuxmathOptions();
+ bool allowAddition() const;
+ bool allowSubstraction() const;
+
private:
Ui::EditTuxmathOptions *m_ui;
};
Modified: tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/editTuxmathOptions.ui
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/editTuxmathOptions.ui 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/editTuxmathOptions.ui 2009-08-11 21:25:18 UTC (rev 1415)
@@ -1,7 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<class>EditTuxmathOptions</class>
- <widget class="QDialog" name="EditTuxmathOptions" >
- <property name="geometry" >
+ <widget class="QDialog" name="EditTuxmathOptions">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@@ -9,9 +10,49 @@
<height>300</height>
</rect>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string>Dialog</string>
</property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QCheckBox" name="includeAddition">
+ <property name="text">
+ <string>Include addition</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="includeSubstraction">
+ <property name="text">
+ <string>Include substraction</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
<resources/>
<connections/>
Modified: tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/tuxmathMainWidget.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/tuxmathMainWidget.cpp 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/tuxmathMainWidget.cpp 2009-08-11 21:25:18 UTC (rev 1415)
@@ -3,7 +3,14 @@
#include "schoolData.h"
#include "selectStudentWidget.h"
+#include "editTuxmathOptions.h"
+#include "profileDir.h"
+#include "studentDir.h"
+#include "profileDirTuxmath.h"
+#include "tuxmathOptions.h"
+#include <QDebug>
+
TuxmathMainWidget::TuxmathMainWidget(SchoolData *schoolData, QWidget *parent) :
QWidget(parent),
m_ui(new Ui::TuxmathMainWidget)
@@ -15,9 +22,30 @@
m_selectStudentWidget = new SelectStudentWidget(this);
m_ui->verticalLayout->insertWidget(0, m_selectStudentWidget);
m_selectStudentWidget->setStudentTableModel(&m_studentTableModel);
+
+ connect(m_ui->setOptionsButton, SIGNAL(clicked()), this, SLOT(setOptionsClicked()));
}
TuxmathMainWidget::~TuxmathMainWidget()
{
delete m_ui;
}
+
+void TuxmathMainWidget::setOptionsClicked()
+{
+ EditTuxmathOptions editDialog;
+ editDialog.exec();
+ if (editDialog.result() == QDialog::Accepted) {
+ QList<StudentDir *> students = m_studentTableModel.selectedStudents();
+ foreach (StudentDir *student, students) {
+ foreach (ProfileDir *profile, student->profiles()) {
+ ProfileDirTuxmath *profileTm = qobject_cast<ProfileDirTuxmath *>(profile);
+ if (profileTm != 0) {
+ profileTm->tuxmathOptions()->setAdditionAllowed(editDialog.allowAddition());
+ profileTm->tuxmathOptions()->setSubstractionAllowed(editDialog.allowSubstraction());
+ }
+ }
+ }
+ }
+}
+
Modified: tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/tuxmathMainWidget.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/tuxmathMainWidget.h 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/tux4kids-admin/plugins/tuxmathPlugin/tuxmathMainWidget.h 2009-08-11 21:25:18 UTC (rev 1415)
@@ -25,6 +25,9 @@
StudentTableModel m_studentTableModel;
QPointer<SelectStudentWidget> m_selectStudentWidget;
+private slots:
+ void setOptionsClicked();
+
};
#endif // TUXMATHMAINWIDGET_H
Modified: tux4kids-admin/trunk/tux4kids-admin/src/mainWindow.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/mainWindow.cpp 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/tux4kids-admin/src/mainWindow.cpp 2009-08-11 21:25:18 UTC (rev 1415)
@@ -21,7 +21,6 @@
foreach (QPluginLoader *pluginLoader, m_mainController->pluginManager()->plugins()) {
PluginInterface *plugin = qobject_cast<PluginInterface *>(pluginLoader->instance());
if (plugin != 0) {
- qDebug() << "AAA" << plugin->name();
QWidget *widget = plugin->mainWidget();
if (widget != 0) {
m_ui->tabWidget->insertTab(3, widget, plugin->name());
Modified: tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.cpp 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.cpp 2009-08-11 21:25:18 UTC (rev 1415)
@@ -131,6 +131,17 @@
return result;
}
+QList<StudentDir *> StudentTableModel::selectedStudents() const
+{
+ QList<StudentDir *> result;
+ for(int i = 0; i < m_studentsSelection.size(); i++) {
+ if (m_studentsSelection.at(i)) {
+ result.append(m_students.at(i));
+ }
+ }
+ return result;
+}
+
void StudentTableModel::setSelectedStudents(const QStringList &selectedStudentsDirNames)
{
for (int i = 0; i < m_students.size(); ++i) {
Modified: tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h 2009-08-11 19:40:43 UTC (rev 1414)
+++ tux4kids-admin/trunk/tux4kids-admin/src/studentTableModel.h 2009-08-11 21:25:18 UTC (rev 1415)
@@ -23,6 +23,7 @@
Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
QStringList selectedStudentsDirNames() const;
+ QList<StudentDir *> selectedStudents() const;
void setSelectedStudents(const QStringList &selectedStudentsDirNames);
void clearSelection();
More information about the Tux4kids-commits
mailing list