summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/odict/configdlg.cpp9
-rw-r--r--noncore/apps/odict/odict.cpp8
2 files changed, 14 insertions, 3 deletions
diff --git a/noncore/apps/odict/configdlg.cpp b/noncore/apps/odict/configdlg.cpp
index 33296e3..89bc6f6 100644
--- a/noncore/apps/odict/configdlg.cpp
+++ b/noncore/apps/odict/configdlg.cpp
@@ -1,119 +1,126 @@
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 "configdlg.h" 17#include "configdlg.h"
18#include "searchmethoddlg.h" 18#include "searchmethoddlg.h"
19 19
20#include <qdialog.h> 20#include <qdialog.h>
21#include <qpe/config.h> 21#include <qpe/config.h>
22#include <qlayout.h> 22#include <qlayout.h>
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qlistview.h> 27#include <qlistview.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qstringlist.h> 30#include <qstringlist.h>
31 31
32#include <opie/otabwidget.h> 32#include <opie/otabwidget.h>
33 33
34ConfigDlg::ConfigDlg(QWidget *parent, const char *name, bool modal) : QDialog(parent, name, modal) 34ConfigDlg::ConfigDlg(QWidget *parent, const char *name, bool modal) : QDialog(parent, name, modal)
35{ 35{
36 setCaption( tr( "Options" ) ); 36 setCaption( tr( "Options" ) );
37 QVBoxLayout *vbox_layout = new QVBoxLayout( this ); 37 QVBoxLayout *vbox_layout = new QVBoxLayout( this );
38 tab = new OTabWidget( this, "OTabWidget_tab", OTabWidget::Global, OTabWidget::Bottom ); 38 tab = new OTabWidget( this, "OTabWidget_tab", OTabWidget::Global, OTabWidget::Bottom );
39 vbox_layout->addWidget( tab ); 39 vbox_layout->addWidget( tab );
40 40
41 /*general settings*/ 41 /*general settings*/
42 settings_tab = new QWidget( tab , "settings_tab" ); 42 settings_tab = new QWidget( tab , "settings_tab" );
43 43
44 /*searchmethods*/ 44 /*searchmethods*/
45 search_tab = new QWidget( tab , "search_tab" ); 45 search_tab = new QWidget( tab , "search_tab" );
46 QVBoxLayout *vbox_layout_searchtab = new QVBoxLayout( search_tab, 4 , 4 ,"blah" ); 46 QVBoxLayout *vbox_layout_searchtab = new QVBoxLayout( search_tab, 4 , 4 ,"blah" );
47 47
48 QHBox *hbox = new QHBox( search_tab ); 48 QHBox *hbox = new QHBox( search_tab );
49 list = new QListView( hbox ); 49 list = new QListView( hbox );
50 list->addColumn( tr( "Searchmethod" ) ); 50 list->addColumn( tr( "Searchmethod" ) );
51 loadSearchMethodNames(); 51 loadSearchMethodNames();
52 52
53 QVBox *vbox = new QVBox( hbox ); 53 QVBox *vbox = new QVBox( hbox );
54 new_button = new QPushButton( "New" , vbox ); 54 new_button = new QPushButton( "New" , vbox );
55 change_button = new QPushButton( "Change" , vbox ); 55 change_button = new QPushButton( "Change" , vbox );
56 delete_button = new QPushButton( "Delete" , vbox ); 56 delete_button = new QPushButton( "Delete" , vbox );
57 connect( new_button, SIGNAL( clicked() ), this, SLOT( slotNewMethod() ) ); 57 connect( new_button, SIGNAL( clicked() ), this, SLOT( slotNewMethod() ) );
58 connect( change_button, SIGNAL( clicked() ), this, SLOT( slotChangeMethod() )); 58 connect( change_button, SIGNAL( clicked() ), this, SLOT( slotChangeMethod() ));
59 connect( delete_button, SIGNAL( clicked() ), this, SLOT( slotDeleteMethod() )); 59 connect( delete_button, SIGNAL( clicked() ), this, SLOT( slotDeleteMethod() ));
60 60
61 vbox_layout_searchtab->addWidget( hbox ); 61 vbox_layout_searchtab->addWidget( hbox );
62 62
63 /*add the tabs and maximize*/ 63 /*add the tabs and maximize*/
64 tab->addTab( settings_tab, "pass", tr( "General Settings" ) ); 64 tab->addTab( settings_tab, "pass", tr( "General Settings" ) );
65 tab->addTab( search_tab, "zoom", tr( "Searchmethods" ) ); 65 tab->addTab( search_tab, "zoom", tr( "Searchmethods" ) );
66 showMaximized(); 66 showMaximized();
67} 67}
68 68
69void ConfigDlg::writeEntries() 69void ConfigDlg::writeEntries()
70{ 70{
71 qDebug( "richtig beendet" ); 71 qDebug( "richtig beendet" );
72} 72}
73 73
74void ConfigDlg::slotNewMethod() 74void ConfigDlg::slotNewMethod()
75{ 75{
76 SearchMethodDlg dlg( this, "SearchMethodDlg", true ); 76 SearchMethodDlg dlg( this, "SearchMethodDlg", true );
77 if ( dlg.exec() == QDialog::Accepted ) 77 if ( dlg.exec() == QDialog::Accepted )
78 { 78 {
79 dlg.saveItem(); 79 dlg.saveItem();
80 QListViewItem *item = new QListViewItem( list ); 80 QListViewItem *item = new QListViewItem( list );
81 item->setText( 0 , dlg.nameLE->text() ); 81 item->setText( 0 , dlg.nameLE->text() );
82 } 82 }
83 else qDebug( "SearchMethodDlg abgebrochen" ); 83 else qDebug( "SearchMethodDlg abgebrochen" );
84} 84}
85 85
86void ConfigDlg::slotChangeMethod() 86void ConfigDlg::slotChangeMethod()
87{ 87{
88 if ( list->selectedItem() ) 88 if ( list->selectedItem() )
89 { 89 {
90 SearchMethodDlg dlg( this, "SearchMethodDlg", true, list->selectedItem()->text( 0 ) ); 90 SearchMethodDlg dlg( this, "SearchMethodDlg", true, list->selectedItem()->text( 0 ) );
91 if ( dlg.exec() == QDialog::Accepted ) 91 if ( dlg.exec() == QDialog::Accepted )
92 { 92 {
93 dlg.saveItem(); 93 dlg.saveItem();
94 QListViewItem *item = new QListViewItem( list ); 94 QListViewItem *item = list->selectedItem();
95 item->setText( 0 , dlg.nameLE->text() ); 95 item->setText( 0 , dlg.nameLE->text() );
96 } 96 }
97 else qDebug( "SearchMethodDlg abgebrochen" ); 97 else qDebug( "SearchMethodDlg abgebrochen" );
98 } 98 }
99 else qDebug( "kein item angewählt" ); 99 else qDebug( "kein item angewählt" );
100} 100}
101 101
102void ConfigDlg::slotDeleteMethod() 102void ConfigDlg::slotDeleteMethod()
103{ 103{
104 if ( list->selectedItem() ) 104 if ( list->selectedItem() )
105 {
106 Config cfg ( "odict" );
107 cfg.setGroup( "Method_"+list->selectedItem()->text(0) );
108 cfg.clearGroup();
109 //FIXME: this only removes the entries but not the group itself
110
105 list->takeItem( list->selectedItem() ); 111 list->takeItem( list->selectedItem() );
112 }
106 else qDebug("no item selected"); 113 else qDebug("no item selected");
107} 114}
108 115
109void ConfigDlg::loadSearchMethodNames() 116void ConfigDlg::loadSearchMethodNames()
110{ 117{
111 Config cfg( "odict" ); 118 Config cfg( "odict" );
112 QStringList groupListCfg = cfg.groupList().grep( "Method_" ); 119 QStringList groupListCfg = cfg.groupList().grep( "Method_" );
113 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) 120 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it )
114 { 121 {
115 QListViewItem *item = new QListViewItem( list ); 122 QListViewItem *item = new QListViewItem( list );
116 cfg.setGroup( *it ); 123 cfg.setGroup( *it );
117 item->setText( 0 , cfg.readEntry( "Name" ) ); 124 item->setText( 0 , cfg.readEntry( "Name" ) );
118 } 125 }
119} 126}
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp
index 1fbdb85..e0104eb 100644
--- a/noncore/apps/odict/odict.cpp
+++ b/noncore/apps/odict/odict.cpp
@@ -1,189 +1,193 @@
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 <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 42
43 activated_name = QString::null; 43 activated_name = QString::null;
44 vbox = new QVBox( this ); 44 vbox = new QVBox( this );
45 setCaption( tr( "OPIE-Dictionary" ) ); 45 setCaption( tr( "OPIE-Dictionary" ) );
46 setupMenus(); 46 setupMenus();
47 47
48 QHBox *hbox = new QHBox( vbox ); 48 QHBox *hbox = new QHBox( vbox );
49 QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); 49 QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show();
50 query_le = new QLineEdit( hbox ); 50 query_le = new QLineEdit( hbox );
51 query_co = new QComboBox( hbox ); 51 query_co = new QComboBox( hbox );
52 connect( query_co , SIGNAL( activated(int) ), this, SLOT( slotMethodChanged(int) ) ); 52 connect( query_co , SIGNAL( activated(int) ), this, SLOT( slotMethodChanged(int) ) );
53 ok_button = new QPushButton( tr( "&Ok" ), hbox ); 53 ok_button = new QPushButton( tr( "&Ok" ), hbox );
54 connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); 54 connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) );
55 browser_top = new QTextBrowser( vbox ); 55 browser_top = new QTextBrowser( vbox );
56 browser_bottom = new QTextBrowser( vbox ); 56 browser_bottom = new QTextBrowser( vbox );
57 57
58 loadConfig(); 58 loadConfig();
59 setCentralWidget( vbox ); 59 setCentralWidget( vbox );
60} 60}
61 61
62void ODict::loadConfig() 62void ODict::loadConfig()
63{ 63{
64 Config cfg ( "odict" ); 64 Config cfg ( "odict" );
65 cfg.setGroup( "generalsettings" ); 65 cfg.setGroup( "generalsettings" );
66 errorTol = cfg.readEntry( "errtol" ).toInt(); 66 errorTol = cfg.readEntry( "errtol" ).toInt();
67 casesens = cfg.readEntry( "casesens" ).toInt(); 67 casesens = cfg.readEntry( "casesens" ).toInt();
68 regexp = cfg.readEntry( "regexp" ).toInt(); 68 regexp = cfg.readEntry( "regexp" ).toInt();
69 completewords = cfg.readEntry( "completewords" ).toInt(); 69 completewords = cfg.readEntry( "completewords" ).toInt();
70 70
71 QStringList groupListCfg = cfg.groupList().grep( "Method_" ); 71 QStringList groupListCfg = cfg.groupList().grep( "Method_" );
72 query_co->clear();
72 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) 73 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it )
73 { 74 {
74 cfg.setGroup( *it ); 75 cfg.setGroup( *it );
75 query_co->insertItem( cfg.readEntry( "Name" ) ); 76 query_co->insertItem( cfg.readEntry( "Name" ) );
76 } 77 }
77} 78}
78 79
79 80
80void ODict::saveConfig() 81void ODict::saveConfig()
81{ 82{
82 Config cfg ( "odict" ); 83 Config cfg ( "odict" );
83 cfg.setGroup( "generalsettings" ); 84 cfg.setGroup( "generalsettings" );
84 cfg.writeEntry( "errtol" , errorTol ); 85 cfg.writeEntry( "errtol" , errorTol );
85 cfg.writeEntry( "casesens" , casesens ); 86 cfg.writeEntry( "casesens" , casesens );
86 cfg.writeEntry( "regexp" , regexp ); 87 cfg.writeEntry( "regexp" , regexp );
87 cfg.writeEntry( "completewords" , completewords ); 88 cfg.writeEntry( "completewords" , completewords );
88} 89}
89 90
90void ODict::slotDisplayAbout() 91void ODict::slotDisplayAbout()
91{ 92{
92 QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20030103" ) ); 93 QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20030104" ) );
93} 94}
94 95
95void ODict::slotStartQuery() 96void ODict::slotStartQuery()
96{ 97{
97 QString querystring = query_le->text(); 98 QString querystring = query_le->text();
98 qDebug("opening dict >%s< for >%s<", activated_name.latin1(),querystring.latin1()); 99 qDebug("opening dict >%s< for >%s<", activated_name.latin1(),querystring.latin1());
99 if (querystring.isEmpty()){ 100 if (querystring.isEmpty()){
100 qWarning("empty querysting"); 101 qWarning("empty querystring");
101 return; 102 return;
102 } 103 }
103 if (!activated_name || activated_name.isEmpty()) 104 if (!activated_name || activated_name.isEmpty())
104 QMessageBox::warning(this,tr("No Dictionary"),tr("Please choose a dictonary") ); 105 QMessageBox::warning(this,tr("No Dictionary"),tr("Please choose a dictonary") );
105 else 106 else
106 DingWidget *ding = new DingWidget( querystring , browser_top, browser_bottom, activated_name ); 107 DingWidget *ding = new DingWidget( querystring , browser_top, browser_bottom, activated_name );
107} 108}
108 109
109 110
110void ODict::slotSetErrorcount( int count ) 111void ODict::slotSetErrorcount( int count )
111{ 112{
112 errorTol = count; 113 errorTol = count;
113} 114}
114 115
115void ODict::slotSettings() 116void ODict::slotSettings()
116{ 117{
117 ConfigDlg dlg( this, "Config" , true); 118 ConfigDlg dlg( this, "Config" , true);
118 if ( dlg.exec() == QDialog::Accepted ) 119 if ( dlg.exec() == QDialog::Accepted )
120 {
119 dlg.writeEntries(); 121 dlg.writeEntries();
122 loadConfig();
123 }
120 else qDebug( "abgebrochen" ); 124 else qDebug( "abgebrochen" );
121} 125}
122 126
123void ODict::slotSetParameter( int count ) 127void ODict::slotSetParameter( int count )
124{ 128{
125 if ( count == 0 ) 129 if ( count == 0 )
126 { 130 {
127 if ( casesens ) 131 if ( casesens )
128 casesens = false; 132 casesens = false;
129 else 133 else
130 casesens = true; 134 casesens = true;
131 } 135 }
132 136
133 if ( count == 1 ) 137 if ( count == 1 )
134 { 138 {
135 if ( completewords ) 139 if ( completewords )
136 completewords = false; 140 completewords = false;
137 else 141 else
138 completewords = true; 142 completewords = true;
139 } 143 }
140 if ( count == 2 ) 144 if ( count == 2 )
141 { 145 {
142 if ( regexp ) 146 if ( regexp )
143 regexp = false; 147 regexp = false;
144 else 148 else
145 regexp = true; 149 regexp = true;
146 } 150 }
147 else qWarning( "ERROR" ); 151 else qWarning( "ERROR" );
148} 152}
149 153
150void ODict::slotMethodChanged( int methodnumber ) 154void ODict::slotMethodChanged( int methodnumber )
151{ 155{
152 activated_name = query_co->currentText(); 156 activated_name = query_co->currentText();
153} 157}
154 158
155void ODict::setupMenus() 159void ODict::setupMenus()
156{ 160{
157 menu = new QMenuBar( this ); 161 menu = new QMenuBar( this );
158 162
159 settings = new QPopupMenu( menu ); 163 settings = new QPopupMenu( menu );
160 setting_a = new QAction(tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); 164 setting_a = new QAction(tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 );
161 connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 165 connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
162 setting_a->addTo( settings ); 166 setting_a->addTo( settings );
163 setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); 167 setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 );
164 168
165 parameter = new QPopupMenu( menu ); 169 parameter = new QPopupMenu( menu );
166 connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); 170 connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) );
167 parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); 171 parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 );
168 parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ; 172 parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ;
169 parameter->insertItem( tr( "Allow &reg. expressions" ), 2 ); 173 parameter->insertItem( tr( "Allow &reg. expressions" ), 2 );
170 parameter->insertSeparator(); 174 parameter->insertSeparator();
171 error_tol_menu = new QPopupMenu( menu ); 175 error_tol_menu = new QPopupMenu( menu );
172 error_tol_menu->setCheckable( TRUE ); 176 error_tol_menu->setCheckable( TRUE );
173 connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) ); 177 connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) );
174 178
175 error_tol_menu->insertItem( tr( "0 Errors" ), 0 ); 179 error_tol_menu->insertItem( tr( "0 Errors" ), 0 );
176 error_tol_menu->insertItem( tr( "1 Errors" ), 1 ); 180 error_tol_menu->insertItem( tr( "1 Errors" ), 1 );
177 error_tol_menu->insertItem( tr( "2 Errors" ), 2 ); 181 error_tol_menu->insertItem( tr( "2 Errors" ), 2 );
178 error_tol_menu->insertItem( tr( "3 Errors" ), 3 ); 182 error_tol_menu->insertItem( tr( "3 Errors" ), 3 );
179 error_tol_menu->insertItem( tr( "4 Errors" ), 4 ); 183 error_tol_menu->insertItem( tr( "4 Errors" ), 4 );
180 error_tol_menu->insertItem( tr( "Until Hit" ), 5 ); 184 error_tol_menu->insertItem( tr( "Until Hit" ), 5 );
181 parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu ); 185 parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu );
182 186
183 help = new QPopupMenu( menu ); 187 help = new QPopupMenu( menu );
184 help->insertItem("&About",this,SLOT( slotDisplayAbout() )); 188 help->insertItem("&About",this,SLOT( slotDisplayAbout() ));
185 189
186 menu->insertItem( tr( "Settings" ) , settings ); 190 menu->insertItem( tr( "Settings" ) , settings );
187 menu->insertItem( tr( "Parameter" ) , parameter ); 191 menu->insertItem( tr( "Parameter" ) , parameter );
188 menu->insertItem( tr( "Help" ) , help ); 192 menu->insertItem( tr( "Help" ) , help );
189} 193}