Diffstat (limited to 'noncore/apps/odict/dingwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/odict/dingwidget.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/noncore/apps/odict/dingwidget.cpp b/noncore/apps/odict/dingwidget.cpp index 55a716d..c804385 100644 --- a/noncore/apps/odict/dingwidget.cpp +++ b/noncore/apps/odict/dingwidget.cpp | |||
@@ -25,39 +25,41 @@ | |||
25 | 25 | ||
26 | DingWidget::DingWidget( ) | 26 | DingWidget::DingWidget( ) |
27 | { | 27 | { |
28 | methodname = QString::null; | 28 | methodname = QString::null; |
29 | trenner = QString::null; | 29 | trenner = QString::null; |
30 | lines = 0L; | 30 | lines = 0L; |
31 | } | 31 | } |
32 | 32 | ||
33 | void DingWidget::loadDict( QString name ) | 33 | void DingWidget::loadDict( QString name ) |
34 | { | 34 | { |
35 | lines.clear(); //as we will load a new list we have to | 35 | lines.clear(); //as we will load a new list we have to |
36 | //remove the old one | 36 | //remove the old one |
37 | qDebug( "DingWidget::loadDict( ... )" ); | ||
38 | 37 | ||
39 | Config cfg( "odict" ); | 38 | Config cfg( "odict" ); |
40 | cfg.setGroup( "Method_" + name ); | 39 | cfg.setGroup( "Method_" + name ); |
41 | QFile file( cfg.readEntry( "file" ) ); | 40 | QFile file( cfg.readEntry( "file" ) ); |
42 | 41 | ||
43 | if( file.open( IO_ReadOnly ) ) | 42 | if( file.open( IO_ReadOnly ) ) |
44 | { | 43 | { |
45 | QTextStream stream( &file ); | 44 | QTextStream stream( &file ); |
46 | while ( !stream.eof() ) | 45 | while ( !stream.eof() ) |
47 | { | 46 | { |
48 | lines.append( stream.readLine() ); | 47 | lines.append( stream.readLine() ); |
49 | } | 48 | } |
50 | file.close(); | 49 | file.close(); |
51 | } | 50 | } |
51 | |||
52 | setDict( name ); | ||
53 | |||
52 | loadValues(); | 54 | loadValues(); |
53 | } | 55 | } |
54 | 56 | ||
55 | QString DingWidget::loadedDict() const | 57 | QString DingWidget::loadedDict() const |
56 | { | 58 | { |
57 | return dictName; | 59 | return dictName; |
58 | } | 60 | } |
59 | 61 | ||
60 | void DingWidget::setCaseSensitive( bool caseS ) | 62 | void DingWidget::setCaseSensitive( bool caseS ) |
61 | { | 63 | { |
62 | isCaseSensitive = caseS; | 64 | isCaseSensitive = caseS; |
63 | } | 65 | } |
@@ -70,24 +72,25 @@ void DingWidget::setDict( QString dict ) | |||
70 | void DingWidget::setQueryWord( QString qword ) | 72 | void DingWidget::setQueryWord( QString qword ) |
71 | { | 73 | { |
72 | queryword = qword; | 74 | queryword = qword; |
73 | } | 75 | } |
74 | 76 | ||
75 | 77 | ||
76 | void DingWidget::loadValues() | 78 | void DingWidget::loadValues() |
77 | { | 79 | { |
78 | if ( !methodname ) return; | 80 | if ( !methodname ) return; |
79 | Config cfg( "odict" ); | 81 | Config cfg( "odict" ); |
80 | cfg.setGroup( "Method_" + methodname ); | 82 | cfg.setGroup( "Method_" + methodname ); |
81 | trenner = cfg.readEntry( "Seperator" ); | 83 | trenner = cfg.readEntry( "Seperator" ); |
84 | |||
82 | lang1_name = cfg.readEntry( "Lang1" ); | 85 | lang1_name = cfg.readEntry( "Lang1" ); |
83 | lang2_name = cfg.readEntry( "Lang2" ); | 86 | lang2_name = cfg.readEntry( "Lang2" ); |
84 | } | 87 | } |
85 | 88 | ||
86 | BroswerContent DingWidget::setText( QString word ) | 89 | BroswerContent DingWidget::setText( QString word ) |
87 | { | 90 | { |
88 | queryword = word; | 91 | queryword = word; |
89 | return parseInfo(); | 92 | return parseInfo(); |
90 | } | 93 | } |
91 | 94 | ||
92 | 95 | ||
93 | BroswerContent DingWidget::parseInfo() | 96 | BroswerContent DingWidget::parseInfo() |
@@ -107,25 +110,25 @@ BroswerContent DingWidget::parseInfo() | |||
107 | { | 110 | { |
108 | current = *it; | 111 | current = *it; |
109 | left = current.left( current.find( trenner ) ); | 112 | left = current.left( current.find( trenner ) ); |
110 | 113 | ||
111 | right = current.right( current.length() - current.find(trenner) - trenner.length() ); | 114 | right = current.right( current.length() - current.find(trenner) - trenner.length() ); |
112 | 115 | ||
113 | if ( left.contains( queryword , isCaseSensitive ) ) | 116 | if ( left.contains( queryword , isCaseSensitive ) ) |
114 | { | 117 | { |
115 | left.replace( queryword, substitute ); | 118 | left.replace( queryword, substitute ); |
116 | left = left + " --> " + right; | 119 | left = left + " --> " + right; |
117 | toplist.append( left ); | 120 | toplist.append( left ); |
118 | } | 121 | } |
119 | else | 122 | else if( right.contains( queryword , isCaseSensitive ) ) |
120 | { | 123 | { |
121 | right.replace( queryword, substitute ); | 124 | right.replace( queryword, substitute ); |
122 | right = right + " --> " + left; | 125 | right = right + " --> " + left; |
123 | bottomlist.append( right ); | 126 | bottomlist.append( right ); |
124 | } | 127 | } |
125 | } | 128 | } |
126 | 129 | ||
127 | s_strings.top = toplist.join( "<br>" ); | 130 | s_strings.top = toplist.join( "<br>" ); |
128 | s_strings.bottom = bottomlist.join( "<br>" ); | 131 | s_strings.bottom = bottomlist.join( "<br>" ); |
129 | 132 | ||
130 | return s_strings; | 133 | return s_strings; |
131 | } | 134 | } |