417 |
|
|
418 |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
419 |
{ |
{ |
420 |
|
const bool bBlockSignals = pComboBox->blockSignals(true); |
421 |
|
|
422 |
// Load combobox list from configuration settings file... |
// Load combobox list from configuration settings file... |
423 |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
424 |
|
|
426 |
pComboBox->setUpdatesEnabled(false); |
pComboBox->setUpdatesEnabled(false); |
427 |
pComboBox->setDuplicatesEnabled(false); |
pComboBox->setDuplicatesEnabled(false); |
428 |
pComboBox->clear(); |
pComboBox->clear(); |
429 |
for (int i = 0; i < iLimit; i++) { |
for (int i = 0; i < iLimit; ++i) { |
430 |
const QString& sText = m_settings.value( |
const QString& sText = m_settings.value( |
431 |
"/Item" + QString::number(i + 1)).toString(); |
"/Item" + QString::number(i + 1)).toString(); |
432 |
if (sText.isEmpty()) |
if (sText.isEmpty()) |
437 |
} |
} |
438 |
|
|
439 |
m_settings.endGroup(); |
m_settings.endGroup(); |
440 |
|
|
441 |
|
pComboBox->blockSignals(bBlockSignals); |
442 |
} |
} |
443 |
|
|
444 |
|
|
445 |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
446 |
{ |
{ |
447 |
|
const bool bBlockSignals = pComboBox->blockSignals(true); |
448 |
|
|
449 |
// Add current text as latest item... |
// Add current text as latest item... |
450 |
const QString& sCurrentText = pComboBox->currentText(); |
const QString sCurrentText = pComboBox->currentText(); |
451 |
int iCount = pComboBox->count(); |
int iCount = pComboBox->count(); |
452 |
for (int i = 0; i < iCount; i++) { |
for (int i = 0; i < iCount; i++) { |
453 |
const QString& sText = pComboBox->itemText(i); |
const QString& sText = pComboBox->itemText(i); |
454 |
if (sText == sCurrentText) { |
if (sText == sCurrentText) { |
455 |
pComboBox->removeItem(i); |
pComboBox->removeItem(i); |
456 |
iCount--; |
--iCount; |
457 |
break; |
break; |
458 |
} |
} |
459 |
} |
} |
460 |
while (iCount >= iLimit) |
while (iCount >= iLimit) |
461 |
pComboBox->removeItem(--iCount); |
pComboBox->removeItem(--iCount); |
462 |
pComboBox->insertItem(0, sCurrentText); |
pComboBox->insertItem(0, sCurrentText); |
463 |
iCount++; |
pComboBox->setCurrentIndex(0); |
464 |
|
++iCount; |
465 |
|
|
466 |
// Save combobox list to configuration settings file... |
// Save combobox list to configuration settings file... |
467 |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
468 |
for (int i = 0; i < iCount; i++) { |
for (int i = 0; i < iCount; ++i) { |
469 |
const QString& sText = pComboBox->itemText(i); |
const QString& sText = pComboBox->itemText(i); |
470 |
if (sText.isEmpty()) |
if (sText.isEmpty()) |
471 |
break; |
break; |
472 |
m_settings.setValue("/Item" + QString::number(i + 1), sText); |
m_settings.setValue("/Item" + QString::number(i + 1), sText); |
473 |
} |
} |
474 |
m_settings.endGroup(); |
m_settings.endGroup(); |
475 |
|
|
476 |
|
pComboBox->blockSignals(bBlockSignals); |
477 |
} |
} |
478 |
|
|
479 |
|
|
480 |
int Options::getMaxVoices() { |
int Options::getMaxVoices() { |
481 |
#ifndef CONFIG_MAX_VOICES |
#ifndef CONFIG_MAX_VOICES |
482 |
return -1; |
return -1; |