summaryrefslogtreecommitdiff
authorcniehaus <cniehaus>2003-05-02 22:10:18 (UTC)
committer cniehaus <cniehaus>2003-05-02 22:10:18 (UTC)
commite83acc761bfe83ccd80b8ef6ab1275ee5c26e14f (patch) (unidiff)
tree6211385225d342dc9062615f080d5764d7251beb
parentadefcec2af37482266dbbd0e56b7e57f483c0540 (diff)
downloadopie-e83acc761bfe83ccd80b8ef6ab1275ee5c26e14f.zip
opie-e83acc761bfe83ccd80b8ef6ab1275ee5c26e14f.tar.gz
opie-e83acc761bfe83ccd80b8ef6ab1275ee5c26e14f.tar.bz2
265 lines diff :) mostly markupstuff. But also one bug less
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
@@ -1,128 +1,122 @@
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 //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 }
128} 122}
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
@@ -1,141 +1,143 @@
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 "dingwidget.h" 17#include "dingwidget.h"
18 18
19#include <qfile.h> 19#include <qfile.h>
20#include <qpe/config.h> 20#include <qpe/config.h>
21#include <qhbox.h> 21#include <qhbox.h>
22#include <qlabel.h> 22#include <qlabel.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24#include <qlineedit.h> 24#include <qlineedit.h>
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qregexp.h> 29#include <qregexp.h>
30#include <qtextbrowser.h> 30#include <qtextbrowser.h>
31//#include <stdlib.h> // for getenv 31//#include <stdlib.h> // for getenv
32 32
33DingWidget::DingWidget( ) 33DingWidget::DingWidget( )
34{ 34{
35 methodname = QString::null; 35 methodname = QString::null;
36 trenner = QString::null; 36 trenner = QString::null;
37 lines = 0L; 37 lines = 0L;
38} 38}
39 39
40void DingWidget::loadDict( QString name ) 40void DingWidget::loadDict( QString name )
41{ 41{
42 dictName = name; 42 dictName = name;
43 Config cfg( "odict" ); 43 Config cfg( "odict" );
44 if ( !methodname ) return; 44 if ( !methodname ) return;
45 cfg.setGroup( "Method_" + methodname ); 45 cfg.setGroup( "Method_" + methodname );
46 QFile file( cfg.readEntry( "file" ) ); 46 QFile file( cfg.readEntry( "file" ) );
47 47
48 if( file.open( IO_ReadOnly ) ) 48 if( file.open( IO_ReadOnly ) )
49 { 49 {
50 QTextStream stream( &file ); 50 QTextStream stream( &file );
51 while ( !stream.eof() ) 51 while ( !stream.eof() )
52 { 52 {
53 lines.append( stream.readLine() ); 53 lines.append( stream.readLine() );
54 } 54 }
55 file.close(); 55 file.close();
56 } 56 }
57 loadValues(); 57 loadValues();
58} 58}
59 59
60QString DingWidget::loadedDict() 60QString DingWidget::loadedDict()
61{ 61{
62 return dictName; 62 return dictName;
63} 63}
64 64
65void DingWidget::setCaseSensitive( bool caseS ) 65void DingWidget::setCaseSensitive( bool caseS )
66{ 66{
67 isCaseSensitive = caseS; 67 isCaseSensitive = caseS;
68} 68}
69 69
70void DingWidget::setDict( QString dict ) 70void DingWidget::setDict( QString dict )
71{ 71{
72 methodname = dict; 72 methodname = dict;
73} 73}
74 74
75void DingWidget::setCompleteWord( bool cword ) 75void DingWidget::setCompleteWord( bool cword )
76{ 76{
77 isCompleteWord = cword; 77 isCompleteWord = cword;
78} 78}
79 79
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 )
104 queryword = " " + queryword + " "; 106 queryword = " " + queryword + " ";
105 QStringList search = lines.grep( queryword , isCaseSensitive ); 107 QStringList search = lines.grep( queryword , isCaseSensitive );
106 108
107 QString current; 109 QString current;
108 QString left; 110 QString left;
109 QString right; 111 QString right;
110 QRegExp reg_div( trenner ); 112 QRegExp reg_div( trenner );
111 QRegExp reg_word( queryword ); 113 QRegExp reg_word( queryword );
112 reg_word.setCaseSensitive( isCaseSensitive ); 114 reg_word.setCaseSensitive( isCaseSensitive );
113 QStringList toplist, bottomlist; 115 QStringList toplist, bottomlist;
114 QString substitute = "<strong>"+queryword+"</strong>"; 116 QString substitute = "<strong>"+queryword+"</strong>";
115 117
116 for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it ) 118 for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it )
117 { 119 {
118 current = *it; 120 current = *it;
119 left = current.left( current.find( trenner ) ); 121 left = current.left( current.find( trenner ) );
120 122
121 right = current.right( current.length() - current.find(trenner) - trenner.length() ); 123 right = current.right( current.length() - current.find(trenner) - trenner.length() );
122 124
123 if ( left.contains( queryword , isCaseSensitive ) ) 125 if ( left.contains( queryword , isCaseSensitive ) )
124 { 126 {
125 left.replace( queryword, substitute ); 127 left.replace( queryword, substitute );
126 left = left + " --> " + right; 128 left = left + " --> " + right;
127 toplist.append( left ); 129 toplist.append( left );
128 } 130 }
129 else 131 else
130 { 132 {
131 right.replace( queryword, substitute ); 133 right.replace( queryword, substitute );
132 right = right + " --> " + left; 134 right = right + " --> " + left;
133 bottomlist.append( right ); 135 bottomlist.append( right );
134 } 136 }
135 } 137 }
136 138
137 s_strings.top = toplist.join( "<br>" ); 139 s_strings.top = toplist.join( "<br>" );
138 s_strings.bottom = bottomlist.join( "<br>" ); 140 s_strings.bottom = bottomlist.join( "<br>" );
139 141
140 return s_strings; 142 return s_strings;
141} 143}
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
@@ -1,47 +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 <qstringlist.h> 10#include <qstringlist.h>
11#include <qstring.h> 11#include <qstring.h>
12 12
13struct BroswerContent 13struct BroswerContent
14{ 14{
15 QString top; 15 QString top;
16 QString bottom; 16 QString bottom;
17}; 17};
18 18
19class DingWidget 19class DingWidget
20{ 20{
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;
45 QString methodname; 48 QString methodname;
46 QString trenner; 49 QString trenner;
47}; 50};
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
@@ -1,214 +1,229 @@
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 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
162 if ( count == 1 ) 169 if ( count == 1 )
163 { 170 {
164 if ( completewords ) 171 if ( completewords )
165 completewords = false; 172 completewords = false;
166 else 173 else
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
194 parameter = new QPopupMenu( menu ); 209 parameter = new QPopupMenu( menu );
195 connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); 210 connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) );
196 parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); 211 parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 );
197 parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ; 212 parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ;
198 parameter->insertItem( tr( "Allow &reg. expressions" ), 2 ); 213 parameter->insertItem( tr( "Allow &reg. expressions" ), 2 );
199 parameter->insertSeparator(); 214 parameter->insertSeparator();
200 error_tol_menu = new QPopupMenu( menu ); 215 error_tol_menu = new QPopupMenu( menu );
201 error_tol_menu->setCheckable( TRUE ); 216 error_tol_menu->setCheckable( TRUE );
202 connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) ); 217 connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) );
203 218
204 error_tol_menu->insertItem( tr( "0 Errors" ), 0 ); 219 error_tol_menu->insertItem( tr( "0 Errors" ), 0 );
205 error_tol_menu->insertItem( tr( "1 Errors" ), 1 ); 220 error_tol_menu->insertItem( tr( "1 Errors" ), 1 );
206 error_tol_menu->insertItem( tr( "2 Errors" ), 2 ); 221 error_tol_menu->insertItem( tr( "2 Errors" ), 2 );
207 error_tol_menu->insertItem( tr( "3 Errors" ), 3 ); 222 error_tol_menu->insertItem( tr( "3 Errors" ), 3 );
208 error_tol_menu->insertItem( tr( "4 Errors" ), 4 ); 223 error_tol_menu->insertItem( tr( "4 Errors" ), 4 );
209 error_tol_menu->insertItem( tr( "Until Hit" ), 5 ); 224 error_tol_menu->insertItem( tr( "Until Hit" ), 5 );
210 parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu ); 225 parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu );
211 226
212 menu->insertItem( tr( "Settings" ) , settings ); 227 menu->insertItem( tr( "Settings" ) , settings );
213 menu->insertItem( tr( "Parameter" ) , parameter ); 228 menu->insertItem( tr( "Parameter" ) , parameter );
214} 229}
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,65 +1,68 @@
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;
24class DingWidget; 25class DingWidget;
25 26
26class ODict : public QMainWindow 27class ODict : public QMainWindow
27{ 28{
28 Q_OBJECT 29 Q_OBJECT
29 30
30 public: 31 public:
31 ODict(); 32 ODict();
32 QVBox *vbox; 33 QVBox *vbox;
33 QTextBrowser *browser_top, 34 QTextBrowser *browser_top,
34 *browser_bottom; 35 *browser_bottom;
35 DingWidget *ding; 36 DingWidget *ding;
36 37
37 private: 38 private:
38 QPopupMenu *help, *settings, *parameter, *error_tol_menu; 39 QPopupMenu *help, *settings, *parameter, *error_tol_menu;
39 QMenuBar *menu; 40 QMenuBar *menu;
40 QHBox *hbox; 41 QHBox *hbox;
41 QLineEdit *query_le; 42 QLineEdit *query_le;
42 QComboBox *query_co; 43 QComboBox *query_co;
43 QPushButton *ok_button; 44 QPushButton *ok_button;
44 45
45 QVBoxLayout *vbox_layout; 46 QVBoxLayout *vbox_layout;
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};