|
|
|
@@ -24,6 +24,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
|
, ui(new Ui::MainWindow)
|
|
|
|
, ui(new Ui::MainWindow)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
this->menuSelectedBoardItem = nullptr;
|
|
|
|
|
|
|
|
this->menuSelectedFilterItem = nullptr;
|
|
|
|
|
|
|
|
this->menuSelectedTaskItem = nullptr;
|
|
|
|
init();
|
|
|
|
init();
|
|
|
|
this->selectedBoardIndex = -1;
|
|
|
|
this->selectedBoardIndex = -1;
|
|
|
|
// Change "name" column size
|
|
|
|
// Change "name" column size
|
|
|
|
@@ -77,7 +80,8 @@ void MainWindow::openAbout()
|
|
|
|
void MainWindow::prepareBoardMenu(const QPoint &pos)
|
|
|
|
void MainWindow::prepareBoardMenu(const QPoint &pos)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QMenu menu(this);
|
|
|
|
QMenu menu(this);
|
|
|
|
if (ui->boardList->selectedItems().length() == 1) {
|
|
|
|
this->menuSelectedBoardItem = ui->boardList->itemAt(pos);
|
|
|
|
|
|
|
|
if (this->menuSelectedBoardItem != nullptr) {
|
|
|
|
QAction *renameAction = new QAction(tr("Edit board"), this);
|
|
|
|
QAction *renameAction = new QAction(tr("Edit board"), this);
|
|
|
|
connect(renameAction, &QAction::triggered, this, &MainWindow::onEditNameBoardMenu);
|
|
|
|
connect(renameAction, &QAction::triggered, this, &MainWindow::onEditNameBoardMenu);
|
|
|
|
menu.addAction(renameAction);
|
|
|
|
menu.addAction(renameAction);
|
|
|
|
@@ -99,15 +103,19 @@ void MainWindow::prepareTaskMenu(const QPoint &pos)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool show = false;
|
|
|
|
bool show = false;
|
|
|
|
QMenu menu(this);
|
|
|
|
QMenu menu(this);
|
|
|
|
if (ui->taskList->selectedItems().length() == 1) {
|
|
|
|
this->menuSelectedTaskItem = ui->taskList->itemAt(pos);
|
|
|
|
|
|
|
|
if (menuSelectedTaskItem != nullptr) {
|
|
|
|
show = true;
|
|
|
|
show = true;
|
|
|
|
QAction *renameAction = new QAction(tr("Edit the task"), this);
|
|
|
|
QAction *renameAction = new QAction(tr("Edit the task"), this);
|
|
|
|
connect(renameAction, &QAction::triggered, this, &MainWindow::onEditNameTaskMenu);
|
|
|
|
connect(renameAction, &QAction::triggered, this, &MainWindow::onEditNameTaskMenu);
|
|
|
|
menu.addAction(renameAction);
|
|
|
|
menu.addAction(renameAction);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedBoardIndex > -1)
|
|
|
|
|
|
|
|
{
|
|
|
|
QAction *deleteAction = new QAction(tr("Delete from the board"), this);
|
|
|
|
QAction *deleteAction = new QAction(tr("Delete from the board"), this);
|
|
|
|
connect(deleteAction, &QAction::triggered, this, &MainWindow::onRemoveTaskMenu);
|
|
|
|
connect(deleteAction, &QAction::triggered, this, &MainWindow::onRemoveTaskMenu);
|
|
|
|
menu.addAction(deleteAction);
|
|
|
|
menu.addAction(deleteAction);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
menu.addSeparator();
|
|
|
|
menu.addSeparator();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -246,14 +254,18 @@ void MainWindow::onEditTask(QTreeWidgetItem *item)
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::onRemoveBoardMenu()
|
|
|
|
void MainWindow::onRemoveBoardMenu()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (selectedBoardIndex > -1)
|
|
|
|
if (menuSelectedBoardItem != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
int i = ui->filterListWidget->indexFromItem(menuSelectedFilterItem).row();
|
|
|
|
QMessageBox::StandardButton result = QMessageBox::question(this, "Delete a board", "Do you want to delete this board?");
|
|
|
|
QMessageBox::StandardButton result = QMessageBox::question(this, "Delete a board", "Do you want to delete this board?");
|
|
|
|
if (result == QMessageBox::Yes)
|
|
|
|
if (result == QMessageBox::Yes)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
boards.removeAt(selectedBoardIndex);
|
|
|
|
boards.removeAt(i);
|
|
|
|
delete ui->boardList->takeItem(selectedBoardIndex);
|
|
|
|
delete ui->boardList->takeItem(i);
|
|
|
|
|
|
|
|
if (selectedBoardIndex == i)
|
|
|
|
|
|
|
|
{
|
|
|
|
selectedBoardIndex = -1;
|
|
|
|
selectedBoardIndex = -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
redrawTaskTree();
|
|
|
|
redrawTaskTree();
|
|
|
|
save();
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -278,14 +290,18 @@ void MainWindow::onRemoveTaskMenu()
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::onRemoveFilterMenu()
|
|
|
|
void MainWindow::onRemoveFilterMenu()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (selectedFilterIndex > -1)
|
|
|
|
if (menuSelectedFilterItem != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
int i = ui->filterListWidget->indexFromItem(menuSelectedFilterItem).row();
|
|
|
|
QMessageBox::StandardButton result = QMessageBox::question(this, "Delete a filter", "Do you want to delete this filter?");
|
|
|
|
QMessageBox::StandardButton result = QMessageBox::question(this, "Delete a filter", "Do you want to delete this filter?");
|
|
|
|
if (result == QMessageBox::Yes)
|
|
|
|
if (result == QMessageBox::Yes)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
filters.removeAt(selectedFilterIndex);
|
|
|
|
filters.removeAt(i);
|
|
|
|
delete ui->filterListWidget->takeItem(selectedFilterIndex);
|
|
|
|
delete ui->filterListWidget->takeItem(i);
|
|
|
|
|
|
|
|
if (selectedFilterIndex == i)
|
|
|
|
|
|
|
|
{
|
|
|
|
selectedFilterIndex = -1;
|
|
|
|
selectedFilterIndex = -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
redrawTaskTree();
|
|
|
|
redrawTaskTree();
|
|
|
|
save();
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -294,9 +310,10 @@ void MainWindow::onRemoveFilterMenu()
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::onEditNameBoardMenu()
|
|
|
|
void MainWindow::onEditNameBoardMenu()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (selectedBoardIndex > -1)
|
|
|
|
if (menuSelectedBoardItem != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Board *b = boards.at(selectedBoardIndex);
|
|
|
|
int i = ui->filterListWidget->indexFromItem(menuSelectedFilterItem).row();
|
|
|
|
|
|
|
|
Board *b = boards.at(i);
|
|
|
|
NameDialog dialog("Edit board name", b->getName(), b->getDescription(), this);
|
|
|
|
NameDialog dialog("Edit board name", b->getName(), b->getDescription(), this);
|
|
|
|
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
|
|
|
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -304,7 +321,7 @@ void MainWindow::onEditNameBoardMenu()
|
|
|
|
QString newDesc = dialog.getDescription();
|
|
|
|
QString newDesc = dialog.getDescription();
|
|
|
|
b->setName(newName);
|
|
|
|
b->setName(newName);
|
|
|
|
b->setDescription(newDesc);
|
|
|
|
b->setDescription(newDesc);
|
|
|
|
QListWidgetItem *item = ui->boardList->item(selectedBoardIndex);
|
|
|
|
QListWidgetItem *item = ui->boardList->item(i);
|
|
|
|
item->setText(newName);
|
|
|
|
item->setText(newName);
|
|
|
|
item->setToolTip(newDesc);
|
|
|
|
item->setToolTip(newDesc);
|
|
|
|
ui->label->setText(newName);
|
|
|
|
ui->label->setText(newName);
|
|
|
|
@@ -325,9 +342,10 @@ void MainWindow::onEditNameTaskMenu()
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::onEditFilterMenu()
|
|
|
|
void MainWindow::onEditFilterMenu()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (selectedFilterIndex > -1)
|
|
|
|
if (menuSelectedFilterItem != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Filter f = filters[selectedFilterIndex];
|
|
|
|
int i = ui->filterListWidget->indexFromItem(menuSelectedFilterItem).row();
|
|
|
|
|
|
|
|
Filter f = filters[i];
|
|
|
|
FilterDialog dialog("Edit the filter", f, boards, status, priorities, this);
|
|
|
|
FilterDialog dialog("Edit the filter", f, boards, status, priorities, this);
|
|
|
|
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
|
|
|
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -347,7 +365,8 @@ void MainWindow::onEditFilterMenu()
|
|
|
|
void MainWindow::prepareFilterMenu(const QPoint &pos)
|
|
|
|
void MainWindow::prepareFilterMenu(const QPoint &pos)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QMenu menu(this);
|
|
|
|
QMenu menu(this);
|
|
|
|
if (ui->filterListWidget->selectedItems().length() == 1) {
|
|
|
|
this->menuSelectedFilterItem = ui->filterListWidget->itemAt(pos);
|
|
|
|
|
|
|
|
if (this->menuSelectedFilterItem != nullptr) {
|
|
|
|
QAction *renameAction = new QAction(tr("Edit the filter"), this);
|
|
|
|
QAction *renameAction = new QAction(tr("Edit the filter"), this);
|
|
|
|
connect(renameAction, &QAction::triggered, this, &MainWindow::onEditFilterMenu);
|
|
|
|
connect(renameAction, &QAction::triggered, this, &MainWindow::onEditFilterMenu);
|
|
|
|
menu.addAction(renameAction);
|
|
|
|
menu.addAction(renameAction);
|
|
|
|
@@ -511,28 +530,26 @@ const QJsonDocument MainWindow::getJsonSave()
|
|
|
|
|
|
|
|
|
|
|
|
Task *MainWindow::getSelectedTask()
|
|
|
|
Task *MainWindow::getSelectedTask()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<QTreeWidgetItem*> items = ui->taskList->selectedItems();
|
|
|
|
|
|
|
|
if (items.count() != 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (selectedBoardIndex > -1)
|
|
|
|
if (selectedBoardIndex > -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Board *b = boards[selectedBoardIndex];
|
|
|
|
Board *b = boards[selectedBoardIndex];
|
|
|
|
QList<QTreeWidgetItem*> items = ui->taskList->selectedItems();
|
|
|
|
|
|
|
|
if (items.count() == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int16_t i = ui->taskList->indexOfTopLevelItem(items[0]);
|
|
|
|
int16_t i = ui->taskList->indexOfTopLevelItem(items[0]);
|
|
|
|
return b->taskAt(i);
|
|
|
|
return b->taskAt(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (selectedFilterIndex > -1)
|
|
|
|
else if (selectedFilterIndex > -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!filterResult.empty())
|
|
|
|
if (!filterResult.empty())
|
|
|
|
{
|
|
|
|
|
|
|
|
QList<QTreeWidgetItem*> items = ui->taskList->selectedItems();
|
|
|
|
|
|
|
|
if (items.count() == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int16_t i = ui->taskList->indexOfTopLevelItem(items[0]);
|
|
|
|
int16_t i = ui->taskList->indexOfTopLevelItem(items[0]);
|
|
|
|
return filterResult[i];
|
|
|
|
return filterResult[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|