Ticket #6662: combosetting_labels_r23492.patch
File combosetting_labels_r23492.patch, 3.2 KB (added by , 14 years ago) |
---|
-
libs/libmyth/settings.cpp
643 643 for(unsigned int i = 0 ; i < labels.size() ; ++i) 644 644 cbwidget->insertItem(labels[i]); 645 645 646 cbwidget->setMaxCount(cbwidget->count() + rw); 647 646 648 if (isSet) 647 649 cbwidget->setCurrentIndex(current); 648 650 649 651 if (1 < step) 650 652 cbwidget->setStep(step); 651 653 654 connect(cbwidget, SIGNAL(highlighted(int)), 655 this, SLOT(setValue(int))); 656 connect(cbwidget, SIGNAL(activated(int)), 657 this, SLOT(setValue(int))); 658 connect(this, SIGNAL(selectionsCleared()), 659 cbwidget, SLOT(clear())); 660 652 661 if (rw) 653 {654 connect(cbwidget, SIGNAL(highlighted(const QString &)),655 this, SLOT(setValue(const QString &)));656 connect(cbwidget, SIGNAL(activated(const QString &)),657 this, SLOT(setValue(const QString &)));658 662 connect(cbwidget, SIGNAL(editTextChanged(const QString &)), 659 this, SLOT(setValue(const QString &))); 660 } 661 else 662 { 663 connect(cbwidget, SIGNAL(highlighted(int)), 664 this, SLOT(setValue(int))); 665 connect(cbwidget, SIGNAL(activated(int)), 666 this, SLOT(setValue(int))); 667 } 663 this, SLOT(editTextChanged(const QString &))); 668 664 669 connect(this, SIGNAL(selectionsCleared()),670 cbwidget, SLOT(clear()));671 672 665 if (cg) 673 666 connect(cbwidget, SIGNAL(changeHelpText(QString)), cg, 674 667 SIGNAL(changeHelpText(QString))); … … 728 721 if (cbwidget) 729 722 cbwidget->setCurrentIndex(current); 730 723 } 731 } ;724 } 732 725 733 726 void ComboBoxSetting::setValue(int which) 734 727 { 735 728 if (cbwidget) 736 729 cbwidget->setCurrentIndex(which); 737 730 SelectSetting::setValue(which); 738 } ;731 } 739 732 740 733 void ComboBoxSetting::addSelection( 741 734 const QString &label, QString value, bool select) … … 771 764 return false; 772 765 } 773 766 767 void ComboBoxSetting::editTextChanged(const QString &newText) 768 { 769 if (cbwidget) 770 { 771 for (uint i = 0; i < labels.size(); i++) 772 if (labels[i] == newText) 773 return; 774 775 if (labels.size() == static_cast<size_t>(cbwidget->maxCount())) 776 { 777 SelectSetting::removeSelection(labels[cbwidget->maxCount() - 1], 778 values[cbwidget->maxCount() - 1]); 779 cbwidget->setItemText(cbwidget->maxCount() - 1, newText); 780 } 781 else 782 { 783 cbwidget->insertItem(newText); 784 } 785 786 SelectSetting::addSelection(newText, newText, true); 787 cbwidget->setCurrentIndex(cbwidget->maxCount() - 1); 788 } 789 } 790 774 791 void ComboBoxSetting::setHelpText(const QString &str) 775 792 { 776 793 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;