File indexing completed on 2024-05-05 17:18:59

0001 /***************************************************************************
0002  * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr
0003  * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  ***************************************************************************/
0006 /** @file
0007  * A combo box with more features.
0008  *
0009  * @author Stephane MANKOWSKI / Guillaume DE BURE
0010  */
0011 #include "skgcombobox.h"
0012 
0013 #include <qlineedit.h>
0014 
0015 SKGComboBox::SKGComboBox(QWidget* iParent)
0016     : KComboBox(iParent)
0017 {
0018 }
0019 
0020 SKGComboBox::~SKGComboBox()
0021     = default;
0022 
0023 QString SKGComboBox::text() const
0024 {
0025     return currentText();
0026 }
0027 
0028 void SKGComboBox::setText(const QString& iText)
0029 {
0030     int pos2 = findText(iText);
0031     if (pos2 == -1) {
0032         pos2 = 0;
0033         insertItem(pos2, iText);
0034     }
0035     setCurrentIndex(pos2);
0036 }
0037 
0038 void SKGComboBox::setPalette(const QPalette& iPalette)
0039 {
0040     KComboBox::setPalette(iPalette);
0041     lineEdit()->setPalette(iPalette);
0042 }
0043