1
/*****************************************************************************
2
* This file is part of Kiten, a KDE Japanese Reference Tool... *
3
* Copyright (C) 2006 Joseph Kerian <jkerian@gmail.com> *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program 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 *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the Free Software *
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 *
19
*****************************************************************************/
21
#include "configsortingpage.h"
24
#include <QListWidget>
26
#include <QStringList>
28
#include "dictionarymanager.h"
30
#include "kitenconfig.h"
32
ConfigSortingPage::ConfigSortingPage( QWidget *parent
33
, KitenConfigSkeleton *config
35
: QWidget( parent, f )
39
_dictNames = DictionaryManager::listDictFileTypes();
41
//Setup the relationship between the checkbox and the dictionary sortlist
42
connect( kcfg_dictionary_enable, SIGNAL( clicked( bool ) ),
43
dictionary_order, SLOT( setEnabled( bool ) ) );
44
dictionary_order->setEnabled( _config->dictionary_enable() == "true" );
46
_fields.append( "Word/Kanji" );
47
_fields.append( "Meaning" );
48
_fields.append( "Reading" );
49
QList<QString> fieldListMap = DictionaryManager::generateExtendedFieldsList().keys();
50
_fields += fieldListMap;
52
//Make the connections to alert the main dialog when things change
53
connect( dictionary_order, SIGNAL( added( QListWidgetItem* ) ),
54
this, SIGNAL( widgetChanged() ) );
55
connect( dictionary_order, SIGNAL( removed( QListWidgetItem* ) ),
56
this, SIGNAL( widgetChanged() ) );
57
connect( dictionary_order, SIGNAL( movedUp( QListWidgetItem* ) ),
58
this, SIGNAL( widgetChanged() ) );
59
connect( dictionary_order, SIGNAL( movedDown( QListWidgetItem* ) ),
60
this, SIGNAL( widgetChanged() ) );
62
connect( field_order, SIGNAL( added ( QListWidgetItem* ) ),
63
this, SIGNAL( widgetChanged() ) );
64
connect( field_order, SIGNAL( removed( QListWidgetItem* ) ),
65
this, SIGNAL( widgetChanged() ) );
66
connect( field_order, SIGNAL( movedUp( QListWidgetItem* ) ),
67
this, SIGNAL( widgetChanged() ) );
68
connect( field_order, SIGNAL( movedDown( QListWidgetItem* ) ),
69
this, SIGNAL( widgetChanged() ) );
72
//Read from preferences and set widgets
73
void ConfigSortingPage::updateWidgets()
75
QStringList selectedDicts = _config->dictionary_sortlist();
76
QStringList selectedFields = _config->field_sortlist();
78
QStringList availDicts = _dictNames;
79
QStringList availFields = _fields;
81
foreach( const QString &dict, selectedDicts )
83
availDicts.removeAll( dict );
86
foreach( const QString &field, selectedFields )
88
availDicts.removeAll( field );
91
dictionary_order->availableListWidget()->clear();
92
dictionary_order->availableListWidget()->addItems(availDicts);
93
dictionary_order->selectedListWidget()->clear();
94
dictionary_order->selectedListWidget()->addItems(selectedDicts);
96
field_order->availableListWidget()->clear();
97
field_order->availableListWidget()->addItems(availFields);
98
field_order->selectedListWidget()->clear();
99
field_order->selectedListWidget()->addItems(selectedFields);
102
void ConfigSortingPage::updateSettings()
105
for( int i = 0; i < dictionary_order->selectedListWidget()->count(); i++ )
107
list.append( dictionary_order->selectedListWidget()->item( i )->text() );
109
_config->setDictionary_sortlist( list );
112
for( int i = 0; i < field_order->selectedListWidget()->count(); i++ )
114
list.append( field_order->selectedListWidget()->item( i )->text() );
116
_config->setField_sortlist( list );
119
void ConfigSortingPage::updateWidgetsDefault()
124
bool ConfigSortingPage::isDefault()
129
bool ConfigSortingPage::hasChanged()
134
#include "configsortingpage.moc"