Ticket #6662: combosetting_labels_r20746.patch
File combosetting_labels_r20746.patch, 3.2 KB (added by , 16 years ago) |
---|
-
libs/libmyth/settings.cpp
623 623 for(unsigned int i = 0 ; i < labels.size() ; ++i) 624 624 cbwidget->insertItem(labels[i]); 625 625 626 cbwidget->setMaxCount(cbwidget->count() + rw); 627 626 628 if (isSet) 627 629 cbwidget->setCurrentIndex(current); 628 630 629 631 if (1 < step) 630 632 cbwidget->setStep(step); 631 633 634 connect(cbwidget, SIGNAL(highlighted(int)), 635 this, SLOT(setValue(int))); 636 connect(cbwidget, SIGNAL(activated(int)), 637 this, SLOT(setValue(int))); 638 connect(this, SIGNAL(selectionsCleared()), 639 cbwidget, SLOT(clear())); 640 632 641 if (rw) 633 {634 connect(cbwidget, SIGNAL(highlighted(const QString &)),635 this, SLOT(setValue(const QString &)));636 connect(cbwidget, SIGNAL(activated(const QString &)),637 this, SLOT(setValue(const QString &)));638 642 connect(cbwidget, SIGNAL(editTextChanged(const QString &)), 639 this, SLOT(setValue(const QString &))); 640 } 641 else 642 { 643 connect(cbwidget, SIGNAL(highlighted(int)), 644 this, SLOT(setValue(int))); 645 connect(cbwidget, SIGNAL(activated(int)), 646 this, SLOT(setValue(int))); 647 } 643 this, SLOT(editTextChanged(const QString &))); 648 644 649 connect(this, SIGNAL(selectionsCleared()),650 cbwidget, SLOT(clear()));651 652 645 if (cg) 653 646 connect(cbwidget, SIGNAL(changeHelpText(QString)), cg, 654 647 SIGNAL(changeHelpText(QString))); … … 706 699 if (cbwidget) 707 700 cbwidget->setCurrentIndex(current); 708 701 } 709 } ;702 } 710 703 711 704 void ComboBoxSetting::setValue(int which) 712 705 { 713 706 if (cbwidget) 714 707 cbwidget->setCurrentIndex(which); 715 708 SelectSetting::setValue(which); 716 } ;709 } 717 710 718 711 void ComboBoxSetting::addSelection( 719 712 const QString &label, QString value, bool select) … … 749 742 return false; 750 743 } 751 744 745 void ComboBoxSetting::editTextChanged(const QString &newText) 746 { 747 if (cbwidget) 748 { 749 for (uint i = 0; i < labels.size(); i++) 750 if (labels[i] == newText) 751 return; 752 753 if (labels.size() == static_cast<size_t>(cbwidget->maxCount())) 754 { 755 SelectSetting::removeSelection(labels[cbwidget->maxCount() - 1], 756 values[cbwidget->maxCount() - 1]); 757 cbwidget->setItemText(cbwidget->maxCount() - 1, newText); 758 } 759 else 760 { 761 cbwidget->insertItem(newText); 762 } 763 764 SelectSetting::addSelection(newText, newText, true); 765 cbwidget->setCurrentIndex(cbwidget->maxCount() - 1); 766 } 767 } 768 752 769 void ComboBoxSetting::setHelpText(const QString &str) 753 770 { 754 771 if (cbwidget) -
libs/libmyth/settings.h
341 341 bool select = false); 342 342 bool removeSelection(const QString &label, 343 343 QString value = QString::null); 344 void editTextChanged(const QString &newText); 344 345 345 346 private: 346 347 bool rw;