1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-16 12:55:12 +03:00

Fixes #2465 - A little bit refactoring done while fixing this one

This commit is contained in:
bsongis 2015-07-18 17:22:26 +02:00
parent 2b804f92b5
commit 90ebaf2d88
8 changed files with 76 additions and 72 deletions

View file

@ -95,6 +95,36 @@ void populateGvSourceCB(QComboBox *b, int value)
b->setCurrentIndex(value);
}
void populateFileComboBox(QComboBox * b, const QSet<QString> & set, const QString & current)
{
b->addItem("----");
bool added = false;
// Convert set into list and sort it alphabetically case insensitive
QStringList list = QStringList::fromSet(set);
qSort(list.begin(), list.end(), caseInsensitiveLessThan);
foreach (QString entry, list) {
b->addItem(entry);
if (entry == current) {
b->setCurrentIndex(b->count()-1);
added = true;
}
}
if (!added && !current.isEmpty()) {
b->addItem(current);
b->setCurrentIndex(b->count()-1);
}
}
void getFileComboBoxValue(QComboBox * b, char * dest, int length)
{
memset(dest, 0, length+1);
if (b->currentText() != "----") {
strncpy(dest, b->currentText().toAscii(), length);
}
}
QString getProtocolStr(const int proto)
{
static const char *strings[] = { "OFF",