summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/odict/configdlg.cpp8
-rw-r--r--noncore/apps/odict/dingwidget.cpp2
-rw-r--r--noncore/apps/odict/dingwidget.h3
-rw-r--r--noncore/apps/odict/odict.cpp99
-rw-r--r--noncore/apps/odict/odict.h5
5 files changed, 67 insertions, 50 deletions
diff --git a/noncore/apps/odict/configdlg.cpp b/noncore/apps/odict/configdlg.cpp
index eba7dec..1608486 100644
--- a/noncore/apps/odict/configdlg.cpp
+++ b/noncore/apps/odict/configdlg.cpp
@@ -59,69 +59,63 @@ ConfigDlg::ConfigDlg(QWidget *parent, const char *name, bool modal) : QDialog(pa
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 //XXX wozu gibt es diese Methode?
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 //if ( !dlg.nameLE->text() ) return; //XXX
80 dlg.saveItem(); 79 dlg.saveItem();
81 QListViewItem *item = new QListViewItem( list ); 80 QListViewItem *item = new QListViewItem( list );
82 item->setText( 0 , dlg.nameLE->text() ); 81 item->setText( 0 , dlg.nameLE->text() );
83 } 82 }
84 else qDebug( "SearchMethodDlg abgebrochen" );
85} 83}
86 84
87void ConfigDlg::slotChangeMethod() 85void ConfigDlg::slotChangeMethod()
88{ 86{
89 if ( list->selectedItem() ) 87 if ( list->selectedItem() )
90 { 88 {
91 SearchMethodDlg dlg( this, "SearchMethodDlg", true, list->selectedItem()->text( 0 ) ); 89 SearchMethodDlg dlg( this, "SearchMethodDlg", true, list->selectedItem()->text( 0 ) );
92 if ( dlg.exec() == QDialog::Accepted ) 90 if ( dlg.exec() == QDialog::Accepted )
93 { 91 {
94 //if ( !dlg.nameLE->text() ) return; //XXX geht vielleich nicht
95 dlg.saveItem(); 92 dlg.saveItem();
96 QListViewItem *item = list->selectedItem(); 93 QListViewItem *item = list->selectedItem();
97 item->setText( 0 , dlg.nameLE->text() ); 94 item->setText( 0 , dlg.nameLE->text() );
98 } 95 }
99 else qDebug( "SearchMethodDlg abgebrochen" );
100 } 96 }
101 else qDebug( "kein item angewählt" );
102} 97}
103 98
104void ConfigDlg::slotDeleteMethod() 99void ConfigDlg::slotDeleteMethod()
105{ 100{
106 if ( list->selectedItem() ) 101 if ( list->selectedItem() )
107 { 102 {
108 Config cfg ( "odict" ); 103 Config cfg ( "odict" );
109 cfg.setGroup( "Method_"+list->selectedItem()->text(0) ); 104 cfg.setGroup( "Method_"+list->selectedItem()->text(0) );
110 cfg.clearGroup(); 105 cfg.clearGroup();
111 //FIXME: this only removes the entries but not the group itself 106 //FIXME: this only removes the entries but not the group itself
112 107
113 list->takeItem( list->selectedItem() ); 108 list->takeItem( list->selectedItem() );
114 } 109 }
115 else qDebug("no item selected");
116} 110}
117 111
118void ConfigDlg::loadSearchMethodNames() 112void ConfigDlg::loadSearchMethodNames()
119{ 113{
120 Config cfg( "odict" ); 114 Config cfg( "odict" );
121 QStringList groupListCfg = cfg.groupList().grep( "Method_" ); 115 QStringList groupListCfg = cfg.groupList().grep( "Method_" );
122 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) 116 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it )
123 { 117 {
124 QListViewItem *item = new QListViewItem( list ); 118 QListViewItem *item = new QListViewItem( list );
125 cfg.setGroup( *it ); 119 cfg.setGroup( *it );
126 item->setText( 0 , cfg.readEntry( "Name" ) ); 120 item->setText( 0 , cfg.readEntry( "Name" ) );
127 } 121 }
diff --git a/noncore/apps/odict/dingwidget.cpp b/noncore/apps/odict/dingwidget.cpp
index abb5e75..0707bfb 100644
--- a/noncore/apps/odict/dingwidget.cpp
+++ b/noncore/apps/odict/dingwidget.cpp
@@ -80,24 +80,26 @@ void DingWidget::setCompleteWord( bool cword )
80void DingWidget::setQueryWord( QString qword ) 80void DingWidget::setQueryWord( QString qword )
81{ 81{
82 queryword = qword; 82 queryword = qword;
83} 83}
84 84
85 85
86void DingWidget::loadValues() 86void DingWidget::loadValues()
87{ 87{
88 if ( !methodname ) return; 88 if ( !methodname ) return;
89 Config cfg( "odict" ); 89 Config cfg( "odict" );
90 cfg.setGroup( "Method_" + methodname ); 90 cfg.setGroup( "Method_" + methodname );
91 trenner = cfg.readEntry( "Seperator" ); 91 trenner = cfg.readEntry( "Seperator" );
92 lang1_name = cfg.readEntry( "Lang1" );
93 lang2_name = cfg.readEntry( "Lang2" );
92} 94}
93 95
94BroswerContent DingWidget::setText( QString word ) 96BroswerContent DingWidget::setText( QString word )
95{ 97{
96 queryword = word; 98 queryword = word;
97 return parseInfo(); 99 return parseInfo();
98} 100}
99 101
100 102
101BroswerContent DingWidget::parseInfo() 103BroswerContent DingWidget::parseInfo()
102{ 104{
103 if ( isCompleteWord ) 105 if ( isCompleteWord )
diff --git a/noncore/apps/odict/dingwidget.h b/noncore/apps/odict/dingwidget.h
index 74f40c9..d8466cb 100644
--- a/noncore/apps/odict/dingwidget.h
+++ b/noncore/apps/odict/dingwidget.h
@@ -21,24 +21,27 @@ class DingWidget
21 public: 21 public:
22 DingWidget(); 22 DingWidget();
23 23
24 BroswerContent setText( QString ); 24 BroswerContent setText( QString );
25 QStringList lines; 25 QStringList lines;
26 void setCaseSensitive( bool ); 26 void setCaseSensitive( bool );
27 void setCompleteWord( bool ); 27 void setCompleteWord( bool );
28 void loadDict( QString ); 28 void loadDict( QString );
29 QString loadedDict(); 29 QString loadedDict();
30 void setQueryWord( QString ); 30 void setQueryWord( QString );
31 void setDict( QString ); 31 void setDict( QString );
32 void loadValues(); 32 void loadValues();
33
34 QString lang1_name,
35 lang2_name;
33 36
34 private: 37 private:
35 BroswerContent parseInfo(); 38 BroswerContent parseInfo();
36 39
37 BroswerContent s_strings; 40 BroswerContent s_strings;
38 bool isCompleteWord; 41 bool isCompleteWord;
39 bool isCaseSensitive; 42 bool isCaseSensitive;
40 43
41 QString dictName; 44 QString dictName;
42 45
43 QString search_word; 46 QString search_word;
44 QString queryword; 47 QString queryword;
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp
index 9f9a8d9..cb9c4e0 100644
--- a/noncore/apps/odict/odict.cpp
+++ b/noncore/apps/odict/odict.cpp
@@ -37,125 +37,132 @@
37#include <qpe/resource.h> 37#include <qpe/resource.h>
38 38
39 39
40ODict::ODict() : QMainWindow() 40ODict::ODict() : QMainWindow()
41{ 41{
42 activated_name = QString::null; 42 activated_name = QString::null;
43 43
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 );
50 query_label->show();
50 query_le = new QLineEdit( hbox ); 51 query_le = new QLineEdit( hbox );
51 query_co = new QComboBox( hbox ); 52 query_co = new QComboBox( hbox );
52 connect( query_co , SIGNAL( activated(int) ), this, SLOT( slotMethodChanged(int) ) ); 53 connect( query_co , SIGNAL( activated(const QString&) ), this, SLOT( slotMethodChanged(const QString&) ) );
53 ok_button = new QPushButton( tr( "&Ok" ), hbox ); 54 ok_button = new QPushButton( tr( "&Ok" ), hbox );
54 connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); 55 connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) );
56 top_name = new QLabel( vbox );
55 browser_top = new QTextBrowser( vbox ); 57 browser_top = new QTextBrowser( vbox );
58 bottom_name = new QLabel( vbox );
56 browser_bottom = new QTextBrowser( vbox ); 59 browser_bottom = new QTextBrowser( vbox );
57 60
58 ding = new DingWidget(); 61 ding = new DingWidget();
59 ding->loadValues(); 62 ding->loadValues();
60 63
61 loadConfig(); 64 loadConfig();
62 setCentralWidget( vbox ); 65 setCentralWidget( vbox );
63} 66}
64 67
65void ODict::loadConfig() 68void ODict::loadConfig()
66{ 69{
67 Config cfg ( "odict" ); 70 Config cfg ( "odict" );
68 cfg.setGroup( "generalsettings" ); 71 cfg.setGroup( "generalsettings" );
69 errorTol = cfg.readEntry( "errtol" ).toInt(); 72 errorTol = cfg.readEntry( "errtol" ).toInt();
70 casesens = cfg.readEntry( "casesens" ).toInt(); 73 casesens = cfg.readEntry( "casesens" ).toInt();
71 regexp = cfg.readEntry( "regexp" ).toInt(); 74 regexp = cfg.readEntry( "regexp" ).toInt();
72 completewords = cfg.readEntry( "completewords" ).toInt(); 75 completewords = cfg.readEntry( "completewords" ).toInt();
73 76
74 QStringList groupListCfg = cfg.groupList().grep( "Method_" ); 77 QStringList groupListCfg = cfg.groupList().grep( "Method_" );
75 query_co->clear(); 78 query_co->clear();
76 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) 79 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it )
77 { 80 {
78 cfg.setGroup( *it ); 81 cfg.setGroup( *it );
79 query_co->insertItem( cfg.readEntry( "Name" ) ); 82 query_co->insertItem( cfg.readEntry( "Name" ) );
80 } 83 }
81 slotMethodChanged( 1 ); //FIXME: this line should not contain a integer 84 //XXXslotMethodChanged( "1" ); //FIXME: this line should not contain a integer
82} 85}
83 86
84 87
85void ODict::saveConfig() 88void ODict::saveConfig()
86{ 89{
87 Config cfg ( "odict" ); 90 Config cfg ( "odict" );
88 cfg.setGroup( "generalsettings" ); 91 cfg.setGroup( "generalsettings" );
89 cfg.writeEntry( "errtol" , errorTol ); 92 cfg.writeEntry( "errtol" , errorTol );
90 cfg.writeEntry( "casesens" , casesens ); 93 cfg.writeEntry( "casesens" , casesens );
91 cfg.writeEntry( "regexp" , regexp ); 94 cfg.writeEntry( "regexp" , regexp );
92 cfg.writeEntry( "completewords" , completewords ); 95 cfg.writeEntry( "completewords" , completewords );
93} 96}
94 97
95void ODict::slotStartQuery() 98void ODict::slotStartQuery()
96{ 99{
97 /* 100 if ( !query_le->text( ).isEmpty() )
98 * if the user has not yet defined a dictionary
99 */
100 if ( !query_co->currentText() )
101 { 101 {
102 switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ), 102 /*
103 tr( "No dictionary defined" ), 103 * if the user has not yet defined a dictionary
104 tr( "&Define one" ), 104 */
105 tr( "&Cancel" ), 105 if ( !query_co->currentText() )
106 0, // Define a dict choosen 106 {
107 1 ) ) // Cancel choosen 107 switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ),
108 { 108 tr( "No dictionary defined" ),
109 109 tr( "&Define one" ),
110 case 0: 110 tr( "&Cancel" ),
111 slotSettings(); 111 0, // Define a dict choosen
112 break; 112 1 ) ) // Cancel choosen
113 case 1: // stop here 113 {
114 return; 114
115 } 115 case 0:
116 } 116 slotSettings();
117 117 break;
118 /* 118 case 1: // stop here
119 * ok, the user has defined a dict 119 return;
120 */ 120 }
121 QString querystring = query_le->text(); 121 }
122 ding->setCaseSensitive( casesens ); 122
123 ding->setCompleteWord( completewords ); 123 /*
124 ding->setDict( activated_name ); 124 * ok, the user has defined a dict
125 125 */
126 if ( activated_name != ding->loadedDict() ) 126 QString querystring = query_le->text();
127 ding->loadDict(activated_name); 127 ding->setCaseSensitive( casesens );
128 128 ding->setCompleteWord( completewords );
129 BroswerContent test = ding->setText( querystring ); 129 ding->setDict( activated_name );
130 130 top_name->setText( ding->lang1_name );
131 browser_top->setText( test.top ); 131 bottom_name->setText( ding->lang2_name );
132 browser_bottom->setText( test.bottom ); 132
133 if ( activated_name != ding->loadedDict() )
134 ding->loadDict(activated_name);
135
136 BroswerContent test = ding->setText( querystring );
137
138 browser_top->setText( test.top );
139 browser_bottom->setText( test.bottom );
140 }
133} 141}
134 142
135 143
136void ODict::slotSetErrorcount( int count ) 144void ODict::slotSetErrorcount( int count )
137{ 145{
138 errorTol = count; 146 errorTol = count;
139} 147}
140 148
141void ODict::slotSettings() 149void ODict::slotSettings()
142{ 150{
143 ConfigDlg dlg( this, "Config" , true); 151 ConfigDlg dlg( this, "Config" , true);
144 if ( dlg.exec() == QDialog::Accepted ) 152 if ( dlg.exec() == QDialog::Accepted )
145 { 153 {
146 dlg.writeEntries(); 154 dlg.writeEntries();
147 loadConfig(); 155 loadConfig();
148 } 156 }
149 else qDebug( "abgebrochen" );
150} 157}
151 158
152void ODict::slotSetParameter( int count ) 159void ODict::slotSetParameter( int count )
153{ 160{
154 if ( count == 0 ) 161 if ( count == 0 )
155 { 162 {
156 if ( casesens ) 163 if ( casesens )
157 casesens = false; 164 casesens = false;
158 else 165 else
159 casesens = true; 166 casesens = true;
160 } 167 }
161 168
@@ -167,27 +174,35 @@ void ODict::slotSetParameter( int count )
167 completewords = true; 174 completewords = true;
168 } 175 }
169 if ( count == 2 ) 176 if ( count == 2 )
170 { 177 {
171 if ( regexp ) 178 if ( regexp )
172 regexp = false; 179 regexp = false;
173 else 180 else
174 regexp = true; 181 regexp = true;
175 } 182 }
176 else qWarning( "ERROR" ); 183 else qWarning( "ERROR" );
177} 184}
178 185
179void ODict::slotMethodChanged( int /*methodnumber*/ ) 186void ODict::slotMethodChanged( const QString& methodnumber )
180{ 187{
181 activated_name = query_co->currentText(); 188 activated_name = methodnumber;
189
190 if ( activated_name != ding->loadedDict() )
191 ding->loadDict(activated_name);
192
193 top_name->setText( ding->lang1_name );
194 top_name->setAlignment( AlignHCenter );
195 bottom_name->setText( ding->lang2_name );
196 bottom_name->setAlignment( AlignHCenter );
182} 197}
183 198
184void ODict::setupMenus() 199void ODict::setupMenus()
185{ 200{
186 menu = new QMenuBar( this ); 201 menu = new QMenuBar( this );
187 202
188 settings = new QPopupMenu( menu ); 203 settings = new QPopupMenu( menu );
189 setting_a = new QAction(tr( "Configuration" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 204 setting_a = new QAction(tr( "Configuration" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
190 connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 205 connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
191 setting_a->addTo( settings ); 206 setting_a->addTo( settings );
192 setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); 207 setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 );
193 208
diff --git a/noncore/apps/odict/odict.h b/noncore/apps/odict/odict.h
index 3065feb..b9a0778 100644
--- a/noncore/apps/odict/odict.h
+++ b/noncore/apps/odict/odict.h
@@ -1,23 +1,24 @@
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
12class QLabel;
12class QVBox; 13class QVBox;
13class QPopupMenu; 14class QPopupMenu;
14class QMenuBar; 15class QMenuBar;
15class QHBox; 16class QHBox;
16class QPushButton; 17class QPushButton;
17class QLineEdit; 18class QLineEdit;
18class QAction; 19class QAction;
19class QVBoxLayout; 20class QVBoxLayout;
20class QActionGroup; 21class QActionGroup;
21class DingWidget; 22class DingWidget;
22class QTextBrowser; 23class QTextBrowser;
23class QComboBox; 24class QComboBox;
@@ -46,20 +47,22 @@ class ODict : public QMainWindow
46 47
47 QAction *setting_a, *setting_b; 48 QAction *setting_a, *setting_b;
48 49
49 void setupMenus(); 50 void setupMenus();
50 51
51 int errorTol; 52 int errorTol;
52 bool casesens, completewords, regexp; 53 bool casesens, completewords, regexp;
53 54
54 void loadConfig(); 55 void loadConfig();
55 void saveConfig(); 56 void saveConfig();
56 57
57 QString activated_name; 58 QString activated_name;
59 QLabel *bottom_name,
60 *top_name;
58 61
59 private slots: 62 private slots:
60 void slotStartQuery(); 63 void slotStartQuery();
61 void slotSetErrorcount( int ); 64 void slotSetErrorcount( int );
62 void slotSettings(); 65 void slotSettings();
63 void slotSetParameter( int ); 66 void slotSetParameter( int );
64 void slotMethodChanged( int ); 67 void slotMethodChanged( const QString& );
65}; 68};