Diffstat (limited to 'noncore/apps/odict/dingwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/odict/dingwidget.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/noncore/apps/odict/dingwidget.cpp b/noncore/apps/odict/dingwidget.cpp index 0707bfb..ed67abf 100644 --- a/noncore/apps/odict/dingwidget.cpp +++ b/noncore/apps/odict/dingwidget.cpp | |||
@@ -9,64 +9,63 @@ | |||
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> | ||
22 | #include <qlabel.h> | ||
23 | #include <qpushbutton.h> | ||
24 | #include <qlineedit.h> | ||
25 | #include <qmainwindow.h> | ||
26 | #include <qstring.h> | 21 | #include <qstring.h> |
27 | #include <qtextstream.h> | 22 | #include <qtextstream.h> |
28 | #include <qstringlist.h> | 23 | #include <qstringlist.h> |
29 | #include <qregexp.h> | 24 | #include <qregexp.h> |
30 | #include <qtextbrowser.h> | ||
31 | //#include <stdlib.h> // for getenv | ||
32 | 25 | ||
33 | DingWidget::DingWidget( ) | 26 | DingWidget::DingWidget( ) |
34 | { | 27 | { |
35 | methodname = QString::null; | 28 | methodname = QString::null; |
36 | trenner = QString::null; | 29 | trenner = QString::null; |
37 | lines = 0L; | 30 | lines = 0L; |
38 | } | 31 | } |
39 | 32 | ||
40 | void DingWidget::loadDict( QString name ) | 33 | void DingWidget::loadDict( QString name ) |
41 | { | 34 | { |
35 | qDebug( "bin in DingWidget::loadDict(). name ist:" ); | ||
36 | qDebug( name ); | ||
37 | |||
42 | dictName = name; | 38 | dictName = name; |
43 | Config cfg( "odict" ); | 39 | Config cfg( "odict" ); |
44 | if ( !methodname ) return; | 40 | if ( !methodname ) { return; } |
45 | cfg.setGroup( "Method_" + methodname ); | 41 | cfg.setGroup( "Method_" + methodname ); |
46 | QFile file( cfg.readEntry( "file" ) ); | 42 | QFile file( cfg.readEntry( "file" ) ); |
47 | 43 | ||
44 | qDebug( cfg.readEntry( "file" ) ); | ||
45 | |||
48 | if( file.open( IO_ReadOnly ) ) | 46 | if( file.open( IO_ReadOnly ) ) |
49 | { | 47 | { |
50 | QTextStream stream( &file ); | 48 | QTextStream stream( &file ); |
51 | while ( !stream.eof() ) | 49 | while ( !stream.eof() ) |
52 | { | 50 | { |
53 | lines.append( stream.readLine() ); | 51 | lines.append( stream.readLine() ); |
54 | } | 52 | } |
55 | file.close(); | 53 | file.close(); |
56 | } | 54 | } |
57 | loadValues(); | 55 | loadValues(); |
56 | |||
58 | } | 57 | } |
59 | 58 | ||
60 | QString DingWidget::loadedDict() | 59 | QString DingWidget::loadedDict() const |
61 | { | 60 | { |
62 | return dictName; | 61 | return dictName; |
63 | } | 62 | } |
64 | 63 | ||
65 | void DingWidget::setCaseSensitive( bool caseS ) | 64 | void DingWidget::setCaseSensitive( bool caseS ) |
66 | { | 65 | { |
67 | isCaseSensitive = caseS; | 66 | isCaseSensitive = caseS; |
68 | } | 67 | } |
69 | 68 | ||
70 | void DingWidget::setDict( QString dict ) | 69 | void DingWidget::setDict( QString dict ) |
71 | { | 70 | { |
72 | methodname = dict; | 71 | methodname = dict; |
@@ -93,24 +92,26 @@ void DingWidget::loadValues() | |||
93 | lang2_name = cfg.readEntry( "Lang2" ); | 92 | lang2_name = cfg.readEntry( "Lang2" ); |
94 | } | 93 | } |
95 | 94 | ||
96 | BroswerContent DingWidget::setText( QString word ) | 95 | BroswerContent DingWidget::setText( QString word ) |
97 | { | 96 | { |
98 | queryword = word; | 97 | queryword = word; |
99 | return parseInfo(); | 98 | return parseInfo(); |
100 | } | 99 | } |
101 | 100 | ||
102 | 101 | ||
103 | BroswerContent DingWidget::parseInfo() | 102 | BroswerContent DingWidget::parseInfo() |
104 | { | 103 | { |
104 | qDebug( "bin in DingWidget::parseInfo()" ); | ||
105 | |||
105 | if ( isCompleteWord ) | 106 | if ( isCompleteWord ) |
106 | queryword = " " + queryword + " "; | 107 | queryword = " " + queryword + " "; |
107 | QStringList search = lines.grep( queryword , isCaseSensitive ); | 108 | QStringList search = lines.grep( queryword , isCaseSensitive ); |
108 | 109 | ||
109 | QString current; | 110 | QString current; |
110 | QString left; | 111 | QString left; |
111 | QString right; | 112 | QString right; |
112 | QRegExp reg_div( trenner ); | 113 | QRegExp reg_div( trenner ); |
113 | QRegExp reg_word( queryword ); | 114 | QRegExp reg_word( queryword ); |
114 | reg_word.setCaseSensitive( isCaseSensitive ); | 115 | reg_word.setCaseSensitive( isCaseSensitive ); |
115 | QStringList toplist, bottomlist; | 116 | QStringList toplist, bottomlist; |
116 | QString substitute = "<strong>"+queryword+"</strong>"; | 117 | QString substitute = "<strong>"+queryword+"</strong>"; |