summaryrefslogtreecommitdiff
authorar <ar>2004-05-03 21:35:18 (UTC)
committer ar <ar>2004-05-03 21:35:18 (UTC)
commit412619441fab46fc79c695a23ccf9e38135bdfad (patch) (unidiff)
tree19d9b8af14cf6c345ef532bb32368b9c7b43c50f
parentd1095d71394779557f446e2a67ba55bc62eec859 (diff)
downloadopie-412619441fab46fc79c695a23ccf9e38135bdfad.zip
opie-412619441fab46fc79c695a23ccf9e38135bdfad.tar.gz
opie-412619441fab46fc79c695a23ccf9e38135bdfad.tar.bz2
- convert qDebug to odebug
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.cpp1724
-rw-r--r--noncore/apps/opie-gutenbrowser/NetworkDialog.cpp78
-rw-r--r--noncore/apps/opie-gutenbrowser/SearchDialog.cpp4
-rw-r--r--noncore/apps/opie-gutenbrowser/browserDialog.cpp5
-rw-r--r--noncore/apps/opie-gutenbrowser/fontDialog.cpp20
-rw-r--r--noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp33
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp3217
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp38
-rw-r--r--noncore/apps/opie-gutenbrowser/helpme.cpp13
-rw-r--r--noncore/apps/opie-gutenbrowser/main.cpp2
-rw-r--r--noncore/apps/opie-gutenbrowser/openetext.cpp55
-rw-r--r--noncore/apps/opie-gutenbrowser/optionsDialog.cpp42
-rw-r--r--noncore/apps/opie-reader/Aportis.cpp8
-rw-r--r--noncore/apps/opie-reader/Bkmks.cpp6
-rw-r--r--noncore/apps/opie-reader/BuffDoc.cpp18
-rw-r--r--noncore/apps/opie-reader/CDrawBuffer.cpp22
-rw-r--r--noncore/apps/opie-reader/QTReader.cpp52
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp3231
-rw-r--r--noncore/apps/opie-reader/StyleConsts.cpp2
-rw-r--r--noncore/apps/opie-reader/fileBrowser.cpp8
-rw-r--r--noncore/apps/opie-reader/opie-reader.pro12
-rw-r--r--noncore/apps/opie-reader/plucker.cpp10
-rw-r--r--noncore/apps/opie-reader/plucker_base.cpp1402
-rw-r--r--noncore/apps/tinykate/libkate/document/katebuffer.cpp89
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.cpp73
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.cpp126
-rw-r--r--noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp69
-rw-r--r--noncore/apps/tinykate/libkate/kateconfig.cpp219
-rw-r--r--noncore/apps/tinykate/tinykate.cpp31
29 files changed, 5340 insertions, 5269 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
index 5b22b00..270a4cf 100644
--- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
@@ -1,825 +1,829 @@
1/*************************************************************************** 1/***************************************************************************
2// LibraryDialog.cpp - description 2// LibraryDialog.cpp - description
3// ------------------- 3// -------------------
4// begin : Sat Aug 19 2000 4// begin : Sat Aug 19 2000
5// copyright : (C) 2000 - 2004 by llornkcor 5// copyright : (C) 2000 - 2004 by llornkcor
6// email : ljp@llornkcor.com 6// email : ljp@llornkcor.com
7// ***************************************************/ 7// ***************************************************/
8// /*************************************************************************** 8// /***************************************************************************
9// * This program is free software; you can redistribute it and/or modify * 9// * This program is free software; you can redistribute it and/or modify *
10// * it under the terms of the GNU General Public License as published by * 10// * it under the terms of the GNU General Public License as published by *
11// * the Free Software Foundation; either version 2 of the License, or * 11// * the Free Software Foundation; either version 2 of the License, or *
12// * (at your option) any later version. * 12// * (at your option) any later version. *
13// ***************************************************************************/ 13// ***************************************************************************/
14//ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL 14//ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL
15 15
16#include "LibraryDialog.h"
17#include "output.h"
18
19/* OPIE */
16#include <qpe/applnk.h> 20#include <qpe/applnk.h>
17#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
18#include <qpe/qpedialog.h> 22#include <qpe/qpedialog.h>
23#include <opie2/odebug.h>
19 24
20#include "LibraryDialog.h" 25/* QT */
21#include "output.h"
22
23#include <qpushbutton.h> 26#include <qpushbutton.h>
24#include <qmultilineedit.h> 27#include <qmultilineedit.h>
25//#include <qlayout.h> 28//#include <qlayout.h>
26 29
30/* STD */
27#include <unistd.h> 31#include <unistd.h>
28#include <stdio.h> 32#include <stdio.h>
29#include <stdlib.h> 33#include <stdlib.h>
30 34
31/* 35/*
32 * The dialog will by default be modeless, unless you set 'modal' to 36 * The dialog will by default be modeless, unless you set 'modal' to
33 * TRUE to construct a modal dialog. */ 37 * TRUE to construct a modal dialog. */
34LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool modal, WFlags fl ) 38LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool modal, WFlags fl )
35 : QDialog( parent, name, true/* modal*/, fl ) 39 : QDialog( parent, name, true/* modal*/, fl )
36{ 40{
37 if ( !name ) 41 if ( !name )
38 setName( "LibraryDialog" ); 42 setName( "LibraryDialog" );
39 indexLoaded=false; 43 indexLoaded=false;
40 initDialog(); 44 initDialog();
41 45
42 // this->setMaximumWidth(240); 46 // this->setMaximumWidth(240);
43 47
44 index = "GUTINDEX.ALL"; 48 index = "GUTINDEX.ALL";
45 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 49 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
46 local_index = local_library + index; 50 local_index = local_library + index;
47 51
48 QString iniFile ; 52 QString iniFile ;
49 iniFile = QPEApplication::qpeDir()+"/etc/gutenbrowser/gutenbrowserrc"; 53 iniFile = QPEApplication::qpeDir()+"/etc/gutenbrowser/gutenbrowserrc";
50 54
51 new_index =QPEApplication::qpeDir()+"/etc/gutenbrowser/PGWHOLE.TXT"; 55 new_index =QPEApplication::qpeDir()+"/etc/gutenbrowser/PGWHOLE.TXT";
52 56
53 old_index = QPEApplication::qpeDir()+"/etc/gutenbrowser/GUTINDEX.ALL"; 57 old_index = QPEApplication::qpeDir()+"/etc/gutenbrowser/GUTINDEX.ALL";
54 // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 58 // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
55 59
56 // iniFile = local_library+"gutenbrowserrc"; 60 // iniFile = local_library+"gutenbrowserrc";
57 // new_index = local_library + "PGWHOLE.TXT"; 61 // new_index = local_library + "PGWHOLE.TXT";
58 // old_index = local_library + "GUTINDEX.ALL"; 62 // old_index = local_library + "GUTINDEX.ALL";
59 63
60 Config config("Gutenbrowser"); 64 Config config("Gutenbrowser");
61 65
62 config.setGroup( "HttpServer" ); 66 config.setGroup( "HttpServer" );
63 proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); 67 proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org");
64 68
65 config.setGroup( "FTPsite" ); 69 config.setGroup( "FTPsite" );
66 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); 70 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
67 qDebug("Library Dialog: ftp_host is "+ftp_host); 71 odebug << "Library Dialog: ftp_host is "+ftp_host << oendl;
68 // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); 72 // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) );
69 // ftp_host=ftp_host.stripWhiteSpace(); 73 // ftp_host=ftp_host.stripWhiteSpace();
70 ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); 74 ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
71 75
72 i_binary = 0; 76 i_binary = 0;
73 77
74 config.setGroup("SortAuth"); 78 config.setGroup("SortAuth");
75 if( config.readEntry("authSort", "FALSE") == "TRUE") 79 if( config.readEntry("authSort", "FALSE") == "TRUE")
76 authBox->setChecked(TRUE); 80 authBox->setChecked(TRUE);
77 81
78 config.setGroup("General"); 82 config.setGroup("General");
79 downDir =config.readEntry( "DownloadDirectory",local_library); 83 downDir =config.readEntry( "DownloadDirectory",local_library);
80 qDebug("downDir is "+downDir); 84 odebug << "downDir is "+downDir << oendl;
81 newindexLib.setName( old_index); 85 newindexLib.setName( old_index);
82 indexLib.setName( old_index); 86 indexLib.setName( old_index);
83 87
84 new QPEDialogListener(this); 88 new QPEDialogListener(this);
85} 89}
86 90
87LibraryDialog::~LibraryDialog() 91LibraryDialog::~LibraryDialog()
88{ 92{
89 // delete QList_Item2; 93// delete QList_Item2;
90 // delete QList_Item1; 94// delete QList_Item1;
91 // delete QList_Item3; 95// delete QList_Item3;
92 // delete QList_Item4; 96// delete QList_Item4;
93 // delete QList_Item5; 97// delete QList_Item5;
94 98
95 //saveConfig(); 99 // saveConfig();
96} 100}
97 101
98 /*This groks using PGWHOLE.TXT */ 102 /*This groks using PGWHOLE.TXT */
99void LibraryDialog::Newlibrary() 103void LibraryDialog::Newlibrary()
100{ 104{
101#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files 105#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files
102 //qDebug("Opening new library index %s",newindexLib); 106 //odebug << "Opening new library index " << newindexLib << "" << oendl;
103 if ( newindexLib.open( IO_ReadOnly) ) { 107 if ( newindexLib.open( IO_ReadOnly) ) {
104 setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully 108 setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully
105 QTextStream indexStream( &newindexLib ); 109 QTextStream indexStream( &newindexLib );
106 QString indexLine; 110 QString indexLine;
107 while ( !indexStream.atEnd() ) { // until end of file.. 111 while ( !indexStream.atEnd() ) { // until end of file..
108 indexLine = indexStream.readLine(); 112 indexLine = indexStream.readLine();
109 if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { 113 if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) {
110 year = indexLine.mid(4,4); 114 year = indexLine.mid(4,4);
111 year = year.stripWhiteSpace(); 115 year = year.stripWhiteSpace();
112 file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); 116 file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 );
113 file = file.stripWhiteSpace(); 117 file = file.stripWhiteSpace();
114 number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); 118 number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 );
115 if( year.toInt() < 1984) 119 if( year.toInt() < 1984)
116 number = number.left( number.length() -1 ); 120 number = number.left( number.length() -1 );
117 number = number.stripWhiteSpace(); 121 number = number.stripWhiteSpace();
118 title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); 122 title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() );
119 title = title.stripWhiteSpace(); 123 title = title.stripWhiteSpace();
120 124
121 getAuthor(); // groks author 125 getAuthor(); // groks author
122 author = author.stripWhiteSpace(); 126 author = author.stripWhiteSpace();
123 if (authBox->isChecked()) { // this reverses the first name and last name of the author 127 if (authBox->isChecked()) { // this reverses the first name and last name of the author
124 // qDebug("Sorting last name first"); 128 // odebug << "Sorting last name first" << oendl;
125 QString lastName, firstName=""; 129 QString lastName, firstName="";
126 int finder=author.findRev( ' ', -1, TRUE); 130 int finder=author.findRev( ' ', -1, TRUE);
127 lastName=author.right( author.length()-finder); 131 lastName=author.right( author.length()-finder);
128 firstName=author.left(finder); 132 firstName=author.left(finder);
129 lastName=lastName.stripWhiteSpace(); 133 lastName=lastName.stripWhiteSpace();
130 firstName=firstName.stripWhiteSpace(); 134 firstName=firstName.stripWhiteSpace();
131 135
132 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names 136 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names
133 author=lastName+", "+firstName; 137 author=lastName+", "+firstName;
134 } 138 }
135 139
136 if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) { 140 if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) {
137 141
138 // fill string list or something to be able to resort the whole library 142 // fill string list or something to be able to resort the whole library
139 if( author.isEmpty() ) 143 if( author.isEmpty() )
140 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); 144 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file );
141 else { 145 else {
142 146
143 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || 147 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) ||
144 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) 148 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) )
145 QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); 149 QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file );
146 150
147 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || 151 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) ||
148 (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) 152 (author.left(1) >= QString("g") && author.left(1) <= QString("m")) )
149 QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file ); 153 QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file );
150 154
151 else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || 155 else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) ||
152 (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) 156 (author.left(1) >= QString("n") && author.left(1) <= QString("r")) )
153 QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file ); 157 QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file );
154 158
155 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || 159 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) ||
156 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) 160 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) )
157 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); 161 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file );
158 162
159 else 163 else
160 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); 164 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file );
161 } 165 }
162 } 166 }
163 }// end if 167 }// end if
164 }// end while 168 }// end while
165 newindexLib.close(); 169 newindexLib.close();
166 } 170 }
167#ifndef Q_WS_QWS 171#ifndef Q_WS_QWS
168 setCursor( arrowCursor); 172 setCursor( arrowCursor);
169#endif 173#endif
170#endif 174#endif
171} // end Newlibrary() 175} // end Newlibrary()
172 176
173 177
174void LibraryDialog::Library() 178void LibraryDialog::Library()
175{// old library groking method 179{// old library groking method
176 180
177 ListView1->clear(); 181 ListView1->clear();
178 ListView2->clear(); 182 ListView2->clear();
179 ListView3->clear(); 183 ListView3->clear();
180 ListView4->clear(); 184 ListView4->clear();
181 ListView5->clear(); 185 ListView5->clear();
182 186
183 qDebug("opening GUTINDEX.ALL file"); 187 odebug << "opening GUTINDEX.ALL file" << oendl;
184 IDontKnowWhy = ""; 188 IDontKnowWhy = "";
185 if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully 189 if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully
186 QTextStream indexStream( &indexLib ); 190 QTextStream indexStream( &indexLib );
187 QString indexLine; 191 QString indexLine;
188 qApp->processEvents(); 192 qApp->processEvents();
189 // int jig; 193 // int jig;
190 while ( !indexStream.eof() ) { 194 while ( !indexStream.eof() ) {
191 195
192 indexLine = indexStream.readLine(); 196 indexLine = indexStream.readLine();
193 if ( indexLine != "") { 197 if ( indexLine != "") {
194 if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) { 198 if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) {
195 // month = indexLine.left( 3); 199 // month = indexLine.left( 3);
196 year = indexLine.mid(4,4); 200 year = indexLine.mid(4,4);
197 // title = indexLine.mid( 9, 50); 201 // title = indexLine.mid( 9, 50);
198 file = indexLine.mid(60,12); 202 file = indexLine.mid(60,12);
199 if(file.left(1).find("[",0,TRUE) != -1) 203 if(file.left(1).find("[",0,TRUE) != -1)
200 file.remove(1,1); 204 file.remove(1,1);
201 if( file.find("]",0,TRUE) != -1) 205 if( file.find("]",0,TRUE) != -1)
202 file = file.left( file.find("]",0,TRUE)); 206 file = file.left( file.find("]",0,TRUE));
203 //qDebug("file is "+file); 207 //odebug << "file is "+file << oendl;
204 /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); 208 /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 );
205 number = indexLine.mid(55,5); 209 number = indexLine.mid(55,5);
206 number = number.stripWhiteSpace(); 210 number = number.stripWhiteSpace();
207 // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); 211 // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() );
208 title = indexLine.mid( 9, 50 ); 212 title = indexLine.mid( 9, 50 );
209 title = title.stripWhiteSpace(); 213 title = title.stripWhiteSpace();
210 //qDebug("title is "+title); 214 //odebug << "title is "+title << oendl;
211 getAuthor(); // grok author 215 getAuthor(); // grok author
212 author = author.stripWhiteSpace(); 216 author = author.stripWhiteSpace();
213 //qDebug("author is "+author); 217 //odebug << "author is "+author << oendl;
214 if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author 218 if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author
215 QString lastName, firstName=""; 219 QString lastName, firstName="";
216 int finder=author.findRev( ' ', -1, TRUE); 220 int finder=author.findRev( ' ', -1, TRUE);
217 lastName=author.right( author.length()-finder); 221 lastName=author.right( author.length()-finder);
218 firstName=author.left(finder); 222 firstName=author.left(finder);
219 lastName=lastName.stripWhiteSpace(); 223 lastName=lastName.stripWhiteSpace();
220 firstName=firstName.stripWhiteSpace(); 224 firstName=firstName.stripWhiteSpace();
221 225
222 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names 226 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names
223 author=lastName+", "+firstName; 227 author=lastName+", "+firstName;
224 } 228 }
225 229
226 if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) /*&& (file.find( "]",0, TRUE))*/ ) { 230 if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) /*&& (file.find( "]",0, TRUE))*/ ) {
227 // fill string list or something to be able to sort by Author 231 // fill string list or something to be able to sort by Author
228 if( author.isEmpty() ) 232 if( author.isEmpty() )
229 QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); 233 QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file );
230 else { 234 else {
231 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || 235 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) ||
232 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) 236 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) )
233 QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); 237 QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file );
234 238
235 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || 239 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) ||
236 (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) 240 (author.left(1) >= QString("g") && author.left(1) <= QString("m")) )
237 QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); 241 QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file );
238 242
239 else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || 243 else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) ||
240 (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) 244 (author.left(1) >= QString("n") && author.left(1) <= QString("r")) )
241 QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file ); 245 QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file );
242 246
243 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || 247 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) ||
244 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) 248 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) )
245 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); 249 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file );
246 } 250 }
247 } 251 }
248 } 252 }
249 } 253 }
250 } 254 }
251 indexLib.close(); 255 indexLib.close();
252 } else { 256 } else {
253 QString sMsg; 257 QString sMsg;
254 sMsg = ( tr("Error opening local library index:\n "))+local_index; 258 sMsg = ( tr("Error opening local library index:\n "))+local_index;
255 QMessageBox::message( "Error",sMsg); 259 QMessageBox::message( "Error",sMsg);
256 } 260 }
257 261
258} //end Library() 262} //end Library()
259 263
260 264
261 /* 265 /*
262 Groks the author out of the title */ 266 Groks the author out of the title */
263bool LibraryDialog::getAuthor() 267bool LibraryDialog::getAuthor()
264{ 268{
265 if( title.contains( ", by", TRUE)) { 269 if( title.contains( ", by", TRUE)) {
266 int auth; 270 int auth;
267 auth = title.find(", by", 0, TRUE); 271 auth = title.find(", by", 0, TRUE);
268 author = title.right(title.length() - (auth + 4) ); 272 author = title.right(title.length() - (auth + 4) );
269 if( int finder = author.find("[", 0, TRUE)) { 273 if( int finder = author.find("[", 0, TRUE)) {
270 author = author.left(finder); 274 author = author.left(finder);
271 } 275 }
272 } 276 }
273 else if ( title.contains( "by, ", TRUE) ) { 277 else if ( title.contains( "by, ", TRUE) ) {
274 int auth; 278 int auth;
275 auth = title.find("by, ", 0, TRUE); 279 auth = title.find("by, ", 0, TRUE);
276 author = title.right(title.length() - (auth + 4) ); 280 author = title.right(title.length() - (auth + 4) );
277 if( int finder = author.find("[", 0, TRUE)) { 281 if( int finder = author.find("[", 0, TRUE)) {
278 author = author.left( finder); 282 author = author.left( finder);
279 } 283 }
280 } 284 }
281 else if ( title.contains( " by", TRUE) ) { 285 else if ( title.contains( " by", TRUE) ) {
282 int auth; 286 int auth;
283 auth = title.find(" by", 0, TRUE); 287 auth = title.find(" by", 0, TRUE);
284 author = title.right(title.length() - (auth + 3) ); 288 author = title.right(title.length() - (auth + 3) );
285 if( int finder = author.find("[", 0, TRUE)) { 289 if( int finder = author.find("[", 0, TRUE)) {
286 author = author.left( finder); 290 author = author.left( finder);
287 } 291 }
288 } 292 }
289 else if ( title.contains( "by ", TRUE) ) { 293 else if ( title.contains( "by ", TRUE) ) {
290 int auth; 294 int auth;
291 auth = title.find("by ", 0, TRUE); 295 auth = title.find("by ", 0, TRUE);
292 author = title.right(title.length() - (auth + 3) ); 296 author = title.right(title.length() - (auth + 3) );
293 if( int finder = author.find("[", 0, TRUE)) { 297 if( int finder = author.find("[", 0, TRUE)) {
294 author = author.left( finder); 298 author = author.left( finder);
295 } 299 }
296 } 300 }
297 else if ( title.contains( ",", TRUE) ) { 301 else if ( title.contains( ",", TRUE) ) {
298 int auth; 302 int auth;
299 auth = title.find(",", 0, TRUE); 303 auth = title.find(",", 0, TRUE);
300 author = title.right( title.length() - (auth + 1) ); 304 author = title.right( title.length() - (auth + 1) );
301 if ( author.contains( ",", TRUE) ) { 305 if ( author.contains( ",", TRUE) ) {
302 int auth; 306 int auth;
303 auth = author.find(",", 0, TRUE); 307 auth = author.find(",", 0, TRUE);
304 author = author.right( author.length() - (auth + 1) ); 308 author = author.right( author.length() - (auth + 1) );
305 } 309 }
306 if( int finder = author.find("[", 0, TRUE)) { 310 if( int finder = author.find("[", 0, TRUE)) {
307 author = author.left( finder); 311 author = author.left( finder);
308 } 312 }
309 } 313 }
310 else if ( title.contains( "/", TRUE) ) { 314 else if ( title.contains( "/", TRUE) ) {
311 int auth; 315 int auth;
312 auth = title.find("/", 0, TRUE); 316 auth = title.find("/", 0, TRUE);
313 author = title.right(title.length() - (auth + 1) ); 317 author = title.right(title.length() - (auth + 1) );
314 if( int finder = author.find("[", 0, TRUE)) { 318 if( int finder = author.find("[", 0, TRUE)) {
315 author = author.left( finder); 319 author = author.left( finder);
316 } 320 }
317 } 321 }
318 else if ( title.contains( "of", TRUE) ) { 322 else if ( title.contains( "of", TRUE) ) {
319 int auth; 323 int auth;
320 auth = title.find("of", 0, TRUE); 324 auth = title.find("of", 0, TRUE);
321 author = title.right(title.length() - (auth + 2) ); 325 author = title.right(title.length() - (auth + 2) );
322 if( int finder = author.find("[", 0, TRUE)) 326 if( int finder = author.find("[", 0, TRUE))
323 { 327 {
324 author = author.left( finder); 328 author = author.left( finder);
325 } 329 }
326 } else { 330 } else {
327 author = ""; 331 author = "";
328 } 332 }
329 if ( author.contains("et. al")) { 333 if ( author.contains("et. al")) {
330 int auth; 334 int auth;
331 auth = author.find("et. al", 0, TRUE); 335 auth = author.find("et. al", 0, TRUE);
332 author = author.left( auth ); 336 author = author.left( auth );
333 } 337 }
334 if ( author.contains("#")) { 338 if ( author.contains("#")) {
335 int auth; 339 int auth;
336 auth = author.find("#", 0, TRUE); 340 auth = author.find("#", 0, TRUE);
337 author = author.left( auth); 341 author = author.left( auth);
338 } 342 }
339 if ( author.contains("(")) { 343 if ( author.contains("(")) {
340 int auth; 344 int auth;
341 auth = author.find("(", 0, TRUE); 345 auth = author.find("(", 0, TRUE);
342 author = author.left( auth); 346 author = author.left( auth);
343 } 347 }
344 if ( author.contains("et al")) { 348 if ( author.contains("et al")) {
345 int auth; 349 int auth;
346 auth = author.find("et al", 0, TRUE); 350 auth = author.find("et al", 0, TRUE);
347 author = author.left( auth ); 351 author = author.left( auth );
348 } 352 }
349 QRegExp r = QRegExp("[0-9]", TRUE, FALSE); 353 QRegExp r = QRegExp("[0-9]", TRUE, FALSE);
350 if ( author.left(2).find( r) != -1 ) { 354 if ( author.left(2).find( r) != -1 ) {
351 author = ""; 355 author = "";
352 } 356 }
353 // if( author.contains(" ", TRUE)) { 357 // if( author.contains(" ", TRUE)) {
354 // int suth = author.findRev(" ", -1, TRUE); 358 // int suth = author.findRev(" ", -1, TRUE);
355 // author = author.right( author.length() - suth); 359 // author = author.right( author.length() - suth);
356 // } 360 // }
357 361
358 // title 362 // title
359 // author 363 // author
360 return true; 364 return true;
361}////// end getAuthor() 365}////// end getAuthor()
362 366
363 /* 367 /*
364 selected one etext*/ 368 selected one etext*/
365void LibraryDialog::select_title( QListViewItem * item) 369void LibraryDialog::select_title( QListViewItem * item)
366{ 370{
367 if(item != NULL) { 371 if(item != NULL) {
368 i++; 372 i++;
369 int index = tabWidget->currentPageIndex(); 373 int index = tabWidget->currentPageIndex();
370 DlglistItemTitle = item->text(0); 374 DlglistItemTitle = item->text(0);
371 DlglistItemYear = item->text(2); 375 DlglistItemYear = item->text(2);
372 DlglistItemFile = item->text(3); 376 DlglistItemFile = item->text(3);
373 switch (index) { 377 switch (index) {
374 case 0: { 378 case 0: {
375 ListView1->clearSelection(); 379 ListView1->clearSelection();
376 } 380 }
377 break; 381 break;
378 case 1: { 382 case 1: {
379 ListView2->clearSelection(); 383 ListView2->clearSelection();
380 } 384 }
381 break; 385 break;
382 case 2: { 386 case 2: {
383 ListView3->clearSelection(); 387 ListView3->clearSelection();
384 } 388 }
385 break; 389 break;
386 case 3: { 390 case 3: {
387 ListView4->clearSelection(); 391 ListView4->clearSelection();
388 } 392 }
389 break; 393 break;
390 case 4: { 394 case 4: {
391 ListView5->clearSelection(); 395 ListView5->clearSelection();
392 } 396 }
393 break; 397 break;
394 }; 398 };
395 } 399 }
396 400
397 if(DlglistItemTitle.length()>2) { 401 if(DlglistItemTitle.length()>2) {
398 // DlglistItemNumber = item->text(0); 402 // DlglistItemNumber = item->text(0);
399 item = 0; 403 item = 0;
400 qDebug( "string from librarydialog is:%s %s %s", DlglistItemYear.latin1(),DlglistItemFile.latin1(),DlglistItemNumber.latin1()); 404 odebug << "string from librarydialog is:" << DlglistItemYear << " " << DlglistItemFile << " " << DlglistItemNumber << "" << oendl;
401 qDebug("Title is "+DlglistItemTitle); 405 odebug << "Title is "+DlglistItemTitle << oendl;
402 406
403 // check for connection here 407 // check for connection here
404 // if( get_extext()) 408 // if( get_extext())
405 409
406 if(download_Etext()) { 410 if(download_Etext()) {
407 // qDebug("get here 2"); 411 // odebug << "get here 2" << oendl;
408 if(i_binary == 1) { 412 if(i_binary == 1) {
409 413
410 } 414 }
411 if(checkBox->isChecked () ) { 415 if(checkBox->isChecked () ) {
412 accept(); 416 accept();
413 } 417 }
414 } 418 }
415 } 419 }
416} 420}
417 421
418bool LibraryDialog::download_Etext() 422bool LibraryDialog::download_Etext()
419{ // ftp method 423{ // ftp method
420 // might have to use old gpl'd ftp for embedded!! 424 // might have to use old gpl'd ftp for embedded!!
421 Config cfg("Gutenbrowser"); 425 Config cfg("Gutenbrowser");
422 cfg.setGroup("FTPsite"); 426 cfg.setGroup("FTPsite");
423 ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org"); 427 ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org");
424 ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg"); 428 ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg");
425 429
426 qDebug("about to network dialog"); 430 odebug << "about to network dialog" << oendl;
427 QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile; 431 QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile;
428 432
429 //////////////////// FIXME- if 'x' is part of real name.... 433 //////////////////// FIXME- if 'x' is part of real name....
430 NewlistItemFile = DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).left(DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).find("x", 1, FALSE)); 434 NewlistItemFile = DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).left(DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).find("x", 1, FALSE));
431 435
432 if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) { 436 if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) {
433 NewlistItemFile.replace( 0,4, DlglistItemFile.left(4)); 437 NewlistItemFile.replace( 0,4, DlglistItemFile.left(4));
434 qDebug("NewlistItemFile is now "+NewlistItemFile); 438 odebug << "NewlistItemFile is now "+NewlistItemFile << oendl;
435 } 439 }
436 NewlistItemYear = DlglistItemYear.right(2); 440 NewlistItemYear = DlglistItemYear.right(2);
437 int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10); 441 int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10);
438 qDebug(NewlistItemYear); 442 odebug << NewlistItemYear << oendl;
439 if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) { 443 if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) {
440 NewlistItemYear = "90"; 444 NewlistItemYear = "90";
441 } 445 }
442 Edir ="etext" +NewlistItemYear; 446 Edir ="etext" +NewlistItemYear;
443 dir= ftp_base_dir + "/etext" +NewlistItemYear+"/"; 447 dir= ftp_base_dir + "/etext" +NewlistItemYear+"/";
444 if( ftp_base_dir.find("=",0,true) ) 448 if( ftp_base_dir.find("=",0,true) )
445 ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1); 449 ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1);
446 450
447 networkUrl= "ftp://"+ftp_host+dir; 451 networkUrl= "ftp://"+ftp_host+dir;
448 452
449 outputFile=local_library+".guten_temp"; 453 outputFile=local_library+".guten_temp";
450 //qDebug("Download file:%s",NewlistItemFile.latin1() ); 454 //odebug << "Download file:" << NewlistItemFile << "" << oendl;
451 qDebug("Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile); 455 odebug << "Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile << oendl;
452 QStringList networkList; 456 QStringList networkList;
453 networkList.append((const char *)ftp_host); 457 networkList.append((const char *)ftp_host);
454 networkList.append((const char *)dir); 458 networkList.append((const char *)dir);
455 networkList.append((const char *)outputFile); 459 networkList.append((const char *)outputFile);
456 networkList.append((const char *)NewlistItemFile); 460 networkList.append((const char *)NewlistItemFile);
457//<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile; 461//<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile;
458 462
459 NetworkDialog *NetworkDlg; 463 NetworkDialog *NetworkDlg;
460 NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList); 464 NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList);
461 465
462 466
463 if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer 467 if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer
464 File_Name= NetworkDlg->localFileName; 468 File_Name= NetworkDlg->localFileName;
465 qDebug("back to Library from Network Dialog"); 469 odebug << "back to Library from Network Dialog" << oendl;
466 qDebug("Just downloaded "+NetworkDlg->localFileName); 470 odebug << "Just downloaded "+NetworkDlg->localFileName << oendl;
467 471
468 // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found 472 // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found
469 // QString oldName=File_Name; 473 // QString oldName=File_Name;
470 // File_Name.replace(0,local_library.length(),downDir); 474 // File_Name.replace(0,local_library.length(),downDir);
471 // qDebug("File_Name now is "+File_Name); 475 // odebug << "File_Name now is "+File_Name << oendl;
472 476
473 // } 477 // }
474 // rename .txt to .etx 478 // rename .txt to .etx
475 if(NetworkDlg->successDownload) { 479 if(NetworkDlg->successDownload) {
476 qDebug("Filename is "+File_Name); 480 odebug << "Filename is "+File_Name << oendl;
477 if(File_Name.right(4)==".txt") { 481 if(File_Name.right(4)==".txt") {
478 QString s_fileName=File_Name; 482 QString s_fileName=File_Name;
479 s_fileName.replace( s_fileName.length()-3,3,"gtn"); 483 s_fileName.replace( s_fileName.length()-3,3,"gtn");
480 // s_fileName.replace( s_fileName.length()-3,3,"etx"); 484 // s_fileName.replace( s_fileName.length()-3,3,"etx");
481 rename(File_Name.latin1(),s_fileName.latin1()); 485 rename(File_Name.latin1(),s_fileName.latin1());
482 File_Name=s_fileName; 486 File_Name=s_fileName;
483 487
484 qDebug("Filename is now "+File_Name); 488 odebug << "Filename is now "+File_Name << oendl;
485 489
486 } 490 }
487 if(File_Name.length() > 5 ) { 491 if(File_Name.length() > 5 ) {
488 setTitle(); 492 setTitle();
489 QFileInfo fi(File_Name); 493 QFileInfo fi(File_Name);
490 QString name_file=fi.fileName(); 494 QString name_file=fi.fileName();
491 name_file=name_file.left(name_file.length()-4); 495 name_file=name_file.left(name_file.length()-4);
492 496
493 qDebug("Setting doclink"); 497 odebug << "Setting doclink" << oendl;
494 DocLnk lnk; 498 DocLnk lnk;
495 qDebug("name is "+name_file); 499 odebug << "name is "+name_file << oendl;
496 lnk.setName(name_file); //sets file name 500 lnk.setName(name_file); //sets file name
497 qDebug("Title is "+DlglistItemTitle); 501 odebug << "Title is "+DlglistItemTitle << oendl;
498 lnk.setComment(DlglistItemTitle); 502 lnk.setComment(DlglistItemTitle);
499 503
500 qDebug("Filename is "+File_Name); 504 odebug << "Filename is "+File_Name << oendl;
501 lnk.setFile(File_Name); //sets File property 505 lnk.setFile(File_Name); //sets File property
502 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D 506 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
503 lnk.setExec(File_Name); 507 lnk.setExec(File_Name);
504 lnk.setIcon("gutenbrowser/Gutenbrowser"); 508 lnk.setIcon("gutenbrowser/Gutenbrowser");
505 if(!lnk.writeLink()) { 509 if(!lnk.writeLink()) {
506 qDebug("Writing doclink did not work"); 510 odebug << "Writing doclink did not work" << oendl;
507 } else { 511 } else {
508 } 512 }
509 } else 513 } else
510 QMessageBox::message("Note","There was an error\nwith the file"); 514 QMessageBox::message("Note","There was an error\nwith the file");
511 } 515 }
512 } 516 }
513 return true; 517 return true;
514} 518}
515 519
516bool LibraryDialog::httpDownload() 520bool LibraryDialog::httpDownload()
517{// httpDownload 521{// httpDownload
518#ifndef Q_WS_QWS 522#ifndef Q_WS_QWS
519 Config config("Gutenbrowser"); 523 Config config("Gutenbrowser");
520 config.setGroup( "Browser" ); 524 config.setGroup( "Browser" );
521 QString brow = config.readEntry("Preferred", ""); 525 QString brow = config.readEntry("Preferred", "");
522 QString file_name = "./.guten_temp"; 526 QString file_name = "./.guten_temp";
523 // config.setGroup( "HttpServer" ); 527 // config.setGroup( "HttpServer" );
524 // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); 528 // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org");
525 QString httpName = proxy_http + "/"+Edir; 529 QString httpName = proxy_http + "/"+Edir;
526 // progressBar->setProgress( i); 530 // progressBar->setProgress( i);
527 i++; 531 i++;
528 if ( brow != "Konq") { /////////// use lynx 532 if ( brow != "Konq") { /////////// use lynx
529 // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name; 533 // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name;
530 // system(cmd); 534 // system(cmd);
531 } else { //////////// use KFM 535 } else { //////////// use KFM
532 // KFM::download( httpName, file_name); 536 // KFM::download( httpName, file_name);
533 } 537 }
534 i++; 538 i++;
535 QFile tmp( file_name); 539 QFile tmp( file_name);
536 QString str; 540 QString str;
537 if (tmp.open(IO_ReadOnly)) { 541 if (tmp.open(IO_ReadOnly)) {
538 QTextStream t( &tmp ); // use a text stream 542 QTextStream t( &tmp ); // use a text stream
539 while ( !t.eof()) { 543 while ( !t.eof()) {
540 QString s = t.readLine(); 544 QString s = t.readLine();
541 if (s.contains( NewlistItemFile, FALSE) && (s.contains(".txt")) ) { 545 if (s.contains( NewlistItemFile, FALSE) && (s.contains(".txt")) ) {
542 str = s.mid( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6, (s.find( ".txt</A>", 0, TRUE) + 4) - ( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6 ) ); 546 str = s.mid( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6, (s.find( ".txt</A>", 0, TRUE) + 4) - ( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6 ) );
543 httpName += "/" + str; 547 httpName += "/" + str;
544 } 548 }
545 } //end of while loop 549 } //end of while loop
546 } 550 }
547 tmp.close(); 551 tmp.close();
548 m_getFilePath = local_library + str; 552 m_getFilePath = local_library + str;
549 i++; 553 i++;
550 if ( brow != "KFM"){ ///////// use lynx 554 if ( brow != "KFM"){ ///////// use lynx
551 QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; 555 QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath;
552 // QMessageBox::message("Error", cmd); 556 // QMessageBox::message("Error", cmd);
553 system(cmd); 557 system(cmd);
554 } else { ////////// use KFM 558 } else { ////////// use KFM
555 // KFM::download( httpName, m_getFilePath); 559 // KFM::download( httpName, m_getFilePath);
556 } 560 }
557 i++; 561 i++;
558#endif 562#endif
559 return false; 563 return false;
560} 564}
561 565
562void LibraryDialog::cancelIt() 566void LibraryDialog::cancelIt()
563{ 567{
564 saveConfig(); 568 saveConfig();
565 569
566 DlglistItemNumber = ""; 570 DlglistItemNumber = "";
567 this->reject(); 571 this->reject();
568} 572}
569 573
570bool LibraryDialog::setTitle() 574bool LibraryDialog::setTitle()
571{ 575{
572 Config config("Gutenbrowser"); 576 Config config("Gutenbrowser");
573 qDebug("setting title"); 577 odebug << "setting title" << oendl;
574 qDebug(DlglistItemTitle); 578 odebug << DlglistItemTitle << oendl;
575 579
576 if( DlglistItemTitle.find("[",0,TRUE) != -1) 580 if( DlglistItemTitle.find("[",0,TRUE) != -1)
577 DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" ); 581 DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" );
578 if( DlglistItemTitle.find("]",0,TRUE) !=-1) 582 if( DlglistItemTitle.find("]",0,TRUE) !=-1)
579 DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); 583 DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" );
580 qDebug("Title being set is "+DlglistItemTitle); 584 odebug << "Title being set is "+DlglistItemTitle << oendl;
581 int test = 0; 585 int test = 0;
582 QString ramble, temp; 586 QString ramble, temp;
583 config.setGroup("Files"); 587 config.setGroup("Files");
584 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 588 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
585 int i_numofFiles = s_numofFiles.toInt(); 589 int i_numofFiles = s_numofFiles.toInt();
586 for ( int i = 0; i <= i_numofFiles; i++){ 590 for ( int i = 0; i <= i_numofFiles; i++){
587 temp.setNum( i); 591 temp.setNum( i);
588 ramble = config.readEntry( temp, "" ); 592 ramble = config.readEntry( temp, "" );
589 if( strcmp( ramble, File_Name) == 0){ 593 if( strcmp( ramble, File_Name) == 0){
590 test = 1; 594 test = 1;
591 } 595 }
592 } 596 }
593 config.setGroup("Files"); 597 config.setGroup("Files");
594 config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); 598 config.writeEntry( "NumberOfFiles", i_numofFiles +1 );
595 QString interger; 599 QString interger;
596 interger.setNum( i_numofFiles +1); 600 interger.setNum( i_numofFiles +1);
597 config.writeEntry( interger, File_Name); 601 config.writeEntry( interger, File_Name);
598 config.setGroup( "Titles" ); 602 config.setGroup( "Titles" );
599 config.writeEntry( File_Name, DlglistItemTitle); 603 config.writeEntry( File_Name, DlglistItemTitle);
600 604
601 test = 0; 605 test = 0;
602 return true; 606 return true;
603} 607}
604 608
605 609
606void LibraryDialog::saveConfig() 610void LibraryDialog::saveConfig()
607{ 611{
608 Config config("Gutenbrowser"); 612 Config config("Gutenbrowser");
609 if( httpBox->isChecked() == TRUE) { 613 if( httpBox->isChecked() == TRUE) {
610 checked = 1; 614 checked = 1;
611 config.setGroup( "Proxy" ); 615 config.setGroup( "Proxy" );
612 config.writeEntry("IsChecked", "TRUE"); 616 config.writeEntry("IsChecked", "TRUE");
613 } else { 617 } else {
614 checked = 0; 618 checked = 0;
615 config.setGroup( "Proxy" ); 619 config.setGroup( "Proxy" );
616 config.writeEntry("IsChecked", "FALSE"); 620 config.writeEntry("IsChecked", "FALSE");
617 } 621 }
618 if (authBox->isChecked() == TRUE) { 622 if (authBox->isChecked() == TRUE) {
619 config.setGroup("SortAuth"); 623 config.setGroup("SortAuth");
620 config.writeEntry("authSort", "TRUE"); 624 config.writeEntry("authSort", "TRUE");
621 } else { 625 } else {
622 config.setGroup("SortAuth"); 626 config.setGroup("SortAuth");
623 config.writeEntry("authSort", "FALSE"); 627 config.writeEntry("authSort", "FALSE");
624 } 628 }
625 // config.write(); 629 // config.write();
626} 630}
627 631
628 /* 632 /*
629 searches library index for user word*/ 633 searches library index for user word*/
630void LibraryDialog::onButtonSearch() 634void LibraryDialog::onButtonSearch()
631{ 635{
632 ListView1->clearSelection(); 636 ListView1->clearSelection();
633 ListView2->clearSelection(); 637 ListView2->clearSelection();
634 ListView3->clearSelection(); 638 ListView3->clearSelection();
635 ListView4->clearSelection(); 639 ListView4->clearSelection();
636 ListView5->clearSelection(); 640 ListView5->clearSelection();
637 641
638 int curTab=tabWidget->currentPageIndex(); 642 int curTab=tabWidget->currentPageIndex();
639 SearchDialog* searchDlg; 643 SearchDialog* searchDlg;
640 644
641 // if( resultsList) 645 // if( resultsList)
642 searchDlg = new SearchDialog( this, "Library Search", TRUE); 646 searchDlg = new SearchDialog( this, "Library Search", TRUE);
643 searchDlg->setCaption( tr( "Library Search" ) ); 647 searchDlg->setCaption( tr( "Library Search" ) );
644 searchDlg->setLabel( "- author or title"); 648 searchDlg->setLabel( "- author or title");
645 QString resultString; 649 QString resultString;
646 int i_berger = 0; 650 int i_berger = 0;
647 if( searchDlg->exec() != 0 ) { 651 if( searchDlg->exec() != 0 ) {
648 QString searcherStr = searchDlg->get_text(); 652 QString searcherStr = searchDlg->get_text();
649 int fluff=0; 653 int fluff=0;
650 654
651 // int tabPage = tabWidget->currentPageIndex(); 655 // int tabPage = tabWidget->currentPageIndex();
652 // TODO ititerate here... struct<listViews>?? 656 // TODO ititerate here... struct<listViews>??
653 657
654 QListViewItemIterator it1( ListView1 ); 658 QListViewItemIterator it1( ListView1 );
655 QListViewItemIterator it2( ListView2 ); 659 QListViewItemIterator it2( ListView2 );
656 QListViewItemIterator it3( ListView3 ); 660 QListViewItemIterator it3( ListView3 );
657 QListViewItemIterator it4( ListView4 ); 661 QListViewItemIterator it4( ListView4 );
658 QListViewItemIterator it5( ListView5 ); 662 QListViewItemIterator it5( ListView5 );
659 663
660 //// this is really pitiful work, 664 //// this is really pitiful work,
661 /////// 665 ///////
662 bool cS; 666 bool cS;
663 if( searchDlg->caseSensitiveCheckBox->isChecked()) 667 if( searchDlg->caseSensitiveCheckBox->isChecked())
664 cS=true; //case sensitive 668 cS=true; //case sensitive
665 else 669 else
666 cS=false; 670 cS=false;
667 671
668 if(fluff==0) { 672 if(fluff==0) {
669 for ( ; it1.current(); ++it1 ) { 673 for ( ; it1.current(); ++it1 ) {
670 resultString = ( it1.current() )->text(0); 674 resultString = ( it1.current() )->text(0);
671 resultString += (" : "); 675 resultString += (" : ");
672 resultString += ( it1.current() )->text(2); 676 resultString += ( it1.current() )->text(2);
673 resultString += (" : "); 677 resultString += (" : ");
674 resultString += ( it1.current() )->text(3); 678 resultString += ( it1.current() )->text(3);
675 if( resultString.find( searcherStr, 0, cS) != -1) 679 if( resultString.find( searcherStr, 0, cS) != -1)
676 { 680 {
677 Searchlist.append( resultString); 681 Searchlist.append( resultString);
678 } 682 }
679 } 683 }
680 } 684 }
681 if(fluff==0) {// search routine here 685 if(fluff==0) {// search routine here
682 for ( ; it2.current(); ++it2 ) { 686 for ( ; it2.current(); ++it2 ) {
683 resultString = ( it2.current() )->text(0); 687 resultString = ( it2.current() )->text(0);
684 resultString += (" : "); 688 resultString += (" : ");
685 resultString += ( it2.current() )->text(2); 689 resultString += ( it2.current() )->text(2);
686 resultString += (" : "); 690 resultString += (" : ");
687 resultString += ( it2.current() )->text(3); 691 resultString += ( it2.current() )->text(3);
688 if( resultString.find( searcherStr, 0, cS) != -1) { 692 if( resultString.find( searcherStr, 0, cS) != -1) {
689 Searchlist.append( resultString); 693 Searchlist.append( resultString);
690 } 694 }
691 } 695 }
692 } 696 }
693 if(fluff==0) {// search routine here 697 if(fluff==0) {// search routine here
694 for ( ; it3.current(); ++it3 ) { 698 for ( ; it3.current(); ++it3 ) {
695 resultString = ( it3.current() )->text(0); 699 resultString = ( it3.current() )->text(0);
696 resultString += (" : "); 700 resultString += (" : ");
697 resultString += ( it3.current() )->text(2); 701 resultString += ( it3.current() )->text(2);
698 resultString += (" : "); 702 resultString += (" : ");
699 resultString += ( it3.current() )->text(3); 703 resultString += ( it3.current() )->text(3);
700 704
701 if( resultString.find( searcherStr, 0, cS) != -1) { 705 if( resultString.find( searcherStr, 0, cS) != -1) {
702 Searchlist.append( resultString); 706 Searchlist.append( resultString);
703 } 707 }
704 } 708 }
705 } 709 }
706 if(fluff==0) { 710 if(fluff==0) {
707 // search routine here 711 // search routine here
708 for ( ; it4.current(); ++it4 ) { 712 for ( ; it4.current(); ++it4 ) {
709 resultString = ( it4.current() )->text(0); 713 resultString = ( it4.current() )->text(0);
710 resultString += (" : "); 714 resultString += (" : ");
711 resultString += ( it4.current() )->text(2); 715 resultString += ( it4.current() )->text(2);
712 resultString += (" : "); 716 resultString += (" : ");
713 resultString += ( it4.current() )->text(3); 717 resultString += ( it4.current() )->text(3);
714 if( resultString.find( searcherStr, 0, cS) != -1) { 718 if( resultString.find( searcherStr, 0, cS) != -1) {
715 Searchlist.append( resultString); 719 Searchlist.append( resultString);
716 } 720 }
717 } 721 }
718 } 722 }
719 if(fluff==0) { // search routine here 723 if(fluff==0) { // search routine here
720 for ( ; it5.current(); ++it5 ) { 724 for ( ; it5.current(); ++it5 ) {
721 resultString = ( it5.current() )->text(0); 725 resultString = ( it5.current() )->text(0);
722 resultString += (" : "); 726 resultString += (" : ");
723 resultString += ( it5.current() )->text(2); 727 resultString += ( it5.current() )->text(2);
724 resultString += (" : "); 728 resultString += (" : ");
725 resultString += ( it5.current() )->text(3); 729 resultString += ( it5.current() )->text(3);
726 if( resultString.find( searcherStr, 0, cS) != -1) { 730 if( resultString.find( searcherStr, 0, cS) != -1) {
727 Searchlist.append( resultString); 731 Searchlist.append( resultString);
728 } 732 }
729 } 733 }
730 } 734 }
731 735
732 tabWidget->setCurrentPage( curTab); 736 tabWidget->setCurrentPage( curTab);
733 737
734 Searchlist.sort(); 738 Searchlist.sort();
735 SearchResultsDlg* SearchResultsDialog; 739 SearchResultsDlg* SearchResultsDialog;
736 SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); 740 SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist);
737 741
738 SearchResultsDialog->showMaximized(); 742 SearchResultsDialog->showMaximized();
739 if( SearchResultsDialog->exec() != 0) { 743 if( SearchResultsDialog->exec() != 0) {
740 texter = SearchResultsDialog->selText; 744 texter = SearchResultsDialog->selText;
741 // qDebug(texter); 745 // odebug << texter << oendl;
742 resultLs= SearchResultsDialog->resultsList; 746 resultLs= SearchResultsDialog->resultsList;
743 i_berger = 1; 747 i_berger = 1;
744 } 748 }
745 Searchlist.clear(); 749 Searchlist.clear();
746 750
747 // if(SearchResultsDialog) 751 // if(SearchResultsDialog)
748 // delete SearchResultsDialog; 752 // delete SearchResultsDialog;
749 QString tester; 753 QString tester;
750 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { 754 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) {
751 texter.sprintf("%s \n",(*it).latin1()); 755 texter.sprintf("%s \n",(*it).latin1());
752 // qDebug(texter); 756 // odebug << texter << oendl;
753 if( tester!=texter) 757 if( tester!=texter)
754 parseSearchResults( texter); 758 parseSearchResults( texter);
755 tester = texter; 759 tester = texter;
756 } 760 }
757 if(searchDlg) 761 if(searchDlg)
758 delete searchDlg; 762 delete searchDlg;
759 } 763 }
760 if(checkBox->isChecked() ) { 764 if(checkBox->isChecked() ) {
761 accept(); 765 accept();
762 } else { 766 } else {
763 setActiveWindow(); 767 setActiveWindow();
764 } 768 }
765} 769}
766 770
767 /* 771 /*
768 splits the result string and calls download for the current search result*/ 772 splits the result string and calls download for the current search result*/
769void LibraryDialog::parseSearchResults( QString resultStr) 773void LibraryDialog::parseSearchResults( QString resultStr)
770{ 774{
771 775
772 int stringLeng=resultStr.length(); 776 int stringLeng=resultStr.length();
773 QString my; 777 QString my;
774 my.setNum( stringLeng, 10); 778 my.setNum( stringLeng, 10);
775 779
776 if( resultStr.length() > 2 && resultStr.length() < 130) { 780 if( resultStr.length() > 2 && resultStr.length() < 130) {
777 int titleInt = resultStr.find( " : ", 0, TRUE); 781 int titleInt = resultStr.find( " : ", 0, TRUE);
778 DlglistItemTitle = resultStr.left( titleInt); 782 DlglistItemTitle = resultStr.left( titleInt);
779 int yearInt = resultStr.find( " : ", titleInt+3, TRUE); 783 int yearInt = resultStr.find( " : ", titleInt+3, TRUE);
780 DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); 784 DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3);
781 DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); 785 DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3));
782 download_Etext(); 786 download_Etext();
783 } 787 }
784 /* 788 /*
785 printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/ 789 printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/
786} 790}
787 791
788 // bool LibraryDialog::UnzipIt( QString zipFile) { 792 // bool LibraryDialog::UnzipIt( QString zipFile) {
789 // //////////TODO findsome other way of dealingwithzip files. 793 // //////////TODO findsome other way of dealingwithzip files.
790 // ///usr/bin/unzip"; 794 // ///usr/bin/unzip";
791 // if( QFile::exists( zipFile)) { 795 // if( QFile::exists( zipFile)) {
792 // // QString thatFile = local_library +"PGWHOLE.TXT"; 796 // // QString thatFile = local_library +"PGWHOLE.TXT";
793 // QString cmd; 797 // QString cmd;
794 // #if defined(_WS_X11_) 798 // #if defined(_WS_X11_)
795 // cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; 799 // cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library;
796 // #endif 800 // #endif
797 // #if defined(_WS_WIN_) 801 // #if defined(_WS_WIN_)
798 // QString temp= QDir::convertSeparators(local_library); 802 // QString temp= QDir::convertSeparators(local_library);
799 // zipFile=QDir::convertSeparators( zipFile); 803 // zipFile=QDir::convertSeparators( zipFile);
800 // cmd = temp+"unzip.exe -o " +zipFile/*newestLibraryFile */+" -d " + temp; 804 // cmd = temp+"unzip.exe -o " +zipFile/*newestLibraryFile */+" -d " + temp;
801 // #endif 805 // #endif
802 // #ifndef Q_WS_QWS 806 // #ifndef Q_WS_QWS
803 // // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; 807 // // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library;
804 // cmd = "unzip " + zipFile; 808 // cmd = "unzip " + zipFile;
805 // #endif 809 // #endif
806 810
807 // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No); 811 // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No);
808 // if (exit==QMessageBox::Yes) { 812 // if (exit==QMessageBox::Yes) {
809 // qDebug("Issuing the command "+cmd); 813 // odebug << "Issuing the command "+cmd << oendl;
810 // #if defined(_WS_WIN_) 814 // #if defined(_WS_WIN_)
811 // WinExec( cmd, SW_HIDE ); 815 // WinExec( cmd, SW_HIDE );
812 // #endif 816 // #endif
813 // #if defined(_WS_X11_) 817 // #if defined(_WS_X11_)
814 // system( cmd); 818 // system( cmd);
815 // #endif 819 // #endif
816 // #ifndef Q_WS_QWS 820 // #ifndef Q_WS_QWS
817 // system( cmd); 821 // system( cmd);
818 // #endif 822 // #endif
819 // // printf("unzip\n"); 823 // // printf("unzip\n");
820 // // remove( zipFile /*newestLibraryFile*/); 824 // // remove( zipFile /*newestLibraryFile*/);
821 // return true; 825 // return true;
822 // } 826 // }
823 // else if(exit==QMessageBox::No) { 827 // else if(exit==QMessageBox::No) {
824 // // printf("unzip\n"); 828 // // printf("unzip\n");
825 // return false; 829 // return false;
@@ -827,241 +831,241 @@ void LibraryDialog::parseSearchResults( QString resultStr)
827 // } else { 831 // } else {
828 // // QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); 832 // // QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) );
829 // return false; 833 // return false;
830 // } 834 // }
831 // return true; 835 // return true;
832 // } 836 // }
833 837
834void LibraryDialog::sort() 838void LibraryDialog::sort()
835{ 839{
836 840
837} 841}
838 842
839 /* 843 /*
840 Downloads the current selected listitem*/ 844 Downloads the current selected listitem*/
841bool LibraryDialog::getItem(QListViewItem *it) 845bool LibraryDialog::getItem(QListViewItem *it)
842{ 846{
843 // qDebug("selected getItem"); 847 // odebug << "selected getItem" << oendl;
844 848
845 // DlglistItemNumber = it->text(0); 849 // DlglistItemNumber = it->text(0);
846 DlglistItemTitle = it->text(0); 850 DlglistItemTitle = it->text(0);
847 DlglistItemYear = it->text(2); 851 DlglistItemYear = it->text(2);
848 DlglistItemFile = it->text(3); 852 DlglistItemFile = it->text(3);
849 853
850 if(download_Etext()) { 854 if(download_Etext()) {
851 if(i_binary == 1) { 855 if(i_binary == 1) {
852 } 856 }
853 } 857 }
854 return true; 858 return true;
855} 859}
856 860
857 /* 861 /*
858 download button is pushed so we get the current items to download*/ 862 download button is pushed so we get the current items to download*/
859bool LibraryDialog::onButtonDownload() 863bool LibraryDialog::onButtonDownload()
860{ 864{
861 // qDebug("selected onButtonDownloadz"); 865 // odebug << "selected onButtonDownloadz" << oendl;
862 866
863 QListViewItemIterator it1( ListView1 ); 867 QListViewItemIterator it1( ListView1 );
864 QListViewItemIterator it2( ListView2 ); 868 QListViewItemIterator it2( ListView2 );
865 QListViewItemIterator it3( ListView3 ); 869 QListViewItemIterator it3( ListView3 );
866 QListViewItemIterator it4( ListView4 ); 870 QListViewItemIterator it4( ListView4 );
867 QListViewItemIterator it5( ListView5 ); 871 QListViewItemIterator it5( ListView5 );
868 872
869 // iterate through all items of the listview 873 // iterate through all items of the listview
870 for ( ; it1.current(); ++it1 ) { 874 for ( ; it1.current(); ++it1 ) {
871 if ( it1.current()->isSelected() ) 875 if ( it1.current()->isSelected() )
872 getItem(it1.current()); 876 getItem(it1.current());
873 it1.current()->setSelected(FALSE); 877 it1.current()->setSelected(FALSE);
874 } 878 }
875 for ( ; it2.current(); ++it2 ) { 879 for ( ; it2.current(); ++it2 ) {
876 if ( it2.current()->isSelected() ) 880 if ( it2.current()->isSelected() )
877 getItem(it2.current()); 881 getItem(it2.current());
878 it2.current()->setSelected(FALSE); 882 it2.current()->setSelected(FALSE);
879 } 883 }
880 for ( ; it3.current(); ++it3 ) { 884 for ( ; it3.current(); ++it3 ) {
881 if ( it3.current()->isSelected() ) 885 if ( it3.current()->isSelected() )
882 getItem(it3.current()); 886 getItem(it3.current());
883 it3.current()->setSelected(FALSE); 887 it3.current()->setSelected(FALSE);
884 } 888 }
885 for ( ; it4.current(); ++it4 ) { 889 for ( ; it4.current(); ++it4 ) {
886 if ( it4.current()->isSelected() ) 890 if ( it4.current()->isSelected() )
887 getItem(it4.current()); 891 getItem(it4.current());
888 it4.current()->setSelected(FALSE); 892 it4.current()->setSelected(FALSE);
889 } 893 }
890 for ( ; it5.current(); ++it5 ) { 894 for ( ; it5.current(); ++it5 ) {
891 if ( it5.current()->isSelected() ) 895 if ( it5.current()->isSelected() )
892 getItem(it5.current()); 896 getItem(it5.current());
893 it5.current()->setSelected(FALSE); 897 it5.current()->setSelected(FALSE);
894 } 898 }
895 return true; 899 return true;
896} 900}
897 901
898 902
899 /* 903 /*
900 handles the sorting combo box */ 904 handles the sorting combo box */
901void LibraryDialog::comboSelect(int index) 905void LibraryDialog::comboSelect(int index)
902{ 906{
903 // qDebug("we are sorting"); 907 // odebug << "we are sorting" << oendl;
904 ListView1->setSorting( index, TRUE); 908 ListView1->setSorting( index, TRUE);
905 ListView2->setSorting( index, TRUE); 909 ListView2->setSorting( index, TRUE);
906 ListView3->setSorting( index, TRUE); 910 ListView3->setSorting( index, TRUE);
907 ListView4->setSorting( index, TRUE); 911 ListView4->setSorting( index, TRUE);
908 ListView5->setSorting( index, TRUE); 912 ListView5->setSorting( index, TRUE);
909 913
910 ListView1->sort(); 914 ListView1->sort();
911 ListView2->sort(); 915 ListView2->sort();
912 ListView3->sort(); 916 ListView3->sort();
913 ListView4->sort(); 917 ListView4->sort();
914 ListView5->sort(); 918 ListView5->sort();
915 919
916 // ListView1->triggerUpdate(); 920 // ListView1->triggerUpdate();
917 // ListView2->triggerUpdate(); 921 // ListView2->triggerUpdate();
918 // ListView3->triggerUpdate(); 922 // ListView3->triggerUpdate();
919 // ListView4->triggerUpdate(); 923 // ListView4->triggerUpdate();
920 // ListView5->triggerUpdate(); 924 // ListView5->triggerUpdate();
921} 925}
922 926
923void LibraryDialog::newList() 927void LibraryDialog::newList()
924{ 928{
925 if(indexLoaded) { 929 if(indexLoaded) {
926 onButtonDownload(); 930 onButtonDownload();
927 } else { 931 } else {
928 Output *outDlg; 932 Output *outDlg;
929 buttonNewList->setDown(TRUE); 933 buttonNewList->setDown(TRUE);
930 QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser"); 934 QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser");
931 if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true); 935 if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true);
932 if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) { 936 if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) {
933 qDebug("changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser"); 937 odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl;
934 QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 938 QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
935 QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; 939 QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1";
936 940
937 int result = QMessageBox::warning( this,"Download" 941 int result = QMessageBox::warning( this,"Download"
938 ,"Ok to use /'wget/' to download\na new library list?\n" 942 ,"Ok to use /'wget/' to download\na new library list?\n"
939 ,"Yes","No",0,0,1); 943 ,"Yes","No",0,0,1);
940 qApp->processEvents(); 944 qApp->processEvents();
941 if(result == 0) { 945 if(result == 0) {
942 outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); 946 outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE);
943 outDlg->showMaximized(); 947 outDlg->showMaximized();
944 outDlg->show(); 948 outDlg->show();
945 qApp->processEvents(); 949 qApp->processEvents();
946 FILE *fp; 950 FILE *fp;
947 char line[130]; 951 char line[130];
948 outDlg->OutputEdit->append( tr("Running wget") ); 952 outDlg->OutputEdit->append( tr("Running wget") );
949 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 953 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
950 sleep(1); 954 sleep(1);
951 fp = popen( (const char *) cmd, "r"); 955 fp = popen( (const char *) cmd, "r");
952 if ( !fp ) { 956 if ( !fp ) {
953 } else { 957 } else {
954 qDebug("Issuing the command\n"+cmd); 958 odebug << "Issuing the command\n"+cmd << oendl;
955 // system(cmd); 959 // system(cmd);
956 while ( fgets( line, sizeof line, fp)) { 960 while ( fgets( line, sizeof line, fp)) {
957 outDlg->OutputEdit->append(line); 961 outDlg->OutputEdit->append(line);
958 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 962 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
959 } 963 }
960 pclose(fp); 964 pclose(fp);
961 outDlg->OutputEdit->append("Finished downloading\n"); 965 outDlg->OutputEdit->append("Finished downloading\n");
962 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 966 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
963 qApp->processEvents(); 967 qApp->processEvents();
964 968
965 // if( QFile(gutenindex1).exists() ) { 969 // if( QFile(gutenindex1).exists() ) {
966 // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 970 // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
967 // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) 971 // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0)
968 // qDebug("renaming error"); 972 // odebug << "renaming error" << oendl;
969 // } 973 // }
970 974
971 } 975 }
972 // outDlg->close(); 976 // outDlg->close();
973 FindLibrary(); 977 FindLibrary();
974 if(outDlg) delete outDlg; 978 if(outDlg) delete outDlg;
975 } 979 }
976 buttonNewList->setDown(FALSE); 980 buttonNewList->setDown(FALSE);
977 } else { 981 } else {
978 QMessageBox::message("Note","Could not change directories"); 982 QMessageBox::message("Note","Could not change directories");
979 } 983 }
980 // if(outDlg) 984 // if(outDlg)
981 // delete outDlg; 985 // delete outDlg;
982 } 986 }
983} 987}
984 988
985bool LibraryDialog::moreInfo() 989bool LibraryDialog::moreInfo()
986{ 990{
987 991
988 QListViewItem * item; 992 QListViewItem * item;
989 item = 0; 993 item = 0;
990 QString titleString; 994 QString titleString;
991 item = ListView1->currentItem(); 995 item = ListView1->currentItem();
992 if( item != 0) { 996 if( item != 0) {
993 titleString = item->text(0); 997 titleString = item->text(0);
994 ListView1->clearSelection(); 998 ListView1->clearSelection();
995 item = 0; 999 item = 0;
996 } 1000 }
997 if( item == 0) 1001 if( item == 0)
998 item = ListView2->currentItem(); 1002 item = ListView2->currentItem();
999 if( item != 0) { 1003 if( item != 0) {
1000 titleString = item->text(0); 1004 titleString = item->text(0);
1001 ListView2->clearSelection(); 1005 ListView2->clearSelection();
1002 item = 0; 1006 item = 0;
1003 } 1007 }
1004 if( item == 0) 1008 if( item == 0)
1005 item = ListView3->currentItem(); 1009 item = ListView3->currentItem();
1006 if( item != 0) { 1010 if( item != 0) {
1007 titleString = item->text(0); 1011 titleString = item->text(0);
1008 ListView3->clearSelection(); 1012 ListView3->clearSelection();
1009 item = 0; 1013 item = 0;
1010 } 1014 }
1011 if( item == 0) 1015 if( item == 0)
1012 item = ListView4->currentItem(); 1016 item = ListView4->currentItem();
1013 if( item != 0) { 1017 if( item != 0) {
1014 titleString = item->text(0); 1018 titleString = item->text(0);
1015 ListView4->clearSelection(); 1019 ListView4->clearSelection();
1016 item = 0; 1020 item = 0;
1017 } 1021 }
1018 if( item == 0) 1022 if( item == 0)
1019 item = ListView5->currentItem(); 1023 item = ListView5->currentItem();
1020 if( item != 0) { 1024 if( item != 0) {
1021 titleString = item->text(0); 1025 titleString = item->text(0);
1022 ListView5->clearSelection(); 1026 ListView5->clearSelection();
1023 item = 0; 1027 item = 0;
1024 } 1028 }
1025 item=0; 1029 item=0;
1026 if(titleString.length()>2) { 1030 if(titleString.length()>2) {
1027 qDebug( "Title is "+titleString ); 1031 odebug << "Title is "+titleString << oendl;
1028 titleString.replace( QRegExp("\\s"), "%20"); 1032 titleString.replace( QRegExp("\\s"), "%20");
1029 titleString.replace( QRegExp("'"), "%20"); 1033 titleString.replace( QRegExp("'"), "%20");
1030 titleString.replace( QRegExp("\""), "%20"); 1034 titleString.replace( QRegExp("\""), "%20");
1031 titleString.replace( QRegExp("&"), "%20"); 1035 titleString.replace( QRegExp("&"), "%20");
1032 QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search"; 1036 QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search";
1033 cmd="opera "+cmd; 1037 cmd="opera "+cmd;
1034 system(cmd); 1038 system(cmd);
1035 } else 1039 } else
1036 QMessageBox::message( "Note","If you select a title, this will\nsearch google.com for that title."); 1040 QMessageBox::message( "Note","If you select a title, this will\nsearch google.com for that title.");
1037 return true; 1041 return true;
1038 1042
1039} 1043}
1040 1044
1041 /* 1045 /*
1042 This loads the library Index*/ 1046 This loads the library Index*/
1043void LibraryDialog::FindLibrary() 1047void LibraryDialog::FindLibrary()
1044{ 1048{
1045 buttonLibrary->setDown(TRUE); 1049 buttonLibrary->setDown(TRUE);
1046 1050
1047 qApp->processEvents(); 1051 qApp->processEvents();
1048 if( QFile( new_index).exists() /* && this->isHidden() */) { 1052 if( QFile( new_index).exists() /* && this->isHidden() */) {
1049 newindexLib.setName( new_index); 1053 newindexLib.setName( new_index);
1050 indexLib.setName( new_index); 1054 indexLib.setName( new_index);
1051 qDebug("index file is "+ new_index); 1055 odebug << "index file is "+ new_index << oendl;
1052 Newlibrary(); 1056 Newlibrary();
1053 } else { 1057 } else {
1054 newindexLib.setName( old_index); 1058 newindexLib.setName( old_index);
1055 indexLib.setName( old_index); 1059 indexLib.setName( old_index);
1056 qDebug("new index nameis "+ old_index); 1060 odebug << "new index nameis "+ old_index << oendl;
1057 Library(); 1061 Library();
1058 } 1062 }
1059 indexLoaded=true; 1063 indexLoaded=true;
1060 buttonSearch->setEnabled(TRUE); 1064 buttonSearch->setEnabled(TRUE);
1061 moreInfoButton->setEnabled(TRUE); 1065 moreInfoButton->setEnabled(TRUE);
1062 1066
1063 buttonLibrary->setDown(FALSE); 1067 buttonLibrary->setDown(FALSE);
1064 buttonNewList->setText("Download"); 1068 buttonNewList->setText("Download");
1065 qApp->processEvents(); 1069 qApp->processEvents();
1066 1070
1067} 1071}
diff --git a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
index aed53c6..6e6b707 100644
--- a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
@@ -1,78 +1,84 @@
1// /*************************************************************************** 1// /***************************************************************************
2// NetworkDialog.cpp - description 2// NetworkDialog.cpp - description
3// begin : Sun Aug 27 2000 3// begin : Sun Aug 27 2000
4// copyright : (C) 2000 - 2004 by L.J. Potter 4// copyright : (C) 2000 - 2004 by L.J. Potter
5// email : ljp@llornkcor.com 5// email : ljp@llornkcor.com
6// * This program is free software; you can redistribute it and/or modify * 6// * This program is free software; you can redistribute it and/or modify *
7// * it under the terms of the GNU General Public License as published by * 7// * it under the terms of the GNU General Public License as published by *
8// * the Free Software Foundation; either version 2 of the License, or * 8// * the Free Software Foundation; either version 2 of the License, or *
9// * (at your option) any later version. * 9// * (at your option) any later version. *
10// ***************************************************************************/ 10// ***************************************************************************/
11// // half-assed attempt at providing a network dialog. 11// // half-assed attempt at providing a network dialog.
12// /* Created: Sun Aug 27 15:24:52 2000*/ 12// /* Created: Sun Aug 27 15:24:52 2000*/
13#include <unistd.h>
14 13
15extern "C" {
16#include <ftplib.h>
17}
18 14
19#include "NetworkDialog.h" 15#include "NetworkDialog.h"
20#include "gutenbrowser.h" 16#include "gutenbrowser.h"
21 17
18/* OPIE */
19#include <opie2/odebug.h>
20
21/* QT */
22#include <qprogressbar.h> 22#include <qprogressbar.h>
23#include <qstringlist.h> 23#include <qstringlist.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qvaluelist.h> 25#include <qvaluelist.h>
26#include <qapplication.h> 26#include <qapplication.h>
27#include <qfile.h> 27#include <qfile.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qlayout.h> 31#include <qlayout.h>
32 32
33/* STD */
34#include <unistd.h>
35extern "C" {
36#include <ftplib.h>
37}
38
33QProgressBar* ProgressBar1; 39QProgressBar* ProgressBar1;
34QPushButton* buttonCancel; 40QPushButton* buttonCancel;
35static netbuf *conn = NULL; 41static netbuf *conn = NULL;
36 42
37static int log_progress(netbuf *ctl, int xfered, void *arg) { 43static int log_progress(netbuf *ctl, int xfered, void *arg) {
38 int fsz = *(int *)arg; 44 int fsz = *(int *)arg;
39 int pct = (xfered * 100) / fsz; 45 int pct = (xfered * 100) / fsz;
40 printf("%3d%%\r", pct); 46 printf("%3d%%\r", pct);
41 fflush(stdout); 47 fflush(stdout);
42 ProgressBar1->setProgress(xfered); 48 ProgressBar1->setProgress(xfered);
43 qApp->processEvents(); 49 qApp->processEvents();
44 50
45 return 1; 51 return 1;
46} 52}
47 53
48NetworkDialog::NetworkDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QStringList netL) 54NetworkDialog::NetworkDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QStringList netL)
49 : QDialog( parent, name, modal, fl ) 55 : QDialog( parent, name, modal, fl )
50{ 56{
51 57
52 ftp_host = netL[0]; 58 ftp_host = netL[0];
53 networkUrl = strUrl = netL[0]; 59 networkUrl = strUrl = netL[0];
54 60
55 dir = ftp_base_dir = netL[1]; 61 dir = ftp_base_dir = netL[1];
56 localFileName = netL[2]; 62 localFileName = netL[2];
57 s_partialFileName = netL[3]; 63 s_partialFileName = netL[3];
58 64
59 resize(240,110); 65 resize(240,110);
60 66
61 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 67 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
62 // autoOk = autoDownload; 68// autoOk = autoDownload;
63// if( networkUrl.find("ftp",0,false)== -1 ) { 69// if( networkUrl.find("ftp",0,false)== -1 ) {
64// if ( !name ) 70// if ( !name )
65// setName( "HTTP NetworkDialog" ); 71// setName( "HTTP NetworkDialog" );
66// setCaption( tr( "HTTP Download ) ); 72// setCaption( tr( "HTTP Download ) );
67// qInitNetworkProtocols(); // registers ftp protocol // for now 73// qInitNetworkProtocols(); // registers ftp protocol // for now
68// QNetworkProtocol::registerNetworkProtocol( "http", new QNetworkProtocolFactory<Http> ); 74// QNetworkProtocol::registerNetworkProtocol( "http", new QNetworkProtocolFactory<Http> );
69// } else { 75// } else {
70 if ( !name ) 76 if ( !name )
71 setName( "FTP NetworkDialog" ); 77 setName( "FTP NetworkDialog" );
72 setCaption(tr("FTP Download")); 78 setCaption(tr("FTP Download"));
73// } 79// }
74 initDialog(); //opens file to be written 80 initDialog(); //opens file to be written
75} 81}
76 82
77NetworkDialog::~NetworkDialog() { 83NetworkDialog::~NetworkDialog() {
78} 84}
@@ -105,225 +111,225 @@ void NetworkDialog::initDialog() {
105 hbox->addWidget(buttonCancel,0,AlignRight); 111 hbox->addWidget(buttonCancel,0,AlignRight);
106 112
107 ProgressBar1->setFixedSize(140,22); 113 ProgressBar1->setFixedSize(140,22);
108 buttonOk->setFixedSize(35,22); 114 buttonOk->setFixedSize(35,22);
109 buttonCancel->setFixedSize(35,22); 115 buttonCancel->setFixedSize(35,22);
110 warnLabel ->setGeometry( QRect( 5,1,230,25)); 116 warnLabel ->setGeometry( QRect( 5,1,230,25));
111 TextLabel3->setGeometry( QRect( 5,20,230,25)); 117 TextLabel3->setGeometry( QRect( 5,20,230,25));
112 Layout1->setGeometry( QRect(1,60,235,50)); //TODO check these!! 118 Layout1->setGeometry( QRect(1,60,235,50)); //TODO check these!!
113 119
114// timer= new QTimer(this,"vu timer"); 120// timer= new QTimer(this,"vu timer");
115// connectionTimer=new QTimer(this,"connectionTimeout"); 121// connectionTimer=new QTimer(this,"connectionTimeout");
116 122
117 connect(buttonOk,SIGNAL(clicked()),this,SLOT(doOk())); 123 connect(buttonOk,SIGNAL(clicked()),this,SLOT(doOk()));
118 connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject())); 124 connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject()));
119// connect( timer, SIGNAL(timeout()), this , SLOT(timeSlot())); 125// connect( timer, SIGNAL(timeout()), this , SLOT(timeSlot()));
120// connect( connectionTimer,SIGNAL( timeout()),this,SLOT( connectionTimeSlot())); 126// connect( connectionTimer,SIGNAL( timeout()),this,SLOT( connectionTimeSlot()));
121 if(autoOk) { 127 if(autoOk) {
122 qWarning("XXXXXXXXXXXXXXXXXXXXXXXX"); 128 owarn << "XXXXXXXXXXXXXXXXXXXXXXXX" << oendl;
123 buttonOk->setDown(true); 129 buttonOk->setDown(true);
124 doOk(); 130 doOk();
125 } 131 }
126} 132}
127 133
128void NetworkDialog::timeSlot() { 134void NetworkDialog::timeSlot() {
129 135
130// if(timerProgess < 19 && posTimer) { 136// if(timerProgess < 19 && posTimer) {
131// ProgressBar1->setProgress(timerProgess); 137// ProgressBar1->setProgress(timerProgess);
132// timerProgess++; 138// timerProgess++;
133// } else if(timerProgess > 19 && posTimer) { 139// } else if(timerProgess > 19 && posTimer) {
134// ProgressBar1->setProgress(timerProgess); 140// ProgressBar1->setProgress(timerProgess);
135// timerProgess++; 141// timerProgess++;
136// posTimer=FALSE; 142// posTimer=FALSE;
137// } 143// }
138// if(timerProgess > 1 &&!posTimer) { 144// if(timerProgess > 1 &&!posTimer) {
139// ProgressBar1->setProgress(timerProgess); 145// ProgressBar1->setProgress(timerProgess);
140// timerProgess--; 146// timerProgess--;
141// } else if(timerProgess > 1 &&!posTimer){ 147// } else if(timerProgess > 1 &&!posTimer){
142// ProgressBar1->setProgress(timerProgess); 148// ProgressBar1->setProgress(timerProgess);
143// timerProgess--; 149// timerProgess--;
144// posTimer=TRUE; 150// posTimer=TRUE;
145// } 151// }
146// // qDebug("timer event"); 152// // odebug << "timer event" << oendl;
147// qApp->processEvents(); 153// qApp->processEvents();
148// repaint(); 154// repaint();
149} 155}
150 156
151void NetworkDialog::connectionTimeSlot() { 157void NetworkDialog::connectionTimeSlot() {
152// qDebug("Connections timed out"); 158// odebug << "Connections timed out" << oendl;
153// ftpQuit(); 159// ftpQuit();
154// qApp->processEvents(); 160// qApp->processEvents();
155// repaint(); 161// repaint();
156// reject(); 162// reject();
157} 163}
158 164
159 165
160/* 166/*
161downloads the file networkUrl */ 167downloads the file networkUrl */
162bool NetworkDialog::downloadFile( QString networkUrl ) 168bool NetworkDialog::downloadFile( QString networkUrl )
163{ 169{
164 int fsz; 170 int fsz;
165// timer->start( 250 , FALSE); 171// timer->start( 250 , FALSE);
166// posTimer=TRUE; 172// posTimer=TRUE;
167// connectionTimer->start( 600 , FALSE); 173// connectionTimer->start( 600 , FALSE);
168 warnLabel ->setText( ""); 174 warnLabel ->setText( "");
169 qApp->processEvents(); 175 qApp->processEvents();
170 qDebug("Downloading: %s",networkUrl.latin1()); 176 odebug << "Downloading: " << networkUrl << "" << oendl;
171 qDebug("Into: %s",localFileName.latin1()); 177 odebug << "Into: " << localFileName << "" << oendl;
172 if( networkUrl.length() > 5) { 178 if( networkUrl.length() > 5) {
173 QString ftp_user = "anonymous"; 179 QString ftp_user = "anonymous";
174 QString ftp_pass = "zaurus@gutenbrowser.com"; 180 QString ftp_pass = "zaurus@gutenbrowser.com";
175// ftp_host= networkUrl.mid(networkUrl.find("ftp://",0, TRUE), 181// ftp_host= networkUrl.mid(networkUrl.find("ftp://",0, TRUE),
176 if(ftp_host.length() < 2) { 182 if(ftp_host.length() < 2) {
177 qDebug("Please select an ftp host" ); 183 odebug << "Please select an ftp host" << oendl;
178 successDownload=false; 184 successDownload=false;
179 QMessageBox::message("Note","You need to select an ftp host"); 185 QMessageBox::message("Note","You need to select an ftp host");
180 return false; 186 return false;
181 } 187 }
182 QString msg; 188 QString msg;
183 qDebug(ftp_host); 189 odebug << ftp_host << oendl;
184 qDebug("Opening ftp connection."); 190 odebug << "Opening ftp connection." << oendl;
185 warnLabel->setText("connecting to: "+ftp_host ); 191 warnLabel->setText("connecting to: "+ftp_host );
186 qApp->processEvents(); 192 qApp->processEvents();
187 /////////// Open FTP connection 193 /////////// Open FTP connection
188 if (!FtpConnect( ftp_host.latin1(), &conn)) { 194 if (!FtpConnect( ftp_host.latin1(), &conn)) {
189 i=0; 195 i=0;
190 successDownload=false; 196 successDownload=false;
191 QMessageBox::message("Note","Unable to connect to\n"+ftp_host); 197 QMessageBox::message("Note","Unable to connect to\n"+ftp_host);
192 return false; 198 return false;
193 } 199 }
194 TextLabel3->setText("Opening ftp connection."); 200 TextLabel3->setText("Opening ftp connection.");
195 qApp->processEvents(); 201 qApp->processEvents();
196 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 202 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
197 FtpQuit(conn); 203 FtpQuit(conn);
198 successDownload=false; 204 successDownload=false;
199 msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn)); 205 msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn));
200 QMessageBox::message("Note",msg); 206 QMessageBox::message("Note",msg);
201 return false; 207 return false;
202 } 208 }
203 qDebug("Changing directories."); 209 odebug << "Changing directories." << oendl;
204 TextLabel3->setText("Changing directories."); 210 TextLabel3->setText("Changing directories.");
205 qApp->processEvents(); 211 qApp->processEvents();
206 if (!FtpChdir( dir.latin1(), conn )) { 212 if (!FtpChdir( dir.latin1(), conn )) {
207 successDownload=false; 213 successDownload=false;
208 msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); 214 msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn));
209 QMessageBox::message("Note",msg); 215 QMessageBox::message("Note",msg);
210 FtpQuit(conn); 216 FtpQuit(conn);
211 return false; 217 return false;
212 } 218 }
213// if (!FtpNlst( "./.guten_temp", dir, conn)) { 219// if (!FtpNlst( "./.guten_temp", dir, conn)) {
214// successDownload=false; 220// successDownload=false;
215// msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); 221// msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn));
216// QMessageBox::message("Note",msg); 222// QMessageBox::message("Note",msg);
217// FtpQuit(conn); 223// FtpQuit(conn);
218// return false; 224// return false;
219// } 225// }
220 qDebug("Requesting directory list."); 226 odebug << "Requesting directory list." << oendl;
221 TextLabel3->setText("Getting directory list."); 227 TextLabel3->setText("Getting directory list.");
222 qApp->processEvents(); 228 qApp->processEvents();
223 if (!FtpDir( "./.guten_temp", dir.latin1(), conn) ) { 229 if (!FtpDir( "./.guten_temp", dir.latin1(), conn) ) {
224 msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn)); 230 msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn));
225 QMessageBox::message("Note",msg); 231 QMessageBox::message("Note",msg);
226 successDownload=false; 232 successDownload=false;
227 FtpQuit(conn); 233 FtpQuit(conn);
228 return false; 234 return false;
229 } 235 }
230 QFile tmp("./.guten_temp"); 236 QFile tmp("./.guten_temp");
231 QString s, File_Name; 237 QString s, File_Name;
232 238
233 if (tmp.open(IO_ReadOnly)) { 239 if (tmp.open(IO_ReadOnly)) {
234 QTextStream t( &tmp ); // use a text stream 240 QTextStream t( &tmp ); // use a text stream
235 qDebug("Finding partial filename "+s_partialFileName); 241 odebug << "Finding partial filename "+s_partialFileName << oendl;
236 while ( !t.eof()) { 242 while ( !t.eof()) {
237 s = t.readLine(); 243 s = t.readLine();
238 244
239 if (s.contains(s_partialFileName, FALSE)) { 245 if (s.contains(s_partialFileName, FALSE)) {
240 QString str = s.right( (s.length()) - (s.find(s_partialFileName, FALSE)) ); 246 QString str = s.right( (s.length()) - (s.find(s_partialFileName, FALSE)) );
241 247
242 if (str.contains(".txt")) { 248 if (str.contains(".txt")) {
243 File_Name = str; 249 File_Name = str;
244 qDebug("Found file_name "+ File_Name); 250 odebug << "Found file_name "+ File_Name << oendl;
245 break; 251 break;
246 } 252 }
247// if (str.contains(".zip")) { 253// if (str.contains(".zip")) {
248// File_Name = str; 254// File_Name = str;
249// qDebug("Found file_name "+ File_Name); 255// odebug << "Found file_name "+ File_Name << oendl;
250// break; 256// break;
251// } 257// }
252 258
253 } 259 }
254 } //end of while loop 260 } //end of while loop
255 tmp.close(); 261 tmp.close();
256// tmp.remove(); ///TODO this is for release version Zaurus 262// tmp.remove(); ///TODO this is for release version Zaurus
257 } 263 }
258 else 264 else
259 qDebug("Error opening temp file."); 265 odebug << "Error opening temp file." << oendl;
260 266
261 Config cfg("Gutenbrowser"); 267 Config cfg("Gutenbrowser");
262 cfg.setGroup("General"); 268 cfg.setGroup("General");
263 QString temp=cfg.readEntry("DownloadDirectory",local_library); 269 QString temp=cfg.readEntry("DownloadDirectory",local_library);
264 270
265 localFileName = temp+File_Name; 271 localFileName = temp+File_Name;
266 qDebug("Requesting file "+ File_Name); 272 odebug << "Requesting file "+ File_Name << oendl;
267 qDebug( "Saving as "+localFileName); 273 odebug << "Saving as "+localFileName << oendl;
268 msg="Requesting file "+ File_Name; 274 msg="Requesting file "+ File_Name;
269 TextLabel3->setText(msg); 275 TextLabel3->setText(msg);
270 qApp->processEvents(); 276 qApp->processEvents();
271 if( File_Name.length()>3) { 277 if( File_Name.length()>3) {
272 if (!FtpSize( File_Name.latin1(), &fsz, FTPLIB_ASCII, conn)) 278 if (!FtpSize( File_Name.latin1(), &fsz, FTPLIB_ASCII, conn))
273 fsz = 0; 279 fsz = 0;
274 QString temp; 280 QString temp;
275 temp.sprintf( File_Name+" "+" %dkb", fsz); 281 temp.sprintf( File_Name+" "+" %dkb", fsz);
276 TextLabel3->setText(temp); 282 TextLabel3->setText(temp);
277 283
278 ProgressBar1->setTotalSteps(fsz); 284 ProgressBar1->setTotalSteps(fsz);
279 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 285 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
280 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 286 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
281 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 287 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
282 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 288 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
283 289
284 if (!FtpGet( localFileName.latin1(), File_Name.latin1(), FTPLIB_ASCII, conn)) { 290 if (!FtpGet( localFileName.latin1(), File_Name.latin1(), FTPLIB_ASCII, conn)) {
285 msg.sprintf("Could not download "+ File_Name+"\n%s",FtpLastResponse(conn)); 291 msg.sprintf("Could not download "+ File_Name+"\n%s",FtpLastResponse(conn));
286 successDownload=false; 292 successDownload=false;
287 QMessageBox::message("Note",msg); 293 QMessageBox::message("Note",msg);
288 update(); 294 update();
289 } 295 }
290 } else { 296 } else {
291 QMessageBox::message("Note","Could not download file "+ File_Name); 297 QMessageBox::message("Note","Could not download file "+ File_Name);
292 successDownload=false; 298 successDownload=false;
293 FtpQuit(conn); 299 FtpQuit(conn);
294 return false; 300 return false;
295 } 301 }
296 qDebug("Ftp session successful"); 302 odebug << "Ftp session successful" << oendl;
297 successDownload=TRUE; 303 successDownload=TRUE;
298 FtpQuit(conn); 304 FtpQuit(conn);
299 return true; 305 return true;
300 } //no network url 306 } //no network url
301 return false; 307 return false;
302} 308}
303 309
304void NetworkDialog::doOk() { 310void NetworkDialog::doOk() {
305 qWarning("Do OK"); 311 owarn << "Do OK" << oendl;
306 QString loginStr; 312 QString loginStr;
307 loginStr = "gutenbrowser"; 313 loginStr = "gutenbrowser";
308 if ( !ftp_host.isEmpty() ) { 314 if ( !ftp_host.isEmpty() ) {
309 if( ftp_host.find( "/", ftp_host.length() - 1,TRUE) != -1 && ftp_host.find("ftp://",0, TRUE) != -1) { 315 if( ftp_host.find( "/", ftp_host.length() - 1,TRUE) != -1 && ftp_host.find("ftp://",0, TRUE) != -1) {
310 TextLabel3->setText( tr( "List remote dir:\n" + ftp_host) ); 316 TextLabel3->setText( tr( "List remote dir:\n" + ftp_host) );
311// TextLabel2->setText( tr( "local file to download into: " +localFileName ) ); 317// TextLabel2->setText( tr( "local file to download into: " +localFileName ) );
312 318
313 if( downloadFile(ftp_host)) 319 if( downloadFile(ftp_host))
314 successDownload = true; 320 successDownload = true;
315 else { 321 else {
316 successDownload = false; 322 successDownload = false;
317 reject(); 323 reject();
318 } 324 }
319 } else { 325 } else {
320 if(downloadFile(ftp_host)) 326 if(downloadFile(ftp_host))
321 successDownload = true; 327 successDownload = true;
322 else { 328 else {
323 successDownload = false; 329 successDownload = false;
324 reject(); 330 reject();
325 } 331 }
326 } 332 }
327 } 333 }
328 accept(); 334 accept();
329} 335}
diff --git a/noncore/apps/opie-gutenbrowser/SearchDialog.cpp b/noncore/apps/opie-gutenbrowser/SearchDialog.cpp
index 4ddb3f0..d989304 100644
--- a/noncore/apps/opie-gutenbrowser/SearchDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/SearchDialog.cpp
@@ -85,52 +85,52 @@ QString SearchDialog::get_text() {
85bool SearchDialog::get_direction() { 85bool SearchDialog::get_direction() {
86 return false; //search forward 86 return false; //search forward
87} 87}
88 88
89bool SearchDialog::case_sensitive() { 89bool SearchDialog::case_sensitive() {
90 return true; 90 return true;
91} 91}
92 92
93bool SearchDialog::forward_search() { 93bool SearchDialog::forward_search() {
94 return true; 94 return true;
95} 95}
96 96
97void SearchDialog::byeBye() 97void SearchDialog::byeBye()
98{ 98{
99 99
100 searchString = get_text(); 100 searchString = get_text();
101// qDebug("Search string is "+searchString); 101// odebug << "Search string is "+searchString << oendl;
102 Config cfg("Gutenbrowser"); 102 Config cfg("Gutenbrowser");
103 cfg.setGroup("General"); 103 cfg.setGroup("General");
104 cfg.writeEntry("LastSearch",searchString); 104 cfg.writeEntry("LastSearch",searchString);
105 105
106 QString thisName=name(); 106 QString thisName=name();
107 if( thisName.find("Library Search", 0, TRUE) != -1) { 107 if( thisName.find("Library Search", 0, TRUE) != -1) {
108 // searchString = SearchLineEdit->text(); 108 // searchString = SearchLineEdit->text();
109 accept(); 109 accept();
110 } else { 110 } else {
111 111
112 buttonOk->setDown(TRUE); 112 buttonOk->setDown(TRUE);
113 113
114 emit search_signal(); 114 emit search_signal();
115 buttonOk->setDown(FALSE); 115 buttonOk->setDown(FALSE);
116 } 116 }
117} 117}
118 118
119void SearchDialog::closed() 119void SearchDialog::closed()
120{ 120{
121 searchString = get_text(); 121 searchString = get_text();
122// qDebug("Search string is "+searchString); 122// odebug << "Search string is "+searchString << oendl;
123 Config cfg("Gutenbrowser"); 123 Config cfg("Gutenbrowser");
124 cfg.setGroup("General"); 124 cfg.setGroup("General");
125 cfg.writeEntry("LastSearch",searchString); 125 cfg.writeEntry("LastSearch",searchString);
126 126
127 emit search_done_signal(); 127 emit search_done_signal();
128 //this->reject(); 128 //this->reject();
129 this->hide(); 129 this->hide();
130} 130}
131 131
132 132
133void SearchDialog::setLabel(QString labelText) 133void SearchDialog::setLabel(QString labelText)
134{ 134{
135 TextLabel1->setText( tr( label1Str+labelText) ); 135 TextLabel1->setText( tr( label1Str+labelText) );
136} 136}
diff --git a/noncore/apps/opie-gutenbrowser/browserDialog.cpp b/noncore/apps/opie-gutenbrowser/browserDialog.cpp
index 81dd516..cc05d04 100644
--- a/noncore/apps/opie-gutenbrowser/browserDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/browserDialog.cpp
@@ -1,28 +1,29 @@
1/**************************************************************************** 1/****************************************************************************
2copyright 2001 by L.J. Potter ljp@llornkcor.com 2copyright 2001 by L.J. Potter ljp@llornkcor.com
3 copyright : (C) 2000 -2004 by llornkcor 3 copyright : (C) 2000 -2004 by llornkcor
4 email : ljp@llornkcor.com 4 email : ljp@llornkcor.com
5 5
6****************************************************************************/ 6****************************************************************************/
7 7
8#include "optionsDialog.h" 8#include "optionsDialog.h"
9//#include "fileBrowser.h" 9//#include "fileBrowser.h"
10 10
11/* OPIE */ 11/* OPIE */
12#include <opie2/ofiledialog.h> 12#include <opie2/ofiledialog.h>
13#include <opie2/odebug.h>
13using namespace Opie::Ui; 14using namespace Opie::Ui;
14 15
15/* QT */ 16/* QT */
16#include <qlabel.h> 17#include <qlabel.h>
17#include <qlistbox.h> 18#include <qlistbox.h>
18#include <qpushbutton.h> 19#include <qpushbutton.h>
19#include <qlayout.h> 20#include <qlayout.h>
20 21
21void optionsDialog::BrowserDlg( ) 22void optionsDialog::BrowserDlg( )
22{ 23{
23// setCaption( tr( "Choose Browser" ) ); 24// setCaption( tr( "Choose Browser" ) );
24 http_ListBox1->insertItem( tr( "Opera")); 25 http_ListBox1->insertItem( tr( "Opera"));
25 http_ListBox1->insertItem( tr( "Konqueror")); 26 http_ListBox1->insertItem( tr( "Konqueror"));
26 http_ListBox1->insertItem( tr( "wget")); 27 http_ListBox1->insertItem( tr( "wget"));
27} 28}
28 29
@@ -39,48 +40,48 @@ void optionsDialog::BrowseSelected() {
39 QString fileName; 40 QString fileName;
40 Config cfg("Gutenbrowser"); 41 Config cfg("Gutenbrowser");
41 cfg. setGroup ( "View" ); 42 cfg. setGroup ( "View" );
42 QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); 43 QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir());
43 QMap<QString, QStringList> map; 44 QMap<QString, QStringList> map;
44 map.insert(tr("All"), QStringList() ); 45 map.insert(tr("All"), QStringList() );
45 QStringList text; 46 QStringList text;
46 text << "text/*"; 47 text << "text/*";
47 map.insert(tr("Text"), text ); 48 map.insert(tr("Text"), text );
48 text << "*"; 49 text << "*";
49 map.insert(tr("All"), text ); 50 map.insert(tr("All"), text );
50 51
51 QString str = OFileDialog::getOpenFileName( 2, dir , QString::null, map); 52 QString str = OFileDialog::getOpenFileName( 2, dir , QString::null, map);
52 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) { 53 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) {
53 fileName = str; 54 fileName = str;
54// QStringList fileList=browseForFiles->fileList; 55// QStringList fileList=browseForFiles->fileList;
55// qDebug(selFile); 56// odebug << selFile << oendl;
56// QStringList::ConstIterator f; 57// QStringList::ConstIterator f;
57// QString fileTemp,filer; 58// QString fileTemp,filer;
58// for ( f = fileList.begin(); f != fileList.end(); f++ ) { 59// for ( f = fileList.begin(); f != fileList.end(); f++ ) {
59 60
60// fileTemp = *f; 61// fileTemp = *f;
61// fileTemp.right( fileTemp.length()-5); 62// fileTemp.right( fileTemp.length()-5);
62// fileName = fileTemp; 63// fileName = fileTemp;
63// if( !fileName.isEmpty() ){ 64// if( !fileName.isEmpty() ){
64// filer = fileName; 65// filer = fileName;
65// } else { 66// } else {
66// QString sMsg; 67// QString sMsg;
67// sMsg = "Error opening library filelist "+fileName; 68// sMsg = "Error opening library filelist "+fileName;
68// } 69// }
69 if ( !fileName.isNull() ) { // got a file name 70 if ( !fileName.isNull() ) { // got a file name
70 // ... 71 // ...
71 } 72 }
72 } 73 }
73 74
74} 75}
75 76
76void optionsDialog::setHttp(int index) { 77void optionsDialog::setHttp(int index) {
77 Config config("Gutenbrowser"); 78 Config config("Gutenbrowser");
78 config.setGroup( "HttpServer" ); 79 config.setGroup( "HttpServer" );
79 qDebug("writing http server"); 80 odebug << "writing http server" << oendl;
80 if( index== 0) { 81 if( index== 0) {
81 config.writeEntry("Preferred", "http://sailor.gutenberg.org"); 82 config.writeEntry("Preferred", "http://sailor.gutenberg.org");
82 } else { 83 } else {
83 config.writeEntry("Preferred", "http://www.prairienet.org/pg"); 84 config.writeEntry("Preferred", "http://www.prairienet.org/pg");
84 } 85 }
85 86
86} 87}
diff --git a/noncore/apps/opie-gutenbrowser/fontDialog.cpp b/noncore/apps/opie-gutenbrowser/fontDialog.cpp
index a17b1d3..fa964a6 100644
--- a/noncore/apps/opie-gutenbrowser/fontDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/fontDialog.cpp
@@ -77,43 +77,43 @@ FontDialog::FontDialog( QWidget * parent, const char* name /*, bool modal, WFla
77 77
78} 78}
79 79
80FontDialog::~FontDialog() 80FontDialog::~FontDialog()
81{ 81{
82} 82}
83 83
84void FontDialog::familyListBoxSlot(const QString & text) 84void FontDialog::familyListBoxSlot(const QString & text)
85{ 85{
86 int styleInt = styleListBox->currentItem(); 86 int styleInt = styleListBox->currentItem();
87 int sizeInt = sizeComboBox->currentText().toInt(); 87 int sizeInt = sizeComboBox->currentText().toInt();
88 88
89 sizeComboBox->clear(); 89 sizeComboBox->clear();
90 styleListBox->clear(); 90 styleListBox->clear();
91// clearListBoxes(); 91// clearListBoxes();
92 family = text; 92 family = text;
93// qDebug(family); 93// odebug << family << oendl;
94 QStringList styles = fdb.styles( family ); // string list of styles of our current font family 94 QStringList styles = fdb.styles( family ); // string list of styles of our current font family
95 styleListBox->insertStringList( styles); 95 styleListBox->insertStringList( styles);
96 QString dstyle;// = "\t" + style + " ("; 96 QString dstyle;// = "\t" + style + " (";
97 97
98#ifdef BUGGY_SHARP_ZAURUS 98#ifdef BUGGY_SHARP_ZAURUS
99 99
100QValueList<int> smoothies = fdb.smoothSizes( family, styleListBox->text(0) ); 100QValueList<int> smoothies = fdb.smoothSizes( family, styleListBox->text(0) );
101 for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) { 101 for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) {
102 dstyle = QString::number( *points ); 102 dstyle = QString::number( *points );
103 qDebug(dstyle); 103 odebug << dstyle << oendl;
104 sizeComboBox->insertItem( dstyle.left( dstyle.length() - 1 )); 104 sizeComboBox->insertItem( dstyle.left( dstyle.length() - 1 ));
105 } 105 }
106#else 106#else
107 107
108 for (int i=0; i<nfontsizes; i++) { 108 for (int i=0; i<nfontsizes; i++) {
109 sizeComboBox->insertItem( QString::number(fontsize[i])); 109 sizeComboBox->insertItem( QString::number(fontsize[i]));
110 if(fontsize[i] == sizeInt) { 110 if(fontsize[i] == sizeInt) {
111 sizeComboBox->setCurrentItem(i); 111 sizeComboBox->setCurrentItem(i);
112 } 112 }
113 } 113 }
114#endif 114#endif
115 115
116 if(styleInt == -1 || styleInt > styleListBox->count() ) 116 if(styleInt == -1 || styleInt > styleListBox->count() )
117 styleListBox->setCurrentItem(0); 117 styleListBox->setCurrentItem(0);
118 else 118 else
119 styleListBox->setCurrentItem(styleInt); 119 styleListBox->setCurrentItem(styleInt);
@@ -138,33 +138,33 @@ void FontDialog::populateLists()
138// QFontInfo fontInfo(defaultFont); 138// QFontInfo fontInfo(defaultFont);
139 Config config("Gutenbrowser"); 139 Config config("Gutenbrowser");
140 config.setGroup("Font"); 140 config.setGroup("Font");
141 QString familyStr = config.readEntry("Family", "fixed"); 141 QString familyStr = config.readEntry("Family", "fixed");
142 QString styleStr = config.readEntry("Style", "Regular"); 142 QString styleStr = config.readEntry("Style", "Regular");
143 QString sizeStr = config.readEntry("Size", "10"); 143 QString sizeStr = config.readEntry("Size", "10");
144 QString charSetStr = config.readEntry("CharSet", "iso10646-1" ); 144 QString charSetStr = config.readEntry("CharSet", "iso10646-1" );
145 bool ok; 145 bool ok;
146 int i_size = sizeStr.toInt(&ok,10); 146 int i_size = sizeStr.toInt(&ok,10);
147 selectedFont = fdb.font(familyStr,styleStr,i_size,charSetStr); 147 selectedFont = fdb.font(familyStr,styleStr,i_size,charSetStr);
148// defaultFont.setItalic(TRUE); 148// defaultFont.setItalic(TRUE);
149 families = fdb.families(); 149 families = fdb.families();
150 150
151 for ( QStringList::Iterator f = families.begin(); f != families.end();++f ) { 151 for ( QStringList::Iterator f = families.begin(); f != families.end();++f ) {
152 QString family = *f; 152 QString family = *f;
153// if(family == defaultFont.family()) 153// if(family == defaultFont.family())
154// qDebug(family); 154// odebug << family << oendl;
155 familyListBox->insertItem( family); 155 familyListBox->insertItem( family);
156 156
157 if( familyListBox->text(0) == family) { 157 if( familyListBox->text(0) == family) {
158 QStringList styles = fdb.styles( family ); 158 QStringList styles = fdb.styles( family );
159// string list of styles of our current font family 159// string list of styles of our current font family
160 styleListBox->insertStringList( styles); 160 styleListBox->insertStringList( styles);
161 161
162 for ( QStringList::Iterator s = styles.begin(); s != styles.end();++s ) { // for each font style 162 for ( QStringList::Iterator s = styles.begin(); s != styles.end();++s ) { // for each font style
163 style = *s; 163 style = *s;
164 QString dstyle;// = "\t" + style + " ("; 164 QString dstyle;// = "\t" + style + " (";
165 if(styleListBox->text(0) == style) { 165 if(styleListBox->text(0) == style) {
166 166
167 QValueList<int> smoothies = fdb.smoothSizes( family, style ); 167 QValueList<int> smoothies = fdb.smoothSizes( family, style );
168 for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) { 168 for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) {
169 dstyle = QString::number( *points ) + " "; 169 dstyle = QString::number( *points ) + " ";
170 sizeComboBox ->insertItem( dstyle.left( dstyle.length() - 1 )); 170 sizeComboBox ->insertItem( dstyle.left( dstyle.length() - 1 ));
@@ -196,65 +196,65 @@ void FontDialog::populateLists()
196 changeText(); 196 changeText();
197} 197}
198 198
199void FontDialog::clearListBoxes() { 199void FontDialog::clearListBoxes() {
200 familyListBox->clear(); 200 familyListBox->clear();
201 sizeComboBox->clear(); 201 sizeComboBox->clear();
202 styleListBox->clear(); 202 styleListBox->clear();
203} 203}
204 204
205void FontDialog::changeText() 205void FontDialog::changeText()
206{ 206{
207 if( familyListBox->currentItem() == -1) 207 if( familyListBox->currentItem() == -1)
208 family= familyListBox->text(0); 208 family= familyListBox->text(0);
209 else { 209 else {
210 family = familyListBox->currentText(); 210 family = familyListBox->currentText();
211 } 211 }
212// qDebug("Font family is "+family); 212// odebug << "Font family is "+family << oendl;
213 if( styleListBox->currentItem() == -1) 213 if( styleListBox->currentItem() == -1)
214 style=styleListBox->text(0); 214 style=styleListBox->text(0);
215 else { 215 else {
216 style = styleListBox->currentText(); 216 style = styleListBox->currentText();
217 } 217 }
218// qDebug("font style is "+style); 218// odebug << "font style is "+style << oendl;
219 219
220 if( sizeComboBox->currentItem() == -1 ) 220 if( sizeComboBox->currentItem() == -1 )
221 size = sizeComboBox->text(0); 221 size = sizeComboBox->text(0);
222 else { 222 else {
223 size = sizeComboBox->currentText(); 223 size = sizeComboBox->currentText();
224 } 224 }
225 225
226// qDebug("Font size is "+size); 226// odebug << "Font size is "+size << oendl;
227 bool ok; 227 bool ok;
228 int i_size = size.toInt(&ok,10); 228 int i_size = size.toInt(&ok,10);
229 QStringList charSetList = fdb.charSets(family); 229 QStringList charSetList = fdb.charSets(family);
230// QStringList styles = fdb.styles( family ); // string list of styles of our current font family 230// QStringList styles = fdb.styles( family ); // string list of styles of our current font family
231 QString charSet; 231 QString charSet;
232 for ( QStringList::Iterator s = charSetList.begin(); s != charSetList.end();++s ) { // for each font style 232 for ( QStringList::Iterator s = charSetList.begin(); s != charSetList.end();++s ) { // for each font style
233 charSet = *s; 233 charSet = *s;
234// qDebug(charSet); 234// odebug << charSet << oendl;
235 } 235 }
236 selectedFont = fdb.font(family,style,i_size,charSet); 236 selectedFont = fdb.font(family,style,i_size,charSet);
237 QFontInfo fontInfo( selectedFont); 237 QFontInfo fontInfo( selectedFont);
238// if(fontInfo.italic() ) qDebug("italic"); 238// if(fontInfo.italic() ) odebug << "italic" << oendl;
239 selectedFont.setWeight(fontInfo.weight() ); 239 selectedFont.setWeight(fontInfo.weight() );
240// qDebug("Style are "+style+" %d ",fontInfo.weight()); 240// odebug << "Style are "+style+" " << fontInfo.weight() << " " << oendl;
241 Config cfg("Gutenbrowser"); 241 Config cfg("Gutenbrowser");
242 cfg.setGroup("Font"); 242 cfg.setGroup("Font");
243 cfg.writeEntry("Family",family); 243 cfg.writeEntry("Family",family);
244 cfg.writeEntry("Style",style); 244 cfg.writeEntry("Style",style);
245 cfg.writeEntry("Size",size); 245 cfg.writeEntry("Size",size);
246 cfg.writeEntry("CharSet",charSet); 246 cfg.writeEntry("CharSet",charSet);
247 247
248 if(style.find("Italic",0,TRUE) != -1) { 248 if(style.find("Italic",0,TRUE) != -1) {
249 selectedFont = fdb.font(family,"Regular",i_size,charSet); 249 selectedFont = fdb.font(family,"Regular",i_size,charSet);
250 selectedFont.setItalic(TRUE); //ya right 250 selectedFont.setItalic(TRUE); //ya right
251 cfg.writeEntry("Italic","TRUE"); 251 cfg.writeEntry("Italic","TRUE");
252// qDebug("Style is "+styleListBox->currentText()); 252// odebug << "Style is "+styleListBox->currentText() << oendl;
253 } else 253 } else
254 cfg.writeEntry("Italic","FALSE"); 254 cfg.writeEntry("Italic","FALSE");
255 255
256 MultiLineEdit1->setFont( selectedFont); 256 MultiLineEdit1->setFont( selectedFont);
257 MultiLineEdit1->update(); 257 MultiLineEdit1->update();
258 changedFonts=TRUE; 258 changedFonts=TRUE;
259} 259}
260 260
diff --git a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
index ad770b5..a9c7346 100644
--- a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
+++ b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
@@ -1,57 +1,62 @@
1/*************************************************************************** 1/***************************************************************************
2 ftpsitedlg.cpp - description 2 ftpsitedlg.cpp - description
3 ------------------- 3 -------------------
4 begin : Tue Jul 25 2000 4 begin : Tue Jul 25 2000
5 copyright : (C) 2000 -2004 by llornkcor 5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 ***************************************************************************/ 7 ***************************************************************************/
8/*************************************************************************** 8/***************************************************************************
9 * This program is free software; you can redistribute it and/or modify * 9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by * 10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or * 11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. * 12 * (at your option) any later version. *
13 ***************************************************************************/ 13 ***************************************************************************/
14
14#include "optionsDialog.h" 15#include "optionsDialog.h"
15#include "gutenbrowser.h" 16#include "gutenbrowser.h"
16//#include "NetworkDialog.h" 17//#include "NetworkDialog.h"
17#include "output.h" 18#include "output.h"
18 19
20/* OPIE */
21#include <opie2/odebug.h>
22#include <qpe/config.h>
23
24/* QT */
19#include <qprogressbar.h> 25#include <qprogressbar.h>
20#include <stdlib.h>
21#include <qurloperator.h> 26#include <qurloperator.h>
22#include <qpe/config.h>
23#include <qlistbox.h> 27#include <qlistbox.h>
24 28
29/* STD */
30#include <stdlib.h>
25#include <unistd.h> 31#include <unistd.h>
26#include <stdio.h> 32#include <stdio.h>
27#include <stdlib.h>
28 33
29// :)~ 34// :)~
30void optionsDialog::ftpSiteDlg( ) 35void optionsDialog::ftpSiteDlg( )
31{ 36{
32//printf( "ftpSiteDlg: ListFile is "+ ListFile +"\n" ); 37//printf( "ftpSiteDlg: ListFile is "+ ListFile +"\n" );
33// initDialog(); 38// initDialog();
34 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 39 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
35// ListFile = local_library + "ftpList"; 40// ListFile = local_library + "ftpList";
36 ListFile = QPEApplication::qpeDir() + "/etc/gutenbrowser"; 41 ListFile = QPEApplication::qpeDir() + "/etc/gutenbrowser";
37 QDir dir(ListFile); 42 QDir dir(ListFile);
38 if( !dir.exists()) 43 if( !dir.exists())
39 dir.mkdir(ListFile,true); 44 dir.mkdir(ListFile,true);
40 ListFile+="/ftpList"; 45 ListFile+="/ftpList";
41 qDebug("opening "+ListFile); 46 odebug << "opening "+ListFile << oendl;
42 if ( QFile(ListFile).exists() ) { 47 if ( QFile(ListFile).exists() ) {
43 openSiteList(); 48 openSiteList();
44 } else { 49 } else {
45 switch( QMessageBox::warning( this, "Gutenbrowser", 50 switch( QMessageBox::warning( this, "Gutenbrowser",
46 "Do you want to download \nan ftp site list?", 51 "Do you want to download \nan ftp site list?",
47 QMessageBox::Yes, QMessageBox::No)) { 52 QMessageBox::Yes, QMessageBox::No)) {
48 case QMessageBox::Yes: // yes 53 case QMessageBox::Yes: // yes
49 getSite(); 54 getSite();
50 break; 55 break;
51 case QMessageBox::No: // No 56 case QMessageBox::No: // No
52 // exit 57 // exit
53 break; 58 break;
54 } 59 }
55 60
56 } 61 }
57} 62}
@@ -63,70 +68,70 @@ void optionsDialog::getSite()
63{ 68{
64 QString file_name; 69 QString file_name;
65 QString ftp_listFileURL; 70 QString ftp_listFileURL;
66 QString outputFile; 71 QString outputFile;
67// outputFile = local_library+ "list.html"; 72// outputFile = local_library+ "list.html";
68 outputFile = ListFile + "list.html"; 73 outputFile = ListFile + "list.html";
69 QString networkUrl= "http://www.gutenberg.org/www/mirror.sites.html"; 74 QString networkUrl= "http://www.gutenberg.org/www/mirror.sites.html";
70//http://www.gutenberg.org/index.html"; 75//http://www.gutenberg.org/index.html";
71// QString networkUrl= "http://llornkcor.com/index.shtml"; 76// QString networkUrl= "http://llornkcor.com/index.shtml";
72// // "http://www.gutenberg.org/index.html" 77// // "http://www.gutenberg.org/index.html"
73// 78//
74//Qhttp stops working at times.... :( 79//Qhttp stops working at times.... :(
75// NetworkDialog *NetworkDlg; 80// NetworkDialog *NetworkDlg;
76// NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile); 81// NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile);
77// if( NetworkDlg->exec() != 0 ) 82// if( NetworkDlg->exec() != 0 )
78// { // use new, improved, *INSTANT* network-dialog-file-getterer 83// { // use new, improved, *INSTANT* network-dialog-file-getterer
79// qDebug("gitcha!"); 84// odebug << "gitcha!" << oendl;
80// } 85// }
81// delete NetworkDlg; 86// delete NetworkDlg;
82//#ifdef Q_WS_QWS 87//#ifdef Q_WS_QWS
83 88
84// TODO qprocess here 89// TODO qprocess here
85 90
86 QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl + " 2>&1" ; 91 QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl + " 2>&1" ;
87 qDebug("Issuing the command "+cmd); 92 odebug << "Issuing the command "+cmd << oendl;
88 Output *outDlg; 93 Output *outDlg;
89 outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE); 94 outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE);
90 outDlg->showMaximized(); 95 outDlg->showMaximized();
91 outDlg->show(); 96 outDlg->show();
92 qApp->processEvents(); 97 qApp->processEvents();
93 FILE *fp; 98 FILE *fp;
94 char line[130]; 99 char line[130];
95 outDlg->OutputEdit->append( tr("Running wget") ); 100 outDlg->OutputEdit->append( tr("Running wget") );
96 sleep(1); 101 sleep(1);
97 fp = popen( (const char *) cmd, "r"); 102 fp = popen( (const char *) cmd, "r");
98 while ( fgets( line, sizeof line, fp)) { 103 while ( fgets( line, sizeof line, fp)) {
99 outDlg->OutputEdit->append(line); 104 outDlg->OutputEdit->append(line);
100 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 105 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
101 } 106 }
102 pclose(fp); 107 pclose(fp);
103 outDlg->close(); 108 outDlg->close();
104 if(outDlg) 109 if(outDlg)
105 delete outDlg; 110 delete outDlg;
106 111
107// outputFile=ListFile; 112// outputFile=ListFile;
108 ftp_QListBox_1->clear(); 113 ftp_QListBox_1->clear();
109 parseFtpList( outputFile); // got the html list, now parse it so we can use it 114 parseFtpList( outputFile); // got the html list, now parse it so we can use it
110} 115}
111 116
112bool optionsDialog::parseFtpList( QString outputFile) 117bool optionsDialog::parseFtpList( QString outputFile)
113{ 118{
114// parse ftplist html and extract just the machine names/directories 119// parse ftplist html and extract just the machine names/directories
115// TODO: add locations!! 120// TODO: add locations!!
116 qDebug("parse ftplist "+outputFile); 121 odebug << "parse ftplist "+outputFile << oendl;
117 QString ftpList, s_location; 122 QString ftpList, s_location;
118 QFile f( outputFile ); 123 QFile f( outputFile );
119 124
120 if( f.open( IO_ReadWrite )) { 125 if( f.open( IO_ReadWrite )) {
121 QTextStream t( &f); 126 QTextStream t( &f);
122 QString countryName; 127 QString countryName;
123 bool b_gotchTest=false; 128 bool b_gotchTest=false;
124 129
125 while ( !t.eof() ) { 130 while ( !t.eof() ) {
126 QString s = t.readLine(); 131 QString s = t.readLine();
127 int start; 132 int start;
128 int end; 133 int end;
129 if( s.find( "FTP mirror sites for Project Gutenberg:", 0, TRUE) !=-1) { //lower end of this file 134 if( s.find( "FTP mirror sites for Project Gutenberg:", 0, TRUE) !=-1) { //lower end of this file
130 b_gotchTest = true; 135 b_gotchTest = true;
131 } 136 }
132 if( b_gotchTest) { 137 if( b_gotchTest) {
@@ -139,71 +144,71 @@ bool optionsDialog::parseFtpList( QString outputFile)
139 if(ftpSite.right(1) != "/") { 144 if(ftpSite.right(1) != "/") {
140 // ftpSite += "/"; 145 // ftpSite += "/";
141 } 146 }
142 ftpSite=ftpSite.right( ftpSite.length()-6); 147 ftpSite=ftpSite.right( ftpSite.length()-6);
143 if( ftpSite.find("\n", 0, TRUE) ) 148 if( ftpSite.find("\n", 0, TRUE) )
144 ftpSite.remove( ftpSite.find("\n", 0, TRUE), 1); 149 ftpSite.remove( ftpSite.find("\n", 0, TRUE), 1);
145 150
146 if( ftpSite.find("\"", 0, TRUE) ) 151 if( ftpSite.find("\"", 0, TRUE) )
147 ftpSite.remove( ftpSite.find("\"", 0, TRUE), 1); 152 ftpSite.remove( ftpSite.find("\"", 0, TRUE), 1);
148 if( ftpSite.find("a>", 0, TRUE) ) 153 if( ftpSite.find("a>", 0, TRUE) )
149 ftpSite.remove( ftpSite.find("a>", 0, TRUE) -2, 4); 154 ftpSite.remove( ftpSite.find("a>", 0, TRUE) -2, 4);
150 155
151 156
152 s = t.readLine(); 157 s = t.readLine();
153 s = t.readLine(); 158 s = t.readLine();
154 if(( start=s.find("<BR>(", 0, TRUE) ) != -1) { 159 if(( start=s.find("<BR>(", 0, TRUE) ) != -1) {
155// qDebug("%s",s.latin1()); 160// odebug << "" << s << "" << oendl;
156 end = s.find( ")", 0, TRUE)+1; 161 end = s.find( ")", 0, TRUE)+1;
157 s_location= s.mid( start+4, (end - start) ); 162 s_location= s.mid( start+4, (end - start) );
158 163
159// qDebug("%s", s_location.latin1()); 164// odebug << "" << s_location << "" << oendl;
160// ftpList += ftpSite + "\n"; 165// ftpList += ftpSite + "\n";
161// ftp_QListBox_1->sort( TRUE ); 166// ftp_QListBox_1->sort( TRUE );
162 ftpList += s_location+ " "+ftpSite+"\n"; 167 ftpList += s_location+ " "+ftpSite+"\n";
163 168
164 ftp_QListBox_1->sort( TRUE ); 169 ftp_QListBox_1->sort( TRUE );
165 QString winbug=" "; 170 QString winbug=" ";
166 ftp_QListBox_1->insertItem ( s_location.latin1() +winbug+ftpSite); 171 ftp_QListBox_1->insertItem ( s_location.latin1() +winbug+ftpSite);
167 // ftp_QListBox_1->insertItem ( ftpSite+" "+s_location.latin1()); 172 // ftp_QListBox_1->insertItem ( ftpSite+" "+s_location.latin1());
168 } 173 }
169 174
170 // ftp_QListBox_1->insertItem ( ftpSite); 175 // ftp_QListBox_1->insertItem ( ftpSite);
171 } 176 }
172 } // end find ftp:// 177 } // end find ftp://
173 178
174 } // end while loop 179 } // end while loop
175 QFile f2( ListFile); 180 QFile f2( ListFile);
176 if(!f2.open( IO_ReadWrite | IO_Truncate)) 181 if(!f2.open( IO_ReadWrite | IO_Truncate))
177 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n"+ListFile )) ); 182 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n"+ListFile )) );
178 f2.writeBlock( ftpList, ftpList.length() ); 183 f2.writeBlock( ftpList, ftpList.length() );
179 f.close(); 184 f.close();
180 f2.close(); 185 f2.close();
181 if( f.exists() ) 186 if( f.exists() )
182 f.remove(); 187 f.remove();
183 } else { 188 } else {
184 QMessageBox::message( (tr("ftpSiteDlg")), (tr("List File not opened sucessfully." )) ); 189 QMessageBox::message( (tr("ftpSiteDlg")), (tr("List File not opened sucessfully." )) );
185 return false; 190 return false;
186 } 191 }
187 setActiveWindow(); 192 setActiveWindow();
188 return true; 193 return true;
189} 194}
190 195
191void optionsDialog::openSiteList() { 196void optionsDialog::openSiteList() {
192 197
193 qDebug(" just opens the ftp site list"); 198 odebug << " just opens the ftp site list" << oendl;
194// ListFile = ( QDir::homeDirPath ()) +"/.gutenbrowser/ftpList"; 199// ListFile = ( QDir::homeDirPath ()) +"/.gutenbrowser/ftpList";
195 QFile f( ListFile); 200 QFile f( ListFile);
196 if(!f.open( IO_ReadWrite )) { 201 if(!f.open( IO_ReadWrite )) {
197 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully." )) ); 202 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully." )) );
198 } else { 203 } else {
199 QTextStream t( &f); 204 QTextStream t( &f);
200 while ( !t.atEnd() ) { 205 while ( !t.atEnd() ) {
201 QString ftpSite = t.readLine(); 206 QString ftpSite = t.readLine();
202 ftp_QListBox_1->sort( TRUE ); 207 ftp_QListBox_1->sort( TRUE );
203 ftp_QListBox_1->insertItem ( ftpSite); 208 ftp_QListBox_1->insertItem ( ftpSite);
204 209
205 } // end while loop 210 } // end while loop
206 f.close(); 211 f.close();
207 } 212 }
208 213
209 QListBoxItem *itemSel=0; 214 QListBoxItem *itemSel=0;
@@ -217,31 +222,31 @@ void optionsDialog::getSelection( QListBoxItem *item)
217{ 222{
218 QString selctionStr; 223 QString selctionStr;
219 selctionStr = item->text(); 224 selctionStr = item->text();
220// selctionStr = ftp_QListBox_1->currentText(); 225// selctionStr = ftp_QListBox_1->currentText();
221// printf( selctionStr+"\n" ); 226// printf( selctionStr+"\n" );
222 select_site( selctionStr ); 227 select_site( selctionStr );
223} 228}
224 229
225void optionsDialog::select_site( const char *index ) 230void optionsDialog::select_site( const char *index )
226{ 231{
227// ftp://ftp.datacanyon.com/pub/gutenberg/ 232// ftp://ftp.datacanyon.com/pub/gutenberg/
228 233
229 s_site = index; 234 s_site = index;
230 QString s_site2; 235 QString s_site2;
231// if(s_site.find("(",0,TRUE)) 236// if(s_site.find("(",0,TRUE))
232 s_site2=s_site.right( s_site.length()-(s_site.find(" ",0,TRUE)+4) ); 237 s_site2=s_site.right( s_site.length()-(s_site.find(" ",0,TRUE)+4) );
233qDebug("Selected ftp site is "+ s_site2); 238odebug << "Selected ftp site is "+ s_site2 << oendl;
234 int i_ftp = s_site2.find("/", 0, FALSE); 239 int i_ftp = s_site2.find("/", 0, FALSE);
235 ftp_host = s_site2.left(i_ftp ); 240 ftp_host = s_site2.left(i_ftp );
236 ftp_base_dir = s_site2.right( s_site2.length() - i_ftp); 241 ftp_base_dir = s_site2.right( s_site2.length() - i_ftp);
237 242
238// config->read(); 243// config->read();
239 Config config("Gutenbrowser"); 244 Config config("Gutenbrowser");
240 config.setGroup( "FTPsite" ); 245 config.setGroup( "FTPsite" );
241 config.writeEntry("SiteName",ftp_host); 246 config.writeEntry("SiteName",ftp_host);
242 config.writeEntry("base",ftp_base_dir); 247 config.writeEntry("base",ftp_base_dir);
243// config->write(); 248// config->write();
244 TextLabel3->setText( "Current ftp server:\n"+ftp_host /*+ ftp_base_dir*/ ); 249 TextLabel3->setText( "Current ftp server:\n"+ftp_host /*+ ftp_base_dir*/ );
245// optionsDialog::accept(); 250// optionsDialog::accept();
246} 251}
247 252
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
index 2a9a71e..be2b897 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
@@ -1,1984 +1,1989 @@
1/*************************************************************************** 1/***************************************************************************
2 gutenbrowser.cpp - description 2 gutenbrowser.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Jul 24 22:33:12 MDT 2000 4 begin : Mon Jul 24 22:33:12 MDT 2000
5 copyright : (C) 2000 -2004 by llornkcor 5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7* This program is free software; you can redistribute it and/or modify * 7* This program is free software; you can redistribute it and/or modify *
8* it under the terms of the GNU General Public License as published by * 8* it under the terms of the GNU General Public License as published by *
9* the Free Software Foundation; either version 2 of the License, or * 9* the Free Software Foundation; either version 2 of the License, or *
10* (at your option) any later version. * 10* (at your option) any later version. *
11***************************************************************************/ 11***************************************************************************/
12// http search 12// http search
13// http://digital.library.upenn.edu/books/authors.html 13// http://digital.library.upenn.edu/books/authors.html
14// http://digital.library.upenn.edu/books/titles.html 14// http://digital.library.upenn.edu/books/titles.html
15// ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL 15// ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL
16// donate@gutenberg.net 16// donate@gutenberg.net
17#include <qpe/qpeapplication.h> 17
18#include <qpe/fontdatabase.h>
19#include <qpe/config.h>
20#include <qpe/qcopenvelope_qws.h>
21#include <qpe/mimetype.h>
22#include <qpe/resource.h>
23#include <qpe/applnk.h>
24 18
25#include "editTitle.h" 19#include "editTitle.h"
26#include "gutenbrowser.h" 20#include "gutenbrowser.h"
27#include "LibraryDialog.h" 21#include "LibraryDialog.h"
28 //#include "bookmarksdlg.h" 22 //#include "bookmarksdlg.h"
29#include "optionsDialog.h" 23#include "optionsDialog.h"
30#include "helpme.h" 24#include "helpme.h"
31#include "NetworkDialog.h" 25#include "NetworkDialog.h"
32 26
33#include "openetext.h" 27#include "openetext.h"
34#include "output.h" 28#include "output.h"
35 29
30/* OPIE */
31#include <opie2/odebug.h>
32#include <qpe/qpeapplication.h>
33#include <qpe/fontdatabase.h>
34#include <qpe/config.h>
35#include <qpe/qcopenvelope_qws.h>
36#include <qpe/mimetype.h>
37#include <qpe/resource.h>
38#include <qpe/applnk.h>
36 39
40/* QT */
37#include <qregexp.h> 41#include <qregexp.h>
38#include <qregion.h> 42#include <qregion.h>
39#include <qpaintdevicemetrics.h> 43#include <qpaintdevicemetrics.h>
40#include <qvaluelist.h> 44#include <qvaluelist.h>
41#include <qlabel.h> 45#include <qlabel.h>
42#include <qclipboard.h> 46#include <qclipboard.h>
43#include <qpainter.h> 47#include <qpainter.h>
44#include <qpalette.h> 48#include <qpalette.h>
45#include <qobjectlist.h> 49#include <qobjectlist.h>
46#include <qfontdialog.h> 50#include <qfontdialog.h>
47#include <qtextview.h> 51#include <qtextview.h>
48#include <qbrush.h> 52#include <qbrush.h>
49#include <qfile.h> 53#include <qfile.h>
50#include <qfontinfo.h> 54#include <qfontinfo.h>
51#include <qscrollview.h> 55#include <qscrollview.h>
52#include <qpoint.h> 56#include <qpoint.h>
53 57
58/* STD */
54#include <stdio.h> 59#include <stdio.h>
55#include <stdlib.h> 60#include <stdlib.h>
56#include <unistd.h> 61#include <unistd.h>
57#include <sys/stat.h> 62#include <sys/stat.h>
58#include <fcntl.h> 63#include <fcntl.h>
59#include <errno.h> 64#include <errno.h>
60 65
61static const int nfontsizes = 9; 66static const int nfontsizes = 9;
62static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; 67static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24};
63 68
64#ifdef NOQUICKLAUNCH 69#ifdef NOQUICKLAUNCH
65Gutenbrowser::Gutenbrowser() 70Gutenbrowser::Gutenbrowser()
66 Gutenbrowser(); 71 Gutenbrowser();
67#else 72#else
68Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) 73Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
69#endif 74#endif
70 : QMainWindow() 75 : QMainWindow()
71 { 76 {
72 // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 77 // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
73 // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); 78 // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" );
74 // e << ""; 79 // e << "";
75 // QPEApplication::grabKeyboard(); 80 // QPEApplication::grabKeyboard();
76 showMainList=TRUE; 81 showMainList=TRUE;
77 working=false; 82 working=false;
78 this->setUpdatesEnabled(TRUE); 83 this->setUpdatesEnabled(TRUE);
79 // #ifndef Q_WS_QWS 84 // #ifndef Q_WS_QWS
80 QString msg; 85 QString msg;
81 msg="You have now entered unto gutenbrowser,\n"; 86 msg="You have now entered unto gutenbrowser,\n";
82 msg+="make your self at home, sit back, relax and read something great.\n"; 87 msg+="make your self at home, sit back, relax and read something great.\n";
83 88
84 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 89 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
85 setCaption("Gutenbrowser");// Embedded " VERSION); 90 setCaption("Gutenbrowser");// Embedded " VERSION);
86 this->setUpdatesEnabled(TRUE); 91 this->setUpdatesEnabled(TRUE);
87 92
88 // bool firstTime=FALSE; 93 // bool firstTime=FALSE;
89 topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); 94 topLayout = new QVBoxLayout( this, 0, 0, "topLayout");
90 95
91 menu = new QHBoxLayout(-1,"menu"); 96 menu = new QHBoxLayout(-1,"menu");
92 buttons2 = new QHBoxLayout(-1,"buttons2"); 97 buttons2 = new QHBoxLayout(-1,"buttons2");
93 edits = new QHBoxLayout(-1,"edits"); 98 edits = new QHBoxLayout(-1,"edits");
94 99
95 useSplitter=TRUE; 100 useSplitter=TRUE;
96 101
97 initConfig(); 102 initConfig();
98 initMenuBar(); 103 initMenuBar();
99 initButtonBar(); 104 initButtonBar();
100 initStatusBar(); 105 initStatusBar();
101 initView(); 106 initView();
102 initSlots(); 107 initSlots();
103 108
104 QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); 109 QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold);
105 110
106 connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), 111 connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)),
107 this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); 112 this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) );
108 if( useIcons) 113 if( useIcons)
109 toggleButtonIcons( TRUE); 114 toggleButtonIcons( TRUE);
110 else 115 else
111 toggleButtonIcons( FALSE); 116 toggleButtonIcons( FALSE);
112 117
113 enableButtons(false); 118 enableButtons(false);
114 119
115 Config config("Gutenbrowser"); // populate menubuttonlist 120 Config config("Gutenbrowser"); // populate menubuttonlist
116 config.setGroup("General"); 121 config.setGroup("General");
117 122
118 config.setGroup( "Files" ); 123 config.setGroup( "Files" );
119 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 124 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
120 int i_numofFiles = s_numofFiles.toInt(); 125 int i_numofFiles = s_numofFiles.toInt();
121 126
122 QString tempFileName; 127 QString tempFileName;
123 128
124 for (int i = 0; i <= i_numofFiles; i++) { 129 for (int i = 0; i <= i_numofFiles; i++) {
125 // tempFileName.setNum(i); 130 // tempFileName.setNum(i);
126 config.setGroup( "Files" ); 131 config.setGroup( "Files" );
127 QString ramble = config.readEntry( QString::number(i), "" ); 132 QString ramble = config.readEntry( QString::number(i), "" );
128 133
129 config.setGroup( "Titles" ); 134 config.setGroup( "Titles" );
130 QString tempTitle = config.readEntry( ramble, ""); 135 QString tempTitle = config.readEntry( ramble, "");
131 config.setGroup( tempTitle); 136 config.setGroup( tempTitle);
132 int index=config.readNumEntry( "LineNumber", -1 ); 137 int index=config.readNumEntry( "LineNumber", -1 );
133 if( index != -1) { 138 if( index != -1) {
134 // qDebug( tempTitle); 139 // odebug << tempTitle << oendl;
135 bookmarksMenu->insertItem( tempTitle); 140 bookmarksMenu->insertItem( tempTitle);
136 } 141 }
137 } 142 }
138 143
139 // QString gutenIndex= local_library + "GUTINDEX.ALL"; 144 // QString gutenIndex= local_library + "GUTINDEX.ALL";
140 QString gutenIndex= QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL"; 145 QString gutenIndex= QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL";
141 146
142 if( QFile( gutenIndex).exists() ) { 147 if( QFile( gutenIndex).exists() ) {
143 indexLib.setName( gutenIndex); 148 indexLib.setName( gutenIndex);
144 } else { 149 } else {
145 QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT"; 150 QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT";
146 // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; 151 // QString localLibIndexFile= local_library + "PGWHOLE.TXT";
147 newindexLib.setName( localLibIndexFile); 152 newindexLib.setName( localLibIndexFile);
148 } 153 }
149 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); 154 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */);
150 loadCheck=false; 155 loadCheck=false;
151 chdir(local_library); 156 chdir(local_library);
152 if(!showMainList) { 157 if(!showMainList) {
153 Lview->setFocus(); 158 Lview->setFocus();
154 // if(firstTime) 159 // if(firstTime)
155 // Bookmark(); 160 // Bookmark();
156 for (int i=1;i< qApp->argc();i++) { 161 for (int i=1;i< qApp->argc();i++) {
157 qDebug("Suppose we open somethin"); 162 odebug << "Suppose we open somethin" << oendl;
158 load(qApp->argv()[i]); 163 load(qApp->argv()[i]);
159 } 164 }
160 } else { 165 } else {
161 fillWithTitles(); 166 fillWithTitles();
162 mainList->setFocus(); 167 mainList->setFocus();
163 // mainList->setCurrentItem(0); 168 // mainList->setCurrentItem(0);
164 169
165 } 170 }
166 writeConfig(); 171 writeConfig();
167} //end init 172} //end init
168 173
169Gutenbrowser::~Gutenbrowser() { 174Gutenbrowser::~Gutenbrowser() {
170 // QPEApplication::grabKeyboard(); 175 // QPEApplication::grabKeyboard();
171 // QPEApplication::ungrabKeyboard(); 176 // QPEApplication::ungrabKeyboard();
172 qDebug("Exit"); 177 odebug << "Exit" << oendl;
173} 178}
174 179
175 /* 180 /*
176 Google.com search */ 181 Google.com search */
177void Gutenbrowser::InfoBarClick() { 182void Gutenbrowser::InfoBarClick() {
178 QString text; 183 QString text;
179 if( Lview->hasSelectedText()) { 184 if( Lview->hasSelectedText()) {
180 Lview->copy(); 185 Lview->copy();
181 QClipboard *cb = QApplication::clipboard(); 186 QClipboard *cb = QApplication::clipboard();
182 text = cb->text(); 187 text = cb->text();
183 } else { 188 } else {
184 // text=title; 189 // text=title;
185 text=this->caption(); 190 text=this->caption();
186 } 191 }
187 searchGoogle(text); 192 searchGoogle(text);
188} 193}
189 194
190 /* 195 /*
191 download http with wget or preferred browser */ 196 download http with wget or preferred browser */
192void Gutenbrowser::goGetit( const QString &url, bool showMsg) { 197void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
193 // int eexit=0; 198 // int eexit=0;
194 QString cmd; 199 QString cmd;
195 // config.read(); 200 // config.read();
196 qApp->processEvents(); 201 qApp->processEvents();
197 QString filename = QPEApplication::qpeDir(); 202 QString filename = QPEApplication::qpeDir();
198 if(filename.right(1)!="/") 203 if(filename.right(1)!="/")
199 filename+="/etc/gutenbrowser/"; 204 filename+="/etc/gutenbrowser/";
200 else 205 else
201 filename+="etc/gutenbrowser/"; 206 filename+="etc/gutenbrowser/";
202 qDebug("filename "+filename); 207 odebug << "filename "+filename << oendl;
203 // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; 208 // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/";
204 209
205 filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); 210 filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1);
206 211
207 Config config("Gutenbrowser"); 212 Config config("Gutenbrowser");
208 config.setGroup( "Browser" ); 213 config.setGroup( "Browser" );
209 QString brow = config.readEntry("Preferred", "Opera"); 214 QString brow = config.readEntry("Preferred", "Opera");
210 qDebug("Preferred browser is "+brow); 215 odebug << "Preferred browser is "+brow << oendl;
211 if(!showMsg) { //if we just get the gutenindex.all 216 if(!showMsg) { //if we just get the gutenindex.all
212 cmd="wget -O " + filename +" " + url+" 2>&1" ; 217 cmd="wget -O " + filename +" " + url+" 2>&1" ;
213 chdir(local_library); 218 chdir(local_library);
214 qDebug("Issuing the system command: %s", cmd.latin1()); 219 odebug << "Issuing the system command: " << cmd << "" << oendl;
215 220
216 Output *outDlg; 221 Output *outDlg;
217 outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); 222 outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE);
218 outDlg->showMaximized(); 223 outDlg->showMaximized();
219 outDlg->show(); 224 outDlg->show();
220 qApp->processEvents(); 225 qApp->processEvents();
221 FILE *fp; 226 FILE *fp;
222 char line[130]; 227 char line[130];
223 outDlg->OutputEdit->append( tr("Running wget") ); 228 outDlg->OutputEdit->append( tr("Running wget") );
224 sleep(1); 229 sleep(1);
225 fp = popen( (const char *) cmd, "r"); 230 fp = popen( (const char *) cmd, "r");
226 // qDebug("Issuing the command\n"+cmd); 231 // odebug << "Issuing the command\n"+cmd << oendl;
227 // system(cmd); 232 // system(cmd);
228 while ( fgets( line, sizeof line, fp)) { 233 while ( fgets( line, sizeof line, fp)) {
229 outDlg->OutputEdit->append(line); 234 outDlg->OutputEdit->append(line);
230 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 235 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
231 } 236 }
232 pclose(fp); 237 pclose(fp);
233 outDlg->close(); 238 outDlg->close();
234 if(outDlg) 239 if(outDlg)
235 delete outDlg; 240 delete outDlg;
236 } else { 241 } else {
237 if( brow == "Konq") { 242 if( brow == "Konq") {
238 cmd = "konqueror "+url+" &"; 243 cmd = "konqueror "+url+" &";
239 } 244 }
240 if( brow == "Opera") { //for desktop testing 245 if( brow == "Opera") { //for desktop testing
241 cmd = "opera "+url+" &"; 246 cmd = "opera "+url+" &";
242 } 247 }
243 // if( brow == "Opera") { // on Zaurus 248 // if( brow == "Opera") { // on Zaurus
244 // cmd = "operagui "+url+" &"; 249 // cmd = "operagui "+url+" &";
245 // } 250 // }
246 if( brow == "Mozilla") { 251 if( brow == "Mozilla") {
247 cmd = "mozilla "+url+" &"; 252 cmd = "mozilla "+url+" &";
248 } 253 }
249 if( brow == "Netscape") { 254 if( brow == "Netscape") {
250 cmd = "netscape "+url+" &"; 255 cmd = "netscape "+url+" &";
251 } 256 }
252 if(brow == "wget") { 257 if(brow == "wget") {
253 // cmd="wget -q "+url+" &"; 258 // cmd="wget -q "+url+" &";
254 QString tempHtml=local_library+"webster.html"; 259 QString tempHtml=local_library+"webster.html";
255 cmd="wget -O "+tempHtml+" -q "+url; 260 cmd="wget -O "+tempHtml+" -q "+url;
256 } 261 }
257 262
258 chdir(local_library); 263 chdir(local_library);
259 qDebug("Issuing the sys command: %s", cmd.latin1()); 264 odebug << "Issuing the sys command: " << cmd << "" << oendl;
260 system(cmd); 265 system(cmd);
261 } 266 }
262} 267}
263 268
264void Gutenbrowser::toggleButtonIcons( bool useEm) { 269void Gutenbrowser::toggleButtonIcons( bool useEm) {
265 QString pixDir; 270 QString pixDir;
266 if(useEm) 271 if(useEm)
267 useEm=TRUE; 272 useEm=TRUE;
268 pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; 273 pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser";
269 qDebug("Docdir is "+QPEApplication::documentDir()); 274 odebug << "Docdir is "+QPEApplication::documentDir() << oendl;
270 275
271 if( useIcons && QDir( pixDir).exists() ) { 276 if( useIcons && QDir( pixDir).exists() ) {
272 LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline 277 LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline
273 OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook")); 278 OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook"));
274 ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline 279 ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline
275 BackButton->setPixmap( Resource::loadPixmap("back") );//in inline 280 BackButton->setPixmap( Resource::loadPixmap("back") );//in inline
276 SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline 281 SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline
277 lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder")); 282 lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder"));
278 setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") ); 283 setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") );
279 dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") ); 284 dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") );
280 InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google")); 285 InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google"));
281 } 286 }
282} 287}
283 288
284 289
285bool Gutenbrowser::queryExit() 290bool Gutenbrowser::queryExit()
286{ 291{
287 int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?", 292 int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?",
288 QMessageBox::Ok, QMessageBox::Cancel); 293 QMessageBox::Ok, QMessageBox::Cancel);
289 if (exit==1) { 294 if (exit==1) {
290 writeConfig(); 295 writeConfig();
291 qApp->quit(); 296 qApp->quit();
292 } else { 297 } else {
293 }; 298 };
294 return (exit==1); 299 return (exit==1);
295} 300}
296 301
297 // SLOT IMPLEMENTATION 302 // SLOT IMPLEMENTATION
298 303
299void Gutenbrowser::slotFilePrint() { 304void Gutenbrowser::slotFilePrint() {
300} 305}
301 306
302void Gutenbrowser::ByeBye() { 307void Gutenbrowser::ByeBye() {
303 if (b_queryExit) 308 if (b_queryExit)
304 queryExit(); 309 queryExit();
305 else { 310 else {
306 // writeConfig(); 311 // writeConfig();
307 qApp->quit(); 312 qApp->quit();
308 } 313 }
309} 314}
310 315
311void Gutenbrowser::HelpBtn() { 316void Gutenbrowser::HelpBtn() {
312 HelpMe* HelpDlg; 317 HelpMe* HelpDlg;
313 HelpDlg = new HelpMe( this, "Help Dialog"); 318 HelpDlg = new HelpMe( this, "Help Dialog");
314 HelpDlg->showMaximized(); 319 HelpDlg->showMaximized();
315} 320}
316 321
317void Gutenbrowser::DownloadIndex() { 322void Gutenbrowser::DownloadIndex() {
318#ifndef Q_WS_QWS 323#ifndef Q_WS_QWS
319 { 324 {
320 switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")), 325 switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")),
321 (tr("Do you want to download the newest\n" 326 (tr("Do you want to download the newest\n"
322 "Project Gutenberg Library Index?\n" 327 "Project Gutenberg Library Index?\n"
323 "or select an ftp site?\n")), 328 "or select an ftp site?\n")),
324 (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) ) 329 (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) )
325 { 330 {
326 case 0: // index clicked, 331 case 0: // index clicked,
327 downloadLibIndex(); 332 downloadLibIndex();
328 break; 333 break;
329 334
330 case 1: // ftp selected 335 case 1: // ftp selected
331 downloadFtpList(); 336 downloadFtpList();
332 break; 337 break;
333 338
334 case 2: // Cancel 339 case 2: // Cancel
335 break; 340 break;
336 }; 341 };
337 } 342 }
338#endif 343#endif
339} // end DownloadIndex 344} // end DownloadIndex
340 345
341 346
342void Gutenbrowser::downloadFtpList() { 347void Gutenbrowser::downloadFtpList() {
343 // QString cmd="wget http://www.promo.net/pg/list.html"); 348 // QString cmd="wget http://www.promo.net/pg/list.html");
344 //system(cmd); 349 //system(cmd);
345 qApp->processEvents(); 350 qApp->processEvents();
346 optionsDialog* optDlg; 351 optionsDialog* optDlg;
347 optDlg = new optionsDialog( this,"Options_Dlg", true); 352 optDlg = new optionsDialog( this,"Options_Dlg", true);
348 optDlg->getSite(); 353 optDlg->getSite();
349 if(optDlg) 354 if(optDlg)
350 delete optDlg; 355 delete optDlg;
351} 356}
352 357
353 358
354void Gutenbrowser::downloadLibIndex() { 359void Gutenbrowser::downloadLibIndex() {
355 // QString dwmloader = local_library + "pgwhole.zip"; 360 // QString dwmloader = local_library + "pgwhole.zip";
356 // QString cmd = "lynx -source http://www.gutenberg.net/pgwhole.zip | cat >> " + dwmloader; 361 // QString cmd = "lynx -source http://www.gutenberg.net/pgwhole.zip | cat >> " + dwmloader;
357 // system(cmd); 362 // system(cmd);
358 363
359 // QString outputFile= local_library+ "GUTINDEX.ALL"; 364 // QString outputFile= local_library+ "GUTINDEX.ALL";
360 // config.setGroup( "FTPsite" ); // ftp server config 365 // config.setGroup( "FTPsite" ); // ftp server config
361 // ftp_host=config.readEntry("SiteName", ""); 366 // ftp_host=config.readEntry("SiteName", "");
362 // ftp_base_dir= config.readEntry("base", ""); 367 // ftp_base_dir= config.readEntry("base", "");
363 // QString networkUrl= "ftp://"+ftp_host+ftp_base_dir+"/GUTINDEX.ALL"; 368 // QString networkUrl= "ftp://"+ftp_host+ftp_base_dir+"/GUTINDEX.ALL";
364 QDir dir( local_library); 369 QDir dir( local_library);
365 dir.cd("", TRUE); 370 dir.cd("", TRUE);
366 goGetit( "http://sailor.gutenberg.org/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3 371 goGetit( "http://sailor.gutenberg.org/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3
367 // goGetit( "http://www.gutenberg.net/pgwhole.zip", true); // until ghttp works on binaries -qt3 372 // goGetit( "http://www.gutenberg.net/pgwhole.zip", true); // until ghttp works on binaries -qt3
368 // NetworkDialog *NetworkDlg; 373 // NetworkDialog *NetworkDlg;
369 // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, outputFile ); 374 // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, outputFile );
370 // if( NetworkDlg->exec() != 0 ) 375 // if( NetworkDlg->exec() != 0 )
371 // { // use new, improved, *INSTANT* network-dialog-file-getterer 376 // { // use new, improved, *INSTANT* network-dialog-file-getterer
372 //// QMessageBox::message("Note",""); 377 //// QMessageBox::message("Note","");
373 // } 378 // }
374 // if(NetworkDlg) 379 // if(NetworkDlg)
375 // delete NetworkDlg; 380 // delete NetworkDlg;
376} 381}
377 382
378 383
379void Gutenbrowser::PrintBtn() { 384void Gutenbrowser::PrintBtn() {
380} 385}
381 386
382void Gutenbrowser::SearchBtn() { 387void Gutenbrowser::SearchBtn() {
383 if( loadCheck) { 388 if( loadCheck) {
384 qDebug("loadCheck: we have a loaded doc"); 389 odebug << "loadCheck: we have a loaded doc" << oendl;
385 Search(); 390 Search();
386 } 391 }
387 // else 392 // else
388 // QMessageBox::message("Note","Sorry, can't search. No etext is loaded"); 393 // QMessageBox::message("Note","Sorry, can't search. No etext is loaded");
389} 394}
390 395
391 396
392void Gutenbrowser::ForwardBtn() { 397void Gutenbrowser::ForwardBtn() {
393 398
394 if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) { 399 if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) {
395 400
396 QString s; 401 QString s;
397 QString insertString; 402 QString insertString;
398 int pageSize= Lview->PageSize(); 403 int pageSize= Lview->PageSize();
399 Lview->clear(); 404 Lview->clear();
400 405
401 for(int fd=0; fd < pageSize - 1;fd++) { 406 for(int fd=0; fd < pageSize - 1;fd++) {
402 f.readLine(s, 256); 407 f.readLine(s, 256);
403 if(useWrap) 408 if(useWrap)
404 s.replace(QRegExp("\n"),""); 409 s.replace(QRegExp("\n"),"");
405 insertString+=s; 410 insertString+=s;
406 Lview->insertLine( s, -1); 411 Lview->insertLine( s, -1);
407 // qDebug(s); 412 // odebug << s << oendl;
408 currentLine++; 413 currentLine++;
409 } 414 }
410 // Lview->insertAt( insertString,0,0, FALSE); 415 // Lview->insertAt( insertString,0,0, FALSE);
411 currentFilePos = f.at(); 416 currentFilePos = f.at();
412 // if( i_pageNum != pages) { 417 // if( i_pageNum != pages) {
413 // Lview->MultiLine_Ex::pageDown( FALSE); 418 // Lview->MultiLine_Ex::pageDown( FALSE);
414 i_pageNum++; 419 i_pageNum++;
415 pageStopArray.resize(i_pageNum + 1); 420 pageStopArray.resize(i_pageNum + 1);
416 // int length = Lview->length(); 421 // int length = Lview->length();
417 422
418 pageStopArray[i_pageNum ] = currentFilePos; 423 pageStopArray[i_pageNum ] = currentFilePos;
419 // qDebug("%d current page is number %d, pagesize %d, length %d, current %d", 424 // qDebug("%d current page is number %d, pagesize %d, length %d, current %d",
420 // currentFilePos, i_pageNum, pageSize, Lview->length(), pageStopArray[i_pageNum] ); 425 // currentFilePos, i_pageNum, pageSize, Lview->length(), pageStopArray[i_pageNum] );
421 setStatus(); 426 setStatus();
422 Lview->setCursorPosition( 0, 0, FALSE); 427 Lview->setCursorPosition( 0, 0, FALSE);
423 // } 428 // }
424 429
425 } else { 430 } else {
426 // qDebug("bal"); 431 // odebug << "bal" << oendl;
427 // if( i_pageNum != pages) { 432 // if( i_pageNum != pages) {
428 433
429 // // int newTop = Lview->Top(); 434 // // int newTop = Lview->Top();
430 // // if(Lview->lastRow() > i) 435 // // if(Lview->lastRow() > i)
431 // Lview->ScrollUp(1); 436 // Lview->ScrollUp(1);
432 // // i_pageNum++; 437 // // i_pageNum++;
433 // setStatus(); 438 // setStatus();
434 // Lview->setCursorPosition( Lview->Top(), 0, FALSE); 439 // Lview->setCursorPosition( Lview->Top(), 0, FALSE);
435 440
436 // } 441 // }
437 442
438 } 443 }
439 Lview->setFocus(); 444 Lview->setFocus();
440 445
441 // qDebug("page number %d line number %d", i_pageNum, currentLine); 446 // odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl;
442} 447}
443 448
444 449
445void Gutenbrowser::BackBtn() { 450void Gutenbrowser::BackBtn() {
446 if( i_pageNum > 0) { 451 if( i_pageNum > 0) {
447 int pageSize= Lview->PageSize(); 452 int pageSize= Lview->PageSize();
448 // int length=Lview->length(); 453 // int length=Lview->length();
449 454
450 i_pageNum--; 455 i_pageNum--;
451 currentFilePos = f.at(); 456 currentFilePos = f.at();
452 457
453 // qDebug("%d move back to %d, current page number %d, %d, length %d", 458 // qDebug("%d move back to %d, current page number %d, %d, length %d",
454 // currentFilePos, pageStopArray[i_pageNum - 1 ], i_pageNum, pageSize, Lview->length() ); 459 // currentFilePos, pageStopArray[i_pageNum - 1 ], i_pageNum, pageSize, Lview->length() );
455 460
456 if( i_pageNum < 2) { 461 if( i_pageNum < 2) {
457 f.at( 0); 462 f.at( 0);
458 } else { 463 } else {
459 if(!f.at( pageStopArray[i_pageNum - 1] )) 464 if(!f.at( pageStopArray[i_pageNum - 1] ))
460 qDebug("File positioned backward did not work"); 465 odebug << "File positioned backward did not work" << oendl;
461 } 466 }
462 QString s; 467 QString s;
463 // int sizeLine=0; 468 // int sizeLine=0;
464 Lview->clear(); 469 Lview->clear();
465 // QString insertString; 470 // QString insertString;
466 471
467 for(int fd = 0; fd < pageSize ;fd++) { 472 for(int fd = 0; fd < pageSize ;fd++) {
468 // Lview->removeLine( Lview->PageSize() ); 473 // Lview->removeLine( Lview->PageSize() );
469 f.readLine(s, 256); 474 f.readLine(s, 256);
470 if(useWrap) 475 if(useWrap)
471 s.replace(QRegExp("\n"),""); 476 s.replace(QRegExp("\n"),"");
472 currentLine++; 477 currentLine++;
473 // insertString+=s; 478 // insertString+=s;
474 Lview->insertLine( s, -1); 479 Lview->insertLine( s, -1);
475 } 480 }
476 481
477 // Lview->insertAt( insertString,0,0, FALSE); 482 // Lview->insertAt( insertString,0,0, FALSE);
478 483
479 if( !BackButton->autoRepeat() && !BackButton->isDown()) { 484 if( !BackButton->autoRepeat() && !BackButton->isDown()) {
480 QString topR; 485 QString topR;
481 QString lastR; 486 QString lastR;
482 QString pageR; 487 QString pageR;
483 // int sizer = Lview->lastRow() - Lview->topRow(); 488 // int sizer = Lview->lastRow() - Lview->topRow();
484 // int i_topRow = Lview->topRow(); 489 // int i_topRow = Lview->topRow();
485 if( i_pageNum < 1) 490 if( i_pageNum < 1)
486 i_pageNum = 1; 491 i_pageNum = 1;
487 setCaption(QString::number(i_pageNum)); 492 setCaption(QString::number(i_pageNum));
488 } else { 493 } else {
489 // int newTop = Lview->Top(); 494 // int newTop = Lview->Top();
490 // if(Lview->lastRow() > i) 495 // if(Lview->lastRow() > i)
491 Lview->MultiLine_Ex::pageUp( FALSE); 496 Lview->MultiLine_Ex::pageUp( FALSE);
492 // Lview->ScrollDown(1); 497 // Lview->ScrollDown(1);
493 // i_pageNum--; 498 // i_pageNum--;
494 if( i_pageNum < 1) 499 if( i_pageNum < 1)
495 i_pageNum = 1; 500 i_pageNum = 1;
496 setStatus(); 501 setStatus();
497 Lview->setCursorPosition( Lview->Top(), 0, FALSE); 502 Lview->setCursorPosition( Lview->Top(), 0, FALSE);
498 503
499 } 504 }
500 } 505 }
501 Lview->setFocus(); 506 Lview->setFocus();
502} 507}
503 508
504void Gutenbrowser::doBeginBtn() { 509void Gutenbrowser::doBeginBtn() {
505 if(loadCheck) { 510 if(loadCheck) {
506 qApp->processEvents(); 511 qApp->processEvents();
507 BeginBtn(); 512 BeginBtn();
508 } 513 }
509} 514}
510 515
511 // moves text to the very top = 0 516 // moves text to the very top = 0
512void Gutenbrowser::TopBtn() { 517void Gutenbrowser::TopBtn() {
513 518
514 if(loadCheck) { 519 if(loadCheck) {
515 if( i_pageNum != 0) { 520 if( i_pageNum != 0) {
516 qDebug("top"); 521 odebug << "top" << oendl;
517 qApp->processEvents(); 522 qApp->processEvents();
518 currentLine = 0; 523 currentLine = 0;
519 i_pageNum = 1; 524 i_pageNum = 1;
520 int pageSize = Lview->PageSize() ; 525 int pageSize = Lview->PageSize() ;
521 Lview->clear(); 526 Lview->clear();
522 QString s; 527 QString s;
523 f.at(0); 528 f.at(0);
524 for(int fd=0; fd < pageSize ;fd++) { 529 for(int fd=0; fd < pageSize ;fd++) {
525 f.readLine(s, 256); 530 f.readLine(s, 256);
526 if(useWrap) 531 if(useWrap)
527 s.replace(QRegExp("\n"),""); 532 s.replace(QRegExp("\n"),"");
528 Lview->insertLine(s ,-1); 533 Lview->insertLine(s ,-1);
529 currentLine++; 534 currentLine++;
530 } 535 }
531 Lview->setCursorPosition( 0,0, FALSE); 536 Lview->setCursorPosition( 0,0, FALSE);
532 i_pageNum=1; 537 i_pageNum=1;
533 setStatus(); 538 setStatus();
534 } 539 }
535 Lview->setFocus(); 540 Lview->setFocus();
536 } 541 }
537} 542}
538 543
539 //moves text to the start of the EText 544 //moves text to the start of the EText
540void Gutenbrowser::BeginBtn() { 545void Gutenbrowser::BeginBtn() {
541 i_pageNum = 1; 546 i_pageNum = 1;
542 currentLine = 0; 547 currentLine = 0;
543 QString s_pattern="*END*THE SMALL PRINT"; 548 QString s_pattern="*END*THE SMALL PRINT";
544 QString sPattern2 = "*END THE SMALL PRINT"; 549 QString sPattern2 = "*END THE SMALL PRINT";
545 550
546 int pageSize = Lview->PageSize(); 551 int pageSize = Lview->PageSize();
547 Lview->clear(); 552 Lview->clear();
548 553
549 // int lines = Lview->numLines(); 554 // int lines = Lview->numLines();
550 int pos = 0;//, i = 0; 555 int pos = 0;//, i = 0;
551 int i_topRow = Lview->topRow(); 556 int i_topRow = Lview->topRow();
552 557
553 QString LeftText;// = Lview->text(); 558 QString LeftText;// = Lview->text();
554 559
555 int linesPerPage = Lview->lastRow() - Lview->topRow(); 560 int linesPerPage = Lview->lastRow() - Lview->topRow();
556 // int pages = (( linesPerPage / Lview->editSize() ) ) +1; 561 // int pages = (( linesPerPage / Lview->editSize() ) ) +1;
557 // int pageN = 0; 562 // int pageN = 0;
558 i_pageNum = 1; 563 i_pageNum = 1;
559 int lastPage=1; 564 int lastPage=1;
560 int lineNo=0; 565 int lineNo=0;
561 QString s; 566 QString s;
562 f.at( 0); 567 f.at( 0);
563 568
564 while ( !f.atEnd() ) { 569 while ( !f.atEnd() ) {
565 f.readLine(s, 256); 570 f.readLine(s, 256);
566 lineNo++; 571 lineNo++;
567 LeftText = s; 572 LeftText = s;
568 currentFilePos = f.at(); 573 currentFilePos = f.at();
569 574
570 i_pageNum = lineNo/pageSize; 575 i_pageNum = lineNo/pageSize;
571 if(lastPage < i_pageNum) { 576 if(lastPage < i_pageNum) {
572 pageStopArray.resize(i_pageNum + 1); 577 pageStopArray.resize(i_pageNum + 1);
573 pageStopArray[i_pageNum ] = currentFilePos; 578 pageStopArray[i_pageNum ] = currentFilePos;
574 // qDebug("new page number %d, found at %d", i_pageNum, currentFilePos); 579 // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl;
575 } 580 }
576 // lastPage = i_pageNum; 581 // lastPage = i_pageNum;
577 if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) { 582 if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) {
578 qDebug("<<<<<< FOUND IT!! new page number %d, found at %d", i_pageNum, currentFilePos); 583 odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl;
579 break; 584 break;
580 } 585 }
581 } 586 }
582 if(f.atEnd()) //in case we didnt find anything, we need to show something 587 if(f.atEnd()) //in case we didnt find anything, we need to show something
583 f.at(0); 588 f.at(0);
584 Lview->clear(); 589 Lview->clear();
585 for(int fd=0; fd < pageSize - 1;fd++) { 590 for(int fd=0; fd < pageSize - 1;fd++) {
586 f.readLine(s, 256); 591 f.readLine(s, 256);
587 if(useWrap) 592 if(useWrap)
588 s.replace(QRegExp("\n"),""); 593 s.replace(QRegExp("\n"),"");
589 Lview->insertLine( s, -1); 594 Lview->insertLine( s, -1);
590 currentLine++; 595 currentLine++;
591 } 596 }
592 597
593 i_pageNum = lineNo/pageSize; 598 i_pageNum = lineNo/pageSize;
594 pageStopArray.resize(i_pageNum + 1); 599 pageStopArray.resize(i_pageNum + 1);
595 // int length = Lview->length(); 600 // int length = Lview->length();
596 601
597 qApp->processEvents(); 602 qApp->processEvents();
598 603
599 if( pos > i_topRow ) { 604 if( pos > i_topRow ) {
600 Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE); 605 Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE);
601 } else { 606 } else {
602 Lview->setCursorPosition( pos+2 , 0, FALSE ); 607 Lview->setCursorPosition( pos+2 , 0, FALSE );
603 } 608 }
604 609
605 Lview->deselect(); 610 Lview->deselect();
606 // AdjustStatus(); 611 // AdjustStatus();
607 Lview->setFocus(); 612 Lview->setFocus();
608} 613}
609 614
610 /* 615 /*
611 sets the current page and place as a bookmark*/ 616 sets the current page and place as a bookmark*/
612void Gutenbrowser::setBookmark() { 617void Gutenbrowser::setBookmark() {
613 int eexit=QMessageBox::information(this, "Note", 618 int eexit=QMessageBox::information(this, "Note",
614 "Do you really want to \nset this bookmark?." 619 "Do you really want to \nset this bookmark?."
615 ,QMessageBox::Yes, QMessageBox::No); 620 ,QMessageBox::Yes, QMessageBox::No);
616 if (eexit== 3) { 621 if (eexit== 3) {
617 622
618 currentFilePos = f.at(); 623 currentFilePos = f.at();
619 624
620 Config cfg("Gutenbrowser"); 625 Config cfg("Gutenbrowser");
621 cfg.setGroup("General"); 626 cfg.setGroup("General");
622 file_name=cfg.readEntry("Current",""); 627 file_name=cfg.readEntry("Current","");
623 qApp->processEvents(); 628 qApp->processEvents();
624 qDebug("Settingbook mark "+file_name); 629 odebug << "Settingbook mark "+file_name << oendl;
625 630
626 cfg.setGroup("Titles"); 631 cfg.setGroup("Titles");
627 title=cfg.readEntry(file_name,""); 632 title=cfg.readEntry(file_name,"");
628 qDebug("title is "+ title); 633 odebug << "title is "+ title << oendl;
629 634
630 cfg.setGroup( "Bookmarks" ); 635 cfg.setGroup( "Bookmarks" );
631 636
632 cfg.writeEntry("File Name",file_name); 637 cfg.writeEntry("File Name",file_name);
633 cfg.writeEntry("Page Number",QString::number(i_pageNum) ); 638 cfg.writeEntry("Page Number",QString::number(i_pageNum) );
634 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); 639 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1]));
635 cfg.writeEntry("Title", title); 640 cfg.writeEntry("Title", title);
636 641
637 int row = Lview->topRow();// Lview->Top(); 642 int row = Lview->topRow();// Lview->Top();
638 cfg.writeEntry("LineNumber",QString::number(row) ); 643 cfg.writeEntry("LineNumber",QString::number(row) );
639 644
640 cfg.setGroup(title); 645 cfg.setGroup(title);
641 cfg.writeEntry("File Name",file_name); 646 cfg.writeEntry("File Name",file_name);
642 cfg.writeEntry( "LineNumber", QString::number( row)); 647 cfg.writeEntry( "LineNumber", QString::number( row));
643 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); 648 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1]));
644 cfg.writeEntry( "Page Number", QString::number( i_pageNum) ); 649 cfg.writeEntry( "Page Number", QString::number( i_pageNum) );
645 bookmarksMenu->insertItem( title); 650 bookmarksMenu->insertItem( title);
646 } 651 }
647} //end setBookmark 652} //end setBookmark
648 653
649 654
650 /* goes to last set bookmark*/ 655 /* goes to last set bookmark*/
651void Gutenbrowser::Bookmark( int itemId) { 656void Gutenbrowser::Bookmark( int itemId) {
652 657
653 // qApp->processEvents(); 658 // qApp->processEvents();
654 Config config("Gutenbrowser"); 659 Config config("Gutenbrowser");
655 config.setGroup( "Bookmarks" ); 660 config.setGroup( "Bookmarks" );
656 661
657 // qDebug("<<<<<< %d, %d", Lview->PageSize(), Lview->lastRow() - Lview->topRow() ); 662 // odebug << "<<<<<< " << Lview->PageSize() << ", " << Lview->lastRow() - Lview->topRow() << "" << oendl;
658 663
659 QString itemString; 664 QString itemString;
660 665
661 qDebug("menu item %d", itemId); 666 odebug << "menu item " << itemId << "" << oendl;
662 QString tempTitle; 667 QString tempTitle;
663 QString s_Bmrkrow; 668 QString s_Bmrkrow;
664 QString s_pageNum; 669 QString s_pageNum;
665 int Bmrkrow=0; 670 int Bmrkrow=0;
666 int bookmarkPosition = 0; 671 int bookmarkPosition = 0;
667 672
668 // qApp->processEvents(); 673 // qApp->processEvents();
669 config.setGroup( "Bookmarks" ); 674 config.setGroup( "Bookmarks" );
670 title = config.readEntry("Title", ""); 675 title = config.readEntry("Title", "");
671 file_name = config.readEntry("File Name", ""); 676 file_name = config.readEntry("File Name", "");
672 i_pageNum = config.readNumEntry("Page Number", 0); 677 i_pageNum = config.readNumEntry("Page Number", 0);
673 bookmarkPosition = config.readNumEntry( "PagePosition",0); 678 bookmarkPosition = config.readNumEntry( "PagePosition",0);
674 Bmrkrow = config.readNumEntry("LineNumber",0); 679 Bmrkrow = config.readNumEntry("LineNumber",0);
675 if( !file_name.contains("/")) { 680 if( !file_name.contains("/")) {
676 file_name = local_library + file_name; 681 file_name = local_library + file_name;
677 } 682 }
678 683
679 // getTitle(file_name); 684 // getTitle(file_name);
680 // qApp->processEvents(); 685 // qApp->processEvents();
681 // Lview->setFocus(); 686 // Lview->setFocus();
682 this->setFocus(); 687 this->setFocus();
683 688
684 Lview->clear(); 689 Lview->clear();
685 690
686 load(file_name); 691 load(file_name);
687 692
688 int pageSize= Lview->PageSize(); 693 int pageSize= Lview->PageSize();
689 f.at(0); 694 f.at(0);
690 // Lview->clear(); 695 // Lview->clear();
691 QString s; 696 QString s;
692 int lineNo=0; 697 int lineNo=0;
693 int lastPage=1; 698 int lastPage=1;
694 while ( !f.atEnd() ) { 699 while ( !f.atEnd() ) {
695 f.readLine(s, 256); 700 f.readLine(s, 256);
696 lineNo++; 701 lineNo++;
697 currentFilePos = f.at(); 702 currentFilePos = f.at();
698 703
699 i_pageNum = lineNo/pageSize; 704 i_pageNum = lineNo/pageSize;
700 if(lastPage < i_pageNum) { 705 if(lastPage < i_pageNum) {
701 pageStopArray.resize(i_pageNum + 1); 706 pageStopArray.resize(i_pageNum + 1);
702 pageStopArray[i_pageNum ] = currentFilePos; 707 pageStopArray[i_pageNum ] = currentFilePos;
703 // qDebug("new page number %d, found at %d", i_pageNum, currentFilePos); 708 // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl;
704 } 709 }
705 if(currentFilePos == bookmarkPosition) 710 if(currentFilePos == bookmarkPosition)
706 break; 711 break;
707 } 712 }
708 if(f.atEnd()) 713 if(f.atEnd())
709 f.at(0); 714 f.at(0);
710 else 715 else
711 f.at( bookmarkPosition); 716 f.at( bookmarkPosition);
712 717
713 for(int fd=0; fd < pageSize - 1;fd++) { 718 for(int fd=0; fd < pageSize - 1;fd++) {
714 f.readLine(s, 256); 719 f.readLine(s, 256);
715 lineNo++; 720 lineNo++;
716 if(useWrap) 721 if(useWrap)
717 s.replace(QRegExp("\n"),""); 722 s.replace(QRegExp("\n"),"");
718 Lview->insertLine( s, -1); 723 Lview->insertLine( s, -1);
719 currentLine++; 724 currentLine++;
720 } 725 }
721 726
722 i_pageNum = lineNo/pageSize; 727 i_pageNum = lineNo/pageSize;
723 pageStopArray.resize(i_pageNum + 1); 728 pageStopArray.resize(i_pageNum + 1);
724 729
725 if(showMainList) { 730 if(showMainList) {
726 showMainList=FALSE; 731 showMainList=FALSE;
727 mainList->hide(); 732 mainList->hide();
728 Lview->show(); 733 Lview->show();
729 // qApp->processEvents(); 734 // qApp->processEvents();
730 } 735 }
731 736
732 qDebug("bookmark loaded"); 737 odebug << "bookmark loaded" << oendl;
733 setCaption(title); 738 setCaption(title);
734} 739}
735 740
736 741
737bool Gutenbrowser::load( const char *fileName) { 742bool Gutenbrowser::load( const char *fileName) {
738 743
739 // QCopEnvelope ( "QPE/System", "busy()" ); 744 // QCopEnvelope ( "QPE/System", "busy()" );
740 // qDebug("Title is already set as "+title); 745 // odebug << "Title is already set as "+title << oendl;
741 qDebug("sizeHint %d pageSize %d", sizeHint().height(),Lview->PageSize() ); 746 odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl;
742 if( Lview->PageSize() < 4) { 747 if( Lview->PageSize() < 4) {
743 748
744 Lview->setMaximumHeight( sizeHint().height() ); 749 Lview->setMaximumHeight( sizeHint().height() );
745 Lview->setMinimumHeight( sizeHint().height() ); 750 Lview->setMinimumHeight( sizeHint().height() );
746 pointSize = Lview->fontInfo().pointSize(); 751 pointSize = Lview->fontInfo().pointSize();
747 qDebug("sizeHint %d point size %d", sizeHint().height(), pointSize); 752 odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl;
748 if(pointSize < 10) 753 if(pointSize < 10)
749 Lview->setFixedVisibleLines(19); 754 Lview->setFixedVisibleLines(19);
750 else 755 else
751 Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2); 756 Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2);
752 } 757 }
753 758
754 Config cfg("Gutenbrowser"); 759 Config cfg("Gutenbrowser");
755 cfg.setGroup("General"); 760 cfg.setGroup("General");
756 cfg.writeEntry("Current",fileName); 761 cfg.writeEntry("Current",fileName);
757 currentLine=0; 762 currentLine=0;
758 763
759 file_name=fileName; 764 file_name=fileName;
760 QString o_file = fileName; 765 QString o_file = fileName;
761 766
762 // if (i_pageNum < 1) { 767 // if (i_pageNum < 1) {
763 i_pageNum = 1; 768 i_pageNum = 1;
764 // } 769 // }
765 qDebug("ready to open "+o_file); 770 odebug << "ready to open "+o_file << oendl;
766 771
767 if(f.isOpen()) f.close(); 772 if(f.isOpen()) f.close();
768 f.setName( o_file); 773 f.setName( o_file);
769 774
770 if ( !f.open( IO_ReadOnly)) { 775 if ( !f.open( IO_ReadOnly)) {
771 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) ); 776 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) );
772 return false; 777 return false;
773 } 778 }
774 currentFilePos = 0; 779 currentFilePos = 0;
775 pageStopArray.resize(3); 780 pageStopArray.resize(3);
776 pageStopArray[0] = currentFilePos; 781 pageStopArray[0] = currentFilePos;
777 782
778 fileHandle = f.handle(); 783 fileHandle = f.handle();
779 QString insertString; 784 QString insertString;
780 QTextStream t(&f); 785 QTextStream t(&f);
781 QString s; 786 QString s;
782 for(int fd=0; fd < Lview->PageSize() ;fd++) { 787 for(int fd=0; fd < Lview->PageSize() ;fd++) {
783 s=t.readLine(); 788 s=t.readLine();
784 // insertString+=s; 789 // insertString+=s;
785 if(useWrap) 790 if(useWrap)
786 s.replace(QRegExp("\n"),""); 791 s.replace(QRegExp("\n"),"");
787 // s.replace(QRegExp("\r"),""); 792 // s.replace(QRegExp("\r"),"");
788 Lview->insertLine( s,-1); 793 Lview->insertLine( s,-1);
789 currentLine++; 794 currentLine++;
790 } 795 }
791 796
792 // int length = Lview->length(); 797 // int length = Lview->length();
793 currentFilePos = f.at(); 798 currentFilePos = f.at();
794 799
795 pageStopArray[1] = currentFilePos; 800 pageStopArray[1] = currentFilePos;
796 801
797 qDebug("<<<<<<<<<<<%d current page is number %d, length %d, current %d, pageSize %d", 802 qDebug("<<<<<<<<<<<%d current page is number %d, length %d, current %d, pageSize %d",
798 currentFilePos, i_pageNum, Lview->length(), pageStopArray[i_pageNum], Lview->PageSize() ); 803 currentFilePos, i_pageNum, Lview->length(), pageStopArray[i_pageNum], Lview->PageSize() );
799 804
800 Lview->setMaxLines(Lview->PageSize()*2); 805 Lview->setMaxLines(Lview->PageSize()*2);
801 qDebug("Gulped %d", currentLine); 806 odebug << "Gulped " << currentLine << "" << oendl;
802 setCaption(title); 807 setCaption(title);
803 Lview->setAutoUpdate( TRUE); 808 Lview->setAutoUpdate( TRUE);
804 809
805 Lview->setCursorPosition(0,0,FALSE); 810 Lview->setCursorPosition(0,0,FALSE);
806 811
807 // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; 812 // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1;
808 //qDebug("number of pages %d", pages); 813 //odebug << "number of pages " << pages << "" << oendl;
809 814
810 loadCheck = true; 815 loadCheck = true;
811 enableButtons(true); 816 enableButtons(true);
812 if( donateMenu->count() == 3) { 817 if( donateMenu->count() == 3) {
813 donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() )); 818 donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() ));
814 } 819 }
815 Lview->setFocus(); 820 Lview->setFocus();
816 821
817 // QCopEnvelope("QPE/System", "notBusy()" ); 822 // QCopEnvelope("QPE/System", "notBusy()" );
818 return true; 823 return true;
819} // end load 824} // end load
820 825
821void Gutenbrowser::Search() { 826void Gutenbrowser::Search() {
822 827
823 // if( searchDlg->isHidden()) 828 // if( searchDlg->isHidden())
824 { 829 {
825 qDebug("Starting search dialog"); 830 odebug << "Starting search dialog" << oendl;
826 searchDlg = new SearchDialog( this, "Etext Search", true); 831 searchDlg = new SearchDialog( this, "Etext Search", true);
827 searchDlg->setCaption( tr( "Etext Search" )); 832 searchDlg->setCaption( tr( "Etext Search" ));
828 // searchDlg->setLabel( "- searches etext"); 833 // searchDlg->setLabel( "- searches etext");
829 connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); 834 connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot()));
830 connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); 835 connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot()));
831 836
832 QString resultString; 837 QString resultString;
833 QString string = searchDlg->searchString; 838 QString string = searchDlg->searchString;
834 Lview->deselect(); 839 Lview->deselect();
835 searchDlg->show(); 840 searchDlg->show();
836 searchDlg->result(); 841 searchDlg->result();
837 } 842 }
838} 843}
839 844
840void Gutenbrowser::search_slot( ) { 845void Gutenbrowser::search_slot( ) {
841 int line, col; 846 int line, col;
842 if (!searchDlg /*&& !loadCheck */) 847 if (!searchDlg /*&& !loadCheck */)
843 return; 848 return;
844 849
845 Lview->getCursorPosition(&line,&col); 850 Lview->getCursorPosition(&line,&col);
846 QString to_find_string=searchDlg->get_text(); 851 QString to_find_string=searchDlg->get_text();
847 852
848 // searchDlg->get_direction();// is true if searching backward 853 // searchDlg->get_direction();// is true if searching backward
849 if ( last_search != 0 && searchDlg->get_direction() ){ 854 if ( last_search != 0 && searchDlg->get_direction() ){
850 col = col - pattern.length() - 1 ; 855 col = col - pattern.length() - 1 ;
851 } 856 }
852 again: 857 again:
853 int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col); 858 int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col);
854 if(result == 0){ 859 if(result == 0){
855 if(!searchDlg->get_direction()){ // forward search 860 if(!searchDlg->get_direction()){ // forward search
856 int query = QMessageBox::information( searchDlg, "Find", 861 int query = QMessageBox::information( searchDlg, "Find",
857 "End of document reached.\nContinue from the beginning?", 862 "End of document reached.\nContinue from the beginning?",
858 "Yes", "No", "", 0,1); 863 "Yes", "No", "", 0,1);
859 if (query == 0){ 864 if (query == 0){
860 line = 0; 865 line = 0;
861 col = 0; 866 col = 0;
862 goto again; 867 goto again;
863 } 868 }
864 } else { //backward search 869 } else { //backward search
865 int query = QMessageBox::information( searchDlg, "Find", 870 int query = QMessageBox::information( searchDlg, "Find",
866 "End of document reached.\nContinue from the beginning?", 871 "End of document reached.\nContinue from the beginning?",
867 "Yes", "No", "", 0,1); 872 "Yes", "No", "", 0,1);
868 if (query == 0){ 873 if (query == 0){
869 QString string = Lview->textLine( Lview->numLines() - 1 ); 874 QString string = Lview->textLine( Lview->numLines() - 1 );
870 line = Lview->numLines() - 1; 875 line = Lview->numLines() - 1;
871 lineCheck = line; 876 lineCheck = line;
872 col = string.length(); 877 col = string.length();
873 last_search = -1; //BACKWARD; 878 last_search = -1; //BACKWARD;
874 goto again; 879 goto again;
875 } 880 }
876 } 881 }
877 } else { 882 } else {
878 883
879 //// emit CursorPositionChanged(); textLine 884 //// emit CursorPositionChanged(); textLine
880 } 885 }
881} 886}
882 887
883int Gutenbrowser::doSearch( const QString &s_pattern , bool case_sensitive, bool forward, int line, int col ) { 888int Gutenbrowser::doSearch( const QString &s_pattern , bool case_sensitive, bool forward, int line, int col ) {
884 int i, length; 889 int i, length;
885 int pos = -1; 890 int pos = -1;
886 if(forward) { 891 if(forward) {
887 QString string; 892 QString string;
888 for(i = line; i < Lview->numLines(); i++) { 893 for(i = line; i < Lview->numLines(); i++) {
889 894
890 string = Lview->textLine(i); 895 string = Lview->textLine(i);
891 pos = string.find(s_pattern, i == line ? col : 0, case_sensitive); 896 pos = string.find(s_pattern, i == line ? col : 0, case_sensitive);
892 if( pos != -1) { 897 if( pos != -1) {
893 int top = Lview->Top(); 898 int top = Lview->Top();
894 length = s_pattern.length(); 899 length = s_pattern.length();
895 if( i > Lview->lastRow() ) { 900 if( i > Lview->lastRow() ) {
896 Lview->setCursorPosition(i,pos,FALSE); 901 Lview->setCursorPosition(i,pos,FALSE);
897 for(int l = 0 ; l < length; l++) { 902 for(int l = 0 ; l < length; l++) {
898 Lview->cursorRight(TRUE); 903 Lview->cursorRight(TRUE);
899 } 904 }
900 Lview->setCursorPosition( i , pos + length, TRUE ); 905 Lview->setCursorPosition( i , pos + length, TRUE );
901 int newTop = Lview->Top(); 906 int newTop = Lview->Top();
902 if(Lview->lastRow() > i) 907 if(Lview->lastRow() > i)
903 Lview->ScrollUp( newTop - top); 908 Lview->ScrollUp( newTop - top);
904 // AdjustStatus(); 909 // AdjustStatus();
905 } else { 910 } else {
906 Lview->setCursorPosition(i,pos,FALSE); 911 Lview->setCursorPosition(i,pos,FALSE);
907 for(int l = 0 ; l < length; l++) { 912 for(int l = 0 ; l < length; l++) {
908 Lview->cursorRight(TRUE); 913 Lview->cursorRight(TRUE);
909 } 914 }
910 Lview->setCursorPosition( i , pos + length, TRUE ); 915 Lview->setCursorPosition( i , pos + length, TRUE );
911 // AdjustStatus(); 916 // AdjustStatus();
912 } 917 }
913 pattern = s_pattern; 918 pattern = s_pattern;
914 last_search = 1; //FORWARD; 919 last_search = 1; //FORWARD;
915 return 1; 920 return 1;
916 } 921 }
917 } 922 }
918 } else { //////////////// searching backwards 923 } else { //////////////// searching backwards
919 QString string; 924 QString string;
920 for( i = line; i >= 0; i--) { 925 for( i = line; i >= 0; i--) {
921 string = Lview->textLine(i); 926 string = Lview->textLine(i);
922 int line_length = string.length(); 927 int line_length = string.length();
923 pos = string.findRev(s_pattern, line == i ? col : line_length , case_sensitive); 928 pos = string.findRev(s_pattern, line == i ? col : line_length , case_sensitive);
924 if (pos != -1) { 929 if (pos != -1) {
925 // int top = Lview->Top(); 930 // int top = Lview->Top();
926 length = s_pattern.length(); 931 length = s_pattern.length();
927 if( i < Lview->Top() ) { 932 if( i < Lview->Top() ) {
928 Lview->ScrollDown( Lview->PageSize() ); 933 Lview->ScrollDown( Lview->PageSize() );
929 Lview->MultiLine_Ex::pageUp( FALSE ); 934 Lview->MultiLine_Ex::pageUp( FALSE );
930 if( ! (line == i && pos > col ) ) { 935 if( ! (line == i && pos > col ) ) {
931 Lview->setCursorPosition( i ,pos ,FALSE ); 936 Lview->setCursorPosition( i ,pos ,FALSE );
932 for(int l = 0 ; l < length; l++) { 937 for(int l = 0 ; l < length; l++) {
933 Lview->cursorRight(TRUE); 938 Lview->cursorRight(TRUE);
934 } 939 }
935 Lview->setCursorPosition(i ,pos + length ,TRUE ); 940 Lview->setCursorPosition(i ,pos + length ,TRUE );
936 // int newTop = Lview->Top(); 941 // int newTop = Lview->Top();
937 /* if(useSplitter) Rview->ScrollUp( newTop - top); 942 /* if(useSplitter) Rview->ScrollUp( newTop - top);
938 */ } 943 */ }
939 } else { 944 } else {
940 if( ! (line == i && pos > col ) ) { 945 if( ! (line == i && pos > col ) ) {
941 Lview->setCursorPosition( i, pos, FALSE ); 946 Lview->setCursorPosition( i, pos, FALSE );
942 for( int l = 0 ; l < length; l++) { 947 for( int l = 0 ; l < length; l++) {
943 Lview->cursorRight( TRUE); 948 Lview->cursorRight( TRUE);
944 } 949 }
945 Lview->setCursorPosition( i, pos + length, TRUE ); 950 Lview->setCursorPosition( i, pos + length, TRUE );
946 } 951 }
947 pattern = s_pattern; 952 pattern = s_pattern;
948 last_search = -1; 953 last_search = -1;
949 return 1; 954 return 1;
950 } 955 }
951 } 956 }
952 } 957 }
953 } 958 }
954 return 0; 959 return 0;
955} 960}
956 961
957void Gutenbrowser::LibraryBtn() { 962void Gutenbrowser::LibraryBtn() {
958 963
959 QString newestLibraryFile ="pgwhole.zip"; 964 QString newestLibraryFile ="pgwhole.zip";
960 QString zipFile; 965 QString zipFile;
961 // qDebug("Local Library is %s ", local_library.latin1()); 966 // odebug << "Local Library is " << local_library << " " << oendl;
962 zipFile="/usr/bin/unzip"; 967 zipFile="/usr/bin/unzip";
963 // qDebug("newestLibraryFile is %s ", newestLibraryFile.latin1()); 968 // odebug << "newestLibraryFile is " << newestLibraryFile << " " << oendl;
964 if( QFile::exists( local_library+newestLibraryFile)) { 969 if( QFile::exists( local_library+newestLibraryFile)) {
965 if( QFile::exists(zipFile) ) { 970 if( QFile::exists(zipFile) ) {
966 UnZipIt(newestLibraryFile); 971 UnZipIt(newestLibraryFile);
967 } 972 }
968 else 973 else
969 QMessageBox::message( "Note",( tr("Please install unzip")) ); 974 QMessageBox::message( "Note",( tr("Please install unzip")) );
970 } 975 }
971 // LibraryDlg = new LibraryDialog( this, "Library Index"); 976 // LibraryDlg = new LibraryDialog( this, "Library Index");
972 LibraryDlg->setCaption( tr( "Gutenberg Library")); 977 LibraryDlg->setCaption( tr( "Gutenberg Library"));
973 Config config("Gutenbrowser"); 978 Config config("Gutenbrowser");
974 config.setGroup("General"); 979 config.setGroup("General");
975 QString tmp=config.readEntry("RunBefore","FALSE"); 980 QString tmp=config.readEntry("RunBefore","FALSE");
976 if(tmp=="FALSE") { 981 if(tmp=="FALSE") {
977 QMessageBox::message( "Note", 982 QMessageBox::message( "Note",
978 "<P>Your first time running gutenbrowser. You'll need to click the \"load library\" button to load the gutenberg index.</P>"); 983 "<P>Your first time running gutenbrowser. You'll need to click the \"load library\" button to load the gutenberg index.</P>");
979 config.writeEntry("RunBefore","TRUE"); 984 config.writeEntry("RunBefore","TRUE");
980 } 985 }
981 if(useSplitter) 986 if(useSplitter)
982 LibraryDlg->useSmallInterface=FALSE; 987 LibraryDlg->useSmallInterface=FALSE;
983 988
984 LibraryDlg->showMaximized(); 989 LibraryDlg->showMaximized();
985 990
986 if( LibraryDlg->exec() != 0 ) { 991 if( LibraryDlg->exec() != 0 ) {
987 listItemNumber = LibraryDlg->DlglistItemNumber; 992 listItemNumber = LibraryDlg->DlglistItemNumber;
988 listItemFile = LibraryDlg->DlglistItemFile; 993 listItemFile = LibraryDlg->DlglistItemFile;
989 listItemYear = LibraryDlg->DlglistItemYear; 994 listItemYear = LibraryDlg->DlglistItemYear;
990 listItemTitle = LibraryDlg->DlglistItemTitle; 995 listItemTitle = LibraryDlg->DlglistItemTitle;
991 file_name = LibraryDlg->File_Name; 996 file_name = LibraryDlg->File_Name;
992 // qDebug("title is being set as "+title); 997 // odebug << "title is being set as "+title << oendl;
993 title = listItemTitle; 998 title = listItemTitle;
994 999
995 // config.setGroup( "Proxy" ); 1000 // config.setGroup( "Proxy" );
996 // if( LibraryDlg->checked == 1) { 1001 // if( LibraryDlg->checked == 1) {
997 // config.writeEntry("IsChecked", "TRUE"); 1002 // config.writeEntry("IsChecked", "TRUE");
998 // } else { 1003 // } else {
999 // config.writeEntry("IsChecked", "FALSE"); 1004 // config.writeEntry("IsChecked", "FALSE");
1000 // } 1005 // }
1001 // config.write(); 1006 // config.write();
1002 // config.read(); 1007 // config.read();
1003 if ( listItemNumber.isNull()) { 1008 if ( listItemNumber.isNull()) {
1004 } else { 1009 } else {
1005 i_pageNum = 1; 1010 i_pageNum = 1;
1006 if( file_name !="Error" && file_name.length() >2 && !file_name.isEmpty() ) { 1011 if( file_name !="Error" && file_name.length() >2 && !file_name.isEmpty() ) {
1007 //replace .zip with txt for opening it. 1012 //replace .zip with txt for opening it.
1008 // printf("\nFile name is now\n"); 1013 // printf("\nFile name is now\n");
1009 // printf(file_name); 1014 // printf(file_name);
1010 // printf("\n"); 1015 // printf("\n");
1011 // 1016 //
1012 if( file_name.find(".zip")) 1017 if( file_name.find(".zip"))
1013 { 1018 {
1014 qDebug("Found zip file\n"); 1019 odebug << "Found zip file\n" << oendl;
1015 // QStringList args; 1020 // QStringList args;
1016 // args="unzip"; 1021 // args="unzip";
1017 // args+="-o"; 1022 // args+="-o";
1018 // args+=local_library+file_name; 1023 // args+=local_library+file_name;
1019 // args+="-d"; 1024 // args+="-d";
1020 // args+=local_library; 1025 // args+=local_library;
1021 QString cmd = "/usr/bin/unzip -o " + local_library+file_name + " -d " + local_library; 1026 QString cmd = "/usr/bin/unzip -o " + local_library+file_name + " -d " + local_library;
1022 qDebug("Issuing the command "+ cmd); 1027 odebug << "Issuing the command "+ cmd << oendl;
1023 // unzipProc=new QProcess( this, "unzipProc" ); /// fark that idea! 1028 // unzipProc=new QProcess( this, "unzipProc" ); /// fark that idea!
1024 // unzipProc->start(); 1029 // unzipProc->start();
1025 system(cmd); 1030 system(cmd);
1026 remove( file_name); 1031 remove( file_name);
1027 1032
1028 } 1033 }
1029 // // 1034 // //
1030 // file_name = file_name.left(4)+ ".txt"; 1035 // file_name = file_name.left(4)+ ".txt";
1031 if( LibraryDlg) 1036 if( LibraryDlg)
1032 delete LibraryDlg; 1037 delete LibraryDlg;
1033 setTitle(); 1038 setTitle();
1034 // QCopEnvelope ( "QPE/System", "busy()" ); 1039 // QCopEnvelope ( "QPE/System", "busy()" );
1035 load( file_name); 1040 load( file_name);
1036 } else { 1041 } else {
1037 printf("Not opening the file.\n"); 1042 printf("Not opening the file.\n");
1038 } 1043 }
1039 } 1044 }
1040 } 1045 }
1041 if(showMainList) { 1046 if(showMainList) {
1042 if(!Lview->isHidden()) 1047 if(!Lview->isHidden())
1043 Lview->hide(); 1048 Lview->hide();
1044 qApp->processEvents(); 1049 qApp->processEvents();
1045 showMainList=TRUE; 1050 showMainList=TRUE;
1046 if(mainList->isHidden()) 1051 if(mainList->isHidden())
1047 mainList->show(); 1052 mainList->show();
1048 fillWithTitles(); 1053 fillWithTitles();
1049 qApp->processEvents(); 1054 qApp->processEvents();
1050 } else 1055 } else
1051 setCentralWidget( Lview); 1056 setCentralWidget( Lview);
1052 // QPEApplication::grabKeyboard(); 1057 // QPEApplication::grabKeyboard();
1053 // fixKeys(); 1058 // fixKeys();
1054} 1059}
1055 1060
1056void Gutenbrowser::OpenBtn() { 1061void Gutenbrowser::OpenBtn() {
1057 QString s_temp; 1062 QString s_temp;
1058 s_temp = status; 1063 s_temp = status;
1059 OpenEtext* OpenDlg; 1064 OpenEtext* OpenDlg;
1060 OpenDlg = new OpenEtext(this,"OpenDlg"); 1065 OpenDlg = new OpenEtext(this,"OpenDlg");
1061 OpenDlg->showMaximized(); 1066 OpenDlg->showMaximized();
1062 1067
1063 if( OpenDlg->exec() != 0) { 1068 if( OpenDlg->exec() != 0) {
1064 title = OpenDlg->openFileTitle; 1069 title = OpenDlg->openFileTitle;
1065 qDebug("title open as "+title); 1070 odebug << "title open as "+title << oendl;
1066 file_name = OpenDlg->file; 1071 file_name = OpenDlg->file;
1067 i_pageNum = 1; 1072 i_pageNum = 1;
1068 1073
1069 if( !file_name.isEmpty() || file_name.length() > 2 ) { 1074 if( !file_name.isEmpty() || file_name.length() > 2 ) {
1070 if(showMainList) { 1075 if(showMainList) {
1071 showMainList=FALSE; 1076 showMainList=FALSE;
1072 qDebug("ShowMainList is now false"); 1077 odebug << "ShowMainList is now false" << oendl;
1073 mainList->hide(); 1078 mainList->hide();
1074 Lview->show(); 1079 Lview->show();
1075 qApp->processEvents(); 1080 qApp->processEvents();
1076 } 1081 }
1077 Lview->clear(); 1082 Lview->clear();
1078 // QCopEnvelope ( "QPE/System", "busy()" ); 1083 // QCopEnvelope ( "QPE/System", "busy()" );
1079 load(file_name); 1084 load(file_name);
1080 } else { 1085 } else {
1081 qDebug("file_name is empty!"); 1086 odebug << "file_name is empty!" << oendl;
1082 if(showMainList) { 1087 if(showMainList) {
1083 if(!Lview->isHidden()) 1088 if(!Lview->isHidden())
1084 Lview->hide(); 1089 Lview->hide();
1085 qApp->processEvents(); 1090 qApp->processEvents();
1086 if(mainList->isHidden()) 1091 if(mainList->isHidden())
1087 mainList->show(); 1092 mainList->show();
1088 fillWithTitles(); 1093 fillWithTitles();
1089 qApp->processEvents(); 1094 qApp->processEvents();
1090 } 1095 }
1091 1096
1092 } 1097 }
1093 } 1098 }
1094 if( OpenDlg) 1099 if( OpenDlg)
1095 delete OpenDlg; 1100 delete OpenDlg;
1096 /* 1101 /*
1097 Config config("Gutenbrowser"); 1102 Config config("Gutenbrowser");
1098 config.setGroup( title); 1103 config.setGroup( title);
1099 file_name = config.readEntry("File Name", ""); 1104 file_name = config.readEntry("File Name", "");
1100 i_pageNum = config.readNumEntry("Page Number", -1); 1105 i_pageNum = config.readNumEntry("Page Number", -1);
1101 int Bmrkrow = config.readNumEntry("LineNumber", -1); 1106 int Bmrkrow = config.readNumEntry("LineNumber", -1);
1102 if(Bmrkrow > -1) { 1107 if(Bmrkrow > -1) {
1103 if( Bmrkrow > Lview->topRow() ) { 1108 if( Bmrkrow > Lview->topRow() ) {
1104 Lview->setCursorPosition( Bmrkrow ,0, FALSE ); 1109 Lview->setCursorPosition( Bmrkrow ,0, FALSE );
1105 Lview->ScrollUp( Bmrkrow - Lview->topRow() ); 1110 Lview->ScrollUp( Bmrkrow - Lview->topRow() );
1106 // AdjustStatus(); 1111 // AdjustStatus();
1107 } 1112 }
1108 else if( Bmrkrow < Lview->topRow() ) { 1113 else if( Bmrkrow < Lview->topRow() ) {
1109 Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE ); 1114 Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE );
1110 Lview->ScrollDown( Lview->topRow() - Bmrkrow ); 1115 Lview->ScrollDown( Lview->topRow() - Bmrkrow );
1111 // AdjustStatus(); 1116 // AdjustStatus();
1112 } 1117 }
1113 } 1118 }
1114 */ 1119 */
1115 // ResizeEdits(); 1120 // ResizeEdits();
1116 1121
1117} 1122}
1118 1123
1119void Gutenbrowser::ChangeFont() { 1124void Gutenbrowser::ChangeFont() {
1120#ifndef Q_WS_QWS 1125#ifndef Q_WS_QWS
1121 bool ok; 1126 bool ok;
1122 1127
1123 weight= Lview->fontInfo().weight(); 1128 weight= Lview->fontInfo().weight();
1124 italic = Lview->fontInfo().italic(); 1129 italic = Lview->fontInfo().italic();
1125 bold=Lview->fontInfo().bold(); 1130 bold=Lview->fontInfo().bold();
1126 pointSize= Lview->fontInfo().pointSize(); 1131 pointSize= Lview->fontInfo().pointSize();
1127 fontStr=Lview->fontInfo().family(); 1132 fontStr=Lview->fontInfo().family();
1128 1133
1129 if(italic == true) 1134 if(italic == true)
1130 italicStr="TRUE"; 1135 italicStr="TRUE";
1131 else 1136 else
1132 italicStr="FALSE"; 1137 italicStr="FALSE";
1133 1138
1134 QFont currentfont( fontStr, pointSize, weight, italic ); 1139 QFont currentfont( fontStr, pointSize, weight, italic );
1135 1140
1136 if (ok) { 1141 if (ok) {
1137 QFontInfo fontInfo(font ); 1142 QFontInfo fontInfo(font );
1138 fontStr=fontInfo.family(); 1143 fontStr=fontInfo.family();
1139 1144
1140 pointSize= fontInfo.pointSize(); 1145 pointSize= fontInfo.pointSize();
1141 1146
1142 font.setFontSize(pointSize); 1147 font.setFontSize(pointSize);
1143 1148
1144 pointSizeStr.setNum( pointSize); 1149 pointSizeStr.setNum( pointSize);
1145 1150
1146 weight= fontInfo.weight(); 1151 weight= fontInfo.weight();
1147 weightStr.setNum( weight); 1152 weightStr.setNum( weight);
1148 italic =fontInfo.italic(); 1153 italic =fontInfo.italic();
1149 bold=fontInfo.bold(); 1154 bold=fontInfo.bold();
1150 1155
1151 if(italic == true) 1156 if(italic == true)
1152 italicStr="TRUE"; 1157 italicStr="TRUE";
1153 else 1158 else
1154 italicStr="FALSE"; 1159 italicStr="FALSE";
1155 if(bold == true) 1160 if(bold == true)
1156 boldStr="TRUE"; 1161 boldStr="TRUE";
1157 else 1162 else
1158 boldStr="FALSE"; 1163 boldStr="FALSE";
1159 1164
1160 pointSizeStr.setNum( pointSize); 1165 pointSizeStr.setNum( pointSize);
1161 config.setGroup( "Font" ); 1166 config.setGroup( "Font" );
1162 config.writeEntry("Family", fontStr ); 1167 config.writeEntry("Family", fontStr );
1163 config.writeEntry("Size", pointSizeStr ); 1168 config.writeEntry("Size", pointSizeStr );
1164 config.writeEntry("Weight", weightStr ); 1169 config.writeEntry("Weight", weightStr );
1165 config.writeEntry("Italic", italicStr ); 1170 config.writeEntry("Italic", italicStr );
1166 config.writeEntry("Bold", boldStr ); 1171 config.writeEntry("Bold", boldStr );
1167 // config.write(); 1172 // config.write();
1168 1173
1169 Lview->setFont(font); 1174 Lview->setFont(font);
1170 1175
1171 QRect lRect; 1176 QRect lRect;
1172 QRect rRect; 1177 QRect rRect;
1173 lRect = Lview->rect(); 1178 lRect = Lview->rect();
1174 if(useSplitter) { 1179 if(useSplitter) {
1175 } 1180 }
1176 // if(loadCheck) { 1181 // if(loadCheck) {
1177 // ResizeEdits(); 1182 // ResizeEdits();
1178 // } 1183 // }
1179 update(); 1184 update();
1180 } 1185 }
1181#endif 1186#endif
1182} 1187}
1183 1188
1184 1189
1185 /* 1190 /*
1186 performs dictionary look ups on the web */ 1191 performs dictionary look ups on the web */
1187void Gutenbrowser::LookupBtn() { 1192void Gutenbrowser::LookupBtn() {
1188 QString text; 1193 QString text;
1189 if( Lview->hasSelectedText()) { 1194 if( Lview->hasSelectedText()) {
1190 Lview->copy(); 1195 Lview->copy();
1191 } 1196 }
1192 QClipboard *cb = QApplication::clipboard(); 1197 QClipboard *cb = QApplication::clipboard();
1193 text = cb->text(); 1198 text = cb->text();
1194 int eexit=QMessageBox::information(this, 1199 int eexit=QMessageBox::information(this,
1195 "Note","Do you want to lookup\n\""+text+"\"\non websters web dictionary?", 1200 "Note","Do you want to lookup\n\""+text+"\"\non websters web dictionary?",
1196 QMessageBox::Yes, QMessageBox::No); 1201 QMessageBox::Yes, QMessageBox::No);
1197 if (eexit== 3) { 1202 if (eexit== 3) {
1198 // this link for sale!! 1203 // this link for sale!!
1199 qApp->processEvents(); 1204 qApp->processEvents();
1200 goGetit( "http://www.m-w.com/cgi-bin/dictionary?" + text, true); 1205 goGetit( "http://www.m-w.com/cgi-bin/dictionary?" + text, true);
1201 } 1206 }
1202} 1207}
1203 1208
1204void Gutenbrowser::ClearEdit() { 1209void Gutenbrowser::ClearEdit() {
1205 Lview->setText(""); 1210 Lview->setText("");
1206 loadCheck = false; 1211 loadCheck = false;
1207 status = ( tr("Gutenbrowser")); 1212 status = ( tr("Gutenbrowser"));
1208 InfoBar->setText( ""); 1213 InfoBar->setText( "");
1209 setCaption( tr("Gutenbrowser")); 1214 setCaption( tr("Gutenbrowser"));
1210 i_pageNum = 0; 1215 i_pageNum = 0;
1211 enableButtons(false); 1216 enableButtons(false);
1212 1217
1213 if(!showMainList) { 1218 if(!showMainList) {
1214 Lview->hide(); 1219 Lview->hide();
1215 showMainList=TRUE; 1220 showMainList=TRUE;
1216 mainList->show(); 1221 mainList->show();
1217 fillWithTitles(); 1222 fillWithTitles();
1218 qApp->processEvents(); 1223 qApp->processEvents();
1219 } 1224 }
1220 if(donateMenu->idAt(3) != -1) 1225 if(donateMenu->idAt(3) != -1)
1221 donateMenu->removeItemAt(3); 1226 donateMenu->removeItemAt(3);
1222} 1227}
1223 1228
1224 1229
1225bool Gutenbrowser::getTitle( const char *file ) { 1230bool Gutenbrowser::getTitle( const char *file ) {
1226 QString s_file; 1231 QString s_file;
1227 QString filer = file; 1232 QString filer = file;
1228 if( filer.contains(local_library, TRUE)) { 1233 if( filer.contains(local_library, TRUE)) {
1229 QFileInfo f(file); 1234 QFileInfo f(file);
1230 s_file = f.fileName(); 1235 s_file = f.fileName();
1231 } else { 1236 } else {
1232 s_file = filer; 1237 s_file = filer;
1233 } 1238 }
1234 Config config("Gutenbrowser"); 1239 Config config("Gutenbrowser");
1235 config.setGroup( "Files" ); 1240 config.setGroup( "Files" );
1236 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 1241 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
1237 int i_numofFiles = s_numofFiles.toInt(); 1242 int i_numofFiles = s_numofFiles.toInt();
1238 1243
1239 for (int i = 1; i <= i_numofFiles; i++) { 1244 for (int i = 1; i <= i_numofFiles; i++) {
1240 QString temp; 1245 QString temp;
1241 temp.setNum(i); 1246 temp.setNum(i);
1242 QString ramble = config.readEntry(temp, "" ); 1247 QString ramble = config.readEntry(temp, "" );
1243 1248
1244 if( strcmp(ramble, s_file) == 0) { 1249 if( strcmp(ramble, s_file) == 0) {
1245 config.setGroup( "Titles" ); 1250 config.setGroup( "Titles" );
1246 title = config.readEntry(ramble, ""); 1251 title = config.readEntry(ramble, "");
1247 // qDebug("(getTitle)title is being set as "+title); 1252 // odebug << "(getTitle)title is being set as "+title << oendl;
1248 } 1253 }
1249 } 1254 }
1250 return true; 1255 return true;
1251} 1256}
1252 1257
1253void Gutenbrowser::searchdone_slot() { 1258void Gutenbrowser::searchdone_slot() {
1254 // if (!searchDlg) 1259 // if (!searchDlg)
1255 // return; 1260 // return;
1256 // searchDlg->hide(); 1261 // searchDlg->hide();
1257 // Lview->setFocus(); 1262 // Lview->setFocus();
1258 this->setFocus(); 1263 this->setFocus();
1259 last_search = 0; 1264 last_search = 0;
1260 // ResizeEdits(); 1265 // ResizeEdits();
1261} 1266}
1262 1267
1263 /* 1268 /*
1264 sets the status message */ 1269 sets the status message */
1265bool Gutenbrowser::setStatus() { 1270bool Gutenbrowser::setStatus() {
1266 1271
1267#ifndef Q_WS_QWS 1272#ifndef Q_WS_QWS
1268 QString s_pages; 1273 QString s_pages;
1269 s_pages.setNum( pages); 1274 s_pages.setNum( pages);
1270 QString chNum; 1275 QString chNum;
1271 statusTop = status.left( status.find(" ", TRUE) ); 1276 statusTop = status.left( status.find(" ", TRUE) );
1272 status.append(chNum.setNum( i_pageNum)); 1277 status.append(chNum.setNum( i_pageNum));
1273 status += " / " + s_pages; 1278 status += " / " + s_pages;
1274 1279
1275 if(loadCheck) { 1280 if(loadCheck) {
1276 statusBar->message( status); 1281 statusBar->message( status);
1277 InfoBar->setText( title); 1282 InfoBar->setText( title);
1278 } else { 1283 } else {
1279 } 1284 }
1280#else 1285#else
1281 QString msg; 1286 QString msg;
1282 msg.sprintf(title+" %d", i_pageNum); 1287 msg.sprintf(title+" %d", i_pageNum);
1283 setCaption( msg); 1288 setCaption( msg);
1284#endif 1289#endif
1285 return true; 1290 return true;
1286} 1291}
1287 1292
1288void Gutenbrowser::keyReleaseEvent( QKeyEvent *e) { 1293void Gutenbrowser::keyReleaseEvent( QKeyEvent *e) {
1289 switch ( e->key() ) { 1294 switch ( e->key() ) {
1290 1295
1291 case Key_M: 1296 case Key_M:
1292 // Bookmark(); 1297 // Bookmark();
1293 break; 1298 break;
1294 case Key_D: 1299 case Key_D:
1295 DownloadIndex(); 1300 DownloadIndex();
1296 break; 1301 break;
1297 case Key_L: 1302 case Key_L:
1298 LibraryBtn(); 1303 LibraryBtn();
1299 break; 1304 break;
1300 case Key_O: 1305 case Key_O:
1301 OpenBtn(); 1306 OpenBtn();
1302 break; 1307 break;
1303 case Key_F: 1308 case Key_F:
1304 ForwardBtn(); 1309 ForwardBtn();
1305 break; 1310 break;
1306 case Key_B: 1311 case Key_B:
1307 BackBtn(); 1312 BackBtn();
1308 break; 1313 break;
1309 case Key_P: 1314 case Key_P:
1310 PrintBtn(); 1315 PrintBtn();
1311 break; 1316 break;
1312 case Key_S: 1317 case Key_S:
1313 SearchBtn(); 1318 SearchBtn();
1314 break; 1319 break;
1315 case Key_E: 1320 case Key_E:
1316 ByeBye(); 1321 ByeBye();
1317 break; 1322 break;
1318 case Key_R: 1323 case Key_R:
1319 // setBookmark(); 1324 // setBookmark();
1320 break; 1325 break;
1321 case Key_T: 1326 case Key_T:
1322 ChangeFont(); 1327 ChangeFont();
1323 break; 1328 break;
1324 case Key_C: 1329 case Key_C:
1325 ClearEdit(); 1330 ClearEdit();
1326 break; 1331 break;
1327 case Key_H: 1332 case Key_H:
1328 HelpBtn(); 1333 HelpBtn();
1329 break; 1334 break;
1330 case Key_K: 1335 case Key_K:
1331 LookupBtn(); 1336 LookupBtn();
1332 break; 1337 break;
1333 case Key_U:// hide menu 1338 case Key_U:// hide menu
1334 if(menubar->isHidden() ) 1339 if(menubar->isHidden() )
1335 menubar->show(); 1340 menubar->show();
1336 else 1341 else
1337 menubar->hide(); 1342 menubar->hide();
1338 break; 1343 break;
1339 case Key_I: 1344 case Key_I:
1340 hideButtons(); 1345 hideButtons();
1341 break; 1346 break;
1342 ////////////////////////////// Zaurus keys 1347 ////////////////////////////// Zaurus keys
1343 case Key_Home: 1348 case Key_Home:
1344 // BeginBtn(); 1349 // BeginBtn();
1345 break; 1350 break;
1346 case Key_F9: //activity 1351 case Key_F9: //activity
1347 OpenBtn(); 1352 OpenBtn();
1348 break; 1353 break;
1349 case Key_F10: //contacts 1354 case Key_F10: //contacts
1350 hideButtons(); 1355 hideButtons();
1351 break; 1356 break;
1352 case Key_F11: //menu 1357 case Key_F11: //menu
1353 if(menubar->isHidden() ) 1358 if(menubar->isHidden() )
1354 menubar->show(); 1359 menubar->show();
1355 else 1360 else
1356 menubar->hide(); 1361 menubar->hide();
1357 break; 1362 break;
1358 case Key_F12: //home 1363 case Key_F12: //home
1359 BeginBtn(); 1364 BeginBtn();
1360 break; 1365 break;
1361 case Key_F13: //mail 1366 case Key_F13: //mail
1362 LibraryBtn(); 1367 LibraryBtn();
1363 break; 1368 break;
1364 case Key_Space: 1369 case Key_Space:
1365 if(loadCheck) 1370 if(loadCheck)
1366 ForwardBtn(); 1371 ForwardBtn();
1367 // else 1372 // else
1368 // Bookmark(); 1373 // Bookmark();
1369 break; 1374 break;
1370 case Key_Down: 1375 case Key_Down:
1371 if(loadCheck) { 1376 if(loadCheck) {
1372 // if( !e->isAutoRepeat() ) 1377 // if( !e->isAutoRepeat() )
1373 // AdjustStatus(); 1378 // AdjustStatus();
1374 // } else { 1379 // } else {
1375 // LibraryBtn(); 1380 // LibraryBtn();
1376 // ForwardBtn(); 1381 // ForwardBtn();
1377 } 1382 }
1378 1383
1379 // ForwardButton->setFocus(); 1384 // ForwardButton->setFocus();
1380 // Lview->setFocus(); 1385 // Lview->setFocus();
1381 // if(s_Wrap=="FALSE") 1386 // if(s_Wrap=="FALSE")
1382 // Lview->MultiLine_Ex::ScrollDown( 1); 1387 // Lview->MultiLine_Ex::ScrollDown( 1);
1383 // LibraryBtn(); 1388 // LibraryBtn();
1384 break; 1389 break;
1385 case Key_Up: 1390 case Key_Up:
1386 if(loadCheck) { 1391 if(loadCheck) {
1387 // if( !e->isAutoRepeat() ) 1392 // if( !e->isAutoRepeat() )
1388 // AdjustStatus(); 1393 // AdjustStatus();
1389 // } else { 1394 // } else {
1390 // OpenBtn(); 1395 // OpenBtn();
1391 // BackBtn(); 1396 // BackBtn();
1392 } 1397 }
1393 // BackButton->setFocus(); 1398 // BackButton->setFocus();
1394 // Lview->setFocus(); 1399 // Lview->setFocus();
1395 // if(s_Wrap=="FALSE") 1400 // if(s_Wrap=="FALSE")
1396 // Lview->MultiLine_Ex::ScrollUp( 1); 1401 // Lview->MultiLine_Ex::ScrollUp( 1);
1397 1402
1398 // LibraryBtn(); 1403 // LibraryBtn();
1399 break; 1404 break;
1400 case Key_Right: 1405 case Key_Right:
1401 ForwardButton->setFocus(); 1406 ForwardButton->setFocus();
1402 ForwardBtn(); 1407 ForwardBtn();
1403 // LibraryBtn(); 1408 // LibraryBtn();
1404 break; 1409 break;
1405 case Key_Left: 1410 case Key_Left:
1406 BackBtn(); 1411 BackBtn();
1407 BackButton->setFocus(); 1412 BackButton->setFocus();
1408 // OpenBtn(); 1413 // OpenBtn();
1409 break; 1414 break;
1410 case Key_Escape: 1415 case Key_Escape:
1411 ByeBye(); 1416 ByeBye();
1412 break; 1417 break;
1413 case Key_PageUp: 1418 case Key_PageUp:
1414 BackBtn(); 1419 BackBtn();
1415 break; 1420 break;
1416 case Key_PageDown: 1421 case Key_PageDown:
1417 ForwardBtn(); 1422 ForwardBtn();
1418 break; 1423 break;
1419 1424
1420 ////////////////////////////// Zaurus keys 1425 ////////////////////////////// Zaurus keys
1421 }; 1426 };
1422} 1427}
1423 1428
1424void Gutenbrowser::keyPressEvent( QKeyEvent *e) { 1429void Gutenbrowser::keyPressEvent( QKeyEvent *e) {
1425 switch ( e->key() ) { 1430 switch ( e->key() ) {
1426 // case Key_Next: 1431 // case Key_Next:
1427 // ForwardBtn(); 1432 // ForwardBtn();
1428 // break; 1433 // break;
1429 // case Key_Prior: 1434 // case Key_Prior:
1430 // BackBtn(); 1435 // BackBtn();
1431 // break; 1436 // break;
1432 // case Key_Space: 1437 // case Key_Space:
1433 // ForwardBtn(); 1438 // ForwardBtn();
1434 // break; 1439 // break;
1435 // case Key_Down: 1440 // case Key_Down:
1436 // Lview->MultiLine_Ex::ScrollUp( 1); 1441 // Lview->MultiLine_Ex::ScrollUp( 1);
1437 // if(useSplitter) Rview->MultiLine_Ex::ScrollUp( 1); 1442 // if(useSplitter) Rview->MultiLine_Ex::ScrollUp( 1);
1438 // break; 1443 // break;
1439 // case Key_Up: 1444 // case Key_Up:
1440 // if( Lview->Top() != 0) { 1445 // if( Lview->Top() != 0) {
1441 // Lview->MultiLine_Ex::ScrollDown( 1); 1446 // Lview->MultiLine_Ex::ScrollDown( 1);
1442 // if(useSplitter) Rview->MultiLine_Ex::ScrollDown( 1); 1447 // if(useSplitter) Rview->MultiLine_Ex::ScrollDown( 1);
1443 // } 1448 // }
1444 // break; 1449 // break;
1445 } 1450 }
1446} 1451}
1447 1452
1448void Gutenbrowser::resizeEvent( QResizeEvent *ev) { 1453void Gutenbrowser::resizeEvent( QResizeEvent *ev) {
1449 // qDebug("resize: %d,%d\n",ev->size().width(),ev->size().height()); 1454 // odebug << "resize: " << ev->size().width() << "," << ev->size().height() << "\n" << oendl;
1450 1455
1451 if( !LibraryDlg->isHidden()) 1456 if( !LibraryDlg->isHidden())
1452 LibraryDlg->resize(ev->size().width(),ev->size().height() ); 1457 LibraryDlg->resize(ev->size().width(),ev->size().height() );
1453 1458
1454 // if( loadCheck == true) { 1459 // if( loadCheck == true) {
1455 // ResizeEdits(); 1460 // ResizeEdits();
1456 // AdjustStatus(); 1461 // AdjustStatus();
1457 // } 1462 // }
1458} 1463}
1459 1464
1460 1465
1461void Gutenbrowser::doOptions() { 1466void Gutenbrowser::doOptions() {
1462 optionsDialog* optDlg; 1467 optionsDialog* optDlg;
1463 optDlg = new optionsDialog( this,"Options_Dlg", true); 1468 optDlg = new optionsDialog( this,"Options_Dlg", true);
1464 QString Ddir; 1469 QString Ddir;
1465 Config config("Gutenbrowser"); 1470 Config config("Gutenbrowser");
1466 config.setGroup( "General" ); 1471 config.setGroup( "General" );
1467 QFont myFont; 1472 QFont myFont;
1468 optDlg->showMaximized(); 1473 optDlg->showMaximized();
1469 1474
1470 if( optDlg->exec() !=0) { 1475 if( optDlg->exec() !=0) {
1471 qApp->processEvents(); 1476 qApp->processEvents();
1472 brow=optDlg->browserName; 1477 brow=optDlg->browserName;
1473 toggleButtonIcons( optDlg->useIcon); 1478 toggleButtonIcons( optDlg->useIcon);
1474 ftp_host= optDlg->ftp_host; 1479 ftp_host= optDlg->ftp_host;
1475 ftp_base_dir= optDlg->ftp_base_dir; 1480 ftp_base_dir= optDlg->ftp_base_dir;
1476 brow=optDlg->browserName; 1481 brow=optDlg->browserName;
1477 Ddir=optDlg->downloadDirEdit->text(); 1482 Ddir=optDlg->downloadDirEdit->text();
1478 1483
1479 qDebug("writing library config"); 1484 odebug << "writing library config" << oendl;
1480 Config config("Gutenbrowser"); 1485 Config config("Gutenbrowser");
1481 config.setGroup("General"); 1486 config.setGroup("General");
1482 1487
1483 QString dirname= optDlg->downloadDirEdit->text(); 1488 QString dirname= optDlg->downloadDirEdit->text();
1484 if(dirname.right(1)!="/") 1489 if(dirname.right(1)!="/")
1485 dirname+="/"; 1490 dirname+="/";
1486 config.writeEntry( "DownloadDirectory",dirname); 1491 config.writeEntry( "DownloadDirectory",dirname);
1487 QDir newDir( optDlg->downloadDirEdit->text()); 1492 QDir newDir( optDlg->downloadDirEdit->text());
1488 1493
1489 if( !newDir.exists() ) { 1494 if( !newDir.exists() ) {
1490 int exit=QMessageBox::information(this, "Note", "Ok, to make a new directory\n"+Ddir+" ?", 1495 int exit=QMessageBox::information(this, "Note", "Ok, to make a new directory\n"+Ddir+" ?",
1491 QMessageBox::Ok, QMessageBox::Cancel); 1496 QMessageBox::Ok, QMessageBox::Cancel);
1492 if (exit==1) { 1497 if (exit==1) {
1493 QString cmd="mkdir -p "; 1498 QString cmd="mkdir -p ";
1494 cmd+=Ddir.latin1(); 1499 cmd+=Ddir.latin1();
1495 system(cmd); 1500 system(cmd);
1496 qDebug("Making new dir "+cmd); 1501 odebug << "Making new dir "+cmd << oendl;
1497 if(Ddir.right(1)!="/") { 1502 if(Ddir.right(1)!="/") {
1498 Ddir+="/"; 1503 Ddir+="/";
1499 } 1504 }
1500 config.writeEntry("DownloadDirectory",Ddir); 1505 config.writeEntry("DownloadDirectory",Ddir);
1501 } 1506 }
1502 } 1507 }
1503 1508
1504// if(optDlg->styleChanged) 1509// if(optDlg->styleChanged)
1505// setStyle( optDlg->styleInt); 1510// setStyle( optDlg->styleInt);
1506 if(optDlg->b_qExit==TRUE) 1511 if(optDlg->b_qExit==TRUE)
1507 b_queryExit=TRUE; 1512 b_queryExit=TRUE;
1508 else 1513 else
1509 b_queryExit=FALSE; 1514 b_queryExit=FALSE;
1510 1515
1511 if(optDlg->fontDlg-> changedFonts) { 1516 if(optDlg->fontDlg-> changedFonts) {
1512 qDebug("Setting font"); 1517 odebug << "Setting font" << oendl;
1513 myFont=optDlg->fontDlg->selectedFont; 1518 myFont=optDlg->fontDlg->selectedFont;
1514 Lview->setFont( myFont); 1519 Lview->setFont( myFont);
1515 } 1520 }
1516 1521
1517 if(optDlg->useWordWrap_CheckBox->isChecked() ) { 1522 if(optDlg->useWordWrap_CheckBox->isChecked() ) {
1518 qDebug("WORD WRAP is set"); 1523 odebug << "WORD WRAP is set" << oendl;
1519 Lview->setWordWrap(QMultiLineEdit::WidgetWidth); 1524 Lview->setWordWrap(QMultiLineEdit::WidgetWidth);
1520 useWrap=true; 1525 useWrap=true;
1521 } else { 1526 } else {
1522 qDebug("Word wrap is NOT set"); 1527 odebug << "Word wrap is NOT set" << oendl;
1523 Lview->setWordWrap(QMultiLineEdit::NoWrap); 1528 Lview->setWordWrap(QMultiLineEdit::NoWrap);
1524 useWrap=false; 1529 useWrap=false;
1525 } 1530 }
1526 } 1531 }
1527 if(showMainList) { 1532 if(showMainList) {
1528 if(!Lview->isHidden()) 1533 if(!Lview->isHidden())
1529 Lview->hide(); 1534 Lview->hide();
1530 qApp->processEvents(); 1535 qApp->processEvents();
1531 if(mainList->isHidden()) 1536 if(mainList->isHidden())
1532 mainList->show(); 1537 mainList->show();
1533 fillWithTitles(); 1538 fillWithTitles();
1534 } else { 1539 } else {
1535 Lview->show(); 1540 Lview->show();
1536 showMainList=FALSE; 1541 showMainList=FALSE;
1537 mainList->hide(); 1542 mainList->hide();
1538 } 1543 }
1539 qApp->processEvents(); 1544 qApp->processEvents();
1540 update(); 1545 update();
1541} 1546}
1542 1547
1543bool Gutenbrowser::setTitle() { 1548bool Gutenbrowser::setTitle() {
1544 if( file_name.contains( local_library)) { 1549 if( file_name.contains( local_library)) {
1545 QFileInfo f( file_name); 1550 QFileInfo f( file_name);
1546 QString s_file = f.fileName(); 1551 QString s_file = f.fileName();
1547 file_name = s_file; 1552 file_name = s_file;
1548 } 1553 }
1549 1554
1550 int test = 0; 1555 int test = 0;
1551 Config config("Gutenbrowser"); 1556 Config config("Gutenbrowser");
1552 config.setGroup( "Files" ); 1557 config.setGroup( "Files" );
1553 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 1558 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
1554 int i_numofFiles = s_numofFiles.toInt(); 1559 int i_numofFiles = s_numofFiles.toInt();
1555 1560
1556 for (int i = 1; i <= i_numofFiles; i++) { 1561 for (int i = 1; i <= i_numofFiles; i++) {
1557 QString temp; 1562 QString temp;
1558 temp.setNum(i); 1563 temp.setNum(i);
1559 QString ramble = config.readEntry(temp, "" ); 1564 QString ramble = config.readEntry(temp, "" );
1560 1565
1561 if( strcmp(ramble, file_name) == 0) { 1566 if( strcmp(ramble, file_name) == 0) {
1562 test = 1; 1567 test = 1;
1563 } 1568 }
1564 } 1569 }
1565 if (test == 0) { 1570 if (test == 0) {
1566 config.writeEntry("NumberOfFiles",i_numofFiles +1 ); 1571 config.writeEntry("NumberOfFiles",i_numofFiles +1 );
1567 QString interger; 1572 QString interger;
1568 interger.setNum( i_numofFiles +1); 1573 interger.setNum( i_numofFiles +1);
1569 config.writeEntry(interger, file_name); 1574 config.writeEntry(interger, file_name);
1570 1575
1571 config.setGroup( "Titles" ); 1576 config.setGroup( "Titles" );
1572 config.writeEntry(file_name,listItemTitle); 1577 config.writeEntry(file_name,listItemTitle);
1573 } 1578 }
1574 test = 0; 1579 test = 0;
1575 // config.write(); 1580 // config.write();
1576 return true; 1581 return true;
1577} 1582}
1578 /*Calls new fangled network dialog */ 1583 /*Calls new fangled network dialog */
1579void Gutenbrowser::OnNetworkDialog( const QString &/*networkUrl*/, const QString &/*output*/) 1584void Gutenbrowser::OnNetworkDialog( const QString &/*networkUrl*/, const QString &/*output*/)
1580{ 1585{
1581 // qDebug(networkUrl); 1586 // odebug << networkUrl << oendl;
1582 // qDebug(output); 1587 // odebug << output << oendl;
1583 // #ifndef Q_WS_QWS 1588 // #ifndef Q_WS_QWS
1584 // NetworkDialog *NetworkDlg; 1589 // NetworkDialog *NetworkDlg;
1585 // if( networkUrl.length() < 4 ) networkUrl= "http://sailor.gutenberg.org/mirror.sites.html"; 1590 // if( networkUrl.length() < 4 ) networkUrl= "http://sailor.gutenberg.org/mirror.sites.html";
1586 // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, output); 1591 // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, output);
1587 // if( NetworkDlg->exec() != 0 ) { 1592 // if( NetworkDlg->exec() != 0 ) {
1588 // } 1593 // }
1589 // if(NetworkDlg) 1594 // if(NetworkDlg)
1590 // delete NetworkDlg; 1595 // delete NetworkDlg;
1591 // #endif 1596 // #endif
1592} 1597}
1593 1598
1594void Gutenbrowser::donateGutenberg() 1599void Gutenbrowser::donateGutenberg()
1595{ 1600{
1596 int exit=QMessageBox::information(this,"Info", "http://www.gutenberg.org\ndonate@gutenberg.net", 1601 int exit=QMessageBox::information(this, "Info", "http://www.gutenberg.org\ndonate@gutenberg.net",
1597 QMessageBox::Ok, QMessageBox::Cancel); 1602 QMessageBox::Ok, QMessageBox::Cancel);
1598 1603
1599 if (exit==1) { 1604 if (exit==1) {
1600 } else { 1605 } else {
1601 }; 1606 };
1602} 1607}
1603 1608
1604void Gutenbrowser::donateByteMonkie() 1609void Gutenbrowser::donateByteMonkie()
1605{ 1610{
1606} 1611}
1607 1612
1608void Gutenbrowser::writeConfig() 1613void Gutenbrowser::writeConfig()
1609{ 1614{
1610 // config.read(); 1615 // config.read();
1611 // Config config("Gutenbrowser"); 1616 // Config config("Gutenbrowser");
1612 // #ifndef Q_WS_QWS 1617 // #ifndef Q_WS_QWS
1613 // config.setGroup( "Geometry" ); 1618 // config.setGroup( "Geometry" );
1614 // QString s; 1619 // QString s;
1615 // QString globalPosition; 1620 // QString globalPosition;
1616 // QPoint point; 1621 // QPoint point;
1617 // point=mapToGlobal(QPoint(0,0) ); 1622 // point=mapToGlobal(QPoint(0,0) );
1618 // int posiX, posiY; 1623 // int posiX, posiY;
1619 // posiX=point.x(); 1624 // posiX=point.x();
1620 // posiY=point.y(); 1625 // posiY=point.y();
1621 // globalPosition.sprintf("%i,%i", posiX, posiY); 1626 // globalPosition.sprintf("%i,%i", posiX, posiY);
1622 1627
1623 // QRect frameRect; 1628 // QRect frameRect;
1624 // frameRect = geometry(); 1629 // frameRect = geometry();
1625 // s.sprintf("%i,%i", frameRect.width(), frameRect.height()); 1630 // s.sprintf("%i,%i", frameRect.width(), frameRect.height());
1626 // config.writeEntry("Frame", s); 1631 // config.writeEntry("Frame", s);
1627 // config.writeEntry("Position", globalPosition); 1632 // config.writeEntry("Position", globalPosition);
1628 1633
1629 // if( useIcons==TRUE) 1634 // if( useIcons==TRUE)
1630 // config.writeEntry("Icons", "TRUE"); 1635 // config.writeEntry("Icons", "TRUE");
1631 // else 1636 // else
1632 // config.writeEntry("Icons", "FALSE"); 1637 // config.writeEntry("Icons", "FALSE");
1633 // #endif 1638 // #endif
1634 1639
1635 // #ifndef Q_WS_QWS 1640 // #ifndef Q_WS_QWS
1636 // QString temp; 1641 // QString temp;
1637 // temp.setNum(styleI, 10); 1642 // temp.setNum(styleI, 10);
1638 // config.setGroup( "StyleIze" ); 1643 // config.setGroup( "StyleIze" );
1639 // config.writeEntry( "Style", temp); 1644 // config.writeEntry( "Style", temp);
1640 // #endif 1645 // #endif
1641 1646
1642 // config.setGroup("General"); 1647 // config.setGroup("General");
1643} 1648}
1644 1649
1645void Gutenbrowser::annotations() 1650void Gutenbrowser::annotations()
1646{ 1651{
1647 // #ifndef Q_WS_QWS 1652 // #ifndef Q_WS_QWS
1648 // QMessageBox::message("Note","hi annotate"); 1653 // QMessageBox::message("Note","hi annotate");
1649 // lastBmkButton->setDown(FALSE); 1654 // lastBmkButton->setDown(FALSE);
1650 // #endif 1655 // #endif
1651} 1656}
1652 1657
1653void Gutenbrowser::hideButtons() 1658void Gutenbrowser::hideButtons()
1654{ 1659{
1655 1660
1656 if( !buttonsHidden) { 1661 if( !buttonsHidden) {
1657 buttonsHidden=TRUE; 1662 buttonsHidden=TRUE;
1658 LibraryButton->hide(); 1663 LibraryButton->hide();
1659 SearchButton->hide(); 1664 SearchButton->hide();
1660 InfoBar->hide(); 1665 InfoBar->hide();
1661 OpenButton->hide(); 1666 OpenButton->hide();
1662 BackButton->hide(); 1667 BackButton->hide();
1663 ForwardButton->hide(); 1668 ForwardButton->hide();
1664 setBookmarkButton->hide(); 1669 setBookmarkButton->hide();
1665 lastBmkButton->hide(); 1670 lastBmkButton->hide();
1666 dictionaryButton->hide(); 1671 dictionaryButton->hide();
1667 if(useSplitter) { 1672 if(useSplitter) {
1668 ClearButton->hide(); 1673 ClearButton->hide();
1669 PrintButton->hide(); 1674 PrintButton->hide();
1670 beginButton->hide(); 1675 beginButton->hide();
1671 HelpButton->hide(); 1676 HelpButton->hide();
1672 FontButton->hide(); 1677 FontButton->hide();
1673 ExitButton->hide(); 1678 ExitButton->hide();
1674 OptionsButton->hide(); 1679 OptionsButton->hide();
1675 DownloadButton->hide(); 1680 DownloadButton->hide();
1676 } 1681 }
1677 } else { 1682 } else {
1678 buttonsHidden=FALSE; 1683 buttonsHidden=FALSE;
1679 1684
1680 LibraryButton->show(); 1685 LibraryButton->show();
1681 SearchButton->show(); 1686 SearchButton->show();
1682 InfoBar->show(); 1687 InfoBar->show();
1683 OpenButton->show(); 1688 OpenButton->show();
1684 BackButton->show(); 1689 BackButton->show();
1685 ForwardButton->show(); 1690 ForwardButton->show();
1686 setBookmarkButton->show(); 1691 setBookmarkButton->show();
1687 lastBmkButton->show(); 1692 lastBmkButton->show();
1688 dictionaryButton->show(); 1693 dictionaryButton->show();
1689 if(useSplitter) { 1694 if(useSplitter) {
1690 ClearButton->show(); 1695 ClearButton->show();
1691 PrintButton->show(); 1696 PrintButton->show();
1692 beginButton->show(); 1697 beginButton->show();
1693 HelpButton->show(); 1698 HelpButton->show();
1694 FontButton->show(); 1699 FontButton->show();
1695 ExitButton->show(); 1700 ExitButton->show();
1696 OptionsButton->show(); 1701 OptionsButton->show();
1697 DownloadButton->show(); 1702 DownloadButton->show();
1698 } 1703 }
1699 } 1704 }
1700} 1705}
1701 1706
1702void Gutenbrowser::focusInEvent( QFocusEvent* ) 1707void Gutenbrowser::focusInEvent( QFocusEvent* )
1703{ 1708{
1704} 1709}
1705void Gutenbrowser::focusOutEvent( QFocusEvent* ) 1710void Gutenbrowser::focusOutEvent( QFocusEvent* )
1706{ 1711{
1707} 1712}
1708 1713
1709void Gutenbrowser::cleanUp( ) 1714void Gutenbrowser::cleanUp( )
1710{ 1715{
1711 writeConfig(); 1716 writeConfig();
1712 QPEApplication::grabKeyboard(); 1717 QPEApplication::grabKeyboard();
1713 1718
1714 QPEApplication::ungrabKeyboard(); 1719 QPEApplication::ungrabKeyboard();
1715 // qDebug("Cleanup"); 1720 // odebug << "Cleanup" << oendl;
1716 if(f.isOpen()) f.close(); 1721 if(f.isOpen()) f.close();
1717} 1722}
1718 1723
1719void Gutenbrowser::fixKeys() 1724void Gutenbrowser::fixKeys()
1720{ 1725{
1721 qDebug("Attempting to fix keys"); 1726 odebug << "Attempting to fix keys" << oendl;
1722 1727
1723} 1728}
1724 1729
1725void Gutenbrowser::enableButtons(bool b) 1730void Gutenbrowser::enableButtons(bool b)
1726{ 1731{
1727 BackButton->setEnabled(b); 1732 BackButton->setEnabled(b);
1728 ForwardButton->setEnabled(b); 1733 ForwardButton->setEnabled(b);
1729 SearchButton->setEnabled(b); 1734 SearchButton->setEnabled(b);
1730 setBookmarkButton->setEnabled(b); 1735 setBookmarkButton->setEnabled(b);
1731 dictionaryButton->setEnabled(b); 1736 dictionaryButton->setEnabled(b);
1732 InfoBar->setEnabled(b); 1737 InfoBar->setEnabled(b);
1733 1738
1734 editMenu->setItemEnabled( -5, b); 1739 editMenu->setItemEnabled( -5, b);
1735 editMenu->setItemEnabled( -6, b); 1740 editMenu->setItemEnabled( -6, b);
1736 editMenu->setItemEnabled( -7, b); 1741 editMenu->setItemEnabled( -7, b);
1737 editMenu->setItemEnabled( -8, b); 1742 editMenu->setItemEnabled( -8, b);
1738 1743
1739} 1744}
1740 1745
1741void Gutenbrowser::fillWithTitles() { 1746void Gutenbrowser::fillWithTitles() {
1742 Config config("Gutenbrowser"); 1747 Config config("Gutenbrowser");
1743 config.setGroup( "Files" ); 1748 config.setGroup( "Files" );
1744 int i_numofFiles = config.readNumEntry("NumberOfFiles", 0); 1749 int i_numofFiles = config.readNumEntry("NumberOfFiles", 0);
1745 mainList->clear(); 1750 mainList->clear();
1746 QString temp; 1751 QString temp;
1747 for (int i = 1; i <= i_numofFiles; i++) { 1752 for (int i = 1; i <= i_numofFiles; i++) {
1748 temp.setNum(i); 1753 temp.setNum(i);
1749 config.setGroup( "Files" ); 1754 config.setGroup( "Files" );
1750 QString ramble = config.readEntry(temp, "" ); 1755 QString ramble = config.readEntry(temp, "" );
1751 config.setGroup( "Titles" ); 1756 config.setGroup( "Titles" );
1752 temp = config.readEntry(ramble, ""); 1757 temp = config.readEntry(ramble, "");
1753 if( !temp.isEmpty()) { 1758 if( !temp.isEmpty()) {
1754 mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), temp, -1); 1759 mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), temp, -1);
1755 } 1760 }
1756 } 1761 }
1757} 1762}
1758 1763
1759void Gutenbrowser::listClickedSlot( QListBoxItem * index) { 1764void Gutenbrowser::listClickedSlot( QListBoxItem * index) {
1760 // if( !working) { 1765 // if( !working) {
1761 // working=true; 1766 // working=true;
1762 if(index) { 1767 if(index) {
1763 // QCopEnvelope ( "QPE/System", "busy()" ); 1768 // QCopEnvelope ( "QPE/System", "busy()" );
1764 title = index->text(); 1769 title = index->text();
1765 showMainList=FALSE; 1770 showMainList=FALSE;
1766 mainList->hide(); 1771 mainList->hide();
1767 Lview->show(); 1772 Lview->show();
1768 qApp->processEvents(); 1773 qApp->processEvents();
1769 QString temp; 1774 QString temp;
1770 temp.setNum( mainList->currentItem() + 1); 1775 temp.setNum( mainList->currentItem() + 1);
1771 // openFileTitle = title; 1776 // openFileTitle = title;
1772 Config config("Gutenbrowser"); 1777 Config config("Gutenbrowser");
1773 config.setGroup( "Files" ); 1778 config.setGroup( "Files" );
1774 QString file = config.readEntry(temp, ""); 1779 QString file = config.readEntry(temp, "");
1775 qDebug("About to load"); 1780 odebug << "About to load" << oendl;
1776 if( Lview->isVisible()) 1781 if( Lview->isVisible())
1777 load(file); 1782 load(file);
1778 1783
1779 config.setGroup( title); 1784 config.setGroup( title);
1780 file_name = config.readEntry("File Name", ""); 1785 file_name = config.readEntry("File Name", "");
1781 i_pageNum = config.readNumEntry("Page Number", 1); 1786 i_pageNum = config.readNumEntry("Page Number", 1);
1782 int Bmrkrow = config.readNumEntry("LineNumber", -1); 1787 int Bmrkrow = config.readNumEntry("LineNumber", -1);
1783 if(Bmrkrow > -1) { 1788 if(Bmrkrow > -1) {
1784 if( Bmrkrow > Lview->topRow() ) { 1789 if( Bmrkrow > Lview->topRow() ) {
1785 Lview->setCursorPosition( Bmrkrow /* - Lview->topRow() */,0, FALSE ); 1790 Lview->setCursorPosition( Bmrkrow /* - Lview->topRow() */,0, FALSE );
1786 Lview->ScrollUp( Bmrkrow - Lview->topRow() ); 1791 Lview->ScrollUp( Bmrkrow - Lview->topRow() );
1787 // AdjustStatus(); 1792 // AdjustStatus();
1788 } 1793 }
1789 else if( Bmrkrow < Lview->topRow() ) { 1794 else if( Bmrkrow < Lview->topRow() ) {
1790 Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE ); 1795 Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE );
1791 Lview->ScrollDown( Lview->topRow() - Bmrkrow ); 1796 Lview->ScrollDown( Lview->topRow() - Bmrkrow );
1792 // AdjustStatus(); 1797 // AdjustStatus();
1793 } 1798 }
1794 } 1799 }
1795 } 1800 }
1796} 1801}
1797 1802
1798void Gutenbrowser::infoGutenbrowser() { 1803void Gutenbrowser::infoGutenbrowser() {
1799 QMessageBox::message("Info","Gutenbrowser was developed by\n" 1804 QMessageBox::message("Info","Gutenbrowser was developed by\n"
1800 "Lorn Potter\n" 1805 "Lorn Potter\n"
1801 "ljp<ljp@llornkcor.com>\n"); 1806 "ljp<ljp@llornkcor.com>\n");
1802} 1807}
1803 1808
1804void Gutenbrowser::setDocument(const QString & frozenBoogers) { 1809void Gutenbrowser::setDocument(const QString & frozenBoogers) {
1805 this->hide(); 1810 this->hide();
1806 if(showMainList) { 1811 if(showMainList) {
1807 showMainList=FALSE; 1812 showMainList=FALSE;
1808 if(!mainList->isHidden()) 1813 if(!mainList->isHidden())
1809 mainList->hide(); 1814 mainList->hide();
1810 if(Lview->isHidden()) 1815 if(Lview->isHidden())
1811 Lview->show(); 1816 Lview->show();
1812 qApp->processEvents(); 1817 qApp->processEvents();
1813 } 1818 }
1814 DocLnk lnk; 1819 DocLnk lnk;
1815 lnk = DocLnk(frozenBoogers); 1820 lnk = DocLnk(frozenBoogers);
1816 // qDebug(lnk.file() ); 1821 // odebug << lnk.file() << oendl;
1817 title=lnk.comment(); 1822 title=lnk.comment();
1818 load( lnk.file()); 1823 load( lnk.file());
1819 this->show(); 1824 this->show();
1820 // qDebug(title); 1825 // odebug << title << oendl;
1821 // qApp->processEvents(); 1826 // qApp->processEvents();
1822 // repaint(); 1827 // repaint();
1823} 1828}
1824 1829
1825void Gutenbrowser::mainListPressed(int mouse, QListBoxItem * , const QPoint & ) 1830void Gutenbrowser::mainListPressed(int mouse, QListBoxItem * , const QPoint & )
1826{ 1831{
1827 switch (mouse) { 1832 switch (mouse) {
1828 case 1: 1833 case 1:
1829 break; 1834 break;
1830 case 2: { 1835 case 2: {
1831 QPopupMenu m;// = new QPopupMenu( Local_View ); 1836 QPopupMenu m;// = new QPopupMenu( Local_View );
1832 m.insertItem( tr( "Open" ), this, SLOT( menuOpen() )); 1837 m.insertItem( tr( "Open" ), this, SLOT( menuOpen() ));
1833 m.insertSeparator(); 1838 m.insertSeparator();
1834 m.insertItem( tr( "Search google.com" ), this, SLOT( menuGoogle())); 1839 m.insertItem( tr( "Search google.com" ), this, SLOT( menuGoogle()));
1835 m.insertItem( tr( "Edit Title" ), this, SLOT( menuEditTitle())); 1840 m.insertItem( tr( "Edit Title" ), this, SLOT( menuEditTitle()));
1836 // m.insertSeparator(); 1841 // m.insertSeparator();
1837 // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 1842 // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
1838 m.exec( QCursor::pos() ); 1843 m.exec( QCursor::pos() );
1839 } 1844 }
1840 break; 1845 break;
1841 }; 1846 };
1842} 1847}
1843 1848
1844void Gutenbrowser::menuOpen() { 1849void Gutenbrowser::menuOpen() {
1845 listClickedSlot( mainList->item( mainList->currentItem())); 1850 listClickedSlot( mainList->item( mainList->currentItem()));
1846} 1851}
1847 1852
1848void Gutenbrowser::menuGoogle() { 1853void Gutenbrowser::menuGoogle() {
1849 searchGoogle( mainList->text(mainList->currentItem())); 1854 searchGoogle( mainList->text(mainList->currentItem()));
1850} 1855}
1851 1856
1852void Gutenbrowser::searchGoogle( const QString &tempText) { 1857void Gutenbrowser::searchGoogle( const QString &tempText) {
1853 QString text = tempText; 1858 QString text = tempText;
1854 1859
1855 int eexit=QMessageBox::information(this, "Note","Do you want to search for\n"+text+ 1860 int eexit=QMessageBox::information(this, "Note","Do you want to search for\n"+text+
1856 "\non google.com?",QMessageBox::Yes, QMessageBox::No); 1861 "\non google.com?",QMessageBox::Yes, QMessageBox::No);
1857 if (eexit== 3) { 1862 if (eexit== 3) {
1858 qApp->processEvents(); 1863 qApp->processEvents();
1859 text.replace( QRegExp("\\s"), "%20"); 1864 text.replace( QRegExp("\\s"), "%20");
1860 text.replace( QRegExp("#"), ""); 1865 text.replace( QRegExp("#"), "");
1861 text.replace( QRegExp(","), "%20"); 1866 text.replace( QRegExp(","), "%20");
1862 text.replace( QRegExp("'"), "%20"); 1867 text.replace( QRegExp("'"), "%20");
1863 text.replace( QRegExp("("), ""); 1868 text.replace( QRegExp("("), "");
1864 text.replace( QRegExp(")"), ""); 1869 text.replace( QRegExp(")"), "");
1865 // text.replace( QRegExp("[0-9]"), ""); 1870 // text.replace( QRegExp("[0-9]"), "");
1866 QString s_lookup = "http://google.com/search?q="+text+"&num=30&sa=Google+Search"; 1871 QString s_lookup = "http://google.com/search?q="+text+"&num=30&sa=Google+Search";
1867 goGetit( s_lookup, true); 1872 goGetit( s_lookup, true);
1868 } 1873 }
1869 1874
1870} 1875}
1871 1876
1872void Gutenbrowser::menuEditTitle() 1877void Gutenbrowser::menuEditTitle()
1873{ 1878{
1874 int currentItem = mainList->currentItem(); 1879 int currentItem = mainList->currentItem();
1875 QString title_text = mainList->text( currentItem); 1880 QString title_text = mainList->text( currentItem);
1876 //qDebug("Selected "+title_text); 1881 //odebug << "Selected "+title_text << oendl;
1877 1882
1878 Config config("Gutenbrowser"); 1883 Config config("Gutenbrowser");
1879 config.setGroup( "Files" ); 1884 config.setGroup( "Files" );
1880 QString s_numofFiles = config.readEntry("NumberOfFiles", "0"); 1885 QString s_numofFiles = config.readEntry("NumberOfFiles", "0");
1881 int i_numofFiles = s_numofFiles.toInt(); 1886 int i_numofFiles = s_numofFiles.toInt();
1882 QString fileNum; 1887 QString fileNum;
1883 for (int i = 1; i <= i_numofFiles+1; i++) { 1888 for (int i = 1; i <= i_numofFiles+1; i++) {
1884 1889
1885 fileNum.setNum(i); 1890 fileNum.setNum(i);
1886 config.setGroup( "Files" ); 1891 config.setGroup( "Files" );
1887 QString s_filename = config.readEntry(fileNum, "" ); 1892 QString s_filename = config.readEntry(fileNum, "" );
1888 config.setGroup( "Titles" ); 1893 config.setGroup( "Titles" );
1889 QString file_title = config.readEntry( s_filename, ""); 1894 QString file_title = config.readEntry( s_filename, "");
1890 //qDebug("file_title is "+file_title); 1895 //odebug << "file_title is "+file_title << oendl;
1891 if(title_text == file_title ) { 1896 if(title_text == file_title ) {
1892 // selFile = s_filename; 1897 // selFile = s_filename;
1893 //qDebug("Edit: "+ file_title ); 1898 //odebug << "Edit: "+ file_title << oendl;
1894 i=i_numofFiles+1; 1899 i=i_numofFiles+1;
1895 Edit_Title *titleEdit; 1900 Edit_Title *titleEdit;
1896 titleEdit = new Edit_Title(this,file_title ,TRUE); 1901 titleEdit = new Edit_Title(this,file_title ,TRUE);
1897 if(titleEdit->exec() !=0) { 1902 if(titleEdit->exec() !=0) {
1898 //qDebug(titleEdit->newTitle); 1903 //odebug << titleEdit->newTitle << oendl;
1899 config.writeEntry( s_filename, titleEdit->newTitle); 1904 config.writeEntry( s_filename, titleEdit->newTitle);
1900 mainList->removeItem(currentItem); 1905 mainList->removeItem(currentItem);
1901 mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), titleEdit->newTitle, currentItem); 1906 mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), titleEdit->newTitle, currentItem);
1902 } 1907 }
1903 } 1908 }
1904 } 1909 }
1905 1910
1906 // getTitles(); 1911 // getTitles();
1907 mainList->triggerUpdate(true); 1912 mainList->triggerUpdate(true);
1908 1913
1909} 1914}
1910 1915
1911 1916
1912 1917
1913bool Gutenbrowser::UnZipIt(const QString &zipFile) { 1918bool Gutenbrowser::UnZipIt(const QString &zipFile) {
1914 qDebug(zipFile); 1919 odebug << zipFile << oendl;
1915#ifndef Q_WS_QWS 1920#ifndef Q_WS_QWS
1916 if( QFile::exists( zipFile)) { // TODO findsome other way of dealingwithzip files. 1921 if( QFile::exists( zipFile)) { // TODO findsome other way of dealingwithzip files.
1917 bool isPgWhole=false; 1922 bool isPgWhole=false;
1918 QString thatFile; 1923 QString thatFile;
1919 if(zipFile.find("pgwhole",0,TRUE)) { 1924 if(zipFile.find("pgwhole",0,TRUE)) {
1920 isPgWhole=TRUE; 1925 isPgWhole=TRUE;
1921 thatFile= local_library +"PGWHOLE.TXT"; 1926 thatFile= local_library +"PGWHOLE.TXT";
1922 } 1927 }
1923 // else { 1928 // else {
1924 // thatFile=zipFile.left(4); 1929 // thatFile=zipFile.left(4);
1925 // } 1930 // }
1926 // qDebug((const char*)local_library.latin1()); 1931 // odebug << (const char*)local_library.latin1() << oendl;
1927 QString cmd; 1932 QString cmd;
1928#if defined(_WS_X11_) 1933#if defined(_WS_X11_)
1929 if( chdir((const char*)local_library.latin1())!=0) 1934 if( chdir((const char*)local_library.latin1())!=0)
1930 qDebug("chdir failed."); 1935 odebug << "chdir failed." << oendl;
1931 cmd = "gunzip -S .zip " + local_library+zipFile; 1936 cmd = "gunzip -S .zip " + local_library+zipFile;
1932 //cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; 1937 //cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library;
1933#endif 1938#endif
1934#ifdef Q_WS_QWS 1939#ifdef Q_WS_QWS
1935 if( chdir((const char*)local_library.latin1())!=0) 1940 if( chdir((const char*)local_library.latin1())!=0)
1936 qDebug("chdir failed."); 1941 odebug << "chdir failed." << oendl;
1937 cmd = "unzip " + local_library+zipFile; 1942 cmd = "unzip " + local_library+zipFile;
1938 // cmd = "/usr/bin/unzip -o " + local_library+zipFile +" -d /usr/share/doc/gutenbrowser" ;//+ local_library; 1943 // cmd = "/usr/bin/unzip -o " + local_library+zipFile +" -d /usr/share/doc/gutenbrowser" ;//+ local_library;
1939#endif 1944#endif
1940 int exit=QMessageBox::information(this, "Ok to unzip?", 1945 int exit=QMessageBox::information(this, "Ok to unzip?",
1941 "Ok to unnzip\n"+ zipFile+" ?", 1946 "Ok to unnzip\n"+ zipFile+" ?",
1942 QMessageBox::Yes, QMessageBox::No); 1947 QMessageBox::Yes, QMessageBox::No);
1943 if (exit==QMessageBox::Yes) { 1948 if (exit==QMessageBox::Yes) {
1944#if defined(_WS_X11_)// 1949#if defined(_WS_X11_)//
1945 qDebug("Issuing the command "+cmd); 1950 odebug << "Issuing the command "+cmd << oendl;
1946 system( cmd); 1951 system( cmd);
1947 if( QFile::exists(thatFile)) 1952 if( QFile::exists(thatFile))
1948 remove (thatFile); 1953 remove (thatFile);
1949 if(isPgWhole) { 1954 if(isPgWhole) {
1950 if( rename("pgwhole","PGWHOLE.TXT") !=0) 1955 if( rename("pgwhole","PGWHOLE.TXT") !=0)
1951 qDebug("rename failed"); 1956 odebug << "rename failed" << oendl;
1952 } else { 1957 } else {
1953 if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) 1958 if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0)
1954 qDebug("rename failed"); 1959 odebug << "rename failed" << oendl;
1955 } 1960 }
1956#endif 1961#endif
1957#ifdef Q_WS_QWS 1962#ifdef Q_WS_QWS
1958 qDebug("Issuing the command "+cmd); 1963 odebug << "Issuing the command "+cmd << oendl;
1959 system( cmd); 1964 system( cmd);
1960 if( QFile::exists(thatFile)) 1965 if( QFile::exists(thatFile))
1961 remove(thatFile); 1966 remove(thatFile);
1962 if(isPgWhole) { 1967 if(isPgWhole) {
1963 if( rename("pgwhole","PGWHOLE.TXT") !=0) 1968 if( rename("pgwhole","PGWHOLE.TXT") !=0)
1964 qDebug("rename failed"); 1969 odebug << "rename failed" << oendl;
1965 } else { 1970 } else {
1966 if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) 1971 if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0)
1967 qDebug("rename failed"); 1972 odebug << "rename failed" << oendl;
1968 } 1973 }
1969#endif 1974#endif
1970 // remove( zipFile); 1975 // remove( zipFile);
1971 return true; 1976 return true;
1972 } 1977 }
1973 else if(exit==QMessageBox::No) { 1978 else if(exit==QMessageBox::No) {
1974 // qDebug("unzip"); 1979 // odebug << "unzip" << oendl;
1975 return false; 1980 return false;
1976 } 1981 }
1977 } 1982 }
1978 else 1983 else
1979 QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); 1984 QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) );
1980#endif 1985#endif
1981 return false; 1986 return false;
1982} 1987}
1983 1988
1984 1989
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp
index c9149ac..a226258 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp
@@ -1,76 +1,80 @@
1/*************************************************************************** 1/***************************************************************************
2 gutenbrowser.cpp - description 2 gutenbrowser.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Jul 24 22:33:12 MDT 2000 4 begin : Mon Jul 24 22:33:12 MDT 2000
5 copyright : (C) 2000 -2004 by llornkcor 5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7***************************************************************************/ 7***************************************************************************/
8/*************************************************************************** 8/***************************************************************************
9 * This program is free software; you can redistribute it and/or modify * 9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by * 10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or * 11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. * 12 * (at your option) any later version. *
13 ***************************************************************************/ 13 ***************************************************************************/
14
14//#include "gutenbrowserData.h" 15//#include "gutenbrowserData.h"
15#include "gutenbrowser.h" 16#include "gutenbrowser.h"
16 17
18/* OPIE */
19#include <opie2/odebug.h>
17#include <qpe/config.h> 20#include <qpe/config.h>
18#include <qpe/fontdatabase.h> 21#include <qpe/fontdatabase.h>
19#include <qpe/menubutton.h> 22#include <qpe/menubutton.h>
20#include <qpe/resource.h> 23#include <qpe/resource.h>
21#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
22 25
26/* QT */
23#include <qfontinfo.h> 27#include <qfontinfo.h>
24#include <qtoolbutton.h> 28#include <qtoolbutton.h>
25 29
26void Gutenbrowser::initSlots() { 30void Gutenbrowser::initSlots() {
27 31
28 connect(LibraryButton,SIGNAL(released()),SLOT(LibraryBtn())); 32 connect(LibraryButton,SIGNAL(released()),SLOT(LibraryBtn()));
29 connect(OpenButton,SIGNAL(released()),SLOT(OpenBtn())); 33 connect(OpenButton,SIGNAL(released()),SLOT(OpenBtn()));
30 connect(SearchButton,SIGNAL(released()),SLOT(SearchBtn())); 34 connect(SearchButton,SIGNAL(released()),SLOT(SearchBtn()));
31 connect(ForwardButton,SIGNAL(clicked()),SLOT(ForwardBtn())); 35 connect(ForwardButton,SIGNAL(clicked()),SLOT(ForwardBtn()));
32 connect(BackButton,SIGNAL(clicked()),SLOT(BackBtn())); 36 connect(BackButton,SIGNAL(clicked()),SLOT(BackBtn()));
33 connect(setBookmarkButton,SIGNAL(released()),SLOT(setBookmark())); 37 connect(setBookmarkButton,SIGNAL(released()),SLOT(setBookmark()));
34 connect(dictionaryButton,SIGNAL(released()),SLOT(LookupBtn())); 38 connect(dictionaryButton,SIGNAL(released()),SLOT(LookupBtn()));
35 connect(InfoBar,SIGNAL(clicked()),SLOT(InfoBarClick())); 39 connect(InfoBar,SIGNAL(clicked()),SLOT(InfoBarClick()));
36 connect(qApp,SIGNAL(aboutToQuit()),SLOT(cleanUp())); 40 connect(qApp,SIGNAL(aboutToQuit()),SLOT(cleanUp()));
37 connect(mainList,SIGNAL(clicked(QListBoxItem *)),SLOT(listClickedSlot(QListBoxItem *))); 41 connect(mainList,SIGNAL(clicked(QListBoxItem *)),SLOT(listClickedSlot(QListBoxItem *)));
38 connect(bookmarksMenu,SIGNAL(activated(int)),SLOT(Bookmark(int))); 42 connect(bookmarksMenu,SIGNAL(activated(int)),SLOT(Bookmark(int)));
39} 43}
40 44
41void Gutenbrowser::initConfig() { 45void Gutenbrowser::initConfig() {
42//qDebug("Starting configuration."); 46//odebug << "Starting configuration." << oendl;
43 QDir library(local_library); 47 QDir library(local_library);
44 if ( !library.exists()) { 48 if ( !library.exists()) {
45 library.mkdir(local_library, TRUE); 49 library.mkdir(local_library, TRUE);
46 QString msg; 50 QString msg;
47// #ifndef Q_WS_WIN 51// #ifndef Q_WS_WIN
48 msg = "chmod 755 " + local_library; 52 msg = "chmod 755 " + local_library;
49 system(msg); 53 system(msg);
50// QDir pixdir(local_library+"pix"); 54// QDir pixdir(local_library+"pix");
51// if ( !pixdir.exists()) { 55// if ( !pixdir.exists()) {
52// pixdir.mkdir(local_library+"pix", TRUE); 56// pixdir.mkdir(local_library+"pix", TRUE);
53// QString msg; 57// QString msg;
54// msg = "chmod 755 " + local_library+"pix"; 58// msg = "chmod 755 " + local_library+"pix";
55// system(msg); 59// system(msg);
56// } 60// }
57// #endif 61// #endif
58 62
59 } 63 }
60 // qDebug( "init file is %s",iniFile.latin1()); 64 // odebug << "init file is " << iniFile << "" << oendl;
61 65
62#ifdef Q_WS_QWS 66#ifdef Q_WS_QWS
63 useSplitter=FALSE; 67 useSplitter=FALSE;
64 Config config("Gutenbrowser"); 68 Config config("Gutenbrowser");
65 69
66 config.setGroup( "General" ); 70 config.setGroup( "General" );
67//useWordWrap_CheckBox 71//useWordWrap_CheckBox
68 useIcons=TRUE; 72 useIcons=TRUE;
69#else 73#else
70 74
71 config.setGroup( "General" ); 75 config.setGroup( "General" );
72 QString s_Split=config.readEntry("Splitter", "TRUE" ); 76 QString s_Split=config.readEntry("Splitter", "TRUE" );
73 QWidget *d = QApplication::desktop(); 77 QWidget *d = QApplication::desktop();
74 int width=d->width(); 78 int width=d->width();
75 int height=d->height(); 79 int height=d->height();
76 int w=0, h=0; 80 int w=0, h=0;
@@ -124,137 +128,137 @@ void Gutenbrowser::initConfig() {
124 useIcons=FALSE; 128 useIcons=FALSE;
125#endif 129#endif
126// #if defined(_WS_WIN_) 130// #if defined(_WS_WIN_)
127// move( posX-4, posY-20); 131// move( posX-4, posY-20);
128// #endif 132// #endif
129 133
130 config.setGroup( "Browser" ); 134 config.setGroup( "Browser" );
131 brow = config.readEntry( "Preferred", "Opera"); 135 brow = config.readEntry( "Preferred", "Opera");
132 config.setGroup( "FTPsite" ); // ftp server config 136 config.setGroup( "FTPsite" ); // ftp server config
133 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); 137 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
134// ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); 138// ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) );
135 ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); 139 ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) );
136 ftp_host=ftp_host.stripWhiteSpace(); 140 ftp_host=ftp_host.stripWhiteSpace();
137 141
138 ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); 142 ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
139 143
140 //bool ok2; 144 //bool ok2;
141 QString temp; 145 QString temp;
142 QString copying; 146 QString copying;
143 copying=""; 147 copying="";
144 148
145 config.setGroup("General"); 149 config.setGroup("General");
146 QString qExit; 150 QString qExit;
147 qExit=config.readEntry("queryExit","TRUE"); 151 qExit=config.readEntry("queryExit","TRUE");
148 if(qExit=="TRUE") { 152 if(qExit=="TRUE") {
149 b_queryExit=TRUE; 153 b_queryExit=TRUE;
150// qDebug("Please query before leaving the library."); 154// odebug << "Please query before leaving the library." << oendl;
151 } else { 155 } else {
152// qDebug("Please DO NOT query before leaving the library."); 156// odebug << "Please DO NOT query before leaving the library." << oendl;
153 b_queryExit=FALSE; 157 b_queryExit=FALSE;
154 } 158 }
155// bookmarks 159// bookmarks
156// config.setGroup("Titles"); 160// config.setGroup("Titles");
157// QString tmpTitle=config.readEntry(file_name,""); 161// QString tmpTitle=config.readEntry(file_name,"");
158 162
159 163
160}// end initConfig() 164}// end initConfig()
161 165
162void Gutenbrowser::initMenuBar() 166void Gutenbrowser::initMenuBar()
163{ 167{
164// qDebug("Starting menu init."); 168// odebug << "Starting menu init." << oendl;
165 // menuBar entry fileMenu 169 // menuBar entry fileMenu
166 menubar = new QPEMenuBar(this); 170 menubar = new QPEMenuBar(this);
167 171
168 fileMenu=new QPopupMenu(); 172 fileMenu=new QPopupMenu();
169 fileMenu->insertItem(Resource::loadPixmap("gutenbrowser/openbook"), 173 fileMenu->insertItem(Resource::loadPixmap("gutenbrowser/openbook"),
170 "Open Local Library...", this, SLOT( OpenBtn()) ); 174 "Open Local Library...", this, SLOT( OpenBtn()) );
171// fileMenu->insertItem("Download FTPSite", this, SLOT( downloadFtpList()) ); 175// fileMenu->insertItem("Download FTPSite", this, SLOT( downloadFtpList()) );
172 fileMenu->insertItem( Resource::loadPixmap("home"), 176 fileMenu->insertItem( Resource::loadPixmap("home"),
173 "Download Library Index", this, SLOT( downloadLibIndex()) ); 177 "Download Library Index", this, SLOT( downloadLibIndex()) );
174 fileMenu->insertItem( Resource::loadPixmap("quit"), 178 fileMenu->insertItem( Resource::loadPixmap("quit"),
175 "Quit Gutenbrowser...", this, SLOT( ByeBye()) ); 179 "Quit Gutenbrowser...", this, SLOT( ByeBye()) );
176 // menuBar entry editMenu 180 // menuBar entry editMenu
177 181
178 editMenu=new QPopupMenu(); 182 editMenu=new QPopupMenu();
179 183
180 editMenu->insertItem(Resource::loadPixmap("up"), "Top", 184 editMenu->insertItem(Resource::loadPixmap("up"), "Top",
181 this, SLOT(TopBtn()) ); 185 this, SLOT(TopBtn()) );
182 editMenu->insertItem( Resource::loadPixmap("back"), "Beginning", 186 editMenu->insertItem( Resource::loadPixmap("back"), "Beginning",
183 this, SLOT(doBeginBtn()) ); 187 this, SLOT(doBeginBtn()) );
184 editMenu->insertItem( Resource::loadPixmap("gutenbrowser/search"), "Search", 188 editMenu->insertItem( Resource::loadPixmap("gutenbrowser/search"), "Search",
185 this, SLOT(SearchBtn()) ); 189 this, SLOT(SearchBtn()) );
186 190
187 editMenu->insertItem("Clear", this, SLOT(ClearEdit()) ); 191 editMenu->insertItem("Clear", this, SLOT(ClearEdit()) );
188 192
189 optionsMenu= new QPopupMenu(); 193 optionsMenu= new QPopupMenu();
190 optionsMenu->insertItem( Resource::loadPixmap("gutenbrowser/configure"), 194 optionsMenu->insertItem( Resource::loadPixmap("gutenbrowser/configure"),
191 "Configure", this, SLOT(doOptions()) ); 195 "Configure", this, SLOT(doOptions()) );
192 196
193 donateMenu = new QPopupMenu(); 197 donateMenu = new QPopupMenu();
194// donateMenu->insertItem("Gutenberg", this, SLOT(donateGutenberg()) ); 198// donateMenu->insertItem("Gutenberg", this, SLOT(donateGutenberg()) );
195 donateMenu->insertItem( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), 199 donateMenu->insertItem( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"),
196 "Gutenbrowser Developer", this, SLOT(infoGutenbrowser()) ); 200 "Gutenbrowser Developer", this, SLOT(infoGutenbrowser()) );
197 201
198 menubar->insertItem("File", fileMenu); 202 menubar->insertItem("File", fileMenu);
199 menubar->insertItem("Page", editMenu); 203 menubar->insertItem("Page", editMenu);
200 menubar->insertItem("Options", optionsMenu); 204 menubar->insertItem("Options", optionsMenu);
201// menubar->insertItem("More Info", donateMenu); 205// menubar->insertItem("More Info", donateMenu);
202 206
203 menu->addWidget( menubar,0); 207 menu->addWidget( menubar,0);
204 208
205 topLayout->addLayout( menu, 0); 209 topLayout->addLayout( menu, 0);
206} 210}
207 211
208void Gutenbrowser::initButtonBar() 212void Gutenbrowser::initButtonBar()
209{ 213{
210//qDebug("Starting buttonbar init."); 214//odebug << "Starting buttonbar init." << oendl;
211 215
212 OpenButton = new QPushButton( this, "OpenButton" ); 216 OpenButton = new QPushButton( this, "OpenButton" );
213 OpenButton->setFocusPolicy( QWidget::TabFocus ); 217 OpenButton->setFocusPolicy( QWidget::TabFocus );
214 218
215 LibraryButton = new QPushButton( this, "LibraryButton" ); 219 LibraryButton = new QPushButton( this, "LibraryButton" );
216 LibraryButton->setFocusPolicy( QWidget::TabFocus ); 220 LibraryButton->setFocusPolicy( QWidget::TabFocus );
217 221
218 BackButton = new QPushButton( this, "BackButton" ); 222 BackButton = new QPushButton( this, "BackButton" );
219 BackButton->setFocusPolicy( QWidget::TabFocus ); 223 BackButton->setFocusPolicy( QWidget::TabFocus );
220 BackButton->setAutoRepeat(TRUE); 224 BackButton->setAutoRepeat(TRUE);
221 225
222 ForwardButton = new QPushButton( this, "ForwardButton" ); 226 ForwardButton = new QPushButton( this, "ForwardButton" );
223 ForwardButton->setFocusPolicy( QWidget::TabFocus ); 227 ForwardButton->setFocusPolicy( QWidget::TabFocus );
224// ForwardButton->setAutoRepeat(TRUE); 228// ForwardButton->setAutoRepeat(TRUE);
225 229
226 SearchButton = new QPushButton( this, "SearchButton" ); 230 SearchButton = new QPushButton( this, "SearchButton" );
227 SearchButton->setFocusPolicy( QWidget::TabFocus ); 231 SearchButton->setFocusPolicy( QWidget::TabFocus );
228 232
229 setBookmarkButton = new QPushButton( this, "setBookmark" ); 233 setBookmarkButton = new QPushButton( this, "setBookmark" );
230 setBookmarkButton->setFocusPolicy( QWidget::TabFocus ); 234 setBookmarkButton->setFocusPolicy( QWidget::TabFocus );
231 235
232 lastBmkButton = new MenuButton( this, "lastBmkButton" ); 236 lastBmkButton = new MenuButton( this, "lastBmkButton" );
233 lastBmkButton->setFocusPolicy( QWidget::TabFocus ); 237 lastBmkButton->setFocusPolicy( QWidget::TabFocus );
234 238
235 bookmarksMenu = new QPopupMenu(); 239 bookmarksMenu = new QPopupMenu();
236 bookmarksMenu->insertItem("Last Set", this, SLOT(Bookmark( int) )); 240 bookmarksMenu->insertItem("Last Set", this, SLOT(Bookmark( int) ));
237 241
238 lastBmkButton->setPopup(bookmarksMenu); 242 lastBmkButton->setPopup(bookmarksMenu);
239 243
240 dictionaryButton = new QPushButton( this, "dictionaryButton" ); 244 dictionaryButton = new QPushButton( this, "dictionaryButton" );
241 dictionaryButton->setFocusPolicy( QWidget::TabFocus ); 245 dictionaryButton->setFocusPolicy( QWidget::TabFocus );
242 246
243 InfoBar = new QPushButton( this, "Info_Bar" ); 247 InfoBar = new QPushButton( this, "Info_Bar" );
244// qDebug("Infobar"); 248// odebug << "Infobar" << oendl;
245// if(!useSplitter) { 249// if(!useSplitter) {
246 250
247 buttonsHidden=FALSE; 251 buttonsHidden=FALSE;
248 buttons2->setSpacing(2); 252 buttons2->setSpacing(2);
249 buttons2->addWidget(OpenButton, 0, AlignCenter); 253 buttons2->addWidget(OpenButton, 0, AlignCenter);
250 buttons2->addWidget(LibraryButton, 0, AlignCenter); 254 buttons2->addWidget(LibraryButton, 0, AlignCenter);
251 buttons2->addWidget(BackButton, 0, AlignCenter); 255 buttons2->addWidget(BackButton, 0, AlignCenter);
252 buttons2->addWidget(ForwardButton, 0, AlignCenter); 256 buttons2->addWidget(ForwardButton, 0, AlignCenter);
253 buttons2->addWidget(SearchButton, 0, AlignCenter); 257 buttons2->addWidget(SearchButton, 0, AlignCenter);
254 buttons2->addWidget(setBookmarkButton, 0, AlignCenter); 258 buttons2->addWidget(setBookmarkButton, 0, AlignCenter);
255 buttons2->addWidget(lastBmkButton, 0, AlignCenter); 259 buttons2->addWidget(lastBmkButton, 0, AlignCenter);
256 buttons2->addWidget(dictionaryButton, 0, AlignCenter); 260 buttons2->addWidget(dictionaryButton, 0, AlignCenter);
257 buttons2->addWidget(InfoBar, 0, AlignCenter); 261 buttons2->addWidget(InfoBar, 0, AlignCenter);
258 262
259 topLayout->setSpacing(0); 263 topLayout->setSpacing(0);
260 topLayout->addLayout( buttons2,0); 264 topLayout->addLayout( buttons2,0);
@@ -263,50 +267,50 @@ void Gutenbrowser::initButtonBar()
263 267
264/* STATUSBAR*/ 268/* STATUSBAR*/
265void Gutenbrowser::initStatusBar() 269void Gutenbrowser::initStatusBar()
266{ 270{
267// #ifndef Q_WS_QWS 271// #ifndef Q_WS_QWS
268 272
269// statusBar = new QStatusBar( this, "Status Bar"); 273// statusBar = new QStatusBar( this, "Status Bar");
270// statusBar->message(IDS_STATUS_DEFAULT, 2000); 274// statusBar->message(IDS_STATUS_DEFAULT, 2000);
271// #endif 275// #endif
272} 276}
273 277
274void Gutenbrowser::initView() 278void Gutenbrowser::initView()
275{ 279{
276 // set the main widget here 280 // set the main widget here
277// QFont defaultFont( "charter", 10, 50, 0 ); 281// QFont defaultFont( "charter", 10, 50, 0 );
278 Lview = new MultiLine_Ex(this); 282 Lview = new MultiLine_Ex(this);
279 283
280 Config cfg("Gutenbrowser"); 284 Config cfg("Gutenbrowser");
281 cfg.setGroup("Font"); 285 cfg.setGroup("Font");
282 286
283 FontDatabase fdb; 287 FontDatabase fdb;
284 QFont defaultFont=Lview->font(); 288 QFont defaultFont=Lview->font();
285 QFontInfo fontInfo(defaultFont); 289 QFontInfo fontInfo(defaultFont);
286 290
287 QString family = cfg.readEntry("Family", fontInfo.family()); 291 QString family = cfg.readEntry("Family", fontInfo.family());
288 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 292 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
289 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 293 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
290 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 294 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
291 295
292 defaultFont = fdb.font(family,style,i_size,charSet); 296 defaultFont = fdb.font(family,style,i_size,charSet);
293 297
294 QString italic=cfg.readEntry("Italic","FALSE"); 298 QString italic=cfg.readEntry("Italic","FALSE");
295 if(italic=="TRUE") { 299 if(italic=="TRUE") {
296 qDebug("Set Italic font"); 300 odebug << "Set Italic font" << oendl;
297 defaultFont = fdb.font(family,"Regular",i_size,charSet); //workaround 301 defaultFont = fdb.font(family,"Regular",i_size,charSet); //workaround
298 defaultFont.setItalic(TRUE); 302 defaultFont.setItalic(TRUE);
299 } 303 }
300 304
301 Lview->setFont( defaultFont); 305 Lview->setFont( defaultFont);
302 update(); 306 update();
303 307
304 cfg.setGroup("General"); 308 cfg.setGroup("General");
305 309
306 if( cfg.readBoolEntry("WordWrap", 1)) { 310 if( cfg.readBoolEntry("WordWrap", 1)) {
307 Lview->setWordWrap(QMultiLineEdit::WidgetWidth); 311 Lview->setWordWrap(QMultiLineEdit::WidgetWidth);
308 useWrap=true; 312 useWrap=true;
309 } else { 313 } else {
310 Lview->setWordWrap(QMultiLineEdit::NoWrap); 314 Lview->setWordWrap(QMultiLineEdit::NoWrap);
311 useWrap=false; 315 useWrap=false;
312 } 316 }
diff --git a/noncore/apps/opie-gutenbrowser/helpme.cpp b/noncore/apps/opie-gutenbrowser/helpme.cpp
index 6a9b8c0..53e0236 100644
--- a/noncore/apps/opie-gutenbrowser/helpme.cpp
+++ b/noncore/apps/opie-gutenbrowser/helpme.cpp
@@ -1,41 +1,46 @@
1/*************************************************************************** 1/***************************************************************************
2 helpme.cpp - description 2 helpme.cpp - description
3 ------------------- 3 -------------------
4 begin : Tue Jul 25 2000 4 begin : Tue Jul 25 2000
5 begin : Sat Dec 4 1999 5 begin : Sat Dec 4 1999
6 copyright : (C) 2000 -2004 by llornkcor 6 copyright : (C) 2000 -2004 by llornkcor
7 email : ljp@llornkcor.com 7 email : ljp@llornkcor.com
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 <qpe/qcopenvelope_qws.h>
18#include <qpe/qpeapplication.h>
19 17
20#include "helpme.h" 18#include "helpme.h"
21#include "helpwindow.h" 19#include "helpwindow.h"
22 20
21/* OPIE */
22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/qpeapplication.h>
24#include <opie2/odebug.h>
25
26/* QT */
23#include <qprogressdialog.h> 27#include <qprogressdialog.h>
24#include <qlayout.h> 28#include <qlayout.h>
25 29
30/* STD */
26#include <sys/stat.h> 31#include <sys/stat.h>
27#include <unistd.h> 32#include <unistd.h>
28 33
29HelpMe::HelpMe(QWidget *parent, QString name ) : QDialog(parent,name) 34HelpMe::HelpMe(QWidget *parent, QString name ) : QDialog(parent,name)
30{ 35{
31 local_library = ( QDir::homeDirPath ())+"/Applications/gutenbrowser/"; 36 local_library = ( QDir::homeDirPath ())+"/Applications/gutenbrowser/";
32 setCaption(tr("Gutenbrowser About " VERSION)); 37 setCaption(tr("Gutenbrowser About " VERSION));
33 38
34 QGridLayout *layout = new QGridLayout( this ); 39 QGridLayout *layout = new QGridLayout( this );
35 layout->setSpacing( 4 ); 40 layout->setSpacing( 4 );
36 layout->setMargin( 4 ); 41 layout->setMargin( 4 );
37 42
38 Edit = new QMultiLineEdit(this, ""); 43 Edit = new QMultiLineEdit(this, "");
39 Edit->setReadOnly(true); 44 Edit->setReadOnly(true);
40 Edit->append(tr("Based on gutenbook.pl, available from http://www.gutenbook.org")); 45 Edit->append(tr("Based on gutenbook.pl, available from http://www.gutenbook.org"));
41 Edit->append(tr("Much appreciation to Lee Burgess,")); 46 Edit->append(tr("Much appreciation to Lee Burgess,"));
@@ -98,25 +103,25 @@ void HelpMe::goToURL3()
98 url = "http://www.gutenbook.org"; 103 url = "http://www.gutenbook.org";
99 goGetit( url); 104 goGetit( url);
100} 105}
101 106
102void HelpMe::goGetit( QString url) 107void HelpMe::goGetit( QString url)
103{ 108{
104 HelpWindow *help = new HelpWindow( url, ".", 0, "gutenbrowser"); 109 HelpWindow *help = new HelpWindow( url, ".", 0, "gutenbrowser");
105 help->setCaption("Qt Example - Helpviewer"); 110 help->setCaption("Qt Example - Helpviewer");
106 help->showMaximized(); 111 help->showMaximized();
107 help->show(); 112 help->show();
108} 113}
109 114
110void HelpMe::help() 115void HelpMe::help()
111{ 116{
112 QString msg ; 117 QString msg ;
113 msg=QPEApplication::qpeDir()+"help/html/gutenbrowser-index.html"; // or where ever this ends up to be 118 msg=QPEApplication::qpeDir()+"help/html/gutenbrowser-index.html"; // or where ever this ends up to be
114qDebug(msg); 119odebug << msg << oendl;
115 QString url = "file://"+msg; 120 QString url = "file://"+msg;
116 goGetit( url); 121 goGetit( url);
117 122
118// QCopEnvelope e("QPE/Application/helpbrowser", "setDocument(QString)" ); 123// QCopEnvelope e("QPE/Application/helpbrowser", "setDocument(QString)" );
119// e << msg; 124// e << msg;
120 125
121// goGetit( msg); 126// goGetit( msg);
122} 127}
diff --git a/noncore/apps/opie-gutenbrowser/main.cpp b/noncore/apps/opie-gutenbrowser/main.cpp
index 5c3348c..71c836d 100644
--- a/noncore/apps/opie-gutenbrowser/main.cpp
+++ b/noncore/apps/opie-gutenbrowser/main.cpp
@@ -24,33 +24,33 @@ OPIE_EXPORT_APP( OApplicationFactory<Gutenbrowser> )
24// #include <qstring.h> 24// #include <qstring.h>
25// // #include <stdio.h> 25// // #include <stdio.h>
26// // #include <stdlib.h> 26// // #include <stdlib.h>
27 27
28// int main(int argc, char *argv[]){ 28// int main(int argc, char *argv[]){
29 // QPEApplication a(argc, argv); 29 // QPEApplication a(argc, argv);
30// // char * psz; 30// // char * psz;
31// // if (argc > 1) { 31// // if (argc > 1) {
32// // for( int i=0; i < argc; i++) { 32// // for( int i=0; i < argc; i++) {
33// // psz = argv[i]; 33// // psz = argv[i];
34// // if( psz[0] == '-' || psz[0] == '/' ) { 34// // if( psz[0] == '-' || psz[0] == '/' ) {
35// // // The next character is the option. 35// // // The next character is the option.
36// // switch( psz[1] ) 36// // switch( psz[1] )
37// // { 37// // {
38// // case 'v': // help 38// // case 'v': // help
39// // printf("Gutenbrowser: "VERSION"\n"); 39// // printf("Gutenbrowser: "VERSION"\n");
40// // // qDebug("Gutenbrowser: "VERSION); 40// // // odebug << "Gutenbrowser: "VERSION << oendl;
41// // // return 0; 41// // // return 0;
42// // break; 42// // break;
43// // case 't': // current time 19:34:20 04/03/00 43// // case 't': // current time 19:34:20 04/03/00
44// // // return 0; 44// // // return 0;
45// // break; 45// // break;
46// // case 'f': // 46// // case 'f': //
47// // // file_Name=argv[i+1]; 47// // // file_Name=argv[i+1];
48// // break; 48// // break;
49// // } 49// // }
50// // } 50// // }
51// // } 51// // }
52// // } 52// // }
53// // QNetworkProtocol::registerNetworkProtocol("http", new QNetworkProtocolFactory<Http>); 53// // QNetworkProtocol::registerNetworkProtocol("http", new QNetworkProtocolFactory<Http>);
54// // qInitNetworkProtocols();//registers ftp protocol // for now 54// // qInitNetworkProtocols();//registers ftp protocol // for now
55 // Gutenbrowser *gutenbrowser=new Gutenbrowser(); 55 // Gutenbrowser *gutenbrowser=new Gutenbrowser();
56// // a.setMainWidget(gutenbrowser); 56// // a.setMainWidget(gutenbrowser);
diff --git a/noncore/apps/opie-gutenbrowser/openetext.cpp b/noncore/apps/opie-gutenbrowser/openetext.cpp
index bd44ce6..0267416 100644
--- a/noncore/apps/opie-gutenbrowser/openetext.cpp
+++ b/noncore/apps/opie-gutenbrowser/openetext.cpp
@@ -5,46 +5,49 @@
5 copyright : (C) 2000 -2004 by llornkcor 5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 ***************************************************************************/ 7 ***************************************************************************/
8/*************************************************************************** 8/***************************************************************************
9 * This program is free software; you can redistribute it and/or modify * 9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by * 10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or * 11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. * 12 * (at your option) any later version. *
13 ***************************************************************************/ 13 ***************************************************************************/
14 14
15#include "gutenbrowser.h" 15#include "gutenbrowser.h"
16#include "openetext.h" 16#include "openetext.h"
17#include "editTitle.h" 17#include "editTitle.h"
18 18
19/* OPIE */ 19/* OPIE */
20#include <opie2/ofiledialog.h> 20#include <opie2/ofiledialog.h>
21#include <opie2/odebug.h>
21#include <qpe/applnk.h> 22#include <qpe/applnk.h>
22#include <qpe/config.h> 23#include <qpe/config.h>
23#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
24using namespace Opie::Ui; 25using namespace Opie::Ui;
25 26
26#include <stdlib.h> 27/* QT */
27#include <qtextstream.h> 28#include <qtextstream.h>
28#include <qfileinfo.h> 29#include <qfileinfo.h>
29 30
31/* STD */
30#if defined(_WS_WIN_) 32#if defined(_WS_WIN_)
31#include <windows.h> 33#include <windows.h>
32#else 34#else
33#include <unistd.h> 35#include <unistd.h>
34#include "sys/stat.h" 36#include <stdlib.h>
37#include <sys/stat.h>
35#endif 38#endif
36 39
37OpenEtext::OpenEtext(QWidget *parent, QString name) : QDialog(parent,name,true) 40OpenEtext::OpenEtext(QWidget *parent, QString name) : QDialog(parent,name,true)
38{ 41{
39 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 42 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
40 local_index=local_library+"GUTINDEX.ALL"; 43 local_index=local_library+"GUTINDEX.ALL";
41 initDialog(); 44 initDialog();
42 connect( QListBox_1, SIGNAL(selected ( int)),this, SLOT(select_title(int)) ); 45 connect( QListBox_1, SIGNAL(selected ( int)),this, SLOT(select_title(int)) );
43 46
44 getTitles(); 47 getTitles();
45} 48}
46 49
47OpenEtext::~OpenEtext() 50OpenEtext::~OpenEtext()
48{ 51{
49} 52}
50 53
@@ -121,192 +124,192 @@ OpenFileButton->setDown(TRUE);
121 Config cfg("Gutenbrowser"); 124 Config cfg("Gutenbrowser");
122 cfg. setGroup ( "View" ); 125 cfg. setGroup ( "View" );
123 QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); 126 QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir());
124 QMap<QString, QStringList> map; 127 QMap<QString, QStringList> map;
125 map.insert(tr("All"), QStringList() ); 128 map.insert(tr("All"), QStringList() );
126 QStringList text; 129 QStringList text;
127 text << "text/*"; 130 text << "text/*";
128 map.insert(tr("Text"), text ); 131 map.insert(tr("Text"), text );
129 text << "*"; 132 text << "*";
130 map.insert(tr("All"), text ); 133 map.insert(tr("All"), text );
131 134
132 QString str = OFileDialog::getOpenFileName( 2, dir , QString::null, map); 135 QString str = OFileDialog::getOpenFileName( 2, dir , QString::null, map);
133 136
134 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) { 137 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) {
135 filer = str; 138 filer = str;
136 139
137 qDebug("Open file: "+str); 140 odebug << "Open file: "+str << oendl;
138 141
139 // QStringList::ConstIterator f; 142 // QStringList::ConstIterator f;
140// QString fileTemp; 143// QString fileTemp;
141// for ( f = fileList.begin(); f != fileList.end(); f++ ) { 144// for ( f = fileList.begin(); f != fileList.end(); f++ ) {
142// fileTemp = *f; 145// fileTemp = *f;
143// fileTemp.right( fileTemp.length()-5); 146// fileTemp.right( fileTemp.length()-5);
144// fileName = fileTemp; 147// fileName = fileTemp;
145// if( !fileName.isEmpty() ){ 148// if( !fileName.isEmpty() ){
146// filer = fileName; 149// filer = fileName;
147// } else { //filename is empty 150// } else { //filename is empty
148// // QString sMsg; 151// // QString sMsg;
149// // sMsg = "Error opening library filelist "+fileName; 152// // sMsg = "Error opening library filelist "+fileName;
150// } 153// }
151 154
152 if( filer.right(4) == ".txt" 155 if( filer.right(4) == ".txt"
153 || filer.right(4) == ".TXT" 156 || filer.right(4) == ".TXT"
154 || filer.right(4) == ".etx" 157 || filer.right(4) == ".etx"
155 || filer.right(4) == ".ETX" 158 || filer.right(4) == ".ETX"
156 || filer.right(4) == ".etx" 159 || filer.right(4) == ".etx"
157 || filer.right(4) == ".ETX" 160 || filer.right(4) == ".ETX"
158 || filer.right(4) == ".zip" 161 || filer.right(4) == ".zip"
159 || filer.right(4) == ".ZIP" ) { 162 || filer.right(4) == ".ZIP" ) {
160 QFileInfo zipFile( filer); 163 QFileInfo zipFile( filer);
161 QString s_fileName = zipFile.fileName(); 164 QString s_fileName = zipFile.fileName();
162 QString cmd; 165 QString cmd;
163 166
164 if( s_fileName.right(4) == ".zip") { // unzip that sucker.... 167 if( s_fileName.right(4) == ".zip") { // unzip that sucker....
165 s_fileName = s_fileName.left( s_fileName.length() - 4); 168 s_fileName = s_fileName.left( s_fileName.length() - 4);
166 if( chdir((const char*)local_library.latin1())!=0) 169 if( chdir((const char*)local_library.latin1())!=0)
167 qDebug("chdir failed.");// QString cmd = "gunzip -d " + filer + " -d " + local_library; 170 odebug << "chdir failed." << oendl; // QString cmd = "gunzip -d " + filer + " -d " + local_library;
168 cmd = "gunzip -S .zip " + filer; 171 cmd = "gunzip -S .zip " + filer;
169 fileName = local_library + s_fileName + ".txt"; 172 fileName = local_library + s_fileName + ".txt";
170 system( cmd); 173 system( cmd);
171 } 174 }
172// this renames the .txt to .etx!! 175// this renames the .txt to .etx!!
173 else /*if( s_fileName.right(4) == ".txt" || if( s_fileName.right(4) == ".TXT"))*/ { 176 else /*if( s_fileName.right(4) == ".txt" || if( s_fileName.right(4) == ".TXT"))*/ {
174// qDebug("Filename is "+fileName); 177// odebug << "Filename is "+fileName << oendl;
175 s_fileName = fileName; 178 s_fileName = fileName;
176 s_fileName.replace( s_fileName.length()-3,3,"gtn");// s_fileName.replace( s_fileName.length()-3,3,"etx"); 179 s_fileName.replace( s_fileName.length()-3,3,"gtn");// s_fileName.replace( s_fileName.length()-3,3,"etx");
177 rename(fileName.latin1(),s_fileName.latin1()); 180 rename(fileName.latin1(),s_fileName.latin1());
178 fileName = s_fileName; 181 fileName = s_fileName;
179// qDebug("Filename is now "+fileName); 182// odebug << "Filename is now "+fileName << oendl;
180 } 183 }
181 } else 184 } else
182 fileName = str; 185 fileName = str;
183 186
184 FindTitle(fileName); 187 FindTitle(fileName);
185 188
186 QFileInfo fi( fileName); 189 QFileInfo fi( fileName);
187 name_file = fi.fileName(); 190 name_file = fi.fileName();
188 name_file = name_file.left(name_file.length() - 4); 191 name_file = name_file.left(name_file.length() - 4);
189 192
190 qDebug("Setting doclink"); 193 odebug << "Setting doclink" << oendl;
191 DocLnk lnk; 194 DocLnk lnk;
192 qDebug("name is " + name_file); 195 odebug << "name is " + name_file << oendl;
193 lnk.setName(name_file); //sets file name 196 lnk.setName(name_file); //sets file name
194 qDebug("Title is "+title); 197 odebug << "Title is "+title << oendl;
195 lnk.setComment(title); 198 lnk.setComment(title);
196 199
197 QListBox_1->clear(); 200 QListBox_1->clear();
198 getTitles(); 201 getTitles();
199 qDebug("Filename is "+fileName); 202 odebug << "Filename is "+fileName << oendl;
200 lnk.setFile(fileName); //sets File property 203 lnk.setFile(fileName); //sets File property
201 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D 204 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
202 lnk.setExec(fileName); 205 lnk.setExec(fileName);
203 lnk.setIcon("gutenbrowser/Gutenbrowser"); 206 lnk.setIcon("gutenbrowser/Gutenbrowser");
204 if(!lnk.writeLink()) 207 if(!lnk.writeLink())
205 qDebug("Writing doclink did not work"); 208 odebug << "Writing doclink did not work" << oendl;
206 209
207 } // end of for each file name.... 210 } // end of for each file name....
208 OpenFileButton->setDown(FALSE); 211 OpenFileButton->setDown(FALSE);
209} 212}
210 213
211/* 214/*
212find the title in the config file */ 215find the title in the config file */
213bool OpenEtext::FindTitle( QString filename) 216bool OpenEtext::FindTitle( QString filename)
214{ 217{
215 Config config("Gutenbrowser"); 218 Config config("Gutenbrowser");
216 config.setGroup( "Files" ); 219 config.setGroup( "Files" );
217 QString s_numofFiles = config.readEntry("NumberOfFiles", "0"); 220 QString s_numofFiles = config.readEntry("NumberOfFiles", "0");
218 int i_numofFiles = s_numofFiles.toInt(); 221 int i_numofFiles = s_numofFiles.toInt();
219 222
220 QFileInfo fi(filename); 223 QFileInfo fi(filename);
221 name = fi.fileName(); 224 name = fi.fileName();
222 qDebug("filename to open is " + name); 225 odebug << "filename to open is " + name << oendl;
223 QFile indexLib( filename); 226 QFile indexLib( filename);
224 bool findCheck = FALSE; 227 bool findCheck = FALSE;
225 // int Titlenumber=0; 228 // int Titlenumber=0;
226 229
227 if ( indexLib.open( IO_ReadOnly) ) { 230 if ( indexLib.open( IO_ReadOnly) ) {
228 qDebug("file opened successfully"); 231 odebug << "file opened successfully" << oendl;
229 QTextStream indexStream( &indexLib ); 232 QTextStream indexStream( &indexLib );
230 QString target = "Project Gutenberg Etext of"; 233 QString target = "Project Gutenberg Etext of";
231 QString target2 = "Project Gutenberg Etext"; 234 QString target2 = "Project Gutenberg Etext";
232 QString target3 = "Project Gutenberg's Etext of"; 235 QString target3 = "Project Gutenberg's Etext of";
233 QString target4 = "Project Gutenberg's Etext"; 236 QString target4 = "Project Gutenberg's Etext";
234 QString indexLine; 237 QString indexLine;
235 while ( !indexStream.eof() ) { 238 while ( !indexStream.eof() ) {
236 // until end of file.. 239 // until end of file..
237 indexLine = indexStream.readLine(); 240 indexLine = indexStream.readLine();
238 if( indexLine.find(target, 0, TRUE) > -1 && !findCheck) {findCheck = TRUE; 241 if( indexLine.find(target, 0, TRUE) > -1 && !findCheck) {findCheck = TRUE;
239 title = indexLine.mid( indexLine.find(target, 0, TRUE) + (target.length()) , indexLine.find("\r", 0, TRUE)); 242 title = indexLine.mid( indexLine.find(target, 0, TRUE) + (target.length()) , indexLine.find("\r", 0, TRUE));
240 title = title.left( title.find( "*",0, TRUE)); 243 title = title.left( title.find( "*",0, TRUE));
241 title = title.stripWhiteSpace (); 244 title = title.stripWhiteSpace ();
242// qDebug("Found the title 1 and it is %s", title.latin1()); 245// odebug << "Found the title 1 and it is " << title << "" << oendl;
243// QListBox_1->insertItem ( title); 246// QListBox_1->insertItem ( title);
244 } 247 }
245 if( indexLine.find( target2, 0, TRUE) > -1 && !findCheck) { 248 if( indexLine.find( target2, 0, TRUE) > -1 && !findCheck) {
246 findCheck = TRUE; 249 findCheck = TRUE;
247 title = indexLine.mid( indexLine.find( target2, 0, TRUE ) + ( target2.length()) , indexLine.find("\r", 0, TRUE) ); 250 title = indexLine.mid( indexLine.find( target2, 0, TRUE ) + ( target2.length()) , indexLine.find("\r", 0, TRUE) );
248 title = title.left( title.find( "*",0, TRUE)); 251 title = title.left( title.find( "*",0, TRUE));
249 title = title.stripWhiteSpace (); 252 title = title.stripWhiteSpace ();
250// qDebug("Found the title 2 and it is %s", title.latin1()); 253// odebug << "Found the title 2 and it is " << title << "" << oendl;
251// QListBox_1->insertItem ( title); 254// QListBox_1->insertItem ( title);
252 } 255 }
253 if( indexLine.find( target3, 0, TRUE) > -1 && !findCheck) { 256 if( indexLine.find( target3, 0, TRUE) > -1 && !findCheck) {
254 findCheck = TRUE; 257 findCheck = TRUE;
255 title = indexLine.mid( indexLine.find( target3, 0, TRUE) + ( target3.length()) , indexLine.find("\r", 0, TRUE)); 258 title = indexLine.mid( indexLine.find( target3, 0, TRUE) + ( target3.length()) , indexLine.find("\r", 0, TRUE));
256 title = title.left( title.find( "*",0, TRUE)); 259 title = title.left( title.find( "*",0, TRUE));
257 title = title.stripWhiteSpace (); 260 title = title.stripWhiteSpace ();
258// qDebug("Found the title 3 and it is %s", title.latin1()); 261// odebug << "Found the title 3 and it is " << title << "" << oendl;
259 } 262 }
260 if( indexLine.find( target4, 0, TRUE) > -1 && !findCheck) { 263 if( indexLine.find( target4, 0, TRUE) > -1 && !findCheck) {
261 findCheck = TRUE; 264 findCheck = TRUE;
262 title = indexLine.mid( indexLine.find( target4, 0, TRUE) + ( target4.length()) , indexLine.find("\r", 0, TRUE)); 265 title = indexLine.mid( indexLine.find( target4, 0, TRUE) + ( target4.length()) , indexLine.find("\r", 0, TRUE));
263 title = title.left( title.find( "*",0, TRUE)); 266 title = title.left( title.find( "*",0, TRUE));
264 title = title.stripWhiteSpace (); 267 title = title.stripWhiteSpace ();
265// qDebug("Found the title 4 and it is %s", title.latin1()); 268// odebug << "Found the title 4 and it is " << title << "" << oendl;
266 } 269 }
267 } //endof file 270 } //endof file
268 indexLib.close(); 271 indexLib.close();
269 272
270 if( !findCheck || title.length() < 2) { 273 if( !findCheck || title.length() < 2) {
271 qDebug("Trying hard to find title from GUTINDEX.ALL"); 274 odebug << "Trying hard to find title from GUTINDEX.ALL" << oendl;
272 title = titleFromLibrary( filename); 275 title = titleFromLibrary( filename);
273 findCheck = TRUE; 276 findCheck = TRUE;
274 } 277 }
275 278
276 if ( checkConf() == false && findCheck == TRUE) { 279 if ( checkConf() == false && findCheck == TRUE) {
277 280
278 config.setGroup( "Files"); 281 config.setGroup( "Files");
279 config.writeEntry("NumberOfFiles",i_numofFiles + 1 ); 282 config.writeEntry("NumberOfFiles",i_numofFiles + 1 );
280 QString interger; 283 QString interger;
281 interger.setNum( i_numofFiles +1); 284 interger.setNum( i_numofFiles +1);
282 config.writeEntry(interger, filename); 285 config.writeEntry(interger, filename);
283 config.setGroup( "Titles" ); 286 config.setGroup( "Titles" );
284 for (int i = 1; i <= i_numofFiles; i++) { //find dup titles in config file 287 for (int i = 1; i <= i_numofFiles; i++) { //find dup titles in config file
285 QString temp; 288 QString temp;
286 temp.setNum(i); 289 temp.setNum(i);
287 config.setGroup( "Files" ); 290 config.setGroup( "Files" );
288 QString ramble = config.readEntry(temp, "" ); 291 QString ramble = config.readEntry(temp, "" );
289 config.setGroup( "Titles" ); 292 config.setGroup( "Titles" );
290 QString title1 = config.readEntry(ramble, ""); 293 QString title1 = config.readEntry(ramble, "");
291 if(title1==title) 294 if(title1==title)
292 title+="1"; 295 title+="1";
293 i= i_numofFiles+1; 296 i= i_numofFiles+1;
294 } 297 }
295 if(title.length()<3) { 298 if(title.length()<3) {
296// qDebug("title is empty"); 299// odebug << "title is empty" << oendl;
297 title="Unknown"; 300 title="Unknown";
298 } 301 }
299 config.writeEntry( filename,title); 302 config.writeEntry( filename,title);
300 } 303 }
301 } else { 304 } else {
302 QString sMsg; 305 QString sMsg;
303 sMsg = "Error opening library file: "+filename; 306 sMsg = "Error opening library file: "+filename;
304 printf( sMsg+"\n"); 307 printf( sMsg+"\n");
305 } 308 }
306 return true; 309 return true;
307} 310}
308 311
309QString OpenEtext::titleFromLibrary( QString fileName) 312QString OpenEtext::titleFromLibrary( QString fileName)
310{ 313{
311 QFile indexLib( local_index); 314 QFile indexLib( local_index);
312 QString target; 315 QString target;
@@ -330,39 +333,39 @@ QString OpenEtext::titleFromLibrary( QString fileName)
330 target = target.left( target.length()-1); 333 target = target.left( target.length()-1);
331 } 334 }
332 } 335 }
333 if ( indexLib.open( IO_ReadOnly) ) { 336 if ( indexLib.open( IO_ReadOnly) ) {
334 // file opened successfully 337 // file opened successfully
335 QTextStream indexStream( &indexLib ); 338 QTextStream indexStream( &indexLib );
336 QString indexLine; 339 QString indexLine;
337 bool findCheck = FALSE; 340 bool findCheck = FALSE;
338 while ( !indexStream.atEnd() ) { // until end of file.. 341 while ( !indexStream.atEnd() ) { // until end of file..
339 indexLine = indexStream.readLine(); 342 indexLine = indexStream.readLine();
340 343
341 if( indexLine.find( target,0,FALSE) > 0 ) { 344 if( indexLine.find( target,0,FALSE) > 0 ) {
342 findCheck = TRUE; 345 findCheck = TRUE;
343 title = indexLine.mid( 9, 50); 346 title = indexLine.mid( 9, 50);
344// title = indexLine.mid( 26, indexLine.length() ); 347// title = indexLine.mid( 26, indexLine.length() );
345 title = title.stripWhiteSpace (); 348 title = title.stripWhiteSpace ();
346// qDebug("Finally Found the title and it is\n %s", title.latin1()); 349// odebug << "Finally Found the title and it is\n " << title << "" << oendl;
347// QListBox_1->insertItem ( title); 350// QListBox_1->insertItem ( title);
348 } 351 }
349 } //end while loop 352 } //end while loop
350 } 353 }
351 else 354 else
352 qDebug("Error opening library index "+ local_index); 355 odebug << "Error opening library index "+ local_index << oendl;
353 return title; 356 return title;
354} 357}
355 358
356bool OpenEtext::checkConf() 359bool OpenEtext::checkConf()
357{ 360{
358 QString file = fileName; 361 QString file = fileName;
359 Config config("Gutenbrowser"); 362 Config config("Gutenbrowser");
360 config.setGroup( "Files" ); 363 config.setGroup( "Files" );
361 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 364 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
362 int i_numofFiles = s_numofFiles.toInt(); 365 int i_numofFiles = s_numofFiles.toInt();
363 366
364 for (int i = 1; i <= i_numofFiles; i++) { 367 for (int i = 1; i <= i_numofFiles; i++) {
365 QString temp; 368 QString temp;
366 temp.setNum(i); 369 temp.setNum(i);
367 config.setGroup( "Files"); 370 config.setGroup( "Files");
368 QString ramble = config.readEntry(temp, "" ); 371 QString ramble = config.readEntry(temp, "" );
@@ -401,33 +404,33 @@ void OpenEtext::removeSelection()
401 s_numofFiles = config.readEntry("NumberOfFiles", "0"); 404 s_numofFiles = config.readEntry("NumberOfFiles", "0");
402 int rem=0; 405 int rem=0;
403 int i_numofFiles = s_numofFiles.toInt(); 406 int i_numofFiles = s_numofFiles.toInt();
404 QString fileNum2; 407 QString fileNum2;
405 QString fileNum; 408 QString fileNum;
406 409
407 for (int i = 1; i <= i_numofFiles; i++) { 410 for (int i = 1; i <= i_numofFiles; i++) {
408 fileNum.setNum(i); 411 fileNum.setNum(i);
409 config.setGroup( "Files" ); 412 config.setGroup( "Files" );
410 413
411 QString s_filename = config.readEntry(fileNum, "" ); 414 QString s_filename = config.readEntry(fileNum, "" );
412 config.setGroup( "Titles" ); 415 config.setGroup( "Titles" );
413 416
414 QString file_title = config.readEntry( s_filename, ""); 417 QString file_title = config.readEntry( s_filename, "");
415 if(title_text == file_title) { 418 if(title_text == file_title) {
416 rem=i; 419 rem=i;
417//qDebug("file title to remove is "+file_title); 420//odebug << "file title to remove is "+file_title << oendl;
418 selFile = s_filename; 421 selFile = s_filename;
419 config.removeEntry( s_filename); //removes file=title 422 config.removeEntry( s_filename); //removes file=title
420 } 423 }
421 } 424 }
422 config.setGroup( "Files" ); 425 config.setGroup( "Files" );
423 426
424 for(int fg = rem; fg < i_numofFiles ; fg++ ) { //this rewrites Files number entry 427 for(int fg = rem; fg < i_numofFiles ; fg++ ) { //this rewrites Files number entry
425 fileNum.setNum(fg); 428 fileNum.setNum(fg);
426 fileNum2.setNum( fg + 1); 429 fileNum2.setNum( fg + 1);
427 430
428 QString s_filename2 = config.readEntry(fileNum2, "" ); 431 QString s_filename2 = config.readEntry(fileNum2, "" );
429 432
430 if (!s_filename2.isEmpty()) { 433 if (!s_filename2.isEmpty()) {
431 config.writeEntry(fileNum, s_filename2 ); 434 config.writeEntry(fileNum, s_filename2 );
432 } 435 }
433 } 436 }
@@ -469,50 +472,50 @@ void OpenEtext::remFile()
469 472
470 QListBox_1->triggerUpdate(true); 473 QListBox_1->triggerUpdate(true);
471} 474}
472 475
473/* 476/*
474sorts the list*/ 477sorts the list*/
475void OpenEtext::scan() { 478void OpenEtext::scan() {
476 479
477 QListBox_1->sort(TRUE); 480 QListBox_1->sort(TRUE);
478 QListBox_1->triggerUpdate(true); 481 QListBox_1->triggerUpdate(true);
479} 482}
480 483
481void OpenEtext::editTitle() { 484void OpenEtext::editTitle() {
482 485
483 int currentItem=QListBox_1->currentItem(); 486 int currentItem=QListBox_1->currentItem();
484 QString title_text = QListBox_1->text( currentItem); 487 QString title_text = QListBox_1->text( currentItem);
485//qDebug("Selected "+title_text); 488//odebug << "Selected "+title_text << oendl;
486 489
487 Config config("Gutenbrowser"); 490 Config config("Gutenbrowser");
488 config.setGroup( "Files" ); 491 config.setGroup( "Files" );
489 s_numofFiles = config.readEntry("NumberOfFiles", "0"); 492 s_numofFiles = config.readEntry("NumberOfFiles", "0");
490 int i_numofFiles = s_numofFiles.toInt(); 493 int i_numofFiles = s_numofFiles.toInt();
491 QString fileNum; 494 QString fileNum;
492 for (int i = 1; i <= i_numofFiles+1; i++) { 495 for (int i = 1; i <= i_numofFiles+1; i++) {
493 496
494 fileNum.setNum(i); 497 fileNum.setNum(i);
495 config.setGroup( "Files" ); 498 config.setGroup( "Files" );
496 QString s_filename = config.readEntry(fileNum, "" ); 499 QString s_filename = config.readEntry(fileNum, "" );
497 config.setGroup( "Titles" ); 500 config.setGroup( "Titles" );
498 QString file_title = config.readEntry( s_filename, ""); 501 QString file_title = config.readEntry( s_filename, "");
499//qDebug("file_title is "+file_title); 502//odebug << "file_title is "+file_title << oendl;
500 if(title_text == file_title ) { 503 if(title_text == file_title ) {
501 selFile = s_filename; 504 selFile = s_filename;
502//qDebug("Edit: "+ file_title ); 505//odebug << "Edit: "+ file_title << oendl;
503 i=i_numofFiles+1; 506 i=i_numofFiles+1;
504 Edit_Title *titleEdit; 507 Edit_Title *titleEdit;
505 titleEdit = new Edit_Title(this,file_title ,TRUE); 508 titleEdit = new Edit_Title(this,file_title ,TRUE);
506 if(titleEdit->exec() !=0) { 509 if(titleEdit->exec() !=0) {
507//qDebug(titleEdit->newTitle); 510//odebug << titleEdit->newTitle << oendl;
508 config.writeEntry( s_filename, titleEdit->newTitle); 511 config.writeEntry( s_filename, titleEdit->newTitle);
509 QListBox_1->removeItem(currentItem); 512 QListBox_1->removeItem(currentItem);
510 QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), titleEdit->newTitle, currentItem); 513 QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), titleEdit->newTitle, currentItem);
511 } 514 }
512 } 515 }
513 } 516 }
514 517
515// getTitles(); 518// getTitles();
516 QListBox_1->triggerUpdate(true); 519 QListBox_1->triggerUpdate(true);
517} 520}
518 521
diff --git a/noncore/apps/opie-gutenbrowser/optionsDialog.cpp b/noncore/apps/opie-gutenbrowser/optionsDialog.cpp
index bfd9c26..8cc83da 100644
--- a/noncore/apps/opie-gutenbrowser/optionsDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/optionsDialog.cpp
@@ -1,79 +1,87 @@
1/*************************************************************************** 1/***************************************************************************
2 optionsDialog.cpp - description 2 optionsDialog.cpp - description
3 ------------------- 3 -------------------
4 begin : Tue Jul 25 2000 4 begin : Tue Jul 25 2000
5 copyright : (C) 2000 -2004 by llornkcor 5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 ***************************************************************************/ 7 ***************************************************************************/
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16#include "optionsDialog.h"
17#include <qpe/config.h>
18#include "fontDialog.h"
19 16
20// #include <unistd.h>
21// #include <stdio.h>
22// #include <stdlib.h>
23 17
18#include "optionsDialog.h"
19#include "fontDialog.h"
24//#include "ftpsitedlg.h" 20//#include "ftpsitedlg.h"
25//#include "browserDialog.h" 21//#include "browserDialog.h"
26//#define Inherited QDialog 22//#define Inherited QDialog
23
24/* OPIE */
25#include <opie2/odebug.h>
26#include <qpe/config.h>
27
28/* QT */
27#include <qfont.h> 29#include <qfont.h>
28#include <qcheckbox.h> 30#include <qcheckbox.h>
29#include <qcombobox.h> 31#include <qcombobox.h>
30#include <qlabel.h> 32#include <qlabel.h>
31#include <qlistbox.h> 33#include <qlistbox.h>
32#include <qpushbutton.h> 34#include <qpushbutton.h>
33#include <qtabwidget.h> 35#include <qtabwidget.h>
34#include <qwidget.h> 36#include <qwidget.h>
35#include <qlayout.h> 37#include <qlayout.h>
36#include <qvariant.h> 38#include <qvariant.h>
37#include <qtooltip.h> 39#include <qtooltip.h>
38#ifndef Q_WS_QWS 40#ifndef Q_WS_QWS
39#include <qwhatsthis.h> 41#include <qwhatsthis.h>
40#endif 42#endif
43
44/* STD */
45// #include <unistd.h>
46// #include <stdio.h>
47// #include <stdlib.h>
48
41/* 49/*
42 * The dialog will by default be modeless, unless you set 'modal' to 50 * The dialog will by default be modeless, unless you set 'modal' to
43 * TRUE to construct a modal dialog. 51 * TRUE to construct a modal dialog.
44 */ 52 */
45optionsDialog::optionsDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 53optionsDialog::optionsDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
46 : QDialog( parent, name, modal, fl ) 54 : QDialog( parent, name, modal, fl )
47{ 55{
48 if ( !name ) 56 if ( !name )
49 setName( "optionsDialog" ); 57 setName( "optionsDialog" );
50 changedFonts=FALSE; 58 changedFonts=FALSE;
51 // styleChanged=FALSE; 59 // styleChanged=FALSE;
52// connect( this,SIGNAL( aboutToQuit()),SLOT( OnExit()) ); 60// connect( this,SIGNAL( aboutToQuit()),SLOT( OnExit()) );
53 b_qExit=TRUE; 61 b_qExit=TRUE;
54 initDialog(); 62 initDialog();
55 63
56 ftpSiteDlg(); 64 ftpSiteDlg();
57 BrowserDlg(); 65 BrowserDlg();
58 FontDialog(); 66 FontDialog();
59} 67}
60 68
61optionsDialog::~optionsDialog() 69optionsDialog::~optionsDialog()
62{ 70{
63//qDebug("OnExit()"); 71//odebug << "OnExit()" << oendl;
64// writeConfig(); 72// writeConfig();
65} 73}
66 74
67/// optionsDialog 75/// optionsDialog
68void optionsDialog::doOptions() { 76void optionsDialog::doOptions() {
69 77
70// config.read(); 78// config.read();
71 getConfig(); 79 getConfig();
72} 80}
73 81
74void optionsDialog::getConfig() 82void optionsDialog::getConfig()
75{ 83{
76 Config config("Gutenbrowser"); 84 Config config("Gutenbrowser");
77 config.setGroup( "FTPsite" ); // ftp server config 85 config.setGroup( "FTPsite" ); // ftp server config
78 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); 86 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
79 ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); 87 ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
@@ -112,96 +120,96 @@ void optionsDialog::getConfig()
112// if( i_style==0){ styleInt=0; ComboBoxStyle->setCurrentItem(0);}//"styleMetal")); 120// if( i_style==0){ styleInt=0; ComboBoxStyle->setCurrentItem(0);}//"styleMetal"));
113// if( i_style==1) { styleInt=1; ComboBoxStyle->setCurrentItem(1);}//"styleWindows") ); 121// if( i_style==1) { styleInt=1; ComboBoxStyle->setCurrentItem(1);}//"styleWindows") );
114// if( i_style==2) { styleInt=2; ComboBoxStyle->setCurrentItem(2);}//"stylePlatinum")); 122// if( i_style==2) { styleInt=2; ComboBoxStyle->setCurrentItem(2);}//"stylePlatinum"));
115// if( i_style==2){ styleInt=2; ComboBoxStyle->setCurrentItem(2);}//"styleCDE") ); 123// if( i_style==2){ styleInt=2; ComboBoxStyle->setCurrentItem(2);}//"styleCDE") );
116// if( i_style==3) { styleInt=3; ComboBoxStyle->setCurrentItem(3);}//"styleMotif") ); 124// if( i_style==3) { styleInt=3; ComboBoxStyle->setCurrentItem(3);}//"styleMotif") );
117// if( i_style==4) { styleInt=4; ComboBoxStyle->setCurrentItem(4);}//"styleMotifPlus")); 125// if( i_style==4) { styleInt=4; ComboBoxStyle->setCurrentItem(4);}//"styleMotifPlus"));
118// // if( i_style==5) { styleInt=5; ComboBoxStyle->setCurrentItem(5);}//"styleWood") ); 126// // if( i_style==5) { styleInt=5; ComboBoxStyle->setCurrentItem(5);}//"styleWood") );
119// if( i_style==6) { styleInt=6; ComboBoxStyle->setCurrentItem(6);}//"styleSgi") ); 127// if( i_style==6) { styleInt=6; ComboBoxStyle->setCurrentItem(6);}//"styleSgi") );
120// if( i_style==7) { styleInt=7; ComboBoxStyle->setCurrentItem(7);}//"stylePlatinumPlus") ); 128// if( i_style==7) { styleInt=7; ComboBoxStyle->setCurrentItem(7);}//"stylePlatinumPlus") );
121// if( i_style==9){ styleInt=9; ComboBoxStyle->setCurrentItem(9);}//"styleLace")); 129// if( i_style==9){ styleInt=9; ComboBoxStyle->setCurrentItem(9);}//"styleLace"));
122// if( i_style==10){ styleInt=10; ComboBoxStyle->setCurrentItem(10);}//"styleLacePlus")); 130// if( i_style==10){ styleInt=10; ComboBoxStyle->setCurrentItem(10);}//"styleLacePlus"));
123// #endif 131// #endif
124 config.setGroup("General"); 132 config.setGroup("General");
125 QString qExit=config.readEntry("queryExit","TRUE"); 133 QString qExit=config.readEntry("queryExit","TRUE");
126 if(qExit=="TRUE") { 134 if(qExit=="TRUE") {
127 cb_queryExit->setChecked(TRUE); 135 cb_queryExit->setChecked(TRUE);
128 qDebug("Config Setting b_qExit=TRUE;"); 136 odebug << "Config Setting b_qExit=TRUE;" << oendl;
129 b_qExit=TRUE; 137 b_qExit=TRUE;
130 } else { 138 } else {
131 cb_queryExit->setChecked(FALSE); 139 cb_queryExit->setChecked(FALSE);
132 qDebug("ConfigSetting b_qExit=FALSE;"); 140 odebug << "ConfigSetting b_qExit=FALSE;" << oendl;
133 b_qExit=FALSE; 141 b_qExit=FALSE;
134 } 142 }
135 143
136 144
137 useWordWrap_CheckBox->setChecked( config.readBoolEntry("WordWrap", 1)); 145 useWordWrap_CheckBox->setChecked( config.readBoolEntry("WordWrap", 1));
138 QString downDir=config.readEntry( "DownloadDirectory",local_library); 146 QString downDir=config.readEntry( "DownloadDirectory",local_library);
139 downloadDirEdit->setText(downDir); 147 downloadDirEdit->setText(downDir);
140} // end getConfig 148} // end getConfig
141 149
142// // void optionsDialog::setStyle( int index) { 150// // void optionsDialog::setStyle( int index) {
143 151
144// // qDebug("Set style%d",index); 152// // odebug << "Set style" << index << "" << oendl;
145// // //int styleInt= index; 153// // //int styleInt= index;
146// // styleChanged=TRUE; 154// // styleChanged=TRUE;
147// // if( ComboBoxStyle->currentItem()==0) styleInt=0;//"styleMetal")); 155// // if( ComboBoxStyle->currentItem()==0) styleInt=0;//"styleMetal"));
148// // if( ComboBoxStyle->currentItem()==1) styleInt=1;//"styleWindows") ); 156// // if( ComboBoxStyle->currentItem()==1) styleInt=1;//"styleWindows") );
149// // if( ComboBoxStyle->currentItem()==2) styleInt=2;//"stylePlatinum")); 157// // if( ComboBoxStyle->currentItem()==2) styleInt=2;//"stylePlatinum"));
150// // // if( ComboBoxStyle->currentItem()==2) styleInt=2;//"styleCDE") ); 158// // // if( ComboBoxStyle->currentItem()==2) styleInt=2;//"styleCDE") );
151// // // if( ComboBoxStyle->currentItem()==3) styleInt=3;//"styleMotif") ); 159// // // if( ComboBoxStyle->currentItem()==3) styleInt=3;//"styleMotif") );
152// // // if( ComboBoxStyle->currentItem()==4) styleInt=4;//"styleMotifPlus")); 160// // // if( ComboBoxStyle->currentItem()==4) styleInt=4;//"styleMotifPlus"));
153// // // // if( ComboBoxStyle->currentItem()==5) styleInt=5;//"styleWood") ); 161// // // // if( ComboBoxStyle->currentItem()==5) styleInt=5;//"styleWood") );
154// // // if( ComboBoxStyle->currentItem()==6) styleInt=6;//"styleSgi") ); 162// // // if( ComboBoxStyle->currentItem()==6) styleInt=6;//"styleSgi") );
155// // // if( ComboBoxStyle->currentItem()==7) styleInt=7;//"stylePlatinumPlus") ); 163// // // if( ComboBoxStyle->currentItem()==7) styleInt=7;//"stylePlatinumPlus") );
156// // // if( ComboBoxStyle->currentItem()==9) styleInt=9;//"styleLace")); 164// // // if( ComboBoxStyle->currentItem()==9) styleInt=9;//"styleLace"));
157// // // if( ComboBoxStyle->currentItem()==10) styleInt=10;//"styleLacePlus")); 165// // // if( ComboBoxStyle->currentItem()==10) styleInt=10;//"styleLacePlus"));
158// // QString temp; 166// // QString temp;
159// // temp.setNum(styleInt, 10); 167// // temp.setNum(styleInt, 10);
160// // Config config("Gutenbrowser"); 168// // Config config("Gutenbrowser");
161// // config.setGroup( "StyleIze" ); 169// // config.setGroup( "StyleIze" );
162// // config.writeEntry( "Style", temp); 170// // config.writeEntry( "Style", temp);
163// // config.write(); 171// // config.write();
164// // } 172// // }
165 173
166void optionsDialog::slotQueryExit() 174void optionsDialog::slotQueryExit()
167{ 175{
168 Config config("Gutenbrowser"); 176 Config config("Gutenbrowser");
169 config.setGroup("General"); 177 config.setGroup("General");
170 qDebug("writing queryExit"); 178 odebug << "writing queryExit" << oendl;
171 if(cb_queryExit->isChecked()) { 179 if(cb_queryExit->isChecked()) {
172 b_qExit=TRUE; 180 b_qExit=TRUE;
173 config.writeEntry("queryExit","TRUE"); 181 config.writeEntry("queryExit","TRUE");
174 qDebug("WritingConfig queryExit=TRUE"); 182 odebug << "WritingConfig queryExit=TRUE" << oendl;
175 } else { 183 } else {
176 b_qExit=FALSE; 184 b_qExit=FALSE;
177 config.writeEntry("queryExit","FALSE"); 185 config.writeEntry("queryExit","FALSE");
178 qDebug("WritingConfig queryExit=FALSE"); 186 odebug << "WritingConfig queryExit=FALSE" << oendl;
179 } 187 }
180 config.write(); 188 config.write();
181} 189}
182 190
183 191
184// void optionsDialog::slotUseSplit() 192// void optionsDialog::slotUseSplit()
185// { 193// {
186 194
187// } 195// }
188 196
189// void optionsDialog::lineEditChanged(const QString &editText) { 197// void optionsDialog::lineEditChanged(const QString &editText) {
190// qDebug(editText); 198// odebug << editText << oendl;
191// } 199// }
192 200
193void optionsDialog::changeFonts() 201void optionsDialog::changeFonts()
194{ 202{
195 changedFonts=TRUE; 203 changedFonts=TRUE;
196} 204}
197 205
198 206
199void optionsDialog::slotWordWrap(bool b) { 207void optionsDialog::slotWordWrap(bool b) {
200 208
201 Config config("Gutenbrowser"); 209 Config config("Gutenbrowser");
202 config.setGroup("General"); 210 config.setGroup("General");
203 211
204 config.writeEntry("WordWrap", b); 212 config.writeEntry("WordWrap", b);
205 config.write(); 213 config.write();
206 214
207} 215}
diff --git a/noncore/apps/opie-reader/Aportis.cpp b/noncore/apps/opie-reader/Aportis.cpp
index 2f8cdc3..06f44a4 100644
--- a/noncore/apps/opie-reader/Aportis.cpp
+++ b/noncore/apps/opie-reader/Aportis.cpp
@@ -15,40 +15,40 @@ void Aportis::dePeanut(int& ch)
15 ch = c; 15 ch = c;
16 } 16 }
17} 17}
18 18
19CList<Bkmk>* Aportis::getbkmklist() 19CList<Bkmk>* Aportis::getbkmklist()
20{ 20{
21/* 21/*
22 if (peanutfile) 22 if (peanutfile)
23 { 23 {
24 if (nRecs2 > nRecs) 24 if (nRecs2 > nRecs)
25 { 25 {
26 CList<Bkmk>* t = new CList<Bkmk>; 26 CList<Bkmk>* t = new CList<Bkmk>;
27 for (int i = nRecs; i < nRecs2; i++) 27 for (int i = nRecs; i < nRecs2; i++)
28 { 28 {
29 char name[17]; 29 char name[17];
30 name[16] = '\0'; 30 name[16] = '\0';
31 // qDebug("Record:%d, Length:%u",i,recordlength(i)); 31 // odebug << "Record:" << i << ", Length:" << recordlength(i) << "" << oendl;
32 gotorecordnumber(i); 32 gotorecordnumber(i);
33 fread(name,1,16,fin); 33 fread(name,1,16,fin);
34 unsigned long lcn; 34 unsigned long lcn;
35 fread(&lcn,sizeof(lcn),1,fin); 35 fread(&lcn,sizeof(lcn),1,fin);
36 lcn ^= 0xa5a5a5a5; 36 lcn ^= 0xa5a5a5a5;
37 lcn = SwapLong(lcn); 37 lcn = SwapLong(lcn);
38 // qDebug("Bookmark:%s:%u", name,lcn); 38 // odebug << "Bookmark:" << name << ":" << lcn << "" << oendl;
39 tchar tname[17]; 39 tchar tname[17];
40 memset(tname, 0, sizeof(tname)); 40 memset(tname, 0, sizeof(tname));
41 for (int i = 0; name[i] != 0; i++) 41 for (int i = 0; name[i] != 0; i++)
42 { 42 {
43 tname[i] = name[i] ^ 0xa5; 43 tname[i] = name[i] ^ 0xa5;
44 } 44 }
45 t->push_back(Bkmk(tname, NULL, lcn)); 45 t->push_back(Bkmk(tname, NULL, lcn));
46 } 46 }
47 return t; 47 return t;
48 } 48 }
49 else 49 else
50 { 50 {
51 return NULL; 51 return NULL;
52 } 52 }
53 } 53 }
54*/ 54*/
@@ -108,33 +108,33 @@ int Aportis::OpenFile(const char *src)
108 else 108 else
109 { 109 {
110 return -2; 110 return -2;
111 } 111 }
112 } 112 }
113 113
114 nRecs2 = nRecs = SwapWord(head.recordList.numRecords) - 1; 114 nRecs2 = nRecs = SwapWord(head.recordList.numRecords) - 1;
115 fseek(fin,0,SEEK_END); 115 fseek(fin,0,SEEK_END);
116 dwLen = ftell(fin); 116 dwLen = ftell(fin);
117 117
118 if (peanutfile) 118 if (peanutfile)
119 { 119 {
120 120
121 PeanutHeader hdr0; 121 PeanutHeader hdr0;
122 gotorecordnumber(0); 122 gotorecordnumber(0);
123 fread(&hdr0, sizeof(hdr0), 1, fin); 123 fread(&hdr0, sizeof(hdr0), 1, fin);
124// qDebug("Version:%x", ntohs(hdr0.Version)); 124// odebug << "Version:" << ntohs(hdr0.Version) << "" << oendl;
125 if (hdr0.Version && 0x0200) 125 if (hdr0.Version && 0x0200)
126 { 126 {
127 bCompressed = 2; 127 bCompressed = 2;
128 } 128 }
129 else 129 else
130 { 130 {
131 bCompressed = 1; 131 bCompressed = 1;
132 } 132 }
133 BlockSize = 4096; 133 BlockSize = 4096;
134 nRecs = SwapWord(hdr0.Records)-1; 134 nRecs = SwapWord(hdr0.Records)-1;
135 dwTLen = nRecs*BlockSize; 135 dwTLen = nRecs*BlockSize;
136 } 136 }
137 else 137 else
138 { 138 {
139 gotorecordnumber(0); 139 gotorecordnumber(0);
140 tDocRecord0 hdr0; 140 tDocRecord0 hdr0;
@@ -169,33 +169,33 @@ int Aportis::OpenFile(const char *src)
169 if (BlockSize == 0) 169 if (BlockSize == 0)
170 { 170 {
171 BlockSize = 4096; 171 BlockSize = 4096;
172 printf("WARNING: Blocksize not set in source file\n"); 172 printf("WARNING: Blocksize not set in source file\n");
173 } 173 }
174 } 174 }
175 } 175 }
176 176
177 177
178 178
179 // this is the main record buffer 179 // this is the main record buffer
180 // it knows how to stretch to accomodate the decompress 180 // it knows how to stretch to accomodate the decompress
181 currentrec = 0; 181 currentrec = 0;
182 cbptr = 0; 182 cbptr = 0;
183 outptr = 0; 183 outptr = 0;
184 refreshbuffer(); 184 refreshbuffer();
185// qDebug("Number of records:[%u,%u]", nRecs, nRecs2); 185// odebug << "Number of records:[" << nRecs << "," << nRecs2 << "]" << oendl;
186 return ret; 186 return ret;
187} 187}
188 188
189int Aportis::getch() 189int Aportis::getch()
190{ 190{
191 if (bCompressed == 1) 191 if (bCompressed == 1)
192 { 192 {
193 if ((dwRecLen == 0) && !refreshbuffer()) return EOF; 193 if ((dwRecLen == 0) && !refreshbuffer()) return EOF;
194 else 194 else
195 { 195 {
196 int c = getc(fin); 196 int c = getc(fin);
197 dePeanut(c); 197 dePeanut(c);
198 dwRecLen--; 198 dwRecLen--;
199 currentpos++; 199 currentpos++;
200 return c; 200 return c;
201 } 201 }
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp
index 16bc1f1..480c240 100644
--- a/noncore/apps/opie-reader/Bkmks.cpp
+++ b/noncore/apps/opie-reader/Bkmks.cpp
@@ -204,41 +204,41 @@ CList<Bkmk>* BkmkFile::readall()
204 bl = readall00(&read05); 204 bl = readall00(&read05);
205 } 205 }
206 else 206 else
207 { 207 {
208 fseek(f,0,SEEK_SET); 208 fseek(f,0,SEEK_SET);
209 bl = readall00(&read03); 209 bl = readall00(&read03);
210 } 210 }
211 isUpgraded = true; 211 isUpgraded = true;
212 } 212 }
213 else 213 else
214 { 214 {
215 switch(newmagic & 0xff) 215 switch(newmagic & 0xff)
216 { 216 {
217 case 6: 217 case 6:
218 isUpgraded = false; 218 isUpgraded = false;
219 bl = readall00(read06); 219 bl = readall00(read06);
220 // qDebug("Correct version!"); 220 // odebug << "Correct version!" << oendl;
221 break; 221 break;
222 case 5: 222 case 5:
223 isUpgraded = true; 223 isUpgraded = true;
224 bl = readall00(read05); 224 bl = readall00(read05);
225 // qDebug("Known version!"); 225 // odebug << "Known version!" << oendl;
226 break; 226 break;
227 default: 227 default:
228 // qDebug("Unknown version!"); 228 // odebug << "Unknown version!" << oendl;
229 isUpgraded = true; 229 isUpgraded = true;
230 bl = readall00(read05); 230 bl = readall00(read05);
231 } 231 }
232 } 232 }
233 } 233 }
234 return bl; 234 return bl;
235} 235}
236 236
237CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(FILE*)) 237CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(FILE*))
238{ 238{
239 CList<Bkmk>* bl = new CList<Bkmk>; 239 CList<Bkmk>* bl = new CList<Bkmk>;
240 while (1) 240 while (1)
241 { 241 {
242 Bkmk* b = (*readfn)(f); 242 Bkmk* b = (*readfn)(f);
243 if (b == NULL) break; 243 if (b == NULL) break;
244 bl->push_back(*b); 244 bl->push_back(*b);
diff --git a/noncore/apps/opie-reader/BuffDoc.cpp b/noncore/apps/opie-reader/BuffDoc.cpp
index 4fbab93..68391b8 100644
--- a/noncore/apps/opie-reader/BuffDoc.cpp
+++ b/noncore/apps/opie-reader/BuffDoc.cpp
@@ -19,43 +19,43 @@ linkType BuffDoc::hyperlink(unsigned int n, QString& wrd)
19 { 19 {
20 lastword.empty(); 20 lastword.empty();
21 lastsizes[0] = laststartline = n; 21 lastsizes[0] = laststartline = n;
22#ifdef NEWLINEBREAK 22#ifdef NEWLINEBREAK
23 lastispara = true; 23 lastispara = true;
24#else 24#else
25 lastispara = false; 25 lastispara = false;
26#endif 26#endif
27 lastsizes[0] = laststartline = exp->locate(); 27 lastsizes[0] = laststartline = exp->locate();
28 } 28 }
29 } 29 }
30 return bRet; 30 return bRet;
31} 31}
32 32
33void BuffDoc::locate(unsigned int n) 33void BuffDoc::locate(unsigned int n)
34{ 34{
35 // //qDebug("BuffDoc:locating:%u",n); 35 // //odebug << "BuffDoc:locating:" << n << "" << oendl;
36 lastword.empty(); 36 lastword.empty();
37 lastsizes[0] = laststartline = n; 37 lastsizes[0] = laststartline = n;
38#ifdef NEWLINEBREAK 38#ifdef NEWLINEBREAK
39 lastispara = true; 39 lastispara = true;
40#else 40#else
41 lastispara = false; 41 lastispara = false;
42#endif 42#endif
43 // tchar linebuf[1024]; 43 // tchar linebuf[1024];
44 if (exp != NULL) exp->locate(n); 44 if (exp != NULL) exp->locate(n);
45 // //qDebug("BuffDoc:Located"); 45 // //odebug << "BuffDoc:Located" << oendl;
46} 46}
47 47
48#ifdef NEWLINEBREAK 48#ifdef NEWLINEBREAK
49bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border) 49bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border)
50{ 50{
51 bool moreleft = true; 51 bool moreleft = true;
52 bool margindone = false; 52 bool margindone = false;
53 int w = wth-2*_border; 53 int w = wth-2*_border;
54 tchar ch = 32; 54 tchar ch = 32;
55 CStyle cs; 55 CStyle cs;
56 buff->empty(); 56 buff->empty();
57 if (exp == NULL) 57 if (exp == NULL)
58 { 58 {
59 buff->empty(); 59 buff->empty();
60 buff->setEof(); 60 buff->setEof();
61 return false; 61 return false;
@@ -175,33 +175,33 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border)
175 buff->empty(); 175 buff->empty();
176 if (exp == NULL) 176 if (exp == NULL)
177 { 177 {
178 //(*buff)[0] = '\0'; 178 //(*buff)[0] = '\0';
179 buff->empty(); 179 buff->empty();
180 return false; 180 return false;
181 } 181 }
182 int len = 0, lastcheck = 0; 182 int len = 0, lastcheck = 0;
183 if (lastword.length() > 0) 183 if (lastword.length() > 0)
184 { 184 {
185 *buff = lastword; 185 *buff = lastword;
186 cs = lastword.laststyle(); 186 cs = lastword.laststyle();
187 w -= buff->leftMargin() + buff->rightMargin(); 187 w -= buff->leftMargin() + buff->rightMargin();
188 margindone = true; 188 margindone = true;
189 } 189 }
190 else buff->empty(); 190 else buff->empty();
191// //qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); 191// //odebug << "Buff:" << toQString(buff->data()) << " Lastword:" << toQString(lastword.data()) << "" << oendl;
192 lastcheck = len = buff->length(); 192 lastcheck = len = buff->length();
193 unsigned int slen = buff->width(len); 193 unsigned int slen = buff->width(len);
194 if (slen > w) 194 if (slen > w)
195 { 195 {
196 for ( ; len > 1; len--) 196 for ( ; len > 1; len--)
197 { 197 {
198 if (buff->width(len) < w) break; 198 if (buff->width(len) < w) break;
199 } 199 }
200// lastword = buff->data() + len - 1; 200// lastword = buff->data() + len - 1;
201 laststartline = lastsizes[len-1]; 201 laststartline = lastsizes[len-1];
202 for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1]; 202 for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1];
203// (*buff)[len-1] = '-'; 203// (*buff)[len-1] = '-';
204 if (len > 2) 204 if (len > 2)
205 { 205 {
206 lastword.setright(*buff, len - 1); 206 lastword.setright(*buff, len - 1);
207 buff->truncate(len-1); 207 buff->truncate(len-1);
@@ -309,34 +309,34 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw, unsigned char _border)
309 int i = 1; 309 int i = 1;
310 while (i*cw < w-buff->offset(w,0)) 310 while (i*cw < w-buff->offset(w,0))
311 { 311 {
312 getch(ch, cs); 312 getch(ch, cs);
313 if (ch == '\12' || ch == UEOF) break; 313 if (ch == '\12' || ch == UEOF) break;
314 buff->addch(ch,cs); 314 buff->addch(ch,cs);
315 i++; 315 i++;
316 } 316 }
317 buff->truncate(i); 317 buff->truncate(i);
318 laststartline = exp->locate(); 318 laststartline = exp->locate();
319 buff->resize(); 319 buff->resize();
320 return (ch != UEOF); 320 return (ch != UEOF);
321} 321}
322 322
323int BuffDoc::openfile(QWidget* _parent, const char *src) 323int BuffDoc::openfile(QWidget* _parent, const char *src)
324{ 324{
325 // //qDebug("BuffDoc:Openfile:%s", src); 325 // //odebug << "BuffDoc:Openfile:" << src << "" << oendl;
326 // //qDebug("Trying aportis %x",exp); 326 // //odebug << "Trying aportis " << exp << "" << oendl;
327 if (exp != NULL) delete exp; 327 if (exp != NULL) delete exp;
328 lastword.empty(); 328 lastword.empty();
329 lastsizes[0] = laststartline = 0; 329 lastsizes[0] = laststartline = 0;
330#ifdef NEWLINEBREAK 330#ifdef NEWLINEBREAK
331 lastispara = true; 331 lastispara = true;
332#else 332#else
333 lastispara = false; 333 lastispara = false;
334#endif 334#endif
335 /* 335 /*
336 exp = new Text; 336 exp = new Text;
337 int ret = exp->openfile(src); 337 int ret = exp->openfile(src);
338 */ 338 */
339 339
340 exp = new Aportis; 340 exp = new Aportis;
341 int ret = exp->openfile(src); 341 int ret = exp->openfile(src);
342 if (ret == -1) 342 if (ret == -1)
@@ -365,48 +365,48 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
365 365
366 delete exp; 366 delete exp;
367 exp = new CNEF; 367 exp = new CNEF;
368 ret = exp->openfile(src); 368 ret = exp->openfile(src);
369 } 369 }
370#endif 370#endif
371 if (ret != 0) 371 if (ret != 0)
372 { 372 {
373 373
374 delete exp; 374 delete exp;
375 exp = new CPlucker; 375 exp = new CPlucker;
376 ret = exp->openfile(src); 376 ret = exp->openfile(src);
377 } 377 }
378 if (ret != 0) 378 if (ret != 0)
379 { 379 {
380 delete exp; 380 delete exp;
381 //qDebug("Trying ppms"); 381 //odebug << "Trying ppms" << oendl;
382 exp = new ppm_expander; 382 exp = new ppm_expander;
383 ret = exp->openfile(src); 383 ret = exp->openfile(src);
384 } 384 }
385 if (ret != 0) 385 if (ret != 0)
386 { 386 {
387 delete exp; 387 delete exp;
388 exp = new Text; 388 exp = new Text;
389 // //qDebug("Trying text"); 389 // //odebug << "Trying text" << oendl;
390 ret = exp->openfile(src); 390 ret = exp->openfile(src);
391 } 391 }
392 392
393 if (ret != 0) 393 if (ret != 0)
394 { 394 {
395 delete exp; 395 delete exp;
396 QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file"); 396 QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file");
397 return ret; 397 return ret;
398 } 398 }
399 // //qDebug("Doing final open:%x:%x",exp,filt); 399 // //odebug << "Doing final open:" << exp << ":" << filt << "" << oendl;
400 400
401 lastword.empty(); 401 lastword.empty();
402 lastsizes[0] = laststartline = 0; 402 lastsizes[0] = laststartline = 0;
403#ifdef NEWLINEBREAK 403#ifdef NEWLINEBREAK
404 lastispara = true; 404 lastispara = true;
405#else 405#else
406 lastispara = false; 406 lastispara = false;
407#endif 407#endif
408 exp->locate(0); 408 exp->locate(0);
409 filt->setsource(exp); 409 filt->setsource(exp);
410 // //qDebug("BuffDoc:file opened"); 410 // //odebug << "BuffDoc:file opened" << oendl;
411 return 0; 411 return 0;
412} 412}
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp
index ec36fb2..b137ac3 100644
--- a/noncore/apps/opie-reader/CDrawBuffer.cpp
+++ b/noncore/apps/opie-reader/CDrawBuffer.cpp
@@ -27,51 +27,51 @@ void CDrawBuffer::setright(CDrawBuffer& rhs, int f)
27 int st = next->start-f; 27 int st = next->start-f;
28 if (st < 0) st = 0; 28 if (st < 0) st = 0;
29 29
30 CStyle _style = next->style; 30 CStyle _style = next->style;
31 31
32 segs.push_back(textsegment(st,next->style)); 32 segs.push_back(textsegment(st,next->style));
33 } 33 }
34 } 34 }
35 for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i]; 35 for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i];
36 (*this)[i-f] = '\0'; 36 (*this)[i-f] = '\0';
37 len = i; 37 len = i;
38} 38}
39 39
40CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) 40CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs)
41{ 41{
42 int i; 42 int i;
43// //qDebug("Trying 2"); 43// //odebug << "Trying 2" << oendl;
44 len = rhs.len; 44 len = rhs.len;
45 m_maxstyle = rhs.m_maxstyle; 45 m_maxstyle = rhs.m_maxstyle;
46 m_ascent = rhs.m_ascent; 46 m_ascent = rhs.m_ascent;
47 m_descent = rhs.m_descent; 47 m_descent = rhs.m_descent;
48 m_lineSpacing = rhs.m_lineSpacing; 48 m_lineSpacing = rhs.m_lineSpacing;
49 m_lineExtraSpacing = rhs.m_lineExtraSpacing; 49 m_lineExtraSpacing = rhs.m_lineExtraSpacing;
50 while (!segs.isEmpty()) 50 while (!segs.isEmpty())
51 { 51 {
52 segs.erase(0); 52 segs.erase(0);
53 } 53 }
54 for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) 54 for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++)
55 { 55 {
56 segs.push_back(*iter); 56 segs.push_back(*iter);
57 } 57 }
58 for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; 58 for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i];
59 (*this)[i] = '\0'; 59 (*this)[i] = '\0';
60 len = i; 60 len = i;
61// //qDebug("Tried 2"); 61// //odebug << "Tried 2" << oendl;
62 return *this; 62 return *this;
63} 63}
64 64
65CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) 65CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp)
66{ 66{
67 int i; 67 int i;
68 while (!segs.isEmpty()) 68 while (!segs.isEmpty())
69 { 69 {
70 segs.erase(0); 70 segs.erase(0);
71 } 71 }
72 segs.push_back(textsegment(0, CStyle())); 72 segs.push_back(textsegment(0, CStyle()));
73 for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; 73 for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i];
74 (*this)[i] = '\0'; 74 (*this)[i] = '\0';
75 len = i; 75 len = i;
76 return *this; 76 return *this;
77} 77}
@@ -195,33 +195,33 @@ int CDrawBuffer::width(int numchars, bool onscreen, int scwidth, unsigned char _
195 int cx = currentx; 195 int cx = currentx;
196 while ((nsp = str.find(" ", lastspace+1)) >= 0) 196 while ((nsp = str.find(" ", lastspace+1)) >= 0)
197 { 197 {
198 if (nsp > nonspace) 198 if (nsp > nonspace)
199 { 199 {
200 spacenumber++; 200 spacenumber++;
201 int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; 201 int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar;
202 QString nstr = str.mid(lastspace+1, nsp-lastspace); 202 QString nstr = str.mid(lastspace+1, nsp-lastspace);
203 int lw = fm.width(nstr); 203 int lw = fm.width(nstr);
204 cx += lw+nexttoadd; 204 cx += lw+nexttoadd;
205 spacesofar += nexttoadd; 205 spacesofar += nexttoadd;
206 lastspace = nsp; 206 lastspace = nsp;
207 } 207 }
208 else 208 else
209 { 209 {
210 QString nstr = str.mid(lastspace+1, nsp-lastspace); 210 QString nstr = str.mid(lastspace+1, nsp-lastspace);
211 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); 211 // odebug << "str:" << str << ": last:" << lastspace << " new:" << nsp << " nstr:" << nstr << ":" << oendl;
212 int lw = fm.width(nstr); 212 int lw = fm.width(nstr);
213 cx += lw; 213 cx += lw;
214 lastspace = nsp; 214 lastspace = nsp;
215 } 215 }
216 } 216 }
217 QString nstr = str.right(str.length()-1-lastspace); 217 QString nstr = str.right(str.length()-1-lastspace);
218 cx += fm.width(nstr); 218 cx += fm.width(nstr);
219 currentx = cx; 219 currentx = cx;
220 } 220 }
221 else 221 else
222 { 222 {
223 currentx += fm.width(str); 223 currentx += fm.width(str);
224 } 224 }
225 } 225 }
226 } 226 }
227 textstart = textend; 227 textstart = textend;
@@ -304,33 +304,33 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
304 just = false; 304 just = false;
305 } 305 }
306 else 306 else
307 { 307 {
308 extraspace = (scwidth - 2*_border - rightMargin() - leftMargin() - width()); 308 extraspace = (scwidth - 2*_border - rightMargin() - leftMargin() - width());
309 if (extraspace == 0) just = false; 309 if (extraspace == 0) just = false;
310 } 310 }
311 } 311 }
312 CList<textsegment>::iterator textend = textstart; 312 CList<textsegment>::iterator textend = textstart;
313 do 313 do
314 { 314 {
315 textend++; 315 textend++;
316 int end = (textend != segs.end()) ? textend->start : len; 316 int end = (textend != segs.end()) ? textend->start : len;
317 CStyle currentstyle = textstart->style; 317 CStyle currentstyle = textstart->style;
318 QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); 318 QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
319 //f.setUnderline(currentstyle.isUnderline()); 319 //f.setUnderline(currentstyle.isUnderline());
320 //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); 320 //if (currentstyle.isUnderline()) odebug << "UNDERLINE" << oendl;
321 _p->setFont(f); 321 _p->setFont(f);
322 QString str = text.mid(textstart->start, end-textstart->start); 322 QString str = text.mid(textstart->start, end-textstart->start);
323#if defined(OPIE) || !defined(USEQPE) 323#if defined(OPIE) || !defined(USEQPE)
324 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100)); 324 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100));
325#else 325#else
326 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); 326 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10));
327#endif 327#endif
328 int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2; 328 int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2;
329 if (_bMono) 329 if (_bMono)
330 { 330 {
331 if (currentstyle.isUnderline()) 331 if (currentstyle.isUnderline())
332 { 332 {
333 _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset); 333 _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset);
334 } 334 }
335 if (currentstyle.isStrikethru()) 335 if (currentstyle.isStrikethru())
336 { 336 {
@@ -395,43 +395,43 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
395 else 395 else
396 { 396 {
397 QFontMetrics fm(f); 397 QFontMetrics fm(f);
398 int w; 398 int w;
399 if (just) 399 if (just)
400 { 400 {
401 int lastspace = -1; 401 int lastspace = -1;
402 int nsp = 0; 402 int nsp = 0;
403 int cx = currentx; 403 int cx = currentx;
404 while ((nsp = str.find(" ", lastspace+1)) >= 0) 404 while ((nsp = str.find(" ", lastspace+1)) >= 0)
405 { 405 {
406 if (nsp+textstart->start >= nonspace) 406 if (nsp+textstart->start >= nonspace)
407 { 407 {
408 spacenumber++; 408 spacenumber++;
409 int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; 409 int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar;
410 QString nstr = str.mid(lastspace+1, nsp-lastspace); 410 QString nstr = str.mid(lastspace+1, nsp-lastspace);
411 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); 411 // odebug << "str:" << str << ": last:" << lastspace << " new:" << nsp << " nstr:" << nstr << ":" << oendl;
412 int lw = fm.width(nstr); 412 int lw = fm.width(nstr);
413 _p->drawText( cx, _y+voffset, nstr); 413 _p->drawText( cx, _y+voffset, nstr);
414 cx += lw+nexttoadd; 414 cx += lw+nexttoadd;
415 spacesofar += nexttoadd; 415 spacesofar += nexttoadd;
416 lastspace = nsp; 416 lastspace = nsp;
417 } 417 }
418 else 418 else
419 { 419 {
420 QString nstr = str.mid(lastspace+1, nsp-lastspace); 420 QString nstr = str.mid(lastspace+1, nsp-lastspace);
421 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); 421 // odebug << "str:" << str << ": last:" << lastspace << " new:" << nsp << " nstr:" << nstr << ":" << oendl;
422 int lw = fm.width(nstr); 422 int lw = fm.width(nstr);
423 _p->drawText( cx, _y+voffset, nstr); 423 _p->drawText( cx, _y+voffset, nstr);
424 cx += lw; 424 cx += lw;
425 lastspace = nsp; 425 lastspace = nsp;
426 } 426 }
427 } 427 }
428 QString nstr = str.right(str.length()-1-lastspace); 428 QString nstr = str.right(str.length()-1-lastspace);
429 _p->drawText( cx, _y+voffset, nstr); 429 _p->drawText( cx, _y+voffset, nstr);
430 cx += fm.width(nstr); 430 cx += fm.width(nstr);
431 w = cx - currentx; 431 w = cx - currentx;
432 } 432 }
433 else 433 else
434 { 434 {
435 _p->drawText( currentx, _y+voffset, str); 435 _p->drawText( currentx, _y+voffset, str);
436 w = fm.width(str); 436 w = fm.width(str);
437 } 437 }
@@ -457,40 +457,40 @@ CStyle CDrawBuffer::laststyle()
457{ 457{
458 return segs.last().style; 458 return segs.last().style;
459} 459}
460 460
461linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt) 461linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt)
462{ 462{
463 int end = 0; 463 int end = 0;
464 CStyle currentstyle; 464 CStyle currentstyle;
465 CList<textsegment>::iterator textstart = segs.begin(); 465 CList<textsegment>::iterator textstart = segs.begin();
466 CList<textsegment>::iterator textend = textstart; 466 CList<textsegment>::iterator textend = textstart;
467 do 467 do
468 { 468 {
469 textend++; 469 textend++;
470 end = (textend != segs.end()) ? textend->start : len; 470 end = (textend != segs.end()) ? textend->start : len;
471 currentstyle = textstart->style; 471 currentstyle = textstart->style;
472/* 472/*
473 if (currentstyle.isPicture()) qDebug("Passed thru picture"); 473 if (currentstyle.isPicture()) odebug << "Passed thru picture" << oendl;
474 if (currentstyle.getLink()) qDebug("Passed thru link"); 474 if (currentstyle.getLink()) odebug << "Passed thru link" << oendl;
475 //qDebug("islink:%d - %d", numchars, end); 475 //odebug << "islink:" << numchars << " - " << end << "" << oendl;
476*/ 476*/
477 textstart = textend; 477 textstart = textend;
478 } 478 }
479 while (textend != segs.end() && end <= numchars); 479 while (textend != segs.end() && end <= numchars);
480// if (currentstyle.isPicture()) qDebug("Clicked on picture"); 480// if (currentstyle.isPicture()) odebug << "Clicked on picture" << oendl;
481 if (currentstyle.getPictureLink()) 481 if (currentstyle.getPictureLink())
482 { 482 {
483 tgt = currentstyle.getPictureLinkData(); 483 tgt = currentstyle.getPictureLinkData();
484 return ePicture; 484 return ePicture;
485 } 485 }
486 if (currentstyle.getLink()) 486 if (currentstyle.getLink())
487 { 487 {
488 tgt = currentstyle.getData(); 488 tgt = currentstyle.getData();
489 return eLink; 489 return eLink;
490 } 490 }
491 return eNone; 491 return eNone;
492} 492}
493 493
494void CDrawBuffer::resize() 494void CDrawBuffer::resize()
495{ 495{
496 int gzoom = fc->gzoom(); 496 int gzoom = fc->gzoom();
@@ -526,21 +526,21 @@ void CDrawBuffer::resize()
526*/ 526*/
527 if (ascent > m_ascent) m_ascent = ascent; 527 if (ascent > m_ascent) m_ascent = ascent;
528 if (descent > m_descent) m_descent = descent; 528 if (descent > m_descent) m_descent = descent;
529 if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; 529 if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra;
530 m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; 530 m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing;
531 } 531 }
532 int lead = fc->getlead(); 532 int lead = fc->getlead();
533 if (lead != 0) 533 if (lead != 0)
534 { 534 {
535 int xt = (lead*m_lineSpacing+5)/10; 535 int xt = (lead*m_lineSpacing+5)/10;
536 m_descent += xt; 536 m_descent += xt;
537 m_lineSpacing += xt; 537 m_lineSpacing += xt;
538 } 538 }
539 if (m_bSop) 539 if (m_bSop)
540 { 540 {
541 int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10; 541 int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10;
542 //qDebug("ExtraSpace:%d", xt); 542 //odebug << "ExtraSpace:" << xt << "" << oendl;
543 m_ascent += xt; 543 m_ascent += xt;
544 m_lineSpacing += xt; 544 m_lineSpacing += xt;
545 } 545 }
546} 546}
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp
index d64abb4..b356ba5 100644
--- a/noncore/apps/opie-reader/QTReader.cpp
+++ b/noncore/apps/opie-reader/QTReader.cpp
@@ -67,57 +67,57 @@ QTReader::QTReader( QWidget *parent, const char *name, WFlags f) :
67/* 67/*
68QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : 68QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) :
69 QWidget(parent, name, f), 69 QWidget(parent, name, f),
70 m_textfont(0), 70 m_textfont(0),
71 m_textsize(1), 71 m_textsize(1),
72 textarray(NULL), 72 textarray(NULL),
73 numlines(0), 73 numlines(0),
74 bstripcr(true), 74 bstripcr(true),
75 bunindent(false), 75 bunindent(false),
76 brepara(false), 76 brepara(false),
77 bdblspce(false), 77 bdblspce(false),
78 btight(false), 78 btight(false),
79 bindenter(0), 79 bindenter(0),
80 m_fm(NULL) 80 m_fm(NULL)
81{ 81{
82 init(); 82 init();
83// // qDebug("Load_file(1)"); 83// // odebug << "Load_file(1)" << oendl;
84 load_file((const tchar*)filename); 84 load_file((const tchar*)filename);
85} 85}
86*/ 86*/
87 87
88/* 88/*
89void QTReader::mouseMoveEvent(QMouseEvent* _e) 89void QTReader::mouseMoveEvent(QMouseEvent* _e)
90{ 90{
91 91
92 mouseUpOn = !(_e->pos().x() == -1); 92 mouseUpOn = !(_e->pos().x() == -1);
93 93
94 qDebug("MouseMove:[%d, %d]", _e->pos().x(), _e->pos().y()); 94 odebug << "MouseMove:[" << _e->pos().x() << ", " << _e->pos().y() << "]" << oendl;
95} 95}
96*/ 96*/
97long QTReader::real_delay() 97long QTReader::real_delay()
98{ 98{
99 return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); 99 return ( 8976 + m_delay ) / ( m_linespacing * m_linespacing );
100} 100}
101 101
102void QTReader::mousePressEvent( QMouseEvent* _e ) 102void QTReader::mousePressEvent( QMouseEvent* _e )
103{ 103{
104 buffdoc.unsuspend(); 104 buffdoc.unsuspend();
105 if (_e->button() == RightButton) 105 if (_e->button() == RightButton)
106 { 106 {
107 //qDebug("MousePress"); 107 //odebug << "MousePress" << oendl;
108 mouseUpOn = false; 108 mouseUpOn = false;
109 if (m_swapmouse) 109 if (m_swapmouse)
110 { 110 {
111 int lineno = 0; 111 int lineno = 0;
112 int ht = textarray[0]->lineSpacing(); 112 int ht = textarray[0]->lineSpacing();
113 while ((ht < _e->y()) && (lineno < numlines)) 113 while ((ht < _e->y()) && (lineno < numlines))
114 { 114 {
115 ht += textarray[++lineno]->lineSpacing(); 115 ht += textarray[++lineno]->lineSpacing();
116 } 116 }
117 size_t startpos, startoffset, tgt; 117 size_t startpos, startoffset, tgt;
118 getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt); 118 getcurrentpos(_e->x(), _e->y(), startpos, startoffset, tgt);
119 processmousewordevent(startpos, startoffset, _e, lineno); 119 processmousewordevent(startpos, startoffset, _e, lineno);
120 } 120 }
121 else 121 else
122 processmousepositionevent(_e); 122 processmousepositionevent(_e);
123 } 123 }
@@ -304,55 +304,55 @@ void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouse
304 { 304 {
305 wrd[0] = textarray[lineno]->data()[chno]; 305 wrd[0] = textarray[lineno]->data()[chno];
306 } 306 }
307 } 307 }
308 else 308 else
309 { 309 {
310 CDrawBuffer* t = textarray[lineno]; 310 CDrawBuffer* t = textarray[lineno];
311 int first = 0; 311 int first = 0;
312 int tgt = _e->x() - t->offset(width(), m_border); 312 int tgt = _e->x() - t->offset(width(), m_border);
313 while (1) 313 while (1)
314 { 314 {
315 int i = first+1; 315 int i = first+1;
316 while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; 316 while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
317 if (t->width(i, true, width(), m_border) > tgt) 317 if (t->width(i, true, width(), m_border) > tgt)
318 { 318 {
319 wrd = toQString(t->data()+first, i - first); 319 wrd = toQString(t->data()+first, i - first);
320 // qDebug("Got %s", (const char *)wrd); 320 // odebug << "Got " << (const char *)wrd << "" << oendl;
321 break; 321 break;
322 } 322 }
323 while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; 323 while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
324 if ((*t)[i] == 0) break; 324 if ((*t)[i] == 0) break;
325 first = i; 325 first = i;
326 } 326 }
327 } 327 }
328 if (!wrd.isEmpty()) 328 if (!wrd.isEmpty())
329 { 329 {
330 //qDebug("Selected:%s", (const char*)wrd); 330 //odebug << "Selected:" << wrd << "" << oendl;
331 emit OnWordSelected(wrd, locnarray[lineno], (m_twotouch) ? wrd : toQString(textarray[lineno]->data())); 331 emit OnWordSelected(wrd, locnarray[lineno], (m_twotouch) ? wrd : toQString(textarray[lineno]->data()));
332 } 332 }
333} 333}
334 334
335void QTReader::mouseReleaseEvent( QMouseEvent* _e ) 335void QTReader::mouseReleaseEvent( QMouseEvent* _e )
336{ 336{
337 buffdoc.unsuspend(); 337 buffdoc.unsuspend();
338 if (_e->button() == LeftButton) 338 if (_e->button() == LeftButton)
339 { 339 {
340 if (mouseUpOn) 340 if (mouseUpOn)
341 { 341 {
342 // qDebug("MouseRelease"); 342 // odebug << "MouseRelease" << oendl;
343 if (_e->x() > width() - m_border) 343 if (_e->x() > width() - m_border)
344 { 344 {
345 locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*_e->y()+height()/2)/height()); 345 locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*_e->y()+height()/2)/height());
346 return; 346 return;
347 } 347 }
348 if (textarray[0] != NULL) 348 if (textarray[0] != NULL)
349 { 349 {
350 QString line; 350 QString line;
351 // int lineno = _e->y()/m_linespacing; 351 // int lineno = _e->y()/m_linespacing;
352 int lineno = 0; 352 int lineno = 0;
353 int ht = textarray[0]->lineSpacing(); 353 int ht = textarray[0]->lineSpacing();
354 while ((ht < _e->y()) && (lineno < numlines)) 354 while ((ht < _e->y()) && (lineno < numlines))
355 { 355 {
356 ht += textarray[++lineno]->lineSpacing(); 356 ht += textarray[++lineno]->lineSpacing();
357 } 357 }
358 size_t startpos, startoffset, tgt; 358 size_t startpos, startoffset, tgt;
@@ -381,49 +381,49 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e )
381 } 381 }
382 } 382 }
383 else 383 else
384 { 384 {
385 // QString anchortext = textarray[lineno]->getanchortext(startoffset); 385 // QString anchortext = textarray[lineno]->getanchortext(startoffset);
386 if (!href.isEmpty()) 386 if (!href.isEmpty())
387 { 387 {
388 emit OnURLSelected(href); 388 emit OnURLSelected(href);
389 } 389 }
390 } 390 }
391 locate(pagelocate()); 391 locate(pagelocate());
392 } 392 }
393 return; 393 return;
394 } 394 }
395 case ePicture: 395 case ePicture:
396 { 396 {
397 // qDebug("Picture:%x", tgt); 397 // odebug << "Picture:" << tgt << "" << oendl;
398 QImage* pm = buffdoc.getPicture(tgt); 398 QImage* pm = buffdoc.getPicture(tgt);
399 if (pm != NULL) 399 if (pm != NULL)
400 { 400 {
401 emit OnShowPicture(*pm); 401 emit OnShowPicture(*pm);
402 delete pm; 402 delete pm;
403 } 403 }
404 else 404 else
405 { 405 {
406 locate(pagelocate()); 406 locate(pagelocate());
407 } 407 }
408 return; 408 return;
409 } 409 }
410 case eNone: 410 case eNone:
411 break; 411 break;
412 default: 412 default:
413 // qDebug("Unknown linktype"); 413 // odebug << "Unknown linktype" << oendl;
414 return; 414 return;
415 } 415 }
416 if (m_swapmouse) 416 if (m_swapmouse)
417 processmousepositionevent(_e); 417 processmousepositionevent(_e);
418 else 418 else
419 processmousewordevent(startpos, startoffset, _e, lineno); 419 processmousewordevent(startpos, startoffset, _e, lineno);
420 } 420 }
421 } 421 }
422 else 422 else
423 { 423 {
424 mouseUpOn = true; 424 mouseUpOn = true;
425 } 425 }
426 } 426 }
427} 427}
428 428
429void QTReader::focusInEvent(QFocusEvent* e) 429void QTReader::focusInEvent(QFocusEvent* e)
@@ -683,33 +683,33 @@ void QTReader::setautoscroll(bool _sc)
683#ifdef _SCROLLPIPE 683#ifdef _SCROLLPIPE
684 if (m_pipeout != NULL) 684 if (m_pipeout != NULL)
685 { 685 {
686 pclose(m_pipeout); 686 pclose(m_pipeout);
687 m_pipeout = NULL; 687 m_pipeout = NULL;
688 } 688 }
689#endif 689#endif
690 } 690 }
691 else 691 else
692 { 692 {
693 CDrawBuffer* reusebuffer = textarray[numlines]; 693 CDrawBuffer* reusebuffer = textarray[numlines];
694 if (reusebuffer == NULL || reusebuffer->eof()) return; 694 if (reusebuffer == NULL || reusebuffer->eof()) return;
695 m_autoScroll = true; 695 m_autoScroll = true;
696#ifdef _SCROLLPIPE 696#ifdef _SCROLLPIPE
697 if (!m_pipetarget.isEmpty()) 697 if (!m_pipetarget.isEmpty())
698 { 698 {
699 // qDebug("Opening pipe to %s", (const char*)m_pipetarget); 699 // odebug << "Opening pipe to " << m_pipetarget << "" << oendl;
700 m_pipeout = popen((const char*)m_pipetarget, "w"); 700 m_pipeout = popen((const char*)m_pipetarget, "w");
701 m_isPaused = false; 701 m_isPaused = false;
702 } 702 }
703#endif 703#endif
704 autoscroll(); 704 autoscroll();
705#ifdef USEQPE 705#ifdef USEQPE
706 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed 706 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed
707#endif 707#endif
708 } 708 }
709} 709}
710 710
711bool QTReader::getline(CDrawBuffer *buff) 711bool QTReader::getline(CDrawBuffer *buff)
712{ 712{
713 buffdoc.unsuspend(); 713 buffdoc.unsuspend();
714 if (m_bMonoSpaced) 714 if (m_bMonoSpaced)
715 { 715 {
@@ -810,73 +810,73 @@ void QTReader::autoscroll()
810} 810}
811 811
812void QTReader::setfont() 812void QTReader::setfont()
813{ 813{
814// m_fontControl.Change 814// m_fontControl.Change
815 m_charWidth = (m_charpc*m_fontControl.currentsize())/100; 815 m_charWidth = (m_charpc*m_fontControl.currentsize())/100;
816 if (m_charWidth <= 0) m_charWidth = 1; 816 if (m_charWidth <= 0) m_charWidth = 1;
817 m_ascent = m_fontControl.ascent(); 817 m_ascent = m_fontControl.ascent();
818 m_descent = m_fontControl.descent(); 818 m_descent = m_fontControl.descent();
819 m_linespacing = m_fontControl.lineSpacing(); 819 m_linespacing = m_fontControl.lineSpacing();
820} 820}
821 821
822void QTReader::drawFonts( QPainter *p ) 822void QTReader::drawFonts( QPainter *p )
823{ 823{
824 if (bDoUpdates) 824 if (bDoUpdates)
825 { 825 {
826 //qDebug("How refreshing..."); 826 //odebug << "How refreshing..." << oendl;
827 if (buffdoc.empty()) return; 827 if (buffdoc.empty()) return;
828 setfont(); 828 setfont();
829 if (m_lastwidth != width()) 829 if (m_lastwidth != width())
830 { 830 {
831 // qDebug("Not Optimised %d", m_lastwidth); 831 // odebug << "Not Optimised " << m_lastwidth << "" << oendl;
832 m_lastwidth = width(); 832 m_lastwidth = width();
833 m_lastheight = height(); 833 m_lastheight = height();
834 buffdoc.setwidth(m_lastwidth-2*m_border); 834 buffdoc.setwidth(m_lastwidth-2*m_border);
835 locate(pagelocate()); 835 locate(pagelocate());
836 // qDebug("Not Optimised %d", m_lastwidth); 836 // odebug << "Not Optimised " << m_lastwidth << "" << oendl;
837 } 837 }
838 else 838 else
839 { 839 {
840 int newht = height(); 840 int newht = height();
841 if (m_lastheight > newht) 841 if (m_lastheight > newht)
842 { 842 {
843 // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht); 843 // odebug << "Optimised < " << numlines << " " << m_lastheight << " " << newht << "" << oendl;
844 int ypos = 0; 844 int ypos = 0;
845 for (int i = 0; i < numlines; i++) 845 for (int i = 0; i < numlines; i++)
846 { 846 {
847 if ((ypos += textarray[i]->lineSpacing()) > newht) 847 if ((ypos += textarray[i]->lineSpacing()) > newht)
848 { 848 {
849 numlines = i; 849 numlines = i;
850 jumpto(mylastpos = locnarray[i+1]); 850 jumpto(mylastpos = locnarray[i+1]);
851 break; 851 break;
852 } 852 }
853 } 853 }
854 // qDebug("Optimised < %d", numlines); 854 // odebug << "Optimised < " << numlines << "" << oendl;
855 m_lastheight = newht; 855 m_lastheight = newht;
856 } 856 }
857 else if (m_lastheight < newht) 857 else if (m_lastheight < newht)
858 { 858 {
859 // qDebug("Optimised > %d", numlines); 859 // odebug << "Optimised > " << numlines << "" << oendl;
860 int ypos = 0; 860 int ypos = 0;
861 for (int i = 0; i <= numlines; i++) 861 for (int i = 0; i <= numlines; i++)
862 { 862 {
863 ypos += textarray[i]->lineSpacing(); 863 ypos += textarray[i]->lineSpacing();
864 } 864 }
865 fillbuffer(numlines+1, ypos, newht); 865 fillbuffer(numlines+1, ypos, newht);
866 // qDebug("Optimised > %d", numlines); 866 // odebug << "Optimised > " << numlines << "" << oendl;
867 } 867 }
868 if (numlines > 0) 868 if (numlines > 0)
869 { 869 {
870 int ypos = textarray[0]->ascent(); 870 int ypos = textarray[0]->ascent();
871 textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_border); 871 textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_border);
872 // int last = (m_showlast) ? numlines : numlines-1; 872 // int last = (m_showlast) ? numlines : numlines-1;
873 // for (int i = 1; i <= last; i++) 873 // for (int i = 1; i <= last; i++)
874 for (int i = 1; i < numlines; i++) 874 for (int i = 1; i < numlines; i++)
875 { 875 {
876 // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; 876 // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2;
877 ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ 877 ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+
878 (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; 878 (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2;
879 textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_border); 879 textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_border);
880 } 880 }
881// mylastpos = locate(); 881// mylastpos = locate();
882 } 882 }
@@ -884,33 +884,33 @@ void QTReader::drawFonts( QPainter *p )
884 884
885 m_scrolldy1 = m_scrolldy2 = m_scrollpart; 885 m_scrolldy1 = m_scrolldy2 = m_scrollpart;
886 if (m_border > 5 && !buffdoc.empty()) 886 if (m_border > 5 && !buffdoc.empty())
887 { 887 {
888 p->fillRect(width()-2, 0, 2, height(), cyan); 888 p->fillRect(width()-2, 0, 2, height(), cyan);
889 int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); 889 int sectionsize = (buffdoc.endSection()-buffdoc.startSection());
890 int mid = (height()*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize); 890 int mid = (height()*(locnarray[numlines]+locnarray[0]-2*buffdoc.startSection())+sectionsize)/(2*sectionsize);
891 p->fillRect(width()-2, mid-5, 2, 10, yellow); 891 p->fillRect(width()-2, mid-5, 2, 10, yellow);
892 p->fillRect(width()-2, (height()*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize, 2, ((locnarray[numlines]-locnarray[0])*height()+sectionsize/2)/sectionsize, magenta); 892 p->fillRect(width()-2, (height()*(locnarray[0]-buffdoc.startSection())+sectionsize/2)/sectionsize, 2, ((locnarray[numlines]-locnarray[0])*height()+sectionsize/2)/sectionsize, magenta);
893 } 893 }
894 894
895 emit OnRedraw(); 895 emit OnRedraw();
896 } 896 }
897/* 897/*
898 else 898 else
899 { 899 {
900 qDebug("Not so refreshing..."); 900 odebug << "Not so refreshing..." << oendl;
901 } 901 }
902*/ 902*/
903} 903}
904 904
905QString QTReader::firstword() 905QString QTReader::firstword()
906{ 906{
907 if (m_bMonoSpaced) 907 if (m_bMonoSpaced)
908 { 908 {
909 return toQString(textarray[0]->data()); 909 return toQString(textarray[0]->data());
910 } 910 }
911 else 911 else
912 { 912 {
913 int start, end, len, j; 913 int start, end, len, j;
914 for (j = 0; j < numlines; j++) 914 for (j = 0; j < numlines; j++)
915 { 915 {
916 len = textarray[j]->length(); 916 len = textarray[j]->length();
@@ -1015,62 +1015,62 @@ void QTReader::printIt()
1015// 1015//
1016 1016
1017void QTReader::paintEvent( QPaintEvent * ) 1017void QTReader::paintEvent( QPaintEvent * )
1018{ 1018{
1019 QPainter paint( this ); 1019 QPainter paint( this );
1020 drawIt( &paint ); 1020 drawIt( &paint );
1021} 1021}
1022 1022
1023// 1023//
1024// Called when the widget has been resized. 1024// Called when the widget has been resized.
1025// Moves the button group to the upper right corner 1025// Moves the button group to the upper right corner
1026// of the widget. 1026// of the widget.
1027 1027
1028/* 1028/*
1029void QTReader::resizeEvent( QResizeEvent * ) 1029void QTReader::resizeEvent( QResizeEvent * )
1030{ 1030{
1031// // qDebug("resize:(%u,%u)", width(), height()); 1031// // odebug << "resize:(" << width() << "," << height() << ")" << oendl;
1032 // bgroup->move( width()-bgroup->width(), 0 ); 1032 // bgroup->move( width()-bgroup->width(), 0 );
1033} 1033}
1034*/ 1034*/
1035 1035
1036// 1036//
1037// Create and display our widget. 1037// Create and display our widget.
1038// 1038//
1039/* 1039/*
1040int main( int argc, tchar **argv ) 1040int main( int argc, tchar **argv )
1041{ 1041{
1042 QApplication app( argc, argv ); 1042 QApplication app( argc, argv );
1043 QTReader draw; 1043 QTReader draw;
1044 app.setMainWidget( &draw ); 1044 app.setMainWidget( &draw );
1045 draw.setCaption("Qt Example - Drawdemo"); 1045 draw.setCaption("Qt Example - Drawdemo");
1046 draw.show(); 1046 draw.show();
1047 return app.exec(); 1047 return app.exec();
1048} 1048}
1049*/ 1049*/
1050 1050
1051 1051
1052bool QTReader::locate(unsigned long n) { 1052bool QTReader::locate(unsigned long n) {
1053 //printf("Locate\n"); 1053 //printf("Locate\n");
1054 buffdoc.unsuspend(); 1054 buffdoc.unsuspend();
1055 buffdoc.locate(n); 1055 buffdoc.locate(n);
1056// // qDebug("&buffdoc.located"); 1056// // odebug << "&buffdoc.located" << oendl;
1057 fillbuffer(); 1057 fillbuffer();
1058// // qDebug("&Buffer filled"); 1058// // odebug << "&Buffer filled" << oendl;
1059 update(); 1059 update();
1060// // qDebug("&Located"); 1060// // odebug << "&Located" << oendl;
1061 return true; 1061 return true;
1062} 1062}
1063 1063
1064unsigned int QTReader::screenlines() 1064unsigned int QTReader::screenlines()
1065{ 1065{
1066 // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; 1066 // int linespacing = (tight) ? m_ascent : m_ascent+m_descent;
1067 // return (height()-m_descent)/(m_linespacing); 1067 // return (height()-m_descent)/(m_linespacing);
1068 return (height()-2)/(m_linespacing); 1068 return (height()-2)/(m_linespacing);
1069}; 1069};
1070 1070
1071bool QTReader::fillbuffer(int reuse, int ht, int newht) 1071bool QTReader::fillbuffer(int reuse, int ht, int newht)
1072{ 1072{
1073 buffdoc.unsuspend(); 1073 buffdoc.unsuspend();
1074 if (buffdoc.empty()) return false; 1074 if (buffdoc.empty()) return false;
1075 if (newht < 0) 1075 if (newht < 0)
1076 m_lastheight = height(); 1076 m_lastheight = height();
@@ -1104,38 +1104,38 @@ bool QTReader::fillbuffer(int reuse, int ht, int newht)
1104 --numlines; 1104 --numlines;
1105 mylastpos = locate(); 1105 mylastpos = locate();
1106 return true; 1106 return true;
1107 } 1107 }
1108 } 1108 }
1109 } 1109 }
1110 1110
1111 --numlines; 1111 --numlines;
1112 mylastpos = locate(); 1112 mylastpos = locate();
1113 m_scrolldy1 = m_scrolldy2 = m_scrollpart = m_lastheight - lastypos; 1113 m_scrolldy1 = m_scrolldy2 = m_scrollpart = m_lastheight - lastypos;
1114 1114
1115 return true; 1115 return true;
1116} 1116}
1117 1117
1118void QTReader::dopagedn() 1118void QTReader::dopagedn()
1119{ 1119{
1120// qDebug("HEIGHT(2):%d", m_lastheight); 1120// odebug << "HEIGHT(2):" << m_lastheight << "" << oendl;
1121 buffdoc.unsuspend(); 1121 buffdoc.unsuspend();
1122 int skip = 0, ypos = 0; 1122 int skip = 0, ypos = 0;
1123 if (locate() != mylastpos) 1123 if (locate() != mylastpos)
1124 { 1124 {
1125 ////qDebug("Jumping to %u", mylastpos); 1125 ////odebug << "Jumping to " << mylastpos << "" << oendl;
1126 jumpto(mylastpos); 1126 jumpto(mylastpos);
1127 } 1127 }
1128 CDrawBuffer* reusebuffer = textarray[numlines]; 1128 CDrawBuffer* reusebuffer = textarray[numlines];
1129 if (reusebuffer != NULL && reusebuffer->eof()) return; 1129 if (reusebuffer != NULL && reusebuffer->eof()) return;
1130 if (reusebuffer != NULL) 1130 if (reusebuffer != NULL)
1131 { 1131 {
1132 for (int i = 0; i <= m_overlap; i++) 1132 for (int i = 0; i <= m_overlap; i++)
1133 { 1133 {
1134 int offset = numlines - m_overlap + i; 1134 int offset = numlines - m_overlap + i;
1135 reusebuffer = textarray[offset]; 1135 reusebuffer = textarray[offset];
1136 size_t reuselocn = locnarray[offset]; 1136 size_t reuselocn = locnarray[offset];
1137 textarray[offset] = textarray[i]; 1137 textarray[offset] = textarray[i];
1138 textarray[i] = reusebuffer; 1138 textarray[i] = reusebuffer;
1139 // reusebuffer->empty(); 1139 // reusebuffer->empty();
1140 locnarray[offset] = locnarray[i]; 1140 locnarray[offset] = locnarray[i];
1141 locnarray[i] = reuselocn; 1141 locnarray[i] = reuselocn;
@@ -1300,39 +1300,39 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn)
1300 1300
1301 bool bRC = false; 1301 bool bRC = false;
1302 unsigned int lcn = _lcn; 1302 unsigned int lcn = _lcn;
1303 if (m_lastfile == newfile) 1303 if (m_lastfile == newfile)
1304 { 1304 {
1305 lcn = m_lastposn; 1305 lcn = m_lastposn;
1306 } 1306 }
1307 // QMessageBox::information(0, "Opening...", newfile); 1307 // QMessageBox::information(0, "Opening...", newfile);
1308 m_lastwidth = width(); 1308 m_lastwidth = width();
1309 m_lastheight = height(); 1309 m_lastheight = height();
1310 if (buffdoc.openfile(this,newfile) == 0) 1310 if (buffdoc.openfile(this,newfile) == 0)
1311 { 1311 {
1312 m_lastfile = newfile; 1312 m_lastfile = newfile;
1313 buffdoc.setwidth(m_lastwidth-2*m_border); 1313 buffdoc.setwidth(m_lastwidth-2*m_border);
1314 bRC = true; 1314 bRC = true;
1315 buffdoc.setContinuous(m_continuousDocument); 1315 buffdoc.setContinuous(m_continuousDocument);
1316// // qDebug("buffdoc.openfile done"); 1316// // odebug << "buffdoc.openfile done" << oendl;
1317 locate(lcn); 1317 locate(lcn);
1318// // qDebug("buffdoc.locate done"); 1318// // odebug << "buffdoc.locate done" << oendl;
1319 } 1319 }
1320 setfilter(getfilter()); 1320 setfilter(getfilter());
1321 update(); 1321 update();
1322// // qDebug("Updated"); 1322// // odebug << "Updated" << oendl;
1323 return bRC; 1323 return bRC;
1324} 1324}
1325 1325
1326void QTReader::lineDown() 1326void QTReader::lineDown()
1327{ 1327{
1328 int ypos = 0; 1328 int ypos = 0;
1329 int offset = numlines; 1329 int offset = numlines;
1330 1330
1331 for (int i = 0; i <= numlines; i++) 1331 for (int i = 0; i <= numlines; i++)
1332 { 1332 {
1333 if ((ypos += textarray[numlines-i]->lineSpacing()) > height()) 1333 if ((ypos += textarray[numlines-i]->lineSpacing()) > height())
1334 { 1334 {
1335 offset = i-1; 1335 offset = i-1;
1336 break; 1336 break;
1337 } 1337 }
1338 } 1338 }
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index b072854..f18cb59 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -4,98 +4,99 @@
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20
20#include "useqpe.h" 21#include "useqpe.h"
21#include <qregexp.h> 22#include "QTReader.h"
22#include <qclipboard.h> 23#include "GraphicWin.h"
23#include <qwidgetstack.h> 24#include "Bkmks.h"
25#include "cbkmkselector.h"
26#include "infowin.h"
27#include "ToolbarPrefs.h"
28#include "Prefs.h"
29#include "CAnnoEdit.h"
30#include "QFloatBar.h"
31#include "FixedFont.h"
32#include "URLDialog.h"
33#include "QTReaderApp.h"
34#include "CDrawBuffer.h"
35#include "Filedata.h"
36#include "opie.h"
37#include "names.h"
38#include "CEncoding_tables.h"
39#include "CloseDialog.h"
40
41/* OPIE */
42#include <opie2/odebug.h>
43#ifdef USEQPE
44#include <qpe/menubutton.h>
45#include <qpe/fontdatabase.h>
46#include <qpe/global.h>
47#include <qpe/applnk.h>
48#include <qpe/config.h>
49#include <qpe/qcopenvelope_qws.h>
50#endif
51
52/* QT */
24#ifdef USEQPE 53#ifdef USEQPE
25#include <qmenubar.h> 54#include <qmenubar.h>
26#include <qtoolbar.h> 55#include <qtoolbar.h>
27#endif 56#endif
57#include <qregexp.h>
58#include <qclipboard.h>
59#include <qwidgetstack.h>
28#include <qmenubar.h> 60#include <qmenubar.h>
29#include <qtoolbar.h> 61#include <qtoolbar.h>
30#ifdef USEQPE
31#include <qpe/menubutton.h>
32#include <qpe/fontdatabase.h>
33#endif
34#include <qcombobox.h> 62#include <qcombobox.h>
35#include <qpopupmenu.h> 63#include <qpopupmenu.h>
36#include <qaction.h> 64#include <qaction.h>
37#include <qapplication.h> 65#include <qapplication.h>
38#include <qlineedit.h> 66#include <qlineedit.h>
39#include <qtoolbutton.h> 67#include <qtoolbutton.h>
40#include <qspinbox.h> 68#include <qspinbox.h>
41#include <qobjectlist.h> 69#include <qobjectlist.h>
42#ifdef USEQPE
43#include <qpe/global.h>
44#include <qpe/applnk.h>
45#endif
46#include <qfileinfo.h> 70#include <qfileinfo.h>
47#include <stdlib.h> //getenv
48#include <qprogressbar.h> 71#include <qprogressbar.h>
49#ifdef USEQPE
50#include <qpe/config.h>
51#endif
52#include <qbuttongroup.h> 72#include <qbuttongroup.h>
53#include <qradiobutton.h> 73#include <qradiobutton.h>
54#ifdef USEQPE 74
55#include <qpe/qcopenvelope_qws.h> 75/* STD */
56#endif 76#include <stdlib.h> //getenv
57#include "QTReader.h" 77
58#include "GraphicWin.h"
59#include "Bkmks.h"
60#include "cbkmkselector.h"
61#include "infowin.h"
62#include "ToolbarPrefs.h"
63#include "Prefs.h"
64#include "CAnnoEdit.h"
65#include "QFloatBar.h"
66#include "FixedFont.h"
67#include "URLDialog.h"
68//#include <qpe/fontdatabase.h>
69 78
70#ifdef USEQPE 79#ifdef USEQPE
71#include <qpe/resource.h> 80#include <qpe/resource.h>
72#include <qpe/qpeapplication.h> 81#include <qpe/qpeapplication.h>
73#include "fileBrowser.h" 82#include "fileBrowser.h"
74#else 83#else
75#include "qfiledialog.h" 84#include "qfiledialog.h"
76#endif 85#endif
77 86
78#include "QTReaderApp.h"
79#include "CDrawBuffer.h"
80#include "Filedata.h"
81#include "opie.h"
82#include "names.h"
83#include "CEncoding_tables.h"
84#include "CloseDialog.h"
85
86bool CheckVersion(int&, int&, char&); 87bool CheckVersion(int&, int&, char&);
87 88
88#ifdef _WINDOWS 89#ifdef _WINDOWS
89#define PICDIR "c:\\uqtreader\\pics\\" 90#define PICDIR "c:\\uqtreader\\pics\\"
90#else 91#else
91#ifdef USEQPE 92#ifdef USEQPE
92#define PICDIR "opie-reader/" 93#define PICDIR "opie-reader/"
93#else 94#else
94#define PICDIR "/home/tim/uqtreader/pics/" 95#define PICDIR "/home/tim/uqtreader/pics/"
95#endif 96#endif
96#endif 97#endif
97 98
98unsigned long QTReaderApp::m_uid = 0; 99unsigned long QTReaderApp::m_uid = 0;
99 100
100void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } 101void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); }
101 102
@@ -112,174 +113,174 @@ void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); }
112#include <unistd.h> 113#include <unistd.h>
113#endif 114#endif
114#include <stddef.h> 115#include <stddef.h>
115#ifndef _WINDOWS 116#ifndef _WINDOWS
116#include <dirent.h> 117#include <dirent.h>
117#endif 118#endif
118 119
119void QTReaderApp::listBkmkFiles() 120void QTReaderApp::listBkmkFiles()
120{ 121{
121 bkmkselector->clear(); 122 bkmkselector->clear();
122 bkmkselector->setText("Cancel"); 123 bkmkselector->setText("Cancel");
123#ifndef USEQPE 124#ifndef USEQPE
124 int cnt = 0; 125 int cnt = 0;
125 126
126 QDir d = QDir::home(); // "/" 127 QDir d = QDir::home(); // "/"
127 if ( !d.cd(APPDIR) ) { // "/tmp" 128 if ( !d.cd(APPDIR) ) { // "/tmp"
128 qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); 129 owarn << "Cannot find the \"~/" APPDIR "\" directory" << oendl;
129 d = QDir::home(); 130 d = QDir::home();
130 d.mkdir(APPDIR); 131 d.mkdir(APPDIR);
131 d.cd(APPDIR); 132 d.cd(APPDIR);
132 } 133 }
133 134
134 135
135 136
136 137
137 d.setFilter( QDir::Files | QDir::NoSymLinks ); 138 d.setFilter( QDir::Files | QDir::NoSymLinks );
138// d.setSorting( QDir::Size | QDir::Reversed ); 139// d.setSorting( QDir::Size | QDir::Reversed );
139 140
140 const QFileInfoList *list = d.entryInfoList(); 141 const QFileInfoList *list = d.entryInfoList();
141 QFileInfoListIterator it( *list ); // create list iterator 142 QFileInfoListIterator it( *list ); // create list iterator
142 QFileInfo *fi; // pointer for traversing 143 QFileInfo *fi; // pointer for traversing
143 144
144 while ( (fi=it.current()) ) { // for each file... 145 while ( (fi=it.current()) ) { // for each file...
145 146
146 bkmkselector->insertItem(fi->fileName()); 147 bkmkselector->insertItem(fi->fileName());
147 cnt++; 148 cnt++;
148 149
149 //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); 150 //odebug << "" << fi->size() << " " << fi->fileName().data() << "" << oendl;
150 ++it; // goto next list element 151 ++it; // goto next list element
151 } 152 }
152 153
153#else /* USEQPE */ 154#else /* USEQPE */
154 int cnt = 0; 155 int cnt = 0;
155 DIR *d; 156 DIR *d;
156 d = opendir((const char *)Global::applicationFileName(APPDIR,"")); 157 d = opendir((const char *)Global::applicationFileName(APPDIR,""));
157 158
158 while(1) 159 while(1)
159 { 160 {
160 struct dirent* de; 161 struct dirent* de;
161 struct stat buf; 162 struct stat buf;
162 de = readdir(d); 163 de = readdir(d);
163 if (de == NULL) break; 164 if (de == NULL) break;
164 165
165 if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) 166 if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode))
166 { 167 {
167 bkmkselector->insertItem(de->d_name); 168 bkmkselector->insertItem(de->d_name);
168 cnt++; 169 cnt++;
169 } 170 }
170 } 171 }
171 172
172 closedir(d); 173 closedir(d);
173#endif 174#endif
174 if (cnt > 0) 175 if (cnt > 0)
175 { 176 {
176//tjw menu->hide(); 177//tjw menu->hide();
177 editorStack->raiseWidget( bkmkselector ); 178 editorStack->raiseWidget( bkmkselector );
178 hidetoolbars(); 179 hidetoolbars();
179 m_nBkmkAction = cRmBkmkFile; 180 m_nBkmkAction = cRmBkmkFile;
180 } 181 }
181 else 182 else
182 QMessageBox::information(this, PROGNAME, "No bookmark files"); 183 QMessageBox::information(this, PROGNAME, "No bookmark files");
183} 184}
184 185
185void QTReaderApp::hidetoolbars() 186void QTReaderApp::hidetoolbars()
186{ 187{
187 menubar->hide(); 188 menubar->hide();
188 if (fileBar != NULL) fileBar->hide(); 189 if (fileBar != NULL) fileBar->hide();
189 if (viewBar != NULL) viewBar->hide(); 190 if (viewBar != NULL) viewBar->hide();
190 if (navBar != NULL) navBar->hide(); 191 if (navBar != NULL) navBar->hide();
191 if (markBar != NULL) markBar->hide(); 192 if (markBar != NULL) markBar->hide();
192 if (m_fontVisible) m_fontBar->hide(); 193 if (m_fontVisible) m_fontBar->hide();
193 if (regVisible) 194 if (regVisible)
194 { 195 {
195#ifdef USEQPE 196#ifdef USEQPE
196 Global::hideInputMethod(); 197 Global::hideInputMethod();
197#endif 198#endif
198 regBar->hide(); 199 regBar->hide();
199 } 200 }
200 if (searchVisible) 201 if (searchVisible)
201 { 202 {
202#ifdef USEQPE 203#ifdef USEQPE
203 Global::hideInputMethod(); 204 Global::hideInputMethod();
204#endif 205#endif
205 searchBar->hide(); 206 searchBar->hide();
206 } 207 }
207} 208}
208 209
209QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) 210QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
210 : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false), 211 : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false),
211 fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL) 212 fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL)
212{ 213{
213 m_url_clipboard = false; 214 m_url_clipboard = false;
214 m_url_localfile = false; 215 m_url_localfile = false;
215 m_url_globalfile = false; 216 m_url_globalfile = false;
216 ftime(&m_lastkeytime); 217 ftime(&m_lastkeytime);
217//// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); 218//// odebug << "Application directory = " << (const tchar *)QPEApplication::documentDir() << "" << oendl;
218//// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); 219//// odebug << "Application directory = " << (const tchar *)Global::applicationFileName("uqtreader" << "" << oendl;
219 220
220 m_bcloseDisabled = true; 221 m_bcloseDisabled = true;
221 m_disableesckey = false; 222 m_disableesckey = false;
222 pBkmklist = NULL; 223 pBkmklist = NULL;
223 pOpenlist = NULL; 224 pOpenlist = NULL;
224// doc = 0; 225// doc = 0;
225 226
226 m_fBkmksChanged = false; 227 m_fBkmksChanged = false;
227 228
228 QString lang = getenv( "LANG" ); 229 QString lang = getenv( "LANG" );
229 QString rot = getenv( "QWS_DISPLAY" ); 230 QString rot = getenv( "QWS_DISPLAY" );
230 231
231/* 232/*
232 int m_rot = 0; 233 int m_rot = 0;
233 if (rot.contains("Rot90")) 234 if (rot.contains("Rot90"))
234 { 235 {
235 m_rot = 90; 236 m_rot = 90;
236 } 237 }
237 else if (rot.contains("Rot180")) 238 else if (rot.contains("Rot180"))
238 { 239 {
239 m_rot = 180; 240 m_rot = 180;
240 } 241 }
241 else if (rot.contains("Rot270")) 242 else if (rot.contains("Rot270"))
242 { 243 {
243 m_rot = 270; 244 m_rot = 270;
244 } 245 }
245 246
246// qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); 247// odebug << "Initial Rotation(" << m_rot << "):" << rot << "" << oendl;
247*/ 248*/
248 m_autogenstr = "^ *[A-Z].*[a-z] *$"; 249 m_autogenstr = "^ *[A-Z].*[a-z] *$";
249 250
250#ifdef USEQPE 251#ifdef USEQPE
251 setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); 252 setIcon( Resource::loadPixmap( PICDIR "uqtreader") );
252#else 253#else
253 setIcon( QPixmap (PICDIR "uqtreader.png") ); 254 setIcon( QPixmap (PICDIR "uqtreader.png") );
254#endif /* USEQPE */ 255#endif /* USEQPE */
255 256
256// QToolBar *bar = new QToolBar( this ); 257// QToolBar *bar = new QToolBar( this );
257// menubar = new QToolBar( this ); 258// menubar = new QToolBar( this );
258#ifdef USEQPE 259#ifdef USEQPE
259 Config config( APPDIR ); 260 Config config( APPDIR );
260#else 261#else
261 QDir d = QDir::home(); // "/" 262 QDir d = QDir::home(); // "/"
262 if ( !d.cd(APPDIR) ) { // "/tmp" 263 if ( !d.cd(APPDIR) ) { // "/tmp"
263 qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); 264 owarn << "Cannot find the \"~/" APPDIR "\" directory" << oendl;
264 d = QDir::home(); 265 d = QDir::home();
265 d.mkdir(APPDIR); 266 d.mkdir(APPDIR);
266 d.cd(APPDIR); 267 d.cd(APPDIR);
267 } 268 }
268 QFileInfo fi(d, INIFILE); 269 QFileInfo fi(d, INIFILE);
269// qDebug("Path:%s", (const char*)fi.absFilePath()); 270// odebug << "Path:" << fi.absFilePath() << "" << oendl;
270 Config config(fi.absFilePath()); 271 Config config(fi.absFilePath());
271#endif 272#endif
272 config.setGroup("Toolbar"); 273 config.setGroup("Toolbar");
273 m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); 274 m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false);
274 m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); 275 m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1);
275 m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); 276 m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2);
276 menubar = new QToolBar("Menus", this, m_tbposition); 277 menubar = new QToolBar("Menus", this, m_tbposition);
277 278
278// fileBar = new QToolBar("File", this); 279// fileBar = new QToolBar("File", this);
279// QToolBar* viewBar = new QToolBar("File", this); 280// QToolBar* viewBar = new QToolBar("File", this);
280// QToolBar* navBar = new QToolBar("File", this); 281// QToolBar* navBar = new QToolBar("File", this);
281// QToolBar* markBar = new QToolBar("File", this); 282// QToolBar* markBar = new QToolBar("File", this);
282 283
283#ifdef USEQPE 284#ifdef USEQPE
284 mb = new QMenuBar( menubar ); 285 mb = new QMenuBar( menubar );
285#else 286#else
@@ -342,45 +343,45 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
342 343
343// bkmkselector = new QListBox(editorStack, "Bookmarks"); 344// bkmkselector = new QListBox(editorStack, "Bookmarks");
344 bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); 345 bkmkselector = new CBkmkSelector(editorStack, "Bookmarks");
345 // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); 346 // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) );
346 connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); 347 connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) );
347 connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); 348 connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) );
348 editorStack->addWidget( bkmkselector, get_unique_id() ); 349 editorStack->addWidget( bkmkselector, get_unique_id() );
349 350
350/* 351/*
351 importSelector = new FileSelector( "*", editorStack, "importselector", false ); 352 importSelector = new FileSelector( "*", editorStack, "importselector", false );
352 connect( importSelector, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( importFile(const DocLnk&) ) ); 353 connect( importSelector, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( importFile(const DocLnk&) ) );
353 354
354 editorStack->addWidget( importSelector, get_unique_id() ); 355 editorStack->addWidget( importSelector, get_unique_id() );
355 356
356 // don't need the close visible, it is redundant... 357 // don't need the close visible, it is redundant...
357 importSelector->setCloseVisible( FALSE ); 358 importSelector->setCloseVisible( FALSE );
358*/ 359*/
359// qDebug("Reading file list"); 360// odebug << "Reading file list" << oendl;
360 readfilelist(); 361 readfilelist();
361 362
362 reader = new QTReader( editorStack ); 363 reader = new QTReader( editorStack );
363 364
364 reader->bDoUpdates = false; 365 reader->bDoUpdates = false;
365 366
366#ifdef USEQPE 367#ifdef USEQPE
367 ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); 368 ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold);
368#endif 369#endif
369 370
370// qDebug("Reading config"); 371// odebug << "Reading config" << oendl;
371// Config config( APPDIR ); 372// Config config( APPDIR );
372 config.setGroup( "View" ); 373 config.setGroup( "View" );
373 m_debounce = config.readNumEntry("Debounce", 0); 374 m_debounce = config.readNumEntry("Debounce", 0);
374#ifdef USEQPE 375#ifdef USEQPE
375 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); 376 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false);
376#else 377#else
377 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); 378 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true);
378#endif 379#endif
379 reader->bstripcr = config.readBoolEntry( "StripCr", true ); 380 reader->bstripcr = config.readBoolEntry( "StripCr", true );
380 reader->bfulljust = config.readBoolEntry( "FullJust", false ); 381 reader->bfulljust = config.readBoolEntry( "FullJust", false );
381 reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); 382 reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 ));
382 reader->setlead(config.readNumEntry( "ExtraLead", 0 )); 383 reader->setlead(config.readNumEntry( "ExtraLead", 0 ));
383 reader->btextfmt = config.readBoolEntry( "TextFmt", false ); 384 reader->btextfmt = config.readBoolEntry( "TextFmt", false );
384 reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); 385 reader->bautofmt = config.readBoolEntry( "AutoFmt", true );
385 reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); 386 reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
386 reader->bpeanut = config.readBoolEntry( "Peanut", false ); 387 reader->bpeanut = config.readBoolEntry( "Peanut", false );
@@ -424,39 +425,39 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
424 m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); 425 m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone);
425 m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); 426 m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen);
426 m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); 427 m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut);
427 m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); 428 m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn);
428 m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); 429 m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp);
429 m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); 430 m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown);
430 431
431 m_leftScroll = config.readBoolEntry("LeftScroll", false); 432 m_leftScroll = config.readBoolEntry("LeftScroll", false);
432 m_rightScroll = config.readBoolEntry("RightScroll", false); 433 m_rightScroll = config.readBoolEntry("RightScroll", false);
433 m_upScroll = config.readBoolEntry("UpScroll", true); 434 m_upScroll = config.readBoolEntry("UpScroll", true);
434 m_downScroll = config.readBoolEntry("DownScroll", true); 435 m_downScroll = config.readBoolEntry("DownScroll", true);
435 436
436 m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); 437 m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false);
437 reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); 438 reader->setBaseSize(config.readNumEntry( "Basesize", 10 ));
438 439
439#ifndef USEQPE 440#ifndef USEQPE
440 config.setGroup( "Geometry" ); 441 config.setGroup( "Geometry" );
441 setGeometry(0,0, 442 setGeometry(0,0,
442 config.readNumEntry( "width", QApplication::desktop()->width()/2 ), 443 config.readNumEntry( "width", QApplication::desktop()->width()/2 ),
443 config.readNumEntry( "height", QApplication::desktop()->height()/2 )); 444 config.readNumEntry( "height", QApplication::desktop()->height()/2 ));
444 move( 445 move(
445 config.readNumEntry( "x", 20 ), 446 config.readNumEntry( "x", 20 ),
446 config.readNumEntry( "y", 20 )); 447 config.readNumEntry( "y", 20 ));
447#endif 448#endif
448 449
449 450
450 451
451 setTwoTouch(m_twoTouch); 452 setTwoTouch(m_twoTouch);
452 453
453 connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); 454 connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) );
454 455
455 connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); 456 connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) );
456 connect( reader, SIGNAL( OnWordSelected(const QString&,size_t,const QString&) ), this, SLOT( OnWordSelected(const QString&,size_t,const QString&) ) ); 457 connect( reader, SIGNAL( OnWordSelected(const QString&,size_t,const QString&) ), this, SLOT( OnWordSelected(const QString&,size_t,const QString&) ) );
457 connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) ); 458 connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) );
458 editorStack->addWidget( reader, get_unique_id() ); 459 editorStack->addWidget( reader, get_unique_id() );
459 460
460 m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); 461 m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL);
461 connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); 462 connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) );
462 m_preferences_action->addTo( settings ); 463 m_preferences_action->addTo( settings );
@@ -533,33 +534,33 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
533 m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); 534 m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL);
534 connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); 535 connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) );
535 m_end_action->addTo(navigation); 536 m_end_action->addTo(navigation);
536 537
537 m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); 538 m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL);
538 connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); 539 connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) );
539 m_jump_action->addTo(navigation); 540 m_jump_action->addTo(navigation);
540 541
541 m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); 542 m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true );
542 connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); 543 connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) );
543 m_pageline_action->addTo(navigation); 544 m_pageline_action->addTo(navigation);
544 m_pageline_action->setOn(reader->m_bpagemode); 545 m_pageline_action->setOn(reader->m_bpagemode);
545 546
546 m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); 547 m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 );
547 connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); 548 connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) );
548 m_pageup_action->addTo( navigation ); 549 m_pageup_action->addTo( navigation );
549 550
550 m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); 551 m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 );
551 connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 552 connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) );
552 m_pagedn_action->addTo( navigation ); 553 m_pagedn_action->addTo( navigation );
553 554
554 m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 ); 555 m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 );
555 connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) ); 556 connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) );
556 m_back_action->addTo( navigation ); 557 m_back_action->addTo( navigation );
557 558
558 m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 ); 559 m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 );
559 connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) ); 560 connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) );
560 m_home_action->addTo( navigation ); 561 m_home_action->addTo( navigation );
561 562
562 m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 ); 563 m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 );
563 connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) ); 564 connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) );
564 m_forward_action->addTo( navigation ); 565 m_forward_action->addTo( navigation );
565 566
@@ -714,1032 +715,1032 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
714 pbar->hide(); 715 pbar->hide();
715 716
716 searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); 717 searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE );
717 718
718 searchBar->setHorizontalStretchable( TRUE ); 719 searchBar->setHorizontalStretchable( TRUE );
719 720
720 connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); 721 connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() ));
721 722
722 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 723 searchEdit = new QLineEdit( searchBar, "searchEdit" );
723// QFont f("unifont", 16 /*, QFont::Bold*/); 724// QFont f("unifont", 16 /*, QFont::Bold*/);
724// searchEdit->setFont( f ); 725// searchEdit->setFont( f );
725 searchBar->setStretchableWidget( searchEdit ); 726 searchBar->setStretchableWidget( searchEdit );
726 727
727 728
728#ifdef __ISEARCH 729#ifdef __ISEARCH
729 connect( searchEdit, SIGNAL( textChanged(const QString&) ), 730 connect( searchEdit, SIGNAL( textChanged(const QString&) ),
730 this, SLOT( search(const QString&) ) ); 731 this, SLOT( search(const QString&) ) );
731#else 732#else
732 connect( searchEdit, SIGNAL( returnPressed() ), 733 connect( searchEdit, SIGNAL( returnPressed() ),
733 this, SLOT( search() ) ); 734 this, SLOT( search() ) );
734#endif 735#endif
735 QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); 736 QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 );
736 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 737 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
737 a->addTo( searchBar ); 738 a->addTo( searchBar );
738 739
739 a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); 740 a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 );
740 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 741 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
741 a->addTo( searchBar ); 742 a->addTo( searchBar );
742 743
743 searchBar->hide(); 744 searchBar->hide();
744 745
745 regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); 746 regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE );
746 connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); 747 connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() ));
747 748
748 regBar->setHorizontalStretchable( TRUE ); 749 regBar->setHorizontalStretchable( TRUE );
749 750
750 regEdit = new QLineEdit( regBar, "regEdit" ); 751 regEdit = new QLineEdit( regBar, "regEdit" );
751// regEdit->setFont( f ); 752// regEdit->setFont( f );
752 753
753 regBar->setStretchableWidget( regEdit ); 754 regBar->setStretchableWidget( regEdit );
754 755
755 connect( regEdit, SIGNAL( returnPressed() ), 756 connect( regEdit, SIGNAL( returnPressed() ),
756 this, SLOT( do_regaction() ) ); 757 this, SLOT( do_regaction() ) );
757 758
758 a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); 759 a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 );
759 connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); 760 connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) );
760 a->addTo( regBar ); 761 a->addTo( regBar );
761 762
762 a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); 763 a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 );
763 connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); 764 connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) );
764 a->addTo( regBar ); 765 a->addTo( regBar );
765 766
766 regBar->hide(); 767 regBar->hide();
767 768
768 m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); 769 m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE );
769 770
770 m_fontBar->setHorizontalStretchable( TRUE ); 771 m_fontBar->setHorizontalStretchable( TRUE );
771 772
772// qDebug("Font selector"); 773// odebug << "Font selector" << oendl;
773 m_fontSelector = new QComboBox(false, m_fontBar); 774 m_fontSelector = new QComboBox(false, m_fontBar);
774 m_fontBar->setStretchableWidget( m_fontSelector ); 775 m_fontBar->setStretchableWidget( m_fontSelector );
775 { 776 {
776#ifndef USEQPE 777#ifndef USEQPE
777 QFontDatabase f; 778 QFontDatabase f;
778#else 779#else
779 FontDatabase f; 780 FontDatabase f;
780#endif 781#endif
781 QStringList flist = f.families(); 782 QStringList flist = f.families();
782 bool realfont = false; 783 bool realfont = false;
783 for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) 784 for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++)
784 { 785 {
785 if (reader->m_fontname == *nm) 786 if (reader->m_fontname == *nm)
786 { 787 {
787 realfont = true; 788 realfont = true;
788 } 789 }
789 if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); 790 if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm);
790 } 791 }
791 if (!realfont) reader->m_fontname = flist[0]; 792 if (!realfont) reader->m_fontname = flist[0];
792 } // delete the FontDatabase!!! 793 } // delete the FontDatabase!!!
793 connect( m_fontSelector, SIGNAL( activated(const QString&) ), 794 connect( m_fontSelector, SIGNAL( activated(const QString&) ),
794 this, SLOT( do_setfont(const QString&) ) ); 795 this, SLOT( do_setfont(const QString&) ) );
795 connect( m_fontSelector, SIGNAL( activated(int) ), 796 connect( m_fontSelector, SIGNAL( activated(int) ),
796 this, SLOT( do_setencoding(int) ) ); 797 this, SLOT( do_setencoding(int) ) );
797 798
798 m_fontBar->hide(); 799 m_fontBar->hide();
799 m_fontVisible = false; 800 m_fontVisible = false;
800#ifdef USEMSGS 801#ifdef USEMSGS
801 connect(qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), 802 connect(qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ),
802 this, SLOT( msgHandler(const QCString&,const QByteArray&) ) ); 803 this, SLOT( msgHandler(const QCString&,const QByteArray&) ) );
803#endif 804#endif
804// qDebug("Initing"); 805// odebug << "Initing" << oendl;
805 reader->init(); 806 reader->init();
806// qDebug("Inited"); 807// odebug << "Inited" << oendl;
807// m_buttonAction[m_spaceTarget]->setOn(true); 808// m_buttonAction[m_spaceTarget]->setOn(true);
808// qDebug("fonting"); 809// odebug << "fonting" << oendl;
809 do_setfont(reader->m_fontname); 810 do_setfont(reader->m_fontname);
810 if (!reader->m_lastfile.isEmpty()) 811 if (!reader->m_lastfile.isEmpty())
811 { 812 {
812 //qDebug("doclnk"); 813// odebug << "doclnk" << oendl;
813 //doc = new DocLnk(reader->m_lastfile); 814// doc = new DocLnk(reader->m_lastfile);
814 //qDebug("doclnk done"); 815// odebug << "doclnk done" << oendl;
815 if (pOpenlist != NULL) 816 if (pOpenlist != NULL)
816 { 817 {
817 818
818/* 819/*
819 int ind = 0; 820 int ind = 0;
820 Bkmk* p = (*pOpenlist)[ind]; 821 Bkmk* p = (*pOpenlist)[ind];
821 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) 822 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
822 { 823 {
823 p = (*pOpenlist)[++ind]; 824 p = (*pOpenlist)[++ind];
824 } 825 }
825*/ 826*/
826 Bkmk* p = NULL; 827 Bkmk* p = NULL;
827 for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) 828 for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++)
828 { 829 {
829 p = iter.pContent(); 830 p = iter.pContent();
830 if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) 831 if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile)
831 { 832 {
832 break; 833 break;
833 } 834 }
834 // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); 835// odebug << "Item:" << toQString(CFiledata(p->anno()).name()) << "" << oendl;
835 p = NULL; 836 p = NULL;
836 } 837 }
837 if (p != NULL) 838 if (p != NULL)
838 { 839 {
839 //qDebug("openfrombkmk"); 840// odebug << "openfrombkmk" << oendl;
840 if (!openfrombkmk(p)) 841 if (!openfrombkmk(p))
841 showEditTools(); 842 showEditTools();
842 } 843 }
843 else 844 else
844 { 845 {
845 //qDebug("openfile"); 846// odebug << "openfile" << oendl;
846 openFile( reader->m_lastfile ); 847 openFile( reader->m_lastfile );
847 } 848 }
848 } 849 }
849 else 850 else
850 { 851 {
851 // qDebug("Openfile 2"); 852// odebug << "Openfile 2" << oendl;
852 if (!reader->m_lastfile.isEmpty()) 853 if (!reader->m_lastfile.isEmpty())
853 openFile( reader->m_lastfile ); 854 openFile( reader->m_lastfile );
854 } 855 }
855 } 856 }
856 else 857 else
857 { 858 {
858 showEditTools(); 859 showEditTools();
859 } 860 }
860// qApp->processEvents(); 861// qApp->processEvents();
861 reader->bDoUpdates = true; 862 reader->bDoUpdates = true;
862 reader->update(); 863 reader->update();
863 config.setGroup("Version"); 864 config.setGroup("Version");
864 int major = config.readNumEntry("Major", 0); 865 int major = config.readNumEntry("Major", 0);
865 int bkmktype = config.readNumEntry("BkmkType", 0); 866 int bkmktype = config.readNumEntry("BkmkType", 0);
866 char minor = config.readNumEntry("Minor", 0); 867 char minor = config.readNumEntry("Minor", 0);
867 if (CheckVersion(major, bkmktype, minor)) 868 if (CheckVersion(major, bkmktype, minor))
868 { 869 {
869 config.writeEntry("Major", major); 870 config.writeEntry("Major", major);
870 config.writeEntry("BkmkType", bkmktype); 871 config.writeEntry("BkmkType", bkmktype);
871 config.writeEntry("Minor", (int)minor); 872 config.writeEntry("Minor", (int)minor);
872 } 873 }
873// qDebug("finished update"); 874// odebug << "finished update" << oendl;
874} 875}
875 876
876void QTReaderApp::addtoolbars(Config* config) 877void QTReaderApp::addtoolbars(Config* config)
877{ 878{
878 config->setGroup("Toolbar"); 879 config->setGroup("Toolbar");
879 880
880 if (fileBar != NULL) 881 if (fileBar != NULL)
881 { 882 {
882 if (fileBar != menubar) 883 if (fileBar != menubar)
883 { 884 {
884 fileBar->clear(); 885 fileBar->clear();
885 } 886 }
886 else 887 else
887 { 888 {
888 m_preferences_action->removeFrom( filebar() ); 889 m_preferences_action->removeFrom( filebar() );
889 m_open_action->removeFrom( filebar() ); 890 m_open_action->removeFrom( filebar() );
890 m_close_action->removeFrom( filebar() ); 891 m_close_action->removeFrom( filebar() );
891 m_info_action->removeFrom( filebar() ); 892 m_info_action->removeFrom( filebar() );
892 m_touch_action->removeFrom( filebar() ); 893 m_touch_action->removeFrom( filebar() );
893 m_find_action->removeFrom( filebar() ); 894 m_find_action->removeFrom( filebar() );
894 } 895 }
895 } 896 }
896 897
897 m_preferences_action->addTo( filebar() ); 898 m_preferences_action->addTo( filebar() );
898 addfilebar(config, "Open", m_open_action); 899 addfilebar(config, "Open", m_open_action);
899 addfilebar(config, "Close", m_close_action); 900 addfilebar(config, "Close", m_close_action);
900 addfilebar(config, "Info", m_info_action); 901 addfilebar(config, "Info", m_info_action);
901 addfilebar(config, "Two/One Touch", m_touch_action); 902 addfilebar(config, "Two/One Touch", m_touch_action);
902 addfilebar(config, "Find", m_find_action); 903 addfilebar(config, "Find", m_find_action);
903 904
904 if (navBar != NULL) 905 if (navBar != NULL)
905 { 906 {
906 if ((navBar == fileBar) && (fileBar == menubar)) 907 if ((navBar == fileBar) && (fileBar == menubar))
907 { 908 {
908 m_scrollButton->removeFrom( navbar() ); 909 m_scrollButton->removeFrom( navbar() );
909 m_start_action->removeFrom( navbar() ); 910 m_start_action->removeFrom( navbar() );
910 m_end_action->removeFrom( navbar() ); 911 m_end_action->removeFrom( navbar() );
911 m_jump_action->removeFrom( navbar() ); 912 m_jump_action->removeFrom( navbar() );
912 m_pageline_action->removeFrom( navbar() ); 913 m_pageline_action->removeFrom( navbar() );
913 m_pageup_action->removeFrom( navbar() ); 914 m_pageup_action->removeFrom( navbar() );
914 m_pagedn_action->removeFrom( navbar() ); 915 m_pagedn_action->removeFrom( navbar() );
915 m_back_action->removeFrom( navbar() ); 916 m_back_action->removeFrom( navbar() );
916 m_home_action->removeFrom( navbar() ); 917 m_home_action->removeFrom( navbar() );
917 m_forward_action->removeFrom( navbar() ); 918 m_forward_action->removeFrom( navbar() );
918 } 919 }
919 else if (navBar != fileBar) 920 else if (navBar != fileBar)
920 { 921 {
921 navBar->clear(); 922 navBar->clear();
922 } 923 }
923 } 924 }
924 925
925 addnavbar(config, "Scroll", m_scrollButton); 926 addnavbar(config, "Scroll", m_scrollButton);
926 addnavbar(config, "Goto Start", m_start_action); 927 addnavbar(config, "Goto Start", m_start_action);
927 addnavbar(config, "Goto End", m_end_action); 928 addnavbar(config, "Goto End", m_end_action);
928 929
929 addnavbar(config, "Jump", m_jump_action); 930 addnavbar(config, "Jump", m_jump_action);
930 addnavbar(config, "Page/Line Scroll", m_pageline_action); 931 addnavbar(config, "Page/Line Scroll", m_pageline_action);
931 932
932 addnavbar(config, "Page Up", m_pageup_action); 933 addnavbar(config, "Page Up", m_pageup_action);
933 addnavbar(config, "Page Down", m_pagedn_action); 934 addnavbar(config, "Page Down", m_pagedn_action);
934 935
935 addnavbar(config, "Back", m_back_action); 936 addnavbar(config, "Back", m_back_action);
936 addnavbar(config, "Home", m_home_action); 937 addnavbar(config, "Home", m_home_action);
937 addnavbar(config, "Forward", m_forward_action); 938 addnavbar(config, "Forward", m_forward_action);
938 939
939 if (viewBar != NULL) 940 if (viewBar != NULL)
940 { 941 {
941 if ((viewBar == fileBar) && (fileBar == menubar)) 942 if ((viewBar == fileBar) && (fileBar == menubar))
942 { 943 {
943 m_actFullscreen->removeFrom( filebar() ); 944 m_actFullscreen->removeFrom( filebar() );
944 m_zoomin_action->removeFrom( viewbar() ); 945 m_zoomin_action->removeFrom( viewbar() );
945 m_zoomout_action->removeFrom( viewbar() ); 946 m_zoomout_action->removeFrom( viewbar() );
946 m_setfont_action->removeFrom( viewbar() ); 947 m_setfont_action->removeFrom( viewbar() );
947 m_setenc_action->removeFrom( viewbar() ); 948 m_setenc_action->removeFrom( viewbar() );
948 m_setmono_action->removeFrom( viewbar() ); 949 m_setmono_action->removeFrom( viewbar() );
949 } 950 }
950 else if (viewBar != fileBar) 951 else if (viewBar != fileBar)
951 { 952 {
952 viewBar->clear(); 953 viewBar->clear();
953 } 954 }
954 } 955 }
955 956
956 addviewbar(config, "Fullscreen", m_actFullscreen); 957 addviewbar(config, "Fullscreen", m_actFullscreen);
957 addviewbar(config, "Zoom In", m_zoomin_action); 958 addviewbar(config, "Zoom In", m_zoomin_action);
958 addviewbar(config, "Zoom Out", m_zoomout_action); 959 addviewbar(config, "Zoom Out", m_zoomout_action);
959 addviewbar(config, "Set Font", m_setfont_action); 960 addviewbar(config, "Set Font", m_setfont_action);
960 addviewbar(config, "Encoding Select", m_setenc_action); 961 addviewbar(config, "Encoding Select", m_setenc_action);
961 addviewbar(config, "Ideogram Mode", m_setmono_action); 962 addviewbar(config, "Ideogram Mode", m_setmono_action);
962 963
963 if (markBar != NULL) 964 if (markBar != NULL)
964 { 965 {
965 if ((markBar == fileBar) && (fileBar == menubar)) 966 if ((markBar == fileBar) && (fileBar == menubar))
966 { 967 {
967 m_mark_action->removeFrom( markbar() ); 968 m_mark_action->removeFrom( markbar() );
968 m_annotate_action->removeFrom( markbar()); 969 m_annotate_action->removeFrom( markbar());
969 m_goto_action->removeFrom( markbar() ); 970 m_goto_action->removeFrom( markbar() );
970 m_delete_action->removeFrom( markbar() ); 971 m_delete_action->removeFrom( markbar() );
971 m_autogen_action->removeFrom( markbar() ); 972 m_autogen_action->removeFrom( markbar() );
972 m_clear_action->removeFrom( markbar() ); 973 m_clear_action->removeFrom( markbar() );
973 m_save_action->removeFrom( markbar() ); 974 m_save_action->removeFrom( markbar() );
974 m_tidy_action->removeFrom( markbar() ); 975 m_tidy_action->removeFrom( markbar() );
975 m_startBlock_action->removeFrom( markbar() ); 976 m_startBlock_action->removeFrom( markbar() );
976 m_endBlock_action->removeFrom( markbar() ); 977 m_endBlock_action->removeFrom( markbar() );
977 } 978 }
978 else if (markBar != fileBar) 979 else if (markBar != fileBar)
979 { 980 {
980 markBar->clear(); 981 markBar->clear();
981 } 982 }
982 } 983 }
983 addmarkbar(config, "Mark", m_mark_action); 984 addmarkbar(config, "Mark", m_mark_action);
984 addmarkbar(config, "Annotate", m_annotate_action); 985 addmarkbar(config, "Annotate", m_annotate_action);
985 addmarkbar(config, "Goto", m_goto_action); 986 addmarkbar(config, "Goto", m_goto_action);
986 addmarkbar(config, "Delete", m_delete_action); 987 addmarkbar(config, "Delete", m_delete_action);
987 addmarkbar(config, "Autogen", m_autogen_action); 988 addmarkbar(config, "Autogen", m_autogen_action);
988 addmarkbar(config, "Clear", m_clear_action); 989 addmarkbar(config, "Clear", m_clear_action);
989 addmarkbar(config, "Save", m_save_action); 990 addmarkbar(config, "Save", m_save_action);
990 addmarkbar(config, "Tidy", m_tidy_action); 991 addmarkbar(config, "Tidy", m_tidy_action);
991 addmarkbar(config, "Start Block", m_startBlock_action); 992 addmarkbar(config, "Start Block", m_startBlock_action);
992 addmarkbar(config, "Copy Block", m_endBlock_action); 993 addmarkbar(config, "Copy Block", m_endBlock_action);
993 if (checkbar(config, "Annotation indicator")) 994 if (checkbar(config, "Annotation indicator"))
994 { 995 {
995 if (m_bkmkAvail == NULL) 996 if (m_bkmkAvail == NULL)
996 { 997 {
997 m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 ); 998 m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 );
998 connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); 999 connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) );
999 1000
1000 m_bkmkAvail->setEnabled(false); 1001 m_bkmkAvail->setEnabled(false);
1001 } 1002 }
1002 QLabel *spacer = new QLabel(markBar, ""); 1003 QLabel *spacer = new QLabel(markBar, "");
1003 markbar()->setStretchableWidget(spacer); 1004 markbar()->setStretchableWidget(spacer);
1004 m_bkmkAvail->removeFrom( markbar() ); 1005 m_bkmkAvail->removeFrom( markbar() );
1005 m_bkmkAvail->addTo( markbar() ); 1006 m_bkmkAvail->addTo( markbar() );
1006 } 1007 }
1007 else 1008 else
1008 { 1009 {
1009 if (m_bkmkAvail != NULL) 1010 if (m_bkmkAvail != NULL)
1010 { 1011 {
1011 m_bkmkAvail->removeFrom( markbar() ); 1012 m_bkmkAvail->removeFrom( markbar() );
1012 delete m_bkmkAvail; 1013 delete m_bkmkAvail;
1013 m_bkmkAvail = NULL; 1014 m_bkmkAvail = NULL;
1014 } 1015 }
1015 } 1016 }
1016} 1017}
1017 1018
1018bool QTReaderApp::checkbar(Config* _config, const QString& key) 1019bool QTReaderApp::checkbar(Config* _config, const QString& key)
1019{ 1020{
1020 return _config->readBoolEntry(key, false); 1021 return _config->readBoolEntry(key, false);
1021} 1022}
1022 1023
1023 1024
1024QToolBar* QTReaderApp::filebar() 1025QToolBar* QTReaderApp::filebar()
1025{ 1026{
1026 if (fileBar == NULL) 1027 if (fileBar == NULL)
1027 { 1028 {
1028 switch (m_tbpol) 1029 switch (m_tbpol)
1029 { 1030 {
1030 case cesSingle: 1031 case cesSingle:
1031 // qDebug("Setting filebar to menubar"); 1032// odebug << "Setting filebar to menubar" << oendl;
1032 fileBar = menubar; 1033 fileBar = menubar;
1033 break; 1034 break;
1034 default: 1035 default:
1035 qDebug("Incorrect toolbar policy set"); 1036 odebug << "Incorrect toolbar policy set" << oendl;
1036 case cesMenuTool: 1037 case cesMenuTool:
1037 case cesMultiple: 1038 case cesMultiple:
1038 // qDebug("Creating new file bar"); 1039// odebug << "Creating new file bar" << oendl;
1039 fileBar = new QToolBar("File", this, m_tbposition); 1040 fileBar = new QToolBar("File", this, m_tbposition);
1040 break; 1041 break;
1041 } 1042 }
1042 //fileBar->setHorizontalStretchable( true ); 1043// fileBar->setHorizontalStretchable( true );
1043 } 1044 }
1044 return fileBar; 1045 return fileBar;
1045} 1046}
1046QToolBar* QTReaderApp::viewbar() 1047QToolBar* QTReaderApp::viewbar()
1047{ 1048{
1048 if (viewBar == NULL) 1049 if (viewBar == NULL)
1049 { 1050 {
1050 switch (m_tbpol) 1051 switch (m_tbpol)
1051 { 1052 {
1052 case cesMultiple: 1053 case cesMultiple:
1053 viewBar = new QToolBar("View", this, m_tbposition); 1054 viewBar = new QToolBar("View", this, m_tbposition);
1054 break; 1055 break;
1055 default: 1056 default:
1056 qDebug("Incorrect toolbar policy set"); 1057 odebug << "Incorrect toolbar policy set" << oendl;
1057 case cesSingle: 1058 case cesSingle:
1058 case cesMenuTool: 1059 case cesMenuTool:
1059 viewBar = fileBar; 1060 viewBar = fileBar;
1060 break; 1061 break;
1061 } 1062 }
1062 } 1063 }
1063 return viewBar; 1064 return viewBar;
1064} 1065}
1065QToolBar* QTReaderApp::navbar() 1066QToolBar* QTReaderApp::navbar()
1066{ 1067{
1067 if (navBar == NULL) 1068 if (navBar == NULL)
1068 { 1069 {
1069 switch (m_tbpol) 1070 switch (m_tbpol)
1070 { 1071 {
1071 case cesMultiple: 1072 case cesMultiple:
1072 // qDebug("Creating new nav bar"); 1073// odebug << "Creating new nav bar" << oendl;
1073 navBar = new QToolBar("Navigation", this, m_tbposition); 1074 navBar = new QToolBar("Navigation", this, m_tbposition);
1074 break; 1075 break;
1075 default: 1076 default:
1076 qDebug("Incorrect toolbar policy set"); 1077 odebug << "Incorrect toolbar policy set" << oendl;
1077 case cesSingle: 1078 case cesSingle:
1078 case cesMenuTool: 1079 case cesMenuTool:
1079 navBar = fileBar; 1080 navBar = fileBar;
1080 // qDebug("Setting navbar to filebar"); 1081// odebug << "Setting navbar to filebar" << oendl;
1081 break; 1082 break;
1082 } 1083 }
1083 } 1084 }
1084 return navBar; 1085 return navBar;
1085} 1086}
1086QToolBar* QTReaderApp::markbar() 1087QToolBar* QTReaderApp::markbar()
1087{ 1088{
1088 if (markBar == NULL) 1089 if (markBar == NULL)
1089 { 1090 {
1090 switch (m_tbpol) 1091 switch (m_tbpol)
1091 { 1092 {
1092 case cesMultiple: 1093 case cesMultiple:
1093 markBar = new QToolBar("Marks", this, m_tbposition); 1094 markBar = new QToolBar("Marks", this, m_tbposition);
1094 break; 1095 break;
1095 default: 1096 default:
1096 qDebug("Incorrect toolbar policy set"); 1097 odebug << "Incorrect toolbar policy set" << oendl;
1097 case cesSingle: 1098 case cesSingle:
1098 case cesMenuTool: 1099 case cesMenuTool:
1099 markBar = fileBar; 1100 markBar = fileBar;
1100 break; 1101 break;
1101 } 1102 }
1102 } 1103 }
1103 return markBar; 1104 return markBar;
1104} 1105}
1105 1106
1106void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) 1107void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a)
1107{ 1108{
1108 if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); 1109 if (_config->readBoolEntry(key, false)) a->addTo( filebar() );
1109} 1110}
1110void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) 1111void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a)
1111{ 1112{
1112 if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); 1113 if (_config->readBoolEntry(key, false)) a->addTo( navbar() );
1113} 1114}
1114void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) 1115void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a)
1115{ 1116{
1116 if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); 1117 if (_config->readBoolEntry(key, false)) a->addTo( markbar() );
1117} 1118}
1118void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) 1119void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a)
1119{ 1120{
1120 if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); 1121 if (_config->readBoolEntry(key, false)) a->addTo( viewbar() );
1121} 1122}
1122 1123
1123void QTReaderApp::suspend() { reader->suspend(); } 1124void QTReaderApp::suspend() { reader->suspend(); }
1124 1125
1125#ifdef USEMSGS 1126#ifdef USEMSGS
1126void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) 1127void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
1127{ 1128{
1128 QString msg = QString::fromUtf8(_msg); 1129 QString msg = QString::fromUtf8(_msg);
1129 1130
1130//// qDebug("Received:%s", (const char*)msg); 1131//// odebug << "Received:" << msg << "" << oendl;
1131 1132
1132 QDataStream stream( _data, IO_ReadOnly ); 1133 QDataStream stream( _data, IO_ReadOnly );
1133 if ( msg == "info(QString)" ) 1134 if ( msg == "info(QString)" )
1134 { 1135 {
1135 QString info; 1136 QString info;
1136 stream >> info; 1137 stream >> info;
1137 QMessageBox::information(this, PROGNAME, info); 1138 QMessageBox::information(this, PROGNAME, info);
1138 } 1139 }
1139 else if ( msg == "Update(int)" ) 1140 else if ( msg == "Update(int)" )
1140 { 1141 {
1141 int info; 1142 int info;
1142 stream >> info; 1143 stream >> info;
1143 if (info) 1144 if (info)
1144 { 1145 {
1145 reader->bDoUpdates = true; 1146 reader->bDoUpdates = true;
1146 reader->refresh(); 1147 reader->refresh();
1147 } 1148 }
1148 else 1149 else
1149 { 1150 {
1150 reader->bDoUpdates = false; 1151 reader->bDoUpdates = false;
1151 } 1152 }
1152 } 1153 }
1153 else if ( msg == "warn(QString)" ) 1154 else if ( msg == "warn(QString)" )
1154 { 1155 {
1155 QString info; 1156 QString info;
1156 stream >> info; 1157 stream >> info;
1157 QMessageBox::warning(this, PROGNAME, info); 1158 QMessageBox::warning(this, PROGNAME, info);
1158 } 1159 }
1159 else if ( msg == "exit()" ) 1160 else if ( msg == "exit()" )
1160 { 1161 {
1161 m_dontSave = true; 1162 m_dontSave = true;
1162 close(); 1163 close();
1163 } 1164 }
1164 else if ( msg == "pageDown()" ) 1165 else if ( msg == "pageDown()" )
1165 { 1166 {
1166 reader->dopagedn(); 1167 reader->dopagedn();
1167 } 1168 }
1168 else if ( msg == "pageUp()" ) 1169 else if ( msg == "pageUp()" )
1169 { 1170 {
1170 reader->dopageup(); 1171 reader->dopageup();
1171 } 1172 }
1172 else if ( msg == "lineDown()" ) 1173 else if ( msg == "lineDown()" )
1173 { 1174 {
1174 reader->lineDown(); 1175 reader->lineDown();
1175 } 1176 }
1176 else if ( msg == "lineUp()" ) 1177 else if ( msg == "lineUp()" )
1177 { 1178 {
1178 reader->lineUp(); 1179 reader->lineUp();
1179 } 1180 }
1180 else if ( msg == "showText()" ) 1181 else if ( msg == "showText()" )
1181 { 1182 {
1182 showEditTools(); 1183 showEditTools();
1183 } 1184 }
1184 else if ( msg == "home()" ) 1185 else if ( msg == "home()" )
1185 { 1186 {
1186 reader->goHome(); 1187 reader->goHome();
1187 } 1188 }
1188 else if ( msg == "back()" ) 1189 else if ( msg == "back()" )
1189 { 1190 {
1190 reader->goBack(); 1191 reader->goBack();
1191 } 1192 }
1192 else if ( msg == "forward()" ) 1193 else if ( msg == "forward()" )
1193 { 1194 {
1194 reader->goForward(); 1195 reader->goForward();
1195 } 1196 }
1196 else if ( msg == "File/Open(QString)" ) 1197 else if ( msg == "File/Open(QString)" )
1197 { 1198 {
1198 QString info; 1199 QString info;
1199 stream >> info; 1200 stream >> info;
1200 openFile( info ); 1201 openFile( info );
1201 } 1202 }
1202 else if ( msg == "File/Info()" ) 1203 else if ( msg == "File/Info()" )
1203 { 1204 {
1204 showinfo(); 1205 showinfo();
1205 } 1206 }
1206 else if ( msg == "File/Action(QString)" ) 1207 else if ( msg == "File/Action(QString)" )
1207 { 1208 {
1208 QString info; 1209 QString info;
1209 stream >> info; 1210 stream >> info;
1210 m_spaceTarget = ActNameToInt(info); 1211 m_spaceTarget = ActNameToInt(info);
1211 } 1212 }
1212 else if ( msg == "Navigation/Scroll(int)" ) 1213 else if ( msg == "Navigation/Scroll(int)" )
1213 { 1214 {
1214 int info; 1215 int info;
1215 stream >> info; 1216 stream >> info;
1216 autoScroll(info); 1217 autoScroll(info);
1217 } 1218 }
1218 1219
1219 else if ( msg == "Navigation/GotoStart()" ) 1220 else if ( msg == "Navigation/GotoStart()" )
1220 { 1221 {
1221 gotoStart(); 1222 gotoStart();
1222 } 1223 }
1223 else if ( msg == "Navigation/GotoEnd()" ) 1224 else if ( msg == "Navigation/GotoEnd()" )
1224 { 1225 {
1225 gotoEnd(); 1226 gotoEnd();
1226 } 1227 }
1227 else if ( msg == "Navigation/Jump(int)" ) 1228 else if ( msg == "Navigation/Jump(int)" )
1228 { 1229 {
1229 int info; 1230 int info;
1230 stream >> info; 1231 stream >> info;
1231 reader->locate(info); 1232 reader->locate(info);
1232 } 1233 }
1233 else if ( msg == "Navigation/Page/LineScroll(int)" ) 1234 else if ( msg == "Navigation/Page/LineScroll(int)" )
1234 { 1235 {
1235 int info; 1236 int info;
1236 stream >> info; 1237 stream >> info;
1237 pagemode(info); 1238 pagemode(info);
1238 } 1239 }
1239 else if ( msg == "Navigation/SetOverlap(int)" ) 1240 else if ( msg == "Navigation/SetOverlap(int)" )
1240 { 1241 {
1241 int info; 1242 int info;
1242 stream >> info; 1243 stream >> info;
1243 reader->m_overlap = info; 1244 reader->m_overlap = info;
1244 } 1245 }
1245 else if ( msg == "Navigation/SetMargin(int)" ) 1246 else if ( msg == "Navigation/SetMargin(int)" )
1246 { 1247 {
1247 int info; 1248 int info;
1248 stream >> info; 1249 stream >> info;
1249 do_margin(info); 1250 do_margin(info);
1250 } 1251 }
1251 else if ( msg == "File/SetDictionary(QString)" ) 1252 else if ( msg == "File/SetDictionary(QString)" )
1252 { 1253 {
1253 QString info; 1254 QString info;
1254 stream >> info; 1255 stream >> info;
1255 do_settarget(info); 1256 do_settarget(info);
1256 } 1257 }
1257#ifdef _SCROLLPIPE 1258#ifdef _SCROLLPIPE
1258 else if ( msg == "File/SetScrollTarget(QString)" ) 1259 else if ( msg == "File/SetScrollTarget(QString)" )
1259 { 1260 {
1260 QString info; 1261 QString info;
1261 stream >> info; 1262 stream >> info;
1262 reader->m_pipetarget = info; 1263 reader->m_pipetarget = info;
1263 } 1264 }
1264#endif 1265#endif
1265 else if ( msg == "File/Two/OneTouch(int)" ) 1266 else if ( msg == "File/Two/OneTouch(int)" )
1266 { 1267 {
1267 int info; 1268 int info;
1268 stream >> info; 1269 stream >> info;
1269 setTwoTouch(info); 1270 setTwoTouch(info);
1270 } 1271 }
1271 else if ( msg == "Target/Annotation(int)" ) 1272 else if ( msg == "Target/Annotation(int)" )
1272 { 1273 {
1273 int info; 1274 int info;
1274 stream >> info; 1275 stream >> info;
1275 OnAnnotation(info); 1276 OnAnnotation(info);
1276 } 1277 }
1277 else if ( msg == "Target/Dictionary(int)" ) 1278 else if ( msg == "Target/Dictionary(int)" )
1278 { 1279 {
1279 int info; 1280 int info;
1280 stream >> info; 1281 stream >> info;
1281 OnDictionary(info); 1282 OnDictionary(info);
1282 } 1283 }
1283 else if ( msg == "Target/Clipboard(int)" ) 1284 else if ( msg == "Target/Clipboard(int)" )
1284 { 1285 {
1285 int info; 1286 int info;
1286 stream >> info; 1287 stream >> info;
1287 OnClipboard(info); 1288 OnClipboard(info);
1288 } 1289 }
1289 else if ( msg == "File/Find(QString)" ) 1290 else if ( msg == "File/Find(QString)" )
1290 { 1291 {
1291 QString info; 1292 QString info;
1292 stream >> info; 1293 stream >> info;
1293 QRegExp arg(info); 1294 QRegExp arg(info);
1294 size_t pos = reader->pagelocate(); 1295 size_t pos = reader->pagelocate();
1295 size_t start = pos; 1296 size_t start = pos;
1296 CDrawBuffer test(&(reader->m_fontControl)); 1297 CDrawBuffer test(&(reader->m_fontControl));
1297 reader->getline(&test); 1298 reader->getline(&test);
1298 while (arg.match(toQString(test.data())) == -1) 1299 while (arg.match(toQString(test.data())) == -1)
1299 { 1300 {
1300 pos = reader->locate(); 1301 pos = reader->locate();
1301 if (!reader->getline(&test)) 1302 if (!reader->getline(&test))
1302 { 1303 {
1303 QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); 1304 QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info);
1304 pos = start; 1305 pos = start;
1305 break; 1306 break;
1306 } 1307 }
1307 } 1308 }
1308 reader->locate(pos); 1309 reader->locate(pos);
1309 } 1310 }
1310 else if ( msg == "File/Fullscreen(int)" ) 1311 else if ( msg == "File/Fullscreen(int)" )
1311 { 1312 {
1312 int info; 1313 int info;
1313 stream >> info; 1314 stream >> info;
1314 setfullscreen(info); 1315 setfullscreen(info);
1315 } 1316 }
1316 else if ( msg == "File/Continuous(int)" ) 1317 else if ( msg == "File/Continuous(int)" )
1317 { 1318 {
1318 int info; 1319 int info;
1319 stream >> info; 1320 stream >> info;
1320 setcontinuous(info); 1321 setcontinuous(info);
1321 } 1322 }
1322 else if ( msg == "Markup(QString)" ) 1323 else if ( msg == "Markup(QString)" )
1323 { 1324 {
1324 QString info; 1325 QString info;
1325 stream >> info; 1326 stream >> info;
1326 if (info == "Auto") 1327 if (info == "Auto")
1327 { 1328 {
1328 autofmt(true); 1329 autofmt(true);
1329 } 1330 }
1330 if (info == "None") 1331 if (info == "None")
1331 { 1332 {
1332 autofmt(false); 1333 autofmt(false);
1333 textfmt(false); 1334 textfmt(false);
1334 striphtml(false); 1335 striphtml(false);
1335 peanut(false); 1336 peanut(false);
1336 } 1337 }
1337 if (info == "Text") 1338 if (info == "Text")
1338 { 1339 {
1339 textfmt(true); 1340 textfmt(true);
1340 } 1341 }
1341 if (info == "HTML") 1342 if (info == "HTML")
1342 { 1343 {
1343 striphtml(true); 1344 striphtml(true);
1344 } 1345 }
1345 if (info == "Peanut/PML") 1346 if (info == "Peanut/PML")
1346 { 1347 {
1347 peanut(true); 1348 peanut(true);
1348 } 1349 }
1349 } 1350 }
1350 else if ( msg == "Layout/StripCR(int)" ) 1351 else if ( msg == "Layout/StripCR(int)" )
1351 { 1352 {
1352 int info; 1353 int info;
1353 stream >> info; 1354 stream >> info;
1354 stripcr(info); 1355 stripcr(info);
1355 } 1356 }
1356 else if ( msg == "Layout/Dehyphen(int)" ) 1357 else if ( msg == "Layout/Dehyphen(int)" )
1357 { 1358 {
1358 int info; 1359 int info;
1359 stream >> info; 1360 stream >> info;
1360 dehyphen(info); 1361 dehyphen(info);
1361 } 1362 }
1362 else if ( msg == "Layout/Depluck(int)" ) 1363 else if ( msg == "Layout/Depluck(int)" )
1363 { 1364 {
1364 int info; 1365 int info;
1365 stream >> info; 1366 stream >> info;
1366 depluck(info); 1367 depluck(info);
1367 } 1368 }
1368 else if ( msg == "Layout/Dejpluck(int)" ) 1369 else if ( msg == "Layout/Dejpluck(int)" )
1369 { 1370 {
1370 int info; 1371 int info;
1371 stream >> info; 1372 stream >> info;
1372 dejpluck(info); 1373 dejpluck(info);
1373 } 1374 }
1374 else if ( msg == "Layout/SingleSpace(int)" ) 1375 else if ( msg == "Layout/SingleSpace(int)" )
1375 { 1376 {
1376 int info; 1377 int info;
1377 stream >> info; 1378 stream >> info;
1378 onespace(info); 1379 onespace(info);
1379 } 1380 }
1380#ifdef REPALM 1381#ifdef REPALM
1381 else if ( msg == "Layout/Repalm(int)" ) 1382 else if ( msg == "Layout/Repalm(int)" )
1382 { 1383 {
1383 int info; 1384 int info;
1384 stream >> info; 1385 stream >> info;
1385 repalm(info); 1386 repalm(info);
1386 } 1387 }
1387#endif 1388#endif
1388 else if ( msg == "Layout/Unindent(int)" ) 1389 else if ( msg == "Layout/Unindent(int)" )
1389 { 1390 {
1390 int info; 1391 int info;
1391 stream >> info; 1392 stream >> info;
1392 unindent(info); 1393 unindent(info);
1393 } 1394 }
1394 else if ( msg == "Layout/Re-paragraph(int)" ) 1395 else if ( msg == "Layout/Re-paragraph(int)" )
1395 { 1396 {
1396 int info; 1397 int info;
1397 stream >> info; 1398 stream >> info;
1398 repara(info); 1399 repara(info);
1399 } 1400 }
1400 else if ( msg == "Layout/DoubleSpace(int)" ) 1401 else if ( msg == "Layout/DoubleSpace(int)" )
1401 { 1402 {
1402 int info; 1403 int info;
1403 stream >> info; 1404 stream >> info;
1404 dblspce(info); 1405 dblspce(info);
1405 } 1406 }
1406 else if ( msg == "Layout/Indent(int)" ) 1407 else if ( msg == "Layout/Indent(int)" )
1407 { 1408 {
1408 int info; 1409 int info;
1409 stream >> info; 1410 stream >> info;
1410 reader->bindenter = info; 1411 reader->bindenter = info;
1411 reader->setfilter(reader->getfilter()); 1412 reader->setfilter(reader->getfilter());
1412 } 1413 }
1413 else if ( msg == "Layout/Remap(int)" ) 1414 else if ( msg == "Layout/Remap(int)" )
1414 { 1415 {
1415 int info; 1416 int info;
1416 stream >> info; 1417 stream >> info;
1417 remap(info); 1418 remap(info);
1418 } 1419 }
1419 else if ( msg == "Layout/Embolden(int)" ) 1420 else if ( msg == "Layout/Embolden(int)" )
1420 { 1421 {
1421 int info; 1422 int info;
1422 stream >> info; 1423 stream >> info;
1423 embolden(info); 1424 embolden(info);
1424 } 1425 }
1425 else if ( msg == "Format/Ideogram/Word(int)" ) 1426 else if ( msg == "Format/Ideogram/Word(int)" )
1426 { 1427 {
1427 int info; 1428 int info;
1428 stream >> info; 1429 stream >> info;
1429 monospace(info); 1430 monospace(info);
1430 } 1431 }
1431 else if ( msg == "Format/SetWidth(int)" ) 1432 else if ( msg == "Format/SetWidth(int)" )
1432 { 1433 {
1433 int info; 1434 int info;
1434 stream >> info; 1435 stream >> info;
1435 reader->m_charpc = info; 1436 reader->m_charpc = info;
1436 reader->setfont(); 1437 reader->setfont();
1437 reader->refresh(); 1438 reader->refresh();
1438 } 1439 }
1439 else if ( msg == "Format/SetFont(QString,int)" ) 1440 else if ( msg == "Format/SetFont(QString,int)" )
1440 { 1441 {
1441 QString fontname; 1442 QString fontname;
1442 int size; 1443 int size;
1443 stream >> fontname; 1444 stream >> fontname;
1444 stream >> size; 1445 stream >> size;
1445 setfontHelper(fontname, size); 1446 setfontHelper(fontname, size);
1446 } 1447 }
1447 else if ( msg == "Marks/Autogen(QString)" ) 1448 else if ( msg == "Marks/Autogen(QString)" )
1448 { 1449 {
1449 QString info; 1450 QString info;
1450 stream >> info; 1451 stream >> info;
1451 do_autogen(info); 1452 do_autogen(info);
1452 } 1453 }
1453 else if ( msg == "File/StartBlock()" ) 1454 else if ( msg == "File/StartBlock()" )
1454 { 1455 {
1455 editMark(); 1456 editMark();
1456 } 1457 }
1457 else if ( msg == "File/CopyBlock()" ) 1458 else if ( msg == "File/CopyBlock()" )
1458 { 1459 {
1459 editCopy(); 1460 editCopy();
1460 } 1461 }
1461} 1462}
1462#endif 1463#endif
1463ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) 1464ActionTypes QTReaderApp::ActNameToInt(const QString& _enc)
1464{ 1465{
1465 for (int i = 0; i < MAX_ACTIONS; i++) 1466 for (int i = 0; i < MAX_ACTIONS; i++)
1466 { 1467 {
1467 if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; 1468 if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i;
1468 } 1469 }
1469 return cesAutoScroll; 1470 return cesAutoScroll;
1470} 1471}
1471 1472
1472void QTReaderApp::setfullscreen(bool sfs) 1473void QTReaderApp::setfullscreen(bool sfs)
1473{ 1474{
1474 reader->bDoUpdates = false; 1475 reader->bDoUpdates = false;
1475 m_fullscreen = sfs; 1476 m_fullscreen = sfs;
1476 showEditTools(); 1477 showEditTools();
1477// qApp->processEvents(); 1478// qApp->processEvents();
1478 reader->bDoUpdates = true; 1479 reader->bDoUpdates = true;
1479 reader->update(); 1480 reader->update();
1480} 1481}
1481 1482
1482void QTReaderApp::buttonActionSelected(QAction* _a) 1483void QTReaderApp::buttonActionSelected(QAction* _a)
1483{ 1484{
1484//// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); 1485//// odebug << "es:" << _a << " : " << (const char *)(_a->text()) << " (" << ActNameToInt(_a->text()) << ")" << oendl;
1485 m_spaceTarget = ActNameToInt(_a->text()); 1486 m_spaceTarget = ActNameToInt(_a->text());
1486} 1487}
1487 1488
1488QTReaderApp::~QTReaderApp() 1489QTReaderApp::~QTReaderApp()
1489{ 1490{
1490} 1491}
1491 1492
1492void QTReaderApp::autoScroll(bool _b) 1493void QTReaderApp::autoScroll(bool _b)
1493{ 1494{
1494 reader->setautoscroll(_b); 1495 reader->setautoscroll(_b);
1495 setScrollState(reader->m_autoScroll); 1496 setScrollState(reader->m_autoScroll);
1496} 1497}
1497 1498
1498void QTReaderApp::zoomin() 1499void QTReaderApp::zoomin()
1499{ 1500{
1500 reader->zoomin(); 1501 reader->zoomin();
1501} 1502}
1502 1503
1503void QTReaderApp::zoomout() 1504void QTReaderApp::zoomout()
1504{ 1505{
1505 reader->zoomout(); 1506 reader->zoomout();
1506} 1507}
1507 1508
1508void QTReaderApp::clearBkmkList() 1509void QTReaderApp::clearBkmkList()
1509{ 1510{
1510 delete pBkmklist; 1511 delete pBkmklist;
1511 pBkmklist = NULL; 1512 pBkmklist = NULL;
1512 m_fBkmksChanged = false; 1513 m_fBkmksChanged = false;
1513} 1514}
1514 1515
1515void QTReaderApp::fileClose() 1516void QTReaderApp::fileClose()
1516{ 1517{
1517 CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); 1518 CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this);
1518 if (cd->exec()) 1519 if (cd->exec())
1519 { 1520 {
1520 if (pOpenlist != NULL) 1521 if (pOpenlist != NULL)
1521 { 1522 {
1522 int ind = 0; 1523 int ind = 0;
1523 Bkmk* p = (*pOpenlist)[ind]; 1524 Bkmk* p = (*pOpenlist)[ind];
1524 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) 1525 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
1525 { 1526 {
1526 p = (*pOpenlist)[++ind]; 1527 p = (*pOpenlist)[++ind];
1527 } 1528 }
1528 if (p != NULL) pOpenlist->erase(ind); 1529 if (p != NULL) pOpenlist->erase(ind);
1529 if (cd->delFile()) 1530 if (cd->delFile())
1530 { 1531 {
1531 unlink((const char*)reader->m_lastfile); 1532 unlink((const char*)reader->m_lastfile);
1532 } 1533 }
1533 if (cd->delMarks()) 1534 if (cd->delMarks())
1534 { 1535 {
1535#ifndef USEQPE 1536#ifndef USEQPE
1536 QDir d = QDir::home(); // "/" 1537 QDir d = QDir::home(); // "/"
1537 d.cd(APPDIR); 1538 d.cd(APPDIR);
1538 d.remove(reader->m_string); 1539 d.remove(reader->m_string);
1539#else /* USEQPE */ 1540#else /* USEQPE */
1540 unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); 1541 unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string));
1541#endif /* USEQPE */ 1542#endif /* USEQPE */
1542 } 1543 }
1543 if (cd->delConfig()) 1544 if (cd->delConfig())
1544 { 1545 {
1545#ifndef USEQPE 1546#ifndef USEQPE
1546 QDir d = QDir::home(); // "/" 1547 QDir d = QDir::home(); // "/"
1547 d.cd(APPDIR "/configs"); 1548 d.cd(APPDIR "/configs");
1548 d.remove(reader->m_string); 1549 d.remove(reader->m_string);
1549#else /* USEQPE */ 1550#else /* USEQPE */
1550 unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); 1551 unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string));
1551#endif /* USEQPE */ 1552#endif /* USEQPE */
1552 } 1553 }
1553 } 1554 }
1554 1555
1555 fileOpen2(); 1556 fileOpen2();
1556 } 1557 }
1557 delete cd; 1558 delete cd;
1558} 1559}
1559 1560
1560void QTReaderApp::updatefileinfo() 1561void QTReaderApp::updatefileinfo()
1561{ 1562{
1562 if (reader->m_string.isEmpty()) return; 1563 if (reader->m_string.isEmpty()) return;
1563 if (reader->m_lastfile.isEmpty()) return; 1564 if (reader->m_lastfile.isEmpty()) return;
1564 tchar* nm = fromQString(reader->m_string); 1565 tchar* nm = fromQString(reader->m_string);
1565 tchar* fl = fromQString(reader->m_lastfile); 1566 tchar* fl = fromQString(reader->m_lastfile);
1566// qDebug("Lastfile:%x", fl); 1567// odebug << "Lastfile:" << fl << "" << oendl;
1567 bool notadded = true; 1568 bool notadded = true;
1568 if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; 1569 if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>;
1569 else 1570 else
1570 { 1571 {
1571 for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) 1572 for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++)
1572 { 1573 {
1573 if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) 1574 if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0)
1574 { 1575 {
1575 iter->value(reader->pagelocate()); 1576 iter->value(reader->pagelocate());
1576 unsigned short dlen; 1577 unsigned short dlen;
1577 unsigned char* data; 1578 unsigned char* data;
1578 CFiledata fd(iter->anno()); 1579 CFiledata fd(iter->anno());
1579 reader->setSaveData(data, dlen, fd.content(), fd.length()); 1580 reader->setSaveData(data, dlen, fd.content(), fd.length());
1580 // qDebug("Filedata(1):%u, %u", fd.length(), dlen); 1581// odebug << "Filedata(1):" << fd.length() << ", " << dlen << "" << oendl;
1581 // getstate(data, dlen); 1582// getstate(data, dlen);
1582 iter->setAnno(data, dlen); 1583 iter->setAnno(data, dlen);
1583 notadded = false; 1584 notadded = false;
1584 delete [] data; 1585 delete [] data;
1585 break; 1586 break;
1586 } 1587 }
1587 } 1588 }
1588 } 1589 }
1589// qDebug("Added?:%x", notadded); 1590// odebug << "Added?:" << notadded << "" << oendl;
1590 if (notadded) 1591 if (notadded)
1591 { 1592 {
1592 struct stat fnstat; 1593 struct stat fnstat;
1593 stat((const char *)reader->m_lastfile, &fnstat); 1594 stat((const char *)reader->m_lastfile, &fnstat);
1594 CFiledata fd(fnstat.st_mtime, fl); 1595 CFiledata fd(fnstat.st_mtime, fl);
1595 unsigned short dlen; 1596 unsigned short dlen;
1596 unsigned char* data; 1597 unsigned char* data;
1597 reader->setSaveData(data, dlen, fd.content(), fd.length()); 1598 reader->setSaveData(data, dlen, fd.content(), fd.length());
1598 pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); 1599 pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate()));
1599 //qDebug("Filedata(2):%u, %u", fd.length(), dlen); 1600// odebug << "Filedata(2):" << fd.length() << ", " << dlen << "" << oendl;
1600 delete [] data; 1601 delete [] data;
1601 } 1602 }
1602 delete [] nm; 1603 delete [] nm;
1603 delete [] fl; 1604 delete [] fl;
1604} 1605}
1605 1606
1606void QTReaderApp::fileOpen() 1607void QTReaderApp::fileOpen()
1607{ 1608{
1608/* 1609/*
1609 menu->hide(); 1610 menu->hide();
1610 fileBar->hide(); 1611 fileBar->hide();
1611 if (regVisible) regBar->hide(); 1612 if (regVisible) regBar->hide();
1612 if (searchVisible) searchBar->hide(); 1613 if (searchVisible) searchBar->hide();
1613*/ 1614*/
1614// qDebug("fileOpen"); 1615// odebug << "fileOpen" << oendl;
1615// if (!reader->m_lastfile.isEmpty()) 1616// if (!reader->m_lastfile.isEmpty())
1616 updatefileinfo(); 1617 updatefileinfo();
1617 fileOpen2(); 1618 fileOpen2();
1618} 1619}
1619 1620
1620void QTReaderApp::fileOpen2() 1621void QTReaderApp::fileOpen2()
1621{ 1622{
1622 if (pBkmklist != NULL) 1623 if (pBkmklist != NULL)
1623 { 1624 {
1624 if (m_fBkmksChanged) 1625 if (m_fBkmksChanged)
1625 { 1626 {
1626 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) 1627 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
1627 savebkmks(); 1628 savebkmks();
1628 } 1629 }
1629 delete pBkmklist; 1630 delete pBkmklist;
1630 pBkmklist = NULL; 1631 pBkmklist = NULL;
1631 m_fBkmksChanged = false; 1632 m_fBkmksChanged = false;
1632 } 1633 }
1633 reader->disableAutoscroll(); 1634 reader->disableAutoscroll();
1634/* 1635/*
1635 editorStack->raiseWidget( fileSelector ); 1636 editorStack->raiseWidget( fileSelector );
1636 fileSelector->reread(); 1637 fileSelector->reread();
1637*/ 1638*/
1638 bool usebrowser = true; 1639 bool usebrowser = true;
1639 if (pOpenlist != NULL) 1640 if (pOpenlist != NULL)
1640 { 1641 {
1641 m_nBkmkAction = cOpenFile; 1642 m_nBkmkAction = cOpenFile;
1642 if (listbkmk(pOpenlist, "Browse")) usebrowser = false; 1643 if (listbkmk(pOpenlist, "Browse")) usebrowser = false;
1643 } 1644 }
1644 if (usebrowser) 1645 if (usebrowser)
1645 { 1646 {
1646 QString fn = usefilebrowser(); 1647 QString fn = usefilebrowser();
1647 //qApp->processEvents(); 1648// qApp->processEvents();
1648 if (!fn.isEmpty() && QFileInfo(fn).isFile()) 1649 if (!fn.isEmpty() && QFileInfo(fn).isFile())
1649 { 1650 {
1650 openFile(fn); 1651 openFile(fn);
1651 } 1652 }
1652 reader->setFocus(); 1653 reader->setFocus();
1653 } 1654 }
1654// reader->refresh(); 1655// reader->refresh();
1655// qDebug("HEIGHT:%d", reader->m_lastheight); 1656// odebug << "HEIGHT:" << reader->m_lastheight << "" << oendl;
1656} 1657}
1657 1658
1658QString QTReaderApp::usefilebrowser() 1659QString QTReaderApp::usefilebrowser()
1659{ 1660{
1660#ifndef USEQPE 1661#ifndef USEQPE
1661 QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); 1662 QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) );
1662 return s; 1663 return s;
1663#else 1664#else
1664 fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, 1665 fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog,
1665 0, 1666 0,
1666 // WStyle_Customize | WStyle_NoBorderEx, 1667// WStyle_Customize | WStyle_NoBorderEx,
1667 "*", QFileInfo(reader->m_lastfile).dirPath(true)); 1668 "*", QFileInfo(reader->m_lastfile).dirPath(true));
1668 1669
1669 1670
1670 QString fn; 1671 QString fn;
1671 if (fb->exec()) 1672 if (fb->exec())
1672 { 1673 {
1673 fn = fb->getCurrentFile(); 1674 fn = fb->getCurrentFile();
1674 } 1675 }
1675// qDebug("Selected %s", (const char*)fn); 1676// odebug << "Selected " << fn << "" << oendl;
1676 delete fb; 1677 delete fb;
1677 showEditTools(); 1678 showEditTools();
1678 return fn; 1679 return fn;
1679#endif 1680#endif
1680} 1681}
1681 1682
1682void QTReaderApp::showgraphic(QImage& pm) 1683void QTReaderApp::showgraphic(QImage& pm)
1683{ 1684{
1684 QPixmap pc; 1685 QPixmap pc;
1685 pc.convertFromImage(pm); 1686 pc.convertFromImage(pm);
1686 m_graphicwin->setPixmap(pc); 1687 m_graphicwin->setPixmap(pc);
1687 editorStack->raiseWidget( m_graphicwin ); 1688 editorStack->raiseWidget( m_graphicwin );
1688 m_graphicwin->setFocus(); 1689 m_graphicwin->setFocus();
1689} 1690}
1690 1691
1691 1692
1692void QTReaderApp::showprefs() 1693void QTReaderApp::showprefs()
1693{ 1694{
1694 CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this); 1695 CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this);
1695 1696
1696 prefwin->twotouch(m_twoTouch); 1697 prefwin->twotouch(m_twoTouch);
1697 prefwin->propfontchange(m_propogatefontchange); 1698 prefwin->propfontchange(m_propogatefontchange);
1698 prefwin->StripCR(reader->bstripcr); 1699 prefwin->StripCR(reader->bstripcr);
1699 prefwin->Dehyphen(reader->bdehyphen); 1700 prefwin->Dehyphen(reader->bdehyphen);
1700 prefwin->SingleSpace(reader->bonespace); 1701 prefwin->SingleSpace(reader->bonespace);
1701 prefwin->Unindent(reader->bunindent); 1702 prefwin->Unindent(reader->bunindent);
1702 prefwin->Reparagraph(reader->brepara); 1703 prefwin->Reparagraph(reader->brepara);
1703 prefwin->DoubleSpace(reader->bdblspce); 1704 prefwin->DoubleSpace(reader->bdblspce);
1704 prefwin->Remap(reader->bremap); 1705 prefwin->Remap(reader->bremap);
1705 prefwin->Embolden(reader->bmakebold); 1706 prefwin->Embolden(reader->bmakebold);
1706 prefwin->FullJustify(reader->bfulljust); 1707 prefwin->FullJustify(reader->bfulljust);
1707 prefwin->ParaLead(reader->getextraspace()); 1708 prefwin->ParaLead(reader->getextraspace());
1708 prefwin->LineLead(reader->getlead()); 1709 prefwin->LineLead(reader->getlead());
1709 prefwin->Margin(reader->m_border); 1710 prefwin->Margin(reader->m_border);
1710 prefwin->Indent(reader->bindenter); 1711 prefwin->Indent(reader->bindenter);
1711 if (reader->bautofmt) 1712 if (reader->bautofmt)
1712 { 1713 {
1713 prefwin->Markup(0); 1714 prefwin->Markup(0);
1714 } 1715 }
1715 else if (reader->btextfmt) 1716 else if (reader->btextfmt)
1716 { 1717 {
1717 prefwin->Markup(2); 1718 prefwin->Markup(2);
1718 } 1719 }
1719 else if (reader->bstriphtml) 1720 else if (reader->bstriphtml)
1720 { 1721 {
1721 prefwin->Markup(3); 1722 prefwin->Markup(3);
1722 } 1723 }
1723 else if (reader->bpeanut) 1724 else if (reader->bpeanut)
1724 { 1725 {
1725 prefwin->Markup(4); 1726 prefwin->Markup(4);
1726 } 1727 }
1727 else 1728 else
1728 { 1729 {
1729 prefwin->Markup(1); 1730 prefwin->Markup(1);
1730 } 1731 }
1731 prefwin->Depluck(reader->bdepluck); 1732 prefwin->Depluck(reader->bdepluck);
1732 prefwin->Dejpluck(reader->bdejpluck); 1733 prefwin->Dejpluck(reader->bdejpluck);
1733 prefwin->Continuous(reader->m_continuousDocument); 1734 prefwin->Continuous(reader->m_continuousDocument);
1734 1735
1735 prefwin->dictApplication(m_targetapp); 1736 prefwin->dictApplication(m_targetapp);
1736 prefwin->dictMessage(m_targetmsg); 1737 prefwin->dictMessage(m_targetmsg);
1737 1738
1738 prefwin->spaceAction(m_spaceTarget); 1739 prefwin->spaceAction(m_spaceTarget);
1739 prefwin->escapeAction(m_escapeTarget); 1740 prefwin->escapeAction(m_escapeTarget);
1740 prefwin->returnAction(m_returnTarget); 1741 prefwin->returnAction(m_returnTarget);
1741 prefwin->leftAction(m_leftTarget); 1742 prefwin->leftAction(m_leftTarget);
1742 prefwin->rightAction(m_rightTarget); 1743 prefwin->rightAction(m_rightTarget);
1743 prefwin->upAction(m_upTarget); 1744 prefwin->upAction(m_upTarget);
1744 prefwin->downAction(m_downTarget); 1745 prefwin->downAction(m_downTarget);
1745 1746
@@ -1755,348 +1756,348 @@ void QTReaderApp::showprefs()
1755 prefwin->SwapMouse(reader->m_swapmouse); 1756 prefwin->SwapMouse(reader->m_swapmouse);
1756 1757
1757 prefwin->Font(reader->m_fontname); 1758 prefwin->Font(reader->m_fontname);
1758 1759
1759 prefwin->gfxsize(reader->getBaseSize()); 1760 prefwin->gfxsize(reader->getBaseSize());
1760 1761
1761 prefwin->pageoverlap(reader->m_overlap); 1762 prefwin->pageoverlap(reader->m_overlap);
1762 1763
1763 prefwin->ideogram(reader->m_bMonoSpaced); 1764 prefwin->ideogram(reader->m_bMonoSpaced);
1764 1765
1765 prefwin->encoding(reader->m_encd); 1766 prefwin->encoding(reader->m_encd);
1766 1767
1767 prefwin->ideogramwidth(reader->m_charpc); 1768 prefwin->ideogramwidth(reader->m_charpc);
1768 1769
1769 if (prefwin->exec()) 1770 if (prefwin->exec())
1770 { 1771 {
1771 m_twoTouch = prefwin->twotouch(); 1772 m_twoTouch = prefwin->twotouch();
1772 reader->setTwoTouch(m_twoTouch); 1773 reader->setTwoTouch(m_twoTouch);
1773 m_touch_action->setOn(m_twoTouch); 1774 m_touch_action->setOn(m_twoTouch);
1774 1775
1775 reader->bstripcr = prefwin->StripCR(); 1776 reader->bstripcr = prefwin->StripCR();
1776 reader->bdehyphen = prefwin->Dehyphen(); 1777 reader->bdehyphen = prefwin->Dehyphen();
1777 reader->bonespace = prefwin->SingleSpace(); 1778 reader->bonespace = prefwin->SingleSpace();
1778 reader->bunindent = prefwin->Unindent(); 1779 reader->bunindent = prefwin->Unindent();
1779 reader->brepara = prefwin->Reparagraph(); 1780 reader->brepara = prefwin->Reparagraph();
1780 reader->bdblspce = prefwin->DoubleSpace(); 1781 reader->bdblspce = prefwin->DoubleSpace();
1781 reader->bremap = prefwin->Remap(); 1782 reader->bremap = prefwin->Remap();
1782 reader->bmakebold = prefwin->Embolden(); 1783 reader->bmakebold = prefwin->Embolden();
1783 reader->bfulljust = prefwin->FullJustify(); 1784 reader->bfulljust = prefwin->FullJustify();
1784 reader->setextraspace(prefwin->ParaLead()); 1785 reader->setextraspace(prefwin->ParaLead());
1785 reader->setlead(prefwin->LineLead()); 1786 reader->setlead(prefwin->LineLead());
1786 reader->m_border = prefwin->Margin(); 1787 reader->m_border = prefwin->Margin();
1787 reader->bindenter = prefwin->Indent(); 1788 reader->bindenter = prefwin->Indent();
1788 reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; 1789 reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false;
1789 switch (prefwin->Markup()) 1790 switch (prefwin->Markup())
1790 { 1791 {
1791 case 0: 1792 case 0:
1792 reader->bautofmt = true; 1793 reader->bautofmt = true;
1793 break; 1794 break;
1794 case 1: 1795 case 1:
1795 break; 1796 break;
1796 case 2: 1797 case 2:
1797 reader->btextfmt = true; 1798 reader->btextfmt = true;
1798 break; 1799 break;
1799 case 3: 1800 case 3:
1800 reader->bstriphtml = true; 1801 reader->bstriphtml = true;
1801 break; 1802 break;
1802 case 4: 1803 case 4:
1803 reader->bpeanut = true; 1804 reader->bpeanut = true;
1804 break; 1805 break;
1805 default: 1806 default:
1806 qDebug("Format out of range"); 1807 odebug << "Format out of range" << oendl;
1807 } 1808 }
1808 reader->bdepluck = prefwin->Depluck(); 1809 reader->bdepluck = prefwin->Depluck();
1809 reader->bdejpluck = prefwin->Dejpluck(); 1810 reader->bdejpluck = prefwin->Dejpluck();
1810 reader->setContinuous(prefwin->Continuous()); 1811 reader->setContinuous(prefwin->Continuous());
1811 1812
1812 m_spaceTarget = (ActionTypes)prefwin->spaceAction(); 1813 m_spaceTarget = (ActionTypes)prefwin->spaceAction();
1813 m_escapeTarget = (ActionTypes)prefwin->escapeAction(); 1814 m_escapeTarget = (ActionTypes)prefwin->escapeAction();
1814 m_returnTarget = (ActionTypes)prefwin->returnAction(); 1815 m_returnTarget = (ActionTypes)prefwin->returnAction();
1815 m_leftTarget = (ActionTypes)prefwin->leftAction(); 1816 m_leftTarget = (ActionTypes)prefwin->leftAction();
1816 m_rightTarget = (ActionTypes)prefwin->rightAction(); 1817 m_rightTarget = (ActionTypes)prefwin->rightAction();
1817 m_upTarget = (ActionTypes)prefwin->upAction(); 1818 m_upTarget = (ActionTypes)prefwin->upAction();
1818 m_downTarget = (ActionTypes)prefwin->downAction(); 1819 m_downTarget = (ActionTypes)prefwin->downAction();
1819 m_leftScroll = prefwin->leftScroll(); 1820 m_leftScroll = prefwin->leftScroll();
1820 m_rightScroll = prefwin->rightScroll(); 1821 m_rightScroll = prefwin->rightScroll();
1821 m_upScroll = prefwin->upScroll(); 1822 m_upScroll = prefwin->upScroll();
1822 m_downScroll = prefwin->downScroll(); 1823 m_downScroll = prefwin->downScroll();
1823 1824
1824 m_targetapp = prefwin->dictApplication(); 1825 m_targetapp = prefwin->dictApplication();
1825 m_targetmsg = prefwin->dictMessage(); 1826 m_targetmsg = prefwin->dictMessage();
1826 1827
1827 m_doAnnotation = prefwin->miscannotation(); 1828 m_doAnnotation = prefwin->miscannotation();
1828 m_doDictionary = prefwin->miscdictionary(); 1829 m_doDictionary = prefwin->miscdictionary();
1829 m_doClipboard = prefwin->miscclipboard(); 1830 m_doClipboard = prefwin->miscclipboard();
1830 reader->m_swapmouse = prefwin->SwapMouse(); 1831 reader->m_swapmouse = prefwin->SwapMouse();
1831 reader->setBaseSize(prefwin->gfxsize()); 1832 reader->setBaseSize(prefwin->gfxsize());
1832 reader->m_overlap = prefwin->pageoverlap(); 1833 reader->m_overlap = prefwin->pageoverlap();
1833 reader->m_bMonoSpaced = prefwin->ideogram(); 1834 reader->m_bMonoSpaced = prefwin->ideogram();
1834 m_setmono_action->setOn(reader->m_bMonoSpaced); 1835 m_setmono_action->setOn(reader->m_bMonoSpaced);
1835 reader->m_encd = prefwin->encoding(); 1836 reader->m_encd = prefwin->encoding();
1836 reader->m_charpc = prefwin->ideogramwidth(); 1837 reader->m_charpc = prefwin->ideogramwidth();
1837 1838
1838 if ( 1839 if (
1839 reader->m_fontname != prefwin->Font() 1840 reader->m_fontname != prefwin->Font()
1840 || 1841 ||
1841 m_propogatefontchange != prefwin->propfontchange()) 1842 m_propogatefontchange != prefwin->propfontchange())
1842 { 1843 {
1843 m_propogatefontchange = prefwin->propfontchange(); 1844 m_propogatefontchange = prefwin->propfontchange();
1844 setfontHelper(prefwin->Font()); 1845 setfontHelper(prefwin->Font());
1845 } 1846 }
1846 delete prefwin; 1847 delete prefwin;
1847 reader->setfilter(reader->getfilter()); 1848 reader->setfilter(reader->getfilter());
1848 reader->refresh(); 1849 reader->refresh();
1849 1850
1850 } 1851 }
1851 else 1852 else
1852 { 1853 {
1853 delete prefwin; 1854 delete prefwin;
1854 } 1855 }
1855} 1856}
1856 1857
1857void QTReaderApp::showtoolbarprefs() 1858void QTReaderApp::showtoolbarprefs()
1858{ 1859{
1859#ifdef USEQPE 1860#ifdef USEQPE
1860 CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); 1861 CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this);
1861#else 1862#else
1862 QFileInfo fi; 1863 QFileInfo fi;
1863 QDir d = QDir::home(); // "/" 1864 QDir d = QDir::home(); // "/"
1864 if ( !d.cd(APPDIR) ) 1865 if ( !d.cd(APPDIR) )
1865 { // "/tmp" 1866 { // "/tmp"
1866 qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); 1867 owarn << "Cannot find the \"~/" << APPDIR << "\" directory" << oendl;
1867 d = QDir::home(); 1868 d = QDir::home();
1868 d.mkdir(APPDIR); 1869 d.mkdir(APPDIR);
1869 d.cd(APPDIR); 1870 d.cd(APPDIR);
1870 } 1871 }
1871 fi.setFile(d, INIFILE); 1872 fi.setFile(d, INIFILE);
1872 CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); 1873 CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this);
1873#endif 1874#endif
1874 prefwin->tbpolicy(m_tbpolsave); 1875 prefwin->tbpolicy(m_tbpolsave);
1875 prefwin->tbposition(m_tbposition-2); 1876 prefwin->tbposition(m_tbposition-2);
1876 prefwin->tbmovable(m_tbmovesave); 1877 prefwin->tbmovable(m_tbmovesave);
1877 prefwin->floating(m_bFloatingDialog); 1878 prefwin->floating(m_bFloatingDialog);
1878 if (prefwin->exec()) 1879 if (prefwin->exec())
1879 { 1880 {
1880 m_bFloatingDialog = prefwin->floating(); 1881 m_bFloatingDialog = prefwin->floating();
1881 if ( 1882 if (
1882 m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() 1883 m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy()
1883 || 1884 ||
1884 m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) 1885 m_tbposition != (ToolBarDock)(prefwin->tbposition()+2)
1885 || 1886 ||
1886 m_tbmovesave != prefwin->tbmovable() 1887 m_tbmovesave != prefwin->tbmovable()
1887 ) 1888 )
1888 { 1889 {
1889 QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); 1890 QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started");
1890 } 1891 }
1891 m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); 1892 m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy();
1892 m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); 1893 m_tbposition = (ToolBarDock)(prefwin->tbposition()+2);
1893 m_tbmovesave = prefwin->tbmovable(); 1894 m_tbmovesave = prefwin->tbmovable();
1894 bool isChanged = prefwin->isChanged(); 1895 bool isChanged = prefwin->isChanged();
1895 delete prefwin; 1896 delete prefwin;
1896#ifdef USEQPE 1897#ifdef USEQPE
1897 Config config( APPDIR ); 1898 Config config( APPDIR );
1898#else 1899#else
1899 QFileInfo fi; 1900 QFileInfo fi;
1900 QDir d = QDir::home(); // "/" 1901 QDir d = QDir::home(); // "/"
1901 if ( !d.cd(APPDIR) ) 1902 if ( !d.cd(APPDIR) )
1902 { // "/tmp" 1903 { // "/tmp"
1903 qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); 1904 owarn << "Cannot find the \"~/" << APPDIR << "\" directory" << oendl;
1904 d = QDir::home(); 1905 d = QDir::home();
1905 d.mkdir(APPDIR); 1906 d.mkdir(APPDIR);
1906 d.cd(APPDIR); 1907 d.cd(APPDIR);
1907 } 1908 }
1908 fi.setFile(d, INIFILE); 1909 fi.setFile(d, INIFILE);
1909 Config config( fi.absFilePath() ); 1910 Config config( fi.absFilePath() );
1910#endif 1911#endif
1911 if (isChanged) addtoolbars(&config); 1912 if (isChanged) addtoolbars(&config);
1912 } 1913 }
1913 else 1914 else
1914 { 1915 {
1915 delete prefwin; 1916 delete prefwin;
1916 } 1917 }
1917} 1918}
1918 1919
1919void QTReaderApp::showinfo() 1920void QTReaderApp::showinfo()
1920{ 1921{
1921 unsigned long fs, ts, pl; 1922 unsigned long fs, ts, pl;
1922 if (reader->empty()) 1923 if (reader->empty())
1923 { 1924 {
1924 QMessageBox::information(this, PROGNAME, "No file loaded", 1); 1925 QMessageBox::information(this, PROGNAME, "No file loaded", 1);
1925 } 1926 }
1926 else 1927 else
1927 { 1928 {
1928 reader->sizes(fs,ts); 1929 reader->sizes(fs,ts);
1929 pl = reader->pagelocate(); 1930 pl = reader->pagelocate();
1930 m_infoWin->setFileSize(fs); 1931 m_infoWin->setFileSize(fs);
1931 m_infoWin->setTextSize(ts); 1932 m_infoWin->setTextSize(ts);
1932 m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); 1933 m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts);
1933 m_infoWin->setLocation(pl); 1934 m_infoWin->setLocation(pl);
1934 m_infoWin->setRead((100*pl + (ts >> 1))/ts); 1935 m_infoWin->setRead((100*pl + (ts >> 1))/ts);
1935 editorStack->raiseWidget( m_infoWin ); 1936 editorStack->raiseWidget( m_infoWin );
1936 m_infoWin->setFocus(); 1937 m_infoWin->setFocus();
1937 } 1938 }
1938} 1939}
1939 1940
1940void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) 1941void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn)
1941{ 1942{
1942 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; 1943 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>;
1943#ifdef _UNICODE 1944#ifdef _UNICODE
1944 CBuffer buff(name.length()+1); 1945 CBuffer buff(name.length()+1);
1945 int i; 1946 int i;
1946 for (i = 0; i < name.length(); i++) 1947 for (i = 0; i < name.length(); i++)
1947 { 1948 {
1948 buff[i] = name[i].unicode(); 1949 buff[i] = name[i].unicode();
1949 } 1950 }
1950 buff[i] = 0; 1951 buff[i] = 0;
1951 CBuffer buff2(text.length()+1); 1952 CBuffer buff2(text.length()+1);
1952 for (i = 0; i < text.length(); i++) 1953 for (i = 0; i < text.length(); i++)
1953 { 1954 {
1954 buff2[i] = text[i].unicode(); 1955 buff2[i] = text[i].unicode();
1955 } 1956 }
1956 buff2[i] = 0; 1957 buff2[i] = 0;
1957 pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn)); 1958 pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn));
1958#else 1959#else
1959 pBkmklist->push_front(Bkmk((const tchar*)text,posn)); 1960 pBkmklist->push_front(Bkmk((const tchar*)text,posn));
1960#endif 1961#endif
1961 m_fBkmksChanged = true; 1962 m_fBkmksChanged = true;
1962 pBkmklist->sort(); 1963 pBkmklist->sort();
1963} 1964}
1964 1965
1965void QTReaderApp::addAnno(const QString& name, const QString& text) 1966void QTReaderApp::addAnno(const QString& name, const QString& text)
1966{ 1967{
1967 if (m_annoIsEditing) 1968 if (m_annoIsEditing)
1968 { 1969 {
1969 if (name.isEmpty()) 1970 if (name.isEmpty())
1970 { 1971 {
1971 QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); 1972 QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1);
1972 } 1973 }
1973 else 1974 else
1974 { 1975 {
1975 addAnno(name, text, m_annoWin->getPosn()); 1976 addAnno(name, text, m_annoWin->getPosn());
1976 } 1977 }
1977 showEditTools(); 1978 showEditTools();
1979 }
1980 else
1981 {
1982 if (m_annoWin->edited())
1983 {
1984 CBuffer buff(text.length()+1);
1985 int i;
1986 for (i = 0; i < text.length(); i++)
1987 {
1988 buff[i] = text[i].unicode();
1989 }
1990 buff[i] = 0;
1991 m_fBkmksChanged = true;
1992 m_anno->setAnno(buff.data());
1993 }
1994 bool found = findNextBookmark(m_anno->value()+1);
1995 if (found)
1996 {
1997 m_annoWin->setName(toQString(m_anno->name()));
1998 m_annoWin->setAnno(toQString(m_anno->anno()));
1978 } 1999 }
1979 else 2000 else
1980 { 2001 {
1981 if (m_annoWin->edited()) 2002 showEditTools();
1982 { 2003 }
1983 CBuffer buff(text.length()+1);
1984 int i;
1985 for (i = 0; i < text.length(); i++)
1986 {
1987 buff[i] = text[i].unicode();
1988 }
1989 buff[i] = 0;
1990 m_fBkmksChanged = true;
1991 m_anno->setAnno(buff.data());
1992 }
1993 bool found = findNextBookmark(m_anno->value()+1);
1994 if (found)
1995 {
1996 m_annoWin->setName(toQString(m_anno->name()));
1997 m_annoWin->setAnno(toQString(m_anno->anno()));
1998 }
1999 else
2000 {
2001 showEditTools();
2002 }
2003 } 2004 }
2004} 2005}
2005 2006
2006bool QTReaderApp::findNextBookmark(size_t start) 2007bool QTReaderApp::findNextBookmark(size_t start)
2007{ 2008{
2008 bool found = false; 2009 bool found = false;
2009 for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) 2010 for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++)
2010 { 2011 {
2011 if (iter->value() >= start) 2012 if (iter->value() >= start)
2012 { 2013 {
2013 if (iter->value() < reader->locate()) 2014 if (iter->value() < reader->locate())
2014 { 2015 {
2015 found = true; 2016 found = true;
2016 m_anno = iter.pContent(); 2017 m_anno = iter.pContent();
2017 } 2018 }
2018 break; 2019 break;
2019 } 2020 }
2020 } 2021 }
2021 return found; 2022 return found;
2022} 2023}
2023 2024
2024void QTReaderApp::addanno() 2025void QTReaderApp::addanno()
2025{ 2026{
2026 if (reader->empty()) 2027 if (reader->empty())
2027 { 2028 {
2028 QMessageBox::information(this, PROGNAME, "No file loaded", 1); 2029 QMessageBox::information(this, PROGNAME, "No file loaded", 1);
2029 } 2030 }
2030 else 2031 else
2031 { 2032 {
2032 m_annoWin->setName(""); 2033 m_annoWin->setName("");
2033 m_annoWin->setAnno(""); 2034 m_annoWin->setAnno("");
2034 m_annoWin->setPosn(reader->pagelocate()); 2035 m_annoWin->setPosn(reader->pagelocate());
2035 m_annoIsEditing = true; 2036 m_annoIsEditing = true;
2036 editorStack->raiseWidget( m_annoWin ); 2037 editorStack->raiseWidget( m_annoWin );
2037#ifdef USEQPE 2038#ifdef USEQPE
2038 Global::showInputMethod(); 2039 Global::showInputMethod();
2039#endif 2040#endif
2040 m_annoWin->setFocus(); 2041 m_annoWin->setFocus();
2041 } 2042 }
2042} 2043}
2043 2044
2044void QTReaderApp::infoClose() 2045void QTReaderApp::infoClose()
2045{ 2046{
2046 showEditTools(); 2047 showEditTools();
2047} 2048}
2048 2049
2049/* 2050/*
2050void QTReaderApp::fileRevert() 2051void QTReaderApp::fileRevert()
2051{ 2052{
2052 clear(); 2053 clear();
2053 fileOpen(); 2054 fileOpen();
2054} 2055}
2055 2056
2056void QTReaderApp::editCut() 2057void QTReaderApp::editCut()
2057{ 2058{
2058#ifndef QT_NO_CLIPBOARD 2059#ifndef QT_NO_CLIPBOARD
2059 editor->cut(); 2060 editor->cut();
2060#endif 2061#endif
2061} 2062}
2062*/ 2063*/
2063void QTReaderApp::editMark() 2064void QTReaderApp::editMark()
2064{ 2065{
2065 m_savedpos = reader->pagelocate(); 2066 m_savedpos = reader->pagelocate();
2066} 2067}
2067 2068
2068void QTReaderApp::editCopy() 2069void QTReaderApp::editCopy()
2069{ 2070{
2070 QClipboard* cb = QApplication::clipboard(); 2071 QClipboard* cb = QApplication::clipboard();
2071 QString text; 2072 QString text;
2072 int ch; 2073 int ch;
2073 unsigned long currentpos = reader->pagelocate(); 2074 unsigned long currentpos = reader->pagelocate();
2074 unsigned long endpos = reader->locate(); 2075 unsigned long endpos = reader->locate();
2075 if (m_savedpos == 0xffffffff) 2076 if (m_savedpos == 0xffffffff)
2076 { 2077 {
2077 m_savedpos = currentpos; 2078 m_savedpos = currentpos;
2078 } 2079 }
2079 reader->jumpto(m_savedpos); 2080 reader->jumpto(m_savedpos);
2080 while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) 2081 while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF)
2081 { 2082 {
2082 text += ch; 2083 text += ch;
2083 } 2084 }
2084 cb->setText(text); 2085 cb->setText(text);
2085 reader->locate(currentpos); 2086 reader->locate(currentpos);
2086 m_savedpos = 0xffffffff; 2087 m_savedpos = 0xffffffff;
2087} 2088}
2088 2089
2089void QTReaderApp::gotoStart() 2090void QTReaderApp::gotoStart()
2090{ 2091{
2091 reader->locate(reader->buffdoc.startSection()); 2092 reader->locate(reader->buffdoc.startSection());
2092} 2093}
2093 2094
2094void QTReaderApp::gotoEnd() 2095void QTReaderApp::gotoEnd()
2095{ 2096{
2096 reader->dopageup(reader->buffdoc.endSection()); 2097 reader->dopageup(reader->buffdoc.endSection());
2097} 2098}
2098 2099
2099void QTReaderApp::pageup() 2100void QTReaderApp::pageup()
2100{ 2101{
2101 reader->NavUp(); 2102 reader->NavUp();
2102} 2103}
@@ -2112,83 +2113,83 @@ void QTReaderApp::pagemode(bool _b)
2112} 2113}
2113 2114
2114/* 2115/*
2115void QTReaderApp::setspacing() 2116void QTReaderApp::setspacing()
2116{ 2117{
2117 m_nRegAction = cMonoSpace; 2118 m_nRegAction = cMonoSpace;
2118 char lcn[20]; 2119 char lcn[20];
2119 sprintf(lcn, "%lu", reader->m_charpc); 2120 sprintf(lcn, "%lu", reader->m_charpc);
2120 regEdit->setText(lcn); 2121 regEdit->setText(lcn);
2121 do_regedit(); 2122 do_regedit();
2122} 2123}
2123*/ 2124*/
2124void QTReaderApp::settarget() 2125void QTReaderApp::settarget()
2125{ 2126{
2126 m_nRegAction = cSetTarget; 2127 m_nRegAction = cSetTarget;
2127 QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) 2128 QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp)
2128 + "/" 2129 + "/"
2129 + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); 2130 + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg);
2130 regEdit->setText(text); 2131 regEdit->setText(text);
2131 do_regedit(); 2132 do_regedit();
2132} 2133}
2133 2134
2134/* 2135/*
2135void QTReaderApp::do_mono(const QString& lcn) 2136void QTReaderApp::do_mono(const QString& lcn)
2136{ 2137{
2137 bool ok; 2138 bool ok;
2138 unsigned long ulcn = lcn.toULong(&ok); 2139 unsigned long ulcn = lcn.toULong(&ok);
2139 if (ok) 2140 if (ok)
2140 { 2141 {
2141 reader->m_charpc = ulcn; 2142 reader->m_charpc = ulcn;
2142 reader->setfont(); 2143 reader->setfont();
2143 reader->refresh(); 2144 reader->refresh();
2144 //reader->setmono(true); 2145// reader->setmono(true);
2145 } 2146 }
2146 else 2147 else
2147 QMessageBox::information(this, PROGNAME, "Must be a number"); 2148 QMessageBox::information(this, PROGNAME, "Must be a number");
2148} 2149}
2149*/ 2150*/
2150/* 2151/*
2151void QTReaderApp::editPaste() 2152void QTReaderApp::editPaste()
2152{ 2153{
2153#ifndef QT_NO_CLIPBOARD 2154#ifndef QT_NO_CLIPBOARD
2154 editor->paste(); 2155 editor->paste();
2155#endif 2156#endif
2156} 2157}
2157*/ 2158*/
2158 2159
2159void QTReaderApp::editFind() 2160void QTReaderApp::editFind()
2160{ 2161{
2161 searchStart = reader->pagelocate(); 2162 searchStart = reader->pagelocate();
2162#ifdef __ISEARCH 2163#ifdef __ISEARCH
2163 searchStack = new QStack<searchrecord>; 2164 searchStack = new QStack<searchrecord>;
2164#endif 2165#endif
2165#ifdef USEQPE 2166#ifdef USEQPE
2166 Global::showInputMethod(); 2167 Global::showInputMethod();
2167#endif 2168#endif
2168 searchBar->show(); 2169 searchBar->show();
2169 searchVisible = TRUE; 2170 searchVisible = TRUE;
2170 searchEdit->setFocus(); 2171 searchEdit->setFocus();
2171#ifdef __ISEARCH 2172#ifdef __ISEARCH
2172 searchStack->push(new searchrecord("",reader->pagelocate())); 2173 searchStack->push(new searchrecord("",reader->pagelocate()));
2173#endif 2174#endif
2174} 2175}
2175 2176
2176void QTReaderApp::findNext() 2177void QTReaderApp::findNext()
2177{ 2178{
2178// // qDebug("findNext called\n"); 2179// // odebug << "findNext called\n" << oendl;
2179#ifdef __ISEARCH 2180#ifdef __ISEARCH
2180 QString arg = searchEdit->text(); 2181 QString arg = searchEdit->text();
2181#else 2182#else
2182 QRegExp arg = searchEdit->text(); 2183 QRegExp arg = searchEdit->text();
2183#endif 2184#endif
2184 CDrawBuffer test(&(reader->m_fontControl)); 2185 CDrawBuffer test(&(reader->m_fontControl));
2185 size_t start = reader->pagelocate(); 2186 size_t start = reader->pagelocate();
2186 reader->jumpto(start); 2187 reader->jumpto(start);
2187 reader->getline(&test); 2188 reader->getline(&test);
2188 dosearch(start, test, arg); 2189 dosearch(start, test, arg);
2189} 2190}
2190 2191
2191void QTReaderApp::findClose() 2192void QTReaderApp::findClose()
2192{ 2193{
2193 searchVisible = FALSE; 2194 searchVisible = FALSE;
2194 searchEdit->setText(""); 2195 searchEdit->setText("");
@@ -2236,70 +2237,70 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
2236 int lastpc = (100*pos)/ts; 2237 int lastpc = (100*pos)/ts;
2237 pbar->setProgress(lastpc); 2238 pbar->setProgress(lastpc);
2238// qApp->processEvents(); 2239// qApp->processEvents();
2239 if (reader->buffdoc.getpara(test) >= 0) 2240 if (reader->buffdoc.getpara(test) >= 0)
2240 { 2241 {
2241 reader->setFocus(); 2242 reader->setFocus();
2242#ifdef __ISEARCH 2243#ifdef __ISEARCH
2243 while (strstr(test.data(),(const tchar*)arg) == NULL) 2244 while (strstr(test.data(),(const tchar*)arg) == NULL)
2244#else 2245#else
2245#ifdef _UNICODE 2246#ifdef _UNICODE
2246 while ((offset = arg.match(toQString(test.data()))) == -1) 2247 while ((offset = arg.match(toQString(test.data()))) == -1)
2247#else 2248#else
2248 while (arg.match(test.data()) == -1) 2249 while (arg.match(test.data()) == -1)
2249#endif 2250#endif
2250#endif 2251#endif
2251 { 2252 {
2252 pos = reader->locate(); 2253 pos = reader->locate();
2253 int pc = (100*pos)/ts; 2254 int pc = (100*pos)/ts;
2254 if (pc != lastpc) 2255 if (pc != lastpc)
2255 { 2256 {
2256 pbar->setProgress(pc); 2257 pbar->setProgress(pc);
2257 qApp->processEvents(); 2258 qApp->processEvents();
2258 reader->setFocus(); 2259 reader->setFocus();
2259 lastpc = pc; 2260 lastpc = pc;
2260 }
2261
2262 if (reader->buffdoc.getpara(test) < 0)
2263 {
2264 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
2265 pos = searchStart;
2266 else
2267 pos = start;
2268 findClose();
2269 pbar->hide();
2270 reader->locate(pos);
2271 return false;
2272 }
2273 } 2261 }
2274// qDebug("Found it at %u:%u", pos, offset); 2262
2263 if (reader->buffdoc.getpara(test) < 0)
2264 {
2265 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
2266 pos = searchStart;
2267 else
2268 pos = start;
2269 findClose();
2270 pbar->hide();
2271 reader->locate(pos);
2272 return false;
2273 }
2274 }
2275// odebug << "Found it at " << pos << ":" << offset << "" << oendl;
2275 pbar->hide(); 2276 pbar->hide();
2276// qDebug("Hid"); 2277// odebug << "Hid" << oendl;
2277 reader->locate(pos+offset); 2278 reader->locate(pos+offset);
2278// qDebug("Loacted"); 2279// odebug << "Loacted" << oendl;
2279// qDebug("page up"); 2280// odebug << "page up" << oendl;
2280 ret = true; 2281 ret = true;
2281 } 2282 }
2282 else 2283 else
2283 { 2284 {
2284 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) 2285 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
2285 pos = searchStart; 2286 pos = searchStart;
2286 else 2287 else
2287 pos = start; 2288 pos = start;
2288 ret = false; 2289 ret = false;
2289 findClose(); 2290 findClose();
2290 } 2291 }
2291 return ret; 2292 return ret;
2292} 2293}
2293 2294
2294#ifdef __ISEARCH 2295#ifdef __ISEARCH
2295void QTReaderApp::search(const QString & arg) 2296void QTReaderApp::search(const QString & arg)
2296{ 2297{
2297 searchrecord* ss = searchStack->top(); 2298 searchrecord* ss = searchStack->top();
2298 CBuffer test; 2299 CBuffer test;
2299 size_t start = reader->pagelocate(); 2300 size_t start = reader->pagelocate();
2300 bool haspopped = false; 2301 bool haspopped = false;
2301 while (arg.left(ss->s.length()) != ss->s) 2302 while (arg.left(ss->s.length()) != ss->s)
2302 { 2303 {
2303 haspopped = true; 2304 haspopped = true;
2304 start = ss->pos; 2305 start = ss->pos;
2305// reader->locate(start); 2306// reader->locate(start);
@@ -2320,890 +2321,890 @@ void QTReaderApp::search(const QString & arg)
2320 { 2321 {
2321 start = reader->pagelocate(); 2322 start = reader->pagelocate();
2322 reader->jumpto(start); 2323 reader->jumpto(start);
2323 searchStack->push(new searchrecord(arg,start)); 2324 searchStack->push(new searchrecord(arg,start));
2324 } 2325 }
2325 dosearch(start, test, arg); 2326 dosearch(start, test, arg);
2326} 2327}
2327#else 2328#else
2328void QTReaderApp::search() 2329void QTReaderApp::search()
2329{ 2330{
2330 findNext(); 2331 findNext();
2331} 2332}
2332#endif 2333#endif
2333 2334
2334void QTReaderApp::openFile( const QString &f ) 2335void QTReaderApp::openFile( const QString &f )
2335{ 2336{
2336// qDebug("File:%s", (const char*)f); 2337// odebug << "File:" << f << "" << oendl;
2337// openFile(DocLnk(f)); 2338// openFile(DocLnk(f));
2338//} 2339//}
2339// 2340//
2340//void QTReaderApp::openFile( const DocLnk &f ) 2341//void QTReaderApp::openFile( const DocLnk &f )
2341//{ 2342//{
2342 clear(); 2343 clear();
2343 QFileInfo fm(f); 2344 QFileInfo fm(f);
2344 if ( fm.exists() ) 2345 if ( fm.exists() )
2345 { 2346 {
2346// QMessageBox::information(0, "Progress", "Calling fileNew()"); 2347// QMessageBox::information(0, "Progress", "Calling fileNew()");
2347#ifdef USEQPE 2348#ifdef USEQPE
2348 if (fm.extension( FALSE ) == "desktop") 2349 if (fm.extension( FALSE ) == "desktop")
2349 { 2350 {
2350 DocLnk d(f); 2351 DocLnk d(f);
2351 QFileInfo fnew(d.file()); 2352 QFileInfo fnew(d.file());
2352 fm = fnew; 2353 fm = fnew;
2353 if (!fm.exists()) return; 2354 if (!fm.exists()) return;
2354 } 2355 }
2355#endif 2356#endif
2356 clear(); 2357 clear();
2357 2358
2358 reader->setText(fm.baseName(), fm.absFilePath()); 2359 reader->setText(fm.baseName(), fm.absFilePath());
2359 m_loadedconfig = readconfig(reader->m_string, false); 2360 m_loadedconfig = readconfig(reader->m_string, false);
2360 showEditTools(); 2361 showEditTools();
2361 readbkmks(); 2362 readbkmks();
2362 m_savedpos = 0xffffffff; 2363 m_savedpos = 0xffffffff;
2363 } 2364 }
2364 else 2365 else
2365 { 2366 {
2366 QMessageBox::information(this, PROGNAME, "File does not exist"); 2367 QMessageBox::information(this, PROGNAME, "File does not exist");
2367 reader->m_lastfile = QString::null; 2368 reader->m_lastfile = QString::null;
2368 } 2369 }
2369 2370
2370} 2371}
2371/* 2372/*
2372void QTReaderApp::resizeEvent(QResizeEvent* e) 2373void QTReaderApp::resizeEvent(QResizeEvent* e)
2373{ 2374{
2374 if (m_fullscreen) 2375 if (m_fullscreen)
2375 { 2376 {
2376 showNormal(); 2377 showNormal();
2377 showFullScreen(); 2378 showFullScreen();
2378 } 2379 }
2379} 2380}
2380*/ 2381*/
2381void QTReaderApp::handlekey(QKeyEvent* e) 2382void QTReaderApp::handlekey(QKeyEvent* e)
2382{ 2383{
2383// qDebug("Keypress event"); 2384// odebug << "Keypress event" << oendl;
2384 timeb now; 2385 timeb now;
2385 ftime(&now); 2386 ftime(&now);
2386 unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; 2387 unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm;
2387 if (etime < m_debounce) 2388 if (etime < m_debounce)
2388 { 2389 {
2389 return; 2390 return;
2390 } 2391 }
2391 m_lastkeytime = now; 2392 m_lastkeytime = now;
2392 switch(e->key()) 2393 switch(e->key())
2393 { 2394 {
2394 case Key_Escape: 2395 case Key_Escape:
2395 // qDebug("escape event"); 2396// odebug << "escape event" << oendl;
2396 if (m_disableesckey) 2397 if (m_disableesckey)
2397 { 2398 {
2398 m_disableesckey = false; 2399 m_disableesckey = false;
2399 } 2400 }
2400 else 2401 else
2401 { 2402 {
2402 m_bcloseDisabled = true; 2403 m_bcloseDisabled = true;
2403 if (m_fullscreen) 2404 if (m_fullscreen)
2404 { 2405 {
2405 m_actFullscreen->setOn(false); 2406 m_actFullscreen->setOn(false);
2406 e->accept(); 2407 e->accept();
2407 } 2408 }
2408 else 2409 else
2409 { 2410 {
2410 // qDebug("escape action"); 2411// odebug << "escape action" << oendl;
2411 doAction(m_escapeTarget, e); 2412 doAction(m_escapeTarget, e);
2412 } 2413 }
2413 } 2414 }
2414 break; 2415 break;
2415 case Key_Space: 2416 case Key_Space:
2416 { 2417 {
2417 doAction(m_spaceTarget, e); 2418 doAction(m_spaceTarget, e);
2418 } 2419 }
2419 break; 2420 break;
2420 case Key_Return: 2421 case Key_Return:
2421 { 2422 {
2422 doAction(m_returnTarget, e); 2423 doAction(m_returnTarget, e);
2423 } 2424 }
2424 break; 2425 break;
2425 case Key_Left: 2426 case Key_Left:
2426 { 2427 {
2427 if (reader->m_autoScroll && m_leftScroll) 2428 if (reader->m_autoScroll && m_leftScroll)
2428 { 2429 {
2429 reader->reduceScroll(); 2430 reader->reduceScroll();
2430 } 2431 }
2431 else 2432 else
2432 { 2433 {
2433 doAction(m_leftTarget, e); 2434 doAction(m_leftTarget, e);
2434 } 2435 }
2435 } 2436 }
2436 break; 2437 break;
2437 case Key_Right: 2438 case Key_Right:
2438 { 2439 {
2439 if (reader->m_autoScroll && m_rightScroll) 2440 if (reader->m_autoScroll && m_rightScroll)
2440 { 2441 {
2441 reader->increaseScroll(); 2442 reader->increaseScroll();
2442 } 2443 }
2443 else 2444 else
2444 { 2445 {
2445 doAction(m_rightTarget, e); 2446 doAction(m_rightTarget, e);
2446 } 2447 }
2447 } 2448 }
2448 break; 2449 break;
2449 case Key_Up: 2450 case Key_Up:
2450 { 2451 {
2451 if (reader->m_autoScroll && m_upScroll) 2452 if (reader->m_autoScroll && m_upScroll)
2452 { 2453 {
2453 reader->increaseScroll(); 2454 reader->increaseScroll();
2454 } 2455 }
2455 else 2456 else
2456 { 2457 {
2457 doAction(m_upTarget, e); 2458 doAction(m_upTarget, e);
2458 } 2459 }
2459 } 2460 }
2460 break; 2461 break;
2461 case Key_Down: 2462 case Key_Down:
2462 { 2463 {
2463 if (reader->m_autoScroll && m_downScroll) 2464 if (reader->m_autoScroll && m_downScroll)
2464 { 2465 {
2465 reader->reduceScroll(); 2466 reader->reduceScroll();
2466 } 2467 }
2467 else 2468 else
2468 { 2469 {
2469 doAction(m_downTarget, e); 2470 doAction(m_downTarget, e);
2470 } 2471 }
2471 } 2472 }
2472 break; 2473 break;
2473 default: 2474 default:
2474 { 2475 {
2475 e->ignore(); 2476 e->ignore();
2476 } 2477 }
2477 2478
2478/* 2479/*
2479 QString msg("Key press was:"); 2480 QString msg("Key press was:");
2480 QString key; 2481 QString key;
2481 msg += key.setNum(e->key()); 2482 msg += key.setNum(e->key());
2482 QMessageBox::information(this, PROGNAME, msg); 2483 QMessageBox::information(this, PROGNAME, msg);
2483*/ 2484*/
2484 } 2485 }
2485} 2486}
2486 2487
2487void QTReaderApp::showEditTools() 2488void QTReaderApp::showEditTools()
2488{ 2489{
2489// if ( !doc ) 2490// if ( !doc )
2490 //close(); 2491// close();
2491 if (m_fullscreen) 2492 if (m_fullscreen)
2492 { 2493 {
2493 if (menubar != NULL) menubar->hide(); 2494 if (menubar != NULL) menubar->hide();
2494 if (fileBar != NULL) fileBar->hide(); 2495 if (fileBar != NULL) fileBar->hide();
2495 if (viewBar != NULL) viewBar->hide(); 2496 if (viewBar != NULL) viewBar->hide();
2496 if (navBar != NULL) navBar->hide(); 2497 if (navBar != NULL) navBar->hide();
2497 if (markBar != NULL) markBar->hide(); 2498 if (markBar != NULL) markBar->hide();
2498 searchBar->hide(); 2499 searchBar->hide();
2499 regBar->hide(); 2500 regBar->hide();
2500#ifdef USEQPE 2501#ifdef USEQPE
2501 Global::hideInputMethod(); 2502 Global::hideInputMethod();
2502#endif 2503#endif
2503 m_fontBar->hide(); 2504 m_fontBar->hide();
2504 //showNormal(); 2505// showNormal();
2505 showFullScreen(); 2506 showFullScreen();
2506 } 2507 }
2507 else 2508 else
2508 { 2509 {
2509 //qDebug("him"); 2510// odebug << "him" << oendl;
2510#ifdef USEQPE 2511#ifdef USEQPE
2511 Global::hideInputMethod(); 2512 Global::hideInputMethod();
2512#endif 2513#endif
2513 //qDebug("eb"); 2514// odebug << "eb" << oendl;
2514 menubar->show(); 2515 menubar->show();
2515 if (fileBar != NULL) fileBar->show(); 2516 if (fileBar != NULL) fileBar->show();
2516 if (viewBar != NULL) viewBar->show(); 2517 if (viewBar != NULL) viewBar->show();
2517 if (navBar != NULL) navBar->show(); 2518 if (navBar != NULL) navBar->show();
2518 if (markBar != NULL) markBar->show(); 2519 if (markBar != NULL) markBar->show();
2519 mb->show(); 2520 mb->show();
2520 if ( searchVisible ) 2521 if ( searchVisible )
2521 { 2522 {
2522#ifdef USEQPE 2523#ifdef USEQPE
2523 Global::showInputMethod(); 2524 Global::showInputMethod();
2524#endif 2525#endif
2525 searchBar->show(); 2526 searchBar->show();
2526 } 2527 }
2527 if ( regVisible ) 2528 if ( regVisible )
2528 { 2529 {
2529#ifdef USEQPE 2530#ifdef USEQPE
2530 Global::showInputMethod(); 2531 Global::showInputMethod();
2531#endif 2532#endif
2532 regBar->show(); 2533 regBar->show();
2533 } 2534 }
2534 if (m_fontVisible) m_fontBar->show(); 2535 if (m_fontVisible) m_fontBar->show();
2535 //qDebug("sn"); 2536// odebug << "sn" << oendl;
2536 showNormal(); 2537 showNormal();
2537 //qDebug("sm"); 2538// odebug << "sm" << oendl;
2538#ifdef USEQPE 2539#ifdef USEQPE
2539 showMaximized(); 2540 showMaximized();
2540#endif 2541#endif
2541 //setCentralWidget(reader); 2542// setCentralWidget(reader);
2542 } 2543 }
2543 2544
2544// qDebug("uc"); 2545// odebug << "uc" << oendl;
2545 updateCaption(); 2546 updateCaption();
2546// qDebug("rw"); 2547// odebug << "rw" << oendl;
2547 editorStack->raiseWidget( reader ); 2548 editorStack->raiseWidget( reader );
2548// qDebug("sf"); 2549// odebug << "sf" << oendl;
2549 reader->setFocus(); 2550 reader->setFocus();
2550 reader->refresh(); 2551 reader->refresh();
2551} 2552}
2552/* 2553/*
2553void QTReaderApp::save() 2554void QTReaderApp::save()
2554{ 2555{
2555 if ( !doc ) 2556 if ( !doc )
2556 return; 2557 return;
2557 if ( !editor->edited() ) 2558 if ( !editor->edited() )
2558 return; 2559 return;
2559 2560
2560 QString rt = editor->text(); 2561 QString rt = editor->text();
2561 QString pt = rt; 2562 QString pt = rt;
2562 2563
2563 if ( doc->name().isEmpty() ) { 2564 if ( doc->name().isEmpty() ) {
2564 unsigned ispace = pt.find( ' ' ); 2565 unsigned ispace = pt.find( ' ' );
2565 unsigned ienter = pt.find( '\n' ); 2566 unsigned ienter = pt.find( '\n' );
2566 int i = (ispace < ienter) ? ispace : ienter; 2567 int i = (ispace < ienter) ? ispace : ienter;
2567 QString docname; 2568 QString docname;
2568 if ( i == -1 ) { 2569 if ( i == -1 ) {
2569 if ( pt.isEmpty() ) 2570 if ( pt.isEmpty() )
2570 docname = "Empty Text"; 2571 docname = "Empty Text";
2571 else 2572 else
2572 docname = pt; 2573 docname = pt;
2573 } else { 2574 } else {
2574 docname = pt.left( i ); 2575 docname = pt.left( i );
2575 } 2576 }
2576 doc->setName(docname); 2577 doc->setName(docname);
2577 } 2578 }
2578 FileManager fm; 2579 FileManager fm;
2579 fm.saveFile( *doc, rt ); 2580 fm.saveFile( *doc, rt );
2580} 2581}
2581*/ 2582*/
2582 2583
2583void QTReaderApp::clear() 2584void QTReaderApp::clear()
2584{ 2585{
2585// if (doc != 0) 2586// if (doc != 0)
2586// { 2587// {
2587// QMessageBox::information(this, PROGNAME, "Deleting doc", 1); 2588// QMessageBox::information(this, PROGNAME, "Deleting doc", 1);
2588 //delete doc; 2589// delete doc;
2589// QMessageBox::information(this, PROGNAME, "Deleted doc", 1); 2590// QMessageBox::information(this, PROGNAME, "Deleted doc", 1);
2590 //doc = 0; 2591// doc = 0;
2591 // } 2592 // }
2592 reader->clear(); 2593 reader->clear();
2593} 2594}
2594 2595
2595void QTReaderApp::updateCaption() 2596void QTReaderApp::updateCaption()
2596{ 2597{
2597// if ( !doc ) 2598// if ( !doc )
2598 //setCaption( tr("QTReader") ); 2599// setCaption( tr("QTReader") );
2599// else { 2600// else {
2600 //QString s = doc->name(); 2601// QString s = doc->name();
2601 //if ( s.isEmpty() ) 2602// if ( s.isEmpty() )
2602 // s = tr( "Unnamed" ); 2603// s = tr( "Unnamed" );
2603 setCaption( reader->m_string + " - " + tr("Reader") ); 2604 setCaption( reader->m_string + " - " + tr("Reader") );
2604// } 2605// }
2605} 2606}
2606 2607
2607void QTReaderApp::setDocument(const QString& fileref) 2608void QTReaderApp::setDocument(const QString& fileref)
2608{ 2609{
2609 bFromDocView = TRUE; 2610 bFromDocView = TRUE;
2610//QMessageBox::information(0, "setDocument", fileref); 2611//QMessageBox::information(0, "setDocument", fileref);
2611 openFile(fileref); 2612 openFile(fileref);
2612// showEditTools(); 2613// showEditTools();
2613} 2614}
2614 2615
2615void QTReaderApp::closeEvent( QCloseEvent *e ) 2616void QTReaderApp::closeEvent( QCloseEvent *e )
2616{ 2617{
2617// qDebug("Close event"); 2618// odebug << "Close event" << oendl;
2618 if (m_fullscreen) 2619 if (m_fullscreen)
2619 { 2620 {
2620 m_fullscreen = false; 2621 m_fullscreen = false;
2621 showEditTools(); 2622 showEditTools();
2622 e->accept(); 2623 e->accept();
2623 } 2624 }
2624 else if (m_dontSave) 2625 else if (m_dontSave)
2625 { 2626 {
2626 e->accept(); 2627 e->accept();
2627 } 2628 }
2628 else 2629 else
2629 { 2630 {
2630 if (editorStack->visibleWidget() == reader) 2631 if (editorStack->visibleWidget() == reader)
2631 { 2632 {
2632 if ((m_escapeTarget != cesNone) && m_bcloseDisabled) 2633 if ((m_escapeTarget != cesNone) && m_bcloseDisabled)
2633 { 2634 {
2634 //qDebug("Close disabled"); 2635// odebug << "Close disabled" << oendl;
2635 m_bcloseDisabled = false; 2636 m_bcloseDisabled = false;
2636 e->ignore(); 2637 e->ignore();
2637 } 2638 }
2638 else 2639 else
2639 { 2640 {
2640 if (m_fontVisible) 2641 if (m_fontVisible)
2641 { 2642 {
2642 m_fontBar->hide(); 2643 m_fontBar->hide();
2643 m_fontVisible = false; 2644 m_fontVisible = false;
2644 } 2645 }
2645 if (regVisible) 2646 if (regVisible)
2646 { 2647 {
2647 regBar->hide(); 2648 regBar->hide();
2648#ifdef USEQPE 2649#ifdef USEQPE
2649 Global::hideInputMethod(); 2650 Global::hideInputMethod();
2650#endif 2651#endif
2651 regVisible = false; 2652 regVisible = false;
2652 return; 2653 return;
2653 } 2654 }
2654 if (searchVisible) 2655 if (searchVisible)
2655 { 2656 {
2656 searchBar->hide(); 2657 searchBar->hide();
2657#ifdef USEQPE 2658#ifdef USEQPE
2658 Global::hideInputMethod(); 2659 Global::hideInputMethod();
2659#endif 2660#endif
2660 searchVisible = false; 2661 searchVisible = false;
2661 return; 2662 return;
2662 } 2663 }
2663 if (m_fBkmksChanged && pBkmklist != NULL) 2664 if (m_fBkmksChanged && pBkmklist != NULL)
2664 { 2665 {
2665 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) 2666 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
2666 savebkmks(); 2667 savebkmks();
2667 delete pBkmklist; 2668 delete pBkmklist;
2668 pBkmklist = NULL; 2669 pBkmklist = NULL;
2669 m_fBkmksChanged = false; 2670 m_fBkmksChanged = false;
2670 } 2671 }
2671 bFromDocView = FALSE; 2672 bFromDocView = FALSE;
2672 updatefileinfo(); 2673 updatefileinfo();
2673 saveprefs(); 2674 saveprefs();
2674 e->accept(); 2675 e->accept();
2675 } 2676 }
2676 } 2677 }
2677 else 2678 else
2678 { 2679 {
2679 showEditTools(); 2680 showEditTools();
2680 m_disableesckey = true; 2681 m_disableesckey = true;
2681 } 2682 }
2682 } 2683 }
2683} 2684}
2684 2685
2685void QTReaderApp::do_gotomark() 2686void QTReaderApp::do_gotomark()
2686{ 2687{
2687 m_nBkmkAction = cGotoBkmk; 2688 m_nBkmkAction = cGotoBkmk;
2688 if (!listbkmk(pBkmklist)) 2689 if (!listbkmk(pBkmklist))
2689 QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); 2690 QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
2690} 2691}
2691 2692
2692void QTReaderApp::do_delmark() 2693void QTReaderApp::do_delmark()
2693{ 2694{
2694 m_nBkmkAction = cDelBkmk; 2695 m_nBkmkAction = cDelBkmk;
2695 if (!listbkmk(pBkmklist)) 2696 if (!listbkmk(pBkmklist))
2696 QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); 2697 QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
2697} 2698}
2698 2699
2699bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) 2700bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
2700{ 2701{
2701 bkmkselector->clear(); 2702 bkmkselector->clear();
2702 if (_lab.isEmpty()) 2703 if (_lab.isEmpty())
2703 bkmkselector->setText("Cancel"); 2704 bkmkselector->setText("Cancel");
2704 else 2705 else
2705 bkmkselector->setText(_lab); 2706 bkmkselector->setText(_lab);
2706 int cnt = 0; 2707 int cnt = 0;
2707 if (plist != NULL) 2708 if (plist != NULL)
2708 { 2709 {
2709 for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) 2710 for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++)
2710 { 2711 {
2711#ifdef _UNICODE 2712#ifdef _UNICODE
2712 // qDebug("Item:%s", (const char*)toQString(i->name())); 2713// odebug << "Item:" << toQString(i->name()) << "" << oendl;
2713 bkmkselector->insertItem(toQString(i->name())); 2714 bkmkselector->insertItem(toQString(i->name()));
2714#else 2715#else
2715 bkmkselector->insertItem(i->name()); 2716 bkmkselector->insertItem(i->name());
2716#endif 2717#endif
2717 cnt++; 2718 cnt++;
2718 } 2719 }
2719 } 2720 }
2720 if (cnt > 0) 2721 if (cnt > 0)
2721 { 2722 {
2722 hidetoolbars(); 2723 hidetoolbars();
2723 editorStack->raiseWidget( bkmkselector ); 2724 editorStack->raiseWidget( bkmkselector );
2724 return true; 2725 return true;
2725 } 2726 }
2726 else 2727 else
2727 return false; 2728 return false;
2728} 2729}
2729 2730
2730void QTReaderApp::do_autogen() 2731void QTReaderApp::do_autogen()
2731{ 2732{
2732 m_nRegAction = cAutoGen; 2733 m_nRegAction = cAutoGen;
2733 regEdit->setText(m_autogenstr); 2734 regEdit->setText(m_autogenstr);
2734 do_regedit(); 2735 do_regedit();
2735} 2736}
2736 2737
2737void QTReaderApp::do_regedit() 2738void QTReaderApp::do_regedit()
2738{ 2739{
2739// fileBar->hide(); 2740// fileBar->hide();
2740 reader->bDoUpdates = false; 2741 reader->bDoUpdates = false;
2741// qDebug("Showing regbar"); 2742// odebug << "Showing regbar" << oendl;
2742 regBar->show(); 2743 regBar->show();
2743// qDebug("Showing kbd"); 2744// odebug << "Showing kbd" << oendl;
2744#ifdef USEQPE 2745#ifdef USEQPE
2745 Global::showInputMethod(); 2746 Global::showInputMethod();
2746#endif 2747#endif
2747 regVisible = true; 2748 regVisible = true;
2748 regEdit->setFocus(); 2749 regEdit->setFocus();
2749// qApp->processEvents(); 2750// qApp->processEvents();
2750 reader->bDoUpdates = true; 2751 reader->bDoUpdates = true;
2751 reader->update(); 2752 reader->update();
2752} 2753}
2753 2754
2754bool QTReaderApp::openfrombkmk(Bkmk* bk) 2755bool QTReaderApp::openfrombkmk(Bkmk* bk)
2755{ 2756{
2756 QString fn = toQString( 2757 QString fn = toQString(
2757 CFiledata(bk->anno()).name() 2758 CFiledata(bk->anno()).name()
2758 ); 2759 );
2759 //qDebug("fileinfo"); 2760// odebug << "fileinfo" << oendl;
2760 if (!fn.isEmpty() && QFileInfo(fn).isFile()) 2761 if (!fn.isEmpty() && QFileInfo(fn).isFile())
2761 { 2762 {
2762 //qDebug("Opening"); 2763// odebug << "Opening" << oendl;
2763 openFile(fn); 2764 openFile(fn);
2764 struct stat fnstat; 2765 struct stat fnstat;
2765 stat((const char *)reader->m_lastfile, &fnstat); 2766 stat((const char *)reader->m_lastfile, &fnstat);
2766 2767
2767 if (CFiledata(bk->anno()).date() 2768 if (CFiledata(bk->anno()).date()
2768 != fnstat.st_mtime) 2769 != fnstat.st_mtime)
2769 { 2770 {
2770 CFiledata fd(bk->anno()); 2771 CFiledata fd(bk->anno());
2771 fd.setdate(fnstat.st_mtime); 2772 fd.setdate(fnstat.st_mtime);
2772 bk->value(0); 2773 bk->value(0);
2773 }
2774 else
2775 {
2776 unsigned short svlen = bk->filedatalen();
2777 unsigned char* svdata = bk->filedata();
2778 reader->putSaveData(svdata, svlen);
2779 // setstate(svdata, svlen);
2780 if (svlen != 0)
2781 {
2782 QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?");
2783 }
2784 // qDebug("updating");
2785 // showEditTools();
2786 reader->locate(bk->value());
2787 }
2788 return true;
2789 } 2774 }
2790 else 2775 else
2791 { 2776 {
2792 return false; 2777 unsigned short svlen = bk->filedatalen();
2778 unsigned char* svdata = bk->filedata();
2779 reader->putSaveData(svdata, svlen);
2780// setstate(svdata, svlen);
2781 if (svlen != 0)
2782 {
2783 QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?");
2784 }
2785// odebug << "updating" << oendl;
2786// showEditTools();
2787 reader->locate(bk->value());
2788 }
2789 return true;
2790 }
2791 else
2792 {
2793 return false;
2793 } 2794 }
2794} 2795}
2795 2796
2796void QTReaderApp::gotobkmk(int ind) 2797void QTReaderApp::gotobkmk(int ind)
2797{ 2798{
2798 showEditTools(); 2799 showEditTools();
2799 switch (m_nBkmkAction) 2800 switch (m_nBkmkAction)
2800 { 2801 {
2801 case cOpenFile: 2802 case cOpenFile:
2802 { 2803 {
2803 // qApp->processEvents(); 2804// qApp->processEvents();
2804 if (!openfrombkmk((*pOpenlist)[ind])) 2805 if (!openfrombkmk((*pOpenlist)[ind]))
2805 { 2806 {
2806 pOpenlist->erase(ind); 2807 pOpenlist->erase(ind);
2807 QMessageBox::information(this, PROGNAME, "Can't find file"); 2808 QMessageBox::information(this, PROGNAME, "Can't find file");
2808 } 2809 }
2809 } 2810 }
2810 break; 2811 break;
2811 case cGotoBkmk: 2812 case cGotoBkmk:
2812 reader->locate((*pBkmklist)[ind]->value()); 2813 reader->locate((*pBkmklist)[ind]->value());
2813 break; 2814 break;
2814 case cDelBkmk: 2815 case cDelBkmk:
2815 //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); 2816//// odebug << "Deleting:" << (*pBkmklist)[ind]->name() << "\n" << oendl;
2816 pBkmklist->erase(ind); 2817 pBkmklist->erase(ind);
2817 m_fBkmksChanged = true; 2818 m_fBkmksChanged = true;
2818 // pBkmklist->sort(); 2819// pBkmklist->sort();
2819 break; 2820 break;
2820 case cRmBkmkFile: 2821 case cRmBkmkFile:
2821 { 2822 {
2822#ifndef USEQPE 2823#ifndef USEQPE
2823 QDir d = QDir::home(); // "/" 2824 QDir d = QDir::home(); // "/"
2824 d.cd(APPDIR); 2825 d.cd(APPDIR);
2825 d.remove(bkmkselector->text(ind)); 2826 d.remove(bkmkselector->text(ind));
2826#else /* USEQPE */ 2827#else /* USEQPE */
2827 unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); 2828 unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind)));
2828#endif /* USEQPE */ 2829#endif /* USEQPE */
2829 } 2830 }
2830 break; 2831 break;
2831 case cLdConfig: 2832 case cLdConfig:
2832 readconfig(bkmkselector->text(ind), false); 2833 readconfig(bkmkselector->text(ind), false);
2833 break; 2834 break;
2834 case cRmConfig: 2835 case cRmConfig:
2835 { 2836 {
2836#ifndef USEQPE 2837#ifndef USEQPE
2837 QDir d = QDir::home(); // "/" 2838 QDir d = QDir::home(); // "/"
2838 d.cd(APPDIR "/configs"); 2839 d.cd(APPDIR "/configs");
2839 d.remove(bkmkselector->text(ind)); 2840 d.remove(bkmkselector->text(ind));
2840#else /* USEQPE */ 2841#else /* USEQPE */
2841 unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); 2842 unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind)));
2842#endif /* USEQPE */ 2843#endif /* USEQPE */
2843 } 2844 }
2844 break; 2845 break;
2845 case cExportLinks: 2846 case cExportLinks:
2846 { 2847 {
2847#ifndef USEQPE 2848#ifndef USEQPE
2848 QDir d = QDir::home(); // "/" 2849 QDir d = QDir::home(); // "/"
2849 d.cd(APPDIR "/urls"); 2850 d.cd(APPDIR "/urls");
2850 QFileInfo fi(d, bkmkselector->text(ind)); 2851 QFileInfo fi(d, bkmkselector->text(ind));
2851 if (fi.exists()) 2852 if (fi.exists())
2852 { 2853 {
2853 QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); 2854 QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) );
2854 if (!outfile.isEmpty()) 2855 if (!outfile.isEmpty())
2855 { 2856 {
2856 FILE* fout = fopen((const char *)outfile, "w"); 2857 FILE* fout = fopen((const char *)outfile, "w");
2857 if (fout != NULL) 2858 if (fout != NULL)
2858 { 2859 {
2859 FILE* fin = fopen((const char *)fi.absFilePath(), "r"); 2860 FILE* fin = fopen((const char *)fi.absFilePath(), "r");
2860 if (fin != NULL) 2861 if (fin != NULL)
2861 { 2862 {
2862 fprintf(fout, "<html><body>\n"); 2863 fprintf(fout, "<html><body>\n");
2863 int ch = 0; 2864 int ch = 0;
2864 while ((ch = fgetc(fin)) != EOF) 2865 while ((ch = fgetc(fin)) != EOF)
2865 { 2866 {
2866 fputc(ch, fout); 2867 fputc(ch, fout);
2867 } 2868 }
2868 fclose(fin); 2869 fclose(fin);
2869 fprintf(fout, "</html></body>\n"); 2870 fprintf(fout, "</html></body>\n");
2870 d.remove(bkmkselector->text(ind)); 2871 d.remove(bkmkselector->text(ind));
2871 } 2872 }
2872 fclose(fout); 2873 fclose(fout);
2873 } 2874 }
2874 else 2875 else
2875 QMessageBox::information(this, PROGNAME, "Couldn't open output"); 2876 QMessageBox::information(this, PROGNAME, "Couldn't open output");
2876 } 2877 }
2877 } 2878 }
2878#else /* USEQPE */ 2879#else /* USEQPE */
2879 FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); 2880 FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r");
2880 if (fin != NULL) 2881 if (fin != NULL)
2881 { 2882 {
2882 bool allok = false; 2883 bool allok = false;
2883 fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); 2884 fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null);
2884 if (fb->exec()) 2885 if (fb->exec())
2885 { 2886 {
2886 QString outfile = fb->getCurrentFile(); 2887 QString outfile = fb->getCurrentFile();
2887 FILE* fout = fopen((const char *)outfile, "w"); 2888 FILE* fout = fopen((const char *)outfile, "w");
2888 if (fout != NULL) 2889 if (fout != NULL)
2889 { 2890 {
2890 fprintf(fout, "<html><body>\n"); 2891 fprintf(fout, "<html><body>\n");
2891 int ch = 0; 2892 int ch = 0;
2892 while ((ch = fgetc(fin)) != EOF) 2893 while ((ch = fgetc(fin)) != EOF)
2893 { 2894 {
2894 fputc(ch, fout); 2895 fputc(ch, fout);
2895 } 2896 }
2896 fprintf(fout, "</html></body>\n"); 2897 fprintf(fout, "</html></body>\n");
2897 fclose(fout); 2898 fclose(fout);
2898 allok = true; 2899 allok = true;
2899 } 2900 }
2900 else 2901 else
2901 QMessageBox::information(this, PROGNAME, "Couldn't open output"); 2902 QMessageBox::information(this, PROGNAME, "Couldn't open output");
2902 } 2903 }
2903 delete fb; 2904 delete fb;
2904 fclose(fin); 2905 fclose(fin);
2905 if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); 2906 if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)));
2906 } 2907 }
2907 else 2908 else
2908 { 2909 {
2909 QMessageBox::information(this, PROGNAME, "Couldn't open input"); 2910 QMessageBox::information(this, PROGNAME, "Couldn't open input");
2910 } 2911 }
2911 2912
2912/* 2913/*
2913 CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); 2914 CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE );
2914 int ret = f->exec(); 2915 int ret = f->exec();
2915 qDebug("Return:%d", ret); 2916 odebug << "Return:" << ret << "" << oendl;
2916 DocLnk* doc = f->getDoc(); 2917 DocLnk* doc = f->getDoc();
2917 if (doc != NULL) 2918 if (doc != NULL)
2918 { 2919 {
2919 FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); 2920 FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r");
2920 QString rt; 2921 QString rt;
2921 rt = "<html><body>\n"; 2922 rt = "<html><body>\n";
2922 int ch = 0; 2923 int ch = 0;
2923 while ((ch = fgetc(fin)) != EOF) 2924 while ((ch = fgetc(fin)) != EOF)
2924 { 2925 {
2925 rt += (char)ch; 2926 rt += (char)ch;
2926 } 2927 }
2927 fclose(fin); 2928 fclose(fin);
2928 rt += "</html></body>\n"; 2929 rt += "</html></body>\n";
2929 if ( doc->name().isEmpty() ) 2930 if ( doc->name().isEmpty() )
2930 { 2931 {
2931 doc->setName(bkmkselector->text(ind)); 2932 doc->setName(bkmkselector->text(ind));
2932 } 2933 }
2933 FileManager fm; 2934 FileManager fm;
2934 fm.saveFile( *doc, rt ); 2935 fm.saveFile( *doc, rt );
2935 qDebug("YES"); 2936 odebug << "YES" << oendl;
2936 } 2937 }
2937 else 2938 else
2938 { 2939 {
2939 qDebug("NO"); 2940 odebug << "NO" << oendl;
2940 } 2941 }
2941 delete f; 2942 delete f;
2942*/ 2943*/
2943 2944
2944#endif /* USEQPE */ 2945#endif /* USEQPE */
2945 } 2946 }
2946 break; 2947 break;
2947 } 2948 }
2948} 2949}
2949 2950
2950void QTReaderApp::cancelbkmk() 2951void QTReaderApp::cancelbkmk()
2951{ 2952{
2952 if (m_nBkmkAction == cOpenFile) 2953 if (m_nBkmkAction == cOpenFile)
2953 { 2954 {
2954 QString fn = usefilebrowser(); 2955 QString fn = usefilebrowser();
2955 if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); 2956 if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn);
2956 } 2957 }
2957 showEditTools(); 2958 showEditTools();
2958} 2959}
2959 2960
2960void QTReaderApp::jump() 2961void QTReaderApp::jump()
2961{ 2962{
2962 m_nRegAction = cJump; 2963 m_nRegAction = cJump;
2963 char lcn[20]; 2964 char lcn[20];
2964 sprintf(lcn, "%lu", reader->pagelocate()); 2965 sprintf(lcn, "%lu", reader->pagelocate());
2965 regEdit->setText(lcn); 2966 regEdit->setText(lcn);
2966 do_regedit(); 2967 do_regedit();
2967} 2968}
2968 2969
2969void QTReaderApp::do_jump(const QString& lcn) 2970void QTReaderApp::do_jump(const QString& lcn)
2970{ 2971{
2971 bool ok; 2972 bool ok;
2972 unsigned long ulcn = lcn.toULong(&ok); 2973 unsigned long ulcn = lcn.toULong(&ok);
2973 if (ok) 2974 if (ok)
2974 reader->locate(ulcn); 2975 reader->locate(ulcn);
2975 else 2976 else
2976 QMessageBox::information(this, PROGNAME, "Must be a number"); 2977 QMessageBox::information(this, PROGNAME, "Must be a number");
2977} 2978}
2978 2979
2979void QTReaderApp::do_regaction() 2980void QTReaderApp::do_regaction()
2980{ 2981{
2981 reader->bDoUpdates = false; 2982 reader->bDoUpdates = false;
2982 regBar->hide(); 2983 regBar->hide();
2983#ifdef USEQPE 2984#ifdef USEQPE
2984 Global::hideInputMethod(); 2985 Global::hideInputMethod();
2985#endif 2986#endif
2986 regVisible = false; 2987 regVisible = false;
2987 switch(m_nRegAction) 2988 switch(m_nRegAction)
2988 { 2989 {
2989 case cAutoGen: 2990 case cAutoGen:
2990 do_autogen(regEdit->text()); 2991 do_autogen(regEdit->text());
2991 break; 2992 break;
2992 case cAddBkmk: 2993 case cAddBkmk:
2993 do_addbkmk(regEdit->text()); 2994 do_addbkmk(regEdit->text());
2994 break; 2995 break;
2995 case cJump: 2996 case cJump:
2996 do_jump(regEdit->text()); 2997 do_jump(regEdit->text());
2997 break; 2998 break;
2998/* 2999/*
2999 case cMonoSpace: 3000 case cMonoSpace:
3000 do_mono(regEdit->text()); 3001 do_mono(regEdit->text());
3001 break; 3002 break;
3002*/ 3003*/
3003 case cSetTarget: 3004 case cSetTarget:
3004 do_settarget(regEdit->text()); 3005 do_settarget(regEdit->text());
3005 break; 3006 break;
3006#ifdef _SCROLLPIPE 3007#ifdef _SCROLLPIPE
3007 case cSetPipeTarget: 3008 case cSetPipeTarget:
3008 do_setpipetarget(regEdit->text()); 3009 do_setpipetarget(regEdit->text());
3009 break; 3010 break;
3010#endif 3011#endif
3011 case cSetConfigName: 3012 case cSetConfigName:
3012 // qDebug("Saving config"); 3013// odebug << "Saving config" << oendl;
3013 do_saveconfig(regEdit->text(), false); 3014 do_saveconfig(regEdit->text(), false);
3014 break; 3015 break;
3015 } 3016 }
3016// reader->restore(); 3017// reader->restore();
3017// fileBar->show(); 3018// fileBar->show();
3018 reader->setFocus(); 3019 reader->setFocus();
3019// qApp->processEvents(); 3020// qApp->processEvents();
3020 reader->bDoUpdates = true; 3021 reader->bDoUpdates = true;
3021 reader->update(); 3022 reader->update();
3022} 3023}
3023 3024
3024void QTReaderApp::do_settarget(const QString& _txt) 3025void QTReaderApp::do_settarget(const QString& _txt)
3025{ 3026{
3026 int ind = _txt.find('/'); 3027 int ind = _txt.find('/');
3027 if (ind == -1) 3028 if (ind == -1)
3028 { 3029 {
3029 m_targetapp = ""; 3030 m_targetapp = "";
3030 m_targetmsg = ""; 3031 m_targetmsg = "";
3031 QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); 3032 QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename");
3032 } 3033 }
3033 else 3034 else
3034 { 3035 {
3035 m_targetapp = _txt.left(ind); 3036 m_targetapp = _txt.left(ind);
3036 m_targetmsg = _txt.right(_txt.length()-ind-1); 3037 m_targetmsg = _txt.right(_txt.length()-ind-1);
3037 } 3038 }
3038} 3039}
3039 3040
3040void QTReaderApp::chooseencoding() 3041void QTReaderApp::chooseencoding()
3041{ 3042{
3042 m_fontSelector->clear(); 3043 m_fontSelector->clear();
3043 m_fontSelector->insertItem("Ascii"); 3044 m_fontSelector->insertItem("Ascii");
3044 m_fontSelector->insertItem("UTF-8"); 3045 m_fontSelector->insertItem("UTF-8");
3045 m_fontSelector->insertItem("UCS-2(BE)"); 3046 m_fontSelector->insertItem("UCS-2(BE)");
3046 m_fontSelector->insertItem("USC-2(LE)"); 3047 m_fontSelector->insertItem("USC-2(LE)");
3047 m_fontSelector->insertItem("Palm"); 3048 m_fontSelector->insertItem("Palm");
3048 for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) 3049 for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++)
3049 { 3050 {
3050 m_fontSelector->insertItem(iter->mime); 3051 m_fontSelector->insertItem(iter->mime);
3051 } // delete the FontDatabase!!! 3052 } // delete the FontDatabase!!!
3052 m_fontSelector->setCurrentItem (reader->m_encd); 3053 m_fontSelector->setCurrentItem (reader->m_encd);
3053 m_fontAction = cChooseEncoding; 3054 m_fontAction = cChooseEncoding;
3054 m_fontBar->show(); 3055 m_fontBar->show();
3055 m_fontVisible = true; 3056 m_fontVisible = true;
3056} 3057}
3057 3058
3058void QTReaderApp::setfont() 3059void QTReaderApp::setfont()
3059{ 3060{
3060 m_fontSelector->clear(); 3061 m_fontSelector->clear();
3061 { 3062 {
3062#ifdef USEQPE 3063#ifdef USEQPE
3063 FontDatabase f; 3064 FontDatabase f;
3064#else 3065#else
3065 QFontDatabase f; 3066 QFontDatabase f;
3066#endif 3067#endif
3067 QStringList flist = f.families(); 3068 QStringList flist = f.families();
3068 m_fontSelector->insertStringList(flist); 3069 m_fontSelector->insertStringList(flist);
3069 } // delete the FontDatabase!!! 3070 } // delete the FontDatabase!!!
3070 3071
3071 for (int i = 1; i <= m_fontSelector->count(); i++) 3072 for (int i = 1; i <= m_fontSelector->count(); i++)
3072 { 3073 {
3073 if (m_fontSelector->text(i) == reader->m_fontname) 3074 if (m_fontSelector->text(i) == reader->m_fontname)
3074 { 3075 {
3075 m_fontSelector->setCurrentItem(i); 3076 m_fontSelector->setCurrentItem(i);
3076 break; 3077 break;
3077 } 3078 }
3078 } 3079 }
3079 m_fontAction = cChooseFont; 3080 m_fontAction = cChooseFont;
3080 m_fontBar->show(); 3081 m_fontBar->show();
3081 m_fontVisible = true; 3082 m_fontVisible = true;
3082} 3083}
3083 3084
3084void QTReaderApp::setfontHelper(const QString& lcn, int size) 3085void QTReaderApp::setfontHelper(const QString& lcn, int size)
3085{ 3086{
3086 if (size == 0) size = reader->m_fontControl.currentsize(); 3087 if (size == 0) size = reader->m_fontControl.currentsize();
3087 if (m_propogatefontchange) 3088 if (m_propogatefontchange)
3088 { 3089 {
3089 QFont f(lcn, 10); 3090 QFont f(lcn, 10);
3090 bkmkselector->setFont( f ); 3091 bkmkselector->setFont( f );
3091 regEdit->setFont( f ); 3092 regEdit->setFont( f );
3092 searchEdit->setFont( f ); 3093 searchEdit->setFont( f );
3093 m_annoWin->setFont( f ); 3094 m_annoWin->setFont( f );
3094 } 3095 }
3095 reader->m_fontname = lcn; 3096 reader->m_fontname = lcn;
3096 if (!reader->ChangeFont(size)) 3097 if (!reader->ChangeFont(size))
3097 { 3098 {
3098 reader->ChangeFont(size); 3099 reader->ChangeFont(size);
3099 } 3100 }
3100} 3101}
3101 3102
3102void QTReaderApp::do_setencoding(int i) 3103void QTReaderApp::do_setencoding(int i)
3103{ 3104{
3104// qDebug("setencoding:%d", i); 3105// odebug << "setencoding:" << i << "" << oendl;
3105 if (m_fontAction == cChooseEncoding) 3106 if (m_fontAction == cChooseEncoding)
3106 { 3107 {
3107 reader->setencoding(i); 3108 reader->setencoding(i);
3108 } 3109 }
3109 reader->refresh(); 3110 reader->refresh();
3110 m_fontBar->hide(); 3111 m_fontBar->hide();
3111 m_fontVisible = false; 3112 m_fontVisible = false;
3112// qDebug("showedit"); 3113// odebug << "showedit" << oendl;
3113 if (reader->isVisible()) showEditTools(); 3114 if (reader->isVisible()) showEditTools();
3114// qDebug("showeditdone"); 3115// odebug << "showeditdone" << oendl;
3115} 3116}
3116 3117
3117void QTReaderApp::do_setfont(const QString& lcn) 3118void QTReaderApp::do_setfont(const QString& lcn)
3118{ 3119{
3119 if (m_fontAction == cChooseFont) 3120 if (m_fontAction == cChooseFont)
3120 { 3121 {
3121 setfontHelper(lcn); 3122 setfontHelper(lcn);
3122 } 3123 }
3123 reader->refresh(); 3124 reader->refresh();
3124 m_fontBar->hide(); 3125 m_fontBar->hide();
3125 m_fontVisible = false; 3126 m_fontVisible = false;
3126// qDebug("showedit"); 3127// odebug << "showedit" << oendl;
3127 //if (reader->isVisible()) 3128 //if (reader->isVisible())
3128 showEditTools(); 3129 showEditTools();
3129// qDebug("showeditdone"); 3130// odebug << "showeditdone" << oendl;
3130} 3131}
3131 3132
3132void QTReaderApp::do_autogen(const QString& regText) 3133void QTReaderApp::do_autogen(const QString& regText)
3133{ 3134{
3134 unsigned long fs, ts; 3135 unsigned long fs, ts;
3135 reader->sizes(fs,ts); 3136 reader->sizes(fs,ts);
3136// // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); 3137// // odebug << "Reg:" << (const tchar*)(regEdit->text()) << "\n" << oendl;
3137 m_autogenstr = regText; 3138 m_autogenstr = regText;
3138 QRegExp re(regText); 3139 QRegExp re(regText);
3139 CBuffer buff; 3140 CBuffer buff;
3140 if (pBkmklist != NULL) delete pBkmklist; 3141 if (pBkmklist != NULL) delete pBkmklist;
3141 pBkmklist = new CList<Bkmk>; 3142 pBkmklist = new CList<Bkmk>;
3142 m_fBkmksChanged = true; 3143 m_fBkmksChanged = true;
3143 3144
3144 pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); 3145 pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height());
3145 pbar->show(); 3146 pbar->show();
3146 pbar->raise(); 3147 pbar->raise();
3147 pbar->reset(); 3148 pbar->reset();
3148 reader->update(); 3149 reader->update();
3149 qApp->processEvents(); 3150 qApp->processEvents();
3150 reader->setFocus(); 3151 reader->setFocus();
3151 reader->jumpto(0); 3152 reader->jumpto(0);
3152 int lastpc = 0; 3153 int lastpc = 0;
3153 int i = 0; 3154 int i = 0;
3154 while (i >= 0) 3155 while (i >= 0)
3155 { 3156 {
3156 unsigned int lcn = reader->locate(); 3157 unsigned int lcn = reader->locate();
3157 int pc = (100*lcn)/ts; 3158 int pc = (100*lcn)/ts;
3158 if (pc != lastpc) 3159 if (pc != lastpc)
3159 { 3160 {
3160 pbar->setProgress(pc); 3161 pbar->setProgress(pc);
3161 qApp->processEvents(); 3162 qApp->processEvents();
3162 if (reader->locate() != lcn) reader->jumpto(lcn); 3163 if (reader->locate() != lcn) reader->jumpto(lcn);
3163 reader->setFocus(); 3164 reader->setFocus();
3164 lastpc = pc; 3165 lastpc = pc;
3165 } 3166 }
3166 i = reader->buffdoc.getpara(buff); 3167 i = reader->buffdoc.getpara(buff);
3167#ifdef _UNICODE 3168#ifdef _UNICODE
3168 if (re.match(toQString(buff.data())) != -1) 3169 if (re.match(toQString(buff.data())) != -1)
3169#else 3170#else
3170 if (re.match(buff.data()) != -1) 3171 if (re.match(buff.data()) != -1)
3171#endif 3172#endif
3172 pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); 3173 pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn));
3173 } 3174 }
3174 pBkmklist->sort(); 3175 pBkmklist->sort();
3175 pbar->setProgress(100); 3176 pbar->setProgress(100);
3176 qApp->processEvents(); 3177 qApp->processEvents();
3177 pbar->hide(); 3178 pbar->hide();
3178 reader->refresh(); 3179 reader->refresh();
3179} 3180}
3180 3181
3181void QTReaderApp::saveprefs() 3182void QTReaderApp::saveprefs()
3182{ 3183{
3183// qDebug("saveprefs"); 3184// odebug << "saveprefs" << oendl;
3184// reader->saveprefs("uqtreader"); 3185// reader->saveprefs("uqtreader");
3185// if (!m_loadedconfig) 3186// if (!m_loadedconfig)
3186 do_saveconfig( APPDIR, true ); 3187 do_saveconfig( APPDIR, true );
3187 3188
3188/* 3189/*
3189 Config config( APPDIR ); 3190 Config config( APPDIR );
3190 config.setGroup( "View" ); 3191 config.setGroup( "View" );
3191 3192
3192 reader->m_lastposn = reader->pagelocate(); 3193 reader->m_lastposn = reader->pagelocate();
3193 3194
3194 config.writeEntry("FloatDialogs", m_bFloatingDialog); 3195 config.writeEntry("FloatDialogs", m_bFloatingDialog);
3195 config.writeEntry( "StripCr", reader->bstripcr ); 3196 config.writeEntry( "StripCr", reader->bstripcr );
3196 config.writeEntry( "AutoFmt", reader->bautofmt ); 3197 config.writeEntry( "AutoFmt", reader->bautofmt );
3197 config.writeEntry( "TextFmt", reader->btextfmt ); 3198 config.writeEntry( "TextFmt", reader->btextfmt );
3198 config.writeEntry( "StripHtml", reader->bstriphtml ); 3199 config.writeEntry( "StripHtml", reader->bstriphtml );
3199 config.writeEntry( "Dehyphen", reader->bdehyphen ); 3200 config.writeEntry( "Dehyphen", reader->bdehyphen );
3200 config.writeEntry( "Depluck", reader->bdepluck ); 3201 config.writeEntry( "Depluck", reader->bdepluck );
3201 config.writeEntry( "Dejpluck", reader->bdejpluck ); 3202 config.writeEntry( "Dejpluck", reader->bdejpluck );
3202 config.writeEntry( "OneSpace", reader->bonespace ); 3203 config.writeEntry( "OneSpace", reader->bonespace );
3203 config.writeEntry( "Unindent", reader->bunindent ); 3204 config.writeEntry( "Unindent", reader->bunindent );
3204 config.writeEntry( "Repara", reader->brepara ); 3205 config.writeEntry( "Repara", reader->brepara );
3205 config.writeEntry( "DoubleSpace", reader->bdblspce ); 3206 config.writeEntry( "DoubleSpace", reader->bdblspce );
3206 config.writeEntry( "Indent", reader->bindenter ); 3207 config.writeEntry( "Indent", reader->bindenter );
3207 config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); 3208 config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) );
3208 config.writeEntry( "ScrollDelay", reader->m_delay); 3209 config.writeEntry( "ScrollDelay", reader->m_delay);
3209 config.writeEntry( "LastFile", reader->m_lastfile ); 3210 config.writeEntry( "LastFile", reader->m_lastfile );
@@ -3248,451 +3249,451 @@ void QTReaderApp::saveprefs()
3248 config.writeEntry( "ExtraSpace", reader->getextraspace() ); 3249 config.writeEntry( "ExtraSpace", reader->getextraspace() );
3249 config.writeEntry( "ExtraLead", reader->getlead() ); 3250 config.writeEntry( "ExtraLead", reader->getlead() );
3250 config.writeEntry( "Basesize", (int)reader->getBaseSize()); 3251 config.writeEntry( "Basesize", (int)reader->getBaseSize());
3251 config.writeEntry( "RequestorFontChange", m_propogatefontchange); 3252 config.writeEntry( "RequestorFontChange", m_propogatefontchange);
3252 3253
3253 config.setGroup( "Toolbar" ); 3254 config.setGroup( "Toolbar" );
3254 config.writeEntry("Movable", m_tbmovesave); 3255 config.writeEntry("Movable", m_tbmovesave);
3255 config.writeEntry("Policy", m_tbpolsave); 3256 config.writeEntry("Policy", m_tbpolsave);
3256 config.writeEntry("Position", m_tbposition); 3257 config.writeEntry("Position", m_tbposition);
3257*/ 3258*/
3258 savefilelist(); 3259 savefilelist();
3259} 3260}
3260 3261
3261/* 3262/*
3262void QTReaderApp::oldFile() 3263void QTReaderApp::oldFile()
3263{ 3264{
3264// qDebug("oldFile called"); 3265// odebug << "oldFile called" << oendl;
3265 reader->setText(true); 3266 reader->setText(true);
3266// qDebug("settext called"); 3267// odebug << "settext called" << oendl;
3267 showEditTools(); 3268 showEditTools();
3268// qDebug("showedit called"); 3269// odebug << "showedit called" << oendl;
3269} 3270}
3270*/ 3271*/
3271 3272
3272/* 3273/*
3273void info_cb(Fl_Widget* o, void* _data) 3274void info_cb(Fl_Widget* o, void* _data)
3274{ 3275{
3275 3276
3276 if (infowin == NULL) 3277 if (infowin == NULL)
3277 { 3278 {
3278 3279
3279 infowin = new Fl_Window(160,240); 3280 infowin = new Fl_Window(160,240);
3280 filename = new Fl_Output(45,5,110,14,"Filename"); 3281 filename = new Fl_Output(45,5,110,14,"Filename");
3281 filesize = new Fl_Output(45,25,110,14,"Filesize"); 3282 filesize = new Fl_Output(45,25,110,14,"Filesize");
3282 textsize = new Fl_Output(45,45,110,14,"Textsize"); 3283 textsize = new Fl_Output(45,45,110,14,"Textsize");
3283 comprat = new CBar(45,65,110,14,"Ratio %"); 3284 comprat = new CBar(45,65,110,14,"Ratio %");
3284 posn = new Fl_Output(45,85,110,14,"Location"); 3285 posn = new Fl_Output(45,85,110,14,"Location");
3285 frcn = new CBar(45,105,110,14,"% Read"); 3286 frcn = new CBar(45,105,110,14,"% Read");
3286 about = new Fl_Multiline_Output(5,125,150,90); 3287 about = new Fl_Multiline_Output(5,125,150,90);
3287 about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); 3288 about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files");
3288 Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); 3289 Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay");
3289 infowin->set_modal(); 3290 infowin->set_modal();
3290 } 3291 }
3291 if (((reader_ui *)_data)->g_filename[0] != '\0') 3292 if (((reader_ui *)_data)->g_filename[0] != '\0')
3292 { 3293 {
3293 unsigned long fs,ts; 3294 unsigned long fs,ts;
3294 tchar sz[20]; 3295 tchar sz[20];
3295 ((reader_ui *)_data)->input->sizes(fs,ts); 3296 ((reader_ui *)_data)->input->sizes(fs,ts);
3296 unsigned long pl = ((reader_ui *)_data)->input->locate(); 3297 unsigned long pl = ((reader_ui *)_data)->input->locate();
3297 3298
3298 filename->value(((reader_ui *)_data)->g_filename); 3299 filename->value(((reader_ui *)_data)->g_filename);
3299 3300
3300 sprintf(sz,"%u",fs); 3301 sprintf(sz,"%u",fs);
3301 filesize->value(sz); 3302 filesize->value(sz);
3302 3303
3303 sprintf(sz,"%u",ts); 3304 sprintf(sz,"%u",ts);
3304 textsize->value(sz); 3305 textsize->value(sz);
3305 3306
3306 comprat->value(100-(100*fs + (ts >> 1))/ts); 3307 comprat->value(100-(100*fs + (ts >> 1))/ts);
3307 3308
3308 sprintf(sz,"%u",pl); 3309 sprintf(sz,"%u",pl);
3309 posn->value(sz); 3310 posn->value(sz);
3310 3311
3311 frcn->value((100*pl + (ts >> 1))/ts); 3312 frcn->value((100*pl + (ts >> 1))/ts);
3312 } 3313 }
3313 infowin->show(); 3314 infowin->show();
3314} 3315}
3315*/ 3316*/
3316 3317
3317void QTReaderApp::savebkmks() 3318void QTReaderApp::savebkmks()
3318{ 3319{
3319 if (pBkmklist != NULL) 3320 if (pBkmklist != NULL)
3320 { 3321 {
3321#ifndef USEQPE 3322#ifndef USEQPE
3322 QDir d = QDir::home(); // "/" 3323 QDir d = QDir::home(); // "/"
3323 d.cd(APPDIR); 3324 d.cd(APPDIR);
3324 QFileInfo fi(d, reader->m_string); 3325 QFileInfo fi(d, reader->m_string);
3325 BkmkFile bf((const char *)fi.absFilePath(), true); 3326 BkmkFile bf((const char *)fi.absFilePath(), true);
3326#else /* USEQPE */ 3327#else /* USEQPE */
3327 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true); 3328 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true);
3328#endif /* USEQPE */ 3329#endif /* USEQPE */
3329 bf.write(*pBkmklist); 3330 bf.write(*pBkmklist);
3330 } 3331 }
3331 m_fBkmksChanged = false; 3332 m_fBkmksChanged = false;
3332} 3333}
3333 3334
3334void QTReaderApp::readfilelist() 3335void QTReaderApp::readfilelist()
3335{ 3336{
3336#ifndef USEQPE 3337#ifndef USEQPE
3337 QDir d = QDir::home(); // "/" 3338 QDir d = QDir::home(); // "/"
3338 d.cd(APPDIR); 3339 d.cd(APPDIR);
3339 QFileInfo fi(d, ".openfiles"); 3340 QFileInfo fi(d, ".openfiles");
3340 BkmkFile bf((const char *)fi.absFilePath()); 3341 BkmkFile bf((const char *)fi.absFilePath());
3341#else /* USEQPE */ 3342#else /* USEQPE */
3342 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles")); 3343 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"));
3343#endif /* USEQPE */ 3344#endif /* USEQPE */
3344// qDebug("Reading open files"); 3345// odebug << "Reading open files" << oendl;
3345 pOpenlist = bf.readall(); 3346 pOpenlist = bf.readall();
3346// if (pOpenlist != NULL) qDebug("...with success"); 3347// if (pOpenlist != NULL) odebug << "...with success" << oendl;
3347// else qDebug("...without success!"); 3348// else odebug << "...without success!" << oendl;
3348} 3349}
3349 3350
3350void QTReaderApp::savefilelist() 3351void QTReaderApp::savefilelist()
3351{ 3352{
3352 if (pOpenlist != NULL) 3353 if (pOpenlist != NULL)
3353 { 3354 {
3354#ifndef USEQPE 3355#ifndef USEQPE
3355 QDir d = QDir::home(); // "/" 3356 QDir d = QDir::home(); // "/"
3356 d.cd(APPDIR); 3357 d.cd(APPDIR);
3357 QFileInfo fi(d, ".openfiles"); 3358 QFileInfo fi(d, ".openfiles");
3358 BkmkFile bf((const char *)fi.absFilePath(), true); 3359 BkmkFile bf((const char *)fi.absFilePath(), true);
3359#else /* USEQPE */ 3360#else /* USEQPE */
3360 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true); 3361 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true);
3361#endif /* USEQPE */ 3362#endif /* USEQPE */
3362 //qDebug("Writing open files"); 3363// odebug << "Writing open files" << oendl;
3363 bf.write(*pOpenlist); 3364 bf.write(*pOpenlist);
3364 } 3365 }
3365} 3366}
3366 3367
3367void QTReaderApp::readbkmks() 3368void QTReaderApp::readbkmks()
3368{ 3369{
3369 if (pBkmklist != NULL) 3370 if (pBkmklist != NULL)
3370 { 3371 {
3371 delete pBkmklist; 3372 delete pBkmklist;
3372 } 3373 }
3373 struct stat fnstat; 3374 struct stat fnstat;
3374 struct stat bkstat; 3375 struct stat bkstat;
3375#ifndef USEQPE 3376#ifndef USEQPE
3376 QDir d = QDir::home(); // "/" 3377 QDir d = QDir::home(); // "/"
3377 d.cd(APPDIR); 3378 d.cd(APPDIR);
3378 QFileInfo fi(d, reader->m_string); 3379 QFileInfo fi(d, reader->m_string);
3379#endif /* ! USEQPE */ 3380#endif /* ! USEQPE */
3380 if ( 3381 if (
3381 stat((const char *)reader->m_lastfile, &fnstat) == 0 3382 stat((const char *)reader->m_lastfile, &fnstat) == 0
3382 && 3383 &&
3383#ifndef USEQPE 3384#ifndef USEQPE
3384 stat((const char *)fi.absFilePath(), &bkstat) == 0 3385 stat((const char *)fi.absFilePath(), &bkstat) == 0
3385#else /* USEQPE */ 3386#else /* USEQPE */
3386 stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 3387 stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0
3387#endif /* USEQPE */ 3388#endif /* USEQPE */
3388 ) 3389 )
3390 {
3391 if (bkstat.st_mtime < fnstat.st_mtime)
3389 { 3392 {
3390 if (bkstat.st_mtime < fnstat.st_mtime)
3391 {
3392#ifndef USEQPE 3393#ifndef USEQPE
3393 unlink((const char *)fi.absFilePath()); 3394 unlink((const char *)fi.absFilePath());
3394#else /* USEQPE */ 3395#else /* USEQPE */
3395 unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); 3396 unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string));
3396#endif /* USEQPE */ 3397#endif /* USEQPE */
3397 } 3398 }
3398 } 3399 }
3399 3400
3400#ifndef USEQPE 3401#ifndef USEQPE
3401 BkmkFile bf((const char *)fi.absFilePath()); 3402 BkmkFile bf((const char *)fi.absFilePath());
3402#else /* USEQPE */ 3403#else /* USEQPE */
3403 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string)); 3404 BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string));
3404#endif /* USEQPE */ 3405#endif /* USEQPE */
3405 3406
3406 pBkmklist = bf.readall(); 3407 pBkmklist = bf.readall();
3407 m_fBkmksChanged = bf.upgraded(); 3408 m_fBkmksChanged = bf.upgraded();
3408 if (pBkmklist == NULL) 3409 if (pBkmklist == NULL)
3409 { 3410 {
3410 pBkmklist = reader->getbkmklist(); 3411 pBkmklist = reader->getbkmklist();
3411 } 3412 }
3412 if (pBkmklist != NULL) 3413 if (pBkmklist != NULL)
3413 pBkmklist->sort(); 3414 pBkmklist->sort();
3414} 3415}
3415 3416
3416void QTReaderApp::addbkmk() 3417void QTReaderApp::addbkmk()
3417{ 3418{
3418 m_nRegAction = cAddBkmk; 3419 m_nRegAction = cAddBkmk;
3419 regEdit->setText(reader->firstword()); 3420 regEdit->setText(reader->firstword());
3420 do_regedit(); 3421 do_regedit();
3421} 3422}
3422 3423
3423void QTReaderApp::do_addbkmk(const QString& text) 3424void QTReaderApp::do_addbkmk(const QString& text)
3424{ 3425{
3425 if (text.isEmpty()) 3426 if (text.isEmpty())
3426 { 3427 {
3427 QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); 3428 QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1);
3428 } 3429 }
3429 else 3430 else
3430 { 3431 {
3431 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; 3432 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>;
3432#ifdef _UNICODE 3433#ifdef _UNICODE
3433 CBuffer buff; 3434 CBuffer buff;
3434 int i = 0; 3435 int i = 0;
3435 for (i = 0; i < text.length(); i++) 3436 for (i = 0; i < text.length(); i++)
3436 { 3437 {
3437 buff[i] = text[i].unicode(); 3438 buff[i] = text[i].unicode();
3438 } 3439 }
3439 buff[i] = 0; 3440 buff[i] = 0;
3440 pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); 3441 pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate()));
3441#else 3442#else
3442 pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); 3443 pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate()));
3443#endif 3444#endif
3444 m_fBkmksChanged = true; 3445 m_fBkmksChanged = true;
3445 pBkmklist->sort(); 3446 pBkmklist->sort();
3446 } 3447 }
3447} 3448}
3448 3449
3449void QTReaderApp::OnRedraw() 3450void QTReaderApp::OnRedraw()
3450{ 3451{
3451 if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) 3452 if ((pBkmklist != NULL) && (m_bkmkAvail != NULL))
3452 { 3453 {
3453 bool found = findNextBookmark(reader->pagelocate()); 3454 bool found = findNextBookmark(reader->pagelocate());
3454 m_bkmkAvail->setEnabled(found); 3455 m_bkmkAvail->setEnabled(found);
3455 } 3456 }
3456} 3457}
3457 3458
3458void QTReaderApp::showAnnotation() 3459void QTReaderApp::showAnnotation()
3459{ 3460{
3460 m_annoWin->setName(toQString(m_anno->name())); 3461 m_annoWin->setName(toQString(m_anno->name()));
3461 m_annoWin->setAnno(toQString(m_anno->anno())); 3462 m_annoWin->setAnno(toQString(m_anno->anno()));
3462 m_annoIsEditing = false; 3463 m_annoIsEditing = false;
3463#ifdef USEQPE 3464#ifdef USEQPE
3464 Global::showInputMethod(); 3465 Global::showInputMethod();
3465#endif 3466#endif
3466 editorStack->raiseWidget( m_annoWin ); 3467 editorStack->raiseWidget( m_annoWin );
3467 m_annoWin->setFocus(); 3468 m_annoWin->setFocus();
3468} 3469}
3469 3470
3470void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) 3471void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line)
3471{ 3472{
3472//// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); 3473//// odebug << "OnWordSelected(" << posn << "):" << wrd << "" << oendl;
3473 3474
3474 if (m_doClipboard) 3475 if (m_doClipboard)
3475 { 3476 {
3476 QClipboard* cb = QApplication::clipboard(); 3477 QClipboard* cb = QApplication::clipboard();
3477 cb->setText(wrd); 3478 cb->setText(wrd);
3478#ifdef USEQPE 3479#ifdef USEQPE
3479 if (wrd.length() > 10) 3480 if (wrd.length() > 10)
3480 { 3481 {
3481 Global::statusMessage(wrd.left(8) + ".."); 3482 Global::statusMessage(wrd.left(8) + "..");
3482 } 3483 }
3483 else 3484 else
3484 { 3485 {
3485 Global::statusMessage(wrd); 3486 Global::statusMessage(wrd);
3486 } 3487 }
3487#endif 3488#endif
3488 } 3489 }
3489 if (m_doAnnotation) 3490 if (m_doAnnotation)
3490 { 3491 {
3491 //addAnno(wrd, "Need to be able to edit this", posn); 3492// addAnno(wrd, "Need to be able to edit this", posn);
3492 m_annoWin->setName(line); 3493 m_annoWin->setName(line);
3493 m_annoWin->setAnno(""); 3494 m_annoWin->setAnno("");
3494 m_annoWin->setPosn(posn); 3495 m_annoWin->setPosn(posn);
3495 m_annoIsEditing = true; 3496 m_annoIsEditing = true;
3496#ifdef USEQPE 3497#ifdef USEQPE
3497 Global::showInputMethod(); 3498 Global::showInputMethod();
3498#endif 3499#endif
3499 editorStack->raiseWidget( m_annoWin ); 3500 editorStack->raiseWidget( m_annoWin );
3500 } 3501 }
3501#ifdef USEQPE 3502#ifdef USEQPE
3502 if (m_doDictionary) 3503 if (m_doDictionary)
3503 { 3504 {
3504 if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) 3505 if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty())
3505 { 3506 {
3506 QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); 3507 QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8());
3507 e << wrd; 3508 e << wrd;
3508 } 3509 }
3509 } 3510 }
3510#endif 3511#endif
3511} 3512}
3512 3513
3513void QTReaderApp::doAction(ActionTypes a, QKeyEvent* e) 3514void QTReaderApp::doAction(ActionTypes a, QKeyEvent* e)
3514{ 3515{
3515 if (a == 0) 3516 if (a == 0)
3516 { 3517 {
3517 e->ignore(); 3518 e->ignore();
3518 } 3519 }
3519 else 3520 else
3520 { 3521 {
3521 e->accept(); 3522 e->accept();
3522 //qDebug("Accepted"); 3523// odebug << "Accepted" << oendl;
3523 switch (a) 3524 switch (a)
3524 { 3525 {
3525 case cesOpenFile: 3526 case cesOpenFile:
3526 { 3527 {
3527 fileOpen(); 3528 fileOpen();
3528 } 3529 }
3529 break; 3530 break;
3530 case cesAutoScroll: 3531 case cesAutoScroll:
3531 { 3532 {
3532 reader->setautoscroll(!reader->m_autoScroll); 3533 reader->setautoscroll(!reader->m_autoScroll);
3533 setScrollState(reader->m_autoScroll); 3534 setScrollState(reader->m_autoScroll);
3534 } 3535 }
3535 break; 3536 break;
3536 case cesActionMark: 3537 case cesActionMark:
3537 { 3538 {
3538 addbkmk(); 3539 addbkmk();
3539 } 3540 }
3540 break; 3541 break;
3541 case cesFullScreen: 3542 case cesFullScreen:
3542 { 3543 {
3543 m_actFullscreen->setOn(!m_fullscreen); 3544 m_actFullscreen->setOn(!m_fullscreen);
3544 } 3545 }
3545 break; 3546 break;
3546 case cesActionAnno: 3547 case cesActionAnno:
3547 { 3548 {
3548 addanno(); 3549 addanno();
3549 } 3550 }
3550 break; 3551 break;
3551 case cesZoomIn: 3552 case cesZoomIn:
3552 zoomin(); 3553 zoomin();
3553 break; 3554 break;
3554 case cesZoomOut: 3555 case cesZoomOut:
3555 zoomout(); 3556 zoomout();
3556 break; 3557 break;
3557 case cesBack: 3558 case cesBack:
3558 reader->goBack(); 3559 reader->goBack();
3559 break; 3560 break;
3560 case cesForward: 3561 case cesForward:
3561 reader->goForward(); 3562 reader->goForward();
3562 break; 3563 break;
3563 case cesHome: 3564 case cesHome:
3564 reader->goHome(); 3565 reader->goHome();
3565 break; 3566 break;
3566 case cesPageUp: 3567 case cesPageUp:
3567 reader->dopageup(); 3568 reader->dopageup();
3568 break; 3569 break;
3569 case cesPageDown: 3570 case cesPageDown:
3570 reader->dopagedn(); 3571 reader->dopagedn();
3571 break; 3572 break;
3572 case cesLineUp: 3573 case cesLineUp:
3573 reader->lineUp(); 3574 reader->lineUp();
3574 break; 3575 break;
3575 case cesLineDown: 3576 case cesLineDown:
3576 reader->lineDown(); 3577 reader->lineDown();
3577 break; 3578 break;
3578 case cesStartDoc: 3579 case cesStartDoc:
3579 gotoStart(); 3580 gotoStart();
3580 break; 3581 break;
3581 case cesEndDoc: 3582 case cesEndDoc:
3582 gotoEnd(); 3583 gotoEnd();
3583 break; 3584 break;
3584 default: 3585 default:
3585 qDebug("Unknown ActionType:%u", a); 3586 odebug << "Unknown ActionType:" << a << "" << oendl;
3586 break; 3587 break;
3587 } 3588 }
3588 } 3589 }
3589} 3590}
3590 3591
3591void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } 3592void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); }
3592void QTReaderApp::restoreFocus() { reader->setFocus(); } 3593void QTReaderApp::restoreFocus() { reader->setFocus(); }
3593 3594
3594void QTReaderApp::SaveConfig() 3595void QTReaderApp::SaveConfig()
3595{ 3596{
3596 m_nRegAction = cSetConfigName; 3597 m_nRegAction = cSetConfigName;
3597 regEdit->setText(reader->m_string); 3598 regEdit->setText(reader->m_string);
3598 do_regedit(); 3599 do_regedit();
3599} 3600}
3600 3601
3601void QTReaderApp::do_saveconfig(const QString& _txt, bool full) 3602void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
3602{ 3603{
3603// qDebug("do_saveconfig:%s", (const char*)_txt); 3604// odebug << "do_saveconfig:" << _txt << "" << oendl;
3604#ifdef USEQPE 3605#ifdef USEQPE
3605 QString configname; 3606 QString configname;
3606 Config::Domain dom; 3607 Config::Domain dom;
3607 3608
3608 if (full) 3609 if (full)
3609 { 3610 {
3610 configname = _txt; 3611 configname = _txt;
3611 dom = Config::User; 3612 dom = Config::User;
3612 } 3613 }
3613 else 3614 else
3614 { 3615 {
3615 configname = Global::applicationFileName(APPDIR "/configs", _txt); 3616 configname = Global::applicationFileName(APPDIR "/configs", _txt);
3616 dom = Config::File; 3617 dom = Config::File;
3617 } 3618 }
3618 3619
3619 Config config(configname, dom); 3620 Config config(configname, dom);
3620 config.setGroup( "View" ); 3621 config.setGroup( "View" );
3621 3622
3622#else 3623#else
3623 QFileInfo fi; 3624 QFileInfo fi;
3624 if (full) 3625 if (full)
3625 { 3626 {
3626 // qDebug("full:%s", (const char*)_txt); 3627// odebug << "full:" << _txt << "" << oendl;
3627 QDir d = QDir::home(); // "/" 3628 QDir d = QDir::home(); // "/"
3628 if ( !d.cd(_txt) ) 3629 if ( !d.cd(_txt) )
3629 { // "/tmp" 3630 { // "/tmp"
3630 qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); 3631 owarn << "Cannot find the \"~/" << _txt << "\" directory" << oendl;
3631 d = QDir::home(); 3632 d = QDir::home();
3632 d.mkdir(_txt); 3633 d.mkdir(_txt);
3633 d.cd(_txt); 3634 d.cd(_txt);
3634 } 3635 }
3635 fi.setFile(d, INIFILE); 3636 fi.setFile(d, INIFILE);
3636 } 3637 }
3637 else 3638 else
3638 { 3639 {
3639 QDir d = QDir::home(); // "/" 3640 QDir d = QDir::home(); // "/"
3640 if ( !d.cd(APPDIR) ) 3641 if ( !d.cd(APPDIR) )
3641 { // "/tmp" 3642 { // "/tmp"
3642 qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); 3643 owarn << "Cannot find the \"~/" APPDIR "\" directory" << oendl;
3643 d = QDir::home(); 3644 d = QDir::home();
3644 d.mkdir(APPDIR); 3645 d.mkdir(APPDIR);
3645 d.cd(APPDIR); 3646 d.cd(APPDIR);
3646 } 3647 }
3647 if ( !d.cd("configs") ) 3648 if ( !d.cd("configs") )
3648 { // "/tmp" 3649 { // "/tmp"
3649 qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); 3650 owarn << "Cannot find the \"~/" APPDIR "/configs\" directory" << oendl;
3650 d = QDir::home(); 3651 d = QDir::home();
3651 d.cd(APPDIR); 3652 d.cd(APPDIR);
3652 d.mkdir("configs"); 3653 d.mkdir("configs");
3653 d.cd("configs"); 3654 d.cd("configs");
3654 } 3655 }
3655 fi.setFile(d, _txt); 3656 fi.setFile(d, _txt);
3656 } 3657 }
3657 //qDebug("Path:%s", (const char*)fi.absFilePath()); 3658// odebug << "Path:" << fi.absFilePath() << "" << oendl;
3658 Config config(fi.absFilePath()); 3659 Config config(fi.absFilePath());
3659#endif 3660#endif
3660 3661
3661 3662
3662 config.writeEntry( "StripCr", reader->bstripcr ); 3663 config.writeEntry( "StripCr", reader->bstripcr );
3663 config.writeEntry( "AutoFmt", reader->bautofmt ); 3664 config.writeEntry( "AutoFmt", reader->bautofmt );
3664 config.writeEntry( "TextFmt", reader->btextfmt ); 3665 config.writeEntry( "TextFmt", reader->btextfmt );
3665 config.writeEntry( "StripHtml", reader->bstriphtml ); 3666 config.writeEntry( "StripHtml", reader->bstriphtml );
3666 config.writeEntry( "Dehyphen", reader->bdehyphen ); 3667 config.writeEntry( "Dehyphen", reader->bdehyphen );
3667 config.writeEntry( "Depluck", reader->bdepluck ); 3668 config.writeEntry( "Depluck", reader->bdepluck );
3668 config.writeEntry( "Dejpluck", reader->bdejpluck ); 3669 config.writeEntry( "Dejpluck", reader->bdejpluck );
3669 config.writeEntry( "OneSpace", reader->bonespace ); 3670 config.writeEntry( "OneSpace", reader->bonespace );
3670 config.writeEntry( "Unindent", reader->bunindent ); 3671 config.writeEntry( "Unindent", reader->bunindent );
3671 config.writeEntry( "Repara", reader->brepara ); 3672 config.writeEntry( "Repara", reader->brepara );
3672 config.writeEntry( "DoubleSpace", reader->bdblspce ); 3673 config.writeEntry( "DoubleSpace", reader->bdblspce );
3673 config.writeEntry( "Indent", reader->bindenter ); 3674 config.writeEntry( "Indent", reader->bindenter );
3674 config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); 3675 config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) );
3675 config.writeEntry( "ScrollDelay", reader->m_delay); 3676 config.writeEntry( "ScrollDelay", reader->m_delay);
3676 if (full) 3677 if (full)
3677 { 3678 {
3678 config.writeEntry("Debounce", m_debounce); 3679 config.writeEntry("Debounce", m_debounce);
3679 config.writeEntry("FloatDialogs", m_bFloatingDialog); 3680 config.writeEntry("FloatDialogs", m_bFloatingDialog);
3680 reader->m_lastposn = reader->pagelocate(); 3681 reader->m_lastposn = reader->pagelocate();
3681 config.writeEntry( "LastFile", reader->m_lastfile ); 3682 config.writeEntry( "LastFile", reader->m_lastfile );
3682 config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); 3683 config.writeEntry( "LastPosn", (int)(reader->pagelocate()) );
3683 } 3684 }
3684 config.writeEntry( "PageMode", reader->m_bpagemode ); 3685 config.writeEntry( "PageMode", reader->m_bpagemode );
3685 config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); 3686 config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced );
3686 config.writeEntry( "SwapMouse", reader->m_swapmouse); 3687 config.writeEntry( "SwapMouse", reader->m_swapmouse);
3687 config.writeEntry( "Fontname", reader->m_fontname ); 3688 config.writeEntry( "Fontname", reader->m_fontname );
3688 config.writeEntry( "Encoding", reader->m_encd ); 3689 config.writeEntry( "Encoding", reader->m_encd );
3689 config.writeEntry( "CharSpacing", reader->m_charpc ); 3690 config.writeEntry( "CharSpacing", reader->m_charpc );
3690 config.writeEntry( "Overlap", (int)(reader->m_overlap) ); 3691 config.writeEntry( "Overlap", (int)(reader->m_overlap) );
3691 config.writeEntry( "Margin", (int)reader->m_border ); 3692 config.writeEntry( "Margin", (int)reader->m_border );
3692 config.writeEntry( "TargetApp", m_targetapp ); 3693 config.writeEntry( "TargetApp", m_targetapp );
3693 config.writeEntry( "TargetMsg", m_targetmsg ); 3694 config.writeEntry( "TargetMsg", m_targetmsg );
3694#ifdef _SCROLLPIPE 3695#ifdef _SCROLLPIPE
3695 config.writeEntry( "PipeTarget", reader->m_pipetarget ); 3696 config.writeEntry( "PipeTarget", reader->m_pipetarget );
3696 config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); 3697 config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara );
3697#endif 3698#endif
3698 config.writeEntry( "TwoTouch", m_twoTouch ); 3699 config.writeEntry( "TwoTouch", m_twoTouch );
@@ -3711,58 +3712,58 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
3711 config.writeEntry("UpScroll", m_upScroll); 3712 config.writeEntry("UpScroll", m_upScroll);
3712 config.writeEntry("DownScroll", m_downScroll); 3713 config.writeEntry("DownScroll", m_downScroll);
3713#ifdef REPALM 3714#ifdef REPALM
3714 config.writeEntry( "Repalm", reader->brepalm ); 3715 config.writeEntry( "Repalm", reader->brepalm );
3715#endif 3716#endif
3716 config.writeEntry( "Remap", reader->bremap ); 3717 config.writeEntry( "Remap", reader->bremap );
3717 config.writeEntry( "Peanut", reader->bpeanut ); 3718 config.writeEntry( "Peanut", reader->bpeanut );
3718 config.writeEntry( "MakeBold", reader->bmakebold ); 3719 config.writeEntry( "MakeBold", reader->bmakebold );
3719 config.writeEntry( "Continuous", reader->m_continuousDocument ); 3720 config.writeEntry( "Continuous", reader->m_continuousDocument );
3720 config.writeEntry( "FullJust", reader->bfulljust ); 3721 config.writeEntry( "FullJust", reader->bfulljust );
3721 config.writeEntry( "ExtraSpace", reader->getextraspace() ); 3722 config.writeEntry( "ExtraSpace", reader->getextraspace() );
3722 config.writeEntry( "ExtraLead", reader->getlead() ); 3723 config.writeEntry( "ExtraLead", reader->getlead() );
3723 config.writeEntry( "Basesize", (int)reader->getBaseSize()); 3724 config.writeEntry( "Basesize", (int)reader->getBaseSize());
3724 config.writeEntry( "RequestorFontChange", m_propogatefontchange); 3725 config.writeEntry( "RequestorFontChange", m_propogatefontchange);
3725 if (full) 3726 if (full)
3726 { 3727 {
3727 config.setGroup( "Toolbar" ); 3728 config.setGroup( "Toolbar" );
3728 config.writeEntry("Movable", m_tbmovesave); 3729 config.writeEntry("Movable", m_tbmovesave);
3729 config.writeEntry("Policy", m_tbpolsave); 3730 config.writeEntry("Policy", m_tbpolsave);
3730 config.writeEntry("Position", m_tbposition); 3731 config.writeEntry("Position", m_tbposition);
3731#ifndef USEQPE 3732#ifndef USEQPE
3732 config.setGroup( "Geometry" ); 3733 config.setGroup( "Geometry" );
3733 config.writeEntry( "x", x() ); 3734 config.writeEntry( "x", x() );
3734 config.writeEntry( "y", y() ); 3735 config.writeEntry( "y", y() );
3735 config.writeEntry( "width", width() ); 3736 config.writeEntry( "width", width() );
3736 config.writeEntry( "height", height() ); 3737 config.writeEntry( "height", height() );
3737#endif 3738#endif
3738 } 3739 }
3739} 3740}
3740 3741
3741/* 3742/*
3742void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen) 3743void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen)
3743{ 3744{
3744 unsigned short sdlen; 3745 unsigned short sdlen;
3745 memcpy(&sdlen, _sd, sizeof(sdlen)); 3746 memcpy(&sdlen, _sd, sizeof(sdlen));
3746 sdlen -= sizeof(sdlen); 3747 sdlen -= sizeof(sdlen);
3747 _sd += sizeof(sdlen); 3748 _sd += sizeof(sdlen);
3748 statedata* sd; 3749 statedata* sd;
3749 char* data; 3750 char* data;
3750 if (sdlen < sizeof(statedata)+1) 3751 if (sdlen < sizeof(statedata)+1)
3751 { 3752 {
3752 sdlen = sizeof(statedata)+1; 3753 sdlen = sizeof(statedata)+1;
3753 } 3754 }
3754 data = new char[sdlen]; 3755 data = new char[sdlen];
3755 sd = (statedata*)data; 3756 sd = (statedata*)data;
3756 memcpy(sd, _sd, sdlen); 3757 memcpy(sd, _sd, sdlen);
3757 data[sdlen] = 0; 3758 data[sdlen] = 0;
3758 reader->setstate(*sd); 3759 reader->setstate(*sd);
3759 delete [] data; 3760 delete [] data;
3760} 3761}
3761 3762
3762void QTReaderApp::getstate(unsigned char*& data, unsigned short& len) 3763void QTReaderApp::getstate(unsigned char*& data, unsigned short& len)
3763{ 3764{
3764 unsigned char* olddata = data; 3765 unsigned char* olddata = data;
3765 unsigned short oldlen = len; 3766 unsigned short oldlen = len;
3766 len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length(); 3767 len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length();
3767 data = new unsigned char[len]; 3768 data = new unsigned char[len];
3768 memcpy(data, olddata, oldlen); 3769 memcpy(data, olddata, oldlen);
@@ -3788,95 +3789,95 @@ void QTReaderApp::getstate(unsigned char*& data, unsigned short& len)
3788 sd->bmakebold = reader->bmakebold; 3789 sd->bmakebold = reader->bmakebold;
3789 sd->Continuous = reader->m_continuousDocument; 3790 sd->Continuous = reader->m_continuousDocument;
3790#ifdef REPALM 3791#ifdef REPALM
3791 sd->brepalm = reader->brepalm; 3792 sd->brepalm = reader->brepalm;
3792#endif 3793#endif
3793 sd->bindenter = reader->bindenter; 3794 sd->bindenter = reader->bindenter;
3794 sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize() 3795 sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize()
3795 sd->m_encd = reader->m_encd; 3796 sd->m_encd = reader->m_encd;
3796 sd->m_charpc = reader->m_charpc; 3797 sd->m_charpc = reader->m_charpc;
3797 strcpy(sd->m_fontname, reader->m_fontname.latin1()); 3798 strcpy(sd->m_fontname, reader->m_fontname.latin1());
3798} 3799}
3799*/ 3800*/
3800#ifdef _SCRIPT 3801#ifdef _SCRIPT
3801void QTReaderApp::RunScript() 3802void QTReaderApp::RunScript()
3802{ 3803{
3803 fileBrowser* fb = new fileBrowser(this,"OpieReader",!m_bFloatingDialog, 3804 fileBrowser* fb = new fileBrowser(this,"OpieReader",!m_bFloatingDialog,
3804 0, 3805 0,
3805 // WStyle_Customize | WStyle_NoBorderEx, 3806// WStyle_Customize | WStyle_NoBorderEx,
3806 "*", Global::applicationFileName(APPDIR "/scripts", "")); 3807 "*", Global::applicationFileName(APPDIR "/scripts", ""));
3807 3808
3808 QString fn; 3809 QString fn;
3809 if (fb->exec()) 3810 if (fb->exec())
3810 { 3811 {
3811 fn = fb->fileList[0]; 3812 fn = fb->fileList[0];
3812 } 3813 }
3813 delete fb; 3814 delete fb;
3814 if ( !fn.isEmpty() && fork() == 0 ) 3815 if ( !fn.isEmpty() && fork() == 0 )
3815 { 3816 {
3816 execlp((const char *)fn,(const char *)fn,NULL); 3817 execlp((const char *)fn,(const char *)fn,NULL);
3817 } 3818 }
3818} 3819}
3819 3820
3820void QTReaderApp::SaveScript(const char* sname) 3821void QTReaderApp::SaveScript(const char* sname)
3821{ 3822{
3822 FILE* f = fopen(sname,"w"); 3823 FILE* f = fopen(sname,"w");
3823 if (f != NULL) 3824 if (f != NULL)
3824 { 3825 {
3825#ifdef OPIE 3826#ifdef OPIE
3826 fprintf(f, "#!/bin/sh\nmsg() {\n\tqcop QPE/Application/reader \"$1\" \"$2\" \"$3\"\n}\n"); 3827 fprintf(f, "#!/bin/sh\nmsg() {\n\tqcop QPE/Application/reader \"$1\" \"$2\" \"$3\"\n}\n");
3827#else 3828#else
3828 fprintf(f, "#!/bin/bash\nmsg() {\n\tqcop QPE/Application/uqtreader \"$1\" \"$2\" \"$3\"\n}\n"); 3829 fprintf(f, "#!/bin/bash\nmsg() {\n\tqcop QPE/Application/uqtreader \"$1\" \"$2\" \"$3\"\n}\n");
3829#endif 3830#endif
3830 fprintf(f, "msg \"Update(int)\" 0\n"); 3831 fprintf(f, "msg \"Update(int)\" 0\n");
3831 fprintf(f, "msg \"Layout/StripCR(int)\" %d\n", (reader->bstripcr) ? 1:0); 3832 fprintf(f, "msg \"Layout/StripCR(int)\" %d\n", (reader->bstripcr) ? 1:0);
3832 if (reader->btextfmt) fprintf(f, "msg \"Markup(QString)\" \"Text\"\n"); 3833 if (reader->btextfmt) fprintf(f, "msg \"Markup(QString)\" \"Text\"\n");
3833 else if (reader->bautofmt) fprintf(f, "msg \"Markup(QString)\" \"Auto\"\n"); 3834 else if (reader->bautofmt) fprintf(f, "msg \"Markup(QString)\" \"Auto\"\n");
3834 else if (reader->bstriphtml) fprintf(f, "msg \"Markup(QString)\" \"HTML\"\n"); 3835 else if (reader->bstriphtml) fprintf(f, "msg \"Markup(QString)\" \"HTML\"\n");
3835 else if (reader->bpeanut) fprintf(f, "msg \"Markup(QString)\" \"Peanut/PML\"\n"); 3836 else if (reader->bpeanut) fprintf(f, "msg \"Markup(QString)\" \"Peanut/PML\"\n");
3836 else fprintf(f, "msg \"Markup(QString)\" \"None\"\n"); 3837 else fprintf(f, "msg \"Markup(QString)\" \"None\"\n");
3837 fprintf(f, "msg \"Layout/Dehyphen(int)\" %d\n", (reader->bdehyphen) ? 1:0); 3838 fprintf(f, "msg \"Layout/Dehyphen(int)\" %d\n", (reader->bdehyphen) ? 1:0);
3838 fprintf(f, "msg \"Layout/Depluck(int)\" %d\n", (reader->bdepluck) ? 1:0); 3839 fprintf(f, "msg \"Layout/Depluck(int)\" %d\n", (reader->bdepluck) ? 1:0);
3839 fprintf(f, "msg \"Layout/Dejpluck(int)\" %d\n", (reader->bdejpluck) ? 1:0); 3840 fprintf(f, "msg \"Layout/Dejpluck(int)\" %d\n", (reader->bdejpluck) ? 1:0);
3840 fprintf(f, "msg \"Layout/SingleSpace(int)\" %d\n", (reader->bonespace) ? 1:0); 3841 fprintf(f, "msg \"Layout/SingleSpace(int)\" %d\n", (reader->bonespace) ? 1:0);
3841 fprintf(f, "msg \"Layout/Unindent(int)\" %d\n", (reader->bunindent) ? 1:0); 3842 fprintf(f, "msg \"Layout/Unindent(int)\" %d\n", (reader->bunindent) ? 1:0);
3842 fprintf(f, "msg \"Layout/Re-paragraph(int)\" %d\n", (reader->brepara) ? 1:0); 3843 fprintf(f, "msg \"Layout/Re-paragraph(int)\" %d\n", (reader->brepara) ? 1:0);
3843 fprintf(f, "msg \"Layout/DoubleSpace(int)\" %d\n", (reader->bdblspce) ? 1:0); 3844 fprintf(f, "msg \"Layout/DoubleSpace(int)\" %d\n", (reader->bdblspce) ? 1:0);
3844 fprintf(f, "msg \"Layout/Indent(int)\" %d\n", reader->bindenter); 3845 fprintf(f, "msg \"Layout/Indent(int)\" %d\n", reader->bindenter);
3845 fprintf(f, "msg \"Format/SetFont(QString,int)\" \"%s\" %d\n", (const char*)reader->m_fontname, reader->m_textsize); 3846 fprintf(f, "msg \"Format/SetFont(QString,int)\" \"%s\" %d\n", (const char*)reader->m_fontname, reader->m_textsize);
3846 fprintf(f, "msg \"Navigation/Page/LineScroll(int)\" %d\n", (reader->m_bpagemode) ? 1:0); 3847 fprintf(f, "msg \"Navigation/Page/LineScroll(int)\" %d\n", (reader->m_bpagemode) ? 1:0);
3847 fprintf(f, "msg \"Format/Ideogram/Word(int)\" %d\n", (reader->m_bMonoSpaced) ? 1:0); 3848 fprintf(f, "msg \"Format/Ideogram/Word(int)\" %d\n", (reader->m_bMonoSpaced) ? 1:0);
3848 fprintf(f, "msg \"Format/Encoding(QString)\" \"%s\"\n", (const char*)m_EncodingAction[reader->m_encd]->text()); 3849 fprintf(f, "msg \"Format/Encoding(QString)\" \"%s\"\n", (const char*)m_EncodingAction[reader->m_encd]->text());
3849 fprintf(f, "msg \"Format/SetWidth(int)\" %d\n", reader->m_charpc); 3850 fprintf(f, "msg \"Format/SetWidth(int)\" %d\n", reader->m_charpc);
3850 fprintf(f, "msg \"Navigation/SetOverlap(int)\" %d\n", reader->m_overlap); 3851 fprintf(f, "msg \"Navigation/SetOverlap(int)\" %d\n", reader->m_overlap);
3851 fprintf(f, "msg \"Layout/Remap(int)\" %d\n", (reader->bremap) ? 1:0); 3852 fprintf(f, "msg \"Layout/Remap(int)\" %d\n", (reader->bremap) ? 1:0);
3852 fprintf(f, "msg \"Layout/Embolden(int)\" %d\n", (reader->bmakebold) ? 1:0); 3853 fprintf(f, "msg \"Layout/Embolden(int)\" %d\n", (reader->bmakebold) ? 1:0);
3853 fprintf(f, "msg \"File/Continuous(int)\" %d\n", (reader->m_continuousDocument) ? 1:0); 3854 fprintf(f, "msg \"File/Continuous(int)\" %d\n", (reader->m_continuousDocument) ? 1:0);
3854 fprintf(f, "msg \"File/SetDictionary(QString)\" \"%s/%s\"\n", (const char *)m_targetapp, (const char *)m_targetmsg); 3855 fprintf(f, "msg \"File/SetDictionary(QString)\" \"%s/%s\"\n", (const char *)m_targetapp, (const char *)m_targetmsg);
3855#ifdef _SCROLLPIPE 3856#ifdef _SCROLLPIPE
3856 fprintf(f, "msg \"File/SetScrollTarget(QString)\" \"%s\"\n", (const char *)reader->m_pipetarget); 3857 fprintf(f, "msg \"File/SetScrollTarget(QString)\" \"%s\"\n", (const char *)reader->m_pipetarget);
3857#endif 3858#endif
3858 fprintf(f, "msg \"File/Two/OneTouch(int)\" %d\n", (m_twoTouch) ? 1:0); 3859 fprintf(f, "msg \"File/Two/OneTouch(int)\" %d\n", (m_twoTouch) ? 1:0);
3859 fprintf(f, "msg \"Target/Annotation(int)\" %d\n", (m_doAnnotation) ? 1:0); 3860 fprintf(f, "msg \"Target/Annotation(int)\" %d\n", (m_doAnnotation) ? 1:0);
3860 fprintf(f, "msg \"Target/Dictionary(int)\" %d\n", (m_doDictionary) ? 1:0); 3861 fprintf(f, "msg \"Target/Dictionary(int)\" %d\n", (m_doDictionary) ? 1:0);
3861 fprintf(f, "msg \"Target/Clipboard(int)\" %d\n", (m_doClipboard) ? 1:0); 3862 fprintf(f, "msg \"Target/Clipboard(int)\" %d\n", (m_doClipboard) ? 1:0);
3862 fprintf(f, "msg \"File/Action(QString)\" \"%s\"\n", (const char *)m_buttonAction[m_spaceTarget]->text()); 3863 fprintf(f, "msg \"File/Action(QString)\" \"%s\"\n", (const char *)m_buttonAction[m_spaceTarget]->text());
3863 fprintf(f, "msg \"Update(int)\" 1\n"); 3864 fprintf(f, "msg \"Update(int)\" 1\n");
3864 fprintf(f, "msg \"info(QString)\" \"All Done\"\n"); 3865 fprintf(f, "msg \"info(QString)\" \"All Done\"\n");
3865 fclose(f); 3866 fclose(f);
3866 chmod(sname, S_IXUSR | S_IXGRP | S_IXOTH); 3867 chmod(sname, S_IXUSR | S_IXGRP | S_IXOTH);
3867 } 3868 }
3868} 3869}
3869 3870
3870void QTReaderApp::SaveConfig() 3871void QTReaderApp::SaveConfig()
3871{ 3872{
3872 m_nRegAction = cSetConfigName; 3873 m_nRegAction = cSetConfigName;
3873 regEdit->setText(""); 3874 regEdit->setText("");
3874 do_regedit(); 3875 do_regedit();
3875} 3876}
3876 3877
3877void QTReaderApp::do_saveconfig(const QString& _txt) 3878void QTReaderApp::do_saveconfig(const QString& _txt)
3878{ 3879{
3879 SaveScript(Global::applicationFileName(APPDIR "/scripts", _txt)); 3880 SaveScript(Global::applicationFileName(APPDIR "/scripts", _txt));
3880} 3881}
3881#endif 3882#endif
3882 3883
@@ -3900,118 +3901,118 @@ void QTReaderApp::setpause(bool sfs)
3900} 3901}
3901#endif 3902#endif
3902 3903
3903void QTReaderApp::monospace(bool _b) 3904void QTReaderApp::monospace(bool _b)
3904{ 3905{
3905 reader->setmono(_b); 3906 reader->setmono(_b);
3906} 3907}
3907 3908
3908bool QTReaderApp::readconfig(const QString& _txt, bool full=false) 3909bool QTReaderApp::readconfig(const QString& _txt, bool full=false)
3909{ 3910{
3910#ifdef USEQPE 3911#ifdef USEQPE
3911 QString configname; 3912 QString configname;
3912 Config::Domain dom; 3913 Config::Domain dom;
3913 3914
3914 if (full) 3915 if (full)
3915 { 3916 {
3916 configname = _txt; 3917 configname = _txt;
3917 dom = Config::User; 3918 dom = Config::User;
3918 } 3919 }
3919 else 3920 else
3920 { 3921 {
3921 configname = Global::applicationFileName(APPDIR "/configs", _txt); 3922 configname = Global::applicationFileName(APPDIR "/configs", _txt);
3922 QFileInfo fm(configname); 3923 QFileInfo fm(configname);
3923 if ( !fm.exists() ) return false; 3924 if ( !fm.exists() ) return false;
3924 dom = Config::File; 3925 dom = Config::File;
3925 } 3926 }
3926 3927
3927 Config config(configname, dom); 3928 Config config(configname, dom);
3928 config.setGroup( "View" ); 3929 config.setGroup( "View" );
3929 3930
3930#else 3931#else
3931 QFileInfo fi; 3932 QFileInfo fi;
3932 if (full) 3933 if (full)
3933 { 3934 {
3934 QDir d = QDir::home(); // "/" 3935 QDir d = QDir::home(); // "/"
3935 if ( !d.cd(_txt) ) 3936 if ( !d.cd(_txt) )
3936 { // "/tmp" 3937 { // "/tmp"
3937 qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); 3938 owarn << "Cannot find the \"~/" << _txt << "\" directory" << oendl;
3938 d = QDir::home(); 3939 d = QDir::home();
3939 d.mkdir(_txt); 3940 d.mkdir(_txt);
3940 d.cd(_txt); 3941 d.cd(_txt);
3941 } 3942 }
3942 fi.setFile(d, INIFILE); 3943 fi.setFile(d, INIFILE);
3943 } 3944 }
3944 else 3945 else
3945 { 3946 {
3946 QDir d = QDir::home(); // "/" 3947 QDir d = QDir::home(); // "/"
3947 if ( !d.cd(APPDIR) ) 3948 if ( !d.cd(APPDIR) )
3948 { // "/tmp" 3949 { // "/tmp"
3949 qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); 3950 owarn << "Cannot find the \"~/" APPDIR "\" directory" << oendl;
3950 d = QDir::home(); 3951 d = QDir::home();
3951 d.mkdir(APPDIR); 3952 d.mkdir(APPDIR);
3952 d.cd(APPDIR); 3953 d.cd(APPDIR);
3953 } 3954 }
3954 if ( !d.cd("configs") ) 3955 if ( !d.cd("configs") )
3955 { // "/tmp" 3956 { // "/tmp"
3956 qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); 3957 owarn << "Cannot find the \"~/" APPDIR "/configs\" directory" << oendl;
3957 d = QDir::home(); 3958 d = QDir::home();
3958 d.mkdir("configs"); 3959 d.mkdir("configs");
3959 d.cd("configs"); 3960 d.cd("configs");
3960 } 3961 }
3961 fi.setFile(d, _txt); 3962 fi.setFile(d, _txt);
3962 } 3963 }
3963#ifdef _WINDOWS 3964#ifdef _WINDOWS
3964 struct stat fnstat; 3965 struct stat fnstat;
3965 if (stat((const char *)reader->m_lastfile, &fnstat) == 0) return false; // get round fileinfo bug on windows 3966 if (stat((const char *)reader->m_lastfile, &fnstat) == 0) return false; // get round fileinfo bug on windows
3966#else 3967#else
3967 if (!fi.exists()) return false; 3968 if (!fi.exists()) return false;
3968#endif 3969#endif
3969 Config config(fi.absFilePath()); 3970 Config config(fi.absFilePath());
3970#endif 3971#endif
3971 if (full) 3972 if (full)
3972 { 3973 {
3973 config.setGroup("Toolbar"); 3974 config.setGroup("Toolbar");
3974 m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); 3975 m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false);
3975 m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); 3976 m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1);
3976 m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); 3977 m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2);
3977 } 3978 }
3978 config.setGroup( "View" ); 3979 config.setGroup( "View" );
3979 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); 3980 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false);
3980 reader->bstripcr = config.readBoolEntry( "StripCr", true ); 3981 reader->bstripcr = config.readBoolEntry( "StripCr", true );
3981 reader->bfulljust = config.readBoolEntry( "FullJust", false ); 3982 reader->bfulljust = config.readBoolEntry( "FullJust", false );
3982 reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); 3983 reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 ));
3983 reader->setlead(config.readNumEntry( "ExtraLead", 0 )); 3984 reader->setlead(config.readNumEntry( "ExtraLead", 0 ));
3984 reader->btextfmt = config.readBoolEntry( "TextFmt", false ); 3985 reader->btextfmt = config.readBoolEntry( "TextFmt", false );
3985 reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); 3986 reader->bautofmt = config.readBoolEntry( "AutoFmt", true );
3986 reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); 3987 reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
3987 reader->bpeanut = config.readBoolEntry( "Peanut", false ); 3988 reader->bpeanut = config.readBoolEntry( "Peanut", false );
3988 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); 3989 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false );
3989 reader->bdepluck = config.readBoolEntry( "Depluck", false ); 3990 reader->bdepluck = config.readBoolEntry( "Depluck", false );
3990 reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); 3991 reader->bdejpluck = config.readBoolEntry( "Dejpluck", false );
3991 reader->bonespace = config.readBoolEntry( "OneSpace", false ); 3992 reader->bonespace = config.readBoolEntry( "OneSpace", false );
3992 reader->bunindent = config.readBoolEntry( "Unindent", false ); 3993 reader->bunindent = config.readBoolEntry( "Unindent", false );
3993 reader->brepara = config.readBoolEntry( "Repara", false ); 3994 reader->brepara = config.readBoolEntry( "Repara", false );
3994 reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); 3995 reader->bdblspce = config.readBoolEntry( "DoubleSpace", false );
3995 reader->bindenter = config.readNumEntry( "Indent", 0 ); 3996 reader->bindenter = config.readNumEntry( "Indent", 0 );
3996 reader->m_textsize = config.readNumEntry( "FontSize", 12 ); 3997 reader->m_textsize = config.readNumEntry( "FontSize", 12 );
3997 reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); 3998 reader->m_delay = config.readNumEntry( "ScrollDelay", 5184);
3998 if (full) 3999 if (full)
3999 { 4000 {
4000 reader->m_lastfile = config.readEntry( "LastFile", QString::null ); 4001 reader->m_lastfile = config.readEntry( "LastFile", QString::null );
4001 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); 4002 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 );
4002 } 4003 }
4003 reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); 4004 reader->m_bpagemode = config.readBoolEntry( "PageMode", true );
4004 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); 4005 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false);
4005 reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); 4006 reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false);
4006 reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); 4007 reader->m_fontname = config.readEntry( "Fontname", "helvetica" );
4007 reader->m_encd = config.readNumEntry( "Encoding", 0 ); 4008 reader->m_encd = config.readNumEntry( "Encoding", 0 );
4008 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); 4009 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 );
4009 reader->m_overlap = config.readNumEntry( "Overlap", 0 ); 4010 reader->m_overlap = config.readNumEntry( "Overlap", 0 );
4010 reader->m_border = config.readNumEntry( "Margin", 6 ); 4011 reader->m_border = config.readNumEntry( "Margin", 6 );
4011#ifdef REPALM 4012#ifdef REPALM
4012 reader->brepalm = config.readBoolEntry( "Repalm", true ); 4013 reader->brepalm = config.readBoolEntry( "Repalm", true );
4013#endif 4014#endif
4014 reader->bremap = config.readBoolEntry( "Remap", true ); 4015 reader->bremap = config.readBoolEntry( "Remap", true );
4015 reader->bmakebold = config.readBoolEntry( "MakeBold", false ); 4016 reader->bmakebold = config.readBoolEntry( "MakeBold", false );
4016 reader->setContinuous(config.readBoolEntry( "Continuous", true )); 4017 reader->setContinuous(config.readBoolEntry( "Continuous", true ));
4017 m_targetapp = config.readEntry( "TargetApp", QString::null ); 4018 m_targetapp = config.readEntry( "TargetApp", QString::null );
@@ -4032,190 +4033,190 @@ bool QTReaderApp::readconfig(const QString& _txt, bool full=false)
4032 m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); 4033 m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp);
4033 m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); 4034 m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown);
4034 4035
4035 m_leftScroll = config.readBoolEntry("LeftScroll", false); 4036 m_leftScroll = config.readBoolEntry("LeftScroll", false);
4036 m_rightScroll = config.readBoolEntry("RightScroll", false); 4037 m_rightScroll = config.readBoolEntry("RightScroll", false);
4037 m_upScroll = config.readBoolEntry("UpScroll", true); 4038 m_upScroll = config.readBoolEntry("UpScroll", true);
4038 m_downScroll = config.readBoolEntry("DownScroll", true); 4039 m_downScroll = config.readBoolEntry("DownScroll", true);
4039 m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); 4040 m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false);
4040 reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); 4041 reader->setBaseSize(config.readNumEntry( "Basesize", 10 ));
4041 reader->setTwoTouch(m_twoTouch); 4042 reader->setTwoTouch(m_twoTouch);
4042 4043
4043 m_touch_action->setOn(m_twoTouch); 4044 m_touch_action->setOn(m_twoTouch);
4044 m_setmono_action->setOn(reader->m_bMonoSpaced); 4045 m_setmono_action->setOn(reader->m_bMonoSpaced);
4045 setfontHelper(reader->m_fontname); 4046 setfontHelper(reader->m_fontname);
4046 if (full) 4047 if (full)
4047 { 4048 {
4048 addtoolbars(&config); 4049 addtoolbars(&config);
4049 } 4050 }
4050 reader->setfilter(reader->getfilter()); 4051 reader->setfilter(reader->getfilter());
4051 reader->refresh(); 4052 reader->refresh();
4052 return true; 4053 return true;
4053} 4054}
4054 4055
4055bool QTReaderApp::PopulateConfig(const char* tgtdir) 4056bool QTReaderApp::PopulateConfig(const char* tgtdir)
4056{ 4057{
4057 bkmkselector->clear(); 4058 bkmkselector->clear();
4058 bkmkselector->setText("Cancel"); 4059 bkmkselector->setText("Cancel");
4059#ifndef USEQPE 4060#ifndef USEQPE
4060 int cnt = 0; 4061 int cnt = 0;
4061 4062
4062 QDir d = QDir::home(); // "/" 4063 QDir d = QDir::home(); // "/"
4063 if ( !d.cd(APPDIR) ) { // "/tmp" 4064 if ( !d.cd(APPDIR) ) { // "/tmp"
4064 qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); 4065 owarn << "Cannot find the \"~/" APPDIR "\" directory" << oendl;
4065 d = QDir::home(); 4066 d = QDir::home();
4066 d.mkdir(APPDIR); 4067 d.mkdir(APPDIR);
4067 d.cd(APPDIR); 4068 d.cd(APPDIR);
4068 } 4069 }
4069 if ( !d.cd(tgtdir) ) { // "/tmp" 4070 if ( !d.cd(tgtdir) ) { // "/tmp"
4070 qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir ); 4071 owarn << "Cannot find the \"~/" APPDIR "/" << tgtdir << "\" directory" << oendl;
4071 d = QDir::home(); 4072 d = QDir::home();
4072 d.mkdir(tgtdir); 4073 d.mkdir(tgtdir);
4073 d.cd(tgtdir); 4074 d.cd(tgtdir);
4074 } 4075 }
4075 d.setFilter( QDir::Files | QDir::NoSymLinks ); 4076 d.setFilter( QDir::Files | QDir::NoSymLinks );
4076// d.setSorting( QDir::Size | QDir::Reversed ); 4077// d.setSorting( QDir::Size | QDir::Reversed );
4077 4078
4078 const QFileInfoList *list = d.entryInfoList(); 4079 const QFileInfoList *list = d.entryInfoList();
4079 QFileInfoListIterator it( *list ); // create list iterator 4080 QFileInfoListIterator it( *list ); // create list iterator
4080 QFileInfo *fi; // pointer for traversing 4081 QFileInfo *fi; // pointer for traversing
4081 4082
4082 while ( (fi=it.current()) ) { // for each file... 4083 while ( (fi=it.current()) ) { // for each file...
4083 4084
4084 bkmkselector->insertItem(fi->fileName()); 4085 bkmkselector->insertItem(fi->fileName());
4085 cnt++; 4086 cnt++;
4086 4087
4087 //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); 4088 //odebug << "" << fi->size() << " " << fi->fileName().data() << "" << oendl;
4088 ++it; // goto next list element 4089 ++it; // goto next list element
4089 } 4090 }
4090 4091
4091#else /* USEQPE */ 4092#else /* USEQPE */
4092 int cnt = 0; 4093 int cnt = 0;
4093 DIR *d; 4094 DIR *d;
4094 char* finaldir; 4095 char* finaldir;
4095 finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; 4096 finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1];
4096 strcpy(finaldir, APPDIR); 4097 strcpy(finaldir, APPDIR);
4097 strcat(finaldir, "/"); 4098 strcat(finaldir, "/");
4098 strcat(finaldir, tgtdir); 4099 strcat(finaldir, tgtdir);
4099 d = opendir((const char *)Global::applicationFileName(finaldir,"")); 4100 d = opendir((const char *)Global::applicationFileName(finaldir,""));
4100 4101
4101 while(1) 4102 while(1)
4102 { 4103 {
4103 struct dirent* de; 4104 struct dirent* de;
4104 struct stat buf; 4105 struct stat buf;
4105 de = readdir(d); 4106 de = readdir(d);
4106 if (de == NULL) break; 4107 if (de == NULL) break;
4107 4108
4108 if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) 4109 if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode))
4109 { 4110 {
4110 bkmkselector->insertItem(de->d_name); 4111 bkmkselector->insertItem(de->d_name);
4111 cnt++; 4112 cnt++;
4112 } 4113 }
4113 } 4114 }
4114 delete [] finaldir; 4115 delete [] finaldir;
4115 closedir(d); 4116 closedir(d);
4116#endif 4117#endif
4117 return (cnt > 0); 4118 return (cnt > 0);
4118} 4119}
4119 4120
4120void QTReaderApp::LoadConfig() 4121void QTReaderApp::LoadConfig()
4121{ 4122{
4122 if (PopulateConfig("configs")) 4123 if (PopulateConfig("configs"))
4123 { 4124 {
4124 editorStack->raiseWidget( bkmkselector ); 4125 editorStack->raiseWidget( bkmkselector );
4125 hidetoolbars(); 4126 hidetoolbars();
4126 m_nBkmkAction = cLdConfig; 4127 m_nBkmkAction = cLdConfig;
4127 } 4128 }
4128 else 4129 else
4129 QMessageBox::information(this, PROGNAME, "No config files"); 4130 QMessageBox::information(this, PROGNAME, "No config files");
4130} 4131}
4131 4132
4132void QTReaderApp::TidyConfig() 4133void QTReaderApp::TidyConfig()
4133{ 4134{
4134 if (PopulateConfig("configs")) 4135 if (PopulateConfig("configs"))
4135 { 4136 {
4136 editorStack->raiseWidget( bkmkselector ); 4137 editorStack->raiseWidget( bkmkselector );
4137 hidetoolbars(); 4138 hidetoolbars();
4138 m_nBkmkAction = cRmConfig; 4139 m_nBkmkAction = cRmConfig;
4139 } 4140 }
4140 else 4141 else
4141 QMessageBox::information(this, PROGNAME, "No config files"); 4142 QMessageBox::information(this, PROGNAME, "No config files");
4142} 4143}
4143 4144
4144void QTReaderApp::ExportLinks() 4145void QTReaderApp::ExportLinks()
4145{ 4146{
4146 if (PopulateConfig("urls")) 4147 if (PopulateConfig("urls"))
4147 { 4148 {
4148 editorStack->raiseWidget( bkmkselector ); 4149 editorStack->raiseWidget( bkmkselector );
4149 hidetoolbars(); 4150 hidetoolbars();
4150 m_nBkmkAction = cExportLinks; 4151 m_nBkmkAction = cExportLinks;
4151 } 4152 }
4152 else 4153 else
4153 QMessageBox::information(this, PROGNAME, "No url files"); 4154 QMessageBox::information(this, PROGNAME, "No url files");
4154} 4155}
4155 4156
4156void QTReaderApp::OnURLSelected(const QString& href) 4157void QTReaderApp::OnURLSelected(const QString& href)
4157{ 4158{
4158 CURLDialog* urld = new CURLDialog(href, false, this); 4159 CURLDialog* urld = new CURLDialog(href, false, this);
4159 urld->clipboard(m_url_clipboard); 4160 urld->clipboard(m_url_clipboard);
4160 urld->localfile(m_url_localfile); 4161 urld->localfile(m_url_localfile);
4161 urld->globalfile(m_url_globalfile); 4162 urld->globalfile(m_url_globalfile);
4162 if (urld->exec()) 4163 if (urld->exec())
4163 { 4164 {
4164 m_url_clipboard = urld->clipboard(); 4165 m_url_clipboard = urld->clipboard();
4165 m_url_localfile = urld->localfile(); 4166 m_url_localfile = urld->localfile();
4166 m_url_globalfile = urld->globalfile(); 4167 m_url_globalfile = urld->globalfile();
4167 if (m_url_clipboard) 4168 if (m_url_clipboard)
4168 { 4169 {
4169 QClipboard* cb = QApplication::clipboard(); 4170 QClipboard* cb = QApplication::clipboard();
4170 cb->setText(href); 4171 cb->setText(href);
4171 qDebug("<a href=\"%s\">%s</a>", (const char*)href, (const char*)href); 4172 odebug << "<a href=\"" << href << "\">" << href << "</a>" << oendl;
4172 } 4173 }
4173 if (m_url_localfile) 4174 if (m_url_localfile)
4174 { 4175 {
4175 writeUrl(reader->m_string, href); 4176 writeUrl(reader->m_string, href);
4176 } 4177 }
4177 if (m_url_globalfile) 4178 if (m_url_globalfile)
4178 { 4179 {
4179 writeUrl("GlobalURLFile", href); 4180 writeUrl("GlobalURLFile", href);
4180 } 4181 }
4181 } 4182 }
4182 delete urld; 4183 delete urld;
4183} 4184}
4184 4185
4185void QTReaderApp::writeUrl(const QString& file, const QString& href) 4186void QTReaderApp::writeUrl(const QString& file, const QString& href)
4186{ 4187{
4187 QString filename; 4188 QString filename;
4188#ifdef USEQPE 4189#ifdef USEQPE
4189 filename = Global::applicationFileName(APPDIR "/urls", file); 4190 filename = Global::applicationFileName(APPDIR "/urls", file);
4190#else 4191#else
4191 QFileInfo fi; 4192 QFileInfo fi;
4192 QDir d = QDir::home(); // "/" 4193 QDir d = QDir::home(); // "/"
4193 if ( !d.cd(APPDIR) ) 4194 if ( !d.cd(APPDIR) )
4194 { // "/tmp" 4195 { // "/tmp"
4195 qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); 4196 owarn << "Cannot find the \"~/" APPDIR "\" directory" << oendl;
4196 d = QDir::home(); 4197 d = QDir::home();
4197 d.mkdir(APPDIR); 4198 d.mkdir(APPDIR);
4198 d.cd(APPDIR); 4199 d.cd(APPDIR);
4199 } 4200 }
4200 if ( !d.cd("urls") ) 4201 if ( !d.cd("urls") )
4201 { // "/tmp" 4202 { // "/tmp"
4202 qWarning( "Cannot find the \"~/" APPDIR "/urls\" directory" ); 4203 owarn << "Cannot find the \"~/" APPDIR "/urls\" directory" << oendl;
4203 d = QDir::home(); 4204 d = QDir::home();
4204 d.cd(APPDIR); 4205 d.cd(APPDIR);
4205 d.mkdir("urls"); 4206 d.mkdir("urls");
4206 d.cd("urls"); 4207 d.cd("urls");
4207 } 4208 }
4208 fi.setFile(d, file); 4209 fi.setFile(d, file);
4209 filename = fi.absFilePath(); 4210 filename = fi.absFilePath();
4210#endif 4211#endif
4211 FILE* fout = fopen(filename, "a"); 4212 FILE* fout = fopen(filename, "a");
4212 if (fout != NULL) 4213 if (fout != NULL)
4213 { 4214 {
4214 fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href); 4215 fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href);
4215 fclose(fout); 4216 fclose(fout);
4216 } 4217 }
4217 else 4218 else
4218 { 4219 {
4219 QMessageBox::warning(this, PROGNAME, "Problem with writing URL"); 4220 QMessageBox::warning(this, PROGNAME, "Problem with writing URL");
4220 } 4221 }
4221} 4222}
diff --git a/noncore/apps/opie-reader/StyleConsts.cpp b/noncore/apps/opie-reader/StyleConsts.cpp
index 9fb56b7..f47acee 100644
--- a/noncore/apps/opie-reader/StyleConsts.cpp
+++ b/noncore/apps/opie-reader/StyleConsts.cpp
@@ -1,25 +1,25 @@
1 1
2#include <qimage.h> 2#include <qimage.h>
3#include "StyleConsts.h" 3#include "StyleConsts.h"
4 4
5GraphicLink::~GraphicLink() { delete graphic; } 5GraphicLink::~GraphicLink() { delete graphic; }
6 6
7pmstore::~pmstore() 7pmstore::~pmstore()
8{ 8{
9//// qDebug("Deleting image"); 9//// odebug << "Deleting image" << oendl;
10 delete graphic; 10 delete graphic;
11} 11}
12 12
13CStyle::~CStyle() 13CStyle::~CStyle()
14{ 14{
15 if (graphic != NULL) 15 if (graphic != NULL)
16 { 16 {
17 if (--(graphic->count) == 0) 17 if (--(graphic->count) == 0)
18 { 18 {
19 delete graphic; 19 delete graphic;
20 } 20 }
21 } 21 }
22} 22}
23 23
24CStyle::CStyle(const CStyle& rhs) : graphic(NULL) 24CStyle::CStyle(const CStyle& rhs) : graphic(NULL)
25{ 25{
diff --git a/noncore/apps/opie-reader/fileBrowser.cpp b/noncore/apps/opie-reader/fileBrowser.cpp
index e1cde6c..72a1222 100644
--- a/noncore/apps/opie-reader/fileBrowser.cpp
+++ b/noncore/apps/opie-reader/fileBrowser.cpp
@@ -119,78 +119,78 @@ fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, boo
119} 119}
120 120
121void fileBrowser::resizeEvent(QResizeEvent* e) 121void fileBrowser::resizeEvent(QResizeEvent* e)
122{ 122{
123 ListView->setColumnWidth(1,(ListView->width())/4); 123 ListView->setColumnWidth(1,(ListView->width())/4);
124 ListView->setColumnWidth(0,ListView->width()-20-ListView->columnWidth(1)); 124 ListView->setColumnWidth(0,ListView->width()-20-ListView->columnWidth(1));
125} 125}
126 126
127fileBrowser::~fileBrowser() 127fileBrowser::~fileBrowser()
128{ 128{
129} 129}
130 130
131 131
132void fileBrowser::populateList() 132void fileBrowser::populateList()
133{ 133{
134 ListView->clear(); 134 ListView->clear();
135////qDebug(currentDir.canonicalPath()); 135////odebug << currentDir.canonicalPath() << oendl;
136// currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); 136// currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks );
137 currentDir.setFilter( filterspec ); 137 currentDir.setFilter( filterspec );
138 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 138 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
139 currentDir.setMatchAllDirs(TRUE); 139 currentDir.setMatchAllDirs(TRUE);
140 140
141 currentDir.setNameFilter(filterStr); 141 currentDir.setNameFilter(filterStr);
142// currentDir.setNameFilter("*.txt;*.etx"); 142// currentDir.setNameFilter("*.txt;*.etx");
143 QString fileL, fileS; 143 QString fileL, fileS;
144 const QFileInfoList *list = currentDir.entryInfoList(); 144 const QFileInfoList *list = currentDir.entryInfoList();
145 QFileInfoListIterator it(*list); 145 QFileInfoListIterator it(*list);
146 QFileInfo *fi; 146 QFileInfo *fi;
147 while ( (fi=it.current()) ) 147 while ( (fi=it.current()) )
148 { 148 {
149 if (fi->fileName() != ".") 149 if (fi->fileName() != ".")
150 { 150 {
151 fileS.sprintf( "%10li", fi->size() ); 151 fileS.sprintf( "%10li", fi->size() );
152 fileL.sprintf( "%s",fi->fileName().data() ); 152 fileL.sprintf( "%s",fi->fileName().data() );
153 if( fi->isDir() ) 153 if( fi->isDir() )
154 { 154 {
155 fileL+="/"; 155 fileL+="/";
156 } 156 }
157 else 157 else
158 { 158 {
159//// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 159//// odebug << "Not a dir: "+currentDir.canonicalPath()+fileL << oendl;
160 } 160 }
161 new QListViewItem( ListView,fileL,fileS ); 161 new QListViewItem( ListView,fileL,fileS );
162 } 162 }
163 ++it; 163 ++it;
164 } 164 }
165 ListView->setSorting( 2, FALSE); 165 ListView->setSorting( 2, FALSE);
166 dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); 166 dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath());
167 ListView->setFocus(); 167 ListView->setFocus();
168} 168}
169 169
170void fileBrowser::upDir() 170void fileBrowser::upDir()
171{ 171{
172//// qDebug(currentDir.canonicalPath()); 172//// odebug << currentDir.canonicalPath() << oendl;
173} 173}
174 174
175void fileBrowser::listClicked(QListViewItem *selectedItem) 175void fileBrowser::listClicked(QListViewItem *selectedItem)
176{ 176{
177 if (selectedItem == NULL) return; 177 if (selectedItem == NULL) return;
178 QString strItem=selectedItem->text(0); 178 QString strItem=selectedItem->text(0);
179 179
180//// qDebug("%s", (const char*)strItem); 180//// odebug << "" << strItem << "" << oendl;
181 181
182 182
183 QString strSize=selectedItem->text(1); 183 QString strSize=selectedItem->text(1);
184 184
185 strSize.stripWhiteSpace(); 185 strSize.stripWhiteSpace();
186 186
187 bool ok; 187 bool ok;
188 188
189 QFileInfo fi(strItem); 189 QFileInfo fi(strItem);
190 while (fi.isSymLink()) fi.setFile(fi.readLink()); 190 while (fi.isSymLink()) fi.setFile(fi.readLink());
191 if (fi.isDir()) 191 if (fi.isDir())
192 { 192 {
193 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 193 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
194 194
195 if(QDir(strItem).exists()) 195 if(QDir(strItem).exists())
196 { 196 {
diff --git a/noncore/apps/opie-reader/opie-reader.pro b/noncore/apps/opie-reader/opie-reader.pro
index e42204a..dbf6964 100644
--- a/noncore/apps/opie-reader/opie-reader.pro
+++ b/noncore/apps/opie-reader/opie-reader.pro
@@ -1,18 +1,18 @@
1 CONFIG = qt warn_on 1CONFIG = qt warn_on
2 HEADERS = Aportis.h \ 2HEADERS = Aportis.h \
3 Bkmks.h \ 3 Bkmks.h \
4 BuffDoc.h \ 4 BuffDoc.h \
5 CAnnoEdit.h \ 5 CAnnoEdit.h \
6 CBuffer.h \ 6 CBuffer.h \
7 CDrawBuffer.h \ 7 CDrawBuffer.h \
8 CEncoding.h \ 8 CEncoding.h \
9 CEncoding_tables.h \ 9 CEncoding_tables.h \
10 CExpander.h \ 10 CExpander.h \
11 CFilter.h \ 11 CFilter.h \
12 CloseDialog.h \ 12 CloseDialog.h \
13 Filedata.h \ 13 Filedata.h \
14 FixedFont.h \ 14 FixedFont.h \
15 FontControl.h \ 15 FontControl.h \
16 GraphicWin.h \ 16 GraphicWin.h \
17 Markups.h \ 17 Markups.h \
18 Navigation.h \ 18 Navigation.h \
@@ -36,33 +36,33 @@ HEADERS = Aportis.h \
36 linktype.h \ 36 linktype.h \
37 my_list.h \ 37 my_list.h \
38 names.h \ 38 names.h \
39 opie.h \ 39 opie.h \
40 pdb.h \ 40 pdb.h \
41 plucker_base.h \ 41 plucker_base.h \
42 plucker.h \ 42 plucker.h \
43 ppm.h \ 43 ppm.h \
44 ppm_expander.h \ 44 ppm_expander.h \
45 usenef.h \ 45 usenef.h \
46 useqpe.h \ 46 useqpe.h \
47 ustring.h \ 47 ustring.h \
48 utypes.h \ 48 utypes.h \
49 version.h \ 49 version.h \
50 ztxt.h 50 ztxt.h
51 51
52 SOURCES = Aportis.cpp \ 52SOURCES = Aportis.cpp \
53 Bkmks.cpp \ 53 Bkmks.cpp \
54 BuffDoc.cpp \ 54 BuffDoc.cpp \
55 CBuffer.cpp \ 55 CBuffer.cpp \
56 CDrawBuffer.cpp \ 56 CDrawBuffer.cpp \
57 CEncoding.cpp \ 57 CEncoding.cpp \
58 CEncoding_tables.cpp \ 58 CEncoding_tables.cpp \
59 CFilter.cpp \ 59 CFilter.cpp \
60 CloseDialog.cpp \ 60 CloseDialog.cpp \
61 FontControl.cpp \ 61 FontControl.cpp \
62 Navigation.cpp \ 62 Navigation.cpp \
63 Palm2QImage.cpp \ 63 Palm2QImage.cpp \
64 Prefs.cpp \ 64 Prefs.cpp \
65 QTReader.cpp \ 65 QTReader.cpp \
66 QTReaderApp.cpp \ 66 QTReaderApp.cpp \
67 QtrListView.cpp \ 67 QtrListView.cpp \
68 StyleConsts.cpp \ 68 StyleConsts.cpp \
@@ -70,23 +70,23 @@ SOURCES = Aportis.cpp \
70 URLDialog.cpp \ 70 URLDialog.cpp \
71 arith_d.cpp \ 71 arith_d.cpp \
72 fileBrowser.cpp \ 72 fileBrowser.cpp \
73 infowin.cpp \ 73 infowin.cpp \
74 main.cpp \ 74 main.cpp \
75 pdb.cpp \ 75 pdb.cpp \
76 plucker.cpp \ 76 plucker.cpp \
77 plucker_base.cpp \ 77 plucker_base.cpp \
78 ppm.cpp \ 78 ppm.cpp \
79 ppm_expander.cpp \ 79 ppm_expander.cpp \
80 version.cpp \ 80 version.cpp \
81 ztxt.cpp 81 ztxt.cpp
82 82
83DESTDIR = $(OPIEDIR)/bin 83DESTDIR = $(OPIEDIR)/bin
84TARGET = reader 84TARGET = reader
85 85
86 INCLUDEPATH+= $(OPIEDIR)/include 86INCLUDEPATH += $(OPIEDIR)/include
87 DEPENDPATH+= $(OPIEDIR)/include 87DEPENDPATH += $(OPIEDIR)/include
88 LIBS += -lqpe 88LIBS += -lqpe -lopiecore2
89 89
90include ( $(OPIEDIR)/include.pro ) 90include ( $(OPIEDIR)/include.pro )
91 91
92 92
diff --git a/noncore/apps/opie-reader/plucker.cpp b/noncore/apps/opie-reader/plucker.cpp
index e52fd6a..a8e688f 100644
--- a/noncore/apps/opie-reader/plucker.cpp
+++ b/noncore/apps/opie-reader/plucker.cpp
@@ -44,67 +44,67 @@ void CPlucker::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8&
44 44
45CPlucker::CPlucker() 45CPlucker::CPlucker()
46 { /*printf("constructing:%x\n",fin);*/ } 46 { /*printf("constructing:%x\n",fin);*/ }
47 47
48bool CPlucker::CorrectDecoder() 48bool CPlucker::CorrectDecoder()
49{ 49{
50 return (memcmp(&head.type, "DataPlkr", 8) == 0); 50 return (memcmp(&head.type, "DataPlkr", 8) == 0);
51} 51}
52 52
53int CPlucker::bgetch() 53int CPlucker::bgetch()
54{ 54{
55 int ch = EOF; 55 int ch = EOF;
56 if (bufferpos >= buffercontent) 56 if (bufferpos >= buffercontent)
57 { 57 {
58 if (!m_continuous) return EOF; 58 if (!m_continuous) return EOF;
59 if (bufferrec >= ntohs(head.recordList.numRecords) - 1) return EOF; 59 if (bufferrec >= ntohs(head.recordList.numRecords) - 1) return EOF;
60 ////qDebug("Passing through %u", currentpos); 60 ////odebug << "Passing through " << currentpos << "" << oendl;
61 if (!expand(bufferrec+1)) return EOF; 61 if (!expand(bufferrec+1)) return EOF;
62 mystyle.unset(); 62 mystyle.unset();
63 if (m_ParaOffsets[m_nextParaIndex] == 0) 63 if (m_ParaOffsets[m_nextParaIndex] == 0)
64 { 64 {
65 while (m_ParaOffsets[m_nextParaIndex+1] == 0) 65 while (m_ParaOffsets[m_nextParaIndex+1] == 0)
66 { 66 {
67 // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); 67 // odebug << "Skipping extraspace:" << m_ParaAttrs[m_nextParaIndex]&7 << "" << oendl;
68 m_nextParaIndex++; 68 m_nextParaIndex++;
69 } 69 }
70 } 70 }
71 mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); 71 mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2);
72 //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); 72 //odebug << "Using extraspace:" << m_ParaAttrs[m_nextParaIndex]&7 << "" << oendl;
73 ch = 10; 73 ch = 10;
74 EOPPhase = 4; 74 EOPPhase = 4;
75 } 75 }
76 else if (bufferpos == m_nextPara) 76 else if (bufferpos == m_nextPara)
77 { 77 {
78 while (bufferpos == m_nextPara) 78 while (bufferpos == m_nextPara)
79 { 79 {
80 UInt16 attr = m_ParaAttrs[m_nextParaIndex]; 80 UInt16 attr = m_ParaAttrs[m_nextParaIndex];
81 m_nextParaIndex++; 81 m_nextParaIndex++;
82 // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); 82 // odebug << "Skipping extraspace:" << m_ParaAttrs[m_nextParaIndex]&7 << "" << oendl;
83 if (m_nextParaIndex == m_nParas) 83 if (m_nextParaIndex == m_nParas)
84 { 84 {
85 m_nextPara = -1; 85 m_nextPara = -1;
86 } 86 }
87 else 87 else
88 { 88 {
89 m_nextPara += m_ParaOffsets[m_nextParaIndex]; 89 m_nextPara += m_ParaOffsets[m_nextParaIndex];
90 } 90 }
91 } 91 }
92 mystyle.unset(); 92 mystyle.unset();
93 mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); 93 mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2);
94 //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); 94 //odebug << "Using extraspace:" << m_ParaAttrs[m_nextParaIndex]&7 << "" << oendl;
95 if (m_lastBreak == locate()) 95 if (m_lastBreak == locate())
96 { 96 {
97 currentpos++; 97 currentpos++;
98 ch = expandedtextbuffer[bufferpos++]; 98 ch = expandedtextbuffer[bufferpos++];
99 } 99 }
100 else 100 else
101 { 101 {
102 ch = 10; 102 ch = 10;
103 } 103 }
104 } 104 }
105 else 105 else
106 { 106 {
107 currentpos++; 107 currentpos++;
108 ch = expandedtextbuffer[bufferpos++]; 108 ch = expandedtextbuffer[bufferpos++];
109 } 109 }
110 return ch; 110 return ch;
diff --git a/noncore/apps/opie-reader/plucker_base.cpp b/noncore/apps/opie-reader/plucker_base.cpp
index caa945d..b523a54 100644
--- a/noncore/apps/opie-reader/plucker_base.cpp
+++ b/noncore/apps/opie-reader/plucker_base.cpp
@@ -1,190 +1,198 @@
1
2
1#include "useqpe.h" 3#include "useqpe.h"
2#include <stdio.h> 4#include "plucker_base.h"
3#include <string.h> 5#include "Aportis.h"
6#include "Palm2QImage.h"
7
8/* OPIE */
9#include <opie2/odebug.h>
4#ifdef USEQPE 10#ifdef USEQPE
5#include <qpe/qcopenvelope_qws.h> 11#include <qpe/qcopenvelope_qws.h>
6#endif /* USEQPE */
7#ifdef LOCALPICTURES
8#include <qscrollview.h>
9#endif
10#ifdef USEQPE
11#include <qpe/global.h> 12#include <qpe/global.h>
12#endif /* USEQPE */ 13#endif /* USEQPE */
14
13#ifndef USEQPE 15#ifndef USEQPE
14#include <qapplication.h> 16#include <qapplication.h>
15#else /* USEQPE */ 17#else /* USEQPE */
16#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
17#endif /* USEQPE */ 19#endif /* USEQPE */
18 20
19#include "plucker_base.h" 21/* QT */
20#include "Aportis.h" 22#ifdef LOCALPICTURES
21#include "Palm2QImage.h" 23#include <qscrollview.h>
24#endif
25
26/* STD */
27#include <stdio.h>
28#include <string.h>
29
22 30
23CPlucker_base::CPlucker_base() : 31CPlucker_base::CPlucker_base() :
24#ifdef LOCALPICTURES 32#ifdef LOCALPICTURES
25 m_viewer(NULL), 33 m_viewer(NULL),
26 m_picture(NULL), 34 m_picture(NULL),
27#endif 35#endif
28 expandedtextbuffer(NULL), 36 expandedtextbuffer(NULL),
29 compressedtextbuffer(NULL) 37 compressedtextbuffer(NULL)
30//, urls(NULL) 38//, urls(NULL)
31 { /*printf("constructing:%x\n",fin);*/ } 39 { /*printf("constructing:%x\n",fin);*/ }
32 40
33 41
34void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buffersize) 42void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buffersize)
35{ 43{
36 if (type%2 == 0) 44 if (type%2 == 0)
37 { 45 {
38 fread(buffer, reclen, sizeof(char), fin); 46 fread(buffer, reclen, sizeof(char), fin);
39 } 47 }
40 else 48 else
41 { 49 {
42 UInt8* readbuffer = NULL; 50 UInt8* readbuffer = NULL;
43 if (reclen > compressedbuffersize) 51 if (reclen > compressedbuffersize)
44 { 52 {
45 readbuffer = new UInt8[reclen]; 53 readbuffer = new UInt8[reclen];
46 } 54 }
47 else 55 else
48 { 56 {
49 readbuffer = compressedtextbuffer; 57 readbuffer = compressedtextbuffer;
50 } 58 }
51 if (readbuffer != NULL) 59 if (readbuffer != NULL)
52 { 60 {
53 fread(readbuffer, reclen, sizeof(char), fin); 61 fread(readbuffer, reclen, sizeof(char), fin);
54 switch (ntohs(hdr0.version)) 62 switch (ntohs(hdr0.version))
55 { 63 {
56 case 2: 64 case 2:
57 UnZip(readbuffer, reclen, buffer, buffersize); 65 UnZip(readbuffer, reclen, buffer, buffersize);
58 break; 66 break;
59 case 1: 67 case 1:
60 UnDoc(readbuffer, reclen, buffer, buffersize); 68 UnDoc(readbuffer, reclen, buffer, buffersize);
61 break; 69 break;
62 } 70 }
63 if (reclen > compressedbuffersize) 71 if (reclen > compressedbuffersize)
64 { 72 {
65 delete [] readbuffer; 73 delete [] readbuffer;
66 } 74 }
67 } 75 }
68 } 76 }
69} 77}
70 78
71void CPlucker_base::sizes(unsigned long& _file, unsigned long& _text) 79void CPlucker_base::sizes(unsigned long& _file, unsigned long& _text)
72{ 80{
73 _file = file_length; 81 _file = file_length;
74 if (textlength == 0) 82 if (textlength == 0)
75 { 83 {
76 for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) 84 for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
77 { 85 {
78 gotorecordnumber(recptr); 86 gotorecordnumber(recptr);
79 UInt16 thishdr_uid, thishdr_nParagraphs; 87 UInt16 thishdr_uid, thishdr_nParagraphs;
80 UInt32 thishdr_size; 88 UInt32 thishdr_size;
81 UInt8 thishdr_type, thishdr_reserved; 89 UInt8 thishdr_type, thishdr_reserved;
82 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 90 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
83 if (thishdr_type < 2) textlength += thishdr_size; 91 if (thishdr_type < 2) textlength += thishdr_size;
84 } 92 }
85 } 93 }
86 _text = textlength; 94 _text = textlength;
87//ntohl(hdr0.size); 95//ntohl(hdr0.size);
88} 96}
89 97
90char* CPlucker_base::geturl(UInt16 tgt) 98char* CPlucker_base::geturl(UInt16 tgt)
91{ 99{
92 char * pRet = NULL; 100 char * pRet = NULL;
93 gotorecordnumber(0); 101 gotorecordnumber(0);
94 fread(&hdr0, 1, 6, fin); 102 fread(&hdr0, 1, 6, fin);
95 unsigned int nrecs = ntohs(hdr0.nRecords); 103 unsigned int nrecs = ntohs(hdr0.nRecords);
96 //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); 104 //odebug << "Version " << ntohs(hdr0.version) << ", no. recs " << nrecs << "" << oendl;
97 UInt16 urlid = 0; 105 UInt16 urlid = 0;
98 bool urlsfound = false; 106 bool urlsfound = false;
99 char* urls = NULL; 107 char* urls = NULL;
100 size_t urlsize = 0; 108 size_t urlsize = 0;
101 for (unsigned int i = 0; i < nrecs; i++) 109 for (unsigned int i = 0; i < nrecs; i++)
102 { 110 {
103 UInt16 id, name; 111 UInt16 id, name;
104 fread(&name, 1, sizeof(name), fin); 112 fread(&name, 1, sizeof(name), fin);
105 fread(&id, 1, sizeof(id), fin); 113 fread(&id, 1, sizeof(id), fin);
106 //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); 114 //odebug << "N:" << ntohs(name) << ", I:" << ntohs(id) << "" << oendl;
107 if (ntohs(name) == 2) 115 if (ntohs(name) == 2)
108 { 116 {
109 urlsfound = true; 117 urlsfound = true;
110 urlid = id; 118 urlid = id;
111 //qDebug("Found url index:%d", ntohs(urlid)); 119 //odebug << "Found url index:" << ntohs(urlid) << "" << oendl;
112 } 120 }
113 ////qDebug("%x", id); 121// //odebug << "" << id << "" << oendl;
114 } 122 }
115 if (urlsfound) 123 if (urlsfound)
116 { 124 {
117 unsigned short recptr = finduid(ntohs(urlid)); 125 unsigned short recptr = finduid(ntohs(urlid));
118 if (recptr != 0) 126 if (recptr != 0)
119 { 127 {
120 gotorecordnumber(recptr); 128 gotorecordnumber(recptr);
121 UInt16 thishdr_uid, thishdr_nParagraphs; 129 UInt16 thishdr_uid, thishdr_nParagraphs;
122 UInt32 thishdr_size; 130 UInt32 thishdr_size;
123 UInt8 thishdr_type, thishdr_reserved; 131 UInt8 thishdr_type, thishdr_reserved;
124 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 132 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
125 UInt16 urlctr = 0; 133 UInt16 urlctr = 0;
126 while (1) 134 while (1)
127 { 135 {
128 UInt16 tctr; 136 UInt16 tctr;
129 fread(&tctr, 1, sizeof(tctr), fin); 137 fread(&tctr, 1, sizeof(tctr), fin);
130 fread(&urlid, 1, sizeof(urlid), fin); 138 fread(&urlid, 1, sizeof(urlid), fin);
131 tctr = ntohs(tctr); 139 tctr = ntohs(tctr);
132 //qDebug("tgt:%u urlctr:%u tctr:%u", tgt, urlctr, tctr); 140 //odebug << "tgt:" << tgt << " urlctr:" << urlctr << " tctr:" << tctr << "" << oendl;
133 if (tctr >= tgt) 141 if (tctr >= tgt)
134 { 142 {
135 break; 143 break;
136 } 144 }
137 urlctr = tctr; 145 urlctr = tctr;
138 } 146 }
139 //qDebug("urls are in %d", ntohs(urlid)); 147 //odebug << "urls are in " << ntohs(urlid) << "" << oendl;
140 recptr = finduid(ntohs(urlid)); 148 recptr = finduid(ntohs(urlid));
141 if (recptr != 0) 149 if (recptr != 0)
142 { 150 {
143 UInt32 reclen = recordlength(recptr) - HeaderSize(); 151 UInt32 reclen = recordlength(recptr) - HeaderSize();
144 gotorecordnumber(recptr); 152 gotorecordnumber(recptr);
145 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 153 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
146 //qDebug("Found urls:%x",thishdr_type); 154 //odebug << "Found urls:" << thishdr_type << "" << oendl;
147 urlsize = thishdr_size; 155 urlsize = thishdr_size;
148 urls = new char[urlsize]; 156 urls = new char[urlsize];
149 Expand(reclen, thishdr_type, (UInt8*)urls, urlsize); 157 Expand(reclen, thishdr_type, (UInt8*)urls, urlsize);
150 char* ptr = urls; 158 char* ptr = urls;
151 int rn = urlctr+1; 159 int rn = urlctr+1;
152 while (ptr - urls < urlsize) 160 while (ptr - urls < urlsize)
153 { 161 {
154 if (rn == tgt) 162 if (rn == tgt)
155 { 163 {
156 //qDebug("URL:%s", ptr); 164 //odebug << "URL:" << ptr << "" << oendl;
157 int len = strlen(ptr)+1; 165 int len = strlen(ptr)+1;
158 pRet = new char[len]; 166 pRet = new char[len];
159 memcpy(pRet, ptr, len); 167 memcpy(pRet, ptr, len);
160 break; 168 break;
161 } 169 }
162 ptr += strlen(ptr)+1; 170 ptr += strlen(ptr)+1;
163 rn++; 171 rn++;
164 } 172 }
165 delete [] urls; 173 delete [] urls;
166 } 174 }
167 } 175 }
168 } 176 }
169 else 177 else
170 { 178 {
171 QMessageBox::information(NULL, 179 QMessageBox::information(NULL,
172 QString(PROGNAME), 180 QString(PROGNAME),
173 QString("No external links\nin this pluck") 181 QString("No external links\nin this pluck")
174 ); 182 );
175 } 183 }
176 return pRet; 184 return pRet;
177} 185}
178 186
179CPlucker_base::~CPlucker_base() 187CPlucker_base::~CPlucker_base()
180{ 188{
181 if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; 189 if (expandedtextbuffer != NULL) delete [] expandedtextbuffer;
182 if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; 190 if (compressedtextbuffer != NULL) delete [] compressedtextbuffer;
183#ifdef LOCALPICTURES 191#ifdef LOCALPICTURES
184 if (m_viewer != NULL) delete m_viewer; 192 if (m_viewer != NULL) delete m_viewer;
185#endif 193#endif
186} 194}
187 195
188int CPlucker_base::getch() { return getch(false); } 196int CPlucker_base::getch() { return getch(false); }
189 197
190void CPlucker_base::getch(tchar& ch, CStyle& sty) 198void CPlucker_base::getch(tchar& ch, CStyle& sty)
@@ -193,279 +201,279 @@ void CPlucker_base::getch(tchar& ch, CStyle& sty)
193 sty = mystyle; 201 sty = mystyle;
194} 202}
195 203
196unsigned int CPlucker_base::locate() 204unsigned int CPlucker_base::locate()
197{ 205{
198 return currentpos; 206 return currentpos;
199/* 207/*
200 UInt16 thisrec = 1; 208 UInt16 thisrec = 1;
201 unsigned long locpos = 0; 209 unsigned long locpos = 0;
202 gotorecordnumber(thisrec); 210 gotorecordnumber(thisrec);
203 UInt16 thishdr_uid, thishdr_nParagraphs; 211 UInt16 thishdr_uid, thishdr_nParagraphs;
204 UInt32 thishdr_size; 212 UInt32 thishdr_size;
205 UInt8 thishdr_type, thishdr_reserved; 213 UInt8 thishdr_type, thishdr_reserved;
206 while (thisrec < bufferrec) 214 while (thisrec < bufferrec)
207 { 215 {
208 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 216 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
209 if (thishdr_type < 2) locpos += thishdr_size; 217 if (thishdr_type < 2) locpos += thishdr_size;
210 thisrec++; 218 thisrec++;
211 gotorecordnumber(thisrec); 219 gotorecordnumber(thisrec);
212 } 220 }
213 return locpos+bufferpos; 221 return locpos+bufferpos;
214*/ 222*/
215} 223}
216 224
217void CPlucker_base::locate(unsigned int n) 225void CPlucker_base::locate(unsigned int n)
218{ 226{
219 227
220// clock_t start = clock(); 228// clock_t start = clock();
221 UInt32 textlength = currentpos - bufferpos; 229 UInt32 textlength = currentpos - bufferpos;
222 UInt16 recptr = bufferrec; 230 UInt16 recptr = bufferrec;
223 if (n < textlength/2) 231 if (n < textlength/2)
224 { 232 {
225 textlength = 0; 233 textlength = 0;
226 UInt16 thishdr_uid, thishdr_nParagraphs; 234 UInt16 thishdr_uid, thishdr_nParagraphs;
227 UInt32 thishdr_size = buffercontent; 235 UInt32 thishdr_size = buffercontent;
228 UInt8 thishdr_type, thishdr_reserved; 236 UInt8 thishdr_type, thishdr_reserved;
229 for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) 237 for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
230 { 238 {
231 gotorecordnumber(recptr); 239 gotorecordnumber(recptr);
232 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 240 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
233 if (thishdr_type < 2) 241 if (thishdr_type < 2)
234 { 242 {
235 textlength += thishdr_size; 243 textlength += thishdr_size;
236 if (textlength > n) 244 if (textlength > n)
237 { 245 {
238 textlength -= thishdr_size; 246 textlength -= thishdr_size;
239 break; 247 break;
240 } 248 }
241 } 249 }
242 } 250 }
243 } 251 }
244 else if (n < textlength) 252 else if (n < textlength)
245 { 253 {
246 UInt16 thishdr_uid, thishdr_nParagraphs; 254 UInt16 thishdr_uid, thishdr_nParagraphs;
247 UInt32 thishdr_size; 255 UInt32 thishdr_size;
248 UInt8 thishdr_type, thishdr_reserved; 256 UInt8 thishdr_type, thishdr_reserved;
249 while (n < textlength && recptr > 1) 257 while (n < textlength && recptr > 1)
250 { 258 {
251 recptr--; 259 recptr--;
252 gotorecordnumber(recptr); 260 gotorecordnumber(recptr);
253 //qDebug("recptr:%u", recptr); 261 //odebug << "recptr:" << recptr << "" << oendl;
254 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 262 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
255 if (thishdr_type < 2) 263 if (thishdr_type < 2)
256 { 264 {
257 textlength -= thishdr_size; 265 textlength -= thishdr_size;
258 } 266 }
259 } 267 }
260 } 268 }
261 else 269 else
262 { 270 {
263 UInt16 thishdr_uid, thishdr_nParagraphs; 271 UInt16 thishdr_uid, thishdr_nParagraphs;
264 UInt32 thishdr_size = buffercontent; 272 UInt32 thishdr_size = buffercontent;
265 UInt8 thishdr_type, thishdr_reserved; 273 UInt8 thishdr_type, thishdr_reserved;
266 while (n > textlength + thishdr_size && recptr < ntohs(head.recordList.numRecords)-1) 274 while (n > textlength + thishdr_size && recptr < ntohs(head.recordList.numRecords)-1)
267 { 275 {
268 textlength += thishdr_size; 276 textlength += thishdr_size;
269 recptr++; 277 recptr++;
270 gotorecordnumber(recptr); 278 gotorecordnumber(recptr);
271 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 279 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
272 if (!(thishdr_type < 2)) 280 if (!(thishdr_type < 2))
273 { 281 {
274 thishdr_size = 0; 282 thishdr_size = 0;
275 } 283 }
276 } 284 }
277 } 285 }
278// qDebug("Time(1): %u", clock()-start); 286// odebug << "Time(1): " << clock()-start << "" << oendl;
279/* 287/*
280 expand(recptr); 288 expand(recptr);
281 mystyle.unset(); 289 mystyle.unset();
282 bufferpos = n-textlength; 290 bufferpos = n-textlength;
283 currentpos = n; 291 currentpos = n;
284 while (bufferpos >= m_nextPara && m_nextPara >= 0) 292 while (bufferpos >= m_nextPara && m_nextPara >= 0)
285 { 293 {
286 UInt16 attr = m_ParaAttrs[m_nextParaIndex]; 294 UInt16 attr = m_ParaAttrs[m_nextParaIndex];
287 m_nextParaIndex++; 295 m_nextParaIndex++;
288 if (m_nextParaIndex == m_nParas) 296 if (m_nextParaIndex == m_nParas)
289 { 297 {
290 m_nextPara = -1; 298 m_nextPara = -1;
291 } 299 }
292 else 300 else
293 { 301 {
294 m_nextPara += m_ParaOffsets[m_nextParaIndex]; 302 m_nextPara += m_ParaOffsets[m_nextParaIndex];
295 } 303 }
296 } 304 }
297 305
298 return; 306 return;
299*/ 307*/
300// start = clock(); 308// start = clock();
301 309
302 UInt16 thisrec = 0; 310 UInt16 thisrec = 0;
303 unsigned long locpos = 0; 311 unsigned long locpos = 0;
304 unsigned long bs = 0; 312 unsigned long bs = 0;
305 UInt16 thishdr_uid, thishdr_nParagraphs; 313 UInt16 thishdr_uid, thishdr_nParagraphs;
306 UInt32 thishdr_size; 314 UInt32 thishdr_size;
307 UInt8 thishdr_type, thishdr_reserved; 315 UInt8 thishdr_type, thishdr_reserved;
308 do 316 do
309 { 317 {
310 thisrec++; 318 thisrec++;
311 locpos += bs; 319 locpos += bs;
312 gotorecordnumber(thisrec); 320 gotorecordnumber(thisrec);
313 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 321 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
314 if (thishdr_type < 2) 322 if (thishdr_type < 2)
315 { 323 {
316 bs = thishdr_size; 324 bs = thishdr_size;
317 } 325 }
318 else 326 else
319 { 327 {
320 bs = 0; 328 bs = 0;
321 } 329 }
322 } while (locpos + bs <= n); 330 } while (locpos + bs <= n);
323 331
324// qDebug("Time(2): %u", clock()-start); 332// odebug << "Time(2): " << clock()-start << "" << oendl;
325 if (recptr != thisrec) 333 if (recptr != thisrec)
326 { 334 {
327 qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec); 335 odebug << "Disaster:recptr:" << recptr << " thisrec:" << thisrec << "" << oendl;
328 UInt16 thishdr_uid, thishdr_nParagraphs; 336 UInt16 thishdr_uid, thishdr_nParagraphs;
329 UInt32 thishdr_size = buffercontent; 337 UInt32 thishdr_size = buffercontent;
330 UInt8 thishdr_type, thishdr_reserved; 338 UInt8 thishdr_type, thishdr_reserved;
331 for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) 339 for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
332 { 340 {
333 gotorecordnumber(recptr); 341 gotorecordnumber(recptr);
334 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 342 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
335 // qDebug("UID:%u Paras:%u Size:%u Type:%u Reserved:%u", thishdr_uid, thishdr_nParagraphs, thishdr_size, (unsigned int)thishdr_type, (unsigned int)thishdr_reserved); 343// odebug << "UID:" << thishdr_uid << " Paras:" << thishdr_nParagraphs << " Size:" << thishdr_size << " Type:" << (unsigned int)thishdr_type << " Reserved:" << (unsigned int)thishdr_reserved << "" << oendl;
336 } 344 }
337 //QApplication::exit ( 100 ); 345// QApplication::exit ( 100 );
338 } 346 }
339 347
340 currentpos = locpos; 348 currentpos = locpos;
341 expand(thisrec); 349 expand(thisrec);
342 while (currentpos < n && bufferpos < buffercontent) getch_base(true); 350 while (currentpos < n && bufferpos < buffercontent) getch_base(true);
343 351
344/* // This is faster but the alignment attribute doesn't get set 8^( 352/* // This is faster but the alignment attribute doesn't get set 8^(
345 bufferpos = n-locpos; 353 bufferpos = n-locpos;
346 currentpos = n; 354 currentpos = n;
347 while (bufferpos >= m_nextPara && m_nextPara >= 0) 355 while (bufferpos >= m_nextPara && m_nextPara >= 0)
348 { 356 {
349 UInt16 attr = m_ParaAttrs[m_nextParaIndex]; 357 UInt16 attr = m_ParaAttrs[m_nextParaIndex];
350 m_nextParaIndex++; 358 m_nextParaIndex++;
351 if (m_nextParaIndex == m_nParas) 359 if (m_nextParaIndex == m_nParas)
352 { 360 {
353 m_nextPara = -1; 361 m_nextPara = -1;
354 } 362 }
355 else 363 else
356 { 364 {
357 m_nextPara += m_ParaOffsets[m_nextParaIndex]; 365 m_nextPara += m_ParaOffsets[m_nextParaIndex];
358 } 366 }
359 } 367 }
360*/ 368*/
361} 369}
362 370
363bool CPlucker_base::expand(int thisrec) 371bool CPlucker_base::expand(int thisrec)
364{ 372{
365 mystyle.unset(); 373 mystyle.unset();
366 size_t reclen = recordlength(thisrec); 374 size_t reclen = recordlength(thisrec);
367 gotorecordnumber(thisrec); 375 gotorecordnumber(thisrec);
368 UInt16 thishdr_uid, thishdr_nParagraphs; 376 UInt16 thishdr_uid, thishdr_nParagraphs;
369 UInt32 thishdr_size; 377 UInt32 thishdr_size;
370 UInt8 thishdr_type, thishdr_reserved; 378 UInt8 thishdr_type, thishdr_reserved;
371 while (1) 379 while (1)
372 { 380 {
373 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 381 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
374 //qDebug("This (%d) type is %d, uid is %u", thisrec, thishdr_type, thishdr_uid); 382 //odebug << "This (" << thisrec << ") type is " << thishdr_type << ", uid is " << thishdr_uid << "" << oendl;
375 if (thishdr_type < 2) break; 383 if (thishdr_type < 2) break;
376 //qDebug("Skipping paragraph of type %d", thishdr_type); 384 //odebug << "Skipping paragraph of type " << thishdr_type << "" << oendl;
377 if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; 385 if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false;
378 reclen = recordlength(thisrec); 386 reclen = recordlength(thisrec);
379 gotorecordnumber(thisrec); 387 gotorecordnumber(thisrec);
380 } 388 }
381 m_nParas = thishdr_nParagraphs; 389 m_nParas = thishdr_nParagraphs;
382 m_bufferisreserved = (thishdr_reserved != 0); 390 m_bufferisreserved = (thishdr_reserved != 0);
383 //qDebug("It has %u paragraphs and is %u bytes", thishdr_nParagraphs, thishdr_size); 391 //odebug << "It has " << thishdr_nParagraphs << " paragraphs and is " << thishdr_size << " bytes" << oendl;
384 uid = thishdr_uid; 392 uid = thishdr_uid;
385// gotorecordnumber(thisrec); 393// gotorecordnumber(thisrec);
386// fread(expandedtextbuffer,1,10,fin); 394// fread(expandedtextbuffer,1,10,fin);
387 for (int i = 0; i < m_nParas; i++) 395 for (int i = 0; i < m_nParas; i++)
388 { 396 {
389 UInt16 ubytes, attrs; 397 UInt16 ubytes, attrs;
390 fread(&ubytes, 1, sizeof(ubytes), fin); 398 fread(&ubytes, 1, sizeof(ubytes), fin);
391 fread(&attrs, 1, sizeof(attrs), fin); 399 fread(&attrs, 1, sizeof(attrs), fin);
392 m_ParaOffsets[i] = ntohs(ubytes); 400 m_ParaOffsets[i] = ntohs(ubytes);
393 m_ParaAttrs[i] = ntohs(attrs); 401 m_ParaAttrs[i] = ntohs(attrs);
394 ////qDebug("Bytes %u, Attr %x", ntohs(ubytes), ntohs(attrs)); 402// //odebug << "Bytes " << ntohs(ubytes) << ", Attr " << ntohs(attrs) << "" << oendl;
395 } 403 }
396 if (m_nParas > 0) 404 if (m_nParas > 0)
397 { 405 {
398 m_nextPara = m_ParaOffsets[0]; 406 m_nextPara = m_ParaOffsets[0];
399 //qDebug("First offset = %u", m_nextPara); 407 //odebug << "First offset = " << m_nextPara << "" << oendl;
400 m_nextParaIndex = 0; 408 m_nextParaIndex = 0;
401 } 409 }
402 else 410 else
403 { 411 {
404 m_nextPara = -1; 412 m_nextPara = -1;
405 } 413 }
406 414
407 reclen -= HeaderSize()+4*m_nParas; 415 reclen -= HeaderSize()+4*m_nParas;
408 416
409 buffercontent = thishdr_size; 417 buffercontent = thishdr_size;
410 418
411 if (thishdr_size > buffersize) 419 if (thishdr_size > buffersize)
412 { 420 {
413 delete [] expandedtextbuffer; 421 delete [] expandedtextbuffer;
414 buffersize = thishdr_size; 422 buffersize = thishdr_size;
415 expandedtextbuffer = new UInt8[buffersize]; 423 expandedtextbuffer = new UInt8[buffersize];
416 } 424 }
417 425
418 Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent); 426 Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent);
419 bufferpos = 0; 427 bufferpos = 0;
420 bufferrec = thisrec; 428 bufferrec = thisrec;
421 //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size); 429 //odebug << "BC:" << buffercontent << ", HS:" << thishdr_size << "" << oendl;
422 return true; 430 return true;
423} 431}
424 432
425void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) 433void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize)
426{ 434{
427 z_stream zstream; 435 z_stream zstream;
428 memset(&zstream,sizeof(zstream),0); 436 memset(&zstream,sizeof(zstream),0);
429 zstream.next_in = compressedbuffer; 437 zstream.next_in = compressedbuffer;
430 zstream.next_out = tgtbuffer; 438 zstream.next_out = tgtbuffer;
431 zstream.avail_out = bsize; 439 zstream.avail_out = bsize;
432 zstream.avail_in = reclen; 440 zstream.avail_in = reclen;
433 441
434 int keylen = 0; 442 int keylen = 0;
435 443
436 zstream.zalloc = Z_NULL; 444 zstream.zalloc = Z_NULL;
437 zstream.zfree = Z_NULL; 445 zstream.zfree = Z_NULL;
438 zstream.opaque = Z_NULL; 446 zstream.opaque = Z_NULL;
439 447
440// printf("Initialising\n"); 448// printf("Initialising\n");
441 449
442 inflateInit(&zstream); 450 inflateInit(&zstream);
443 int err = 0; 451 int err = 0;
444 do { 452 do {
445 if ( zstream.avail_in == 0 && 0 < keylen ) { 453 if ( zstream.avail_in == 0 && 0 < keylen ) {
446 zstream.next_in = compressedbuffer + keylen; 454 zstream.next_in = compressedbuffer + keylen;
447 zstream.avail_in = reclen - keylen; 455 zstream.avail_in = reclen - keylen;
448 keylen = 0; 456 keylen = 0;
449 } 457 }
450 zstream.next_out = tgtbuffer; 458 zstream.next_out = tgtbuffer;
451 zstream.avail_out = bsize; 459 zstream.avail_out = bsize;
452 460
453 err = inflate( &zstream, Z_SYNC_FLUSH ); 461 err = inflate( &zstream, Z_SYNC_FLUSH );
454 462
455 ////qDebug("err:%d - %u", err, zstream.avail_in); 463// //odebug << "err:" << err << " - " << zstream.avail_in << "" << oendl;
456 464
457 } while ( err == Z_OK ); 465 } while ( err == Z_OK );
458 466
459 inflateEnd(&zstream); 467 inflateEnd(&zstream);
460} 468}
461 469
462void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) 470void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize)
463{ 471{
464// UInt16 headerSize; 472// UInt16 headerSize;
465 UInt16 docSize; 473 UInt16 docSize;
466 UInt16 i; 474 UInt16 i;
467 UInt16 j; 475 UInt16 j;
468 UInt16 k; 476 UInt16 k;
469 477
470 UInt8 *inBuf = compressedbuffer; 478 UInt8 *inBuf = compressedbuffer;
471 UInt8 *outBuf = tgtbuffer; 479 UInt8 *outBuf = tgtbuffer;
@@ -514,722 +522,722 @@ void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuff
514 522
515void CPlucker_base::home() 523void CPlucker_base::home()
516{ 524{
517 currentpos = 0; 525 currentpos = 0;
518 expand(1); 526 expand(1);
519} 527}
520 528
521CList<Bkmk>* CPlucker_base::getbkmklist() 529CList<Bkmk>* CPlucker_base::getbkmklist()
522{ 530{
523/* 531/*
524 UInt16 thishdr_uid, thishdr_nParagraphs; 532 UInt16 thishdr_uid, thishdr_nParagraphs;
525 UInt32 thishdr_size; 533 UInt32 thishdr_size;
526 UInt8 thishdr_type, thishdr_reserved; 534 UInt8 thishdr_type, thishdr_reserved;
527 535
528 for (int i = 1; i < ntohs(head.recordList.numRecords); i++) 536 for (int i = 1; i < ntohs(head.recordList.numRecords); i++)
529 { 537 {
530 gotorecordnumber(i); 538 gotorecordnumber(i);
531 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 539 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
532 if (thishdr_type == 8) 540 if (thishdr_type == 8)
533 { 541 {
534 UInt16 n; 542 UInt16 n;
535 fread(&n, 1, sizeof(n), fin); 543 fread(&n, 1, sizeof(n), fin);
536 n = ntohs(n); 544 n = ntohs(n);
537 //qDebug("Found %u bookmarks", n); 545 //odebug << "Found " << n << " bookmarks" << oendl;
538 } 546 }
539 //qDebug("Found:%d, %u", i , thishdr_type); 547 //odebug << "Found:" << i << ", " << thishdr_type << "" << oendl;
540 } 548 }
541*/ 549*/
542 return NULL; 550 return NULL;
543} 551}
544 552
545 553
546QImage* CPlucker_base::expandimg(UInt16 tgt, bool border) 554QImage* CPlucker_base::expandimg(UInt16 tgt, bool border)
547{ 555{
548 QImage* qimage = getimg(tgt); 556 QImage* qimage = getimg(tgt);
549 QImage* ret; 557 QImage* ret;
550 if (qimage == NULL) return NULL; 558 if (qimage == NULL) return NULL;
551 if (border) 559 if (border)
552 { 560 {
553 QPixmap* image = new QPixmap(0,0); 561 QPixmap* image = new QPixmap(0,0);
554 image->convertFromImage(*qimage); 562 image->convertFromImage(*qimage);
555 delete qimage; 563 delete qimage;
556 QPixmap* pret = new QPixmap(image->width()+4, image->height()+4); 564 QPixmap* pret = new QPixmap(image->width()+4, image->height()+4);
557 pret->fill(Qt::red); 565 pret->fill(Qt::red);
558 bitBlt(pret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP); 566 bitBlt(pret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP);
559 delete image; 567 delete image;
560 ret = new QImage(pret->convertToImage()); 568 ret = new QImage(pret->convertToImage());
561 } 569 }
562 else 570 else
563 { 571 {
564 ret = qimage; 572 ret = qimage;
565 } 573 }
566 return ret; 574 return ret;
567} 575}
568 576
569#ifdef _BUFFERPICS 577#ifdef _BUFFERPICS
570#include <qmap.h> 578#include <qmap.h>
571#endif 579#endif
572 580
573QImage* CPlucker_base::getPicture(unsigned long tgt) 581QImage* CPlucker_base::getPicture(unsigned long tgt)
574{ 582{
575#ifdef _BUFFERPICS 583#ifdef _BUFFERPICS
576 static QMap<unsigned long, QPixmap> pix; 584 static QMap<unsigned long, QPixmap> pix;
577 QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt); 585 QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt);
578 if (t == pix.end()) 586 if (t == pix.end())
579 { 587 {
580 pix[tgt] = *expandimg(tgt); 588 pix[tgt] = *expandimg(tgt);
581 return &pix[tgt]; 589 return &pix[tgt];
582 } 590 }
583 else 591 else
584 return &(t.data()); 592 return &(t.data());
585#else 593#else
586 return expandimg(tgt >> 16); 594 return expandimg(tgt >> 16);
587#endif 595#endif
588} 596}
589 597
590#ifdef LOCALPICTURES 598#ifdef LOCALPICTURES
591#include <unistd.h> 599#include <unistd.h>
592#include <qpe/global.h> 600#include <qpe/global.h>
593void CPlucker_base::showimg(UInt16 tgt) 601void CPlucker_base::showimg(UInt16 tgt)
594{ 602{
595 //qDebug("Crassssssh!"); 603 //odebug << "Crassssssh!" << oendl;
596 QPixmap* qimage = expandimg(tgt); 604 QPixmap* qimage = expandimg(tgt);
597 m_picture->setFixedSize(qimage->size()); 605 m_picture->setFixedSize(qimage->size());
598 m_picture->setBackgroundPixmap(*qimage); 606 m_picture->setBackgroundPixmap(*qimage);
599 delete qimage; 607 delete qimage;
600 m_viewer->show(); 608 m_viewer->show();
601 609
602/* 610/*
603 char tmp[] = "uqtreader.XXXXXX"; 611 char tmp[] = "uqtreader.XXXXXX";
604 QImage* qimage = getimg(tgt); 612 QImage* qimage = getimg(tgt);
605 QPixmap* image = new QPixmap(0,0); 613 QPixmap* image = new QPixmap(0,0);
606// //qDebug("New image"); 614// //odebug << "New image" << oendl;
607 image->convertFromImage(*qimage); 615 image->convertFromImage(*qimage);
608 delete qimage; 616 delete qimage;
609 char tmpfile[sizeof(tmp)+1]; 617 char tmpfile[sizeof(tmp)+1];
610 strcpy(tmpfile,tmp); 618 strcpy(tmpfile,tmp);
611 int f = mkstemp(tmpfile); 619 int f = mkstemp(tmpfile);
612 close(f); 620 close(f);
613 //qDebug("TMPFILE:%s", tmpfile); 621 //odebug << "TMPFILE:" << tmpfile << "" << oendl;
614 if (image->save(tmpfile,"PNG")) 622 if (image->save(tmpfile,"PNG"))
615 { 623 {
616 QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)"); 624 QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)");
617 e << QString(tmpfile); 625 e << QString(tmpfile);
618 } 626 }
619 Global::statusMessage("Opening image"); 627 Global::statusMessage("Opening image");
620 sleep(5); 628 sleep(5);
621 delete image; 629 delete image;
622 unlink(tmpfile); 630 unlink(tmpfile);
623*/ 631*/
624} 632}
625 633
626#endif 634#endif
627 635
628unsigned short CPlucker_base::finduid(unsigned short urlid) 636unsigned short CPlucker_base::finduid(unsigned short urlid)
629{ 637{
630// //qDebug("Finding %u", urlid); 638// //odebug << "Finding " << urlid << "" << oendl;
631 unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); 639 unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords);
632 unsigned short jmid = (jmin+jmax) >> 1; 640 unsigned short jmid = (jmin+jmax) >> 1;
633 while (jmax - jmin > 1) 641 while (jmax - jmin > 1)
634 { 642 {
635 gotorecordnumber(jmid); 643 gotorecordnumber(jmid);
636 UInt16 thishdr_uid, thishdr_nParagraphs; 644 UInt16 thishdr_uid, thishdr_nParagraphs;
637 UInt32 thishdr_size; 645 UInt32 thishdr_size;
638 UInt8 thishdr_type, thishdr_reserved; 646 UInt8 thishdr_type, thishdr_reserved;
639 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 647 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
640 unsigned short luid = thishdr_uid; 648 unsigned short luid = thishdr_uid;
641 ////qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); 649// //odebug << "" << jmin << " " << jmid << " " << jmax << " : " << urlid << "" << oendl;
642 if (luid == urlid) 650 if (luid == urlid)
643 { 651 {
644 return jmid; 652 return jmid;
645 } 653 }
646 if (luid < urlid) 654 if (luid < urlid)
647 { 655 {
648 jmin = jmid; 656 jmin = jmid;
649 } 657 }
650 else 658 else
651 { 659 {
652 jmax = jmid; 660 jmax = jmid;
653 } 661 }
654 jmid = (jmin+jmax) >> 1; 662 jmid = (jmin+jmax) >> 1;
655 } 663 }
656 gotorecordnumber(jmin); 664 gotorecordnumber(jmin);
657 UInt16 thishdr_uid, thishdr_nParagraphs; 665 UInt16 thishdr_uid, thishdr_nParagraphs;
658 UInt32 thishdr_size; 666 UInt32 thishdr_size;
659 UInt8 thishdr_type, thishdr_reserved; 667 UInt8 thishdr_type, thishdr_reserved;
660 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 668 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
661 unsigned short luid = thishdr_uid; 669 unsigned short luid = thishdr_uid;
662 //qDebug("jmin at end:%u,%u", jmin, luid); 670 //odebug << "jmin at end:" << jmin << "," << luid << "" << oendl;
663 if (luid == urlid) 671 if (luid == urlid)
664 { 672 {
665 return jmin; 673 return jmin;
666 } 674 }
667 gotorecordnumber(jmax); 675 gotorecordnumber(jmax);
668 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 676 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
669 luid = thishdr_uid; 677 luid = thishdr_uid;
670 //qDebug("jmax at end:%u,%u", jmax, luid); 678 //odebug << "jmax at end:" << jmax << "," << luid << "" << oendl;
671 if (luid == urlid) 679 if (luid == urlid)
672 { 680 {
673 return jmax; 681 return jmax;
674 } 682 }
675 //qDebug("Couldn't find %u", urlid); 683 //odebug << "Couldn't find " << urlid << "" << oendl;
676 return 0; // Not found! 684 return 0; // Not found!
677} 685}
678 686
679 687
680void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) 688void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
681{ 689{
682 unsigned short sz = 0; 690 unsigned short sz = 0;
683 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) 691 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++)
684 { 692 {
685 sz++; 693 sz++;
686 } 694 }
687 size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long); 695 size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long);
688 unsigned char* newdata = new unsigned char[newlen]; 696 unsigned char* newdata = new unsigned char[newlen];
689 unsigned char* pdata = newdata; 697 unsigned char* pdata = newdata;
690 memcpy(newdata, src, srclen); 698 memcpy(newdata, src, srclen);
691 newdata += srclen; 699 newdata += srclen;
692 memcpy(newdata, &sz, sizeof(sz)); 700 memcpy(newdata, &sz, sizeof(sz));
693 newdata += sizeof(sz); 701 newdata += sizeof(sz);
694#ifdef _WINDOWS 702#ifdef _WINDOWS
695 for (it = visited.begin(); it != visited.end(); it++) 703 for (it = visited.begin(); it != visited.end(); it++)
696#else 704#else
697 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) 705 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++)
698#endif 706#endif
699 { 707 {
700 unsigned long t = *it; 708 unsigned long t = *it;
701 //qDebug("[%u]", t); 709// odebug << "[" << t << "]" << oendl;
702 memcpy(newdata, &t, sizeof(t)); 710 memcpy(newdata, &t, sizeof(t));
703 newdata += sizeof(t); 711 newdata += sizeof(t);
704 } 712 }
705 m_nav.setSaveData(data, len, pdata, newlen); 713 m_nav.setSaveData(data, len, pdata, newlen);
706 delete [] pdata; 714 delete [] pdata;
707} 715}
708 716
709void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen) 717void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen)
710{ 718{
711 unsigned short sz; 719 unsigned short sz;
712 if (srclen >= sizeof(sz)) 720 if (srclen >= sizeof(sz))
713 { 721 {
714 memcpy(&sz, src, sizeof(sz)); 722 memcpy(&sz, src, sizeof(sz));
715 src += sizeof(sz); 723 src += sizeof(sz);
716 srclen -= sizeof(sz); 724 srclen -= sizeof(sz);
717 } 725 }
718 for (int i = 0; i < sz; i++) 726 for (int i = 0; i < sz; i++)
719 { 727 {
720 unsigned long t; 728 unsigned long t;
721 if (srclen >= sizeof(t)) 729 if (srclen >= sizeof(t))
722 { 730 {
723 memcpy(&t, src, sizeof(t)); 731 memcpy(&t, src, sizeof(t));
724 // qDebug("[%u]", t); 732// odebug << "[" << t << "]" << oendl;
725 visited.push_front(t); 733 visited.push_front(t);
726 src += sizeof(t); 734 src += sizeof(t);
727 srclen -= sizeof(t); 735 srclen -= sizeof(t);
728 } 736 }
729 else 737 else
730 { 738 {
731 QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself"); 739 QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself");
732 break; 740 break;
733 } 741 }
734 } 742 }
735 m_nav.putSaveData(src, srclen); 743 m_nav.putSaveData(src, srclen);
736} 744}
737 745
738int CPlucker_base::OpenFile(const char *src) 746int CPlucker_base::OpenFile(const char *src)
739{ 747{
740 m_lastBreak = 0; 748 m_lastBreak = 0;
741 if (!Cpdb::openfile(src)) 749 if (!Cpdb::openfile(src))
742 { 750 {
743 return -1; 751 return -1;
744 } 752 }
745 753
746 if (!CorrectDecoder()) return -1; 754 if (!CorrectDecoder()) return -1;
747 755
748 gotorecordnumber(0); 756 gotorecordnumber(0);
749 fread(&hdr0, 1, 6, fin); 757 fread(&hdr0, 1, 6, fin);
750 setbuffersize(); 758 setbuffersize();
751 compressedtextbuffer = new UInt8[compressedbuffersize]; 759 compressedtextbuffer = new UInt8[compressedbuffersize];
752 expandedtextbuffer = new UInt8[buffersize]; 760 expandedtextbuffer = new UInt8[buffersize];
753 761
754 //qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); 762 //odebug << "Total number of records:" << ntohs(head.recordList.numRecords) << "" << oendl;
755 763
756 unsigned int nrecs = ntohs(hdr0.nRecords); 764 unsigned int nrecs = ntohs(hdr0.nRecords);
757 //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); 765 //odebug << "Version " << ntohs(hdr0.version) << ", no. recs " << nrecs << "" << oendl;
758 UInt16 homerecid = 1; 766 UInt16 homerecid = 1;
759 for (unsigned int i = 0; i < nrecs; i++) 767 for (unsigned int i = 0; i < nrecs; i++)
760 { 768 {
761 UInt16 id, name; 769 UInt16 id, name;
762 fread(&name, 1, sizeof(name), fin); 770 fread(&name, 1, sizeof(name), fin);
763 fread(&id, 1, sizeof(id), fin); 771 fread(&id, 1, sizeof(id), fin);
764 //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); 772 //odebug << "N:" << ntohs(name) << ", I:" << ntohs(id) << "" << oendl;
765 if (ntohs(name) == 0) homerecid = ntohs(id); 773 if (ntohs(name) == 0) homerecid = ntohs(id);
766 } 774 }
767 775
768 textlength = 0; 776 textlength = 0;
769 for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) 777 for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
770 { 778 {
771 gotorecordnumber(recptr); 779 gotorecordnumber(recptr);
772 UInt16 thishdr_uid, thishdr_nParagraphs; 780 UInt16 thishdr_uid, thishdr_nParagraphs;
773 UInt32 thishdr_size; 781 UInt32 thishdr_size;
774 UInt8 thishdr_type, thishdr_reserved; 782 UInt8 thishdr_type, thishdr_reserved;
775 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 783 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
776 if (thishdr_uid == homerecid) 784 if (thishdr_uid == homerecid)
777 { 785 {
778 m_homepos = textlength; 786 m_homepos = textlength;
779 break; 787 break;
780 } 788 }
781 if (thishdr_type < 2) textlength += thishdr_size; 789 if (thishdr_type < 2) textlength += thishdr_size;
782 } 790 }
783 textlength = 0; 791 textlength = 0;
784 home(); 792 home();
785#ifdef LOCALPICTURES 793#ifdef LOCALPICTURES
786 if (m_viewer == NULL) 794 if (m_viewer == NULL)
787 { 795 {
788 m_viewer = new QScrollView(NULL); 796 m_viewer = new QScrollView(NULL);
789 m_picture = new QWidget(m_viewer->viewport()); 797 m_picture = new QWidget(m_viewer->viewport());
790 m_viewer->addChild(m_picture); 798 m_viewer->addChild(m_picture);
791 } 799 }
792#endif 800#endif
793 return 0; 801 return 0;
794 802
795} 803}
796 804
797QImage* CPlucker_base::getimg(UInt16 tgt) 805QImage* CPlucker_base::getimg(UInt16 tgt)
798{ 806{
799 size_t reclen; 807 size_t reclen;
800 UInt16 thisrec = finduid(tgt); 808 UInt16 thisrec = finduid(tgt);
801 reclen = recordlength(thisrec); 809 reclen = recordlength(thisrec);
802 gotorecordnumber(thisrec); 810 gotorecordnumber(thisrec);
803 UInt16 thishdr_uid, thishdr_nParagraphs; 811 UInt16 thishdr_uid, thishdr_nParagraphs;
804 UInt32 thishdr_size; 812 UInt32 thishdr_size;
805 UInt8 thishdr_type, thishdr_reserved; 813 UInt8 thishdr_type, thishdr_reserved;
806 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 814 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
807 reclen -= HeaderSize(); 815 reclen -= HeaderSize();
808 816
809 UInt32 imgsize = thishdr_size; 817 UInt32 imgsize = thishdr_size;
810 UInt8* imgbuffer = new UInt8[imgsize]; 818 UInt8* imgbuffer = new UInt8[imgsize];
811 819
812 Expand(reclen, thishdr_type, imgbuffer, imgsize); 820 Expand(reclen, thishdr_type, imgbuffer, imgsize);
813 821
814 return imagefromdata(imgbuffer, imgsize); 822 return imagefromdata(imgbuffer, imgsize);
815} 823}
816 824
817linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) 825linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
818{ 826{
819 visited.push_front(n); 827 visited.push_front(n);
820 UInt16 tuid = (n >> 16); 828 UInt16 tuid = (n >> 16);
821 n &= 0xffff; 829 n &= 0xffff;
822// //qDebug("Hyper:<%u,%u>", tuid, n); 830// //odebug << "Hyper:<" << tuid << "," << n << ">" << oendl;
823 UInt16 thisrec = 1; 831 UInt16 thisrec = 1;
824 currentpos = 0; 832 currentpos = 0;
825 gotorecordnumber(thisrec); 833 gotorecordnumber(thisrec);
826 UInt16 thishdr_uid, thishdr_nParagraphs; 834 UInt16 thishdr_uid, thishdr_nParagraphs;
827 UInt32 thishdr_size; 835 UInt32 thishdr_size;
828 UInt8 thishdr_type, thishdr_reserved; 836 UInt8 thishdr_type, thishdr_reserved;
829 while (1) 837 while (1)
830 { 838 {
831 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 839 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
832 if (tuid == thishdr_uid) break; 840 if (tuid == thishdr_uid) break;
833 if (thishdr_type < 2) currentpos += thishdr_size; 841 if (thishdr_type < 2) currentpos += thishdr_size;
834 ////qDebug("hyper-cp:%u", currentpos); 842// //odebug << "hyper-cp:" << currentpos << "" << oendl;
835 thisrec++; 843 thisrec++;
836 if (thisrec >= ntohs(head.recordList.numRecords)) 844 if (thisrec >= ntohs(head.recordList.numRecords))
837 { 845 {
838 char *turl = geturl(tuid); 846 char *turl = geturl(tuid);
839 if (turl == NULL) 847 if (turl == NULL)
840 { 848 {
841 QMessageBox::information(NULL, 849 QMessageBox::information(NULL,
842 QString(PROGNAME), 850 QString(PROGNAME),
843 QString("Couldn't find link") 851 QString("Couldn't find link")
844 ); 852 );
845 } 853 }
846 else 854 else
847 { 855 {
848 wrd = turl; 856 wrd = turl;
849#ifdef USEQPE 857#ifdef USEQPE
850 if (wrd.length() > 10) 858 if (wrd.length() > 10)
851 { 859 {
852 Global::statusMessage(wrd.left(8) + ".."); 860 Global::statusMessage(wrd.left(8) + "..");
853 } 861 }
854 else 862 else
855 { 863 {
856 Global::statusMessage(wrd); 864 Global::statusMessage(wrd);
857 } 865 }
858#else 866#else
859#endif /* USEQPE */ 867#endif /* USEQPE */
860 //qDebug("Link:%s", (const char*)wrd); 868 //odebug << "Link:" << wrd << "" << oendl;
861 // setlink(fn, wrd); 869// setlink(fn, wrd);
862 delete [] turl; 870 delete [] turl;
863 } 871 }
864 return eNone; 872 return eNone;
865 } 873 }
866 gotorecordnumber(thisrec); 874 gotorecordnumber(thisrec);
867 } 875 }
868 if (thishdr_type > 1) 876 if (thishdr_type > 1)
869 { 877 {
870 if (thishdr_type == 4) 878 if (thishdr_type == 4)
871 { 879 {
872 QMessageBox::information(NULL, 880 QMessageBox::information(NULL,
873 QString(PROGNAME), 881 QString(PROGNAME),
874 QString("Mailto links\nnot yet supported (2)")); 882 QString("Mailto links\nnot yet supported (2)"));
875 } 883 }
876 else 884 else
877 { 885 {
878 if (thishdr_type > 3) 886 if (thishdr_type > 3)
879 { 887 {
880 QMessageBox::information(NULL, 888 QMessageBox::information(NULL,
881 QString(PROGNAME), 889 QString(PROGNAME),
882 QString("External links\nnot yet supported (2)") 890 QString("External links\nnot yet supported (2)")
883 ); 891 );
884 return eNone; 892 return eNone;
885 } 893 }
886 else 894 else
887 { 895 {
888#ifdef LOCALPICTURES 896#ifdef LOCALPICTURES
889 showimg(tuid); 897 showimg(tuid);
890#else 898#else
891 return ePicture; 899 return ePicture;
892#endif 900#endif
893 } 901 }
894 } 902 }
895 return eNone; 903 return eNone;
896 } 904 }
897/* 905/*
898 if (thishdr_type == 2 || thishdr_type == 3) 906 if (thishdr_type == 2 || thishdr_type == 3)
899 { 907 {
900 expandimg(thisrec); 908 expandimg(thisrec);
901 909
902 } 910 }
903*/ 911*/
904 else 912 else
905 { 913 {
906 expand(thisrec); 914 expand(thisrec);
907 if (n != 0) 915 if (n != 0)
908 { 916 {
909 if (n >= m_nParas) 917 if (n >= m_nParas)
910 { 918 {
911 QMessageBox::information(NULL, 919 QMessageBox::information(NULL,
912 QString(PROGNAME), 920 QString(PROGNAME),
913 QString("Error in link\nPara # too big") 921 QString("Error in link\nPara # too big")
914 ); 922 );
915 return eNone; 923 return eNone;
916 } 924 }
917 unsigned int noff = 0; 925 unsigned int noff = 0;
918 for (unsigned int i = 0; i < n; i++) noff += m_ParaOffsets[i]; 926 for (unsigned int i = 0; i < n; i++) noff += m_ParaOffsets[i];
919 n = noff; 927 n = noff;
920 } 928 }
921 if (n > thishdr_size) 929 if (n > thishdr_size)
922 { 930 {
923 QMessageBox::information(NULL, 931 QMessageBox::information(NULL,
924 QString(PROGNAME), 932 QString(PROGNAME),
925 QString("Error in link\nOffset too big") 933 QString("Error in link\nOffset too big")
926 ); 934 );
927 return eNone; 935 return eNone;
928 } 936 }
929 //qDebug("Hyper:<%u,%u>", tuid, n); 937 //odebug << "Hyper:<" << tuid << "," << n << ">" << oendl;
930 while (bufferpos < n && bufferpos < buffercontent) getch_base(true); 938 while (bufferpos < n && bufferpos < buffercontent) getch_base(true);
931/* // This is faster but the alignment doesn't get set 939/* // This is faster but the alignment doesn't get set
932 mystyle.unset(); 940 mystyle.unset();
933 bufferpos = n; 941 bufferpos = n;
934 currentpos += n; 942 currentpos += n;
935 while (bufferpos >= m_nextPara && m_nextPara >= 0) 943 while (bufferpos >= m_nextPara && m_nextPara >= 0)
936 { 944 {
937 UInt16 attr = m_ParaAttrs[m_nextParaIndex]; 945 UInt16 attr = m_ParaAttrs[m_nextParaIndex];
938 m_nextParaIndex++; 946 m_nextParaIndex++;
939 if (m_nextParaIndex == m_nParas) 947 if (m_nextParaIndex == m_nParas)
940 { 948 {
941 m_nextPara = -1; 949 m_nextPara = -1;
942 } 950 }
943 else 951 else
944 { 952 {
945 m_nextPara += m_ParaOffsets[m_nextParaIndex]; 953 m_nextPara += m_ParaOffsets[m_nextParaIndex];
946 } 954 }
947 } 955 }
948*/ 956*/
949 } 957 }
950 return eLink; 958 return eLink;
951} 959}
952 960
953tchar CPlucker_base::getch_base(bool fast) 961tchar CPlucker_base::getch_base(bool fast)
954{ 962{
955 int ch = bgetch(); 963 int ch = bgetch();
956 while (ch == 0) 964 while (ch == 0)
957 { 965 {
958 ch = bgetch(); 966 ch = bgetch();
959 ////qDebug("Function:%x", ch); 967// //odebug << "Function:" << ch << "" << oendl;
960 switch (ch) 968 switch (ch)
961 { 969 {
962 case 0x38: 970 case 0x38:
963 // //qDebug("Break:%u", locate()); 971// //odebug << "Break:" << locate() << "" << oendl;
964 if (m_lastBreak == locate()) 972 if (m_lastBreak == locate())
965 { 973 {
966 ch = bgetch(); 974 ch = bgetch();
967 } 975 }
968 else 976 else
969 { 977 {
970 ch = 10; 978 ch = 10;
971 } 979 }
972 m_lastBreak = locate(); 980 m_lastBreak = locate();
973 break; 981 break;
974 case 0x0a: 982 case 0x0a:
975 case 0x0c: 983 case 0x0c:
976 { 984 {
977 unsigned long ln = 0; 985 unsigned long ln = 0;
978 int skip = ch & 7; 986 int skip = ch & 7;
979 for (int i = 0; i < 2; i++) 987 for (int i = 0; i < 2; i++)
980 { 988 {
981 int ch = bgetch(); 989 int ch = bgetch();
982 ln = (ln << 8) + ch; 990 ln = (ln << 8) + ch;
983 // //qDebug("ch:%d, ln:%u", ch, ln); 991// //odebug << "ch:" << ch << ", ln:" << ln << "" << oendl;
984 } 992 }
985 if (skip == 2) 993 if (skip == 2)
986 { 994 {
987 ln <<= 16; 995 ln <<= 16;
988 } 996 }
989 else 997 else
990 { 998 {
991 for (int i = 0; i < 2; i++) 999 for (int i = 0; i < 2; i++)
992 { 1000 {
993 int ch = bgetch(); 1001 int ch = bgetch();
994 ln = (ln << 8) + ch; 1002 ln = (ln << 8) + ch;
995 // //qDebug("ch:%d, ln:%u", ch, ln); 1003// //odebug << "ch:" << ch << ", ln:" << ln << "" << oendl;
996 } 1004 }
997 } 1005 }
998 // //qDebug("ln:%u", ln); 1006// //odebug << "ln:" << ln << "" << oendl;
999 mystyle.setLink(true); 1007 mystyle.setLink(true);
1000 mystyle.setData(ln); 1008 mystyle.setData(ln);
1001 // mystyle.setColour(255, 0, 0); 1009// mystyle.setColour(255, 0, 0);
1002 bool hasseen = false; 1010 bool hasseen = false;
1003 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) 1011 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++)
1004 { 1012 {
1005 if (*it == ln) 1013 if (*it == ln)
1006 { 1014 {
1007 hasseen = true; 1015 hasseen = true;
1008 break; 1016 break;
1009 } 1017 }
1010 } 1018 }
1011 if (hasseen) 1019 if (hasseen)
1012 { 1020 {
1013 mystyle.setStrikethru(); 1021 mystyle.setStrikethru();
1014 } 1022 }
1015 else 1023 else
1016 { 1024 {
1017 mystyle.setUnderline(); 1025 mystyle.setUnderline();
1018 } 1026 }
1019 ch = bgetch(); 1027 ch = bgetch();
1020 } 1028 }
1021 break; 1029 break;
1022 case 0x08: 1030 case 0x08:
1023 ch = bgetch(); 1031 ch = bgetch();
1024 // mystyle.setColour(0, 0, 0); 1032// mystyle.setColour(0, 0, 0);
1025 mystyle.unsetUnderline(); 1033 mystyle.unsetUnderline();
1026 mystyle.unsetStrikethru(); 1034 mystyle.unsetStrikethru();
1027 mystyle.setLink(false); 1035 mystyle.setLink(false);
1028 mystyle.setData(0); 1036 mystyle.setData(0);
1029 break; 1037 break;
1030 case 0x40: 1038 case 0x40:
1031 mystyle.setItalic(); 1039 mystyle.setItalic();
1032 ch = bgetch(); 1040 ch = bgetch();
1033 break; 1041 break;
1034 case 0x48: 1042 case 0x48:
1035 mystyle.unsetItalic(); 1043 mystyle.unsetItalic();
1036 ch = bgetch(); 1044 ch = bgetch();
1037 break; 1045 break;
1038 case 0x11: 1046 case 0x11:
1039 { 1047 {
1040 ch = bgetch(); 1048 ch = bgetch();
1041 // //qDebug("Font:%d",ch); 1049// //odebug << "Font:" << ch << "" << oendl;
1042 mystyle.setVOffset(0); 1050 mystyle.setVOffset(0);
1043 mystyle.unsetMono(); 1051 mystyle.unsetMono();
1044 mystyle.unsetBold(); 1052 mystyle.unsetBold();
1045 mystyle.setFontSize(0); 1053 mystyle.setFontSize(0);
1046 switch (ch) 1054 switch (ch)
1047 { 1055 {
1048 case 0: 1056 case 0:
1049 break; 1057 break;
1050 case 1: 1058 case 1:
1051 mystyle.setBold(); 1059 mystyle.setBold();
1052 mystyle.setFontSize(3); 1060 mystyle.setFontSize(3);
1053 break; 1061 break;
1054 case 2: 1062 case 2:
1055 mystyle.setBold(); 1063 mystyle.setBold();
1056 mystyle.setFontSize(2); 1064 mystyle.setFontSize(2);
1057 break; 1065 break;
1058 case 3: 1066 case 3:
1059 mystyle.setBold(); 1067 mystyle.setBold();
1060 mystyle.setFontSize(1); 1068 mystyle.setFontSize(1);
1061 break; 1069 break;
1062 case 4: 1070 case 4:
1063 mystyle.setBold(); 1071 mystyle.setBold();
1064 break; 1072 break;
1065 case 5: 1073 case 5:
1066 mystyle.setBold(); 1074 mystyle.setBold();
1067 break; 1075 break;
1068 case 6: 1076 case 6:
1069 mystyle.setBold(); 1077 mystyle.setBold();
1070 break; 1078 break;
1071 case 7: 1079 case 7:
1072 mystyle.setBold(); 1080 mystyle.setBold();
1073 break; 1081 break;
1074 case 8: // should be fixed width 1082 case 8: // should be fixed width
1075 //qDebug("Trying fixed width"); 1083 //odebug << "Trying fixed width" << oendl;
1076 mystyle.setMono(); 1084 mystyle.setMono();
1077 break; 1085 break;
1078 case 9: 1086 case 9:
1079 mystyle.setFontSize(-1); 1087 mystyle.setFontSize(-1);
1080 break; 1088 break;
1081 case 10: 1089 case 10:
1082 mystyle.setFontSize(-2); 1090 mystyle.setFontSize(-2);
1083 mystyle.setVOffset(1); 1091 mystyle.setVOffset(1);
1084 break; 1092 break;
1085 case 11: 1093 case 11:
1086 mystyle.setFontSize(-2); 1094 mystyle.setFontSize(-2);
1087 mystyle.setVOffset(-1); 1095 mystyle.setVOffset(-1);
1088 break; 1096 break;
1089 default: 1097 default:
1090 qDebug("Unrecognised font"); 1098 odebug << "Unrecognised font" << oendl;
1091 break; 1099 break;
1092 } 1100 }
1093 ch = bgetch(); 1101 ch = bgetch();
1094 } 1102 }
1095 break; 1103 break;
1096 case 0x29: 1104 case 0x29:
1097 ch = bgetch(); 1105 ch = bgetch();
1098 switch (ch) 1106 switch (ch)
1099 { 1107 {
1100 case 0: 1108 case 0:
1101 mystyle.setLeftJustify(); 1109 mystyle.setLeftJustify();
1102 // //qDebug("left"); 1110// //odebug << "left" << oendl;
1103 break; 1111 break;
1104 case 1: 1112 case 1:
1105 mystyle.setRightJustify(); 1113 mystyle.setRightJustify();
1106 // //qDebug("right"); 1114// //odebug << "right" << oendl;
1107 break; 1115 break;
1108 case 2: 1116 case 2:
1109 mystyle.setCentreJustify(); 1117 mystyle.setCentreJustify();
1110 // //qDebug("centre"); 1118// //odebug << "centre" << oendl;
1111 break; 1119 break;
1112 case 3: 1120 case 3:
1113 mystyle.setFullJustify(); 1121 mystyle.setFullJustify();
1114 // //qDebug("full"); 1122// //odebug << "full" << oendl;
1115 break; 1123 break;
1116 1124
1117 } 1125 }
1118 ch = bgetch(); 1126 ch = bgetch();
1119 break; 1127 break;
1120 case 0x53: 1128 case 0x53:
1121 { 1129 {
1122 int r = bgetch(); 1130 int r = bgetch();
1123 int g = bgetch(); 1131 int g = bgetch();
1124 int b = bgetch(); 1132 int b = bgetch();
1125 mystyle.setColour(r,g,b); 1133 mystyle.setColour(r,g,b);
1126 ch = bgetch(); 1134 ch = bgetch();
1127 } 1135 }
1128 break; 1136 break;
1129 case 0x1a: 1137 case 0x1a:
1130 case 0x5c: 1138 case 0x5c:
1131 { 1139 {
1132 bool hasalternate = (ch == 0x5c); 1140 bool hasalternate = (ch == 0x5c);
1133 UInt16 ir = bgetch(); 1141 UInt16 ir = bgetch();
1134 ir = (ir << 8) + bgetch(); 1142 ir = (ir << 8) + bgetch();
1135 if (hasalternate) 1143 if (hasalternate)
1136 { 1144 {
1137 //qDebug("Alternate image:%x", ir); 1145 //odebug << "Alternate image:" << ir << "" << oendl;
1138 UInt16 ir2 = bgetch(); 1146 UInt16 ir2 = bgetch();
1139 ir2 = (ir2 << 8) + bgetch(); 1147 ir2 = (ir2 << 8) + bgetch();
1140 if (!fast) mystyle.setPicture(true, expandimg(ir2, true), true, ir << 16); 1148 if (!fast) mystyle.setPicture(true, expandimg(ir2, true), true, ir << 16);
1141#ifdef LOCALPICTURES 1149#ifdef LOCALPICTURES
1142 UInt32 ln = ir; 1150 UInt32 ln = ir;
1143 ln <<= 16; 1151 ln <<= 16;
1144 mystyle.setLink(true); 1152 mystyle.setLink(true);
1145 mystyle.setData(ln); 1153 mystyle.setData(ln);
1146#endif 1154#endif
1147 } 1155 }
1148 else 1156 else
1149 { 1157 {
1150 if (!fast) mystyle.setPicture(true, expandimg(ir)); 1158 if (!fast) mystyle.setPicture(true, expandimg(ir));
1151 } 1159 }
1152 // if (mystyle.getLink()) qDebug("Picture link!"); 1160// if (mystyle.getLink()) odebug << "Picture link!" << oendl;
1153 ch = '#'; 1161 ch = '#';
1154 } 1162 }
1155 // ch = bgetch(); 1163// ch = bgetch();
1156 break; 1164 break;
1157 case 0x33: 1165 case 0x33:
1158 { 1166 {
1159 UInt8 h = bgetch(); 1167 UInt8 h = bgetch();
1160 UInt8 wc = bgetch(); 1168 UInt8 wc = bgetch();
1161 UInt8 pc = bgetch(); 1169 UInt8 pc = bgetch();
1162 UInt16 w = wc; 1170 UInt16 w = wc;
1163 // //qDebug("h,w,pc [%u, %u, %u]", h, w, pc); 1171// //odebug << "h,w,pc [" << h << ", " << w << ", " << pc << "]" << oendl;
1164 if (w == 0) 1172 if (w == 0)
1165 { 1173 {
1166 w = (m_scrWidth*(unsigned long)pc)/100; 1174 w = (m_scrWidth*(unsigned long)pc)/100;
1167 } 1175 }
1168 if (w == 0) w = m_scrWidth; 1176 if (w == 0) w = m_scrWidth;
1169 mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); 1177 mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue()));
1170 // if (mystyle.getLink()) //qDebug("hRule link!"); 1178// if (mystyle.getLink()) //odebug << "hRule link!" << oendl;
1171 ch = '#'; 1179 ch = '#';
1172 } 1180 }
1173 break; 1181 break;
1174 case 0x60: 1182 case 0x60:
1175 mystyle.setUnderline(); 1183 mystyle.setUnderline();
1176 ch = bgetch(); 1184 ch = bgetch();
1177 break; 1185 break;
1178 case 0x68: 1186 case 0x68:
1179 mystyle.unsetUnderline(); 1187 mystyle.unsetUnderline();
1180 ch = bgetch(); 1188 ch = bgetch();
1181 break; 1189 break;
1182 case 0x22: 1190 case 0x22:
1183 ch = bgetch(); 1191 ch = bgetch();
1184 mystyle.setLeftMargin(ch); 1192 mystyle.setLeftMargin(ch);
1185 // //qDebug("Left margin:%d", ch); 1193// //odebug << "Left margin:" << ch << "" << oendl;
1186 ch = bgetch(); 1194 ch = bgetch();
1187 mystyle.setRightMargin(ch); 1195 mystyle.setRightMargin(ch);
1188 // //qDebug("Right margin:%d", ch); 1196// //odebug << "Right margin:" << ch << "" << oendl;
1189 ch = bgetch(); 1197 ch = bgetch();
1190 break; 1198 break;
1191 case 0x70: 1199 case 0x70:
1192 mystyle.setStrikethru(); 1200 mystyle.setStrikethru();
1193 ch = bgetch(); 1201 ch = bgetch();
1194 break; 1202 break;
1195 case 0x78: 1203 case 0x78:
1196 mystyle.unsetStrikethru(); 1204 mystyle.unsetStrikethru();
1197 ch = bgetch(); 1205 ch = bgetch();
1198 break; 1206 break;
1199 case 0x83: 1207 case 0x83:
1200 { 1208 {
1201 int tlen = bgetch(); 1209 int tlen = bgetch();
1202 ch = bgetch(); 1210 ch = bgetch();
1203 ch <<= 8; 1211 ch <<= 8;
1204 ch |= (tchar)bgetch(); 1212 ch |= (tchar)bgetch();
1205 for (int i = 0; i < tlen; i++) bgetch(); 1213 for (int i = 0; i < tlen; i++) bgetch();
1206 //qDebug("Function 83"); 1214 //odebug << "Function 83" << oendl;
1207 } 1215 }
1208 break; 1216 break;
1209 case 0x85: 1217 case 0x85:
1210 default: 1218 default:
1211 qDebug("Function:%x NOT IMPLEMENTED", ch); 1219 odebug << "Function:" << ch << " NOT IMPLEMENTED" << oendl;
1212 { 1220 {
1213 int skip = ch & 7; 1221 int skip = ch & 7;
1214 for (int i = 0; i < skip; i++) 1222 for (int i = 0; i < skip; i++)
1215 { 1223 {
1216 ch = bgetch(); 1224 ch = bgetch();
1217 //qDebug("Arg %d, %d", i, ch); 1225 //odebug << "Arg " << i << ", " << ch << "" << oendl;
1218 } 1226 }
1219 ch = bgetch(); 1227 ch = bgetch();
1220 } 1228 }
1221 } 1229 }
1222 } 1230 }
1223 1231
1224 if (m_lastIsBreak && !mystyle.isMono()) 1232 if (m_lastIsBreak && !mystyle.isMono())
1225 { 1233 {
1226 while (ch == ' ') 1234 while (ch == ' ')
1227 { 1235 {
1228 ch = getch(false); 1236 ch = getch(false);
1229 } 1237 }
1230 } 1238 }
1231 1239
1232 m_lastIsBreak = (ch == 10); 1240 m_lastIsBreak = (ch == 10);
1233 1241
1234 return (ch == EOF) ? UEOF : ch; 1242 return (ch == EOF) ? UEOF : ch;
1235} 1243}
diff --git a/noncore/apps/tinykate/libkate/document/katebuffer.cpp b/noncore/apps/tinykate/libkate/document/katebuffer.cpp
index 22a4917..4c15fd0 100644
--- a/noncore/apps/tinykate/libkate/document/katebuffer.cpp
+++ b/noncore/apps/tinykate/libkate/document/katebuffer.cpp
@@ -9,161 +9,162 @@
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License version 2 as published by the Free Software Foundation. 10 License version 2 as published by the Free Software Foundation.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23 23
24#include "katebuffer.h" 24#include "katebuffer.h"
25#include "kdebug.h"
25 26
26// Includes for reading file 27/* OPIE */
27#include <sys/types.h> 28#include <opie2/odebug.h>
28#include <sys/stat.h>
29#include <fcntl.h>
30#include <errno.h>
31#include <unistd.h>
32 29
30/* QT */
33#include <qfile.h> 31#include <qfile.h>
34#include <qtextstream.h> 32#include <qtextstream.h>
35
36#include <qtimer.h> 33#include <qtimer.h>
37#include <qtextcodec.h> 34#include <qtextcodec.h>
38 35
39// 36/* STD */
40 37// Includes for reading file
38#include <sys/types.h>
39#include <sys/stat.h>
40#include <fcntl.h>
41#include <errno.h>
42#include <unistd.h>
41#include <assert.h> 43#include <assert.h>
42#include <kdebug.h>
43 44
44/** 45/**
45 * Create an empty buffer. 46 * Create an empty buffer.
46 */ 47 */
47KWBuffer::KWBuffer() 48KWBuffer::KWBuffer()
48{ 49{
49 clear(); 50 clear();
50} 51}
51 52
52void 53void
53KWBuffer::clear() 54KWBuffer::clear()
54{ 55{
55 m_stringListIt=0; 56 m_stringListIt=0;
56 m_stringListCurrent=0; 57 m_stringListCurrent=0;
57 m_stringList.clear(); 58 m_stringList.clear();
58 m_lineCount=1; 59 m_lineCount=1;
59 m_stringListIt = m_stringList.append(new TextLine()); 60 m_stringListIt = m_stringList.append(new TextLine());
60} 61}
61 62
62/** 63/**
63 * Insert a file at line @p line in the buffer. 64 * Insert a file at line @p line in the buffer.
64 */ 65 */
65void 66void
66KWBuffer::insertFile(int line, const QString &file, QTextCodec *codec) 67KWBuffer::insertFile(int line, const QString &file, QTextCodec *codec)
67{ 68{
68 if (line) { 69 if (line) {
69 qDebug("insert File only supports insertion at line 0 == file opening"); 70 odebug << "insert File only supports insertion at line 0 == file opening" << oendl;
70 return; 71 return;
71 } 72 }
72 clear(); 73 clear();
73 QFile iofile(file); 74 QFile iofile(file);
74 iofile.open(IO_ReadOnly); 75 iofile.open(IO_ReadOnly);
75 QTextStream stream(&iofile); 76 QTextStream stream(&iofile);
76 stream.setCodec(codec); 77 stream.setCodec(codec);
77 QString qsl; 78 QString qsl;
78 int count=0; 79 int count=0;
79 for (count=0;((qsl=stream.readLine())!=QString::null);count++) 80 for (count=0;((qsl=stream.readLine())!=QString::null); count++)
80 { 81 {
81 if (count==0) 82 if (count==0)
82 { 83 {
83 (*m_stringListIt)->append(qsl.unicode(),qsl.length()); 84 (*m_stringListIt)->append(qsl.unicode(),qsl.length());
84 } 85 }
85 else 86 else
86 { 87 {
87 TextLine::Ptr tl=new TextLine(); 88 TextLine::Ptr tl=new TextLine();
88 tl ->append(qsl.unicode(),qsl.length()); 89 tl ->append(qsl.unicode(),qsl.length());
89 m_stringListIt=m_stringList.append(tl); 90 m_stringListIt=m_stringList.append(tl);
90 } 91 }
91 } 92 }
92 if (count!=0) 93 if (count!=0)
93 { 94 {
94 m_stringListCurrent=count-1; 95 m_stringListCurrent=count-1;
95 m_lineCount=count; 96 m_lineCount=count;
96 } 97 }
97} 98}
98 99
99void 100void
100KWBuffer::loadFilePart() 101KWBuffer::loadFilePart()
101{ 102{
102} 103}
103 104
104 105
105void 106void
106KWBuffer::insertData(int line, const QByteArray &data, QTextCodec *codec) 107KWBuffer::insertData(int line, const QByteArray &data, QTextCodec *codec)
107{ 108{
108} 109}
109 110
110void 111void
111KWBuffer::slotLoadFile() 112KWBuffer::slotLoadFile()
112{ 113{
113 loadFilePart(); 114 loadFilePart();
114// emit linesChanged(m_totalLines); 115// emit linesChanged(m_totalLines);
115 emit linesChanged(20); 116 emit linesChanged(20);
116} 117}
117 118
118/** 119/**
119 * Return the total number of lines in the buffer. 120 * Return the total number of lines in the buffer.
120 */ 121 */
121int 122int
122KWBuffer::count() 123KWBuffer::count()
123{ 124{
124 qDebug("m_stringList.count %d",m_stringList.count()); 125 odebug << "m_stringList.count " << m_stringList.count() << "" << oendl;
125 return m_lineCount; 126 return m_lineCount;
126 //return m_stringList.count(); 127// return m_stringList.count();
127// return m_totalLines; 128// return m_totalLines;
128} 129}
129 130
130 131
131void KWBuffer::seek(int i) 132void KWBuffer::seek(int i)
132{ 133{
133 if (m_stringListCurrent == i) 134 if (m_stringListCurrent == i)
134 return; 135 return;
135 while(m_stringListCurrent < i) 136 while(m_stringListCurrent < i)
136 { 137 {
137 ++m_stringListCurrent; 138 ++m_stringListCurrent;
138 ++m_stringListIt; 139 ++m_stringListIt;
139 } 140 }
140 while(m_stringListCurrent > i) 141 while(m_stringListCurrent > i)
141 { 142 {
142 --m_stringListCurrent; 143 --m_stringListCurrent;
143 --m_stringListIt; 144 --m_stringListIt;
144 } 145 }
145} 146}
146 147
147 148
148TextLine::Ptr 149TextLine::Ptr
149KWBuffer::line(int i) 150KWBuffer::line(int i)
150{ 151{
151 if (i>=m_stringList.count()) return 0; 152 if (i>=m_stringList.count()) return 0;
152 seek(i); 153 seek(i);
153 return *m_stringListIt; 154 return *m_stringListIt;
154} 155}
155 156
156void 157void
157KWBuffer::insertLine(int i, TextLine::Ptr line) 158KWBuffer::insertLine(int i, TextLine::Ptr line)
158{ 159{
159 seek(i); 160 seek(i);
160 m_stringListIt = m_stringList.insert(m_stringListIt, line); 161 m_stringListIt = m_stringList.insert(m_stringListIt, line);
161 m_stringListCurrent = i; 162 m_stringListCurrent = i;
162 m_lineCount++; 163 m_lineCount++;
163} 164}
164 165
165 166
166void 167void
167KWBuffer::removeLine(int i) 168KWBuffer::removeLine(int i)
168{ 169{
169 seek(i); 170 seek(i);
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp
index 0c742d7..6dc4fd2 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp
@@ -1,95 +1,96 @@
1/*************************************************************************** 1/***************************************************************************
2 katedocument.cpp - description 2 katedocument.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Jan 15 2001 4 begin : Mon Jan 15 2001
5 copyright : (C) 2001 by Christoph "Crossfire" Cullmann 5 copyright : (C) 2001 by Christoph "Crossfire" Cullmann
6 (C) 2002 by Joseph Wenninger 6 (C) 2002 by Joseph Wenninger
7 email : crossfire@babylon2k.de 7 email : crossfire@babylon2k.de
8 jowenn@kde.org 8 jowenn@kde.org
9 9
10***************************************************************************/ 10***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * * 13 * *
14 * This program is free software; you can redistribute it and/or modify * 14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by * 15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or * 16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. * 17 * (at your option) any later version. *
18 * * 18 * *
19 ***************************************************************************/ 19 ***************************************************************************/
20 20
21/* 21/*
22 Copyright (C) 1998, 1999 Jochen Wilhelmy 22 Copyright (C) 1998, 1999 Jochen Wilhelmy
23 digisnap@cs.tu-berlin.de 23 digisnap@cs.tu-berlin.de
24 24
25 This library is free software; you can redistribute it and/or 25 This library is free software; you can redistribute it and/or
26 modify it under the terms of the GNU Library General Public 26 modify it under the terms of the GNU Library General Public
27 License as published by the Free Software Foundation; either 27 License as published by the Free Software Foundation; either
28 version 2 of the License, or (at your option) any later version. 28 version 2 of the License, or (at your option) any later version.
29 29
30 This library is distributed in the hope that it will be useful, 30 This library is distributed in the hope that it will be useful,
31 but WITHOUT ANY WARRANTY; without even the implied warranty of 31 but WITHOUT ANY WARRANTY; without even the implied warranty of
32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 Library General Public License for more details. 33 Library General Public License for more details.
34 34
35 You should have received a copy of the GNU Library General Public License 35 You should have received a copy of the GNU Library General Public License
36 along with this library; see the file COPYING.LIB. If not, write to 36 along with this library; see the file COPYING.LIB. If not, write to
37 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 37 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
38 Boston, MA 02111-1307, USA. 38 Boston, MA 02111-1307, USA.
39*/ 39*/
40 40
41#include "katedocument.h" 41#include "katedocument.h"
42#include "kmessagebox.h"
43#include "kglobal.h"
42 44
45//#include "kcharsets.h"
46#include "kdebug.h"
47//#include "kinstance.h"
43 48
44#include <qfileinfo.h> 49#include "kglobalsettings.h"
45#include <qdatetime.h> 50//#include "kaction.h"
51//#include "kstdaction.h"
46 52
47#include <kmessagebox.h> 53#include "../view/kateview.h"
48#include <qpe/config.h> 54#include "katebuffer.h"
49#include <qstring.h> 55#include "katetextline.h"
50 56
51#include <sys/time.h> 57#include "katecmd.h"
52#include <unistd.h>
53 58
54#include <stdio.h> 59/* OPIE */
60#include <opie2/odebug.h>
61#include <qpe/config.h>
55 62
63/* QT */
64#include <qfileinfo.h>
65#include <qdatetime.h>
66#include <qstring.h>
56#include <qtimer.h> 67#include <qtimer.h>
57#include <qobject.h> 68#include <qobject.h>
58#include <qapplication.h> 69#include <qapplication.h>
59#include <qclipboard.h> 70#include <qclipboard.h>
60#include <qfont.h> 71#include <qfont.h>
61#include <qpainter.h> 72#include <qpainter.h>
62#include <qfile.h> 73#include <qfile.h>
63#include <qtextstream.h> 74#include <qtextstream.h>
64#include <qtextcodec.h> 75#include <qtextcodec.h>
65#include <kglobal.h>
66 76
67//#include <kcharsets.h> 77/* STD */
68#include <kdebug.h> 78#include <sys/time.h>
69//#include <kinstance.h> 79#include <unistd.h>
70 80#include <stdio.h>
71#include <kglobalsettings.h>
72//#include <kaction.h>
73//#include <kstdaction.h>
74
75#include "../view/kateview.h"
76#include "katebuffer.h"
77#include "katetextline.h"
78
79#include "katecmd.h"
80 81
81KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text) 82KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text)
82 : action(a), cursor(cursor), len(len), text(text) { 83 : action(a), cursor(cursor), len(len), text(text) {
83} 84}
84 85
85KateActionGroup::KateActionGroup(PointStruc &aStart, int type) 86KateActionGroup::KateActionGroup(PointStruc &aStart, int type)
86 : start(aStart), action(0L), undoType(type) { 87 : start(aStart), action(0L), undoType(type) {
87} 88}
88 89
89KateActionGroup::~KateActionGroup() { 90KateActionGroup::~KateActionGroup() {
90 KateAction *current, *next; 91 KateAction *current, *next;
91 92
92 current = action; 93 current = action;
93 while (current) { 94 while (current) {
94 next = current->next; 95 next = current->next;
95 delete current; 96 delete current;
@@ -117,55 +118,55 @@ const char * KateActionGroup::typeName(int type)
117 case ugSpell : return "Spell Check"; 118 case ugSpell : return "Spell Check";
118 case ugInsChar : return "Typing"; 119 case ugInsChar : return "Typing";
119 case ugDelChar : return "Delete Text"; 120 case ugDelChar : return "Delete Text";
120 case ugInsLine : return "New Line"; 121 case ugInsLine : return "New Line";
121 case ugDelLine : return "Delete Line"; 122 case ugDelLine : return "Delete Line";
122 } 123 }
123 return ""; 124 return "";
124} 125}
125 126
126const int KateDocument::maxAttribs = 32; 127const int KateDocument::maxAttribs = 32;
127 128
128QStringList KateDocument::searchForList = QStringList(); 129QStringList KateDocument::searchForList = QStringList();
129QStringList KateDocument::replaceWithList = QStringList(); 130QStringList KateDocument::replaceWithList = QStringList();
130 131
131uint KateDocument::uniqueID = 0; 132uint KateDocument::uniqueID = 0;
132 133
133QPtrDict<KateDocument::KateDocPrivate>* KateDocument::d_ptr = 0; 134QPtrDict<KateDocument::KateDocPrivate>* KateDocument::d_ptr = 0;
134 135
135 136
136KateDocument::KateDocument(bool bSingleViewMode, bool bBrowserView, 137KateDocument::KateDocument(bool bSingleViewMode, bool bBrowserView,
137 QWidget *parentWidget, const char *widgetName, 138 QWidget *parentWidget, const char *widgetName,
138 QObject *, const char *) 139 QObject *, const char *)
139 : Kate::Document (), 140 : Kate::Document (),
140 myFont(KGlobalSettings::generalFont()), myFontBold(KGlobalSettings::generalFont()), myFontItalic(KGlobalSettings::generalFont()), myFontBI(KGlobalSettings::generalFont()), 141 myFont(KGlobalSettings::generalFont()), myFontBold(KGlobalSettings::generalFont()), myFontItalic(KGlobalSettings::generalFont()), myFontBI(KGlobalSettings::generalFont()),
141 myFontMetrics (myFont), myFontMetricsBold (myFontBold), myFontMetricsItalic (myFontItalic), myFontMetricsBI (myFontBI), 142 myFontMetrics (myFont), myFontMetricsBold (myFontBold), myFontMetricsItalic (myFontItalic), myFontMetricsBI (myFontBI),
142 hlManager(HlManager::self ()) 143 hlManager(HlManager::self ())
143{ 144{
144 145
145 d(this)->hlSetByUser = false; 146 d(this)->hlSetByUser = false;
146 PreHighlightedTill=0; 147 PreHighlightedTill=0;
147 RequestPreHighlightTill=0; 148 RequestPreHighlightTill=0;
148 149
149 m_bSingleViewMode=bSingleViewMode; 150 m_bSingleViewMode=bSingleViewMode;
150 m_bBrowserView = bBrowserView; 151 m_bBrowserView = bBrowserView;
151 152
152 m_url = QString::null; 153 m_url = QString::null;
153 154
154 // NOTE: QFont::CharSet doesn't provide all the charsets KDE supports 155 // NOTE: QFont::CharSet doesn't provide all the charsets KDE supports
155 // (esp. it doesn't distinguish between UTF-8 and iso10646-1) 156 // (esp. it doesn't distinguish between UTF-8 and iso10646-1)
156 157
157 myEncoding = QString::fromLatin1(QTextCodec::codecForLocale()->name()); 158 myEncoding = QString::fromLatin1(QTextCodec::codecForLocale()->name());
158 159
159 maxLength = -1; 160 maxLength = -1;
160 161
161 setFont (KGlobalSettings::generalFont()); 162 setFont (KGlobalSettings::generalFont());
162 163
163 myDocID = uniqueID; 164 myDocID = uniqueID;
164 uniqueID++; 165 uniqueID++;
165 166
166 myDocName = QString (""); 167 myDocName = QString ("");
167 fileInfo = new QFileInfo (); 168 fileInfo = new QFileInfo ();
168 169
169 myCmd = new KateCmd (this); 170 myCmd = new KateCmd (this);
170 171
171 connect(this,SIGNAL(modifiedChanged()),this,SLOT(slotModChanged())); 172 connect(this,SIGNAL(modifiedChanged()),this,SLOT(slotModChanged()));
@@ -279,68 +280,68 @@ KateDocument::~KateDocument()
279{ 280{
280 m_highlight->release(); 281 m_highlight->release();
281 writeConfig(); 282 writeConfig();
282 283
283 if ( !m_bSingleViewMode ) 284 if ( !m_bSingleViewMode )
284 { 285 {
285 m_views.setAutoDelete( true ); 286 m_views.setAutoDelete( true );
286 m_views.clear(); 287 m_views.clear();
287 m_views.setAutoDelete( false ); 288 m_views.setAutoDelete( false );
288 } 289 }
289 delete_d(this); 290 delete_d(this);
290} 291}
291 292
292void KateDocument::openURL(const QString &filename) 293void KateDocument::openURL(const QString &filename)
293{ 294{
294 295
295 m_file=filename; 296 m_file=filename;
296 fileInfo->setFile (m_file); 297 fileInfo->setFile (m_file);
297 setMTime(); 298 setMTime();
298 299
299 if (!fileInfo->exists() || !fileInfo->isReadable()) 300 if (!fileInfo->exists() || !fileInfo->isReadable())
300 { 301 {
301 qDebug("File doesn't exit or couldn't be read"); 302 odebug << "File doesn't exit or couldn't be read" << oendl;
302 return ; 303 return ;
303 } 304 }
304 305
305 buffer->clear(); 306 buffer->clear();
306#warning fixme 307#warning fixme
307// buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding)); 308// buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding));
308 qDebug("Telling buffer to open file"); 309 odebug << "Telling buffer to open file" << oendl;
309 buffer->insertFile(0, m_file, QTextCodec::codecForLocale()); 310 buffer->insertFile(0, m_file, QTextCodec::codecForLocale());
310 311
311 setMTime(); 312 setMTime();
312 313
313 if (myWordWrap) 314 if (myWordWrap)
314 wrapText (myWordWrapAt); 315 wrapText (myWordWrapAt);
315 316
316 int hl = hlManager->wildcardFind( m_file ); 317 int hl = hlManager->wildcardFind( m_file );
317 318
318 setHighlight(hl); 319 setHighlight(hl);
319 320
320 updateLines(); 321 updateLines();
321 updateViews(); 322 updateViews();
322 323
323 emit fileNameChanged(); 324 emit fileNameChanged();
324 325
325 return ; 326 return ;
326} 327}
327 328
328bool KateDocument::saveFile() 329bool KateDocument::saveFile()
329{ 330{
330 331
331 QFile f( m_file ); 332 QFile f( m_file );
332 if ( !f.open( IO_WriteOnly ) ) 333 if ( !f.open( IO_WriteOnly ) )
333 return false; // Error 334 return false; // Error
334 335
335 QTextStream stream(&f); 336 QTextStream stream(&f);
336 337
337 stream.setEncoding(QTextStream::RawUnicode); // disable Unicode headers 338 stream.setEncoding(QTextStream::RawUnicode); // disable Unicode headers
338#warning fixme 339#warning fixme
339// stream.setCodec(KGlobal::charsets()->codecForName(myEncoding)); 340// stream.setCodec(KGlobal::charsets()->codecForName(myEncoding));
340 stream.setCodec(QTextCodec::codecForLocale()); // this line sets the mapper to the correct codec 341 stream.setCodec(QTextCodec::codecForLocale()); // this line sets the mapper to the correct codec
341 342
342 int maxLine = numLines(); 343 int maxLine = numLines();
343 int line = 0; 344 int line = 0;
344 while(true) 345 while(true)
345 { 346 {
346 stream << getTextLine(line)->getString(); 347 stream << getTextLine(line)->getString();
@@ -598,33 +599,33 @@ void KateDocument::readConfig()
598 KateConfig *config = KGlobal::config(); 599 KateConfig *config = KGlobal::config();
599 config->setGroup("Kate Document"); 600 config->setGroup("Kate Document");
600 601
601 myWordWrap = config->readBoolEntry("Word Wrap On", false); 602 myWordWrap = config->readBoolEntry("Word Wrap On", false);
602 myWordWrapAt = config->readNumEntry("Word Wrap At", 80); 603 myWordWrapAt = config->readNumEntry("Word Wrap At", 80);
603 if (myWordWrap) 604 if (myWordWrap)
604 wrapText (myWordWrapAt); 605 wrapText (myWordWrapAt);
605 606
606 setTabWidth(config->readNumEntry("TabWidth", 8)); 607 setTabWidth(config->readNumEntry("TabWidth", 8));
607 setUndoSteps(config->readNumEntry("UndoSteps", 50)); 608 setUndoSteps(config->readNumEntry("UndoSteps", 50));
608 m_singleSelection = config->readBoolEntry("SingleSelection", false); 609 m_singleSelection = config->readBoolEntry("SingleSelection", false);
609 myEncoding = config->readEntry("Encoding", QString::fromLatin1(QTextCodec::codecForLocale()->name())); 610 myEncoding = config->readEntry("Encoding", QString::fromLatin1(QTextCodec::codecForLocale()->name()));
610 setFont (config->readFontEntry("Font", myFont)); 611 setFont (config->readFontEntry("Font", myFont));
611 612
612 colors[0] = config->readColorEntry("Color Background", colors[0]); 613 colors[0] = config->readColorEntry("Color Background", colors[0]);
613 colors[1] = config->readColorEntry("Color Selected", colors[1]); 614 colors[1] = config->readColorEntry("Color Selected", colors[1]);
614 615
615// config->sync(); 616// config->sync();
616} 617}
617 618
618void KateDocument::writeConfig() 619void KateDocument::writeConfig()
619{ 620{
620 KateConfig *config = KGlobal::config(); 621 KateConfig *config = KGlobal::config();
621 config->setGroup("Kate Document"); 622 config->setGroup("Kate Document");
622 config->writeEntry("Word Wrap On", myWordWrap); 623 config->writeEntry("Word Wrap On", myWordWrap);
623 config->writeEntry("Word Wrap At", myWordWrapAt); 624 config->writeEntry("Word Wrap At", myWordWrapAt);
624 config->writeEntry("TabWidth", tabChars); 625 config->writeEntry("TabWidth", tabChars);
625 config->writeEntry("UndoSteps", undoSteps); 626 config->writeEntry("UndoSteps", undoSteps);
626 config->writeEntry("SingleSelection", m_singleSelection); 627 config->writeEntry("SingleSelection", m_singleSelection);
627 config->writeEntry("Encoding", myEncoding); 628 config->writeEntry("Encoding", myEncoding);
628 config->writeEntry("Font", myFont); 629 config->writeEntry("Font", myFont);
629 config->writeEntry("Color Background", colors[0]); 630 config->writeEntry("Color Background", colors[0]);
630 config->writeEntry("Color Selected", colors[1]); 631 config->writeEntry("Color Selected", colors[1]);
@@ -670,33 +671,33 @@ void KateDocument::setHighlight(int n) {
670 671
671 h = hlManager->getHl(n); 672 h = hlManager->getHl(n);
672 if (h == m_highlight) { 673 if (h == m_highlight) {
673 updateLines(); 674 updateLines();
674 } else { 675 } else {
675 if (m_highlight != 0L) m_highlight->release(); 676 if (m_highlight != 0L) m_highlight->release();
676 h->use(); 677 h->use();
677 m_highlight = h; 678 m_highlight = h;
678 makeAttribs(); 679 makeAttribs();
679 } 680 }
680 PreHighlightedTill=0; 681 PreHighlightedTill=0;
681 RequestPreHighlightTill=0; 682 RequestPreHighlightTill=0;
682 emit(highlightChanged()); 683 emit(highlightChanged());
683} 684}
684 685
685void KateDocument::makeAttribs() { 686void KateDocument::makeAttribs() {
686 qDebug("KateDocument::makeAttribs()"); 687 odebug << "KateDocument::makeAttribs()" << oendl;
687 m_numAttribs = hlManager->makeAttribs(m_highlight, m_attribs, maxAttribs); 688 m_numAttribs = hlManager->makeAttribs(m_highlight, m_attribs, maxAttribs);
688 updateFontData(); 689 updateFontData();
689 updateLines(); 690 updateLines();
690} 691}
691 692
692void KateDocument::updateFontData() { 693void KateDocument::updateFontData() {
693 int maxAscent, maxDescent; 694 int maxAscent, maxDescent;
694 int tabWidth; 695 int tabWidth;
695 KateView *view; 696 KateView *view;
696 697
697 maxAscent = myFontMetrics.ascent(); 698 maxAscent = myFontMetrics.ascent();
698 maxDescent = myFontMetrics.descent(); 699 maxDescent = myFontMetrics.descent();
699 tabWidth = myFontMetrics.width(' '); 700 tabWidth = myFontMetrics.width(' ');
700 701
701 fontHeight = maxAscent + maxDescent + 1; 702 fontHeight = maxAscent + maxDescent + 1;
702 fontAscent = maxAscent; 703 fontAscent = maxAscent;
@@ -1910,34 +1911,34 @@ void KateDocument::updateLines(int startLine, int endLine, int flags, int cursor
1910// kdDebug(13020)<<"KateDocument::updateLines Checkpoint 2"<<endl; 1911// kdDebug(13020)<<"KateDocument::updateLines Checkpoint 2"<<endl;
1911 last_line = lastLine(); 1912 last_line = lastLine();
1912// if (endLine >= last_line) endLine = last_line; 1913// if (endLine >= last_line) endLine = last_line;
1913 1914
1914 line = startLine; 1915 line = startLine;
1915 ctxNum = 0; 1916 ctxNum = 0;
1916 if (line > 0) ctxNum = getTextLine(line - 1)->getContext(); 1917 if (line > 0) ctxNum = getTextLine(line - 1)->getContext();
1917 do { 1918 do {
1918// kdDebug(13020)<<QString("**************Working on line: %1").arg(line)<<endl; 1919// kdDebug(13020)<<QString("**************Working on line: %1").arg(line)<<endl;
1919 textLine = getTextLine(line); 1920 textLine = getTextLine(line);
1920 if (textLine==0) kdDebug(13020)<<"****updateLines()>> error textLine==0"<<endl; 1921 if (textLine==0) kdDebug(13020)<<"****updateLines()>> error textLine==0"<<endl;
1921 if (line <= endLine && line != cursorY) { 1922 if (line <= endLine && line != cursorY) {
1922 if (flags & KateView::cfRemoveSpaces) textLine->removeSpaces(); 1923 if (flags & KateView::cfRemoveSpaces) textLine->removeSpaces();
1923 updateMaxLength(textLine); 1924 updateMaxLength(textLine);
1924 } 1925 }
1925 endCtx = textLine->getContext(); 1926 endCtx = textLine->getContext();
1926// qDebug("DOHIGHLIGHT"); 1927// odebug << "DOHIGHLIGHT" << oendl;
1927 1928
1928 ctxNum = m_highlight->doHighlight(ctxNum,textLine); 1929 ctxNum = m_highlight->doHighlight(ctxNum,textLine);
1929 textLine->setContext(ctxNum); 1930 textLine->setContext(ctxNum);
1930 line++; 1931 line++;
1931 } while ((buffer->line(line)!=0) && (line <= endLine || endCtx != ctxNum)); 1932 } while ((buffer->line(line)!=0) && (line <= endLine || endCtx != ctxNum));
1932// kdDebug(13020)<<"updateLines :: while loop left"<<endl; 1933// kdDebug(13020)<<"updateLines :: while loop left"<<endl;
1933 tagLines(startLine, line - 1); 1934 tagLines(startLine, line - 1);
1934} 1935}
1935 1936
1936 1937
1937void KateDocument::updateMaxLength(TextLine::Ptr &textLine) { 1938void KateDocument::updateMaxLength(TextLine::Ptr &textLine) {
1938 int len; 1939 int len;
1939 1940
1940 len = textWidth(textLine,textLine->length()); 1941 len = textWidth(textLine,textLine->length());
1941 1942
1942 if (len > maxLength) { 1943 if (len > maxLength) {
1943 longestLine = textLine; 1944 longestLine = textLine;
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
index 0d2c283..539d356 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
@@ -1,57 +1,61 @@
1/* 1/*
2 Copyright (C) 1998, 1999 Jochen Wilhelmy 2 Copyright (C) 1998, 1999 Jochen Wilhelmy
3 digisnap@cs.tu-berlin.de 3 digisnap@cs.tu-berlin.de
4 (C) 2002, 2001 The Kate Team <kwrite-devel@kde.org> 4 (C) 2002, 2001 The Kate Team <kwrite-devel@kde.org>
5 (C) 2002 Joseph Wenninger <jowenn@kde.org> 5 (C) 2002 Joseph Wenninger <jowenn@kde.org>
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <string.h>
23
24#include <qtextstream.h>
25#include <qpe/config.h>
26#include <kglobal.h>
27//#include <kinstance.h>
28//#include <kmimemagic.h>
29#include <klocale.h>
30//#include <kregexp.h>
31#include <kglobalsettings.h>
32#include <kdebug.h>
33#include <kstddirs.h>
34
35#include "katehighlight.h" 22#include "katehighlight.h"
36
37
38#include "katetextline.h" 23#include "katetextline.h"
39#include "katedocument.h" 24#include "katedocument.h"
40#include "katesyntaxdocument.h" 25#include "katesyntaxdocument.h"
41 26
27#include "kglobal.h"
28//#include "kinstance.h"
29//#include "kmimemagic.h"
30#include "klocale.h"
31//#include "kregexp.h"
32#include "kglobalsettings.h"
33#include "kdebug.h"
34#include "kstddirs.h"
35
36/* OPIE */
37#include <opie2/odebug.h>
38#include <qpe/config.h>
39
40/* QT */
41#include <qtextstream.h>
42
43/* STD */
44#include <string.h>
45
42 46
43HlManager *HlManager::s_pSelf = 0; 47HlManager *HlManager::s_pSelf = 0;
44 48
45enum Item_styles { dsNormal,dsKeyword,dsDataType,dsDecVal,dsBaseN,dsFloat,dsChar,dsString,dsComment,dsOthers}; 49enum Item_styles { dsNormal,dsKeyword,dsDataType,dsDecVal,dsBaseN,dsFloat,dsChar,dsString,dsComment,dsOthers};
46 50
47static bool trueBool = true; 51static bool trueBool = true;
48static QString stdDeliminator = QString ("!%&()*+,-./:;<=>?[]^{|}~ \t\\"); 52static QString stdDeliminator = QString ("!%&()*+,-./:;<=>?[]^{|}~ \t\\");
49 53
50int getDefStyleNum(QString name) 54int getDefStyleNum(QString name)
51{ 55{
52 if (name=="dsNormal") return dsNormal; 56 if (name=="dsNormal") return dsNormal;
53 if (name=="dsKeyword") return dsKeyword; 57 if (name=="dsKeyword") return dsKeyword;
54 if (name=="dsDataType") return dsDataType; 58 if (name=="dsDataType") return dsDataType;
55 if (name=="dsDecVal") return dsDecVal; 59 if (name=="dsDecVal") return dsDecVal;
56 if (name=="dsBaseN") return dsBaseN; 60 if (name=="dsBaseN") return dsBaseN;
57 if (name=="dsFloat") return dsFloat; 61 if (name=="dsFloat") return dsFloat;
@@ -107,34 +111,34 @@ Hl2CharDetect::Hl2CharDetect(int attribute, int context, QChar ch1, QChar ch2)
107const QChar *Hl2CharDetect::checkHgl(const QChar *str, int len, bool) { 111const QChar *Hl2CharDetect::checkHgl(const QChar *str, int len, bool) {
108 if (str[0] == sChar1 && str[1] == sChar2) return str + 2; 112 if (str[0] == sChar1 && str[1] == sChar2) return str + 2;
109 return 0L; 113 return 0L;
110} 114}
111 115
112HlStringDetect::HlStringDetect(int attribute, int context, const QString &s, bool inSensitive) 116HlStringDetect::HlStringDetect(int attribute, int context, const QString &s, bool inSensitive)
113 : HlItem(attribute, context), str(inSensitive ? s.upper():s), _inSensitive(inSensitive) { 117 : HlItem(attribute, context), str(inSensitive ? s.upper():s), _inSensitive(inSensitive) {
114} 118}
115 119
116HlStringDetect::~HlStringDetect() { 120HlStringDetect::~HlStringDetect() {
117} 121}
118 122
119const QChar *HlStringDetect::checkHgl(const QChar *s, int len, bool) { 123const QChar *HlStringDetect::checkHgl(const QChar *s, int len, bool) {
120 if (!_inSensitive) {if (memcmp(s, str.unicode(), str.length()*sizeof(QChar)) == 0) return s + str.length();} 124 if (!_inSensitive) {if (memcmp(s, str.unicode(), str.length()*sizeof(QChar)) == 0) return s + str.length();}
121 else 125 else
122 { 126 {
123 QString tmp=QString(s,str.length()).upper(); 127 QString tmp=QString(s,str.length()).upper();
124 if (tmp==str) return s+str.length(); 128 if (tmp==str) return s+str.length();
125 } 129 }
126 return 0L; 130 return 0L;
127} 131}
128 132
129 133
130HlRangeDetect::HlRangeDetect(int attribute, int context, QChar ch1, QChar ch2) 134HlRangeDetect::HlRangeDetect(int attribute, int context, QChar ch1, QChar ch2)
131 : HlItem(attribute,context) { 135 : HlItem(attribute,context) {
132 sChar1 = ch1; 136 sChar1 = ch1;
133 sChar2 = ch2; 137 sChar2 = ch2;
134} 138}
135 139
136const QChar *HlRangeDetect::checkHgl(const QChar *s, int len, bool) { 140const QChar *HlRangeDetect::checkHgl(const QChar *s, int len, bool) {
137 if (*s == sChar1) 141 if (*s == sChar1)
138 { 142 {
139 do 143 do
140 { 144 {
@@ -200,75 +204,75 @@ const QChar *HlKeyword::checkHgl(const QChar *s, int len, bool b)
200 return 0L; 204 return 0L;
201} 205}
202 206
203HlInt::HlInt(int attribute, int context) 207HlInt::HlInt(int attribute, int context)
204 : HlItem(attribute,context) { 208 : HlItem(attribute,context) {
205} 209}
206 210
207const QChar *HlInt::checkHgl(const QChar *str, int len, bool) { 211const QChar *HlInt::checkHgl(const QChar *str, int len, bool) {
208 const QChar *s,*s1; 212 const QChar *s,*s1;
209 213
210 s = str; 214 s = str;
211 while (s->isDigit()) s++; 215 while (s->isDigit()) s++;
212 if (s > str) 216 if (s > str)
213 { 217 {
214 if (subItems) 218 if (subItems)
215 { 219 {
216 for (HlItem *it=subItems->first();it;it=subItems->next()) 220 for (HlItem *it=subItems->first();it;it=subItems->next())
217 { 221 {
218 s1=it->checkHgl(s, len, false); 222 s1=it->checkHgl(s, len, false);
219 if (s1) return s1; 223 if (s1) return s1;
220 } 224 }
221 } 225 }
222 return s; 226 return s;
223 } 227 }
224 return 0L; 228 return 0L;
225} 229}
226 230
227HlFloat::HlFloat(int attribute, int context) 231HlFloat::HlFloat(int attribute, int context)
228 : HlItem(attribute,context) { 232 : HlItem(attribute,context) {
229} 233}
230 234
231const QChar *HlFloat::checkHgl(const QChar *s, int len, bool) { 235const QChar *HlFloat::checkHgl(const QChar *s, int len, bool) {
232 bool b, p; 236 bool b, p;
233 const QChar *s1; 237 const QChar *s1;
234 238
235 b = false; 239 b = false;
236 while (s->isDigit()){ 240 while (s->isDigit()){
237 s++; 241 s++;
238 b = true; 242 b = true;
239 } 243 }
240 if (p = (*s == '.')) { 244 if (p = (*s == '.')) {
241 s++; 245 s++;
242 while (s->isDigit()) { 246 while (s->isDigit()) {
243 s++; 247 s++;
244 b = true; 248 b = true;
245 } 249 }
246 } 250 }
247 if (!b) return 0L; 251 if (!b) return 0L;
248 if ((*s&0xdf) == 'E') s++; 252 if ((*s&0xdf) == 'E') s++;
249 else 253 else
250 if (!p) return 0L; 254 if (!p) return 0L;
251 else 255 else
252 { 256 {
253 if (subItems) 257 if (subItems)
254 { 258 {
255 for (HlItem *it=subItems->first();it;it=subItems->next()) 259 for (HlItem *it=subItems->first();it;it=subItems->next())
256 { 260 {
257 s1=it->checkHgl(s, len, false); 261 s1=it->checkHgl(s, len, false);
258 if (s1) return s1; 262 if (s1) return s1;
259 } 263 }
260 } 264 }
261 return s; 265 return s;
262 } 266 }
263 if ((*s == '-')||(*s =='+')) s++; 267 if ((*s == '-')||(*s =='+')) s++;
264 b = false; 268 b = false;
265 while (s->isDigit()) { 269 while (s->isDigit()) {
266 s++; 270 s++;
267 b = true; 271 b = true;
268 } 272 }
269 if (b) 273 if (b)
270 { 274 {
271 if (subItems) 275 if (subItems)
272 { 276 {
273 for (HlItem *it=subItems->first();it;it=subItems->next()) 277 for (HlItem *it=subItems->first();it;it=subItems->next())
274 { 278 {
@@ -332,33 +336,33 @@ const QChar *HlCOct::checkHgl(const QChar *str, int len, bool) {
332} 336}
333 337
334HlCHex::HlCHex(int attribute, int context) 338HlCHex::HlCHex(int attribute, int context)
335 : HlItem(attribute,context) { 339 : HlItem(attribute,context) {
336} 340}
337 341
338const QChar *HlCHex::checkHgl(const QChar *str, int len, bool) { 342const QChar *HlCHex::checkHgl(const QChar *str, int len, bool) {
339 const QChar *s=str; 343 const QChar *s=str;
340#if 0 344#if 0
341 int i; 345 int i;
342 for (i=0;(*s)!='\0';s++,i++); 346 for (i=0;(*s)!='\0';s++,i++);
343 QString line(str,i); 347 QString line(str,i);
344 QRegExp3 rx("0[xX][a-fA-F\\d]+[UuLl]?"); // this matches but is also matching parenthesis 348 QRegExp3 rx("0[xX][a-fA-F\\d]+[UuLl]?"); // this matches but is also matching parenthesis
345 int pos=rx.search(line,0); 349 int pos=rx.search(line,0);
346 if(pos > -1) return str+rx.matchedLength(); 350 if(pos > -1) return str+rx.matchedLength();
347 else 351 else
348 return 0L; 352 return 0L;
349 353
350#else 354#else
351 if (str[0] == '0' && ((str[1]&0xdf) == 'X' )) { 355 if (str[0] == '0' && ((str[1]&0xdf) == 'X' )) {
352 str += 2; 356 str += 2;
353 s = str; 357 s = str;
354 while (s->isDigit() || ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') /*|| (*s >= 'a' && *s <= 'f')*/) s++; 358 while (s->isDigit() || ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') /*|| (*s >= 'a' && *s <= 'f')*/) s++;
355 if (s > str) { 359 if (s > str) {
356 if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++; 360 if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++;
357 return s; 361 return s;
358 } 362 }
359 } 363 }
360 return 0L; 364 return 0L;
361#endif 365#endif
362} 366}
363 367
364HlCFloat::HlCFloat(int attribute, int context) 368HlCFloat::HlCFloat(int attribute, int context)
@@ -387,46 +391,46 @@ const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool)
387HlRegExpr::HlRegExpr(int attribute, int context,QString regexp) 391HlRegExpr::HlRegExpr(int attribute, int context,QString regexp)
388 : HlItem(attribute, context) { 392 : HlItem(attribute, context) {
389 393
390 handlesLinestart=regexp.startsWith("^"); 394 handlesLinestart=regexp.startsWith("^");
391 if(!handlesLinestart) regexp.prepend("^"); 395 if(!handlesLinestart) regexp.prepend("^");
392 Expr=new QRegExp3(regexp); 396 Expr=new QRegExp3(regexp);
393} 397}
394 398
395const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart) 399const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart)
396{ 400{
397 if ((!lineStart) && handlesLinestart) return 0; 401 if ((!lineStart) && handlesLinestart) return 0;
398 402
399 QString line(s,len); 403 QString line(s,len);
400 int pos = Expr->search( line, 0 ); 404 int pos = Expr->search( line, 0 );
401 if (pos==-1) return 0L; 405 if (pos==-1) return 0L;
402 else 406 else
403 return (s+Expr->matchedLength()); 407 return (s+Expr->matchedLength());
404}; 408};
405 409
406 410
407HlLineContinue::HlLineContinue(int attribute, int context) 411HlLineContinue::HlLineContinue(int attribute, int context)
408 : HlItem(attribute,context) { 412 : HlItem(attribute,context) {
409} 413}
410 414
411const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) { 415const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) {
412 416
413 if ((s[0].latin1() == '\\') && (len == 1)) 417 if ((s[0].latin1() == '\\') && (len == 1))
414 { 418 {
415 return s + 1; 419 return s + 1;
416 } 420 }
417 return 0L; 421 return 0L;
418} 422}
419 423
420 424
421HlCStringChar::HlCStringChar(int attribute, int context) 425HlCStringChar::HlCStringChar(int attribute, int context)
422 : HlItem(attribute,context) { 426 : HlItem(attribute,context) {
423} 427}
424 428
425//checks for hex and oct (for example \x1b or \033) 429//checks for hex and oct (for example \x1b or \033)
426const QChar *checkCharHexOct(const QChar *str) { 430const QChar *checkCharHexOct(const QChar *str) {
427 const QChar *s; 431 const QChar *s;
428 s=str; 432 s=str;
429 int n; 433 int n;
430 if (*s == 'x') { 434 if (*s == 'x') {
431 n = 0; 435 n = 0;
432 do { 436 do {
@@ -608,33 +612,33 @@ int Highlight::doHighlight(int ctxNum, TextLine *textLine)
608 612
609 // length of textline 613 // length of textline
610 uint len = textLine->length(); 614 uint len = textLine->length();
611 615
612 bool found = false; 616 bool found = false;
613 while (z < len) 617 while (z < len)
614 { 618 {
615 found = false; 619 found = false;
616 620
617 for (item = context->items.first(); item != 0L; item = context->items.next()) 621 for (item = context->items.first(); item != 0L; item = context->items.next())
618 { 622 {
619 if (item->startEnable(lastChar)) 623 if (item->startEnable(lastChar))
620 { 624 {
621 s2 = item->checkHgl(s1, len-z, z==0); 625 s2 = item->checkHgl(s1, len-z, z==0);
622 if (s2 > s1) 626 if (s2 > s1)
623 { 627 {
624 qDebug("An item has been detected"); 628 odebug << "An item has been detected" << oendl;
625 textLine->setAttribs(item->attr,s1 - str,s2 - str); 629 textLine->setAttribs(item->attr,s1 - str,s2 - str);
626 ctxNum = item->ctx; 630 ctxNum = item->ctx;
627 context = contextList[ctxNum]; 631 context = contextList[ctxNum];
628 z = z + s2 - s1 - 1; 632 z = z + s2 - s1 - 1;
629 s1 = s2 - 1; 633 s1 = s2 - 1;
630 found = true; 634 found = true;
631 break; 635 break;
632 } 636 }
633 } 637 }
634 } 638 }
635 639
636 // nothing found: set attribute of one char 640 // nothing found: set attribute of one char
637 if (!found) 641 if (!found)
638 textLine->setAttribs(context->attr,s1 - str,s1 - str + 1); 642 textLine->setAttribs(context->attr,s1 - str,s1 - str + 1);
639 643
640 lastChar = *s1; 644 lastChar = *s1;
@@ -840,62 +844,62 @@ void Highlight::done()
840/******************************************************************************************* 844/*******************************************************************************************
841 Highlight - createItemData 845 Highlight - createItemData
842 This function reads the itemData entries from the config file, which specifies the 846 This function reads the itemData entries from the config file, which specifies the
843 default attribute styles for matched items/contexts. 847 default attribute styles for matched items/contexts.
844 848
845 * input: none 849 * input: none
846 ************* 850 *************
847 * output: ItemDataList &list :A reference to the internal 851 * output: ItemDataList &list :A reference to the internal
848 list containing the parsed 852 list containing the parsed
849 default config 853 default config
850 ************* 854 *************
851 * return value: none 855 * return value: none
852*******************************************************************************************/ 856*******************************************************************************************/
853 857
854void Highlight::createItemData(ItemDataList &list) 858void Highlight::createItemData(ItemDataList &list)
855{ 859{
856 qDebug("Highlight::createItemData"); 860 odebug << "Highlight::createItemData" << oendl;
857 861
858 // If no highlighting is selected we need only one default. 862 // If no highlighting is selected we need only one default.
859 if (noHl) 863 if (noHl)
860 { 864 {
861 list.append(new ItemData(I18N_NOOP("Normal Text"), dsNormal)); 865 list.append(new ItemData(I18N_NOOP("Normal Text"), dsNormal));
862 return; 866 return;
863 } 867 }
864 868
865 QString color; 869 QString color;
866 QString selColor; 870 QString selColor;
867 QString bold; 871 QString bold;
868 QString italic; 872 QString italic;
869 873
870 // If the internal list isn't already available read the config file 874 // If the internal list isn't already available read the config file
871 if (internalIDList.count()==0) 875 if (internalIDList.count()==0)
872 { 876 {
873 //if all references to the list are destried the contents will also be deleted 877 //if all references to the list are destried the contents will also be deleted
874 internalIDList.setAutoDelete(true); 878 internalIDList.setAutoDelete(true);
875 syntaxContextData *data; 879 syntaxContextData *data;
876 880
877 qDebug("Trying to read itemData section"); 881 odebug << "Trying to read itemData section" << oendl;
878 882
879 //Tell the syntax document class which file we want to parse and which data group 883 //Tell the syntax document class which file we want to parse and which data group
880 HlManager::self()->syntax->setIdentifier(identifier); 884 HlManager::self()->syntax->setIdentifier(identifier);
881 data=HlManager::self()->syntax->getGroupInfo("highlighting","itemData"); 885 data=HlManager::self()->syntax->getGroupInfo("highlighting","itemData");
882 //begin with the real parsing 886 //begin with the real parsing
883 while (HlManager::self()->syntax->nextGroup(data)) 887 while (HlManager::self()->syntax->nextGroup(data))
884 { 888 {
885 qDebug("Setting up one itemData element"); 889 odebug << "Setting up one itemData element" << oendl;
886 // read all attributes 890 // read all attributes
887 color=HlManager::self()->syntax->groupData(data,QString("color")); 891 color=HlManager::self()->syntax->groupData(data,QString("color"));
888 selColor=HlManager::self()->syntax->groupData(data,QString("selColor")); 892 selColor=HlManager::self()->syntax->groupData(data,QString("selColor"));
889 bold=HlManager::self()->syntax->groupData(data,QString("bold")); 893 bold=HlManager::self()->syntax->groupData(data,QString("bold"));
890 italic=HlManager::self()->syntax->groupData(data,QString("italic")); 894 italic=HlManager::self()->syntax->groupData(data,QString("italic"));
891 //check if the user overrides something 895 //check if the user overrides something
892 if ( (!color.isEmpty()) && (!selColor.isEmpty()) && (!bold.isEmpty()) && (!italic.isEmpty())) 896 if ( (!color.isEmpty()) && (!selColor.isEmpty()) && (!bold.isEmpty()) && (!italic.isEmpty()))
893 { 897 {
894 //create a user defined style 898 //create a user defined style
895 internalIDList.append(new ItemData( 899 internalIDList.append(new ItemData(
896 HlManager::self()->syntax->groupData(data,QString("name")).simplifyWhiteSpace(), 900 HlManager::self()->syntax->groupData(data,QString("name")).simplifyWhiteSpace(),
897 getDefStyleNum(HlManager::self()->syntax->groupData(data,QString("defStyleNum"))), 901 getDefStyleNum(HlManager::self()->syntax->groupData(data,QString("defStyleNum"))),
898 QColor(color),QColor(selColor),(bold=="true") || (bold=="1"), (italic=="true") || (italic=="1") 902 QColor(color),QColor(selColor),(bold=="true") || (bold=="1"), (italic=="true") || (italic=="1")
899 )); 903 ));
900 } 904 }
901 else 905 else
@@ -920,38 +924,38 @@ void Highlight::createItemData(ItemDataList &list)
920 Highlight - lookupAttrName 924 Highlight - lookupAttrName
921 This function is a helper for makeContextList and createHlItem. It looks the given 925 This function is a helper for makeContextList and createHlItem. It looks the given
922 attribute name in the itemData list up and returns it's index 926 attribute name in the itemData list up and returns it's index
923 927
924 * input: QString &name :the attribute name to lookup 928 * input: QString &name :the attribute name to lookup
925 * ItemDataList &iDl :the list containing all 929 * ItemDataList &iDl :the list containing all
926 * available attributes 930 * available attributes
927 ************* 931 *************
928 * output: none 932 * output: none
929 ************* 933 *************
930 * return value: int :The index of the attribute 934 * return value: int :The index of the attribute
931 * or 0 935 * or 0
932*******************************************************************************************/ 936*******************************************************************************************/
933 937
934int Highlight::lookupAttrName(const QString& name, ItemDataList &iDl) 938int Highlight::lookupAttrName(const QString& name, ItemDataList &iDl)
935{ 939{
936 for (int i=0;i<iDl.count();i++) 940 for (int i=0;i<iDl.count();i++)
937 { 941 {
938 if (iDl.at(i)->name==name) return i; 942 if (iDl.at(i)->name==name) return i;
939 } 943 }
940 kdDebug(13010)<<"Couldn't resolve itemDataName"<<endl; 944 kdDebug(13010)<<"Couldn't resolve itemDataName"<<endl;
941 return 0; 945 return 0;
942} 946}
943 947
944 948
945/******************************************************************************************* 949/*******************************************************************************************
946 Highlight - createHlItem 950 Highlight - createHlItem
947 This function is a helper for makeContextList. It parses the xml file for 951 This function is a helper for makeContextList. It parses the xml file for
948 information, how single or multi line comments are marked 952 information, how single or multi line comments are marked
949 953
950 * input: syntaxContextData *data : Data about the item read from 954 * input: syntaxContextData *data : Data about the item read from
951 * the xml file 955 * the xml file
952 * ItemDataList &iDl : List of all available itemData 956 * ItemDataList &iDl : List of all available itemData
953 * entries. Needed for attribute 957 * entries. Needed for attribute
954 * name->index translation 958 * name->index translation
955 ************* 959 *************
956 * output: none 960 * output: none
957 ************* 961 *************
@@ -1064,89 +1068,89 @@ bool Highlight::isInWord(QChar c)
1064*******************************************************************************************/ 1068*******************************************************************************************/
1065 1069
1066void Highlight::readCommentConfig() 1070void Highlight::readCommentConfig()
1067{ 1071{
1068 1072
1069 cslStart = ""; 1073 cslStart = "";
1070 HlManager::self()->syntax->setIdentifier(identifier); 1074 HlManager::self()->syntax->setIdentifier(identifier);
1071 1075
1072 syntaxContextData *data=HlManager::self()->syntax->getGroupInfo("general","comment"); 1076 syntaxContextData *data=HlManager::self()->syntax->getGroupInfo("general","comment");
1073 if (data) 1077 if (data)
1074 { 1078 {
1075// kdDebug(13010)<<"COMMENT DATA FOUND"<<endl; 1079// kdDebug(13010)<<"COMMENT DATA FOUND"<<endl;
1076 while (HlManager::self()->syntax->nextGroup(data)) 1080 while (HlManager::self()->syntax->nextGroup(data))
1077 { 1081 {
1078 1082
1079 if (HlManager::self()->syntax->groupData(data,"name")=="singleLine") 1083 if (HlManager::self()->syntax->groupData(data,"name")=="singleLine")
1080 cslStart=HlManager::self()->syntax->groupData(data,"start"); 1084 cslStart=HlManager::self()->syntax->groupData(data,"start");
1081 if (HlManager::self()->syntax->groupData(data,"name")=="multiLine") 1085 if (HlManager::self()->syntax->groupData(data,"name")=="multiLine")
1082 { 1086 {
1083 cmlStart=HlManager::self()->syntax->groupData(data,"start"); 1087 cmlStart=HlManager::self()->syntax->groupData(data,"start");
1084 cmlEnd=HlManager::self()->syntax->groupData(data,"end"); 1088 cmlEnd=HlManager::self()->syntax->groupData(data,"end");
1085 } 1089 }
1086 } 1090 }
1087 HlManager::self()->syntax->freeGroupInfo(data); 1091 HlManager::self()->syntax->freeGroupInfo(data);
1088 } 1092 }
1089 1093
1090} 1094}
1091 1095
1092/******************************************************************************************* 1096/*******************************************************************************************
1093 Highlight - readGlobalKeyWordConfig 1097 Highlight - readGlobalKeyWordConfig
1094 This function is a helper for makeContextList. It parses the xml file for 1098 This function is a helper for makeContextList. It parses the xml file for
1095 information, if keywords should be treated case(in)sensitive and creates the keyword 1099 information, if keywords should be treated case(in)sensitive and creates the keyword
1096 delimiter list. Which is the default list, without any given weak deliminiators 1100 delimiter list. Which is the default list, without any given weak deliminiators
1097 1101
1098 * input: none 1102 * input: none
1099 ************* 1103 *************
1100 * output: none 1104 * output: none
1101 ************* 1105 *************
1102 * return value: none 1106 * return value: none
1103*******************************************************************************************/ 1107*******************************************************************************************/
1104 1108
1105 1109
1106void Highlight::readGlobalKeywordConfig() 1110void Highlight::readGlobalKeywordConfig()
1107{ 1111{
1108 // Tell the syntax document class which file we want to parse 1112 // Tell the syntax document class which file we want to parse
1109 HlManager::self()->syntax->setIdentifier(identifier); 1113 HlManager::self()->syntax->setIdentifier(identifier);
1110 1114
1111 // Get the keywords config entry 1115 // Get the keywords config entry
1112 syntaxContextData * data=HlManager::self()->syntax->getConfig("general","keywords"); 1116 syntaxContextData * data=HlManager::self()->syntax->getConfig("general","keywords");
1113 if (data) 1117 if (data)
1114 { 1118 {
1115 kdDebug(13010)<<"Found global keyword config"<<endl; 1119 kdDebug(13010)<<"Found global keyword config"<<endl;
1116 1120
1117 if (HlManager::self()->syntax->groupItemData(data,QString("casesensitive"))!="0") 1121 if (HlManager::self()->syntax->groupItemData(data,QString("casesensitive"))!="0")
1118 casesensitive=true; else {casesensitive=false; kdDebug(13010)<<"Turning on case insensitiveness"<<endl;} 1122 casesensitive=true; else {casesensitive=false; kdDebug(13010)<<"Turning on case insensitiveness"<<endl;}
1119 //get the weak deliminators 1123 //get the weak deliminators
1120 weakDeliminator=(!HlManager::self()->syntax->groupItemData(data,QString("weakDeliminator"))); 1124 weakDeliminator=(!HlManager::self()->syntax->groupItemData(data,QString("weakDeliminator")));
1121 1125
1122 // remove any weakDelimitars (if any) from the default list and store this list. 1126 // remove any weakDelimitars (if any) from the default list and store this list.
1123 int f; 1127 int f;
1124 for (int s=0; s < weakDeliminator.length(); s++) 1128 for (int s=0; s < weakDeliminator.length(); s++)
1125 { 1129 {
1126 f = 0; 1130 f = 0;
1127 f = deliminator.find (weakDeliminator[s]); 1131 f = deliminator.find (weakDeliminator[s]);
1128 1132
1129 if (f > -1) 1133 if (f > -1)
1130 deliminator.remove (f, 1); 1134 deliminator.remove (f, 1);
1131 } 1135 }
1132 1136
1133 deliminatorChars = deliminator.unicode(); 1137 deliminatorChars = deliminator.unicode();
1134 deliminatorLen = deliminator.length(); 1138 deliminatorLen = deliminator.length();
1135 1139
1136 HlManager::self()->syntax->freeGroupInfo(data); 1140 HlManager::self()->syntax->freeGroupInfo(data);
1137 } 1141 }
1138 else 1142 else
1139 { 1143 {
1140 //Default values 1144 //Default values
1141 casesensitive=true; 1145 casesensitive=true;
1142 weakDeliminator=QString(""); 1146 weakDeliminator=QString("");
1143 } 1147 }
1144 1148
1145} 1149}
1146 1150
1147/******************************************************************************************* 1151/*******************************************************************************************
1148 Highlight - makeContextList 1152 Highlight - makeContextList
1149 That's the most important initialization function for each highlighting. It's called 1153 That's the most important initialization function for each highlighting. It's called
1150 each time a document gets a highlighting style assigned. parses the xml file and 1154 each time a document gets a highlighting style assigned. parses the xml file and
1151 creates a corresponding internal structure 1155 creates a corresponding internal structure
1152 1156
@@ -1191,51 +1195,51 @@ void Highlight::makeContextList()
1191 if (QString("%1").arg(tmpAttr.toInt())==tmpAttr) 1195 if (QString("%1").arg(tmpAttr.toInt())==tmpAttr)
1192 attr=tmpAttr.toInt(); 1196 attr=tmpAttr.toInt();
1193 else 1197 else
1194 attr=lookupAttrName(tmpAttr,iDl); 1198 attr=lookupAttrName(tmpAttr,iDl);
1195 // END - Translation of the attribute parameter 1199 // END - Translation of the attribute parameter
1196 1200
1197 contextList[i]=new HlContext( 1201 contextList[i]=new HlContext(
1198 attr, 1202 attr,
1199 (HlManager::self()->syntax->groupData(data,QString("lineEndContext"))).toInt(), 1203 (HlManager::self()->syntax->groupData(data,QString("lineEndContext"))).toInt(),
1200 (HlManager::self()->syntax->groupData(data,QString("lineBeginContext"))).isEmpty()?-1: 1204 (HlManager::self()->syntax->groupData(data,QString("lineBeginContext"))).isEmpty()?-1:
1201 (HlManager::self()->syntax->groupData(data,QString("lineBeginContext"))).toInt()); 1205 (HlManager::self()->syntax->groupData(data,QString("lineBeginContext"))).toInt());
1202 1206
1203 1207
1204 //Let's create all items for the context 1208 //Let's create all items for the context
1205 while (HlManager::self()->syntax->nextItem(data)) 1209 while (HlManager::self()->syntax->nextItem(data))
1206 { 1210 {
1207 // kdDebug(13010)<< "In make Contextlist: Item:"<<endl; 1211// kdDebug(13010)<< "In make Contextlist: Item:"<<endl;
1208 c=createHlItem(data,iDl); 1212 c=createHlItem(data,iDl);
1209 if (c) 1213 if (c)
1210 { 1214 {
1211 contextList[i]->items.append(c); 1215 contextList[i]->items.append(c);
1212 1216
1213 // Not supported completely atm and only one level. Subitems.(all have to be matched to at once) 1217 // Not supported completely atm and only one level. Subitems.(all have to be matched to at once)
1214 datasub=HlManager::self()->syntax->getSubItems(data); 1218 datasub=HlManager::self()->syntax->getSubItems(data);
1215 bool tmpbool; 1219 bool tmpbool;
1216 if (tmpbool=HlManager::self()->syntax->nextItem(datasub)) 1220 if (tmpbool=HlManager::self()->syntax->nextItem(datasub))
1217 { 1221 {
1218 c->subItems=new QList<HlItem>; 1222 c->subItems=new QList<HlItem>;
1219 for (;tmpbool;tmpbool=HlManager::self()->syntax->nextItem(datasub)) 1223 for (;tmpbool;tmpbool=HlManager::self()->syntax->nextItem(datasub))
1220 c->subItems->append(createHlItem(datasub,iDl)); 1224 c->subItems->append(createHlItem(datasub,iDl));
1221 } 1225 }
1222 HlManager::self()->syntax->freeGroupInfo(datasub); 1226 HlManager::self()->syntax->freeGroupInfo(datasub);
1223 // end of sublevel 1227 // end of sublevel
1224 } 1228 }
1225 // kdDebug(13010)<<"Last line in loop"<<endl; 1229// kdDebug(13010)<<"Last line in loop"<<endl;
1226 } 1230 }
1227 i++; 1231 i++;
1228 } 1232 }
1229 } 1233 }
1230 1234
1231 HlManager::self()->syntax->freeGroupInfo(data); 1235 HlManager::self()->syntax->freeGroupInfo(data);
1232 1236
1233 1237
1234} 1238}
1235 1239
1236HlManager::HlManager() : QObject(0L) 1240HlManager::HlManager() : QObject(0L)
1237{ 1241{
1238 syntax = new SyntaxDocument(); 1242 syntax = new SyntaxDocument();
1239 SyntaxModeList modeList = syntax->modeList(); 1243 SyntaxModeList modeList = syntax->modeList();
1240 1244
1241 hlList.setAutoDelete(true); 1245 hlList.setAutoDelete(true);
@@ -1299,42 +1303,42 @@ int HlManager::wildcardFind(const QString &fileName) {
1299 if (regExp.match(fileName) == 0) return hlList.at(); 1303 if (regExp.match(fileName) == 0) return hlList.at();
1300 } 1304 }
1301 p1 = p2 + 1; 1305 p1 = p2 + 1;
1302 } 1306 }
1303 } 1307 }
1304 return -1; 1308 return -1;
1305} 1309}
1306 1310
1307 1311
1308int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) { 1312int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) {
1309 ItemStyleList defaultStyleList; 1313 ItemStyleList defaultStyleList;
1310 ItemStyle *defaultStyle; 1314 ItemStyle *defaultStyle;
1311 ItemDataList itemDataList; 1315 ItemDataList itemDataList;
1312 ItemData *itemData; 1316 ItemData *itemData;
1313 int nAttribs, z; 1317 int nAttribs, z;
1314 1318
1315 qDebug("HlManager::makeAttribs"); 1319 odebug << "HlManager::makeAttribs" << oendl;
1316 1320
1317 defaultStyleList.setAutoDelete(true); 1321 defaultStyleList.setAutoDelete(true);
1318 getDefaults(defaultStyleList); 1322 getDefaults(defaultStyleList);
1319 1323
1320// itemDataList.setAutoDelete(true); 1324// itemDataList.setAutoDelete(true);
1321 highlight->getItemDataList(itemDataList); 1325 highlight->getItemDataList(itemDataList);
1322 nAttribs = itemDataList.count(); 1326 nAttribs = itemDataList.count();
1323 for (z = 0; z < nAttribs; z++) { 1327 for (z = 0; z < nAttribs; z++) {
1324 qDebug("HlManager::makeAttribs: createing one attribute definition"); 1328 odebug << "HlManager::makeAttribs: createing one attribute definition" << oendl;
1325 itemData = itemDataList.at(z); 1329 itemData = itemDataList.at(z);
1326 if (itemData->defStyle) { 1330 if (itemData->defStyle) {
1327 // default style 1331 // default style
1328 defaultStyle = defaultStyleList.at(itemData->defStyleNum); 1332 defaultStyle = defaultStyleList.at(itemData->defStyleNum);
1329 a[z].col = defaultStyle->col; 1333 a[z].col = defaultStyle->col;
1330 a[z].selCol = defaultStyle->selCol; 1334 a[z].selCol = defaultStyle->selCol;
1331 a[z].bold = defaultStyle->bold; 1335 a[z].bold = defaultStyle->bold;
1332 a[z].italic = defaultStyle->italic; 1336 a[z].italic = defaultStyle->italic;
1333 } else { 1337 } else {
1334 // custom style 1338 // custom style
1335 a[z].col = itemData->col; 1339 a[z].col = itemData->col;
1336 a[z].selCol = itemData->selCol; 1340 a[z].selCol = itemData->selCol;
1337 a[z].bold = itemData->bold; 1341 a[z].bold = itemData->bold;
1338 a[z].italic = itemData->italic; 1342 a[z].italic = itemData->italic;
1339 } 1343 }
1340 } 1344 }
@@ -1402,33 +1406,33 @@ void HlManager::getDefaults(ItemStyleList &list) {
1402 s = config->readEntry(defaultStyleName(z)); 1406 s = config->readEntry(defaultStyleName(z));
1403 if (!s.isEmpty()) { 1407 if (!s.isEmpty()) {
1404 sscanf(s.latin1(),"%X,%X,%d,%d",&col,&selCol,&i->bold,&i->italic); 1408 sscanf(s.latin1(),"%X,%X,%d,%d",&col,&selCol,&i->bold,&i->italic);
1405 i->col.setRgb(col); 1409 i->col.setRgb(col);
1406 i->selCol.setRgb(selCol); 1410 i->selCol.setRgb(selCol);
1407 } 1411 }
1408 } 1412 }
1409*/ 1413*/
1410} 1414}
1411 1415
1412void HlManager::setDefaults(ItemStyleList &list) { 1416void HlManager::setDefaults(ItemStyleList &list) {
1413 KateConfig *config; 1417 KateConfig *config;
1414 int z; 1418 int z;
1415 ItemStyle *i; 1419 ItemStyle *i;
1416 char s[64]; 1420 char s[64];
1417#warning fixme 1421#warning fixme
1418/* 1422/*
1419 config = KateFactory::instance()->config(); 1423 config = KateFactory::instance()->config();
1420 config->setGroup("Default Item Styles"); 1424 config->setGroup("Default Item Styles");
1421 for (z = 0; z < defaultStyles(); z++) { 1425 for (z = 0; z < defaultStyles(); z++) {
1422 i = list.at(z); 1426 i = list.at(z);
1423 sprintf(s,"%X,%X,%d,%d",i->col.rgb(),i->selCol.rgb(),i->bold, i->italic); 1427 sprintf(s,"%X,%X,%d,%d",i->col.rgb(),i->selCol.rgb(),i->bold, i->italic);
1424 config->writeEntry(defaultStyleName(z),s); 1428 config->writeEntry(defaultStyleName(z),s);
1425 } 1429 }
1426*/ 1430*/
1427 emit changed(); 1431 emit changed();
1428} 1432}
1429 1433
1430 1434
1431int HlManager::highlights() { 1435int HlManager::highlights() {
1432 return (int) hlList.count(); 1436 return (int) hlList.count();
1433} 1437}
1434 1438
diff --git a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
index 6059e9b..9fa4452 100644
--- a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
@@ -3,56 +3,61 @@
3 ------------------- 3 -------------------
4 begin : Sat 31 March 2001 4 begin : Sat 31 March 2001
5 copyright : (C) 2001,2002 by Joseph Wenninger 5 copyright : (C) 2001,2002 by Joseph Wenninger
6 email : jowenn@kde.org 6 email : jowenn@kde.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 17
18#include "katesyntaxdocument.h" 18#include "katesyntaxdocument.h"
19#include <kateconfig.h> 19#include "kateconfig.h"
20#include "kdebug.h"
21#include "kstddirs.h"
22#include "klocale.h"
23#include "kmessagebox.h"
24#include "kglobal.h"
25
26/* OPIE */
27#include <opie2/odebug.h>
28#include <qpe/qpeapplication.h>
29
30/* QT */
20#include <qfile.h> 31#include <qfile.h>
21#include <kdebug.h>
22#include <kstddirs.h>
23#include <klocale.h>
24#include <kmessagebox.h>
25#include <qstringlist.h> 32#include <qstringlist.h>
26#include <kglobal.h>
27#include <qpe/qpeapplication.h>
28#include <qdir.h> 33#include <qdir.h>
29 34
30SyntaxDocument::SyntaxDocument() 35SyntaxDocument::SyntaxDocument()
31{ 36{
32 m_root=0; 37 m_root=0;
33 currentFile=""; 38 currentFile="";
34 setupModeList(); 39 setupModeList();
35} 40}
36 41
37void SyntaxDocument::setIdentifier(const QString& identifier) 42void SyntaxDocument::setIdentifier(const QString& identifier)
38{ 43{
39#warning FIXME delete m_root; 44#warning FIXME delete m_root;
40 m_root=Opie::Core::XMLElement::load(identifier); 45 m_root=Opie::Core::XMLElement::load(identifier);
41 if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) ); 46 if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) );
42 47
43} 48}
44 49
45SyntaxDocument::~SyntaxDocument() 50SyntaxDocument::~SyntaxDocument()
46{ 51{
47} 52}
48 53
49void SyntaxDocument::setupModeList(bool force) 54void SyntaxDocument::setupModeList(bool force)
50{ 55{
51 56
52 if (myModeList.count() > 0) return; 57 if (myModeList.count() > 0) return;
53 58
54 KateConfig *config=KGlobal::config(); 59 KateConfig *config=KGlobal::config();
55 KStandardDirs *dirs = KGlobal::dirs(); 60 KStandardDirs *dirs = KGlobal::dirs();
56 61
57// QStringList list=dirs->findAllResources("data","kate/syntax/*.xml",false,true); 62// QStringList list=dirs->findAllResources("data","kate/syntax/*.xml",false,true);
58 QString path=QPEApplication::qpeDir() +"share/tinykate/syntax/"; 63 QString path=QPEApplication::qpeDir() +"share/tinykate/syntax/";
@@ -63,47 +68,47 @@ void SyntaxDocument::setupModeList(bool force)
63 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 68 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
64 { 69 {
65 QString Group="Highlighting_Cache"+path+*it; 70 QString Group="Highlighting_Cache"+path+*it;
66 if ((config->hasGroup(Group)) && (!force)) 71 if ((config->hasGroup(Group)) && (!force))
67 { 72 {
68 config->setGroup(Group); 73 config->setGroup(Group);
69 syntaxModeListItem *mli=new syntaxModeListItem; 74 syntaxModeListItem *mli=new syntaxModeListItem;
70 mli->name = config->readEntry("name",""); 75 mli->name = config->readEntry("name","");
71 mli->section = config->readEntry("section",""); 76 mli->section = config->readEntry("section","");
72 mli->mimetype = config->readEntry("mimetype",""); 77 mli->mimetype = config->readEntry("mimetype","");
73 mli->extension = config->readEntry("extension",""); 78 mli->extension = config->readEntry("extension","");
74 mli->identifier = path+*it; 79 mli->identifier = path+*it;
75 myModeList.append(mli); 80 myModeList.append(mli);
76 } 81 }
77 else 82 else
78 { 83 {
79 qDebug("Found a description file:"+path+(*it)); 84 odebug << "Found a description file:"+path+(*it) << oendl;
80 setIdentifier(path+(*it)); 85 setIdentifier(path+(*it));
81 Opie::Core::XMLElement *e=m_root; 86 Opie::Core::XMLElement *e=m_root;
82 if (e) 87 if (e)
83 { 88 {
84 e=e->firstChild(); 89 e=e->firstChild();
85 qDebug(e->tagName()); 90 odebug << e->tagName() << oendl;
86 if (e->tagName()=="language") 91 if (e->tagName()=="language")
87 { 92 {
88 syntaxModeListItem *mli=new syntaxModeListItem; 93 syntaxModeListItem *mli=new syntaxModeListItem;
89 mli->name = e->attribute("name"); 94 mli->name = e->attribute("name");
90 mli->section = e->attribute("section"); 95 mli->section = e->attribute("section");
91 mli->mimetype = e->attribute("mimetype"); 96 mli->mimetype = e->attribute("mimetype");
92 mli->extension = e->attribute("extensions"); 97 mli->extension = e->attribute("extensions");
93 qDebug(QString("valid description for: %1/%2").arg(mli->section).arg(mli->name)); 98 odebug << QString("valid description for: %1/%2").arg(mli->section).arg(mli->name) << oendl;
94 if (mli->section.isEmpty()) 99 if (mli->section.isEmpty())
95 mli->section=i18n("Other"); 100 mli->section=i18n("Other");
96 101
97 mli->identifier = path+(*it); 102 mli->identifier = path+(*it);
98 config->setGroup(Group); 103 config->setGroup(Group);
99 config->writeEntry("name",mli->name); 104 config->writeEntry("name",mli->name);
100 config->writeEntry("section",mli->section); 105 config->writeEntry("section",mli->section);
101 config->writeEntry("mimetype",mli->mimetype); 106 config->writeEntry("mimetype",mli->mimetype);
102 config->writeEntry("extension",mli->extension); 107 config->writeEntry("extension",mli->extension);
103 myModeList.append(mli); 108 myModeList.append(mli);
104 } 109 }
105 } 110 }
106 } 111 }
107 } 112 }
108 config->write(); 113 config->write();
109// config->sync(); 114// config->sync();
@@ -167,66 +172,66 @@ QString SyntaxDocument::groupData( syntaxContextData* data,QString name)
167 172
168 if (data->currentGroup) 173 if (data->currentGroup)
169 return data->currentGroup->attribute(name); 174 return data->currentGroup->attribute(name);
170 else 175 else
171 return QString(); 176 return QString();
172} 177}
173 178
174void SyntaxDocument::freeGroupInfo( syntaxContextData* data) 179void SyntaxDocument::freeGroupInfo( syntaxContextData* data)
175{ 180{
176 if (data) 181 if (data)
177 delete data; 182 delete data;
178} 183}
179 184
180syntaxContextData* SyntaxDocument::getSubItems(syntaxContextData* data) 185syntaxContextData* SyntaxDocument::getSubItems(syntaxContextData* data)
181{ 186{
182 syntaxContextData *retval=new syntaxContextData; 187 syntaxContextData *retval=new syntaxContextData;
183 retval->parent=0; 188 retval->parent=0;
184 retval->currentGroup=0; 189 retval->currentGroup=0;
185 retval->item=0; 190 retval->item=0;
186 if (data != 0) 191 if (data != 0)
187 { 192 {
188 retval->parent=data->currentGroup; 193 retval->parent=data->currentGroup;
189 retval->currentGroup=data->item; 194 retval->currentGroup=data->item;
190 retval->item=0; 195 retval->item=0;
191 } 196 }
192 197
193 return retval; 198 return retval;
194} 199}
195 200
196syntaxContextData* SyntaxDocument::getConfig(const QString& mainGroupName, const QString &Config) 201syntaxContextData* SyntaxDocument::getConfig(const QString& mainGroupName, const QString &Config)
197{ 202{
198 Opie::Core::XMLElement *e = m_root->firstChild()->firstChild(); 203 Opie::Core::XMLElement *e = m_root->firstChild()->firstChild();
199 204
200 while (e) 205 while (e)
201 { 206 {
202 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl; 207 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl;
203 208
204 if (e->tagName().compare(mainGroupName)==0 ) 209 if (e->tagName().compare(mainGroupName)==0 )
205 { 210 {
206 Opie::Core::XMLElement *e1=e->firstChild(); 211 Opie::Core::XMLElement *e1=e->firstChild();
207 212
208 while (e1) 213 while (e1)
209 { 214 {
210 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; 215 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl;
211 216
212 if (e1->tagName()==Config) 217 if (e1->tagName()==Config)
213 { 218 {
214 syntaxContextData *data=new ( syntaxContextData); 219 syntaxContextData *data=new ( syntaxContextData);
215 data->currentGroup=0; 220 data->currentGroup=0;
216 data->parent=0; 221 data->parent=0;
217 data->item=e1; 222 data->item=e1;
218 return data; 223 return data;
219 } 224 }
220 225
221 e1=e1->nextChild(); 226 e1=e1->nextChild();
222 } 227 }
223 228
224 kdDebug(13010) << "WARNING :returning null 3"<< endl; 229 kdDebug(13010) << "WARNING :returning null 3"<< endl;
225 return 0; 230 return 0;
226 } 231 }
227 232
228 e=e->nextChild(); 233 e=e->nextChild();
229 } 234 }
230 235
231 kdDebug(13010) << "WARNING :returning null 4" << endl; 236 kdDebug(13010) << "WARNING :returning null 4" << endl;
232 return 0; 237 return 0;
@@ -241,66 +246,66 @@ syntaxContextData* SyntaxDocument::getGroupInfo(const QString& mainGroupName, co
241 246
242 while (e) 247 while (e)
243 { 248 {
244 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl; 249 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl;
245 250
246 if (e->tagName().compare(mainGroupName)==0 ) 251 if (e->tagName().compare(mainGroupName)==0 )
247 { 252 {
248 Opie::Core::XMLElement *e1=e->firstChild(); 253 Opie::Core::XMLElement *e1=e->firstChild();
249 254
250 while (e1) 255 while (e1)
251 { 256 {
252 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; 257 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl;
253 if (e1->tagName()==group+"s") 258 if (e1->tagName()==group+"s")
254 { 259 {
255 syntaxContextData *data=new ( syntaxContextData); 260 syntaxContextData *data=new ( syntaxContextData);
256 data->parent=e1; 261 data->parent=e1;
257 data->currentGroup=0; 262 data->currentGroup=0;
258 data->item=0; 263 data->item=0;
259 return data; 264 return data;
260 } 265 }
261 266
262 e1=e1->nextChild(); 267 e1=e1->nextChild();
263 } 268 }
264 269
265 kdDebug(13010) << "WARNING : getGroupInfo returning null :1 " << endl; 270 kdDebug(13010) << "WARNING : getGroupInfo returning null :1 " << endl;
266 return 0; 271 return 0;
267 } 272 }
268 273
269 e=e->nextChild(); 274 e=e->nextChild();
270 } 275 }
271 276
272 kdDebug(13010) << "WARNING : getGroupInfo returning null :2" << endl; 277 kdDebug(13010) << "WARNING : getGroupInfo returning null :2" << endl;
273 return 0; 278 return 0;
274} 279}
275 280
276 281
277QStringList& SyntaxDocument::finddata(const QString& mainGroup,const QString& type,bool clearList) 282QStringList& SyntaxDocument::finddata(const QString& mainGroup,const QString& type,bool clearList)
278{ 283{
279 Opie::Core::XMLElement *e = m_root->firstChild(); 284 Opie::Core::XMLElement *e = m_root->firstChild();
280 if (clearList) 285 if (clearList)
281 m_data.clear(); 286 m_data.clear();
282 287
283 for(e=e->firstChild(); e; e=e->nextChild()) 288 for(e=e->firstChild(); e; e=e->nextChild())
284 { 289 {
285 if (e->tagName()==mainGroup) 290 if (e->tagName()==mainGroup)
286 { 291 {
287 for (Opie::Core::XMLElement *e1=e->firstChild();e1;e1=e1->nextChild()) 292 for (Opie::Core::XMLElement *e1=e->firstChild();e1;e1=e1->nextChild())
288 { 293 {
289 if (e1->tagName()!="list") continue; 294 if (e1->tagName()!="list") continue;
290 295
291 if (e1->attribute("name")==type) 296 if (e1->attribute("name")==type)
292 { 297 {
293 for (Opie::Core::XMLElement *e2=e1->firstChild();e2;e2=e2->nextChild()) 298 for (Opie::Core::XMLElement *e2=e1->firstChild();e2;e2=e2->nextChild())
294 { 299 {
295 qDebug("FOUND A LIST ENTRY("+e2->tagName()+"):"+e2->firstChild()->value()); 300 odebug << "FOUND A LIST ENTRY("+e2->tagName()+"):"+e2->firstChild()->value() << oendl;
296 m_data+=e2->firstChild()->value().stripWhiteSpace(); 301 m_data+=e2->firstChild()->value().stripWhiteSpace();
297 } 302 }
298 break; 303 break;
299 } 304 }
300 } 305 }
301 break; 306 break;
302 } 307 }
303 } 308 }
304 309
305 return m_data; 310 return m_data;
306} 311}
diff --git a/noncore/apps/tinykate/libkate/kateconfig.cpp b/noncore/apps/tinykate/libkate/kateconfig.cpp
index 96f91fb..782b629 100644
--- a/noncore/apps/tinykate/libkate/kateconfig.cpp
+++ b/noncore/apps/tinykate/libkate/kateconfig.cpp
@@ -5,64 +5,69 @@
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define QTOPIA_INTERNAL_LANGLIST
22#include "kateconfig.h"
23
24/* OPIE */
25#include <opie2/odebug.h>
26#include <qpe/global.h>
27
28/* QT */
21#include <qdir.h> 29#include <qdir.h>
22#include <qmessagebox.h> 30#include <qmessagebox.h>
23#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 31#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
24#include <qtextcodec.h> 32#include <qtextcodec.h>
25#endif 33#endif
26#include <qtextstream.h> 34#include <qtextstream.h>
27 35
36/* STD */
28#include <sys/stat.h> 37#include <sys/stat.h>
29#include <sys/types.h> 38#include <sys/types.h>
30#include <fcntl.h> 39#include <fcntl.h>
31#include <stdlib.h> 40#include <stdlib.h>
32#include <unistd.h> 41#include <unistd.h>
33 42
34#define QTOPIA_INTERNAL_LANGLIST
35#include "kateconfig.h"
36#include <qpe/global.h>
37
38 43
39/*! 44/*!
40 \internal 45 \internal
41*/ 46*/
42QString KateConfig::configFilename(const QString& name, Domain d) 47QString KateConfig::configFilename(const QString& name, Domain d)
43{ 48{
44 switch (d) { 49 switch (d) {
45 case File: 50 case File:
46 return name; 51 return name;
47 case User: { 52 case User: {
48 QDir dir = (QString(getenv("HOME")) + "/Settings"); 53 QDir dir = (QString(getenv("HOME")) + "/Settings");
49 if ( !dir.exists() ) 54 if ( !dir.exists() )
50 mkdir(dir.path().local8Bit(),0700); 55 mkdir(dir.path().local8Bit(),0700);
51 return dir.path() + "/" + name + ".conf"; 56 return dir.path() + "/" + name + ".conf";
52 } 57 }
53 } 58 }
54 return name; 59 return name;
55} 60}
56 61
57/*! 62/*!
58 \class KateConfig config.h 63 \class KateConfig config.h
59 \brief The KateConfig class provides for saving application cofniguration state. 64 \brief The KateConfig class provides for saving application cofniguration state.
60 65
61 You should keep a KateConfig in existence only while you do not want others 66 You should keep a KateConfig in existence only while you do not want others
62 to be able to change the state. There is no locking currently, but there 67 to be able to change the state. There is no locking currently, but there
63 may be in the future. 68 may be in the future.
64*/ 69*/
65 70
66/*! 71/*!
67 \enum KateConfig::KateConfigGroup 72 \enum KateConfig::KateConfigGroup
68 \internal 73 \internal
@@ -80,178 +85,178 @@ QString KateConfig::configFilename(const QString& name, Domain d)
80/*! 85/*!
81 Constructs a config that will load or create a configuration with the 86 Constructs a config that will load or create a configuration with the
82 given \a name in the given \a domain. 87 given \a name in the given \a domain.
83 88
84 You must call setGroup() before doing much else with the KateConfig. 89 You must call setGroup() before doing much else with the KateConfig.
85 90
86 In the default Domain, \e User, 91 In the default Domain, \e User,
87 the configuration is user-specific. \a name should not contain "/" in 92 the configuration is user-specific. \a name should not contain "/" in
88 this case, and in general should be the name of the C++ class that is 93 this case, and in general should be the name of the C++ class that is
89 primarily responsible for maintaining the configuration. 94 primarily responsible for maintaining the configuration.
90 95
91 In the File Domain, \a name is an absolute filename. 96 In the File Domain, \a name is an absolute filename.
92*/ 97*/
93KateConfig::KateConfig( const QString &name, Domain domain ) 98KateConfig::KateConfig( const QString &name, Domain domain )
94 : filename( configFilename(name,domain) ) 99 : filename( configFilename(name,domain) )
95{ 100{
96 qWarning("KateConfig constructor\n"); 101 owarn << "KateConfig constructor\n" << oendl;
97 git = groups.end(); 102 git = groups.end();
98 read(); 103 read();
99 QStringList l = Global::languageList(); 104 QStringList l = Global::languageList();
100 lang = l[0]; 105 lang = l[0];
101 glang = l[1]; 106 glang = l[1];
102} 107}
103 108
104 109
105// Sharp ROM compatibility 110// Sharp ROM compatibility
106KateConfig::KateConfig ( const QString &name, bool what ) 111KateConfig::KateConfig ( const QString &name, bool what )
107 : filename( configFilename(name,what ? User : File) ) 112 : filename( configFilename(name,what ? User : File) )
108{ 113{
109 git = groups.end(); 114 git = groups.end();
110 read(); 115 read();
111 QStringList l = Global::languageList(); 116 QStringList l = Global::languageList();
112 lang = l[0]; 117 lang = l[0];
113 glang = l[1]; 118 glang = l[1];
114} 119}
115 120
116/*! 121/*!
117 Writes any changes to disk and destroys the in-memory object. 122 Writes any changes to disk and destroys the in-memory object.
118*/ 123*/
119KateConfig::~KateConfig() 124KateConfig::~KateConfig()
120{ 125{
121 qWarning("KateConfig destructor\n"); 126 owarn << "KateConfig destructor\n" << oendl;
122 if ( changed ) 127 if ( changed )
123 write(); 128 write();
124} 129}
125 130
126/*! 131/*!
127 Returns whether the current group has an entry called \a key. 132 Returns whether the current group has an entry called \a key.
128*/ 133*/
129bool KateConfig::hasKey( const QString &key ) const 134bool KateConfig::hasKey( const QString &key ) const
130{ 135{
131 if ( groups.end() == git ) 136 if ( groups.end() == git )
132 return FALSE; 137 return FALSE;
133 KateConfigGroup::ConstIterator it = ( *git ).find( key ); 138 KateConfigGroup::ConstIterator it = ( *git ).find( key );
134 return it != ( *git ).end(); 139 return it != ( *git ).end();
135} 140}
136 141
137/*! 142/*!
138 Sets the current group for subsequent reading and writing of 143 Sets the current group for subsequent reading and writing of
139 entries to \a gname. Grouping allows the application to partition the namespace. 144 entries to \a gname. Grouping allows the application to partition the namespace.
140 145
141 This function must be called prior to any reading or writing 146 This function must be called prior to any reading or writing
142 of entries. 147 of entries.
143 148
144 The \a gname must not be empty. 149 The \a gname must not be empty.
145*/ 150*/
146void KateConfig::setGroup( const QString &gname ) 151void KateConfig::setGroup( const QString &gname )
147{ 152{
148 QMap< QString, KateConfigGroup>::Iterator it = groups.find( gname ); 153 QMap< QString, KateConfigGroup>::Iterator it = groups.find( gname );
149 if ( it == groups.end() ) { 154 if ( it == groups.end() ) {
150 git = groups.insert( gname, KateConfigGroup() ); 155 git = groups.insert( gname, KateConfigGroup() );
151 changed = TRUE; 156 changed = TRUE;
152 return; 157 return;
153 } 158 }
154 git = it; 159 git = it;
155} 160}
156 161
157/*! 162/*!
158 Writes a (\a key, \a value) entry to the current group. 163 Writes a (\a key, \a value) entry to the current group.
159 164
160 \sa readEntry() 165 \sa readEntry()
161*/ 166*/
162void KateConfig::writeEntry( const QString &key, const char* value ) 167void KateConfig::writeEntry( const QString &key, const char* value )
163{ 168{
164 writeEntry(key,QString(value)); 169 writeEntry(key,QString(value));
165} 170}
166 171
167/*! 172/*!
168 Writes a (\a key, \a value) entry to the current group. 173 Writes a (\a key, \a value) entry to the current group.
169 174
170 \sa readEntry() 175 \sa readEntry()
171*/ 176*/
172void KateConfig::writeEntry( const QString &key, const QString &value ) 177void KateConfig::writeEntry( const QString &key, const QString &value )
173{ 178{
174 if ( git == groups.end() ) { 179 if ( git == groups.end() ) {
175 qWarning( "no group set" ); 180 owarn << "no group set" << oendl;
176 return; 181 return;
177 } 182 }
178 if ( (*git)[key] != value ) { 183 if ( (*git)[key] != value ) {
179 ( *git ).insert( key, value ); 184 ( *git ).insert( key, value );
180 changed = TRUE; 185 changed = TRUE;
181 } 186 }
182} 187}
183 188
184/* 189/*
185 Note that the degree of protection offered by the encryption here is 190 Note that the degree of protection offered by the encryption here is
186 only sufficient to avoid the most casual observation of the configuration 191 only sufficient to avoid the most casual observation of the configuration
187 files. People with access to the files can write down the contents and 192 files. People with access to the files can write down the contents and
188 decrypt it using this source code. 193 decrypt it using this source code.
189 194
190 Conceivably, and at some burden to the user, this encryption could 195 Conceivably, and at some burden to the user, this encryption could
191 be improved. 196 be improved.
192*/ 197*/
193static QString encipher(const QString& plain) 198static QString encipher(const QString& plain)
194{ 199{
195 // mainly, we make it long 200 // mainly, we make it long
196 QString cipher; 201 QString cipher;
197 int mix=28730492; 202 int mix=28730492;
198 for (int i=0; i<(int)plain.length(); i++) { 203 for (int i=0; i<(int)plain.length(); i++) {
199 int u = plain[i].unicode(); 204 int u = plain[i].unicode();
200 int c = u ^ mix; 205 int c = u ^ mix;
201 QString x = QString::number(c,36); 206 QString x = QString::number(c,36);
202 cipher.append(QChar('a'+x.length())); 207 cipher.append(QChar('a'+x.length()));
203 cipher.append(x); 208 cipher.append(x);
204 mix *= u; 209 mix *= u;
205 } 210 }
206 return cipher; 211 return cipher;
207} 212}
208 213
209static QString decipher(const QString& cipher) 214static QString decipher(const QString& cipher)
210{ 215{
211 QString plain; 216 QString plain;
212 int mix=28730492; 217 int mix=28730492;
213 for (int i=0; i<(int)cipher.length();) { 218 for (int i=0; i<(int)cipher.length();) {
214 int l = cipher[i].unicode()-'a'; 219 int l = cipher[i].unicode()-'a';
215 QString x = cipher.mid(i+1,l); i+=l+1; 220 QString x = cipher.mid(i+1,l); i+=l+1;
216 int u = x.toInt(0,36) ^ mix; 221 int u = x.toInt(0,36) ^ mix;
217 plain.append(QChar(u)); 222 plain.append(QChar(u));
218 mix *= u; 223 mix *= u;
219 } 224 }
220 return plain; 225 return plain;
221} 226}
222 227
223/*! 228/*!
224 Writes an encrypted (\a key, \a value) entry to the current group. 229 Writes an encrypted (\a key, \a value) entry to the current group.
225 230
226 Note that the degree of protection offered by the encryption is 231 Note that the degree of protection offered by the encryption is
227 only sufficient to avoid the most casual observation of the configuration 232 only sufficient to avoid the most casual observation of the configuration
228 files. 233 files.
229 234
230 \sa readEntry() 235 \sa readEntry()
231*/ 236*/
232void KateConfig::writeEntryCrypt( const QString &key, const QString &value ) 237void KateConfig::writeEntryCrypt( const QString &key, const QString &value )
233{ 238{
234 if ( git == groups.end() ) { 239 if ( git == groups.end() ) {
235 qWarning( "no group set" ); 240 owarn << "no group set" << oendl;
236 return; 241 return;
237 } 242 }
238 QString evalue = encipher(value); 243 QString evalue = encipher(value);
239 if ( (*git)[key] != evalue ) { 244 if ( (*git)[key] != evalue ) {
240 ( *git ).insert( key, evalue ); 245 ( *git ).insert( key, evalue );
241 changed = TRUE; 246 changed = TRUE;
242 } 247 }
243} 248}
244 249
245/*! 250/*!
246 Writes a (\a key, \a num) entry to the current group. 251 Writes a (\a key, \a num) entry to the current group.
247 252
248 \sa readNumEntry() 253 \sa readNumEntry()
249*/ 254*/
250void KateConfig::writeEntry( const QString &key, int num ) 255void KateConfig::writeEntry( const QString &key, int num )
251{ 256{
252 QString s; 257 QString s;
253 s.setNum( num ); 258 s.setNum( num );
254 writeEntry( key, s ); 259 writeEntry( key, s );
255} 260}
256 261
257void KateConfig::writeEntry( const QString &key, unsigned int num ) 262void KateConfig::writeEntry( const QString &key, unsigned int num )
@@ -274,359 +279,359 @@ void KateConfig::writeEntry( const QString &key, bool b )
274 s.setNum( ( int )b ); 279 s.setNum( ( int )b );
275 writeEntry( key, s ); 280 writeEntry( key, s );
276} 281}
277#endif 282#endif
278 283
279/*! 284/*!
280 Writes a (\a key, \a lst) entry to the current group. The list 285 Writes a (\a key, \a lst) entry to the current group. The list
281 is separated by \a sep, so the strings must not contain that character. 286 is separated by \a sep, so the strings must not contain that character.
282 287
283 \sa readListEntry() 288 \sa readListEntry()
284*/ 289*/
285void KateConfig::writeEntry( const QString &key, const QStringList &lst, const QChar &sep ) 290void KateConfig::writeEntry( const QString &key, const QStringList &lst, const QChar &sep )
286{ 291{
287 QString s; 292 QString s;
288 QStringList::ConstIterator it = lst.begin(); 293 QStringList::ConstIterator it = lst.begin();
289 for ( ; it != lst.end(); ++it ) 294 for ( ; it != lst.end(); ++it )
290 s += *it + sep; 295 s += *it + sep;
291 writeEntry( key, s ); 296 writeEntry( key, s );
292} 297}
293 298
294void KateConfig::writeEntry( const QString &key, const QColor &val ) 299void KateConfig::writeEntry( const QString &key, const QColor &val )
295{ 300{
296 QStringList l; 301 QStringList l;
297 l.append( QString().setNum(val.red()) ); 302 l.append( QString().setNum(val.red()) );
298 l.append( QString().setNum(val.green()) ); 303 l.append( QString().setNum(val.green()) );
299 l.append( QString().setNum(val.blue()) ); 304 l.append( QString().setNum(val.blue()) );
300 305
301 writeEntry( key, l, QChar(',') ); 306 writeEntry( key, l, QChar(',') );
302} 307}
303 308
304void KateConfig::writeEntry( const QString &key, const QFont &val ) 309void KateConfig::writeEntry( const QString &key, const QFont &val )
305{ 310{
306 QStringList l; 311 QStringList l;
307 l.append( val.family() ); 312 l.append( val.family() );
308 l.append( QString().setNum(val.pointSize()) ); 313 l.append( QString().setNum(val.pointSize()) );
309 l.append( QString().setNum(val.weight()) ); 314 l.append( QString().setNum(val.weight()) );
310 l.append( QString().setNum((int)val.italic()) ); 315 l.append( QString().setNum((int)val.italic()) );
311 l.append( QString().setNum((int)val.charSet()) ); 316 l.append( QString().setNum((int)val.charSet()) );
312 317
313 writeEntry( key, l, QChar(',') ); 318 writeEntry( key, l, QChar(',') );
314} 319}
315 320
316/*! 321/*!
317 Removes the \a key entry from the current group. Does nothing if 322 Removes the \a key entry from the current group. Does nothing if
318 there is no such entry. 323 there is no such entry.
319*/ 324*/
320 325
321void KateConfig::removeEntry( const QString &key ) 326void KateConfig::removeEntry( const QString &key )
322{ 327{
323 if ( git == groups.end() ) { 328 if ( git == groups.end() ) {
324 qWarning( "no group set" ); 329 owarn << "no group set" << oendl;
325 return; 330 return;
326 } 331 }
327 ( *git ).remove( key ); 332 ( *git ).remove( key );
328 changed = TRUE; 333 changed = TRUE;
329} 334}
330 335
331/*! 336/*!
332 \fn bool KateConfig::operator == ( const KateConfig & other ) const 337 \fn bool KateConfig::operator == ( const KateConfig & other ) const
333 338
334 Tests for equality with \a other. KateConfig objects are equal if they refer to the same filename. 339 Tests for equality with \a other. KateConfig objects are equal if they refer to the same filename.
335*/ 340*/
336 341
337/*! 342/*!
338 \fn bool KateConfig::operator != ( const KateConfig & other ) const 343 \fn bool KateConfig::operator != ( const KateConfig & other ) const
339 344
340 Tests for inequality with \a other. KateConfig objects are equal if they refer to the same filename. 345 Tests for inequality with \a other. KateConfig objects are equal if they refer to the same filename.
341*/ 346*/
342 347
343/*! 348/*!
344 \fn QString KateConfig::readEntry( const QString &key, const QString &deflt ) const 349 \fn QString KateConfig::readEntry( const QString &key, const QString &deflt ) const
345 350
346 Reads a string entry stored with \a key, defaulting to \a deflt if there is no entry. 351 Reads a string entry stored with \a key, defaulting to \a deflt if there is no entry.
347*/ 352*/
348 353
349/*! 354/*!
350 \internal 355 \internal
351 For compatibility, non-const version. 356 For compatibility, non-const version.
352*/ 357*/
353QString KateConfig::readEntry( const QString &key, const QString &deflt ) 358QString KateConfig::readEntry( const QString &key, const QString &deflt )
354{ 359{
355 QString res = readEntryDirect( key+"["+lang+"]" ); 360 QString res = readEntryDirect( key+"["+lang+"]" );
356 if ( !res.isNull() ) 361 if ( !res.isNull() )
357 return res; 362 return res;
358 if ( !glang.isEmpty() ) { 363 if ( !glang.isEmpty() ) {
359 res = readEntryDirect( key+"["+glang+"]" ); 364 res = readEntryDirect( key+"["+glang+"]" );
360 if ( !res.isNull() ) 365 if ( !res.isNull() )
361 return res; 366 return res;
362 } 367 }
363 return readEntryDirect( key, deflt ); 368 return readEntryDirect( key, deflt );
364} 369}
365 370
366/*! 371/*!
367 \fn QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt ) const 372 \fn QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt ) const
368 373
369 Reads an encrypted string entry stored with \a key, defaulting to \a deflt if there is no entry. 374 Reads an encrypted string entry stored with \a key, defaulting to \a deflt if there is no entry.
370*/ 375*/
371 376
372/*! 377/*!
373 \internal 378 \internal
374 For compatibility, non-const version. 379 For compatibility, non-const version.
375*/ 380*/
376QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt ) 381QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt )
377{ 382{
378 QString res = readEntryDirect( key+"["+lang+"]" ); 383 QString res = readEntryDirect( key+"["+lang+"]" );
379 if ( res.isNull() && glang.isEmpty() ) 384 if ( res.isNull() && glang.isEmpty() )
380 res = readEntryDirect( key+"["+glang+"]" ); 385 res = readEntryDirect( key+"["+glang+"]" );
381 if ( res.isNull() ) 386 if ( res.isNull() )
382 res = readEntryDirect( key, QString::null ); 387 res = readEntryDirect( key, QString::null );
383 if ( res.isNull() ) 388 if ( res.isNull() )
384 return deflt; 389 return deflt;
385 return decipher(res); 390 return decipher(res);
386} 391}
387 392
388/*! 393/*!
389 \fn QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) const 394 \fn QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) const
390 \internal 395 \internal
391*/ 396*/
392 397
393/*! 398/*!
394 \internal 399 \internal
395 For compatibility, non-const version. 400 For compatibility, non-const version.
396*/ 401*/
397QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) 402QString KateConfig::readEntryDirect( const QString &key, const QString &deflt )
398{ 403{
399 if ( git == groups.end() ) { 404 if ( git == groups.end() ) {
400 //qWarning( "no group set" ); 405 //owarn << "no group set" << oendl;
401 return deflt; 406 return deflt;
402 } 407 }
403 KateConfigGroup::ConstIterator it = ( *git ).find( key ); 408 KateConfigGroup::ConstIterator it = ( *git ).find( key );
404 if ( it != ( *git ).end() ) 409 if ( it != ( *git ).end() )
405 return *it; 410 return *it;
406 else 411 else
407 return deflt; 412 return deflt;
408} 413}
409 414
410/*! 415/*!
411 \fn int KateConfig::readNumEntry( const QString &key, int deflt ) const 416 \fn int KateConfig::readNumEntry( const QString &key, int deflt ) const
412 Reads a numeric entry stored with \a key, defaulting to \a deflt if there is no entry. 417 Reads a numeric entry stored with \a key, defaulting to \a deflt if there is no entry.
413*/ 418*/
414 419
415/*! 420/*!
416 \internal 421 \internal
417 For compatibility, non-const version. 422 For compatibility, non-const version.
418*/ 423*/
419int KateConfig::readNumEntry( const QString &key, int deflt ) 424int KateConfig::readNumEntry( const QString &key, int deflt )
420{ 425{
421 QString s = readEntry( key ); 426 QString s = readEntry( key );
422 if ( s.isEmpty() ) 427 if ( s.isEmpty() )
423 return deflt; 428 return deflt;
424 else 429 else
425 return s.toInt(); 430 return s.toInt();
426} 431}
427 432
428/*! 433/*!
429 \fn bool KateConfig::readBoolEntry( const QString &key, bool deflt ) const 434 \fn bool KateConfig::readBoolEntry( const QString &key, bool deflt ) const
430 Reads a bool entry stored with \a key, defaulting to \a deflt if there is no entry. 435 Reads a bool entry stored with \a key, defaulting to \a deflt if there is no entry.
431*/ 436*/
432 437
433/*! 438/*!
434 \internal 439 \internal
435 For compatibility, non-const version. 440 For compatibility, non-const version.
436*/ 441*/
437bool KateConfig::readBoolEntry( const QString &key, bool deflt ) 442bool KateConfig::readBoolEntry( const QString &key, bool deflt )
438{ 443{
439 QString s = readEntry( key ); 444 QString s = readEntry( key );
440 if ( s.isEmpty() ) 445 if ( s.isEmpty() )
441 return deflt; 446 return deflt;
442 else 447 else
443 return (bool)s.toInt(); 448 return (bool)s.toInt();
444} 449}
445 450
446/*! 451/*!
447 \fn QStringList KateConfig::readListEntry( const QString &key, const QChar &sep ) const 452 \fn QStringList KateConfig::readListEntry( const QString &key, const QChar &sep ) const
448 Reads a string list entry stored with \a key, and with \a sep as the separator. 453 Reads a string list entry stored with \a key, and with \a sep as the separator.
449*/ 454*/
450 455
451/*! 456/*!
452 \internal 457 \internal
453 For compatibility, non-const version. 458 For compatibility, non-const version.
454*/ 459*/
455QStringList KateConfig::readListEntry( const QString &key, const QChar &sep ) 460QStringList KateConfig::readListEntry( const QString &key, const QChar &sep )
456{ 461{
457 QString s = readEntry( key ); 462 QString s = readEntry( key );
458 if ( s.isEmpty() ) 463 if ( s.isEmpty() )
459 return QStringList(); 464 return QStringList();
460 else 465 else
461 return QStringList::split( sep, s ); 466 return QStringList::split( sep, s );
462} 467}
463 468
464QColor KateConfig::readColorEntry( const QString &key, const QColor &def ) const 469QColor KateConfig::readColorEntry( const QString &key, const QColor &def ) const
465{ 470{
466 QStringList list = readListEntry(key, QChar(',')); 471 QStringList list = readListEntry(key, QChar(','));
467 if( list.count() != 3 ) 472 if( list.count() != 3 )
468 return def; 473 return def;
469 474
470 return QColor(list[0].toInt(), list[1].toInt(), list[2].toInt()); 475 return QColor(list[0].toInt(), list[1].toInt(), list[2].toInt());
471} 476}
472 477
473QFont KateConfig::readFontEntry( const QString &key, const QFont &def ) const 478QFont KateConfig::readFontEntry( const QString &key, const QFont &def ) const
474{ 479{
475 QStringList list = readListEntry(key, QChar(',')); 480 QStringList list = readListEntry(key, QChar(','));
476 if( list.count() != 5 ) 481 if( list.count() != 5 )
477 return def; 482 return def;
478 483
479 return QFont(list[0], list[1].toInt(), list[2].toInt(), (bool)list[3].toInt(), (QFont::CharSet)list[4].toInt()); 484 return QFont(list[0], list[1].toInt(), list[2].toInt(), (bool)list[3].toInt(), (QFont::CharSet)list[4].toInt());
480} 485}
481 486
482QValueList<int> KateConfig::readIntListEntry( const QString &key ) const 487QValueList<int> KateConfig::readIntListEntry( const QString &key ) const
483{ 488{
484 QString s = readEntry( key ); 489 QString s = readEntry( key );
485 QValueList<int> il; 490 QValueList<int> il;
486 if ( s.isEmpty() ) 491 if ( s.isEmpty() )
487 return il; 492 return il;
488 493
489 QStringList l = QStringList::split( QChar(','), s ); 494 QStringList l = QStringList::split( QChar(','), s );
490 495
491 QStringList::Iterator l_it; 496 QStringList::Iterator l_it;
492 for( l_it = l.begin(); l_it != l.end(); ++l_it ) 497 for( l_it = l.begin(); l_it != l.end(); ++l_it )
493 il.append( (*l_it).toInt() ); 498 il.append( (*l_it).toInt() );
494 return il; 499 return il;
495} 500}
496 501
497/*! 502/*!
498 Removes all entries from the current group. 503 Removes all entries from the current group.
499*/ 504*/
500void KateConfig::clearGroup() 505void KateConfig::clearGroup()
501{ 506{
502 if ( git == groups.end() ) { 507 if ( git == groups.end() ) {
503 qWarning( "no group set" ); 508 owarn << "no group set" << oendl;
504 return; 509 return;
505 } 510 }
506 if ( !(*git).isEmpty() ) { 511 if ( !(*git).isEmpty() ) {
507 ( *git ).clear(); 512 ( *git ).clear();
508 changed = TRUE; 513 changed = TRUE;
509 } 514 }
510} 515}
511 516
512/*! 517/*!
513 \internal 518 \internal
514*/ 519*/
515void KateConfig::write( const QString &fn ) 520void KateConfig::write( const QString &fn )
516{ 521{
517 QString strNewFile; 522 QString strNewFile;
518 if ( !fn.isEmpty() ) 523 if ( !fn.isEmpty() )
519 filename = fn; 524 filename = fn;
520 strNewFile = filename + ".new"; 525 strNewFile = filename + ".new";
521 526
522 QFile f( strNewFile ); 527 QFile f( strNewFile );
523 if ( !f.open( IO_WriteOnly|IO_Raw ) ) { 528 if ( !f.open( IO_WriteOnly|IO_Raw ) ) {
524 qWarning( "could not open for writing `%s'", strNewFile.latin1() ); 529 owarn << "could not open for writing `" << strNewFile << "'" << oendl;
525 git = groups.end(); 530 git = groups.end();
526 return; 531 return;
527 } 532 }
528 533
529 QString str; 534 QString str;
530 QCString cstr; 535 QCString cstr;
531 QMap< QString, KateConfigGroup >::Iterator g_it = groups.begin(); 536 QMap< QString, KateConfigGroup >::Iterator g_it = groups.begin();
532 537
533 for ( ; g_it != groups.end(); ++g_it ) { 538 for ( ; g_it != groups.end(); ++g_it ) {
534 str += "[" + g_it.key() + "]\n"; 539 str += "[" + g_it.key() + "]\n";
535 KateConfigGroup::Iterator e_it = ( *g_it ).begin(); 540 KateConfigGroup::Iterator e_it = ( *g_it ).begin();
536 for ( ; e_it != ( *g_it ).end(); ++e_it ) 541 for ( ; e_it != ( *g_it ).end(); ++e_it )
537 str += e_it.key() + " = " + *e_it + "\n"; 542 str += e_it.key() + " = " + *e_it + "\n";
538 } 543 }
539 cstr = str.utf8(); 544 cstr = str.utf8();
540 545
541 int total_length; 546 int total_length;
542 total_length = f.writeBlock( cstr.data(), cstr.length() ); 547 total_length = f.writeBlock( cstr.data(), cstr.length() );
543 if ( total_length != int(cstr.length()) ) { 548 if ( total_length != int(cstr.length()) ) {
544 QMessageBox::critical( 0, QObject::tr("Out of Space"), 549 QMessageBox::critical( 0, QObject::tr("Out of Space"),
545 QObject::tr("There was a problem creating\nKateConfiguration Information \nfor this program.\n\nPlease free up some space and\ntry again.") ); 550 QObject::tr("There was a problem creating\nKateConfiguration Information \nfor this program.\n\nPlease free up some space and\ntry again.") );
546 f.close(); 551 f.close();
547 QFile::remove( strNewFile ); 552 QFile::remove( strNewFile );
548 return; 553 return;
549 } 554 }
550 555
551 f.close(); 556 f.close();
552 // now rename the file... 557 // now rename the file...
553 if ( rename( strNewFile, filename ) < 0 ) { 558 if ( rename( strNewFile, filename ) < 0 ) {
554 qWarning( "problem renaming the file %s to %s", strNewFile.latin1(), 559 qWarning( "problem renaming the file %s to %s", strNewFile.latin1(),
555 filename.latin1() ); 560 filename.latin1() );
556 QFile::remove( strNewFile ); 561 QFile::remove( strNewFile );
557 } 562 }
558} 563}
559 564
560/*! 565/*!
561 Returns whether the KateConfig is in a valid state. 566 Returns whether the KateConfig is in a valid state.
562*/ 567*/
563bool KateConfig::isValid() const 568bool KateConfig::isValid() const
564{ 569{
565 return groups.end() != git; 570 return groups.end() != git;
566} 571}
567 572
568/*! 573/*!
569 \internal 574 \internal
570*/ 575*/
571void KateConfig::read() 576void KateConfig::read()
572{ 577{
573 changed = FALSE; 578 changed = FALSE;
574 579
575 if ( !QFileInfo( filename ).exists() ) { 580 if ( !QFileInfo( filename ).exists() ) {
576 git = groups.end(); 581 git = groups.end();
577 return; 582 return;
578 } 583 }
579 584
580 QFile f( filename ); 585 QFile f( filename );
581 if ( !f.open( IO_ReadOnly ) ) { 586 if ( !f.open( IO_ReadOnly ) ) {
582 git = groups.end(); 587 git = groups.end();
583 return; 588 return;
584 } 589 }
585 590
586 QTextStream s( &f ); 591 QTextStream s( &f );
587#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 592#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
588 // The below should work, but doesn't in Qt 2.3.0 593 // The below should work, but doesn't in Qt 2.3.0
589 s.setCodec( QTextCodec::codecForMib( 106 ) ); 594 s.setCodec( QTextCodec::codecForMib( 106 ) );
590#else 595#else
591 s.setEncoding( QTextStream::UnicodeUTF8 ); 596 s.setEncoding( QTextStream::UnicodeUTF8 );
592#endif 597#endif
593 598
594 QStringList list = QStringList::split('\n', s.read() ); 599 QStringList list = QStringList::split('\n', s.read() );
595 f.close(); 600 f.close();
596 601
597 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 602 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
598 if ( !parse( *it ) ) { 603 if ( !parse( *it ) ) {
599 git = groups.end(); 604 git = groups.end();
600 return; 605 return;
601 } 606 }
602 } 607 }
603} 608}
604 609
605/*! 610/*!
606 \internal 611 \internal
607*/ 612*/
608bool KateConfig::parse( const QString &l ) 613bool KateConfig::parse( const QString &l )
609{ 614{
610 QString line = l.stripWhiteSpace(); 615 QString line = l.stripWhiteSpace();
611 616
612 if ( line [0] == QChar ( '#' )) 617 if ( line [0] == QChar ( '#' ))
613 return true; // ignore comments 618 return true; // ignore comments
614 619
615 if ( line[ 0 ] == QChar( '[' ) ) { 620 if ( line[ 0 ] == QChar( '[' ) ) {
616 QString gname = line; 621 QString gname = line;
617 gname = gname.remove( 0, 1 ); 622 gname = gname.remove( 0, 1 );
618 if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) ) 623 if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) )
619 gname = gname.remove( gname.length() - 1, 1 ); 624 gname = gname.remove( gname.length() - 1, 1 );
620 git = groups.insert( gname, KateConfigGroup() ); 625 git = groups.insert( gname, KateConfigGroup() );
621 } else if ( !line.isEmpty() ) { 626 } else if ( !line.isEmpty() ) {
622 if ( git == groups.end() ) 627 if ( git == groups.end() )
623 return FALSE; 628 return FALSE;
624 int eq = line.find( '=' ); 629 int eq = line.find( '=' );
625 if ( eq == -1 ) 630 if ( eq == -1 )
626 return FALSE; 631 return FALSE;
627 QString key = line.left(eq).stripWhiteSpace(); 632 QString key = line.left(eq).stripWhiteSpace();
628 QString value = line.mid(eq+1).stripWhiteSpace(); 633 QString value = line.mid(eq+1).stripWhiteSpace();
629 ( *git ).insert( key, value ); 634 ( *git ).insert( key, value );
630 } 635 }
631 return TRUE; 636 return TRUE;
632} 637}
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp
index 3c9a637..9865c35 100644
--- a/noncore/apps/tinykate/tinykate.cpp
+++ b/noncore/apps/tinykate/tinykate.cpp
@@ -1,44 +1,49 @@
1/*************************************************************************** 1/***************************************************************************
2 tinykate.cpp 2 tinykate.cpp
3 Tiny KATE mainwindow 3 Tiny KATE mainwindow
4 ------------------- 4 -------------------
5 begin : November 2002 5 begin : November 2002
6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> 6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org>
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free softwaSre; you can redistribute it and/or modify * 11 * This program is free softwaSre; 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. * 13 * the Free Software Foundation. *
14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * 14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include <qaction.h>
18#include <qtoolbutton.h>
19#include <qmenubar.h>
20#include <qpe/resource.h>
21#include <qpe/qpeapplication.h>
22 17
18#include "tinykate.h"
19
20#include "katedocument.h"
21#include "kglobal.h"
22
23/* OPIE */
24#include <opie2/odebug.h>
23#include <opie2/ofiledialog.h> 25#include <opie2/ofiledialog.h>
26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h>
24 28
25#include "tinykate.h" 29/* QT */
30#include <qaction.h>
31#include <qtoolbutton.h>
32#include <qmenubar.h>
26 33
27#include <katedocument.h>
28#include <kglobal.h>
29 34
30using namespace Opie::Ui; 35using namespace Opie::Ui;
31TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : 36TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
32 QMainWindow( parent, name, f ) 37 QMainWindow( parent, name, f )
33{ 38{
34 shutDown=false; 39 shutDown=false;
35 nextUnnamed=0; 40 nextUnnamed=0;
36 currentView=0; 41 currentView=0;
37 viewCount=0; 42 viewCount=0;
38 setCaption(tr("TinyKATE")); 43 setCaption(tr("TinyKATE"));
39 KGlobal::setAppName("TinyKATE"); 44 KGlobal::setAppName("TinyKATE");
40 45
41 QMenuBar *mb = new QMenuBar( this ); 46 QMenuBar *mb = new QMenuBar( this );
42 mb->setMargin( 0 ); 47 mb->setMargin( 0 );
43 48
44 tabwidget=new OTabWidget(this); 49 tabwidget=new OTabWidget(this);
@@ -139,62 +144,62 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
139 { 144 {
140 hlmenu->insertItem(hlm->hlName(i),i); 145 hlmenu->insertItem(hlm->hlName(i),i);
141 } 146 }
142 popup->insertItem(tr("Highlighting"),hlmenu); 147 popup->insertItem(tr("Highlighting"),hlmenu);
143 148
144 149
145 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); 150 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 );
146 utilSettings->addTo( popup); 151 utilSettings->addTo( popup);
147 152
148 if( qApp->argc() > 1) open(qApp->argv()[1]); 153 if( qApp->argc() > 1) open(qApp->argv()[1]);
149 else slotNew(); 154 else slotNew();
150 155
151} 156}
152 157
153TinyKate::~TinyKate( ) 158TinyKate::~TinyKate( )
154{ 159{
155 qWarning("TinyKate destructor\n"); 160 owarn << "TinyKate destructor\n" << oendl;
156 161
157 shutDown=true; 162 shutDown=true;
158 while (currentView!=0) { 163 while (currentView!=0) {
159 slotClose(); 164 slotClose();
160 } 165 }
161 166
162 if( KGlobal::config() != 0 ) { 167 if( KGlobal::config() != 0 ) {
163 qWarning("deleting KateConfig object..\n"); 168 owarn << "deleting KateConfig object..\n" << oendl;
164 delete KGlobal::config(); 169 delete KGlobal::config();
165 } 170 }
166} 171}
167 172
168void TinyKate::slotOpen( ) 173void TinyKate::slotOpen( )
169{ 174{
170 QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 175 QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
171 QString::null); 176 QString::null);
172 if (!filename.isEmpty()) { 177 if (!filename.isEmpty()) {
173 open(filename); 178 open(filename);
174 } 179 }
175} 180}
176 181
177void TinyKate::open(const QString & filename) 182void TinyKate::open(const QString & filename)
178{ 183{
179 KateDocument *kd= new KateDocument(false, false, this,0,this); 184 KateDocument *kd= new KateDocument(false, false, this,0,this);
180 KTextEditor::View *kv; 185 KTextEditor::View *kv;
181 QFileInfo fi(filename); 186 QFileInfo fi(filename);
182 QString filenamed = fi.fileName(); 187 QString filenamed = fi.fileName();
183 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); 188 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed );
184 qDebug(filename); 189 odebug << filename << oendl;
185 190
186 kd->setDocName( filenamed); 191 kd->setDocName( filenamed);
187 kd->open( filename ); 192 kd->open( filename );
188 viewCount++; 193 viewCount++;
189} 194}
190 195
191void TinyKate::setDocument(const QString& fileref) 196void TinyKate::setDocument(const QString& fileref)
192{ 197{
193 open( fileref ); 198 open( fileref );
194} 199}
195 200
196void TinyKate::slotCurrentChanged( QWidget * view) 201void TinyKate::slotCurrentChanged( QWidget * view)
197{ 202{
198 if (currentView) { 203 if (currentView) {
199 204
200 disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); 205 disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy()));
@@ -236,44 +241,44 @@ void TinyKate::slotClose( )
236{ 241{
237 if (currentView==0) return; 242 if (currentView==0) return;
238 KTextEditor::View *dv=currentView; 243 KTextEditor::View *dv=currentView;
239 currentView=0; 244 currentView=0;
240 tabwidget->removePage(dv); 245 tabwidget->removePage(dv);
241 delete dv->document(); 246 delete dv->document();
242 viewCount--; 247 viewCount--;
243 if ((!viewCount) && (!shutDown)) slotNew(); 248 if ((!viewCount) && (!shutDown)) slotNew();
244} 249}
245 250
246void TinyKate::slotSave() { 251void TinyKate::slotSave() {
247 // feel free to make this how you want 252 // feel free to make this how you want
248 if (currentView==0) return; 253 if (currentView==0) return;
249 254
250 // KateView *kv = (KateView*) currentView; 255 // KateView *kv = (KateView*) currentView;
251 KateDocument *kd = (KateDocument*) currentView->document(); 256 KateDocument *kd = (KateDocument*) currentView->document();
252 // qDebug("saving file "+kd->docName()); 257 // odebug << "saving file "+kd->docName() << oendl;
253 if( kd->docName().isEmpty()) 258 if( kd->docName().isEmpty())
254 slotSaveAs(); 259 slotSaveAs();
255 else 260 else
256 kd->saveFile(); 261 kd->saveFile();
257 // kv->save(); 262 // kv->save();
258 // kd->saveFile(); 263 // kd->saveFile();
259} 264}
260 265
261void TinyKate::slotSaveAs() { 266void TinyKate::slotSaveAs() {
262 if (currentView==0) return; 267 if (currentView==0) return;
263 KateDocument *kd = (KateDocument*) currentView->document(); 268 KateDocument *kd = (KateDocument*) currentView->document();
264 269
265 QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, 270 QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL,
266 QString::null); 271 QString::null);
267 if (!filename.isEmpty()) { 272 if (!filename.isEmpty()) {
268 qDebug("saving file "+filename); 273 odebug << "saving file "+filename << oendl;
269 QFileInfo fi(filename); 274 QFileInfo fi(filename);
270 QString filenamed = fi.fileName(); 275 QString filenamed = fi.fileName();
271 kd->setDocFile( filename); 276 kd->setDocFile( filename);
272 kd->setDocName( filenamed); 277 kd->setDocName( filenamed);
273 kd->saveFile(); 278 kd->saveFile();
274// KTextEditor::View *dv = currentView; 279// KTextEditor::View *dv = currentView;
275// tabwidget->changeTab( dv, filenamed); 280// tabwidget->changeTab( dv, filenamed);
276 // need to change tab label here 281 // need to change tab label here
277 } 282 }
278 283
279} 284}