--- a/ipsservices/nmipssettings/src/nmipssettingslabeledcombobox.cpp Fri Apr 16 14:51:52 2010 +0300
+++ b/ipsservices/nmipssettings/src/nmipssettingslabeledcombobox.cpp Mon May 03 12:23:15 2010 +0300
@@ -56,7 +56,7 @@
// Connect signals and slots.
connect(mComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(comboBoxIndexChanged(int)), Qt::UniqueConnection);
- connect(mComboBox, SIGNAL(currentIndexChanged(int)),
+ connect(mComboBox, SIGNAL(currentIndexChanged(int)),
this, SIGNAL(currentIndexChanged(int)), Qt::UniqueConnection);
}
@@ -68,44 +68,59 @@
}
/*!
- Sets the current combobox index.
- \param index Combobox index to set.
+ Returns the current index.
+ \return Index.
+*/
+int NmIpsSettingsLabeledComboBox::currentIndex() const
+{
+ return mComboBox->currentIndex();
+}
+
+/*!
+ Sets the current index.
+ \param currentIndex Index to set.
*/
void NmIpsSettingsLabeledComboBox::setCurrentIndex(int index)
{
- // Change is not signaled outside via currentIndexChanged.
- disconnect(mComboBox, SIGNAL(currentIndexChanged(int)),
- this, SIGNAL(currentIndexChanged(int)));
mComboBox->setCurrentIndex(index);
+}
- // Force refreshing the label text when the new index is same as current index.
- if (mComboBox->currentIndex() == index) {
- comboBoxIndexChanged(index);
- }
-
- // Reconnect the slot to signal changes outside.
- connect(mComboBox, SIGNAL(currentIndexChanged(int)),
- this, SIGNAL(currentIndexChanged(int)), Qt::UniqueConnection);
+/*!
+ Returns the current combobox items.
+ \return Combobox items.
+*/
+QStringList NmIpsSettingsLabeledComboBox::comboItems() const
+{
+ return mComboBox->items();
}
/*!
- Sets the combobox items and corresponding texts for the label.
- \param texts Item texts.
+ Sets the current combobox items.
+ \param comboItem Combobox items to set.
*/
-void NmIpsSettingsLabeledComboBox::setItems(QStringList comboBoxItems,
- QStringList texts)
+void NmIpsSettingsLabeledComboBox::setComboItems(QStringList comboItems)
+{
+ mComboBox->setItems(comboItems);
+}
+/*!
+ Returns the current label texts.
+ \return Label texts.
+*/
+QStringList NmIpsSettingsLabeledComboBox::labelTexts() const
{
- // Set the combobox items without signaling index change.
- disconnect(mComboBox, SIGNAL(currentIndexChanged(int)),
- this, SIGNAL(currentIndexChanged(int)));
- mComboBox->setItems(comboBoxItems);
- connect(mComboBox, SIGNAL(currentIndexChanged(int)),
- this, SIGNAL(currentIndexChanged(int)), Qt::UniqueConnection);
+ return QStringList(mLabelTexts.values());
+}
- // Set the corresponding texts for the label.
+/*!
+ Sets the current label texts.
+ \param labelTexts Label texts to set.
+*/
+void NmIpsSettingsLabeledComboBox::setLabelTexts(QStringList labelTexts)
+{
+ // Set the label texts.
mLabelTexts.clear();
- for (int i=0; i<comboBoxItems.count(); ++i) {
- mLabelTexts.insert(i, texts.at(i));
+ for (int i=0; i<labelTexts.count(); ++i) {
+ mLabelTexts.insert(i, labelTexts.at(i));
}
}
@@ -115,5 +130,6 @@
*/
void NmIpsSettingsLabeledComboBox::comboBoxIndexChanged(int index)
{
- mLabel->setPlainText(mLabelTexts.value(index));
+ QString label(mLabelTexts.value(index));
+ mLabel->setPlainText(label);
}