Skip to content
Extraits de code Groupes Projets
Valider bf849079 rédigé par Jordan Aurey's avatar Jordan Aurey
Parcourir les fichiers

classe implémentant le model

parent 0e62a55c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
#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();
}
#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
...@@ -8,8 +8,8 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -8,8 +8,8 @@ MainWindow::MainWindow(QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
// on affiche d'abord la TreeView // on affiche d'abord la TreeView
ui->groupBox->show(); ui->treeWidget->show();
ui->groupBox_2->hide(); ui->listWidget->hide();
} }
...@@ -38,13 +38,13 @@ void MainWindow::update_status(GeneralStatus &genStatus) ...@@ -38,13 +38,13 @@ void MainWindow::update_status(GeneralStatus &genStatus)
void MainWindow::on_comboBox_currentTextChanged(const QString &arg1) void MainWindow::on_comboBox_currentTextChanged(const QString &arg1)
{ {
if (arg1 == "Tree"){ if (arg1 == "Tree"){
ui->groupBox->show(); ui->treeWidget->show();
ui->groupBox_2->hide(); ui->listWidget->hide();
} }
else if (arg1 == "List"){ else if (arg1 == "List"){
ui->groupBox_2->show(); ui->listWidget->show();
ui->groupBox ->hide(); ui->treeWidget->hide();
} }
else { else {
......
...@@ -124,10 +124,22 @@ ...@@ -124,10 +124,22 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QListWidget" name="listWidget"/> <widget class="QListWidget" name="listWidget">
<item>
<property name="text">
<string>ListView</string>
</property>
</item>
</widget>
</item> </item>
<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> </item>
</layout> </layout>
</item> </item>
...@@ -180,7 +192,7 @@ ...@@ -180,7 +192,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QListView" name="listView"/> <widget class="QListWidget" name="listWidget_2"/>
</item> </item>
</layout> </layout>
</item> </item>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter