summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/odict/odict.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp
index 4c99964..497de36 100644
--- a/noncore/apps/odict/odict.cpp
+++ b/noncore/apps/odict/odict.cpp
@@ -1,181 +1,183 @@
1/*************************************************************************** 1/***************************************************************************
2 application: : ODict 2 application: : ODict
3 3
4 begin : December 2002 4 begin : December 2002
5 copyright : ( C ) 2002, 2003 by Carsten Niehaus 5 copyright : ( C ) 2002, 2003 by Carsten Niehaus
6 email : cniehaus@handhelds.org 6 email : cniehaus@handhelds.org
7 **************************************************************************/ 7 **************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * ( at your option ) any later version. * 14 * ( at your option ) any later version. *
15 * * 15 * *
16 **************************************************************************/ 16 **************************************************************************/
17#include "odict.h" 17#include "odict.h"
18#include "configdlg.h" 18#include "configdlg.h"
19#include "dingwidget.h" 19#include "dingwidget.h"
20 20
21#include <qmenubar.h> 21#include <qmenubar.h>
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qvbox.h> 23#include <qvbox.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#include <qlineedit.h> 26#include <qlineedit.h>
27#include <qaction.h> 27#include <qaction.h>
28#include <qtextbrowser.h> 28#include <qtextbrowser.h>
29#include <qcombobox.h> 29#include <qcombobox.h>
30 30
31#include <qpe/resource.h> 31#include <qpe/resource.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33 33
34ODict::ODict(QWidget* parent, const char* name, WFlags fl ) : QMainWindow(parent, name, fl ) 34ODict::ODict(QWidget* parent, const char* name, WFlags fl ) : QMainWindow(parent, name, fl )
35{ 35{
36 activated_name = QString::null; 36 activated_name = QString::null;
37 37
38 vbox = new QVBox( this ); 38 vbox = new QVBox( this );
39 setCaption( tr( "Opie-Dictionary" ) ); 39 setCaption( tr( "Opie-Dictionary" ) );
40 setupMenus(); 40 setupMenus();
41 41
42 QHBox *hbox = new QHBox( vbox ); 42 QHBox *hbox = new QHBox( vbox );
43 QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); 43 QLabel* query_label = new QLabel( tr( "Query:" ) , hbox );
44 query_label->show(); 44 query_label->show();
45 query_le = new QLineEdit( hbox ); 45 query_le = new QLineEdit( hbox );
46 query_co = new QComboBox( hbox ); 46 query_co = new QComboBox( hbox );
47 connect( query_co , SIGNAL( activated(const QString&) ), this, SLOT( slotMethodChanged(const QString&) ) ); 47 connect( query_co , SIGNAL( activated(const QString&) ), this, SLOT( slotMethodChanged(const QString&) ) );
48 ok_button = new QPushButton( tr( "&Ok" ), hbox ); 48 ok_button = new QPushButton( tr( "&Ok" ), hbox );
49 connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); 49 connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) );
50 50
51 top_name = new QLabel( vbox ); 51 top_name = new QLabel( vbox );
52 top_name->setAlignment( AlignHCenter ); 52 top_name->setAlignment( AlignHCenter );
53 browser_top = new QTextBrowser( vbox ); 53 browser_top = new QTextBrowser( vbox );
54 bottom_name = new QLabel( vbox ); 54 bottom_name = new QLabel( vbox );
55 bottom_name->setAlignment( AlignHCenter ); 55 bottom_name->setAlignment( AlignHCenter );
56 browser_bottom = new QTextBrowser( vbox ); 56 browser_bottom = new QTextBrowser( vbox );
57 57
58 ding = new DingWidget(); 58 ding = new DingWidget();
59 59
60 loadConfig(); 60 loadConfig();
61 setCentralWidget( vbox ); 61 setCentralWidget( vbox );
62} 62}
63 63
64void ODict::loadConfig() 64void ODict::loadConfig()
65{ 65{
66 /* 66 /*
67 * the name of the last used dictionary 67 * the name of the last used dictionary
68 */ 68 */
69 QString lastname; 69 QString lastname;
70 70
71 Config cfg ( "odict" ); 71 Config cfg ( "odict" );
72 cfg.setGroup( "generalsettings" ); 72 cfg.setGroup( "generalsettings" );
73 casesens = cfg.readEntry( "casesens" ).toInt(); 73 casesens = cfg.readEntry( "casesens" ).toInt();
74 74
75 QString lastDict = cfg.readEntry( "lastdict" ); 75 QString lastDict = cfg.readEntry( "lastdict" );
76 int i = 0, e = 0; 76 int i = 0, e = 0;
77 77
78 QStringList groupListCfg = cfg.groupList().grep( "Method_" ); 78 QStringList groupListCfg = cfg.groupList().grep( "Method_" );
79 query_co->clear(); 79 query_co->clear();
80 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) 80 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it )
81 { 81 {
82 QString name; 82 QString name;
83 cfg.setGroup( *it ); 83 cfg.setGroup( *it );
84 name = cfg.readEntry( "Name" ); 84 name = cfg.readEntry( "Name" );
85 query_co->insertItem( name ); 85 if ( name != QString::null ) {
86 query_co->insertItem( name );
87 }
86 88
87 /* 89 /*
88 * this check is to look up what dictionary has been used the 90 * this check is to look up what dictionary has been used the
89 * last time 91 * last time
90 */ 92 */
91 if ( lastDict == name ) 93 if ( lastDict == name )
92 { 94 {
93 e = i; 95 e = i;
94 lastname = name; 96 lastname = name;
95 } 97 }
96 i++; 98 i++;
97 } 99 }
98 /* 100 /*
99 * now set the two names of the dictionary and the correct QComboBox-Entry 101 * now set the two names of the dictionary and the correct QComboBox-Entry
100 */ 102 */
101 103
102 lookupLanguageNames( lastname ); 104 lookupLanguageNames( lastname );
103 ding->loadDict( lastname ); 105 ding->loadDict( lastname );
104 ding->loadValues(); 106 ding->loadValues();
105 107
106 query_co->setCurrentItem( e ); 108 query_co->setCurrentItem( e );
107 top_name->setText( top_name_content ); 109 top_name->setText( top_name_content );
108 bottom_name->setText( bottom_name_content ); 110 bottom_name->setText( bottom_name_content );
109} 111}
110 112
111void ODict::lookupLanguageNames( QString dictname ) 113void ODict::lookupLanguageNames( QString dictname )
112{ 114{
113 Config cfg ( "odict" ); 115 Config cfg ( "odict" );
114 cfg.setGroup( "Method_"+dictname ); 116 cfg.setGroup( "Method_"+dictname );
115 top_name_content = cfg.readEntry( "Lang1" ); 117 top_name_content = cfg.readEntry( "Lang1" );
116 bottom_name_content = cfg.readEntry( "Lang2" ); 118 bottom_name_content = cfg.readEntry( "Lang2" );
117} 119}
118 120
119void ODict::saveConfig() 121void ODict::saveConfig()
120{ 122{
121 Config cfg ( "odict" ); 123 Config cfg ( "odict" );
122 cfg.setGroup( "generalsettings" ); 124 cfg.setGroup( "generalsettings" );
123 cfg.writeEntry( "casesens" , casesens ); 125 cfg.writeEntry( "casesens" , casesens );
124 cfg.writeEntry( "lastdict" , query_co->currentText() ); 126 cfg.writeEntry( "lastdict" , query_co->currentText() );
125} 127}
126 128
127void ODict::slotStartQuery() 129void ODict::slotStartQuery()
128{ 130{
129 QString querystring = query_le->text(); 131 QString querystring = query_le->text();
130 if ( !querystring.isEmpty() ) 132 if ( !querystring.isEmpty() )
131 { 133 {
132 /* 134 /*
133 * if the user has not yet defined a dictionary 135 * if the user has not yet defined a dictionary
134 */ 136 */
135 if ( !query_co->currentText() ) 137 if ( !query_co->currentText() )
136 { 138 {
137 switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ), 139 switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ),
138 tr( "No dictionary defined" ), 140 tr( "No dictionary defined" ),
139 tr( "&Define one" ), 141 tr( "&Define one" ),
140 tr( "&Cancel" ), 142 tr( "&Cancel" ),
141 0, // Define a dict 143 0, // Define a dict
142 1 ) ) // Cancel choosen 144 1 ) ) // Cancel choosen
143 { 145 {
144 case 0: 146 case 0:
145 slotSettings(); 147 slotSettings();
146 break; 148 break;
147 case 1: // stop here 149 case 1: // stop here
148 return; 150 return;
149 } 151 }
150 } 152 }
151 153
152 /* 154 /*
153 * ok, the user has defined a dict 155 * ok, the user has defined a dict
154 */ 156 */
155 ding->setCaseSensitive( casesens ); 157 ding->setCaseSensitive( casesens );
156 158
157 BroswerContent test = ding->setText( querystring ); 159 BroswerContent test = ding->setText( querystring );
158 160
159 browser_top->setText( test.top ); 161 browser_top->setText( test.top );
160 browser_bottom->setText( test.bottom ); 162 browser_bottom->setText( test.bottom );
161 } 163 }
162} 164}
163 165
164void ODict::slotSettings() 166void ODict::slotSettings()
165{ 167{
166 ConfigDlg dlg( this, "Config" , true); 168 ConfigDlg dlg( this, "Config" , true);
167 if ( dlg.exec() == QDialog::Accepted ) 169 if ( dlg.exec() == QDialog::Accepted )
168 saveConfig(); 170 saveConfig();
169} 171}
170 172
171void ODict::slotSetParameter( int count ) 173void ODict::slotSetParameter( int count )
172{ 174{
173 if ( count == 0 ) 175 if ( count == 0 )
174 { 176 {
175 if ( casesens ) 177 if ( casesens )
176 casesens = false; 178 casesens = false;
177 else 179 else
178 casesens = true; 180 casesens = true;
179 } 181 }
180 182
181 saveConfig(); 183 saveConfig();