author | tille <tille> | 2003-01-09 13:56:54 (UTC) |
---|---|---|
committer | tille <tille> | 2003-01-09 13:56:54 (UTC) |
commit | da7a12b48efb1ff37d1316d77f52123778a403a4 (patch) (unidiff) | |
tree | 9122c888663a54e78c830410851289ceed0ea676 /noncore/apps/odict/odict.cpp | |
parent | b83656c4faa3556a753b7b8642aef1264e8404f3 (diff) | |
download | opie-da7a12b48efb1ff37d1316d77f52123778a403a4.zip opie-da7a12b48efb1ff37d1316d77f52123778a403a4.tar.gz opie-da7a12b48efb1ff37d1316d77f52123778a403a4.tar.bz2 |
commit for carsten
Diffstat (limited to 'noncore/apps/odict/odict.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/odict/odict.cpp | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp index 6f176f9..549c40a 100644 --- a/noncore/apps/odict/odict.cpp +++ b/noncore/apps/odict/odict.cpp | |||
@@ -30,91 +30,120 @@ | |||
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 | |||
43 | activated_name = QString::null; | 42 | activated_name = QString::null; |
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 | ||
48 | QHBox *hbox = new QHBox( vbox ); | 49 | QHBox *hbox = new QHBox( vbox ); |
49 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); | 50 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); 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(int) ), this, SLOT( slotMethodChanged(int) ) ); |
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() ) ); |
55 | browser_top = new QTextBrowser( vbox ); | 56 | browser_top = new QTextBrowser( vbox ); |
56 | browser_bottom = new QTextBrowser( vbox ); | 57 | browser_bottom = new QTextBrowser( vbox ); |
57 | 58 | ||
59 | ding = new DingWidget(); | ||
60 | |||
58 | loadConfig(); | 61 | loadConfig(); |
59 | setCentralWidget( vbox ); | 62 | setCentralWidget( vbox ); |
60 | } | 63 | } |
61 | 64 | ||
62 | void ODict::loadConfig() | 65 | void ODict::loadConfig() |
63 | { | 66 | { |
64 | Config cfg ( "odict" ); | 67 | Config cfg ( "odict" ); |
65 | cfg.setGroup( "generalsettings" ); | 68 | cfg.setGroup( "generalsettings" ); |
66 | errorTol = cfg.readEntry( "errtol" ).toInt(); | 69 | errorTol = cfg.readEntry( "errtol" ).toInt(); |
67 | casesens = cfg.readEntry( "casesens" ).toInt(); | 70 | casesens = cfg.readEntry( "casesens" ).toInt(); |
68 | regexp = cfg.readEntry( "regexp" ).toInt(); | 71 | regexp = cfg.readEntry( "regexp" ).toInt(); |
69 | completewords = cfg.readEntry( "completewords" ).toInt(); | 72 | completewords = cfg.readEntry( "completewords" ).toInt(); |
70 | 73 | ||
71 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); | 74 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); |
72 | query_co->clear(); | 75 | query_co->clear(); |
73 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) | 76 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) |
74 | { | 77 | { |
75 | cfg.setGroup( *it ); | 78 | cfg.setGroup( *it ); |
76 | query_co->insertItem( cfg.readEntry( "Name" ) ); | 79 | query_co->insertItem( cfg.readEntry( "Name" ) ); |
77 | } | 80 | } |
81 | slotMethodChanged(1 ); //FIXME: this line should not contain a integer | ||
78 | } | 82 | } |
79 | 83 | ||
80 | 84 | ||
81 | void ODict::saveConfig() | 85 | void ODict::saveConfig() |
82 | { | 86 | { |
83 | Config cfg ( "odict" ); | 87 | Config cfg ( "odict" ); |
84 | cfg.setGroup( "generalsettings" ); | 88 | cfg.setGroup( "generalsettings" ); |
85 | cfg.writeEntry( "errtol" , errorTol ); | 89 | cfg.writeEntry( "errtol" , errorTol ); |
86 | cfg.writeEntry( "casesens" , casesens ); | 90 | cfg.writeEntry( "casesens" , casesens ); |
87 | cfg.writeEntry( "regexp" , regexp ); | 91 | cfg.writeEntry( "regexp" , regexp ); |
88 | cfg.writeEntry( "completewords" , completewords ); | 92 | cfg.writeEntry( "completewords" , completewords ); |
89 | } | 93 | } |
90 | 94 | ||
91 | void ODict::slotDisplayAbout() | 95 | void ODict::slotDisplayAbout() |
92 | { | 96 | { |
93 | QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20030104" ) ); | 97 | QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20030108" ) ); |
94 | } | 98 | } |
95 | 99 | ||
96 | void ODict::slotStartQuery() | 100 | void ODict::slotStartQuery() |
97 | { | 101 | { |
98 | QString querystring = query_le->text(); | 102 | QString querystring = query_le->text(); |
99 | qDebug("opening dict >%s< for >%s<", activated_name.latin1(),querystring.latin1()); | 103 | //X qDebug("opening dict >%s< for >%s<", activated_name.latin1(),querystring.latin1()); |
100 | if (querystring.isEmpty()){ | 104 | //X if (querystring.isEmpty()){ |
101 | qWarning("empty querystring"); | 105 | //X qWarning("empty querystring"); |
102 | return; | 106 | //X return; |
103 | } | 107 | //X } |
104 | if (!activated_name || activated_name.isEmpty()) | 108 | //X if (!activated_name || activated_name.isEmpty()) |
105 | QMessageBox::warning(this,tr("No Dictionary"),tr("Please choose a dictonary") ); | 109 | //X QMessageBox::warning(this,tr("No Dictionary"),tr("Please choose a dictonary") ); |
106 | else | 110 | //X else |
107 | DingWidget *ding = new DingWidget( querystring , browser_top, browser_bottom, activated_name ); | 111 | //X { |
108 | ding->setText(); | 112 | |
113 | ding->setCaseSensitive( casesens ); | ||
114 | ding->setCompleteWord( completewords ); | ||
115 | ding->setDict( activated_name ); | ||
116 | |||
117 | qDebug( " activated_name ist :" ); | ||
118 | qDebug( activated_name ); | ||
119 | |||
120 | qDebug( " loadedDict() ist :" ); | ||
121 | qDebug( ding->loadedDict() ); | ||
122 | if ( activated_name != ding->loadedDict() ) | ||
123 | { | ||
124 | qDebug( "ComboBox geändert" ); | ||
125 | ding->loadDict(activated_name); | ||
126 | } | ||
127 | else qDebug( "ComboBox war GLEICH" ); | ||
128 | |||
129 | BroswerContent test = ding->setText( querystring ); | ||
130 | |||
131 | browser_top->setText( test.top ); | ||
132 | browser_bottom->setText( test.bottom ); | ||
133 | |||
134 | qDebug( "Text sollte gesetzt sein..." ); | ||
135 | |||
136 | //X } | ||
137 | |||
109 | } | 138 | } |
110 | 139 | ||
111 | 140 | ||
112 | void ODict::slotSetErrorcount( int count ) | 141 | void ODict::slotSetErrorcount( int count ) |
113 | { | 142 | { |
114 | errorTol = count; | 143 | errorTol = count; |
115 | } | 144 | } |
116 | 145 | ||
117 | void ODict::slotSettings() | 146 | void ODict::slotSettings() |
118 | { | 147 | { |
119 | ConfigDlg dlg( this, "Config" , true); | 148 | ConfigDlg dlg( this, "Config" , true); |
120 | if ( dlg.exec() == QDialog::Accepted ) | 149 | if ( dlg.exec() == QDialog::Accepted ) |
@@ -143,25 +172,25 @@ void ODict::slotSetParameter( int count ) | |||
143 | completewords = true; | 172 | completewords = true; |
144 | } | 173 | } |
145 | if ( count == 2 ) | 174 | if ( count == 2 ) |
146 | { | 175 | { |
147 | if ( regexp ) | 176 | if ( regexp ) |
148 | regexp = false; | 177 | regexp = false; |
149 | else | 178 | else |
150 | regexp = true; | 179 | regexp = true; |
151 | } | 180 | } |
152 | else qWarning( "ERROR" ); | 181 | else qWarning( "ERROR" ); |
153 | } | 182 | } |
154 | 183 | ||
155 | void ODict::slotMethodChanged( int methodnumber ) | 184 | void ODict::slotMethodChanged( int /*methodnumber*/ ) |
156 | { | 185 | { |
157 | activated_name = query_co->currentText(); | 186 | activated_name = query_co->currentText(); |
158 | } | 187 | } |
159 | 188 | ||
160 | void ODict::setupMenus() | 189 | void ODict::setupMenus() |
161 | { | 190 | { |
162 | menu = new QMenuBar( this ); | 191 | menu = new QMenuBar( this ); |
163 | 192 | ||
164 | settings = new QPopupMenu( menu ); | 193 | settings = new QPopupMenu( menu ); |
165 | setting_a = new QAction(tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); | 194 | setting_a = new QAction(tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); |
166 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 195 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
167 | setting_a->addTo( settings ); | 196 | setting_a->addTo( settings ); |