blob: 93433a08ed2f18ac69fba729b8b4d4382a4264ab (
plain) (
blame)
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 "combodatawidget.h"
#include "common/unused.h"
#include "config_builder.h"
#include "dialogs/configdialog.h"
#include <QComboBox>
#include <QDebug>
ComboDataWidget::ComboDataWidget(CfgEntry* key) :
assignedKey(key)
{
}
bool ComboDataWidget::isConfigForWidget(CfgEntry* key, QWidget* widget)
{
UNUSED(widget);
return (assignedKey == key);
}
void ComboDataWidget::applyConfigToWidget(CfgEntry* key, QWidget* widget, const QVariant& value)
{
QComboBox* cb = dynamic_cast<QComboBox*>(widget);
if (!cb)
{
qWarning() << "ComboDataWidget assigned to widget which is not combobox, but:" << widget->metaObject()->className()
<< ", config key:" << key->getFullKey();
return;
}
QVariant data;
for (int i = 0; i < cb->count(); i++)
{
data = cb->itemData(i);
if (data == value)
{
cb->setCurrentIndex(i);
break;
}
}
}
QVariant ComboDataWidget::getWidgetConfigValue(QWidget* widget, bool& ok)
{
QComboBox* cb = dynamic_cast<QComboBox*>(widget);
if (!cb)
{
ok = false;
qWarning() << "ComboDataWidget assigned to widget which is not combobox, but:" << widget->metaObject()->className();
return QVariant();
}
ok = true;
return cb->itemData(cb->currentIndex());
}
const char* ComboDataWidget::getModifiedNotifier() const
{
return SIGNAL(currentTextChanged(QString));
}
QString ComboDataWidget::getFilterString(QWidget *widget) const
{
return ConfigDialog::getFilterString(widget);
}
|