• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • kdeui
  • sonnet
dictionarycombobox.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2003 Ingo Kloecker <kloecker@kde.org>
3 * Copyright (c) 2008 Tom Albers <tomalbers@kde.nl>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301 USA
19*/
20
21#include "dictionarycombobox.h"
22
23#include <kdebug.h>
24#include <sonnet/speller.h>
25
26namespace Sonnet
27{
28
29//@cond PRIVATE
30class DictionaryComboBox::Private
31{
32 public:
33 Private( DictionaryComboBox* combo ) : q( combo ) {};
34 DictionaryComboBox* q;
35 void slotDictionaryChanged( int idx );
36};
37
38void DictionaryComboBox::Private::slotDictionaryChanged( int idx )
39{
40 kDebug() << idx;
41 emit q->dictionaryChanged( q->itemData( idx ).toString() );
42 emit q->dictionaryNameChanged( q->itemText( idx ) );
43}
44//@endcon
45
46DictionaryComboBox::DictionaryComboBox( QWidget * parent )
47 : KComboBox( parent ), d( new DictionaryComboBox::Private( this ) )
48{
49 reloadCombo();
50 connect( this, SIGNAL(activated(int)),
51 SLOT(slotDictionaryChanged(int)) );
52}
53
54DictionaryComboBox::~DictionaryComboBox()
55{
56 delete d;
57}
58
59QString DictionaryComboBox::currentDictionaryName() const
60{
61 return currentText();
62}
63
64QString DictionaryComboBox::currentDictionary() const
65{
66 return itemData( currentIndex() ).toString();
67}
68
69void DictionaryComboBox::setCurrentByDictionaryName( const QString & name )
70{
71 if ( name.isEmpty() || name == currentText() )
72 return;
73
74 int idx = findText( name );
75 if ( idx == -1 ) {
76 kDebug() << "name not found" << name;
77 return;
78 }
79
80 setCurrentIndex( idx );
81 d->slotDictionaryChanged( idx );
82}
83
84void DictionaryComboBox::setCurrentByDictionary( const QString & dictionary )
85{
86 if ( dictionary.isEmpty() || dictionary == itemData( currentIndex() ).toString() )
87 return;
88
89 int idx = findData( dictionary );
90 if ( idx == -1 ) {
91 kDebug() << "dictionary not found" << dictionary;
92 return;
93 }
94
95 setCurrentIndex( idx );
96 d->slotDictionaryChanged( idx );
97}
98
99void DictionaryComboBox::reloadCombo()
100{
101 clear();
102 Sonnet::Speller* speller = new Sonnet::Speller();
103 QMap<QString, QString> dictionaries = speller->availableDictionaries();
104 QMapIterator<QString, QString> i( dictionaries );
105 while ( i.hasNext() ) {
106 i.next();
107 kDebug() << "Populate combo:" << i.key() << ":" << i.value();
108 addItem( i.key(), i.value() );
109 }
110 delete speller;
111}
112
113}
114
115#include "dictionarycombobox.moc"
KComboBox
An enhanced combo box.
Definition: kcombobox.h:149
QMap
QWidget
Sonnet::DictionaryComboBox::DictionaryComboBox
DictionaryComboBox(QWidget *parent=0)
Constructor.
Sonnet::Speller
Sonnet::Speller::availableDictionaries
QMap< QString, QString > availableDictionaries() const
dictionarycombobox.h
kDebug
#define kDebug
kdebug.h
KStandardAction::name
const char * name(StandardAction id)
This will return the internal name of a given standard action.
Definition: kstandardaction.cpp:223
KStandardAction::clear
KAction * clear(const QObject *recvr, const char *slot, QObject *parent)
Clear the content of the focus widget.
Definition: kstandardaction.cpp:314
Sonnet
dialog.cpp
speller.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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