summaryrefslogtreecommitdiff
path: root/noncore/apps/odict/odict.cpp
Unidiff
Diffstat (limited to 'noncore/apps/odict/odict.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/odict/odict.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp
index 7de9169..2857c65 100644
--- a/noncore/apps/odict/odict.cpp
+++ b/noncore/apps/odict/odict.cpp
@@ -18,145 +18,153 @@
18#include "configdlg.h" 18#include "configdlg.h"
19#include "dingwidget.h" 19#include "dingwidget.h"
20 20
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qpopupmenu.h> 22#include <qpopupmenu.h>
23#include <qmenubar.h> 23#include <qmenubar.h>
24#include <qmessagebox.h> 24#include <qmessagebox.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qhbox.h> 26#include <qhbox.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qlineedit.h> 30#include <qlineedit.h>
31#include <qmainwindow.h> 31#include <qmainwindow.h>
32#include <qstring.h> 32#include <qstring.h>
33#include <qaction.h> 33#include <qaction.h>
34#include <qtextbrowser.h> 34#include <qtextbrowser.h>
35#include <qcombobox.h> 35#include <qcombobox.h>
36 36
37#include <qpe/resource.h> 37#include <qpe/resource.h>
38 38
39 39
40ODict::ODict() : QMainWindow() 40ODict::ODict() : QMainWindow()
41{ 41{
42
43 activated_name = QString::null;
42 vbox = new QVBox( this ); 44 vbox = new QVBox( this );
43 setCaption( tr( "OPIE-Dictionary" ) ); 45 setCaption( tr( "OPIE-Dictionary" ) );
44 setupMenus(); 46 setupMenus();
45 47
46 QHBox *hbox = new QHBox( vbox ); 48 QHBox *hbox = new QHBox( vbox );
47 QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); 49 QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show();
48 query_le = new QLineEdit( hbox ); 50 query_le = new QLineEdit( hbox );
49 query_co = new QComboBox( hbox ); 51 query_co = new QComboBox( hbox );
52 connect( query_co , SIGNAL( activated(int) ), this, SLOT( slotMethodChanged(int) ) );
50 ok_button = new QPushButton( tr( "&Ok" ), hbox ); 53 ok_button = new QPushButton( tr( "&Ok" ), hbox );
51 connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); 54 connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) );
52 browser_top = new QTextBrowser( vbox ); 55 browser_top = new QTextBrowser( vbox );
53 browser_bottom = new QTextBrowser( vbox ); 56 browser_bottom = new QTextBrowser( vbox );
54 57
55 loadConfig(); 58 loadConfig();
56 setCentralWidget( vbox ); 59 setCentralWidget( vbox );
57} 60}
58 61
59void ODict::loadConfig() 62void ODict::loadConfig()
60{ 63{
61 Config cfg ( "odict" ); 64 Config cfg ( "odict" );
62 cfg.setGroup( "generalsettings" ); 65 cfg.setGroup( "generalsettings" );
63 errorTol = cfg.readEntry( "errtol" ).toInt(); 66 errorTol = cfg.readEntry( "errtol" ).toInt();
64 casesens = cfg.readEntry( "casesens" ).toInt(); 67 casesens = cfg.readEntry( "casesens" ).toInt();
65 regexp = cfg.readEntry( "regexp" ).toInt(); 68 regexp = cfg.readEntry( "regexp" ).toInt();
66 completewords = cfg.readEntry( "completewords" ).toInt(); 69 completewords = cfg.readEntry( "completewords" ).toInt();
67 70
68 QStringList groupListCfg = cfg.groupList().grep( "Method_" ); 71 QStringList groupListCfg = cfg.groupList().grep( "Method_" );
69 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) 72 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it )
70 { 73 {
71 cfg.setGroup( *it ); 74 cfg.setGroup( *it );
72 query_co->insertItem( cfg.readEntry( "Name" ) ); 75 query_co->insertItem( cfg.readEntry( "Name" ) );
73 } 76 }
74} 77}
75 78
76 79
77void ODict::saveConfig() 80void ODict::saveConfig()
78{ 81{
79 Config cfg ( "odict" ); 82 Config cfg ( "odict" );
80 cfg.setGroup( "generalsettings" ); 83 cfg.setGroup( "generalsettings" );
81 cfg.writeEntry( "errtol" , errorTol ); 84 cfg.writeEntry( "errtol" , errorTol );
82 cfg.writeEntry( "casesens" , casesens ); 85 cfg.writeEntry( "casesens" , casesens );
83 cfg.writeEntry( "regexp" , regexp ); 86 cfg.writeEntry( "regexp" , regexp );
84 cfg.writeEntry( "completewords" , completewords ); 87 cfg.writeEntry( "completewords" , completewords );
85} 88}
86 89
87void ODict::slotDisplayAbout() 90void ODict::slotDisplayAbout()
88{ 91{
89 QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20030103" ) ); 92 QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20030103" ) );
90} 93}
91 94
92void ODict::slotStartQuery() 95void ODict::slotStartQuery()
93{ 96{
94 QString querystring = query_le->text(); 97 QString querystring = query_le->text();
95 DingWidget *ding = new DingWidget( vbox , querystring , browser_top, browser_bottom); 98 DingWidget *ding = new DingWidget( vbox , querystring , browser_top, browser_bottom, activated_name);
96} 99}
97 100
98 101
99void ODict::slotSetErrorcount( int count ) 102void ODict::slotSetErrorcount( int count )
100{ 103{
101 errorTol = count; 104 errorTol = count;
102} 105}
103 106
104void ODict::slotSettings() 107void ODict::slotSettings()
105{ 108{
106 ConfigDlg dlg( this, "Config" , true); 109 ConfigDlg dlg( this, "Config" , true);
107 if ( dlg.exec() == QDialog::Accepted ) 110 if ( dlg.exec() == QDialog::Accepted )
108 dlg.writeEntries(); 111 dlg.writeEntries();
109 else qDebug( "abgebrochen" ); 112 else qDebug( "abgebrochen" );
110} 113}
111 114
112void ODict::slotSetParameter( int count ) 115void ODict::slotSetParameter( int count )
113{ 116{
114 if ( count == 0 ) 117 if ( count == 0 )
115 { 118 {
116 if ( casesens ) 119 if ( casesens )
117 casesens = false; 120 casesens = false;
118 else 121 else
119 casesens = true; 122 casesens = true;
120 } 123 }
121 124
122 if ( count == 1 ) 125 if ( count == 1 )
123 { 126 {
124 if ( completewords ) 127 if ( completewords )
125 completewords = false; 128 completewords = false;
126 else 129 else
127 completewords = true; 130 completewords = true;
128 } 131 }
129 if ( count == 2 ) 132 if ( count == 2 )
130 { 133 {
131 if ( regexp ) 134 if ( regexp )
132 regexp = false; 135 regexp = false;
133 else 136 else
134 regexp = true; 137 regexp = true;
135 } 138 }
136 else qWarning( "ERROR" ); 139 else qWarning( "ERROR" );
137} 140}
138 141
142void ODict::slotMethodChanged( int methodnumber )
143{
144 activated_name = query_co->currentText();
145}
146
139void ODict::setupMenus() 147void ODict::setupMenus()
140{ 148{
141 menu = new QMenuBar( this ); 149 menu = new QMenuBar( this );
142 150
143 settings = new QPopupMenu( menu ); 151 settings = new QPopupMenu( menu );
144 setting_a = new QAction(tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); 152 setting_a = new QAction(tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 );
145 connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 153 connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
146 setting_a->addTo( settings ); 154 setting_a->addTo( settings );
147 setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); 155 setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 );
148 156
149 parameter = new QPopupMenu( menu ); 157 parameter = new QPopupMenu( menu );
150 connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); 158 connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) );
151 parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); 159 parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 );
152 parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ; 160 parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ;
153 parameter->insertItem( tr( "Allow &reg. expressions" ), 2 ); 161 parameter->insertItem( tr( "Allow &reg. expressions" ), 2 );
154 parameter->insertSeparator(); 162 parameter->insertSeparator();
155 error_tol_menu = new QPopupMenu( menu ); 163 error_tol_menu = new QPopupMenu( menu );
156 error_tol_menu->setCheckable( TRUE ); 164 error_tol_menu->setCheckable( TRUE );
157 connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) ); 165 connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) );
158 166
159 error_tol_menu->insertItem( tr( "0 Errors" ), 0 ); 167 error_tol_menu->insertItem( tr( "0 Errors" ), 0 );
160 error_tol_menu->insertItem( tr( "1 Errors" ), 1 ); 168 error_tol_menu->insertItem( tr( "1 Errors" ), 1 );
161 error_tol_menu->insertItem( tr( "2 Errors" ), 2 ); 169 error_tol_menu->insertItem( tr( "2 Errors" ), 2 );
162 error_tol_menu->insertItem( tr( "3 Errors" ), 3 ); 170 error_tol_menu->insertItem( tr( "3 Errors" ), 3 );