Creating initial application directory structure.
authorkomarma <komarma@localhost>
Mon, 28 Dec 2009 14:38:15 +0000 (14:38 +0000)
committerkomarma <komarma@localhost>
Mon, 28 Dec 2009 14:38:15 +0000 (14:38 +0000)
13 files changed:
src/app/app.pro [new file with mode: 0644]
src/app/main.cpp [new file with mode: 0644]
src/fosdem.pro [new file with mode: 0644]
src/gui/gui.pro [new file with mode: 0644]
src/gui/mainwindow.cpp [new file with mode: 0644]
src/gui/mainwindow.h [new file with mode: 0644]
src/model/event.cpp [new file with mode: 0644]
src/model/event.h [new file with mode: 0644]
src/model/model.pro [new file with mode: 0644]
src/test/main.cpp [new file with mode: 0644]
src/test/model/eventtest.cpp [new file with mode: 0644]
src/test/model/eventtest.h [new file with mode: 0644]
src/test/test.pro [new file with mode: 0644]

diff --git a/src/app/app.pro b/src/app/app.pro
new file mode 100644 (file)
index 0000000..258c0a6
--- /dev/null
@@ -0,0 +1,12 @@
+TEMPLATE = app
+TARGET = fosdem
+DESTDIR = ../bin
+
+# module dependencies
+LIBS += -L$$DESTDIR -lgui -lmodel
+INCLUDEPATH += ../gui
+DEPENDPATH += . ../gui
+TARGETDEPS += $$DESTDIR/libmodel.a $$DESTDIR/libgui.a
+
+SOURCES += main.cpp
+
diff --git a/src/app/main.cpp b/src/app/main.cpp
new file mode 100644 (file)
index 0000000..cc63c67
--- /dev/null
@@ -0,0 +1,12 @@
+#include <mainwindow.h>
+
+#include <QtGui/QApplication>
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+
+    MainWindow w;
+    w.show();
+    return a.exec();
+}
diff --git a/src/fosdem.pro b/src/fosdem.pro
new file mode 100644 (file)
index 0000000..2f6d07c
--- /dev/null
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+SUBDIRS  = model gui app test
+CONFIG += ordered
+
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
new file mode 100644 (file)
index 0000000..0ee1884
--- /dev/null
@@ -0,0 +1,19 @@
+TEMPLATE = lib
+TARGET = gui
+DESTDIR = ../bin
+CONFIG += static
+
+# module dependencies
+LIBS += -L$$DESTDIR -lmodel
+INCLUDEPATH += ../model
+DEPENDPATH += . ../model
+TARGETDEPS += $$DESTDIR/libmodel.a
+
+
+# A shamelessly long list of sources, headers and forms.
+# Please note that resources MUST be added to the app module
+# (which means they need to be added to the test module as well,
+# but I am sure you can live with that for the time being).
+SOURCES += mainwindow.cpp
+HEADERS += mainwindow.h
+
diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp
new file mode 100644 (file)
index 0000000..d1e4fe6
--- /dev/null
@@ -0,0 +1,6 @@
+#include "mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+    : QMainWindow(parent)
+{
+}
diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h
new file mode 100644 (file)
index 0000000..94aa77a
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QtGui/QMainWindow>
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindow(QWidget *parent = 0);
+};
+
+#endif // MAINWINDOW_H
diff --git a/src/model/event.cpp b/src/model/event.cpp
new file mode 100644 (file)
index 0000000..fafbe20
--- /dev/null
@@ -0,0 +1,7 @@
+#include "event.h"
+
+Event Event::getById(int id, int conferenceId)
+{
+    Event newEvent;
+    return newEvent;
+}
diff --git a/src/model/event.h b/src/model/event.h
new file mode 100644 (file)
index 0000000..8a63407
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef EVENT_H
+#define EVENT_H
+
+#include <QDateTime>
+
+class Event
+{
+public:
+    static Event getById(int id, int conferenceId);
+
+public:
+    int id() const { return mId; }
+    int conferenceId() const { return mConferenceId; }
+    QDateTime start() const { return mStart; }
+    int duration() const { return mDuration; }
+    int activityId() const { return mActivityId; }
+    int typeId() const { return mTypeId; }
+    int languageId() const { return mLanguageId; }
+
+private:
+    Event() {}; // private constructor, use static methods to access instances
+
+private:
+    int mId;
+    int mConferenceId;
+    QDateTime mStart;
+    int mDuration;
+    int mActivityId;
+    int mTypeId;
+    int mLanguageId;
+};
+
+#endif // EVENT_H
diff --git a/src/model/model.pro b/src/model/model.pro
new file mode 100644 (file)
index 0000000..4c0e441
--- /dev/null
@@ -0,0 +1,11 @@
+TEMPLATE = lib
+TARGET = model
+DESTDIR = ../bin
+CONFIG += static
+
+# module dependencies
+DEPENDPATH += .
+
+HEADERS += event.h
+SOURCES += event.cpp
+
diff --git a/src/test/main.cpp b/src/test/main.cpp
new file mode 100644 (file)
index 0000000..2cda835
--- /dev/null
@@ -0,0 +1,12 @@
+#include <QtTest>
+
+#include "model/eventtest.h"
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication app(argc, argv);
+
+    EventTest eventTest;
+    QTest::qExec(&eventTest, argc, argv);
+}
+
diff --git a/src/test/model/eventtest.cpp b/src/test/model/eventtest.cpp
new file mode 100644 (file)
index 0000000..793154d
--- /dev/null
@@ -0,0 +1,26 @@
+#include "eventtest.h"
+
+#include <QtTest>
+#include <QSqlDatabase>
+
+#include <event.h>
+
+void EventTest::initTestCase()
+{
+    // Connect to the test database. Ask Mr. Pavelka to generate one for you :)
+    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
+    db.setDatabaseName("fostem-test.sqlite");
+    QVERIFY(db.open());
+}
+
+void EventTest::getById()
+{
+    Event event = Event::getById(500, 1);
+    QCOMPARE(event.id(), 500);
+    QCOMPARE(event.start(), QDateTime::fromString("Sat Feb 7 11:30:00 2009"));
+    QCOMPARE(event.activityId(), 123);
+
+    // !!! TODO: typeId and languageId
+    QCOMPARE(event.typeId(), 0);
+    QCOMPARE(event.languageId(), 0);
+}
diff --git a/src/test/model/eventtest.h b/src/test/model/eventtest.h
new file mode 100644 (file)
index 0000000..b20386f
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef EVENTTEST_H
+#define EVENTTEST_H
+
+#include <QObject>
+
+class EventTest : public QObject
+{
+    Q_OBJECT
+
+private slots:
+    void initTestCase();
+
+    void getById();
+};
+
+
+#endif // EVENTTEST_H
+
diff --git a/src/test/test.pro b/src/test/test.pro
new file mode 100644 (file)
index 0000000..af4e3e9
--- /dev/null
@@ -0,0 +1,18 @@
+TEMPLATE = app
+TARGET = test
+DESTDIR = ../bin
+CONFIG += qtestlib console
+QT += sql
+
+# module dependencies
+LIBS += -L$$DESTDIR -lgui -lmodel
+INCLUDEPATH += ../gui ../model
+DEPENDPATH += . ../gui ../model
+TARGETDEPS += $$DESTDIR/libmodel.a $$DESTDIR/libgui.a
+
+SOURCES += main.cpp \
+    model/EventTest.cpp
+
+HEADERS += \
+    model/EventTest.h
+