diff --git a/app/elementslistmodel.cpp b/app/elementslistmodel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1a9c8bdef744c536b543556cf11115753c3795e8 --- /dev/null +++ b/app/elementslistmodel.cpp @@ -0,0 +1,44 @@ +#include "elementslistmodel.h" + +ElementsListModel::ElementsListModel(QObject *parent) + : QAbstractListModel(parent) +{ +} + +QVariant ElementsListModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + // FIXME: Implement me! +} + +int ElementsListModel::rowCount(const QModelIndex &parent) const +{ + // For list models only the root node (an invalid parent) should return the list's size. For all + // other (valid) parents, rowCount() should return 0 so that it does not become a tree model. + if (parent.isValid()) + return 0; + + // FIXME: Implement me! +} + +QVariant ElementsListModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + // FIXME: Implement me! + return QVariant(); +} + +bool ElementsListModel::insertRows(int row, int count, const QModelIndex &parent) +{ + beginInsertRows(parent, row, row + count - 1); + // FIXME: Implement me! + endInsertRows(); +} + +bool ElementsListModel::removeRows(int row, int count, const QModelIndex &parent) +{ + beginRemoveRows(parent, row, row + count - 1); + // FIXME: Implement me! + endRemoveRows(); +} diff --git a/app/elementslistmodel.h b/app/elementslistmodel.h new file mode 100644 index 0000000000000000000000000000000000000000..ea4e4d1ee974ba5d3c943a454ced53b758bb3360 --- /dev/null +++ b/app/elementslistmodel.h @@ -0,0 +1,33 @@ +#ifndef ELEMENTSLISTMODEL_H +#define ELEMENTSLISTMODEL_H + +#include <QAbstractListModel> +#include "task.h" + +class ElementsListModel : public QAbstractListModel +{ + Q_OBJECT + +public: + explicit ElementsListModel(QObject *parent = nullptr); + + // Header: + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + + // Basic functionality: + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + + // Add data: + bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; + + // Remove data: + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; + +private: + QVector<Task> taskVector; + +}; + +#endif // ELEMENTSLISTMODEL_H diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index 79351e362fa514b15ad39fbfcaae6b176f271a3b..bfa364f32b8c26f322d81f2c8e3b5a16f4a15084 100644 --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -8,8 +8,8 @@ MainWindow::MainWindow(QWidget *parent) : ui->setupUi(this); // on affiche d'abord la TreeView - ui->groupBox->show(); - ui->groupBox_2->hide(); + ui->treeWidget->show(); + ui->listWidget->hide(); } @@ -38,13 +38,13 @@ void MainWindow::update_status(GeneralStatus &genStatus) void MainWindow::on_comboBox_currentTextChanged(const QString &arg1) { if (arg1 == "Tree"){ - ui->groupBox->show(); - ui->groupBox_2->hide(); + ui->treeWidget->show(); + ui->listWidget->hide(); } else if (arg1 == "List"){ - ui->groupBox_2->show(); - ui->groupBox ->hide(); + ui->listWidget->show(); + ui->treeWidget->hide(); } else { diff --git a/app/mainwindow.ui b/app/mainwindow.ui index 0dbcf2da67395e27b4bf49013358bfeec433118c..5bf7ea86716f77f772cb2d38b60d29165f548615 100644 --- a/app/mainwindow.ui +++ b/app/mainwindow.ui @@ -124,10 +124,22 @@ </layout> </item> <item> - <widget class="QListWidget" name="listWidget"/> + <widget class="QListWidget" name="listWidget"> + <item> + <property name="text"> + <string>ListView</string> + </property> + </item> + </widget> </item> <item> - <widget class="QTreeView" name="treeView"/> + <widget class="QTreeWidget" name="treeWidget"> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> + </widget> </item> </layout> </item> @@ -180,7 +192,7 @@ </layout> </item> <item> - <widget class="QListView" name="listView"/> + <widget class="QListWidget" name="listWidget_2"/> </item> </layout> </item>