Compare commits
20 Commits
v0.1.1-bet
...
v0.3.1-bet
| Author | SHA1 | Date | |
|---|---|---|---|
| 34cb5776f6 | |||
| 3112e16326 | |||
| 09e5f4cd41 | |||
| e40dfb8f69 | |||
|
|
e961e7642e | ||
|
|
22ebe6eded | ||
|
|
93026b1373 | ||
|
|
1b56b5eec5 | ||
|
|
4c95000b8f | ||
|
|
35dee6684f | ||
|
|
d0186d0759 | ||
|
|
3af0771b55 | ||
|
|
961dbd8aa0 | ||
|
|
693532a802 | ||
|
|
ba1a5f94f3 | ||
|
|
43ecd2601e | ||
|
|
6206a16c9d | ||
|
|
36c752694f | ||
|
|
a86ece9c9a | ||
|
|
32a25f9b55 |
14
README.md
14
README.md
@@ -1 +1,15 @@
|
||||
# TaskBoard
|
||||
|
||||
Wrote with Qt 6 Open Source : [Download](https://www.qt.io/download-open-source)
|
||||
|
||||
## Prepare to use on linux
|
||||
You need to install Qt 6.2.4 dependencies
|
||||
|
||||
```sh
|
||||
sudo apt install libxcb1 libxcb-xinerama0 libqt6widgets6 libqt6gui6 libqt6core5compat6 libqt6core5compat6 libqt6core6 libqt6dbus6 qt6-qpa-plugins
|
||||
```
|
||||
### To run on Wayland
|
||||
|
||||
```sh
|
||||
sudo apt install qt6-wayland
|
||||
```
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
greaterThan(QT_MAJOR_VERSION, 5): QT += widgets
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
win32:VERSION = 0.1.1.0 # major.minor.patch.build
|
||||
else:VERSION = 0.1.1 # major.minor.patch
|
||||
win32:VERSION = 0.3.1.0 # major.minor.patch.build
|
||||
else:VERSION = 0.3.1 # major.minor.patch
|
||||
|
||||
DEFINES += APP_VERSION=\"\\\"$${VERSION}\\\"\"
|
||||
DEFINES += APP_NAME=\"\\\"TaskBoard\\\"\"
|
||||
@@ -68,31 +68,41 @@ linux-* {
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
src/frames/boardconfigdialog.cpp \
|
||||
src/frames/filterdialog.cpp \
|
||||
src/frames/aboutdialog.cpp \
|
||||
src/models/board.cpp \
|
||||
src/main.cpp \
|
||||
src/frames/mainwindow.cpp \
|
||||
src/frames/namedialog.cpp \
|
||||
src/frames/prefdialog.cpp \
|
||||
src/models/filter.cpp \
|
||||
src/models/priority.cpp \
|
||||
src/models/status.cpp \
|
||||
src/models/task.cpp \
|
||||
src/frames/taskdialog.cpp \
|
||||
src/services/taskstateservice.cpp \
|
||||
src/tools.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/frames/boardconfigdialog.h \
|
||||
src/frames/filterdialog.h \
|
||||
src/frames/aboutdialog.h \
|
||||
src/models/board.h \
|
||||
src/frames/mainwindow.h \
|
||||
src/frames/namedialog.h \
|
||||
src/frames/prefdialog.h \
|
||||
src/models/filter.h \
|
||||
src/models/priority.h \
|
||||
src/models/status.h \
|
||||
src/models/task.h \
|
||||
src/frames/taskdialog.h \
|
||||
src/services/taskstateservice.h \
|
||||
src/tools.h
|
||||
|
||||
FORMS += \
|
||||
src/frames/boardconfigdialog.ui \
|
||||
src/frames/filterdialog.ui \
|
||||
src/frames/aboutdialog.ui \
|
||||
src/frames/mainwindow.ui \
|
||||
src/frames/namedialog.ui \
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<RCC>
|
||||
<qresource prefix="/images">
|
||||
<file>resources/logo.png</file>
|
||||
<file>resources/board_add.png</file>
|
||||
<file>resources/task_add.png</file>
|
||||
<file>resources/add_filter.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
BIN
resources/add_filter.png
Normal file
BIN
resources/add_filter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
resources/board_add.png
Normal file
BIN
resources/board_add.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
BIN
resources/task_add.png
Normal file
BIN
resources/task_add.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -6,12 +6,36 @@ AboutDialog::AboutDialog(QWidget *parent) :
|
||||
ui(new Ui::AboutDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
#ifdef APP_ARCH
|
||||
ui->appName->setText(QString("%1 (%2)").arg(APP_NAME, APP_ARCH));
|
||||
ui->version->setText(QString("v%1").arg(APP_VERSION));
|
||||
ui->textEdit_2->append(QString("Built with Qt %1").arg(QT_VERSION_STR));
|
||||
#else
|
||||
ui->appName->setText(APP_NAME);
|
||||
#endif
|
||||
QString compiler = getCompilerInfo();
|
||||
ui->version->setText(QString("v%1-%3 (qt %4)").arg(APP_VERSION, compiler, QT_VERSION_STR));
|
||||
ui->textEdit_2->append(QString("Qt Open Source %1").arg(QT_VERSION_STR));
|
||||
}
|
||||
|
||||
AboutDialog::~AboutDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QString AboutDialog::getCompilerInfo()
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
return QString("clang_%1").arg(__clang_version__);
|
||||
#elif __GNUC__
|
||||
#ifdef __MINGW32__
|
||||
return QString("MinGW_%1.%2").arg(QString::number(__MINGW32_MAJOR_VERSION), QString::number(__MINGW32_MINOR_VERSION));
|
||||
#elif __linux__
|
||||
return QString("GLIBC_%1.%2").arg(QString::number(__GLIBC__), QString::number(__GLIBC_MINOR__));
|
||||
#else
|
||||
return "unknown";
|
||||
#endif
|
||||
#elif _MSC_VER
|
||||
return QString("MSVC_%1").arg(_MSC_VER);
|
||||
#else
|
||||
return "unknown";
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define ABOUTDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
|
||||
namespace Ui {
|
||||
class AboutDialog;
|
||||
@@ -17,6 +18,7 @@ public:
|
||||
|
||||
private:
|
||||
Ui::AboutDialog *ui;
|
||||
QString getCompilerInfo();
|
||||
};
|
||||
|
||||
#endif // ABOUTDIALOG_H
|
||||
|
||||
@@ -77,9 +77,15 @@
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@@ -111,8 +117,7 @@
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
hr { height: 1px; border-width: 0; }
|
||||
</style></head><body style=" font-family:'Noto Sans'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||
</style></head><body style=" font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Menlo'; font-size:13pt;">Copyright 2022 Aurélie Delhaie</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Menlo'; font-size:13pt;"><br /></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Menlo'; font-size:13pt;">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the &quot;Software&quot;), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</span></p>
|
||||
@@ -139,9 +144,8 @@ hr { height: 1px; border-width: 0; }
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
hr { height: 1px; border-width: 0; }
|
||||
</style></head><body style=" font-family:'Noto Sans'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string>
|
||||
</style></head><body style=" font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Noto Sans'; font-size:11pt;"><br /></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
81
src/frames/boardconfigdialog.cpp
Normal file
81
src/frames/boardconfigdialog.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
#include "boardconfigdialog.h"
|
||||
#include "ui_boardconfigdialog.h"
|
||||
|
||||
#include "../services/taskstateservice.h"
|
||||
#include <QVector>
|
||||
|
||||
BoardConfigDialog::BoardConfigDialog(Board *b, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::BoardConfigDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->nameField->setText(b->getName());
|
||||
ui->descriptionField->setPlainText(b->getDescription());
|
||||
ui->showStatusCheckbox->setChecked(b->isShowingStatus());
|
||||
if (!b->isAutoStatus())
|
||||
{
|
||||
QVector<Status> statuses = TaskStateService::getInstance()->getStatuses();
|
||||
foreach (Status s, statuses)
|
||||
{
|
||||
ui->statusCombobox->addItem(s.getName(), s.getUUID());
|
||||
}
|
||||
ui->autoStatusCheckbox->setChecked(false);
|
||||
ui->statusCombobox->setEnabled(true);
|
||||
}
|
||||
connect(ui->autoStatusCheckbox, &QCheckBox::stateChanged, this, &BoardConfigDialog::onAutoStatusCheckboxChange);
|
||||
}
|
||||
|
||||
BoardConfigDialog::~BoardConfigDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
const QString BoardConfigDialog::getName()
|
||||
{
|
||||
return ui->nameField->text();
|
||||
}
|
||||
|
||||
const QString BoardConfigDialog::getDescription()
|
||||
{
|
||||
return ui->descriptionField->toPlainText();
|
||||
}
|
||||
|
||||
bool BoardConfigDialog::isAutoStatus()
|
||||
{
|
||||
return ui->autoStatusCheckbox->isChecked();
|
||||
}
|
||||
|
||||
bool BoardConfigDialog::isShowingStatus()
|
||||
{
|
||||
return ui->showStatusCheckbox->isChecked();
|
||||
}
|
||||
|
||||
const QString BoardConfigDialog::getStatus()
|
||||
{
|
||||
if (!ui->autoStatusCheckbox->isChecked())
|
||||
{
|
||||
if (!ui->statusCombobox->currentData().isNull())
|
||||
{
|
||||
return ui->statusCombobox->currentData().toString();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void BoardConfigDialog::onAutoStatusCheckboxChange(int state)
|
||||
{
|
||||
if (state == Qt::CheckState::Unchecked)
|
||||
{
|
||||
QVector<Status> statuses = TaskStateService::getInstance()->getStatuses();
|
||||
foreach (Status s, statuses)
|
||||
{
|
||||
ui->statusCombobox->addItem(s.getName(), s.getUUID());
|
||||
}
|
||||
ui->statusCombobox->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->statusCombobox->setEnabled(false);
|
||||
ui->statusCombobox->clear();
|
||||
}
|
||||
}
|
||||
33
src/frames/boardconfigdialog.h
Normal file
33
src/frames/boardconfigdialog.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef BOARDCONFIGDIALOG_H
|
||||
#define BOARDCONFIGDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "../models/board.h"
|
||||
|
||||
namespace Ui {
|
||||
class BoardConfigDialog;
|
||||
}
|
||||
|
||||
class BoardConfigDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BoardConfigDialog(Board *b, QWidget *parent = nullptr);
|
||||
~BoardConfigDialog();
|
||||
|
||||
const QString getName();
|
||||
const QString getDescription();
|
||||
bool isAutoStatus();
|
||||
bool isShowingStatus();
|
||||
const QString getStatus();
|
||||
|
||||
private slots:
|
||||
void onAutoStatusCheckboxChange(int);
|
||||
|
||||
private:
|
||||
Ui::BoardConfigDialog *ui;
|
||||
};
|
||||
|
||||
#endif // BOARDCONFIGDIALOG_H
|
||||
126
src/frames/boardconfigdialog.ui
Normal file
126
src/frames/boardconfigdialog.ui
Normal file
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BoardConfigDialog</class>
|
||||
<widget class="QDialog" name="BoardConfigDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>379</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Board Configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="nameField"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="descriptionField"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="showStatusCheckbox">
|
||||
<property name="text">
|
||||
<string>Show the board status</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="autoStatusCheckbox">
|
||||
<property name="text">
|
||||
<string>Auto determine status</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Status</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="statusCombobox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>BoardConfigDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>BoardConfigDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
150
src/frames/filterdialog.cpp
Normal file
150
src/frames/filterdialog.cpp
Normal file
@@ -0,0 +1,150 @@
|
||||
#include "filterdialog.h"
|
||||
#include "ui_filterdialog.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "../services/taskstateservice.h"
|
||||
|
||||
FilterDialog::FilterDialog(QString dialogTitle, QVector<Board*> boards, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::FilterDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowTitle(dialogTitle);
|
||||
init(boards);
|
||||
}
|
||||
|
||||
FilterDialog::FilterDialog(QString dialogTitle, Filter f, QVector<Board*> boards, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::FilterDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowTitle(dialogTitle);
|
||||
init(boards);
|
||||
|
||||
ui->nameEdit->setText(f.getName());
|
||||
ui->descriptionEdit->setPlainText(f.getDescription());
|
||||
ui->dateComparationCombobox->setCurrentIndex(f.getExpectedForComparator());
|
||||
foreach (QString uuid, f.getBoards())
|
||||
{
|
||||
for (int i = 0; i < ui->boardListWidget->count(); ++i)
|
||||
{
|
||||
QListWidgetItem *item = ui->boardListWidget->item(i);
|
||||
if (item->data(1).toString() == uuid)
|
||||
{
|
||||
item->setCheckState(Qt::Checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (QString uuid, f.getStatus())
|
||||
{
|
||||
for (int i = 0; i < ui->statusListWidget->count(); ++i)
|
||||
{
|
||||
QListWidgetItem *item = ui->statusListWidget->item(i);
|
||||
if (item->data(1).toString() == uuid)
|
||||
{
|
||||
item->setCheckState(Qt::Checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (QString uuid, f.getPriorities())
|
||||
{
|
||||
for (int i = 0; i < ui->priorityListWidget->count(); ++i)
|
||||
{
|
||||
QListWidgetItem *item = ui->priorityListWidget->item(i);
|
||||
if (item->data(1).toString() == uuid)
|
||||
{
|
||||
item->setCheckState(Qt::Checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FilterDialog::init(QVector<Board *> boards)
|
||||
{
|
||||
for (Board *b : boards)
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem();
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
item->setText(b->getName());
|
||||
item->setData(1, b->getUuid());
|
||||
ui->boardListWidget->addItem(item);
|
||||
}
|
||||
|
||||
QVector<Status> statuses = TaskStateService::getInstance()->getStatuses();
|
||||
for (Status s : statuses)
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem();
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
item->setText(s.getName());
|
||||
item->setData(1, s.getUUID());
|
||||
ui->statusListWidget->addItem(item);
|
||||
}
|
||||
|
||||
QVector<Priority> priorities = TaskStateService::getInstance()->getPriorities();
|
||||
for (Priority p : priorities)
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem();
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
item->setText(p.getName());
|
||||
item->setData(1, p.getUUID());
|
||||
ui->priorityListWidget->addItem(item);
|
||||
}
|
||||
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &FilterDialog::validateAndAccept);
|
||||
}
|
||||
|
||||
FilterDialog::~FilterDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
const Filter FilterDialog::getFilter()
|
||||
{
|
||||
QString name = ui->nameEdit->text();
|
||||
QString description = ui->descriptionEdit->toPlainText();
|
||||
uint8_t dateComparation = 0;
|
||||
if (ui->dateComparationCombobox->currentIndex() > -1)
|
||||
{
|
||||
dateComparation = ui->dateComparationCombobox->currentIndex();
|
||||
}
|
||||
QVector<QString> boards;
|
||||
for (int i = 0; i < ui->boardListWidget->count(); ++i) {
|
||||
QListWidgetItem *item = ui->boardListWidget->item(i);
|
||||
if (item->checkState() == Qt::Checked)
|
||||
{
|
||||
boards.append(item->data(1).toString());
|
||||
}
|
||||
}
|
||||
QVector<QString> status;
|
||||
for (int i = 0; i < ui->statusListWidget->count(); ++i) {
|
||||
QListWidgetItem *item = ui->statusListWidget->item(i);
|
||||
if (item->checkState() == Qt::Checked)
|
||||
{
|
||||
status.append(item->data(1).toString());
|
||||
}
|
||||
}
|
||||
QVector<QString> priorities;
|
||||
for (int i = 0; i < ui->priorityListWidget->count(); ++i) {
|
||||
QListWidgetItem *item = ui->priorityListWidget->item(i);
|
||||
if (item->checkState() == Qt::Checked)
|
||||
{
|
||||
priorities.append(item->data(1).toString());
|
||||
}
|
||||
}
|
||||
return Filter(name, description, dateComparation, boards, status, priorities);
|
||||
}
|
||||
|
||||
void FilterDialog::validateAndAccept()
|
||||
{
|
||||
if (ui->nameEdit->text().length() == 0)
|
||||
{
|
||||
QMessageBox::critical(this, "This filter needs a name", "You need to enter a name to save this filter");
|
||||
return;
|
||||
}
|
||||
accept();
|
||||
}
|
||||
34
src/frames/filterdialog.h
Normal file
34
src/frames/filterdialog.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef FILTERDIALOG_H
|
||||
#define FILTERDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "../models/board.h"
|
||||
#include "../models/priority.h"
|
||||
#include "../models/status.h"
|
||||
#include "../models/filter.h"
|
||||
|
||||
namespace Ui {
|
||||
class FilterDialog;
|
||||
}
|
||||
|
||||
class FilterDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FilterDialog(QString dialogTitle, QVector<Board*> boards, QWidget *parent = nullptr);
|
||||
FilterDialog(QString dialogTitle, Filter f, QVector<Board*> boards, QWidget *parent = nullptr);
|
||||
~FilterDialog();
|
||||
const Filter getFilter();
|
||||
|
||||
private slots:
|
||||
void validateAndAccept();
|
||||
|
||||
private:
|
||||
Ui::FilterDialog *ui;
|
||||
|
||||
void init(QVector<Board*> boards);
|
||||
};
|
||||
|
||||
#endif // FILTERDIALOG_H
|
||||
163
src/frames/filterdialog.ui
Normal file
163
src/frames/filterdialog.ui
Normal file
@@ -0,0 +1,163 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FilterDialog</class>
|
||||
<widget class="QDialog" name="FilterDialog">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::WindowModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>449</width>
|
||||
<height>656</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Filter name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="nameEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="descriptionEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Date comparation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="dateComparationCombobox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Ignore date</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>On time</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>End today</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Ended</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Boards (None = all)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="boardListWidget">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="selectionRectVisible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Status (None = all)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="statusListWidget">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Priority (None = all)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="priorityListWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>FilterDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -4,6 +4,8 @@
|
||||
#define PRIORITIES_KEY "priorities"
|
||||
#define STATUS_KEY "status"
|
||||
#define BOARDS_KEY "boards"
|
||||
#define FILTERS_KEY "filters"
|
||||
#define DEFAULT_STATUS "default_status"
|
||||
|
||||
#include <QUuid>
|
||||
#include <QColor>
|
||||
@@ -15,13 +17,20 @@
|
||||
#include "aboutdialog.h"
|
||||
#include "namedialog.h"
|
||||
#include "taskdialog.h"
|
||||
#include "filterdialog.h"
|
||||
#include "boardconfigdialog.h"
|
||||
#include "../tools.h"
|
||||
#include "../services/taskstateservice.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->boardStatus->setVisible(false);
|
||||
this->menuSelectedBoardItem = nullptr;
|
||||
this->menuSelectedFilterItem = nullptr;
|
||||
this->menuSelectedTaskItem = nullptr;
|
||||
init();
|
||||
this->selectedBoardIndex = -1;
|
||||
// Change "name" column size
|
||||
@@ -32,12 +41,16 @@ 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->filterListWidget, &QListWidget::currentRowChanged, this, &MainWindow::onFilterSelected);
|
||||
connect(ui->filterListWidget, &QListWidget::customContextMenuRequested, this, &MainWindow::prepareFilterMenu);
|
||||
connect(ui->taskList, &QTreeWidget::itemDoubleClicked, this, &MainWindow::onEditTask);
|
||||
connect(ui->taskList, &QTreeWidget::customContextMenuRequested, this, &MainWindow::prepareTaskMenu);
|
||||
ui->boardList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
ui->taskList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
ui->filterListWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@@ -52,11 +65,12 @@ MainWindow::~MainWindow()
|
||||
|
||||
void MainWindow::openPreferences()
|
||||
{
|
||||
PrefDialog dialog(status, priorities, this);
|
||||
PrefDialog dialog(this);
|
||||
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
||||
{
|
||||
this->priorities = dialog.getPriorities();
|
||||
this->status = dialog.getStatus();
|
||||
TaskStateService::getInstance()->updatePriorities(dialog.getPriorities());
|
||||
TaskStateService::getInstance()->updateStatuses(dialog.getStatus());
|
||||
TaskStateService::getInstance()->setDefaultStatus(dialog.getDefaultStatus());
|
||||
save();
|
||||
redrawTaskTree();
|
||||
}
|
||||
@@ -70,51 +84,71 @@ void MainWindow::openAbout()
|
||||
|
||||
void MainWindow::prepareBoardMenu(const QPoint &pos)
|
||||
{
|
||||
if (ui->boardList->selectedItems().length() == 1) {
|
||||
QMenu menu(this);
|
||||
|
||||
QAction *renameAction = new QAction(tr("Rename this board"), this);
|
||||
QMenu menu(this);
|
||||
this->menuSelectedBoardItem = ui->boardList->itemAt(pos);
|
||||
if (this->menuSelectedBoardItem != nullptr) {
|
||||
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)
|
||||
{
|
||||
if (ui->taskList->selectedItems().length() == 1) {
|
||||
QMenu menu(this);
|
||||
|
||||
bool show = false;
|
||||
QMenu menu(this);
|
||||
this->menuSelectedTaskItem = ui->taskList->itemAt(pos);
|
||||
if (menuSelectedTaskItem != nullptr) {
|
||||
show = true;
|
||||
QAction *renameAction = new QAction(tr("Edit the task"), this);
|
||||
connect(renameAction, &QAction::triggered, this, &MainWindow::onEditNameTaskMenu);
|
||||
menu.addAction(renameAction);
|
||||
|
||||
if (selectedBoardIndex > -1)
|
||||
{
|
||||
QAction *deleteAction = new QAction(tr("Delete from the board"), this);
|
||||
connect(deleteAction, &QAction::triggered, this, &MainWindow::onRemoveTaskMenu);
|
||||
menu.addAction(deleteAction);
|
||||
}
|
||||
|
||||
menu.addSeparator();
|
||||
}
|
||||
if (selectedBoardIndex > -1)
|
||||
{
|
||||
show = true;
|
||||
QAction *addAction = new QAction(tr("New task"), this);
|
||||
connect(addAction, &QAction::triggered, this, &MainWindow::onNewTaskClick);
|
||||
menu.addAction(addAction);
|
||||
}
|
||||
|
||||
QAction *deleteAction = new QAction(tr("Delete from the board"), this);
|
||||
connect(deleteAction, &QAction::triggered, this, &MainWindow::onRemoveTaskMenu);
|
||||
menu.addAction(deleteAction);
|
||||
|
||||
if (show)
|
||||
{
|
||||
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();
|
||||
}
|
||||
@@ -124,7 +158,7 @@ void MainWindow::onNewTaskClick()
|
||||
{
|
||||
if (selectedBoardIndex > -1)
|
||||
{
|
||||
TaskDialog dialog(status, priorities, this);
|
||||
TaskDialog dialog(this);
|
||||
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
||||
{
|
||||
Task t = dialog.getTask();
|
||||
@@ -138,39 +172,105 @@ void MainWindow::onNewTaskClick()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onNewFilterClick()
|
||||
{
|
||||
FilterDialog dialog("New filter", boards, this);
|
||||
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
||||
{
|
||||
Filter f = dialog.getFilter();
|
||||
filters.append(f);
|
||||
QListWidgetItem *item = new QListWidgetItem(f.getName());
|
||||
item->setToolTip(f.getDescription());
|
||||
ui->filterListWidget->addItem(item);
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onBoardSelected(int i)
|
||||
{
|
||||
selectedBoardIndex = i;
|
||||
selectedFilterIndex = -1;
|
||||
|
||||
ui->filterListWidget->blockSignals(true);
|
||||
ui->filterListWidget->setCurrentIndex(ui->filterListWidget->currentIndex().sibling(-1, -1));
|
||||
ui->filterListWidget->blockSignals(false);
|
||||
|
||||
filterResult.clear();
|
||||
if (selectedBoardIndex > -1)
|
||||
{
|
||||
Board *b = boards[selectedBoardIndex];
|
||||
ui->label->setText(b->getName());
|
||||
if (b->getDescription().length() > 0)
|
||||
{
|
||||
ui->boardDescription->setText(b->getDescription());
|
||||
ui->boardDescription->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->boardDescription->setText("No description");
|
||||
ui->boardDescription->setEnabled(false);
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
void MainWindow::onFilterSelected(int i)
|
||||
{
|
||||
selectedFilterIndex = i;
|
||||
selectedBoardIndex = -1;
|
||||
|
||||
ui->boardList->blockSignals(true);
|
||||
ui->boardList->setCurrentIndex(ui->boardList->currentIndex().sibling(-1, -1));
|
||||
ui->boardList->blockSignals(false);
|
||||
|
||||
filterResult.clear();
|
||||
ui->actionNew_task->setDisabled(true);
|
||||
if (selectedFilterIndex > -1)
|
||||
{
|
||||
Filter f = filters[selectedFilterIndex];
|
||||
ui->label->setText(f.getName());
|
||||
if (f.getDescription().length() > 0)
|
||||
{
|
||||
ui->boardDescription->setText(f.getDescription());
|
||||
ui->boardDescription->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->boardDescription->setText("No description");
|
||||
ui->boardDescription->setEnabled(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->label->setText("No board selected");
|
||||
ui->boardDescription->clear();
|
||||
}
|
||||
redrawTaskTree();
|
||||
}
|
||||
|
||||
void MainWindow::onEditTask(QTreeWidgetItem *item)
|
||||
{
|
||||
if (item != nullptr && selectedBoardIndex > -1)
|
||||
Task *t = getSelectedTask();
|
||||
if (t != nullptr)
|
||||
{
|
||||
Board *b = boards[selectedBoardIndex];
|
||||
int row = ui->taskList->indexOfTopLevelItem(item);
|
||||
Task *t = b->taskAt(row);
|
||||
if (t != nullptr)
|
||||
TaskDialog dialog(t, this);
|
||||
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
||||
{
|
||||
TaskDialog dialog(t, status, priorities, this);
|
||||
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
||||
Task editedTask = dialog.getTask();
|
||||
t->update(editedTask);
|
||||
updateTaskRow(item, editedTask);
|
||||
save();
|
||||
redrawBoardStatus();
|
||||
if (selectedFilterIndex > -1)
|
||||
{
|
||||
Task editedTask = dialog.getTask();
|
||||
t->update(editedTask);
|
||||
updateTaskRow(item, editedTask);
|
||||
save();
|
||||
redrawTaskTree();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,14 +278,22 @@ void MainWindow::onEditTask(QTreeWidgetItem *item)
|
||||
|
||||
void MainWindow::onRemoveBoardMenu()
|
||||
{
|
||||
if (selectedBoardIndex > -1)
|
||||
if (menuSelectedBoardItem != nullptr)
|
||||
{
|
||||
int i = ui->boardList->indexFromItem(menuSelectedBoardItem).row();
|
||||
if (i == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
QMessageBox::StandardButton result = QMessageBox::question(this, "Delete a board", "Do you want to delete this board?");
|
||||
if (result == QMessageBox::Yes)
|
||||
{
|
||||
boards.removeAt(selectedBoardIndex);
|
||||
delete ui->boardList->takeItem(selectedBoardIndex);
|
||||
selectedBoardIndex = -1;
|
||||
boards.removeAt(i);
|
||||
delete ui->boardList->takeItem(i);
|
||||
if (selectedBoardIndex == i)
|
||||
{
|
||||
selectedBoardIndex = -1;
|
||||
}
|
||||
redrawTaskTree();
|
||||
save();
|
||||
}
|
||||
@@ -208,18 +316,79 @@ void MainWindow::onRemoveTaskMenu()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onRemoveFilterMenu()
|
||||
{
|
||||
if (menuSelectedFilterItem != nullptr)
|
||||
{
|
||||
int i = ui->filterListWidget->indexFromItem(menuSelectedFilterItem).row();
|
||||
if (i == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
QMessageBox::StandardButton result = QMessageBox::question(this, "Delete a filter", "Do you want to delete this filter?");
|
||||
if (result == QMessageBox::Yes)
|
||||
{
|
||||
filters.removeAt(i);
|
||||
delete ui->filterListWidget->takeItem(i);
|
||||
if (selectedFilterIndex == i)
|
||||
{
|
||||
selectedFilterIndex = -1;
|
||||
}
|
||||
redrawTaskTree();
|
||||
save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onEditNameBoardMenu()
|
||||
{
|
||||
if (selectedBoardIndex > -1)
|
||||
if (menuSelectedBoardItem != nullptr)
|
||||
{
|
||||
Board *b = boards.at(selectedBoardIndex);
|
||||
NameDialog dialog("Edit board name", b->getName(), this);
|
||||
int i = ui->boardList->indexFromItem(menuSelectedBoardItem).row();
|
||||
if (i == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Board *b = boards.at(i);
|
||||
BoardConfigDialog dialog(b, this);
|
||||
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
||||
{
|
||||
QString newName= dialog.getChoosenName();
|
||||
QString newName = dialog.getName();
|
||||
QString newDesc = dialog.getDescription();
|
||||
b->setName(newName);
|
||||
ui->boardList->item(selectedBoardIndex)->setText(newName);
|
||||
b->setDescription(newDesc);
|
||||
b->setShowingStatus(dialog.isShowingStatus());
|
||||
if (!dialog.isAutoStatus())
|
||||
{
|
||||
std::optional<Status> status = TaskStateService::getInstance()->getStatusByUUID(dialog.getStatus());
|
||||
if (status.has_value())
|
||||
{
|
||||
b->setDirtyStatus(status.value());
|
||||
}
|
||||
else
|
||||
{
|
||||
b->removeDirtyStatus();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
b->removeDirtyStatus();
|
||||
}
|
||||
QListWidgetItem *item = ui->boardList->item(i);
|
||||
item->setText(newName);
|
||||
item->setToolTip(newDesc);
|
||||
ui->label->setText(newName);
|
||||
if (newDesc.length() > 0)
|
||||
{
|
||||
ui->boardDescription->setText(newDesc);
|
||||
ui->boardDescription->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->boardDescription->setText("No description");
|
||||
ui->boardDescription->setEnabled(false);
|
||||
}
|
||||
redrawBoardStatus();
|
||||
save();
|
||||
}
|
||||
}
|
||||
@@ -227,12 +396,66 @@ void MainWindow::onEditNameBoardMenu()
|
||||
|
||||
void MainWindow::onEditNameTaskMenu()
|
||||
{
|
||||
if (selectedBoardIndex > -1 && ui->taskList->selectedItems().length() == 1)
|
||||
Task *t = getSelectedTask();
|
||||
if (t != nullptr)
|
||||
{
|
||||
onEditTask(ui->taskList->currentItem());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onEditFilterMenu()
|
||||
{
|
||||
if (menuSelectedFilterItem != nullptr)
|
||||
{
|
||||
int i = ui->filterListWidget->indexFromItem(menuSelectedFilterItem).row();
|
||||
Filter f = filters[i];
|
||||
FilterDialog dialog("Edit the filter", f, boards, this);
|
||||
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
||||
{
|
||||
Filter f = dialog.getFilter();
|
||||
filters[selectedFilterIndex] = f;
|
||||
QListWidgetItem *item = ui->filterListWidget->item(selectedFilterIndex);
|
||||
item->setText(f.getName());
|
||||
item->setToolTip(f.getDescription());
|
||||
ui->label->setText(f.getName());
|
||||
if (f.getDescription().length() > 0)
|
||||
{
|
||||
ui->boardDescription->setText(f.getDescription());
|
||||
ui->boardDescription->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->boardDescription->setText("No description");
|
||||
ui->boardDescription->setEnabled(false);
|
||||
}
|
||||
redrawTaskTree();
|
||||
save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::prepareFilterMenu(const QPoint &pos)
|
||||
{
|
||||
QMenu menu(this);
|
||||
this->menuSelectedFilterItem = ui->filterListWidget->itemAt(pos);
|
||||
if (this->menuSelectedFilterItem != nullptr) {
|
||||
QAction *renameAction = new QAction(tr("Edit the filter"), this);
|
||||
connect(renameAction, &QAction::triggered, this, &MainWindow::onEditFilterMenu);
|
||||
menu.addAction(renameAction);
|
||||
|
||||
QAction *deleteAction = new QAction(tr("Delete"), this);
|
||||
connect(deleteAction, &QAction::triggered, this, &MainWindow::onRemoveFilterMenu);
|
||||
menu.addAction(deleteAction);
|
||||
|
||||
menu.addSeparator();
|
||||
}
|
||||
QAction *addAction = new QAction(tr("New filter"), this);
|
||||
connect(addAction, &QAction::triggered, this, &MainWindow::onNewFilterClick);
|
||||
menu.addAction(addAction);
|
||||
|
||||
menu.exec(ui->filterListWidget->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void MainWindow::init()
|
||||
{
|
||||
if (Tools::isSaveFileExist())
|
||||
@@ -244,93 +467,87 @@ void MainWindow::init()
|
||||
QJsonArray jsonPriorities = save[PRIORITIES_KEY].toArray();
|
||||
QJsonArray jsonStatus = save[STATUS_KEY].toArray();
|
||||
QJsonArray jsonBoards = save[BOARDS_KEY].toArray();
|
||||
for (QJsonValueRef value : jsonPriorities) {
|
||||
QJsonArray jsonFilters = save[FILTERS_KEY].toArray();
|
||||
QVector<Priority> priorities;
|
||||
QVector<Status> statuses;
|
||||
for (QJsonValueRef value : jsonPriorities)
|
||||
{
|
||||
priorities.append(Priority(value.toObject()));
|
||||
}
|
||||
for (QJsonValueRef value : jsonStatus) {
|
||||
status.append(Status(value.toObject()));
|
||||
for (QJsonValueRef value : jsonStatus)
|
||||
{
|
||||
statuses.append(Status(value.toObject()));
|
||||
}
|
||||
for (QJsonValueRef value : jsonBoards) {
|
||||
for (QJsonValueRef value : jsonBoards)
|
||||
{
|
||||
boards.append(new Board(value.toObject()));
|
||||
}
|
||||
for (QJsonValueRef value : jsonFilters)
|
||||
{
|
||||
filters.append(Filter(value.toObject()));
|
||||
}
|
||||
TaskStateService::getInstance()->updatePriorities(priorities);
|
||||
TaskStateService::getInstance()->updateStatuses(statuses);
|
||||
QString defaultStatusUUID = save[DEFAULT_STATUS].toString("");
|
||||
for (Status s : TaskStateService::getInstance()->getStatuses())
|
||||
{
|
||||
if (s.getUUID() == defaultStatusUUID)
|
||||
{
|
||||
TaskStateService::getInstance()->setDefaultStatus(s);
|
||||
}
|
||||
}
|
||||
redrawFilterList();
|
||||
redrawBoardList();
|
||||
return;
|
||||
}
|
||||
}
|
||||
this->priorities = defaultPriorities();
|
||||
this->status = defaultStatus();
|
||||
save();
|
||||
}
|
||||
|
||||
QVector<Priority> MainWindow::defaultPriorities()
|
||||
QVector<Filter> MainWindow::defaultFilters()
|
||||
{
|
||||
QVector<Priority> res;
|
||||
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "None", QColor("#d9d9d9")));
|
||||
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "Low", QColor("#309db0")));
|
||||
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "Medium", QColor("#b08e30")));
|
||||
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "High", QColor("#b04330")));
|
||||
return res;
|
||||
}
|
||||
|
||||
QVector<Status> MainWindow::defaultStatus()
|
||||
{
|
||||
QVector<Status> res;
|
||||
res.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "To Do", QColor("#8f8f8f")));
|
||||
res.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "Working on", QColor("#5f30b0")));
|
||||
res.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "Completed", QColor("#30b049")));
|
||||
QVector<Filter> res;
|
||||
return res;
|
||||
}
|
||||
|
||||
const QString MainWindow::getPriorityLabel(QString uuid)
|
||||
{
|
||||
QString res = "";
|
||||
foreach (Priority p, priorities)
|
||||
std::optional<Priority> p = TaskStateService::getInstance()->getPriorityByUUID(uuid);
|
||||
if (p.has_value())
|
||||
{
|
||||
if (p.getUUID() == uuid)
|
||||
{
|
||||
res = p.getName();
|
||||
}
|
||||
return p.value().getName();
|
||||
}
|
||||
return res;
|
||||
return "";
|
||||
}
|
||||
|
||||
const QString MainWindow::getStatusLabel(QString uuid)
|
||||
{
|
||||
QString res = "";
|
||||
foreach (Status s, status)
|
||||
std::optional<Status> s = TaskStateService::getInstance()->getStatusByUUID(uuid);
|
||||
if (s.has_value())
|
||||
{
|
||||
if (s.getUUID() == uuid)
|
||||
{
|
||||
res = s.getName();
|
||||
}
|
||||
return s.value().getName();
|
||||
}
|
||||
return res;
|
||||
return "";
|
||||
}
|
||||
|
||||
const QColor MainWindow::getPriorityColor(QString uuid, QColor defaultColor)
|
||||
{
|
||||
QColor color = defaultColor;
|
||||
foreach (Priority p, priorities)
|
||||
std::optional<Priority> p = TaskStateService::getInstance()->getPriorityByUUID(uuid);
|
||||
if (p.has_value())
|
||||
{
|
||||
if (p.getUUID() == uuid)
|
||||
{
|
||||
color = p.getColor();
|
||||
}
|
||||
return p.value().getColor();
|
||||
}
|
||||
return color;
|
||||
return defaultColor;
|
||||
}
|
||||
|
||||
const QColor MainWindow::getStatusColor(QString uuid, QColor defaultColor)
|
||||
{
|
||||
QColor color = defaultColor;
|
||||
foreach (Status s, status)
|
||||
std::optional<Status> s = TaskStateService::getInstance()->getStatusByUUID(uuid);
|
||||
if (s.has_value())
|
||||
{
|
||||
if (s.getUUID() == uuid)
|
||||
{
|
||||
color = s.getColor();
|
||||
}
|
||||
return s.value().getColor();
|
||||
}
|
||||
return color;
|
||||
return defaultColor;
|
||||
}
|
||||
|
||||
const QJsonDocument MainWindow::getJsonSave()
|
||||
@@ -338,30 +555,89 @@ const QJsonDocument MainWindow::getJsonSave()
|
||||
QJsonDocument doc;
|
||||
QJsonObject obj;
|
||||
QJsonArray jsonPriorities;
|
||||
foreach (Priority p, this->priorities) {
|
||||
QJsonArray jsonStatus;
|
||||
QJsonArray jsonBoards;
|
||||
QJsonArray jsonFilters;
|
||||
|
||||
QVector<Priority> priorities = TaskStateService::getInstance()->getPriorities();
|
||||
foreach (Priority p, priorities) {
|
||||
jsonPriorities.append(p.toJson());
|
||||
}
|
||||
QJsonArray jsonStatus;
|
||||
foreach (Status s, this->status) {
|
||||
|
||||
QVector<Status> statuses = TaskStateService::getInstance()->getStatuses();
|
||||
foreach (Status s, statuses) {
|
||||
jsonStatus.append(s.toJson());
|
||||
}
|
||||
QJsonArray jsonBoards;
|
||||
|
||||
foreach (Board *b, this->boards) {
|
||||
jsonBoards.append(b->toJson());
|
||||
}
|
||||
|
||||
foreach (Filter f, this->filters)
|
||||
{
|
||||
jsonFilters.append(f.toJson());
|
||||
}
|
||||
obj[PRIORITIES_KEY] = jsonPriorities;
|
||||
obj[STATUS_KEY] = jsonStatus;
|
||||
obj[BOARDS_KEY] = jsonBoards;
|
||||
obj[FILTERS_KEY] = jsonFilters;
|
||||
obj[DEFAULT_STATUS] = TaskStateService::getInstance()->getDefaultStatus().getUUID();
|
||||
doc.setObject(obj);
|
||||
return doc;
|
||||
}
|
||||
|
||||
Task *MainWindow::getSelectedTask()
|
||||
{
|
||||
|
||||
QList<QTreeWidgetItem*> items = ui->taskList->selectedItems();
|
||||
if (items.count() != 1)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
if (selectedBoardIndex > -1)
|
||||
{
|
||||
Board *b = boards[selectedBoardIndex];
|
||||
int16_t i = ui->taskList->indexOfTopLevelItem(items[0]);
|
||||
return b->taskAt(i);
|
||||
}
|
||||
else if (selectedFilterIndex > -1)
|
||||
{
|
||||
if (!filterResult.empty())
|
||||
{
|
||||
int16_t i = ui->taskList->indexOfTopLevelItem(items[0]);
|
||||
return filterResult[i];
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MainWindow::updateTaskRow(QTreeWidgetItem *item, Task t)
|
||||
{
|
||||
item->setText(0, t.getTitle());
|
||||
item->setToolTip(0, t.getDescription());
|
||||
item->setText(3, t.getExpectedFor().toString());
|
||||
|
||||
if (t.getExpectedFor() < QDate::currentDate())
|
||||
{
|
||||
QBrush fgColor = item->foreground(3);
|
||||
fgColor.setColor(QColor(176, 67, 48));
|
||||
fgColor.setStyle(Qt::BrushStyle::SolidPattern);
|
||||
item->setForeground(3, fgColor);
|
||||
}
|
||||
else if (t.getExpectedFor() == QDate::currentDate())
|
||||
{
|
||||
QBrush fgColor = item->foreground(3);
|
||||
fgColor.setColor(QColor(176, 142, 48));
|
||||
fgColor.setStyle(Qt::BrushStyle::SolidPattern);
|
||||
item->setForeground(3, fgColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
QBrush fgColor = item->foreground(3);
|
||||
fgColor.setStyle(Qt::BrushStyle::NoBrush);
|
||||
item->setForeground(3, fgColor);
|
||||
}
|
||||
|
||||
if (!t.getStatusUUID().isEmpty())
|
||||
{
|
||||
item->setText(1, getStatusLabel(t.getStatusUUID()));
|
||||
@@ -401,6 +677,23 @@ void MainWindow::redrawBoardList()
|
||||
foreach (Board *b, boards)
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem(b->getName());
|
||||
item->setToolTip(b->getDescription());
|
||||
l->addItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::redrawFilterList()
|
||||
{
|
||||
QListWidget *l = ui->filterListWidget;
|
||||
uint16_t itemCount = l->count();
|
||||
for (int16_t i = itemCount; i >= 0; i--)
|
||||
{
|
||||
delete l->takeItem(i);
|
||||
}
|
||||
foreach (Filter f, filters)
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem(f.getName());
|
||||
item->setToolTip(f.getDescription());
|
||||
l->addItem(item);
|
||||
}
|
||||
}
|
||||
@@ -409,6 +702,10 @@ void MainWindow::redrawTaskTree()
|
||||
{
|
||||
QTreeWidget *l = ui->taskList;
|
||||
uint16_t itemCount = l->topLevelItemCount();
|
||||
if (itemCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int16_t i = itemCount; i >= 0; i--)
|
||||
{
|
||||
delete l->takeTopLevelItem(i);
|
||||
@@ -416,6 +713,13 @@ void MainWindow::redrawTaskTree()
|
||||
if (selectedBoardIndex > -1)
|
||||
{
|
||||
Board *b = boards[selectedBoardIndex];
|
||||
std::optional<Status> boardStatus = TaskStateService::getInstance()->getStatusByUUID(b->getStatus());
|
||||
if (boardStatus.has_value())
|
||||
{
|
||||
ui->boardStatus->setStyleSheet(Tools::getStatusLabelStylesheet(boardStatus.value()));
|
||||
ui->boardStatus->setText(boardStatus.value().getName());
|
||||
ui->boardStatus->setVisible(true);
|
||||
}
|
||||
foreach (Task *t, b->getTasks())
|
||||
{
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
@@ -423,7 +727,37 @@ void MainWindow::redrawTaskTree()
|
||||
ui->taskList->addTopLevelItem(item);
|
||||
}
|
||||
}
|
||||
else if (selectedFilterIndex > -1)
|
||||
{
|
||||
Filter f = filters[selectedFilterIndex];
|
||||
filterResult = f.filter(boards);
|
||||
foreach (Task *t, filterResult)
|
||||
{
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
updateTaskRow(item, *t);
|
||||
ui->taskList->addTopLevelItem(item);
|
||||
}
|
||||
}
|
||||
redrawBoardStatus();
|
||||
}
|
||||
|
||||
void MainWindow::redrawBoardStatus()
|
||||
{
|
||||
ui->boardStatus->setVisible(false);
|
||||
if (selectedBoardIndex > -1)
|
||||
{
|
||||
Board *b = boards[selectedBoardIndex];
|
||||
if (b->isShowingStatus())
|
||||
{
|
||||
std::optional<Status> boardStatus = TaskStateService::getInstance()->getStatusByUUID(b->getStatus());
|
||||
if (boardStatus.has_value())
|
||||
{
|
||||
ui->boardStatus->setStyleSheet(Tools::getStatusLabelStylesheet(boardStatus.value()));
|
||||
ui->boardStatus->setText(boardStatus.value().getName());
|
||||
ui->boardStatus->setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::save()
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QListWidgetItem>
|
||||
#include <QBrush>
|
||||
#include <QJsonDocument>
|
||||
|
||||
#include "../models/priority.h"
|
||||
#include "../models/status.h"
|
||||
#include "../models/board.h"
|
||||
#include "../models/filter.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
@@ -27,12 +29,17 @@ private slots:
|
||||
void openAbout();
|
||||
void onNewBoardClick();
|
||||
void onNewTaskClick();
|
||||
void onNewFilterClick();
|
||||
void onBoardSelected(int i);
|
||||
void onFilterSelected(int i);
|
||||
void onEditTask(QTreeWidgetItem*);
|
||||
void onRemoveBoardMenu();
|
||||
void onRemoveTaskMenu();
|
||||
void onRemoveFilterMenu();
|
||||
void onEditNameBoardMenu();
|
||||
void onEditNameTaskMenu();
|
||||
void onEditFilterMenu();
|
||||
void prepareFilterMenu(const QPoint &pos);
|
||||
void prepareBoardMenu(const QPoint &pos);
|
||||
void prepareTaskMenu(const QPoint &pos);
|
||||
|
||||
@@ -41,13 +48,25 @@ private:
|
||||
|
||||
void init();
|
||||
|
||||
// properties
|
||||
|
||||
int16_t selectedBoardIndex;
|
||||
QVector<Priority> priorities;
|
||||
QVector<Status> status;
|
||||
int16_t selectedFilterIndex;
|
||||
|
||||
QListWidgetItem *menuSelectedFilterItem;
|
||||
QListWidgetItem *menuSelectedBoardItem;
|
||||
QTreeWidgetItem *menuSelectedTaskItem;
|
||||
|
||||
QVector<Task*> filterResult;
|
||||
|
||||
QVector<Board*> boards;
|
||||
QVector<Filter> filters;
|
||||
|
||||
// functions
|
||||
|
||||
QVector<Priority> defaultPriorities();
|
||||
QVector<Status> defaultStatus();
|
||||
QVector<Filter> defaultFilters();
|
||||
|
||||
const QString getPriorityLabel(QString uuid);
|
||||
const QString getStatusLabel(QString uuid);
|
||||
@@ -57,9 +76,13 @@ private:
|
||||
|
||||
const QJsonDocument getJsonSave();
|
||||
|
||||
Task *getSelectedTask();
|
||||
|
||||
void updateTaskRow(QTreeWidgetItem *item, Task t);
|
||||
void redrawBoardList();
|
||||
void redrawFilterList();
|
||||
void redrawTaskTree();
|
||||
void redrawBoardStatus();
|
||||
void save();
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
@@ -24,40 +24,127 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<item row="4" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="boardList">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Filters</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="filterListWidget">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>250</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Boards</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="boardList">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>26</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><- Select a board</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>19</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>No board selected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="boardDescription">
|
||||
<property name="text">
|
||||
<string>Create or select a board to start</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="boardStatus">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-color: rgb(87, 227, 137);
|
||||
border: solid;
|
||||
background-color: rgb(87, 227, 137);
|
||||
border-radius: 4px;
|
||||
color: white;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="taskList">
|
||||
@@ -101,7 +188,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1159</width>
|
||||
<height>24</height>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuAbout">
|
||||
@@ -117,6 +204,7 @@
|
||||
<string>Board</string>
|
||||
</property>
|
||||
<addaction name="actionNew"/>
|
||||
<addaction name="actionNew_filter"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuTask">
|
||||
<property name="title">
|
||||
@@ -128,15 +216,49 @@
|
||||
<addaction name="menuTask"/>
|
||||
<addaction name="menuAbout"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
<property name="floatable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionNew"/>
|
||||
<addaction name="actionNew_task"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionNew_filter"/>
|
||||
</widget>
|
||||
<action name="actionPreferences">
|
||||
<property name="text">
|
||||
<string>Preferences</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNew">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources.qrc">
|
||||
<normaloff>:/images/resources/board_add.png</normaloff>:/images/resources/board_add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New Board</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+N, Ctrl+B</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
<property name="text">
|
||||
@@ -147,11 +269,32 @@
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources.qrc">
|
||||
<normaloff>:/images/resources/task_add.png</normaloff>:/images/resources/task_add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New task</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+N, Ctrl+T</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNew_filter">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources.qrc">
|
||||
<normaloff>:/images/resources/add_filter.png</normaloff>:/images/resources/add_filter.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New filter</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+N, Ctrl+F</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "namedialog.h"
|
||||
#include "ui_namedialog.h"
|
||||
|
||||
NameDialog::NameDialog(QString label, QString defaultName, QWidget *parent) :
|
||||
NameDialog::NameDialog(QString label, QString defaultName, QString description, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::NameDialog)
|
||||
{
|
||||
@@ -9,6 +9,7 @@ NameDialog::NameDialog(QString label, QString defaultName, QWidget *parent) :
|
||||
this->setWindowTitle(label);
|
||||
this->defaultName = defaultName;
|
||||
ui->lineEdit->setText(defaultName);
|
||||
ui->descriptionTextEdit->setPlainText(description);
|
||||
}
|
||||
|
||||
NameDialog::~NameDialog()
|
||||
@@ -24,3 +25,10 @@ const QString NameDialog::getChoosenName()
|
||||
}
|
||||
return defaultName;
|
||||
}
|
||||
|
||||
const QString NameDialog::getDescription()
|
||||
{
|
||||
return ui->descriptionTextEdit->toPlainText();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,9 +12,10 @@ class NameDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NameDialog(QString label, QString defaultName, QWidget *parent = nullptr);
|
||||
explicit NameDialog(QString label, QString defaultName, QString description, QWidget *parent = nullptr);
|
||||
~NameDialog();
|
||||
const QString getChoosenName();
|
||||
const QString getDescription();
|
||||
|
||||
private:
|
||||
Ui::NameDialog *ui;
|
||||
|
||||
@@ -10,19 +10,19 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>133</height>
|
||||
<height>227</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>133</height>
|
||||
<height>227</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>133</height>
|
||||
<height>227</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -34,8 +34,8 @@
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>90</y>
|
||||
<x>50</x>
|
||||
<y>190</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
@@ -51,7 +51,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>50</y>
|
||||
<y>33</y>
|
||||
<width>381</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
@@ -61,7 +61,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<y>13</y>
|
||||
<width>58</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
@@ -70,6 +70,29 @@
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>181</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPlainTextEdit" name="descriptionTextEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>90</y>
|
||||
<width>381</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
||||
@@ -5,21 +5,25 @@
|
||||
#include <QUuid>
|
||||
|
||||
#include "../tools.h"
|
||||
#include "../services/taskstateservice.h"
|
||||
|
||||
PrefDialog::PrefDialog(QVector<Status> status, QVector<Priority> priorities, QWidget *parent) :
|
||||
PrefDialog::PrefDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::PrefDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QVector<Status> status = TaskStateService::getInstance()->getStatuses();
|
||||
foreach (Status s, status)
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem(s.getName());
|
||||
statusUUIDRef.append(s.getUUID());
|
||||
setItemColor(item, s.getColor());
|
||||
ui->statusListWidget->addItem(item);
|
||||
ui->defaultStatusCombobox->addItem(s.getName(), s.getUUID());
|
||||
}
|
||||
|
||||
QVector<Priority> priorities = TaskStateService::getInstance()->getPriorities();
|
||||
foreach (Priority p, priorities)
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem(p.getName());
|
||||
@@ -28,6 +32,8 @@ PrefDialog::PrefDialog(QVector<Status> status, QVector<Priority> priorities, QWi
|
||||
ui->priorityListWidget->addItem(item);
|
||||
}
|
||||
|
||||
ui->defaultStatusCombobox->setCurrentText(TaskStateService::getInstance()->getDefaultStatus().getName());
|
||||
|
||||
connect(ui->addStatusButton, &QPushButton::clicked, this, &PrefDialog::onAddStatusButtonClick);
|
||||
connect(ui->addPriorityButton, &QPushButton::clicked, this, &PrefDialog::onAddPriorityButtonClick);
|
||||
connect(ui->statusListWidget, &QListWidget::currentRowChanged, this, &PrefDialog::onItemSelectionChange);
|
||||
@@ -38,6 +44,8 @@ PrefDialog::PrefDialog(QVector<Status> status, QVector<Priority> priorities, QWi
|
||||
connect(ui->namePriorityEdit, &QLineEdit::textEdited, this, &PrefDialog::onNameChange);
|
||||
connect(ui->removeStatusButton, &QPushButton::clicked, this, &PrefDialog::onRemoveStatusButtonClick);
|
||||
connect(ui->removePriorityButton, &QPushButton::clicked, this, &PrefDialog::onRemovePriorityButtonClick);
|
||||
connect(ui->upStatus, &QPushButton::clicked, this, &PrefDialog::onUpStatusButtonClick);
|
||||
connect(ui->downStatus, &QPushButton::clicked, this, &PrefDialog::onDownStatusButtonClick);
|
||||
}
|
||||
|
||||
PrefDialog::~PrefDialog()
|
||||
@@ -75,6 +83,24 @@ QVector<Status> PrefDialog::getStatus()
|
||||
return res;
|
||||
}
|
||||
|
||||
Status PrefDialog::getDefaultStatus()
|
||||
{
|
||||
QVector<Status> status = TaskStateService::getInstance()->getStatuses();
|
||||
QString uuid = ui->defaultStatusCombobox->currentData().toString();
|
||||
for (Status s : status)
|
||||
{
|
||||
if (uuid == s.getUUID())
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
if (status.count() > 0)
|
||||
{
|
||||
return status[0];
|
||||
}
|
||||
return Status("", "", QColor::fromRgb(0, 0, 0));
|
||||
}
|
||||
|
||||
void PrefDialog::onAddStatusButtonClick()
|
||||
{
|
||||
QColor bgColor = Tools::getRandomColor();
|
||||
@@ -113,6 +139,16 @@ void PrefDialog::onItemSelectionChange(int index)
|
||||
colorBtn = ui->colorStatusButton;
|
||||
nameEdit = ui->nameStatusEdit;
|
||||
colorEdit = ui->colorStatusEdit;
|
||||
if (index > -1)
|
||||
{
|
||||
ui->downStatus->setEnabled((index > 0));
|
||||
ui->upStatus->setEnabled((index < statusUUIDRef.size()-1));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->downStatus->setEnabled(false);
|
||||
ui->upStatus->setEnabled(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -208,6 +244,46 @@ void PrefDialog::onRemovePriorityButtonClick()
|
||||
priorityUUIDRef.removeAt(index);
|
||||
}
|
||||
|
||||
void PrefDialog::onUpStatusButtonClick()
|
||||
{
|
||||
if (ui->statusListWidget->selectedItems().size() != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int i = ui->statusListWidget->indexFromItem(ui->statusListWidget->selectedItems()[0]).row();
|
||||
if (i < statusUUIDRef.size())
|
||||
{
|
||||
QListWidgetItem *item = ui->statusListWidget->takeItem(i);
|
||||
i++;
|
||||
ui->statusListWidget->insertItem(i, item);
|
||||
statusUUIDRef.move(i-1, i);
|
||||
|
||||
ui->downStatus->setEnabled((i > 0));
|
||||
ui->upStatus->setEnabled((i < statusUUIDRef.size()-1));
|
||||
ui->statusListWidget->setCurrentRow(i);
|
||||
}
|
||||
}
|
||||
|
||||
void PrefDialog::onDownStatusButtonClick()
|
||||
{
|
||||
if (ui->statusListWidget->selectedItems().size() != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int i = ui->statusListWidget->indexFromItem(ui->statusListWidget->selectedItems()[0]).row();
|
||||
if (i > 0)
|
||||
{
|
||||
QListWidgetItem *item = ui->statusListWidget->takeItem(i);
|
||||
i--;
|
||||
ui->statusListWidget->insertItem(i, item);
|
||||
statusUUIDRef.move(i+1, i);
|
||||
|
||||
ui->downStatus->setEnabled((i > 0));
|
||||
ui->upStatus->setEnabled((i < statusUUIDRef.size()-1));
|
||||
ui->statusListWidget->setCurrentRow(i);
|
||||
}
|
||||
}
|
||||
|
||||
void PrefDialog::setItemColor(QListWidgetItem *item, QColor bgColor)
|
||||
{
|
||||
QColor fgColor = Tools::getForegroundColor(bgColor);
|
||||
|
||||
@@ -17,11 +17,12 @@ class PrefDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PrefDialog(QVector<Status> status, QVector<Priority> priorities, QWidget *parent = nullptr);
|
||||
explicit PrefDialog(QWidget *parent = nullptr);
|
||||
~PrefDialog();
|
||||
|
||||
QVector<Priority> getPriorities();
|
||||
QVector<Status> getStatus();
|
||||
Status getDefaultStatus();
|
||||
|
||||
private slots:
|
||||
void onAddStatusButtonClick();
|
||||
@@ -31,7 +32,8 @@ private slots:
|
||||
void onNameChange();
|
||||
void onRemoveStatusButtonClick();
|
||||
void onRemovePriorityButtonClick();
|
||||
|
||||
void onUpStatusButtonClick();
|
||||
void onDownStatusButtonClick();
|
||||
private:
|
||||
Ui::PrefDialog *ui;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<class>PrefDialog</class>
|
||||
<widget class="QDialog" name="PrefDialog">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::ApplicationModal</enum>
|
||||
<enum>Qt::WindowModality::ApplicationModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@@ -41,10 +41,10 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
@@ -66,10 +66,10 @@
|
||||
<widget class="QListWidget" name="statusListWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>601</width>
|
||||
<height>291</height>
|
||||
<x>40</x>
|
||||
<y>64</y>
|
||||
<width>571</width>
|
||||
<height>161</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -80,7 +80,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>350</y>
|
||||
<y>290</y>
|
||||
<width>521</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
@@ -90,7 +90,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>352</y>
|
||||
<y>292</y>
|
||||
<width>58</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
@@ -103,7 +103,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>390</y>
|
||||
<y>330</y>
|
||||
<width>58</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
@@ -119,7 +119,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>390</y>
|
||||
<y>330</y>
|
||||
<width>113</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
@@ -135,7 +135,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>390</y>
|
||||
<y>330</y>
|
||||
<width>26</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -148,9 +148,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>570</x>
|
||||
<y>310</y>
|
||||
<y>240</y>
|
||||
<width>41</width>
|
||||
<height>32</height>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -164,7 +164,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>520</x>
|
||||
<y>310</y>
|
||||
<y>240</y>
|
||||
<width>41</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
@@ -173,6 +173,138 @@
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="downStatus">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>240</y>
|
||||
<width>51</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Down</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="upStatus">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>240</y>
|
||||
<width>51</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Up</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>11</x>
|
||||
<y>4</y>
|
||||
<width>601</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Sort status by display priority. The lowest status will only be displayed if higher statuses are not assigned to the board.</p></body></html></string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>79</y>
|
||||
<width>20</width>
|
||||
<height>121</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>60</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Low</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>204</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>High</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>360</y>
|
||||
<width>591</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>390</y>
|
||||
<width>141</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default (for new task)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="defaultStatusCombobox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>440</x>
|
||||
<y>384</y>
|
||||
<width>171</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
|
||||
@@ -3,48 +3,29 @@
|
||||
|
||||
#include <QDate>
|
||||
|
||||
TaskDialog::TaskDialog(QVector<Status> status, QVector<Priority> priorities, QWidget *parent) :
|
||||
#include "../services/taskstateservice.h"
|
||||
|
||||
TaskDialog::TaskDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::TaskDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
init();
|
||||
this->setWindowTitle("New task");
|
||||
this->status = status;
|
||||
this->priorities = priorities;
|
||||
|
||||
foreach (Status s, this->status)
|
||||
{
|
||||
ui->statusCombo->addItem(s.getName());
|
||||
}
|
||||
|
||||
foreach (Priority p, this->priorities)
|
||||
{
|
||||
ui->priorityCombo->addItem(p.getName());
|
||||
}
|
||||
|
||||
QDate expectedFor = QDate::currentDate();
|
||||
expectedFor = expectedFor.addDays(10);
|
||||
ui->expectedForEdit->setDate(expectedFor);
|
||||
ui->statusCombo->setCurrentText(TaskStateService::getInstance()->getDefaultStatus().getName());
|
||||
}
|
||||
|
||||
TaskDialog::TaskDialog(Task *t, QVector<Status> status, QVector<Priority> priorities, QWidget *parent) :
|
||||
TaskDialog::TaskDialog(Task *t, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::TaskDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
init();
|
||||
this->setWindowTitle("Edit task");
|
||||
this->status = status;
|
||||
this->priorities = priorities;
|
||||
|
||||
foreach (Status s, this->status)
|
||||
{
|
||||
ui->statusCombo->addItem(s.getName());
|
||||
}
|
||||
|
||||
foreach (Priority p, this->priorities)
|
||||
{
|
||||
ui->priorityCombo->addItem(p.getName());
|
||||
}
|
||||
|
||||
// set fields
|
||||
ui->nameEdit->setText(t->getTitle());
|
||||
@@ -53,34 +34,12 @@ TaskDialog::TaskDialog(Task *t, QVector<Status> status, QVector<Priority> priori
|
||||
|
||||
if (t->getPriorityUUID().length() > 0)
|
||||
{
|
||||
int16_t refindex = -1;
|
||||
for (uint16_t i = 0; i < this->priorities.count(); i++)
|
||||
{
|
||||
if (this->priorities[i].getUUID() == t->getPriorityUUID())
|
||||
{
|
||||
refindex = i;
|
||||
}
|
||||
}
|
||||
if (refindex > -1)
|
||||
{
|
||||
ui->priorityCombo->setCurrentIndex(refindex);
|
||||
}
|
||||
initSelectionCombobox(t->getPriorityUUID(), ui->priorityCombo);
|
||||
}
|
||||
|
||||
if (t->getStatusUUID().length() > 0)
|
||||
{
|
||||
int16_t refindex = -1;
|
||||
for (uint16_t i = 0; i < this->status.count(); i++)
|
||||
{
|
||||
if (this->status[i].getUUID() == t->getStatusUUID())
|
||||
{
|
||||
refindex = i;
|
||||
}
|
||||
}
|
||||
if (refindex > -1)
|
||||
{
|
||||
ui->statusCombo->setCurrentIndex(refindex);
|
||||
}
|
||||
initSelectionCombobox(t->getStatusUUID(), ui->statusCombo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -96,16 +55,42 @@ Task TaskDialog::getTask()
|
||||
QString description = ui->descriptionEdit->toMarkdown(QTextDocument::MarkdownFeature::MarkdownDialectCommonMark);
|
||||
QDate expectedFor = ui->expectedForEdit->date();
|
||||
QString priorityUUID = "";
|
||||
if (ui->priorityCombo->currentIndex() > -1)
|
||||
if (!ui->priorityCombo->currentData().isNull())
|
||||
{
|
||||
Priority priority = priorities[ui->priorityCombo->currentIndex()];
|
||||
priorityUUID = priority.getUUID();
|
||||
priorityUUID = ui->priorityCombo->currentData().toString();
|
||||
}
|
||||
QString statusUUID = "";
|
||||
if (ui->statusCombo->currentIndex() > -1)
|
||||
if (!ui->statusCombo->currentData().isNull())
|
||||
{
|
||||
Status s = status[ui->statusCombo->currentIndex()];
|
||||
statusUUID = s.getUUID();
|
||||
statusUUID = ui->statusCombo->currentData().toString();
|
||||
}
|
||||
return Task(title, description, expectedFor, priorityUUID, statusUUID);
|
||||
}
|
||||
|
||||
void TaskDialog::init()
|
||||
{
|
||||
QVector<Status> statuses = TaskStateService::getInstance()->getStatuses();
|
||||
QVector<Priority> priorities = TaskStateService::getInstance()->getPriorities();
|
||||
|
||||
foreach (Status s, statuses)
|
||||
{
|
||||
ui->statusCombo->addItem(s.getName(), s.getUUID());
|
||||
}
|
||||
|
||||
foreach (Priority p, priorities)
|
||||
{
|
||||
ui->priorityCombo->addItem(p.getName(), p.getUUID());
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDialog::initSelectionCombobox(QString uuid, QComboBox *cbx)
|
||||
{
|
||||
for (uint16_t i = 0; i < cbx->count(); i++)
|
||||
{
|
||||
if (cbx->itemData(i).toString() == uuid)
|
||||
{
|
||||
cbx->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QVector>
|
||||
#include <QComboBox>
|
||||
|
||||
#include "../models/status.h"
|
||||
#include "../models/priority.h"
|
||||
@@ -17,8 +18,8 @@ class TaskDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TaskDialog(QVector<Status>, QVector<Priority>, QWidget *parent = nullptr);
|
||||
TaskDialog(Task*, QVector<Status>, QVector<Priority>, QWidget *parent = nullptr);
|
||||
explicit TaskDialog(QWidget *parent = nullptr);
|
||||
TaskDialog(Task *t, QWidget *parent = nullptr);
|
||||
~TaskDialog();
|
||||
|
||||
Task getTask();
|
||||
@@ -26,8 +27,8 @@ public:
|
||||
private:
|
||||
Ui::TaskDialog *ui;
|
||||
|
||||
QVector<Status> status;
|
||||
QVector<Priority> priorities;
|
||||
void init();
|
||||
void initSelectionCombobox(QString uuid, QComboBox *cbx);
|
||||
};
|
||||
|
||||
#endif // TASKDIALOG_H
|
||||
|
||||
@@ -2,20 +2,37 @@
|
||||
|
||||
#define NAME_KEY "name"
|
||||
#define TASKS_KEY "tasks"
|
||||
#define UUID_KEY "uuid"
|
||||
#define DESCRIPTION_KEY "description"
|
||||
#define AUTOSTATUS_KEY "auto_status"
|
||||
#define STATUS_KEY "status"
|
||||
#define SHOW_STATUS_KEY "show_status"
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonValue>
|
||||
#include <QUuid>
|
||||
|
||||
Board::Board(QString name)
|
||||
#include "../services/taskstateservice.h"
|
||||
|
||||
Board::Board(QString name, QString description)
|
||||
{
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
this->uuid = uuid.toString(QUuid::WithoutBraces);
|
||||
this->name = name;
|
||||
this->description = description;
|
||||
}
|
||||
|
||||
Board::Board(QJsonObject obj)
|
||||
{
|
||||
this->name = obj[NAME_KEY].toString();
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
this->uuid = obj[UUID_KEY].toString(uuid.toString(QUuid::WithoutBraces));
|
||||
this->name = obj[NAME_KEY].toString("!Missing name!");
|
||||
this->description = obj[DESCRIPTION_KEY].toString("");
|
||||
this->autoStatus = obj[AUTOSTATUS_KEY].toBool(true);
|
||||
this->statusUUID = obj[STATUS_KEY].toString();
|
||||
this->showStatus = obj[SHOW_STATUS_KEY].toBool(!this->autoStatus);
|
||||
QJsonArray jsonTasks = obj[TASKS_KEY].toArray();
|
||||
for (QJsonValue value : jsonTasks) {
|
||||
foreach (QJsonValue value, jsonTasks) {
|
||||
Task *t = new Task(value.toObject());
|
||||
this->tasks.append(t);
|
||||
}
|
||||
@@ -30,16 +47,79 @@ Board::~Board()
|
||||
}
|
||||
}
|
||||
|
||||
const QString Board::getUuid()
|
||||
{
|
||||
return uuid;
|
||||
}
|
||||
|
||||
const QString Board::getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
const QString Board::getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
const QString Board::getStatus()
|
||||
{
|
||||
if (autoStatus)
|
||||
{
|
||||
TaskStateService *tss = TaskStateService::getInstance();
|
||||
int16_t h = -1;
|
||||
QString suuid = "";
|
||||
for (Task *t : tasks)
|
||||
{
|
||||
int16_t w = tss->getStatusWeight(t->getStatusUUID());
|
||||
if (w > -1 && h < w)
|
||||
{
|
||||
h = w;
|
||||
suuid = t->getStatusUUID();
|
||||
}
|
||||
}
|
||||
return suuid;
|
||||
}
|
||||
return statusUUID;
|
||||
}
|
||||
|
||||
bool Board::isShowingStatus()
|
||||
{
|
||||
return showStatus;
|
||||
}
|
||||
|
||||
bool Board::isAutoStatus()
|
||||
{
|
||||
return autoStatus;
|
||||
}
|
||||
|
||||
void Board::setName(const QString name)
|
||||
{
|
||||
this->name = name;
|
||||
}
|
||||
|
||||
void Board::setDescription(const QString description)
|
||||
{
|
||||
this->description = description;
|
||||
}
|
||||
|
||||
void Board::setDirtyStatus(Status s)
|
||||
{
|
||||
this->autoStatus = false;
|
||||
this->statusUUID = s.getUUID();
|
||||
}
|
||||
|
||||
void Board::setShowingStatus(bool v)
|
||||
{
|
||||
this->showStatus = v;
|
||||
}
|
||||
|
||||
void Board::removeDirtyStatus()
|
||||
{
|
||||
this->autoStatus = true;
|
||||
this->statusUUID = "";
|
||||
}
|
||||
|
||||
void Board::add(Task t)
|
||||
{
|
||||
tasks.append(new Task(t));
|
||||
@@ -75,7 +155,12 @@ const QJsonObject Board::toJson()
|
||||
}
|
||||
QJsonObject obj;
|
||||
obj[NAME_KEY] = this->name;
|
||||
obj[UUID_KEY] = this->uuid;
|
||||
obj[STATUS_KEY] = this->statusUUID;
|
||||
obj[AUTOSTATUS_KEY] = this->autoStatus;
|
||||
obj[TASKS_KEY] = array;
|
||||
obj[DESCRIPTION_KEY] = description;
|
||||
obj[SHOW_STATUS_KEY] = this->showStatus;
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,18 +6,31 @@
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "task.h"
|
||||
#include "status.h"
|
||||
|
||||
class Board
|
||||
{
|
||||
public:
|
||||
Board(QString name);
|
||||
Board(QString name, QString description);
|
||||
Board(QJsonObject);
|
||||
~Board();
|
||||
|
||||
const QString getUuid();
|
||||
const QString getName();
|
||||
const QString getDescription();
|
||||
const QString getStatus();
|
||||
bool isShowingStatus();
|
||||
bool isAutoStatus();
|
||||
|
||||
void setName(const QString name);
|
||||
void setDescription(const QString description);
|
||||
void setDirtyStatus(Status s);
|
||||
void setShowingStatus(bool);
|
||||
void removeDirtyStatus();
|
||||
|
||||
void add(Task);
|
||||
void remove(uint16_t index);
|
||||
|
||||
Task *taskAt(uint16_t);
|
||||
const QVector<Task*> getTasks();
|
||||
|
||||
@@ -25,7 +38,13 @@ public:
|
||||
|
||||
private:
|
||||
QVector<Task*> tasks;
|
||||
QString uuid;
|
||||
QString name;
|
||||
QString description;
|
||||
|
||||
QString statusUUID;
|
||||
bool autoStatus;
|
||||
bool showStatus;
|
||||
|
||||
};
|
||||
|
||||
|
||||
196
src/models/filter.cpp
Normal file
196
src/models/filter.cpp
Normal file
@@ -0,0 +1,196 @@
|
||||
#include "filter.h"
|
||||
#include "qjsonarray.h"
|
||||
|
||||
#define NAME_KEY "name"
|
||||
#define DESCRIPTION_KEY "description"
|
||||
#define DATE_KEY "date"
|
||||
#define BOARDS_KEY "boards"
|
||||
#define STATUS_KEY "status"
|
||||
#define PRIORITY_KEY "priority"
|
||||
|
||||
Filter::Filter(QString name, QString description, uint8_t expectedForComparator, QVector<QString> boards, QVector<QString> status, QVector<QString> priorities)
|
||||
{
|
||||
this->name = name;
|
||||
this->description = description;
|
||||
this->expectedForComparator = expectedForComparator;
|
||||
this->boards = boards;
|
||||
this->status = status;
|
||||
this->priorities = priorities;
|
||||
}
|
||||
|
||||
Filter::Filter(QJsonObject obj)
|
||||
{
|
||||
this->name = obj[NAME_KEY].toString("!Missing name!");
|
||||
this->description = obj[DESCRIPTION_KEY].toString();
|
||||
this->expectedForComparator = obj[DATE_KEY].toInt();
|
||||
QJsonArray b = obj[BOARDS_KEY].toArray();
|
||||
QJsonArray s = obj[STATUS_KEY].toArray();
|
||||
QJsonArray p = obj[PRIORITY_KEY].toArray();
|
||||
foreach (QJsonValue value, b)
|
||||
{
|
||||
if (value.isString())
|
||||
{
|
||||
boards.append(value.toString());
|
||||
}
|
||||
}
|
||||
foreach (QJsonValue value, s)
|
||||
{
|
||||
if (value.isString())
|
||||
{
|
||||
status.append(value.toString());
|
||||
}
|
||||
}
|
||||
foreach (QJsonValue value, p)
|
||||
{
|
||||
if (value.isString())
|
||||
{
|
||||
priorities.append(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QVector<Task *> Filter::filter(QVector<Board *> allBoards)
|
||||
{
|
||||
QDate now = QDate::currentDate();
|
||||
QVector<Board*> selectedBoards;
|
||||
if (this->boards.count() > 0)
|
||||
{
|
||||
for (Board *b : allBoards)
|
||||
{
|
||||
foreach (QString boardUuid, this->boards)
|
||||
{
|
||||
if (b->getUuid() == boardUuid)
|
||||
{
|
||||
selectedBoards.append(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedBoards = allBoards;
|
||||
}
|
||||
|
||||
bool fstatus, fpriority, fdate;
|
||||
QVector<Task*> result;
|
||||
for (Board *b : selectedBoards)
|
||||
{
|
||||
for (Task *t : b->getTasks())
|
||||
{
|
||||
fstatus = filterStatus(t);
|
||||
fpriority = filterPriority(t);
|
||||
fdate = filterDate(t, now);
|
||||
if (fstatus && fpriority && fdate)
|
||||
{
|
||||
result.append(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Filter::filterStatus(Task *t)
|
||||
{
|
||||
if (status.count() == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool result = false;
|
||||
foreach (QString s, status)
|
||||
{
|
||||
if (t->getStatusUUID() == s)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Filter::filterPriority(Task *t)
|
||||
{
|
||||
if (priorities.count() == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool result = false;
|
||||
foreach (QString p, priorities)
|
||||
{
|
||||
if (t->getPriorityUUID() == p)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Filter::filterDate(Task *t, QDate now)
|
||||
{
|
||||
switch (expectedForComparator) {
|
||||
case 0:
|
||||
return true;
|
||||
case 1:
|
||||
return t->getExpectedFor() < now;
|
||||
case 2:
|
||||
return t->getExpectedFor() == now;
|
||||
case 3:
|
||||
return t->getExpectedFor() > now;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString Filter::getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
const QString Filter::getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
uint8_t Filter::getExpectedForComparator()
|
||||
{
|
||||
return expectedForComparator;
|
||||
}
|
||||
|
||||
const QVector<QString> Filter::getBoards()
|
||||
{
|
||||
return boards;
|
||||
}
|
||||
|
||||
const QVector<QString> Filter::getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
const QVector<QString> Filter::getPriorities()
|
||||
{
|
||||
return priorities;
|
||||
}
|
||||
|
||||
const QJsonObject Filter::toJson()
|
||||
{
|
||||
QJsonObject obj;
|
||||
obj[NAME_KEY] = name;
|
||||
obj[DESCRIPTION_KEY] = description;
|
||||
obj[DATE_KEY] = expectedForComparator;
|
||||
QJsonArray b;
|
||||
foreach (QString uuid, boards)
|
||||
{
|
||||
b.append(uuid);
|
||||
}
|
||||
QJsonArray s;
|
||||
foreach (QString uuid, status)
|
||||
{
|
||||
s.append(uuid);
|
||||
}
|
||||
QJsonArray p;
|
||||
foreach (QString uuid, priorities)
|
||||
{
|
||||
p.append(uuid);
|
||||
}
|
||||
obj[BOARDS_KEY] = b;
|
||||
obj[STATUS_KEY] = s;
|
||||
obj[PRIORITY_KEY] = p;
|
||||
return obj;
|
||||
}
|
||||
43
src/models/filter.h
Normal file
43
src/models/filter.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef FILTER_H
|
||||
#define FILTER_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "task.h"
|
||||
#include "board.h"
|
||||
|
||||
class Filter
|
||||
{
|
||||
private:
|
||||
QString name;
|
||||
QString description;
|
||||
// 0 none, 1 lower, 2 equal, 3 upper
|
||||
uint8_t expectedForComparator;
|
||||
// if empty => all
|
||||
QVector<QString> boards;
|
||||
QVector<QString> status;
|
||||
QVector<QString> priorities;
|
||||
|
||||
bool filterStatus(Task *t);
|
||||
bool filterPriority(Task *t);
|
||||
bool filterDate(Task *t, QDate now);
|
||||
|
||||
public:
|
||||
Filter(QString name, QString description, uint8_t expectedForComparator,QVector<QString> boards,QVector<QString> status,QVector<QString> priorities);
|
||||
Filter(QJsonObject obj);
|
||||
|
||||
QVector<Task*> filter(QVector<Board*>);
|
||||
|
||||
const QString getName();
|
||||
const QString getDescription();
|
||||
uint8_t getExpectedForComparator();
|
||||
const QVector<QString> getBoards();
|
||||
const QVector<QString> getStatus();
|
||||
const QVector<QString> getPriorities();
|
||||
|
||||
const QJsonObject toJson();
|
||||
};
|
||||
|
||||
#endif // FILTER_H
|
||||
@@ -4,6 +4,8 @@
|
||||
#define NAME_KEY "name"
|
||||
#define COLOR_KEY "color"
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
Priority::Priority(QString uuid, QString name, QColor color)
|
||||
{
|
||||
this->uuid = uuid;
|
||||
@@ -13,9 +15,10 @@ Priority::Priority(QString uuid, QString name, QColor color)
|
||||
|
||||
Priority::Priority(QJsonObject obj)
|
||||
{
|
||||
this->uuid = obj[UUID_KEY].toString();
|
||||
this->name = obj[NAME_KEY].toString();
|
||||
this->color = QColor(obj[COLOR_KEY].toString());
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
this->uuid = obj[UUID_KEY].toString(uuid.toString(QUuid::WithoutBraces));
|
||||
this->name = obj[NAME_KEY].toString("!Missing name!");
|
||||
this->color = QColor(obj[COLOR_KEY].toString("#ffffff"));
|
||||
}
|
||||
|
||||
const QString Priority::getName()
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#define NAME_KEY "name"
|
||||
#define COLOR_KEY "color"
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
Status::Status(QString uuid, QString name, QColor color)
|
||||
{
|
||||
this->uuid = uuid;
|
||||
@@ -13,9 +15,10 @@ Status::Status(QString uuid, QString name, QColor color)
|
||||
|
||||
Status::Status(QJsonObject obj)
|
||||
{
|
||||
this->uuid = obj[UUID_KEY].toString();
|
||||
this->name = obj[NAME_KEY].toString();
|
||||
this->color = QColor(obj[COLOR_KEY].toString());
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
this->uuid = obj[UUID_KEY].toString(uuid.toString(QUuid::WithoutBraces));
|
||||
this->name = obj[NAME_KEY].toString("!Missing name!");
|
||||
this->color = QColor(obj[COLOR_KEY].toString("#ffffff"));
|
||||
}
|
||||
|
||||
const QString Status::getName()
|
||||
|
||||
@@ -5,9 +5,14 @@
|
||||
#define EXPECTEDFOR_KEY "expected_for"
|
||||
#define PRIORITY_KEY "priority"
|
||||
#define STATUS_KEY "status"
|
||||
#define UUID_KEY "uuid"
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
Task::Task(QString title, QString description, QDate expectedFor, QString priorityUUID, QString statusUUID)
|
||||
{
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
this->uuid = uuid.toString(QUuid::WithoutBraces);
|
||||
this->title = title;
|
||||
this->description = description;
|
||||
this->expectedFor = expectedFor;
|
||||
@@ -17,6 +22,8 @@ Task::Task(QString title, QString description, QDate expectedFor, QString priori
|
||||
|
||||
Task::Task(QJsonObject obj)
|
||||
{
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
this->uuid = obj[UUID_KEY].toString(uuid.toString(QUuid::WithoutBraces));
|
||||
this->title = obj[TITLE_KEY].toString();
|
||||
this->description = obj[DESCRIPTION_KEY].toString();
|
||||
this->expectedFor = QDate::fromString(obj[EXPECTEDFOR_KEY].toString(), Qt::DateFormat::ISODate);
|
||||
@@ -24,6 +31,11 @@ Task::Task(QJsonObject obj)
|
||||
this->statusUUID = obj[STATUS_KEY].toString();
|
||||
}
|
||||
|
||||
const QString Task::getUuid()
|
||||
{
|
||||
return this->uuid;
|
||||
}
|
||||
|
||||
const QString Task::getTitle()
|
||||
{
|
||||
return this->title;
|
||||
|
||||
@@ -11,6 +11,7 @@ public:
|
||||
Task(QString title, QString description, QDate expectedFor, QString priorityUUID, QString statusUUID);
|
||||
Task(QJsonObject);
|
||||
|
||||
const QString getUuid();
|
||||
const QString getTitle();
|
||||
const QString getDescription();
|
||||
const QDate getExpectedFor();
|
||||
@@ -21,6 +22,7 @@ public:
|
||||
void update(Task);
|
||||
|
||||
private:
|
||||
QString uuid;
|
||||
QString title;
|
||||
QString description;
|
||||
QDate expectedFor;
|
||||
|
||||
92
src/services/taskstateservice.cpp
Normal file
92
src/services/taskstateservice.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#include "taskstateservice.h"
|
||||
|
||||
TaskStateService *TaskStateService::instance = nullptr;
|
||||
|
||||
TaskStateService *TaskStateService::getInstance()
|
||||
{
|
||||
if (instance == nullptr)
|
||||
{
|
||||
instance = new TaskStateService();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
void TaskStateService::updateStatuses(QVector<Status> statuses)
|
||||
{
|
||||
this->statuses = statuses;
|
||||
}
|
||||
|
||||
void TaskStateService::updatePriorities(QVector<Priority> priorities)
|
||||
{
|
||||
this->priorities = priorities;
|
||||
}
|
||||
|
||||
void TaskStateService::setDefaultStatus(Status s)
|
||||
{
|
||||
this->defaultStatus = s;
|
||||
}
|
||||
|
||||
QVector<Status> TaskStateService::getStatuses()
|
||||
{
|
||||
return statuses;
|
||||
}
|
||||
|
||||
QVector<Priority> TaskStateService::getPriorities()
|
||||
{
|
||||
return priorities;
|
||||
}
|
||||
|
||||
Status TaskStateService::getDefaultStatus()
|
||||
{
|
||||
return this->defaultStatus;
|
||||
}
|
||||
|
||||
std::optional<Status> TaskStateService::getStatusByUUID(QString uuid)
|
||||
{
|
||||
foreach (Status s, statuses) {
|
||||
if (s.getUUID() == uuid)
|
||||
{
|
||||
return std::optional{s};
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<Priority> TaskStateService::getPriorityByUUID(QString uuid)
|
||||
{
|
||||
foreach (Priority p, priorities) {
|
||||
if (p.getUUID() == uuid)
|
||||
{
|
||||
return std::optional{p};
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
int16_t TaskStateService::getStatusWeight(QString uuid)
|
||||
{
|
||||
int16_t weight = -1;
|
||||
for (uint16_t i = 0; i < statuses.count(); i++)
|
||||
{
|
||||
if (statuses[i].getUUID() == uuid)
|
||||
{
|
||||
weight = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return weight;
|
||||
}
|
||||
|
||||
TaskStateService::TaskStateService()
|
||||
{
|
||||
priorities.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "None", QColor(217, 217, 217)));
|
||||
priorities.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "Low", QColor(48, 157, 176)));
|
||||
priorities.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "Medium", QColor(176, 142, 48)));
|
||||
priorities.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "High", QColor(176, 67, 48)));
|
||||
|
||||
Status defaultStatus = Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "To Do", QColor(143, 143, 143));
|
||||
statuses.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "Completed", QColor(48, 176, 73)));
|
||||
statuses.append(defaultStatus);
|
||||
statuses.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "Working on", QColor(95, 48, 176)));
|
||||
this->defaultStatus = defaultStatus;
|
||||
}
|
||||
37
src/services/taskstateservice.h
Normal file
37
src/services/taskstateservice.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef TASKSTATESERVICE_H
|
||||
#define TASKSTATESERVICE_H
|
||||
|
||||
#include <QVector>
|
||||
|
||||
#include "../models/priority.h"
|
||||
#include "../models/status.h"
|
||||
|
||||
class TaskStateService
|
||||
{
|
||||
public:
|
||||
static TaskStateService *getInstance();
|
||||
|
||||
void updateStatuses(QVector<Status>);
|
||||
void updatePriorities(QVector<Priority>);
|
||||
void setDefaultStatus(Status s);
|
||||
|
||||
QVector<Status> getStatuses();
|
||||
QVector<Priority> getPriorities();
|
||||
Status getDefaultStatus();
|
||||
|
||||
std::optional<Status> getStatusByUUID(QString);
|
||||
std::optional<Priority> getPriorityByUUID(QString);
|
||||
int16_t getStatusWeight(QString uuid);
|
||||
|
||||
|
||||
private:
|
||||
TaskStateService();
|
||||
static TaskStateService *instance;
|
||||
|
||||
Status defaultStatus = Status("", "", QColor::fromRgb(0,0,0));
|
||||
|
||||
QVector<Priority> priorities;
|
||||
QVector<Status> statuses;
|
||||
};
|
||||
|
||||
#endif // TASKSTATESERVICE_H
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QDir>
|
||||
|
||||
#include "services/taskstateservice.h"
|
||||
|
||||
Tools::Tools()
|
||||
{
|
||||
|
||||
@@ -95,3 +97,14 @@ bool Tools::readSaveFile(QJsonDocument &doc) {
|
||||
doc = QJsonDocument::fromJson(json.toUtf8());
|
||||
return true;
|
||||
}
|
||||
|
||||
const QString Tools::getStatusLabelStylesheet(Status status)
|
||||
{
|
||||
QColor bg = status.getColor();
|
||||
QColor fg = Tools::getForegroundColor(bg);
|
||||
return QString("border-color: %1; \
|
||||
border: solid; \
|
||||
background-color: %1; \
|
||||
border-radius: 4px; \
|
||||
color: %2;").arg(bg.name(QColor::HexRgb), fg.name(QColor::HexRgb));
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <QColor>
|
||||
#include <QJsonDocument>
|
||||
|
||||
#include "models/status.h"
|
||||
|
||||
class Tools
|
||||
{
|
||||
public:
|
||||
@@ -14,6 +16,7 @@ public:
|
||||
static bool isSaveFileExist();
|
||||
static bool writeSaveToFile(QJsonDocument doc);
|
||||
static bool readSaveFile(QJsonDocument &doc);
|
||||
static const QString getStatusLabelStylesheet(Status);
|
||||
|
||||
private:
|
||||
static const QString getSaveFilePath();
|
||||
|
||||
Reference in New Issue
Block a user