From: khamidou Date: Tue, 26 Jul 2011 14:59:27 +0000 (+0200) Subject: first commit X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=8349e88276233de8a61fa23a4525171a939deb00;p=st.git first commit --- 8349e88276233de8a61fa23a4525171a939deb00 diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..fb62714 --- /dev/null +++ b/README.txt @@ -0,0 +1 @@ +This is the README for st. diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..6e7efd9 --- /dev/null +++ b/main.cpp @@ -0,0 +1,10 @@ +#include +#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 index 0000000..9716148 --- /dev/null +++ b/mainwindow.cpp @@ -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 index 0000000..dfb47d6 --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,18 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +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 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 index 0000000..1361f90 --- /dev/null +++ b/tasklist.cpp @@ -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 index 0000000..784ae41 --- /dev/null +++ b/tasklist.h @@ -0,0 +1,53 @@ +#ifndef TASKLIST_H +#define TASKLIST_H + +#include +#include +#include + +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 : + + + Task 1 + + 3 + 5 + + + 3 + 5 + + + + ... + + */ + +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