-rw-r--r-- | noncore/apps/odict/configdlg.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/odict/dingwidget.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/odict/odict.cpp | 40 |
3 files changed, 18 insertions, 30 deletions
diff --git a/noncore/apps/odict/configdlg.cpp b/noncore/apps/odict/configdlg.cpp index 89bc6f6..eba7dec 100644 --- a/noncore/apps/odict/configdlg.cpp +++ b/noncore/apps/odict/configdlg.cpp | |||
@@ -1,126 +1,128 @@ | |||
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 | ||
34 | ConfigDlg::ConfigDlg(QWidget *parent, const char *name, bool modal) : QDialog(parent, name, modal) | 34 | ConfigDlg::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 | ||
69 | void ConfigDlg::writeEntries() | 69 | void ConfigDlg::writeEntries() |
70 | { | 70 | { |
71 | qDebug( "richtig beendet" ); | 71 | qDebug( "richtig beendet" ); |
72 | } | 72 | } |
73 | 73 | ||
74 | void ConfigDlg::slotNewMethod() | 74 | void 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 | ||
79 | dlg.saveItem(); | 80 | dlg.saveItem(); |
80 | QListViewItem *item = new QListViewItem( list ); | 81 | QListViewItem *item = new QListViewItem( list ); |
81 | item->setText( 0 , dlg.nameLE->text() ); | 82 | item->setText( 0 , dlg.nameLE->text() ); |
82 | } | 83 | } |
83 | else qDebug( "SearchMethodDlg abgebrochen" ); | 84 | else qDebug( "SearchMethodDlg abgebrochen" ); |
84 | } | 85 | } |
85 | 86 | ||
86 | void ConfigDlg::slotChangeMethod() | 87 | void ConfigDlg::slotChangeMethod() |
87 | { | 88 | { |
88 | if ( list->selectedItem() ) | 89 | if ( list->selectedItem() ) |
89 | { | 90 | { |
90 | SearchMethodDlg dlg( this, "SearchMethodDlg", true, list->selectedItem()->text( 0 ) ); | 91 | SearchMethodDlg dlg( this, "SearchMethodDlg", true, list->selectedItem()->text( 0 ) ); |
91 | if ( dlg.exec() == QDialog::Accepted ) | 92 | if ( dlg.exec() == QDialog::Accepted ) |
92 | { | 93 | { |
94 | //if ( !dlg.nameLE->text() ) return; //XXX geht vielleich nicht | ||
93 | dlg.saveItem(); | 95 | dlg.saveItem(); |
94 | QListViewItem *item = list->selectedItem(); | 96 | QListViewItem *item = list->selectedItem(); |
95 | item->setText( 0 , dlg.nameLE->text() ); | 97 | item->setText( 0 , dlg.nameLE->text() ); |
96 | } | 98 | } |
97 | else qDebug( "SearchMethodDlg abgebrochen" ); | 99 | else qDebug( "SearchMethodDlg abgebrochen" ); |
98 | } | 100 | } |
99 | else qDebug( "kein item angewählt" ); | 101 | else qDebug( "kein item angewählt" ); |
100 | } | 102 | } |
101 | 103 | ||
102 | void ConfigDlg::slotDeleteMethod() | 104 | void ConfigDlg::slotDeleteMethod() |
103 | { | 105 | { |
104 | if ( list->selectedItem() ) | 106 | if ( list->selectedItem() ) |
105 | { | 107 | { |
106 | Config cfg ( "odict" ); | 108 | Config cfg ( "odict" ); |
107 | cfg.setGroup( "Method_"+list->selectedItem()->text(0) ); | 109 | cfg.setGroup( "Method_"+list->selectedItem()->text(0) ); |
108 | cfg.clearGroup(); | 110 | cfg.clearGroup(); |
109 | //FIXME: this only removes the entries but not the group itself | 111 | //FIXME: this only removes the entries but not the group itself |
110 | 112 | ||
111 | list->takeItem( list->selectedItem() ); | 113 | list->takeItem( list->selectedItem() ); |
112 | } | 114 | } |
113 | else qDebug("no item selected"); | 115 | else qDebug("no item selected"); |
114 | } | 116 | } |
115 | 117 | ||
116 | void ConfigDlg::loadSearchMethodNames() | 118 | void ConfigDlg::loadSearchMethodNames() |
117 | { | 119 | { |
118 | Config cfg( "odict" ); | 120 | Config cfg( "odict" ); |
119 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); | 121 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); |
120 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) | 122 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) |
121 | { | 123 | { |
122 | QListViewItem *item = new QListViewItem( list ); | 124 | QListViewItem *item = new QListViewItem( list ); |
123 | cfg.setGroup( *it ); | 125 | cfg.setGroup( *it ); |
124 | item->setText( 0 , cfg.readEntry( "Name" ) ); | 126 | item->setText( 0 , cfg.readEntry( "Name" ) ); |
125 | } | 127 | } |
126 | } | 128 | } |
diff --git a/noncore/apps/odict/dingwidget.cpp b/noncore/apps/odict/dingwidget.cpp index 5c4b13b..abb5e75 100644 --- a/noncore/apps/odict/dingwidget.cpp +++ b/noncore/apps/odict/dingwidget.cpp | |||
@@ -1,141 +1,141 @@ | |||
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 | ||
33 | DingWidget::DingWidget( ) | 33 | DingWidget::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 | ||
40 | void DingWidget::loadDict( QString name ) | 40 | void DingWidget::loadDict( QString name ) |
41 | { | 41 | { |
42 | dictName = name; | 42 | dictName = name; |
43 | QString opie_dir = getenv("OPIEDIR"); | ||
44 | |||
45 | Config cfg( "odict" ); | 43 | Config cfg( "odict" ); |
44 | if ( !methodname ) return; | ||
46 | cfg.setGroup( "Method_" + methodname ); | 45 | cfg.setGroup( "Method_" + methodname ); |
47 | QFile file( cfg.readEntry( "file" ) ); | 46 | QFile file( cfg.readEntry( "file" ) ); |
48 | 47 | ||
49 | if( file.open( IO_ReadOnly ) ) | 48 | if( file.open( IO_ReadOnly ) ) |
50 | { | 49 | { |
51 | QTextStream stream( &file ); | 50 | QTextStream stream( &file ); |
52 | while ( !stream.eof() ) | 51 | while ( !stream.eof() ) |
53 | { | 52 | { |
54 | lines.append( stream.readLine() ); | 53 | lines.append( stream.readLine() ); |
55 | } | 54 | } |
56 | file.close(); | 55 | file.close(); |
57 | } | 56 | } |
58 | loadValues(); | 57 | loadValues(); |
59 | } | 58 | } |
60 | 59 | ||
61 | QString DingWidget::loadedDict() | 60 | QString DingWidget::loadedDict() |
62 | { | 61 | { |
63 | return dictName; | 62 | return dictName; |
64 | } | 63 | } |
65 | 64 | ||
66 | void DingWidget::setCaseSensitive( bool caseS ) | 65 | void DingWidget::setCaseSensitive( bool caseS ) |
67 | { | 66 | { |
68 | isCaseSensitive = caseS; | 67 | isCaseSensitive = caseS; |
69 | } | 68 | } |
70 | 69 | ||
71 | void DingWidget::setDict( QString dict ) | 70 | void DingWidget::setDict( QString dict ) |
72 | { | 71 | { |
73 | methodname = dict; | 72 | methodname = dict; |
74 | } | 73 | } |
75 | 74 | ||
76 | void DingWidget::setCompleteWord( bool cword ) | 75 | void DingWidget::setCompleteWord( bool cword ) |
77 | { | 76 | { |
78 | isCompleteWord = cword; | 77 | isCompleteWord = cword; |
79 | } | 78 | } |
80 | 79 | ||
81 | void DingWidget::setQueryWord( QString qword ) | 80 | void DingWidget::setQueryWord( QString qword ) |
82 | { | 81 | { |
83 | queryword = qword; | 82 | queryword = qword; |
84 | } | 83 | } |
85 | 84 | ||
86 | 85 | ||
87 | void DingWidget::loadValues() | 86 | void DingWidget::loadValues() |
88 | { | 87 | { |
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 | } | 92 | } |
93 | 93 | ||
94 | BroswerContent DingWidget::setText( QString word ) | 94 | BroswerContent DingWidget::setText( QString word ) |
95 | { | 95 | { |
96 | queryword = word; | 96 | queryword = word; |
97 | return parseInfo(); | 97 | return parseInfo(); |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | BroswerContent DingWidget::parseInfo() | 101 | BroswerContent DingWidget::parseInfo() |
102 | { | 102 | { |
103 | if ( isCompleteWord ) | 103 | if ( isCompleteWord ) |
104 | queryword = " " + queryword + " "; | 104 | queryword = " " + queryword + " "; |
105 | QStringList search = lines.grep( queryword , isCaseSensitive ); | 105 | QStringList search = lines.grep( queryword , isCaseSensitive ); |
106 | 106 | ||
107 | QString current; | 107 | QString current; |
108 | QString left; | 108 | QString left; |
109 | QString right; | 109 | QString right; |
110 | QRegExp reg_div( trenner ); | 110 | QRegExp reg_div( trenner ); |
111 | QRegExp reg_word( queryword ); | 111 | QRegExp reg_word( queryword ); |
112 | reg_word.setCaseSensitive( isCaseSensitive ); | 112 | reg_word.setCaseSensitive( isCaseSensitive ); |
113 | QStringList toplist, bottomlist; | 113 | QStringList toplist, bottomlist; |
114 | QString substitute = "<strong>"+queryword+"</strong>"; | 114 | QString substitute = "<strong>"+queryword+"</strong>"; |
115 | 115 | ||
116 | for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it ) | 116 | for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it ) |
117 | { | 117 | { |
118 | current = *it; | 118 | current = *it; |
119 | left = current.left( current.find( trenner ) ); | 119 | left = current.left( current.find( trenner ) ); |
120 | 120 | ||
121 | right = current.right( current.length() - current.find(trenner) - trenner.length() ); | 121 | right = current.right( current.length() - current.find(trenner) - trenner.length() ); |
122 | 122 | ||
123 | if ( left.contains( queryword , isCaseSensitive ) ) | 123 | if ( left.contains( queryword , isCaseSensitive ) ) |
124 | { | 124 | { |
125 | left.replace( queryword, substitute ); | 125 | left.replace( queryword, substitute ); |
126 | left = left + " --> " + right; | 126 | left = left + " --> " + right; |
127 | toplist.append( left ); | 127 | toplist.append( left ); |
128 | } | 128 | } |
129 | else | 129 | else |
130 | { | 130 | { |
131 | right.replace( queryword, substitute ); | 131 | right.replace( queryword, substitute ); |
132 | right = right + " --> " + left; | 132 | right = right + " --> " + left; |
133 | bottomlist.append( right ); | 133 | bottomlist.append( right ); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | s_strings.top = toplist.join( "<br>" ); | 137 | s_strings.top = toplist.join( "<br>" ); |
138 | s_strings.bottom = bottomlist.join( "<br>" ); | 138 | s_strings.bottom = bottomlist.join( "<br>" ); |
139 | 139 | ||
140 | return s_strings; | 140 | return s_strings; |
141 | } | 141 | } |
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp index a404e89..cc3148a 100644 --- a/noncore/apps/odict/odict.cpp +++ b/noncore/apps/odict/odict.cpp | |||
@@ -1,204 +1,190 @@ | |||
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 | ||
40 | ODict::ODict() : QMainWindow() | 40 | ODict::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 | |||
48 | 47 | ||
49 | QHBox *hbox = new QHBox( vbox ); | 48 | QHBox *hbox = new QHBox( vbox ); |
50 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); | 49 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); |
51 | query_le = new QLineEdit( hbox ); | 50 | query_le = new QLineEdit( hbox ); |
52 | query_co = new QComboBox( hbox ); | 51 | query_co = new QComboBox( hbox ); |
53 | connect( query_co , SIGNAL( activated(int) ), this, SLOT( slotMethodChanged(int) ) ); | 52 | connect( query_co , SIGNAL( activated(int) ), this, SLOT( slotMethodChanged(int) ) ); |
54 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); | 53 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); |
55 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); | 54 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); |
56 | browser_top = new QTextBrowser( vbox ); | 55 | browser_top = new QTextBrowser( vbox ); |
57 | browser_bottom = new QTextBrowser( vbox ); | 56 | browser_bottom = new QTextBrowser( vbox ); |
58 | 57 | ||
59 | ding = new DingWidget(); | 58 | ding = new DingWidget(); |
60 | ding->loadValues(); | 59 | ding->loadValues(); |
61 | 60 | ||
62 | loadConfig(); | 61 | loadConfig(); |
63 | setCentralWidget( vbox ); | 62 | setCentralWidget( vbox ); |
64 | } | 63 | } |
65 | 64 | ||
66 | void ODict::loadConfig() | 65 | void ODict::loadConfig() |
67 | { | 66 | { |
68 | Config cfg ( "odict" ); | 67 | Config cfg ( "odict" ); |
69 | cfg.setGroup( "generalsettings" ); | 68 | cfg.setGroup( "generalsettings" ); |
70 | errorTol = cfg.readEntry( "errtol" ).toInt(); | 69 | errorTol = cfg.readEntry( "errtol" ).toInt(); |
71 | casesens = cfg.readEntry( "casesens" ).toInt(); | 70 | casesens = cfg.readEntry( "casesens" ).toInt(); |
72 | regexp = cfg.readEntry( "regexp" ).toInt(); | 71 | regexp = cfg.readEntry( "regexp" ).toInt(); |
73 | completewords = cfg.readEntry( "completewords" ).toInt(); | 72 | completewords = cfg.readEntry( "completewords" ).toInt(); |
74 | 73 | ||
75 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); | 74 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); |
76 | query_co->clear(); | 75 | query_co->clear(); |
77 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) | 76 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) |
78 | { | 77 | { |
79 | cfg.setGroup( *it ); | 78 | cfg.setGroup( *it ); |
80 | query_co->insertItem( cfg.readEntry( "Name" ) ); | 79 | query_co->insertItem( cfg.readEntry( "Name" ) ); |
81 | } | 80 | } |
82 | slotMethodChanged(1 ); //FIXME: this line should not contain a integer | 81 | slotMethodChanged(1 ); //FIXME: this line should not contain a integer |
83 | } | 82 | } |
84 | 83 | ||
85 | 84 | ||
86 | void ODict::saveConfig() | 85 | void ODict::saveConfig() |
87 | { | 86 | { |
88 | Config cfg ( "odict" ); | 87 | Config cfg ( "odict" ); |
89 | cfg.setGroup( "generalsettings" ); | 88 | cfg.setGroup( "generalsettings" ); |
90 | cfg.writeEntry( "errtol" , errorTol ); | 89 | cfg.writeEntry( "errtol" , errorTol ); |
91 | cfg.writeEntry( "casesens" , casesens ); | 90 | cfg.writeEntry( "casesens" , casesens ); |
92 | cfg.writeEntry( "regexp" , regexp ); | 91 | cfg.writeEntry( "regexp" , regexp ); |
93 | cfg.writeEntry( "completewords" , completewords ); | 92 | cfg.writeEntry( "completewords" , completewords ); |
94 | } | 93 | } |
95 | 94 | ||
96 | void ODict::slotStartQuery() | 95 | void ODict::slotStartQuery() |
97 | { | 96 | { |
98 | QString querystring = query_le->text(); | 97 | QString querystring = query_le->text(); |
99 | //X qDebug("opening dict >%s< for >%s<", activated_name.latin1(),querystring.latin1()); | 98 | ding->setCaseSensitive( casesens ); |
100 | //X if (querystring.isEmpty()){ | 99 | ding->setCompleteWord( completewords ); |
101 | //X qWarning("empty querystring"); | 100 | ding->setDict( activated_name ); |
102 | //X return; | 101 | |
103 | //X } | 102 | if ( activated_name != ding->loadedDict() ) |
104 | //X if (!activated_name || activated_name.isEmpty()) | 103 | ding->loadDict(activated_name); |
105 | //X QMessageBox::warning(this,tr("No Dictionary"),tr("Please choose a dictonary") ); | 104 | |
106 | //X else | 105 | BroswerContent test = ding->setText( querystring ); |
107 | //X { | 106 | |
108 | 107 | browser_top->setText( test.top ); | |
109 | ding->setCaseSensitive( casesens ); | 108 | browser_bottom->setText( test.bottom ); |
110 | ding->setCompleteWord( completewords ); | ||
111 | ding->setDict( activated_name ); | ||
112 | |||
113 | if ( activated_name != ding->loadedDict() ) | ||
114 | ding->loadDict(activated_name); | ||
115 | |||
116 | BroswerContent test = ding->setText( querystring ); | ||
117 | |||
118 | browser_top->setText( test.top ); | ||
119 | browser_bottom->setText( test.bottom ); | ||
120 | |||
121 | qDebug( "Text sollte gesetzt sein..." ); | ||
122 | //X } | ||
123 | } | 109 | } |
124 | 110 | ||
125 | 111 | ||
126 | void ODict::slotSetErrorcount( int count ) | 112 | void ODict::slotSetErrorcount( int count ) |
127 | { | 113 | { |
128 | errorTol = count; | 114 | errorTol = count; |
129 | } | 115 | } |
130 | 116 | ||
131 | void ODict::slotSettings() | 117 | void ODict::slotSettings() |
132 | { | 118 | { |
133 | ConfigDlg dlg( this, "Config" , true); | 119 | ConfigDlg dlg( this, "Config" , true); |
134 | if ( dlg.exec() == QDialog::Accepted ) | 120 | if ( dlg.exec() == QDialog::Accepted ) |
135 | { | 121 | { |
136 | dlg.writeEntries(); | 122 | dlg.writeEntries(); |
137 | loadConfig(); | 123 | loadConfig(); |
138 | } | 124 | } |
139 | else qDebug( "abgebrochen" ); | 125 | else qDebug( "abgebrochen" ); |
140 | } | 126 | } |
141 | 127 | ||
142 | void ODict::slotSetParameter( int count ) | 128 | void ODict::slotSetParameter( int count ) |
143 | { | 129 | { |
144 | if ( count == 0 ) | 130 | if ( count == 0 ) |
145 | { | 131 | { |
146 | if ( casesens ) | 132 | if ( casesens ) |
147 | casesens = false; | 133 | casesens = false; |
148 | else | 134 | else |
149 | casesens = true; | 135 | casesens = true; |
150 | } | 136 | } |
151 | 137 | ||
152 | if ( count == 1 ) | 138 | if ( count == 1 ) |
153 | { | 139 | { |
154 | if ( completewords ) | 140 | if ( completewords ) |
155 | completewords = false; | 141 | completewords = false; |
156 | else | 142 | else |
157 | completewords = true; | 143 | completewords = true; |
158 | } | 144 | } |
159 | if ( count == 2 ) | 145 | if ( count == 2 ) |
160 | { | 146 | { |
161 | if ( regexp ) | 147 | if ( regexp ) |
162 | regexp = false; | 148 | regexp = false; |
163 | else | 149 | else |
164 | regexp = true; | 150 | regexp = true; |
165 | } | 151 | } |
166 | else qWarning( "ERROR" ); | 152 | else qWarning( "ERROR" ); |
167 | } | 153 | } |
168 | 154 | ||
169 | void ODict::slotMethodChanged( int /*methodnumber*/ ) | 155 | void ODict::slotMethodChanged( int /*methodnumber*/ ) |
170 | { | 156 | { |
171 | activated_name = query_co->currentText(); | 157 | activated_name = query_co->currentText(); |
172 | } | 158 | } |
173 | 159 | ||
174 | void ODict::setupMenus() | 160 | void ODict::setupMenus() |
175 | { | 161 | { |
176 | menu = new QMenuBar( this ); | 162 | menu = new QMenuBar( this ); |
177 | 163 | ||
178 | settings = new QPopupMenu( menu ); | 164 | settings = new QPopupMenu( menu ); |
179 | setting_a = new QAction(tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); | 165 | setting_a = new QAction(tr( "Configuration" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
180 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 166 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
181 | setting_a->addTo( settings ); | 167 | setting_a->addTo( settings ); |
182 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); | 168 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); |
183 | 169 | ||
184 | parameter = new QPopupMenu( menu ); | 170 | parameter = new QPopupMenu( menu ); |
185 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); | 171 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); |
186 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); | 172 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); |
187 | parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ; | 173 | parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ; |
188 | parameter->insertItem( tr( "Allow ®. expressions" ), 2 ); | 174 | parameter->insertItem( tr( "Allow ®. expressions" ), 2 ); |
189 | parameter->insertSeparator(); | 175 | parameter->insertSeparator(); |
190 | error_tol_menu = new QPopupMenu( menu ); | 176 | error_tol_menu = new QPopupMenu( menu ); |
191 | error_tol_menu->setCheckable( TRUE ); | 177 | error_tol_menu->setCheckable( TRUE ); |
192 | connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) ); | 178 | connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) ); |
193 | 179 | ||
194 | error_tol_menu->insertItem( tr( "0 Errors" ), 0 ); | 180 | error_tol_menu->insertItem( tr( "0 Errors" ), 0 ); |
195 | error_tol_menu->insertItem( tr( "1 Errors" ), 1 ); | 181 | error_tol_menu->insertItem( tr( "1 Errors" ), 1 ); |
196 | error_tol_menu->insertItem( tr( "2 Errors" ), 2 ); | 182 | error_tol_menu->insertItem( tr( "2 Errors" ), 2 ); |
197 | error_tol_menu->insertItem( tr( "3 Errors" ), 3 ); | 183 | error_tol_menu->insertItem( tr( "3 Errors" ), 3 ); |
198 | error_tol_menu->insertItem( tr( "4 Errors" ), 4 ); | 184 | error_tol_menu->insertItem( tr( "4 Errors" ), 4 ); |
199 | error_tol_menu->insertItem( tr( "Until Hit" ), 5 ); | 185 | error_tol_menu->insertItem( tr( "Until Hit" ), 5 ); |
200 | parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu ); | 186 | parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu ); |
201 | 187 | ||
202 | menu->insertItem( tr( "Settings" ) , settings ); | 188 | menu->insertItem( tr( "Settings" ) , settings ); |
203 | menu->insertItem( tr( "Parameter" ) , parameter ); | 189 | menu->insertItem( tr( "Parameter" ) , parameter ); |
204 | } | 190 | } |