]> khamidou — GitHub mirrors - st.git/commitdiff
first commit
authorkhamidou <khamidou@gmail.com>
Tue, 26 Jul 2011 14:59:27 +0000 (16:59 +0200)
committerkhamidou <khamidou@gmail.com>
Tue, 26 Jul 2011 14:59:27 +0000 (16:59 +0200)
README.txt [new file with mode: 0644]
main.cpp [new file with mode: 0644]
mainwindow.cpp [new file with mode: 0644]
mainwindow.h [new file with mode: 0644]
st.pro [new file with mode: 0644]
tasklist.cpp [new file with mode: 0644]
tasklist.h [new file with mode: 0644]

diff --git a/README.txt b/README.txt
new file mode 100644 (file)
index 0000000..fb62714
--- /dev/null
@@ -0,0 +1 @@
+This is the README for st.
diff --git a/main.cpp b/main.cpp
new file mode 100644 (file)
index 0000000..6e7efd9
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,10 @@
+#include <QtGui/QApplication>
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    MainWindow w;
+    w.show();
+    return a.exec();
+}
diff --git a/mainwindow.cpp b/mainwindow.cpp
new file mode 100644 (file)
index 0000000..9716148
--- /dev/null
@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+    : QMainWindow(parent)
+{
+}
+
+MainWindow::~MainWindow()
+{
+
+}
diff --git a/mainwindow.h b/mainwindow.h
new file mode 100644 (file)
index 0000000..dfb47d6
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QtGui>
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindow(QWidget *parent = 0);
+    ~MainWindow();
+
+private:
+    QListView *sessionView;
+};
+
+#endif // MAINWINDOW_H
diff --git a/st.pro b/st.pro
new file mode 100644 (file)
index 0000000..0ef79c2
--- /dev/null
+++ b/st.pro
@@ -0,0 +1,13 @@
+# -------------------------------------------------
+# Project created by QtCreator 2011-07-26T16:09:06
+# -------------------------------------------------
+QT += xml \
+    xmlpatterns
+TARGET = st
+TEMPLATE = app
+SOURCES += main.cpp \
+    mainwindow.cpp \
+    tasklist.cpp
+HEADERS += mainwindow.h \
+    tasklist.h
+OTHER_FILES += README.txt
diff --git a/tasklist.cpp b/tasklist.cpp
new file mode 100644 (file)
index 0000000..1361f90
--- /dev/null
@@ -0,0 +1,45 @@
+#include "tasklist.h"
+
+Task::Task(QDomElement &root)
+{
+    QDomElement titleElement = root.firstChildElement("title");
+    _title = titleElement.text();
+
+    QDomElement length = titleElement.nextSibling();
+    QDomElement hours = length.firstChild("hours");    
+
+    int hour = hours.text().toInt();
+
+    QDomElement minutes = hours.nextSibling();
+
+    int minute = minutes.text().toInt();
+
+    _taskLength = QTime(hour, minute, 0);
+
+    /* Fixme : implement remaining */
+}
+
+TaskList::TaskList()
+{
+}
+
+QVariant TaskList::data ( const QModelIndex & index, int role) const
+{
+    /*
+    if (!index.isValid())
+        return QVariant();
+    if (index.row() >= machineList.size() || index.row() < 0)
+        return QVariant();
+
+    if (role == Qt::DisplayRole)
+    return machineList.at(index.row());
+
+    return QVariant();
+    */
+    return QVariant();
+}
+
+int TaskList::rowCount (const QModelIndex & parent) const
+{
+    return 2;
+}
diff --git a/tasklist.h b/tasklist.h
new file mode 100644 (file)
index 0000000..784ae41
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef TASKLIST_H
+#define TASKLIST_H
+
+#include <QtCore>
+#include <QtXml>
+#include <QAbstractListModel>
+
+class Task
+{
+    /** this class models a task, which is a portion of a session */
+    Q_OBJECT
+    QString _title;
+    QTime _taskLength;
+    QTime _timeRemaining;
+
+public:
+    Task(QString title, QTime taskLength) : _title(title), _taskLength(taskLength), _timeRemaining() { };
+    Task(QDomElement& root);
+    QString title(void) { return _title; };
+    QTime taskLength(void) { return _taskLength; }
+
+};
+
+class TaskList : QAbstractListModel
+{
+    /**        TaskList is our model class. It loads and saves tasks from an xml file.
+               Format of the xml file :
+               <session>
+                   <task>
+                       <title>Task 1</title>
+                       <length>
+                           <hours>3</hours>
+                           <minutes>5</minutes>
+                       </length>
+                       <elasped>
+                           <hours>3</hours>
+                           <minutes>5</minutes>
+                       </elapsed>
+                   </task>
+                   <task>
+                       ...
+               </session>
+ */
+
+public:
+    TaskList();
+    TaskList(QFile& f);
+    QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
+    int rowCount (const QModelIndex & parent = QModelIndex() ) const;
+
+};
+
+#endif // TASKLIST_H