[Tux4kids-commits] r1196 - in tux4kids-admin/trunk: libtux4kidsadmin libtux4kidsadmin_tuxmath
Michał Świtakowski
swistakers-guest at alioth.debian.org
Mon Jul 13 21:31:08 UTC 2009
Author: swistakers-guest
Date: 2009-07-13 21:31:07 +0000 (Mon, 13 Jul 2009)
New Revision: 1196
Added:
tux4kids-admin/trunk/libtux4kidsadmin/profileDirPrivate_p.h
tux4kids-admin/trunk/libtux4kidsadmin/schoolData.cpp
tux4kids-admin/trunk/libtux4kidsadmin/schoolData.h
tux4kids-admin/trunk/libtux4kidsadmin/schoolDataPrivate.cpp
tux4kids-admin/trunk/libtux4kidsadmin/schoolDataPrivate_p.h
tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmathPrivate_p.h
Removed:
tux4kids-admin/trunk/libtux4kidsadmin/profileDirPrivate.h
tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmathPrivate.h
Modified:
tux4kids-admin/trunk/libtux4kidsadmin/CMakeLists.txt
tux4kids-admin/trunk/libtux4kidsadmin/libtux4kidsadmin.pro
tux4kids-admin/trunk/libtux4kidsadmin/profileDir.cpp
tux4kids-admin/trunk/libtux4kidsadmin/profileDir.h
tux4kids-admin/trunk/libtux4kidsadmin/profileDirPrivate.cpp
tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/libtux4kidsadmin_tuxmath.pro
tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.cpp
tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.h
tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmathPrivate.cpp
Log:
d-pointer pattern using Qt macros + schoolData class
Modified: tux4kids-admin/trunk/libtux4kidsadmin/CMakeLists.txt
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/CMakeLists.txt 2009-07-13 18:31:04 UTC (rev 1195)
+++ tux4kids-admin/trunk/libtux4kidsadmin/CMakeLists.txt 2009-07-13 21:31:07 UTC (rev 1196)
@@ -4,10 +4,12 @@
SET(LIBTUX4KIDSADMIN_SOURCES
libtux4kidsadmin.cpp
profileDir.cpp
- profileDirPrivate.cpp )
+ profileDirPrivate.cpp
+ schoolData.cpp )
SET(LIBTUX4KIDSADMIN_MOC_HEADERS
- profileDir.h )
+ profileDir.h
+ schoolData.h )
# enable warnings
ADD_DEFINITIONS( -Wall -DLIBTUX4KIDSADMIN_LIBRARY )
Modified: tux4kids-admin/trunk/libtux4kidsadmin/libtux4kidsadmin.pro
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/libtux4kidsadmin.pro 2009-07-13 18:31:04 UTC (rev 1195)
+++ tux4kids-admin/trunk/libtux4kidsadmin/libtux4kidsadmin.pro 2009-07-13 21:31:07 UTC (rev 1196)
@@ -4,8 +4,12 @@
DEFINES += LIBTUX4KIDSADMIN_LIBRARY
SOURCES += libtux4kidsadmin.cpp \
profileDir.cpp \
- profileDirPrivate.cpp
+ profileDirPrivate.cpp \
+ schoolData.cpp \
+ schoolDataPrivate.cpp
HEADERS += libtux4kidsadmin.h \
libtux4kidsadmin_global.h \
profileDir.h \
- profileDirPrivate.h
+ profileDirPrivate_p.h \
+ schoolData.h \
+ schoolDataPrivate_p.h
Modified: tux4kids-admin/trunk/libtux4kidsadmin/profileDir.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/profileDir.cpp 2009-07-13 18:31:04 UTC (rev 1195)
+++ tux4kids-admin/trunk/libtux4kidsadmin/profileDir.cpp 2009-07-13 21:31:07 UTC (rev 1196)
@@ -1,13 +1,27 @@
#include "profileDir.h"
-#include "profileDirPrivate.h"
+#include "profileDirPrivate_p.h"
-ProfileDir::ProfileDir()
+ProfileDir::ProfileDir(QString path, QObject *parent) :
+ QObject(parent), d_ptr(new ProfileDirPrivate(path))
{
- d = new ProfileDirPrivate();
+ Q_D(ProfileDir);
+ d->q_ptr = this;
}
+ProfileDir::ProfileDir(ProfileDirPrivate &dd, QObject *parent)
+ : QObject(parent), d_ptr(&dd)
+{
+}
+
ProfileDir::~ProfileDir()
{
+ Q_D(ProfileDir);
delete d;
}
+ProfileDir::Status ProfileDir::status() const
+{
+ Q_D(const ProfileDir);
+ return d->status;
+}
+
Modified: tux4kids-admin/trunk/libtux4kidsadmin/profileDir.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/profileDir.h 2009-07-13 18:31:04 UTC (rev 1195)
+++ tux4kids-admin/trunk/libtux4kidsadmin/profileDir.h 2009-07-13 21:31:07 UTC (rev 1196)
@@ -2,17 +2,32 @@
#define PROFILEDIR_H
#include <QObject>
+#include "libtux4kidsadmin_global.h"
class ProfileDirPrivate;
-class ProfileDir : public QObject
+class LIBTUX4KIDSADMINSHARED_EXPORT ProfileDir : public QObject
{
Q_OBJECT
+
public:
- ProfileDir();
+ ProfileDir(QString path, QObject *parent = 0);
~ProfileDir();
+
+ enum Status {
+ NoError = 0,
+ InitializationError = 1
+ };
+
+ Status status() const;
+
+protected:
+ ProfileDirPrivate * const d_ptr;
+ ProfileDir(ProfileDirPrivate &dd, QObject *parent = 0);
+
private:
- ProfileDirPrivate *d;
+ Q_DECLARE_PRIVATE(ProfileDir)
+ Q_DISABLE_COPY(ProfileDir)
};
#endif // PROFILEDIR_H
Modified: tux4kids-admin/trunk/libtux4kidsadmin/profileDirPrivate.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/profileDirPrivate.cpp 2009-07-13 18:31:04 UTC (rev 1195)
+++ tux4kids-admin/trunk/libtux4kidsadmin/profileDirPrivate.cpp 2009-07-13 21:31:07 UTC (rev 1196)
@@ -1,5 +1,34 @@
-#include "profileDirPrivate.h"
+#include "profileDirPrivate_p.h"
-ProfileDirPrivate::ProfileDirPrivate()
+#include <QString>
+
+ProfileDirPrivate::ProfileDirPrivate(QString path)
{
+ mainDir.setPath(path);
+ if (!mainDir.exists()) {
+ if (!QDir::root().mkpath(path)) {
+ status = ProfileDir::InitializationError;
+ return;
+ }
+ }
+ mainDir.setPath(path);
+
+ if (!mainDir.mkdir("data")) {
+ status = ProfileDir::InitializationError;
+ return;
+ }
+ dataDir = QDir(mainDir.absolutePath() + "/data");
+
+ attributes = new QSettings(path + "/attributes.ini", QSettings::IniFormat);
+ if (!attributes->status() != QSettings::NoError) {
+ status = ProfileDir::InitializationError;
+ return;
+ }
+
}
+
+ProfileDirPrivate::~ProfileDirPrivate()
+{
+ delete attributes;
+}
+
Deleted: tux4kids-admin/trunk/libtux4kidsadmin/profileDirPrivate.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/profileDirPrivate.h 2009-07-13 18:31:04 UTC (rev 1195)
+++ tux4kids-admin/trunk/libtux4kidsadmin/profileDirPrivate.h 2009-07-13 21:31:07 UTC (rev 1196)
@@ -1,10 +0,0 @@
-#ifndef PROFILEDIRPRIVATE_H
-#define PROFILEDIRPRIVATE_H
-
-class ProfileDirPrivate
-{
-public:
- ProfileDirPrivate();
-};
-
-#endif // PROFILEDIRPRIVATE_H
Copied: tux4kids-admin/trunk/libtux4kidsadmin/profileDirPrivate_p.h (from rev 1185, tux4kids-admin/trunk/libtux4kidsadmin/profileDirPrivate.h)
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/profileDirPrivate_p.h (rev 0)
+++ tux4kids-admin/trunk/libtux4kidsadmin/profileDirPrivate_p.h 2009-07-13 21:31:07 UTC (rev 1196)
@@ -0,0 +1,26 @@
+#ifndef PROFILEDIRPRIVATE_H
+#define PROFILEDIRPRIVATE_H
+
+#include <QtGlobal>
+#include <QDir>
+#include <QSettings>
+#include "profileDir.h"
+
+class QString;
+
+class ProfileDirPrivate
+{
+public:
+ Q_DECLARE_PUBLIC(ProfileDir)
+
+ ProfileDirPrivate(QString path);
+ virtual ~ProfileDirPrivate();
+
+ ProfileDir *q_ptr;
+
+ ProfileDir::Status status;
+ QSettings *attributes;
+ QDir mainDir, dataDir;
+};
+
+#endif // PROFILEDIRPRIVATE_H
Added: tux4kids-admin/trunk/libtux4kidsadmin/schoolData.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/schoolData.cpp (rev 0)
+++ tux4kids-admin/trunk/libtux4kidsadmin/schoolData.cpp 2009-07-13 21:31:07 UTC (rev 1196)
@@ -0,0 +1,33 @@
+#include "schoolData.h"
+#include "schoolDataPrivate_p.h"
+
+SchoolData::SchoolData(QString path, QObject *parent)
+ : QObject(parent), d_ptr(new SchoolDataPrivate(path))
+{
+ Q_D(SchoolData);
+ d->q_ptr = this;
+}
+
+SchoolData::~SchoolData()
+{
+ Q_D(SchoolData);
+ delete d;
+}
+
+SchoolData::Status SchoolData::status() const
+{
+ Q_D(const SchoolData);
+ return d->status;
+}
+
+QString SchoolData::nextProfileDir() const
+{
+ Q_D(const SchoolData);
+ QString baseName = "profile_";
+ int number = 1;
+ while(!d->mainDir.exists(baseName + QString::number(number)))
+ ++number;
+
+ return baseName + QString::number(number);
+}
+
Added: tux4kids-admin/trunk/libtux4kidsadmin/schoolData.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/schoolData.h (rev 0)
+++ tux4kids-admin/trunk/libtux4kidsadmin/schoolData.h 2009-07-13 21:31:07 UTC (rev 1196)
@@ -0,0 +1,33 @@
+#ifndef SCHOOLDATA_H
+#define SCHOOLDATA_H
+
+#include <QObject>
+
+class QString;
+class SchoolDataPrivate;
+
+class SchoolData : public QObject
+{
+ Q_OBJECT
+public:
+ SchoolData(QString path, QObject *parent = 0);
+ ~SchoolData();
+
+ enum Status {
+ NoError = 0,
+ InitializationError = 1
+ };
+
+ Status status() const;
+ QString nextProfileDir() const;
+
+protected:
+ SchoolDataPrivate * const d_ptr;
+ SchoolData(SchoolDataPrivate &dd, QObject *parent = 0);
+
+private:
+ Q_DECLARE_PRIVATE(SchoolData)
+ Q_DISABLE_COPY(SchoolData)
+};
+
+#endif // SCHOOLDATA_H
Added: tux4kids-admin/trunk/libtux4kidsadmin/schoolDataPrivate.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/schoolDataPrivate.cpp (rev 0)
+++ tux4kids-admin/trunk/libtux4kidsadmin/schoolDataPrivate.cpp 2009-07-13 21:31:07 UTC (rev 1196)
@@ -0,0 +1,21 @@
+#include "schoolDataPrivate_p.h"
+
+#include <QString>
+
+SchoolDataPrivate::SchoolDataPrivate(QString path)
+{
+ mainDir.setPath(path);
+ if (!mainDir.exists()) {
+ if (!QDir::root().mkpath(path)) {
+ status = SchoolData::InitializationError;
+ }
+ }
+ mainDir.setPath(path);
+}
+
+
+
+SchoolDataPrivate::~SchoolDataPrivate()
+{
+}
+
Added: tux4kids-admin/trunk/libtux4kidsadmin/schoolDataPrivate_p.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin/schoolDataPrivate_p.h (rev 0)
+++ tux4kids-admin/trunk/libtux4kidsadmin/schoolDataPrivate_p.h 2009-07-13 21:31:07 UTC (rev 1196)
@@ -0,0 +1,24 @@
+#ifndef SCHOOLDATAPRIVATE_P_H
+#define SCHOOLDATAPRIVATE_P_H
+
+#include <QtGlobal>
+#include <QDir>
+#include "schoolData.h"
+class QString;
+
+class SchoolDataPrivate
+{
+public:
+ Q_DECLARE_PUBLIC(SchoolData)
+
+ SchoolDataPrivate(QString path);
+ virtual ~SchoolDataPrivate();
+
+ SchoolData *q_ptr;
+
+ QDir mainDir;
+
+ SchoolData::Status status;
+};
+
+#endif // SCHOOLDATAPRIVATE_P_H
Modified: tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/libtux4kidsadmin_tuxmath.pro
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/libtux4kidsadmin_tuxmath.pro 2009-07-13 18:31:04 UTC (rev 1195)
+++ tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/libtux4kidsadmin_tuxmath.pro 2009-07-13 21:31:07 UTC (rev 1196)
@@ -7,7 +7,7 @@
profileDirTuxmath.cpp
HEADERS += libtux4kidsadmin_tuxmath.h \
libtux4kidsadmin_tuxmath_global.h \
- profileDirTuxmathPrivate.h \
+ profileDirTuxmathPrivate_p.h \
profileDirTuxmath.h
INCLUDEPATH += ../libtux4kidsadmin
LIBS += -ltux4kidsadmin \
Modified: tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.cpp 2009-07-13 18:31:04 UTC (rev 1195)
+++ tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.cpp 2009-07-13 21:31:07 UTC (rev 1196)
@@ -1,11 +1,18 @@
#include "profileDirTuxmath.h"
-ProfileDirTuxmath::ProfileDirTuxmath()
+#include "profileDirTuxmathPrivate_p.h"
+
+
+ProfileDirTuxmath::ProfileDirTuxmath(QString path, QObject *parent)
+ : ProfileDir(*new ProfileDirTuxmathPrivate(path), parent)
{
- d = new ProfileDirTuxmathPrivate();
}
+ProfileDirTuxmath::ProfileDirTuxmath(ProfileDirTuxmathPrivate &dd, QObject *parent)
+ : ProfileDir(dd, parent)
+{
+}
+
ProfileDirTuxmath::~ProfileDirTuxmath()
{
- delete d;
}
Modified: tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.h 2009-07-13 18:31:04 UTC (rev 1195)
+++ tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmath.h 2009-07-13 21:31:07 UTC (rev 1196)
@@ -2,16 +2,22 @@
#define PROFILEDIRTUXMATH_H
#include "profileDir.h"
-#include "profileDirTuxmathPrivate.h"
+#include "libtux4kidsadmin_tuxmath_global.h"
-class ProfileDirTuxmath : public ProfileDir
+class ProfileDirTuxmathPrivate;
+
+class LIBTUX4KIDSADMIN_TUXMATHSHARED_EXPORT ProfileDirTuxmath : public ProfileDir
{
Q_OBJECT
public:
- ProfileDirTuxmath();
+ ProfileDirTuxmath(QString path, QObject *parent = 0);
~ProfileDirTuxmath();
+protected:
+ ProfileDirTuxmath(ProfileDirTuxmathPrivate &dd, QObject *parent);
+
private:
- ProfileDirTuxmathPrivate *d;
+ Q_DECLARE_PRIVATE(ProfileDirTuxmath)
+ Q_DISABLE_COPY(ProfileDirTuxmath)
};
#endif // PROFILEDIRTUXMATH_H
Modified: tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmathPrivate.cpp
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmathPrivate.cpp 2009-07-13 18:31:04 UTC (rev 1195)
+++ tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmathPrivate.cpp 2009-07-13 21:31:07 UTC (rev 1196)
@@ -1,5 +1,13 @@
-#include "profileDirTuxmathPrivate.h"
+#include "profileDirTuxmathPrivate_p.h"
-ProfileDirTuxmathPrivate::ProfileDirTuxmathPrivate()
+#include <QString>
+
+ProfileDirTuxmathPrivate::ProfileDirTuxmathPrivate(QString path)
+ : ProfileDirPrivate(path)
{
}
+
+ProfileDirTuxmathPrivate::~ProfileDirTuxmathPrivate()
+{
+}
+
Deleted: tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmathPrivate.h
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmathPrivate.h 2009-07-13 18:31:04 UTC (rev 1195)
+++ tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmathPrivate.h 2009-07-13 21:31:07 UTC (rev 1196)
@@ -1,12 +0,0 @@
-#ifndef PROFILEDIRTUXMATHPRIVATE_H
-#define PROFILEDIRTUXMATHPRIVATE_H
-
-#include "profileDirPrivate.h"
-
-class ProfileDirTuxmathPrivate : public ProfileDirPrivate
-{
-public:
- ProfileDirTuxmathPrivate();
-};
-
-#endif // PROFILEDIRTUXMATHPRIVATE_H
Copied: tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmathPrivate_p.h (from rev 1185, tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmathPrivate.h)
===================================================================
--- tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmathPrivate_p.h (rev 0)
+++ tux4kids-admin/trunk/libtux4kidsadmin_tuxmath/profileDirTuxmathPrivate_p.h 2009-07-13 21:31:07 UTC (rev 1196)
@@ -0,0 +1,15 @@
+#ifndef PROFILEDIRTUXMATHPRIVATE_H
+#define PROFILEDIRTUXMATHPRIVATE_H
+
+#include "profileDirPrivate_p.h"
+
+class ProfileDirTuxmathPrivate : public ProfileDirPrivate
+{
+public:
+ Q_DECLARE_PUBLIC(ProfileDir)
+
+ ProfileDirTuxmathPrivate(QString path);
+ virtual ~ProfileDirTuxmathPrivate();
+};
+
+#endif // PROFILEDIRTUXMATHPRIVATE_H
More information about the Tux4kids-commits
mailing list