-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAddTagToNoteDialog.cpp
49 lines (42 loc) · 1.48 KB
/
AddTagToNoteDialog.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
#include "AddTagToNoteDialog.h"
#include "ui_AddTagToNoteDialogs.h"
#include "TagManager.h"
AddTagToNoteDialog::AddTagToNoteDialog(Note *n, QWidget *parent) :
QDialog(parent),
ui(new Ui::AddTagToNoteDialog)
{
ui->setupUi(this);
tm = &TagManager::getInstance();
activatedTags = new QSet<Tag*>();
for(QSet<Tag *>::const_iterator it = tm->begin(); it!=tm->end(); ++it){
QListWidgetItem* item = new QListWidgetItemWithpTag((*it)->getName(), *it, ui->listWidget);
item->setData(0, (*it)->getName());
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
if(n->getTags().contains(*it)){
item->setCheckState(Qt::Checked);
activatedTags->insert(*it);
}
else
item->setCheckState(Qt::Unchecked);
}
QObject::connect(ui->listWidget, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(STOCK_ACTIVATED_TAGS(QListWidgetItem*)));
}
void AddTagToNoteDialog::STOCK_ACTIVATED_TAGS(QListWidgetItem * item)
{
if(item->checkState()==Qt::Checked){
qDebug()<<"Getting "<< item->data(0) << "checked";
activatedTags->insert(static_cast<QListWidgetItemWithpTag*>(item)->getRessource());
}
else{
qDebug()<<"Getting "<< item->data(0) << "unchecked";
activatedTags->remove(static_cast<QListWidgetItemWithpTag*>(item)->getRessource());
}
}
AddTagToNoteDialog::~AddTagToNoteDialog()
{
delete ui;
}
QSet<Tag *>* AddTagToNoteDialog::getTags()
{
return activatedTags;
}