--- /dev/null
+This is the README for Task Tracker (tt).
--- /dev/null
+#include <QtGui/QApplication>
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+ return a.exec();
+}
--- /dev/null
+#include "mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent)
+{
+ //tab = new TabView(this);
+ tabWidget = new QTabWidget(this);
+ setWindowTitle(tr("Task Tracker"));
+ setMinimumSize(640, 480);
+
+ table = new TaskModel();
+ tableView = new QTableView();
+ QPushButton *button = new QPushButton("yop");
+
+ tabWidget->addTab(tableView, tr("Tasks"));
+ tabWidget->addTab(button, tr("Stats"));
+
+
+ tableView->setModel(table);
+ tableView->setItemDelegate(new TableDelegate());
+
+ tableView->resizeColumnsToContents();
+ tableView->adjustSize();
+ tableView->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);
+ tableView->horizontalHeader()->setStretchLastSection(true);
+
+ //tableView->setIndexWidget();
+ setCentralWidget(tabWidget);
+
+
+}
+
+MainWindow::~MainWindow()
+{
+
+}
--- /dev/null
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QHBoxLayout>
+#include <QTableView>
+#include <QHeaderView>
+#include <QTabWidget>
+#include <QPushButton>
+#include "taskmodel.h"
+#include "tabledelegate.h"
+
+namespace Ui {
+ class MainWindow;
+}
+
+class MainWindow : public QMainWindow {
+ Q_OBJECT
+public:
+ MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+private:
+ Ui::MainWindow *ui;
+ QTabWidget *tabWidget;
+ TaskModel *table;
+ QTableView *tableView;
+};
+
+#endif // MAINWINDOW_H
--- /dev/null
+#include "tabledelegate.h"
+#include <iostream>
+
+TableDelegate::TableDelegate(QWidget *parent) :
+ QStyledItemDelegate(parent)
+{
+ map = new QSignalMapper(this);
+}
+
+QWidget *TableDelegate::createEditor(QWidget *parent,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
+
+{
+ std::cout << index.column();
+ if (index.column() == 2) {
+ QComboBox *lWidget = new QComboBox(parent);
+ lWidget->addItem("lololol");
+ lWidget->addItem("jkj");
+ lWidget->addItem("lodslolol");
+ lWidget->addItem("dflol");
+
+
+ connect(lWidget, SIGNAL(editingFinished()),
+ this, SLOT(commitAndCloseEditor()));
+
+ return lWidget;
+ } else {
+ return QStyledItemDelegate::createEditor(parent, option, index);
+ }
+}
+
+/* FIXME: rendre propre
+void TableDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
+{
+
+}
+*/
+
+QSize TableDelegate::sizeHint(const QStyleOptionViewItem &option,
+ const QModelIndex &index) const { }
+
+void TableDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {}
+void TableDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
+ const QModelIndex &index) const { }
+
+void TableDelegate::commitAndCloseEditor() { }
--- /dev/null
+#ifndef TABLEDELEGATE_H
+#define TABLEDELEGATE_H
+
+#include <QObject>
+#include <QStyledItemDelegate>
+#include <QComboBox>
+#include <QSignalMapper>
+
+
+class TableDelegate : public QStyledItemDelegate
+{
+ Q_OBJECT
+
+ public:
+ TableDelegate(QWidget *parent = 0);
+
+ /* void paint(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const; */
+ QSize sizeHint(const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+ QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+ void setEditorData(QWidget *editor, const QModelIndex &index) const;
+ void setModelData(QWidget *editor, QAbstractItemModel *model,
+ const QModelIndex &index) const;
+
+ private slots:
+ void commitAndCloseEditor();
+
+ private:
+ QSignalMapper *map; /* On en a besoin pour les boutons et les combobox */
+ };
+
+#endif // TABLEDELEGATE_H
--- /dev/null
+#include "taskmodel.h"
+
+TaskModel::TaskModel(QObject *parent) : QAbstractTableModel(parent)
+{
+
+}
+
+QVariant TaskModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (index.row() >= 4 || index.row() < 0)
+ return QVariant();
+
+ if (role == Qt::DisplayRole) {
+ if (index.column() == 0)
+ return tr("gerard");
+ else if (index.column() == 1)
+ return tr("ho");
+ else if (index.column() == 2)
+ return tr("paf");
+ else if (index.column() == 3)
+ return tr("paf");
+ }
+ return QVariant();
+}
+
+QVariant TaskModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (orientation == Qt::Horizontal) {
+ switch (section) {
+ case 0:
+ return tr("Task");
+
+ case 1:
+ return tr("Total time spent on this task");
+
+ case 2:
+ return tr("Start counting");
+
+ case 3:
+ return tr("Category");
+
+
+ default:
+ return QVariant();
+ }
+ }
+ return QVariant();
+}
--- /dev/null
+#ifndef TASKMODEL_H
+#define TASKMODEL_H
+
+#include <QAbstractTableModel>
+
+class TaskModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ TaskModel(QObject *parent=0);
+
+ int rowCount(const QModelIndex &parent) const { return 2; };
+ int columnCount(const QModelIndex &parent) const { return 4; };
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const {
+ if (!index.isValid())
+ return Qt::ItemIsEnabled;
+
+ return QAbstractTableModel::flags(index) | Qt::ItemIsEditable; };
+
+ bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) { return false; };
+ bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex()) { return false; };
+ bool removeRows(int position, int rows, const QModelIndex &index=QModelIndex()) {return false; };
+
+private:
+ QList< QPair<QString, QString> > listOfPairs;
+};
+
+#endif // TASKMODEL_H
--- /dev/null
+# -------------------------------------------------
+# Project created by QtCreator 2011-06-25T14:16:34
+# -------------------------------------------------
+QT += network \
+ xml
+TARGET = tt
+TEMPLATE = app
+SOURCES += main.cpp \
+ mainwindow.cpp \
+ taskmodel.cpp \
+ tabledelegate.cpp
+HEADERS += mainwindow.h \
+ taskmodel.h \
+ tabledelegate.h
+FORMS +=
+OTHER_FILES += README.txt