-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategorydialog.cpp
55 lines (45 loc) · 1.2 KB
/
categorydialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "categorydialog.h"
#include "ui_categorydialog.h"
#include "filemanager.h"
#include <QMessageBox>
#include <QPushButton>
#include <QColorDialog>
CategoryDialog::CategoryDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CategoryDialog)
{
ui->setupUi(this);
this->setWindowTitle("Category settings");
f = new FileManager(1, 0, "./settings/settings.ttt", false);
QStringList temp = f->readFile();
for (int i = 0; i < temp.count(); i++)
{
ui->categoryList->addItem(temp[i].split(",")[0].toLocal8Bit());
}
}
CategoryDialog::~CategoryDialog()
{
delete ui;
}
// Add new category.
void CategoryDialog::on_addButton_clicked()
{
if (ui->addLineEdit->text() != "")
{
f->updateSettings(ui->addLineEdit->text());
newCategory = ui->addLineEdit->text();
ui->categoryList->addItem(newCategory);
ui->categoryList->sortItems();
}
}
// Delete a category.
void CategoryDialog::on_deleteButton_clicked()
{
QStringList temp;
qDeleteAll(ui->categoryList->selectedItems());
for (int i = 0; i < ui->categoryList->count(); i++)
{
temp.append(ui->categoryList->item(i)->text());
}
f->deleteCategory(temp);
}