algorithm.cpp
1.15 KB
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
#include <QStringList>
#include <openbr.h>
#include "algorithm.h"
/**** ALGORITHM ****/
/*** PUBLIC ***/
br::Algorithm::Algorithm(QWidget *parent)
: QComboBox(parent)
{
setToolTip("Algorithm");
connect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(setAlgorithm(QString)));
}
/*** PUBLIC SLOTS ***/
bool br::Algorithm::addAlgorithm(const QString &algorithm, const QString &displayName)
{
static QStringList availableAlgorithms;
if (availableAlgorithms.isEmpty())
availableAlgorithms = QString(br_objects("Abbreviation", ".*", false)).split("\n");
if (!availableAlgorithms.contains(algorithm))
return false;
if (displayName.isEmpty()) {
addItem(algorithm);
} else {
displayNames.insert(displayName, algorithm);
addItem(displayName);
}
return true;
}
/*** PRIVATE SLOTS ***/
void br::Algorithm::setAlgorithm(QString algorithm)
{
if (displayNames.contains(algorithm))
algorithm = displayNames[algorithm];
br_set_property("algorithm", qPrintable(algorithm));
emit newAlgorithm(algorithm);
}
#include "moc_algorithm.cpp"