• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

libs/libksane/libksane

  • sources
  • kde-4.14
  • kdegraphics
  • libs
  • libksane
  • libksane
  • widgets
labeled_combo.cpp
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is part of the KDE project
4  *
5  * Date : 2007-09-13
6  * Description : Sane interface for KDE
7  *
8  * Copyright (C) 2007-2011 by Kare Sars <kare.sars@iki .fi>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) version 3, or any
14  * later version accepted by the membership of KDE e.V. (or its
15  * successor approved by the membership of KDE e.V.), which shall
16  * act as a proxy defined in Section 6 of version 3 of the license.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  * Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this program. If not, see <http://www.gnu.org/licenses/>.
25  *
26  * ============================================================ */
27 #include "labeled_combo.h"
28 #include "labeled_combo.moc"
29 
30 // Qt includes
31 #include <QLabel>
32 
33 // KDE includes
34 #include <KComboBox>
35 #include <KDebug>
36 
37 namespace KSaneIface
38 {
39 
40 LabeledCombo::LabeledCombo(QWidget *parent, const QString& ltext, const QStringList& list)
41 : KSaneOptionWidget(parent, ltext)
42 {
43  m_combo = new KComboBox(this);
44  m_combo->addItems(list);
45 
46  m_label->setBuddy(m_combo);
47 
48  connect(m_combo, SIGNAL(activated(int)), this, SIGNAL(activated(int)));
49 
50  m_layout->addWidget(m_combo, 0, 1);
51  m_layout->addWidget(new QWidget(this), 0, 2);
52  m_layout->setColumnStretch(1, 0);
53  m_layout->setColumnStretch(2, 50);
54  setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
55 }
56 
57 void LabeledCombo::addItems(const QStringList &list)
58 {
59  m_combo->addItems(list);
60 
61  QString tmp;
62  for (int i=0; i<m_combo->count(); i++) {
63  tmp = m_combo->itemText(i);
64  m_combo->setItemData(i, tmp, Qt::ToolTipRole);
65  }
66 }
67 
68 
69 void LabeledCombo::setCurrentText(const QString &t)
70 {
71  int i;
72  for (i=0; i<m_combo->count(); i++) {
73  if (m_combo->itemText(i) == t) {
74  m_combo->setCurrentIndex(i);
75  }
76  }
77 }
78 
79 QString LabeledCombo::currentText()
80 {
81  return m_combo->currentText();
82 }
83 
84 
85 bool LabeledCombo::setIcon(const QIcon &icon, const QString& str)
86 {
87  for (int i=0; i < m_combo->count(); i++) {
88  if (m_combo->itemText(i) == str) {
89  m_combo->setItemIcon(i, icon);
90  return true;
91  }
92  }
93  return false;
94 }
95 
96 void LabeledCombo::setCurrentIndex(int i)
97 {
98  m_combo->setCurrentIndex(i);
99 }
100 
101 } // NameSpace KSaneIface
labeled_combo.h
QWidget
QGridLayout::addWidget
void addWidget(QWidget *widget, int row, int column, QFlags< Qt::AlignmentFlag > alignment)
KSaneIface::LabeledCombo::setCurrentText
void setCurrentText(const QString &)
If the given string can be found in the comobox, activate that entry.
Definition: labeled_combo.cpp:69
KSaneIface::LabeledCombo::addItems
void addItems(const QStringList &list)
Add string entries to the combobox.
Definition: labeled_combo.cpp:57
KSaneIface::KSaneOptionWidget::m_label
QLabel * m_label
Definition: ksane_option_widget.h:64
QLabel::setBuddy
void setBuddy(QWidget *buddy)
KSaneIface::KSaneOptionWidget::m_layout
QGridLayout * m_layout
Definition: ksane_option_widget.h:65
KSaneIface::KSaneOptionWidget
A wrapper for a checkbox.
Definition: ksane_option_widget.h:45
QString
QWidget::setSizePolicy
void setSizePolicy(QSizePolicy)
QStringList
KSaneIface::LabeledCombo::currentText
QString currentText()
This function is used to read the current string of the combobox.
Definition: labeled_combo.cpp:79
KSaneIface::LabeledCombo::activated
void activated(int)
KSaneIface::LabeledCombo::setIcon
bool setIcon(const QIcon &icon, const QString &str)
add an icon for a string in the combobox
Definition: labeled_combo.cpp:85
QGridLayout::setColumnStretch
void setColumnStretch(int column, int stretch)
QWidget::QWidget
QWidget(QWidget *parent, QFlags< Qt::WindowType > f)
KSaneIface::LabeledCombo::setCurrentIndex
void setCurrentIndex(int)
set the current item of the combobox.
Definition: labeled_combo.cpp:96
KSaneIface::LabeledCombo::LabeledCombo
LabeledCombo(QWidget *parent, const QString &label, const QStringList &list)
create a label and combobox combination.
Definition: labeled_combo.cpp:40
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QIcon
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:19:47 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libs/libksane/libksane

Skip menu "libs/libksane/libksane"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal