author | cniehaus <cniehaus> | 2002-12-29 19:47:28 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2002-12-29 19:47:28 (UTC) |
commit | 434257fad7fe9d5697ed17245671ce470ab15b14 (patch) (unidiff) | |
tree | 999c81a34bcdd4f97f2375b4e4cc2264f433392c | |
parent | 28ca378c37c5e2d4d478a6ba2ea36bdd0cccb543 (diff) | |
download | opie-434257fad7fe9d5697ed17245671ce470ab15b14.zip opie-434257fad7fe9d5697ed17245671ce470ab15b14.tar.gz opie-434257fad7fe9d5697ed17245671ce470ab15b14.tar.bz2 |
read in config, write config
-rw-r--r-- | noncore/apps/odict/odict.cpp | 59 | ||||
-rw-r--r-- | noncore/apps/odict/odict.h | 6 |
2 files changed, 56 insertions, 9 deletions
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp index 7f369d4..0412807 100644 --- a/noncore/apps/odict/odict.cpp +++ b/noncore/apps/odict/odict.cpp | |||
@@ -1,117 +1,158 @@ | |||
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 | 19 | ||
20 | #include <opie/otabwidget.h> | 20 | #include <opie/otabwidget.h> |
21 | 21 | ||
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 <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
30 | #include <qmainwindow.h> | 30 | #include <qmainwindow.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qaction.h> | 32 | #include <qaction.h> |
33 | 33 | ||
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | 35 | ||
36 | 36 | ||
37 | ODict::ODict() : QMainWindow() | 37 | ODict::ODict() : QMainWindow() |
38 | { | 38 | { |
39 | setCaption( tr( "OPIE-Dictionary" ) ); | 39 | setCaption( tr( "OPIE-Dictionary" ) ); |
40 | setupMenus(); | 40 | setupMenus(); |
41 | 41 | ||
42 | QHBox *hbox = new QHBox( this ); | 42 | QHBox *hbox = new QHBox( this ); |
43 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); | 43 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); |
44 | query_le = new QLineEdit( hbox ); | 44 | query_le = new QLineEdit( hbox ); |
45 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); | 45 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); |
46 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); | 46 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); |
47 | 47 | ||
48 | setCentralWidget( hbox ); | 48 | setCentralWidget( hbox ); |
49 | loadConfig(); | ||
50 | } | ||
51 | |||
52 | void ODict::loadConfig() | ||
53 | { | ||
54 | Config cfg ( "odict" ); | ||
55 | cfg.setGroup( "generalsettings" ); | ||
56 | errorTol = cfg.readEntry( "errtol" ).toInt(); | ||
57 | casesens = cfg.readEntry( "casesens" ).toInt(); | ||
58 | regexp = cfg.readEntry( "regexp" ).toInt(); | ||
59 | completewords = cfg.readEntry( "completewords" ).toInt(); | ||
60 | } | ||
61 | |||
62 | |||
63 | void ODict::saveConfig() | ||
64 | { | ||
65 | Config cfg ( "odict" ); | ||
66 | cfg.setGroup( "generalsettings" ); | ||
67 | cfg.writeEntry( "errtol" , errorTol ); | ||
68 | cfg.writeEntry( "casesens" , casesens ); | ||
69 | cfg.writeEntry( "regexp" , regexp ); | ||
70 | cfg.writeEntry( "completewords" , completewords ); | ||
49 | } | 71 | } |
50 | 72 | ||
51 | void ODict::slotDisplayAbout() | 73 | void ODict::slotDisplayAbout() |
52 | { | 74 | { |
53 | QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 0.1" ) ); | 75 | QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20021230" ) ); |
54 | } | 76 | } |
55 | 77 | ||
56 | void ODict::slotStartQuery() | 78 | void ODict::slotStartQuery() |
57 | { | 79 | { |
58 | QString querystring = query_le->text(); | 80 | QString querystring = query_le->text(); |
59 | } | 81 | } |
60 | 82 | ||
61 | 83 | ||
62 | void ODict::slotSetErrorcount( int count ) | 84 | void ODict::slotSetErrorcount( int count ) |
63 | { | 85 | { |
64 | count = 1; | 86 | errorTol = count; |
65 | } | 87 | } |
66 | 88 | ||
67 | void ODict::slotSettings() | 89 | void ODict::slotSettings() |
68 | { | 90 | { |
69 | ConfigDlg dlg( this, "Config" , true); | 91 | ConfigDlg dlg( this, "Config" , true); |
70 | if ( dlg.exec() == QDialog::Accepted ) | 92 | if ( dlg.exec() == QDialog::Accepted ) |
71 | dlg.writeEntries(); | 93 | dlg.writeEntries(); |
72 | else qDebug( "abgebrochen" ); | 94 | else qDebug( "abgebrochen" ); |
73 | } | 95 | } |
74 | 96 | ||
75 | void ODict::slotSetParameter( int /*count*/ ) | 97 | void ODict::slotSetParameter( int count ) |
76 | { | 98 | { |
77 | //X if ( int == 0 ) | 99 | if ( count == 0 ) |
78 | //X if ( int == 1 ) | 100 | { |
79 | //X if ( int == 2 ) | 101 | if ( casesens ) |
80 | //X else qWarning( "ERROR" ); | 102 | casesens = false; |
103 | else | ||
104 | casesens = true; | ||
105 | } | ||
106 | |||
107 | if ( count == 1 ) | ||
108 | { | ||
109 | if ( completewords ) | ||
110 | completewords = false; | ||
111 | else | ||
112 | completewords = true; | ||
113 | } | ||
114 | if ( count == 2 ) | ||
115 | { | ||
116 | if ( regexp ) | ||
117 | regexp = false; | ||
118 | else | ||
119 | regexp = true; | ||
120 | } | ||
121 | else qWarning( "ERROR" ); | ||
81 | } | 122 | } |
82 | 123 | ||
83 | void ODict::setupMenus() | 124 | void ODict::setupMenus() |
84 | { | 125 | { |
85 | menu = new QMenuBar( this ); | 126 | menu = new QMenuBar( this ); |
86 | 127 | ||
87 | settings = new QPopupMenu( menu ); | 128 | settings = new QPopupMenu( menu ); |
88 | setting_a = new QAction(tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); | 129 | setting_a = new QAction(tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); |
89 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 130 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
90 | setting_a->addTo( settings ); | 131 | setting_a->addTo( settings ); |
91 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); | 132 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); |
92 | 133 | ||
93 | parameter = new QPopupMenu( menu ); | 134 | parameter = new QPopupMenu( menu ); |
94 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); | 135 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); |
95 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ); | 136 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); |
96 | parameter->insertItem( tr( "Only &complete Words" ), 1 ) ; | 137 | parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ; |
97 | parameter->insertItem( tr( "Allow ®. expressions" ), 2 ); | 138 | parameter->insertItem( tr( "Allow ®. expressions" ), 2 ); |
98 | parameter->insertSeparator(); | 139 | parameter->insertSeparator(); |
99 | error_tol_menu = new QPopupMenu( menu ); | 140 | error_tol_menu = new QPopupMenu( menu ); |
100 | error_tol_menu->setCheckable( TRUE ); | 141 | error_tol_menu->setCheckable( TRUE ); |
101 | connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) ); | 142 | connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) ); |
102 | 143 | ||
103 | error_tol_menu->insertItem( tr( "0 Errors" ), 0 ); | 144 | error_tol_menu->insertItem( tr( "0 Errors" ), 0 ); |
104 | error_tol_menu->insertItem( tr( "1 Errors" ), 1 ); | 145 | error_tol_menu->insertItem( tr( "1 Errors" ), 1 ); |
105 | error_tol_menu->insertItem( tr( "2 Errors" ), 2 ); | 146 | error_tol_menu->insertItem( tr( "2 Errors" ), 2 ); |
106 | error_tol_menu->insertItem( tr( "3 Errors" ), 3 ); | 147 | error_tol_menu->insertItem( tr( "3 Errors" ), 3 ); |
107 | error_tol_menu->insertItem( tr( "4 Errors" ), 4 ); | 148 | error_tol_menu->insertItem( tr( "4 Errors" ), 4 ); |
108 | error_tol_menu->insertItem( tr( "Until Hit" ), 5 ); | 149 | error_tol_menu->insertItem( tr( "Until Hit" ), 5 ); |
109 | parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu ); | 150 | parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu ); |
110 | 151 | ||
111 | help = new QPopupMenu( menu ); | 152 | help = new QPopupMenu( menu ); |
112 | help->insertItem("&About",this,SLOT( slotDisplayAbout() )); | 153 | help->insertItem("&About",this,SLOT( slotDisplayAbout() )); |
113 | 154 | ||
114 | menu->insertItem( tr( "Settings" ) , settings ); | 155 | menu->insertItem( tr( "Settings" ) , settings ); |
115 | menu->insertItem( tr( "Parameter" ) , parameter ); | 156 | menu->insertItem( tr( "Parameter" ) , parameter ); |
116 | menu->insertItem( tr( "Help" ) , help ); | 157 | menu->insertItem( tr( "Help" ) , help ); |
117 | } | 158 | } |
diff --git a/noncore/apps/odict/odict.h b/noncore/apps/odict/odict.h index 30307c1..014e488 100644 --- a/noncore/apps/odict/odict.h +++ b/noncore/apps/odict/odict.h | |||
@@ -1,44 +1,50 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * ( at your option ) any later version. * | 6 | * ( at your option ) any later version. * |
7 | * * | 7 | * * |
8 | **************************************************************************/ | 8 | **************************************************************************/ |
9 | 9 | ||
10 | #include <qmainwindow.h> | 10 | #include <qmainwindow.h> |
11 | 11 | ||
12 | class QPopupMenu; | 12 | class QPopupMenu; |
13 | class QMenuBar; | 13 | class QMenuBar; |
14 | class QHBox; | 14 | class QHBox; |
15 | class QPushButton; | 15 | class QPushButton; |
16 | class QLineEdit; | 16 | class QLineEdit; |
17 | class QAction; | 17 | class QAction; |
18 | class QActionGroup; | 18 | class QActionGroup; |
19 | 19 | ||
20 | class ODict : public QMainWindow | 20 | class ODict : public QMainWindow |
21 | { | 21 | { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | 23 | ||
24 | public: | 24 | public: |
25 | ODict(); | 25 | ODict(); |
26 | 26 | ||
27 | private: | 27 | private: |
28 | QPopupMenu *help, *settings, *parameter, *error_tol_menu; | 28 | QPopupMenu *help, *settings, *parameter, *error_tol_menu; |
29 | QMenuBar *menu; | 29 | QMenuBar *menu; |
30 | QHBox *hbox; | 30 | QHBox *hbox; |
31 | QLineEdit *query_le; | 31 | QLineEdit *query_le; |
32 | QPushButton *ok_button; | 32 | QPushButton *ok_button; |
33 | 33 | ||
34 | QAction *setting_a, *setting_b; | 34 | QAction *setting_a, *setting_b; |
35 | 35 | ||
36 | void setupMenus(); | 36 | void setupMenus(); |
37 | |||
38 | int errorTol; | ||
39 | bool casesens, completewords, regexp; | ||
40 | |||
41 | void loadConfig(); | ||
42 | void saveConfig(); | ||
37 | 43 | ||
38 | private slots: | 44 | private slots: |
39 | void slotDisplayAbout(); | 45 | void slotDisplayAbout(); |
40 | void slotStartQuery(); | 46 | void slotStartQuery(); |
41 | void slotSetErrorcount( int ); | 47 | void slotSetErrorcount( int ); |
42 | void slotSettings(); | 48 | void slotSettings(); |
43 | void slotSetParameter( int ); | 49 | void slotSetParameter( int ); |
44 | }; | 50 | }; |