-rw-r--r-- | noncore/apps/odict/configdlg.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/odict/dingwidget.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/odict/dingwidget.h | 3 | ||||
-rw-r--r-- | noncore/apps/odict/odict.cpp | 27 | ||||
-rw-r--r-- | noncore/apps/odict/odict.h | 5 |
5 files changed, 31 insertions, 14 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 | |||
@@ -65,43 +65,38 @@ ConfigDlg::ConfigDlg(QWidget *parent, const char *name, bool modal) : QDialog(pa | |||
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 | //XXX wozu gibt es diese Methode? |
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 | ||
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 | ||
87 | void ConfigDlg::slotChangeMethod() | 85 | void 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 | ||
104 | void ConfigDlg::slotDeleteMethod() | 99 | void ConfigDlg::slotDeleteMethod() |
105 | { | 100 | { |
106 | if ( list->selectedItem() ) | 101 | if ( list->selectedItem() ) |
107 | { | 102 | { |
@@ -109,13 +104,12 @@ void ConfigDlg::slotDeleteMethod() | |||
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 | ||
118 | void ConfigDlg::loadSearchMethodNames() | 112 | void 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_" ); |
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 | |||
@@ -86,12 +86,14 @@ void DingWidget::setQueryWord( QString qword ) | |||
86 | void DingWidget::loadValues() | 86 | void 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 | ||
94 | BroswerContent DingWidget::setText( QString word ) | 96 | BroswerContent DingWidget::setText( QString word ) |
95 | { | 97 | { |
96 | queryword = word; | 98 | queryword = word; |
97 | return parseInfo(); | 99 | return parseInfo(); |
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 | |||
@@ -28,12 +28,15 @@ class DingWidget | |||
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 | 33 | ||
34 | QString lang1_name, | ||
35 | lang2_name; | ||
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; |
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 | |||
@@ -43,19 +43,22 @@ ODict::ODict() : QMainWindow() | |||
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(); |
@@ -75,13 +78,13 @@ void ODict::loadConfig() | |||
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 | ||
85 | void ODict::saveConfig() | 88 | void ODict::saveConfig() |
86 | { | 89 | { |
87 | Config cfg ( "odict" ); | 90 | Config cfg ( "odict" ); |
@@ -91,12 +94,14 @@ void ODict::saveConfig() | |||
91 | cfg.writeEntry( "regexp" , regexp ); | 94 | cfg.writeEntry( "regexp" , regexp ); |
92 | cfg.writeEntry( "completewords" , completewords ); | 95 | cfg.writeEntry( "completewords" , completewords ); |
93 | } | 96 | } |
94 | 97 | ||
95 | void ODict::slotStartQuery() | 98 | void ODict::slotStartQuery() |
96 | { | 99 | { |
100 | if ( !query_le->text( ).isEmpty() ) | ||
101 | { | ||
97 | /* | 102 | /* |
98 | * if the user has not yet defined a dictionary | 103 | * if the user has not yet defined a dictionary |
99 | */ | 104 | */ |
100 | if ( !query_co->currentText() ) | 105 | if ( !query_co->currentText() ) |
101 | { | 106 | { |
102 | switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ), | 107 | switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ), |
@@ -119,21 +124,24 @@ void ODict::slotStartQuery() | |||
119 | * ok, the user has defined a dict | 124 | * ok, the user has defined a dict |
120 | */ | 125 | */ |
121 | QString querystring = query_le->text(); | 126 | QString querystring = query_le->text(); |
122 | ding->setCaseSensitive( casesens ); | 127 | ding->setCaseSensitive( casesens ); |
123 | ding->setCompleteWord( completewords ); | 128 | ding->setCompleteWord( completewords ); |
124 | ding->setDict( activated_name ); | 129 | ding->setDict( activated_name ); |
130 | top_name->setText( ding->lang1_name ); | ||
131 | bottom_name->setText( ding->lang2_name ); | ||
125 | 132 | ||
126 | if ( activated_name != ding->loadedDict() ) | 133 | if ( activated_name != ding->loadedDict() ) |
127 | ding->loadDict(activated_name); | 134 | ding->loadDict(activated_name); |
128 | 135 | ||
129 | BroswerContent test = ding->setText( querystring ); | 136 | BroswerContent test = ding->setText( querystring ); |
130 | 137 | ||
131 | browser_top->setText( test.top ); | 138 | browser_top->setText( test.top ); |
132 | browser_bottom->setText( test.bottom ); | 139 | browser_bottom->setText( test.bottom ); |
133 | } | 140 | } |
141 | } | ||
134 | 142 | ||
135 | 143 | ||
136 | void ODict::slotSetErrorcount( int count ) | 144 | void ODict::slotSetErrorcount( int count ) |
137 | { | 145 | { |
138 | errorTol = count; | 146 | errorTol = count; |
139 | } | 147 | } |
@@ -143,13 +151,12 @@ void ODict::slotSettings() | |||
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 | ||
152 | void ODict::slotSetParameter( int count ) | 159 | void ODict::slotSetParameter( int count ) |
153 | { | 160 | { |
154 | if ( count == 0 ) | 161 | if ( count == 0 ) |
155 | { | 162 | { |
@@ -173,15 +180,23 @@ void ODict::slotSetParameter( int count ) | |||
173 | else | 180 | else |
174 | regexp = true; | 181 | regexp = true; |
175 | } | 182 | } |
176 | else qWarning( "ERROR" ); | 183 | else qWarning( "ERROR" ); |
177 | } | 184 | } |
178 | 185 | ||
179 | void ODict::slotMethodChanged( int /*methodnumber*/ ) | 186 | void 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 | ||
184 | void ODict::setupMenus() | 199 | void ODict::setupMenus() |
185 | { | 200 | { |
186 | menu = new QMenuBar( this ); | 201 | menu = new QMenuBar( this ); |
187 | 202 | ||
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 | |||
@@ -6,12 +6,13 @@ | |||
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 QLabel; | ||
12 | class QVBox; | 13 | class QVBox; |
13 | class QPopupMenu; | 14 | class QPopupMenu; |
14 | class QMenuBar; | 15 | class QMenuBar; |
15 | class QHBox; | 16 | class QHBox; |
16 | class QPushButton; | 17 | class QPushButton; |
17 | class QLineEdit; | 18 | class QLineEdit; |
@@ -52,14 +53,16 @@ class ODict : public QMainWindow | |||
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 | }; |