-
Notifications
You must be signed in to change notification settings - Fork 0
/
filetagswidget.cpp
63 lines (55 loc) · 1.31 KB
/
filetagswidget.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
56
57
58
59
60
61
62
63
#include "filetagswidget.h"
#include "ui_filetagswidget.h"
FileTagsWidget::FileTagsWidget(TagPool *tp, QWidget *parent) :
QWidget(parent),
ui(new Ui::FileTagsWidget), tp_(tp)
{
ui->setupUi(this);
}
FileTagsWidget::~FileTagsWidget()
{
delete ui;
}
void FileTagsWidget::setFileName(QString fn)
{
this->clearSelectors();
QStringList tags = tp_->tagsInString(fn);
this->addSelectorList(tags);
}
void FileTagsWidget::addSelector(QString tag)
{
TagTypeSelector *w = new TagTypeSelector(tag,tp_,this);
tag_type_selectors_.insert(tag, w);
tags_.append(tag);
ui->tagsLayout->addWidget(w);
}
void FileTagsWidget::addSelectorList(QStringList tagli)
{
QString t;
foreach (t, tagli){
this->addSelector(t);
}
}
void FileTagsWidget::removeSelector(QString tag)
{
TagTypeSelector *w;
while( tags_.contains(tag) ){
tags_.removeOne(tag);
w = tag_type_selectors_.take(tag);
ui->tagsLayout->removeWidget(w);
w->deleteLater();
}
}
void FileTagsWidget::clearSelectors()
{
TagTypeSelector *w;
QString t;
for (int i= 0; i < tags_.size(); ++i){
t = tags_.at(i);
w = tag_type_selectors_.take(t);
ui->tagsLayout->removeWidget(w);
w->deleteLater();
}
tags_.clear();
tag_type_selectors_.clear();
}