Create filter dialog, board description

This commit is contained in:
Aurélie Delhaie
2023-01-14 18:15:41 +01:00
parent 36c752694f
commit 6206a16c9d
18 changed files with 540 additions and 60 deletions

View File

@@ -15,6 +15,7 @@
#include "aboutdialog.h"
#include "namedialog.h"
#include "taskdialog.h"
#include "filterdialog.h"
#include "../tools.h"
MainWindow::MainWindow(QWidget *parent)
@@ -32,6 +33,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->actionAbout, &QAction::triggered, this, &MainWindow::openAbout);
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::onNewBoardClick);
connect(ui->actionNew_task, &QAction::triggered, this, &MainWindow::onNewTaskClick);
connect(ui->actionNew_filter, &QAction::triggered, this, &MainWindow::onNewFilterClick);
connect(ui->boardList, &QListWidget::currentRowChanged, this, &MainWindow::onBoardSelected);
connect(ui->boardList, &QListWidget::customContextMenuRequested, this, &MainWindow::prepareBoardMenu);
connect(ui->taskList, &QTreeWidget::itemDoubleClicked, this, &MainWindow::onEditTask);
@@ -70,51 +72,57 @@ void MainWindow::openAbout()
void MainWindow::prepareBoardMenu(const QPoint &pos)
{
QMenu menu(this);
if (ui->boardList->selectedItems().length() == 1) {
QMenu menu(this);
QAction *renameAction = new QAction(tr("Rename this board"), this);
QAction *renameAction = new QAction(tr("Edit board"), this);
connect(renameAction, &QAction::triggered, this, &MainWindow::onEditNameBoardMenu);
menu.addAction(renameAction);
menu.addSeparator();
QAction *deleteAction = new QAction(tr("Delete this board"), this);
QAction *deleteAction = new QAction(tr("Delete the board and all the tasks"), this);
connect(deleteAction, &QAction::triggered, this, &MainWindow::onRemoveBoardMenu);
menu.addAction(deleteAction);
menu.exec(ui->boardList->mapToGlobal(pos));
menu.addSeparator();
}
QAction *addAction = new QAction(tr("New board"), this);
connect(addAction, &QAction::triggered, this, &MainWindow::onNewBoardClick);
menu.addAction(addAction);
menu.exec(ui->boardList->mapToGlobal(pos));
}
void MainWindow::prepareTaskMenu(const QPoint &pos)
{
QMenu menu(this);
if (ui->taskList->selectedItems().length() == 1) {
QMenu menu(this);
QAction *renameAction = new QAction(tr("Edit the task"), this);
connect(renameAction, &QAction::triggered, this, &MainWindow::onEditNameTaskMenu);
menu.addAction(renameAction);
menu.addSeparator();
QAction *deleteAction = new QAction(tr("Delete from the board"), this);
connect(deleteAction, &QAction::triggered, this, &MainWindow::onRemoveTaskMenu);
menu.addAction(deleteAction);
menu.exec(ui->taskList->mapToGlobal(pos));
menu.addSeparator();
}
QAction *addAction = new QAction(tr("New task"), this);
connect(addAction, &QAction::triggered, this, &MainWindow::onNewTaskClick);
menu.addAction(addAction);
menu.exec(ui->taskList->mapToGlobal(pos));
}
void MainWindow::onNewBoardClick()
{
NameDialog dialog("Create a board", "New empty board", this);
NameDialog dialog("Create a board", "New empty board", "", this);
if (dialog.exec() == QDialog::DialogCode::Accepted)
{
QString name = dialog.getChoosenName();
Board *b = new Board(name);
QString desc = dialog.getDescription();
Board *b = new Board(name, desc);
boards.append(b);
QListWidgetItem *item = new QListWidgetItem(name);
item->setStatusTip(desc);
ui->boardList->addItem(item);
save();
}
@@ -138,6 +146,17 @@ void MainWindow::onNewTaskClick()
}
}
void MainWindow::onNewFilterClick()
{
FilterDialog dialog("New filter", boards, status, priorities, this);
if (dialog.exec() == QDialog::DialogCode::Accepted)
{
Filter f = dialog.getFilter();
QListWidgetItem *item = new QListWidgetItem(f.getName());
ui->filterListWidget->addItem(item);
}
}
void MainWindow::onBoardSelected(int i)
{
selectedBoardIndex = i;
@@ -145,11 +164,13 @@ void MainWindow::onBoardSelected(int i)
{
Board *b = boards[selectedBoardIndex];
ui->label->setText(b->getName());
ui->boardDescription->setText(b->getDescription());
ui->actionNew_task->setDisabled(false);
}
else
{
ui->label->setText("<- Select a board");
ui->label->setText("No board selected");
ui->boardDescription->clear();
ui->actionNew_task->setDisabled(true);
}
redrawTaskTree();
@@ -213,13 +234,18 @@ void MainWindow::onEditNameBoardMenu()
if (selectedBoardIndex > -1)
{
Board *b = boards.at(selectedBoardIndex);
NameDialog dialog("Edit board name", b->getName(), this);
NameDialog dialog("Edit board name", b->getName(), b->getDescription(), this);
if (dialog.exec() == QDialog::DialogCode::Accepted)
{
QString newName= dialog.getChoosenName();
QString newName = dialog.getChoosenName();
QString newDesc = dialog.getDescription();
b->setName(newName);
ui->boardList->item(selectedBoardIndex)->setText(newName);
b->setDescription(newDesc);
QListWidgetItem *item = ui->boardList->item(selectedBoardIndex);
item->setText(newName);
item->setToolTip(newDesc);
ui->label->setText(newName);
ui->boardDescription->setText(newDesc);
save();
}
}
@@ -281,6 +307,12 @@ QVector<Status> MainWindow::defaultStatus()
return res;
}
QVector<Filter> MainWindow::defaultFilters()
{
QVector<Filter> res;
return res;
}
const QString MainWindow::getPriorityLabel(QString uuid)
{
QString res = "";
@@ -416,6 +448,7 @@ void MainWindow::redrawBoardList()
foreach (Board *b, boards)
{
QListWidgetItem *item = new QListWidgetItem(b->getName());
item->setToolTip(b->getDescription());
l->addItem(item);
}
}