author | llornkcor <llornkcor> | 2005-02-28 09:24:10 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-02-28 09:24:10 (UTC) |
commit | 61fa699140c5efbb6ba0bf2a62f7e8fbf62976be (patch) (unidiff) | |
tree | 7b3695c8a13d694487011526e3ae052b69b6d5fb | |
parent | 7d4beaf7922f15451da6ba65c2e21fb569887b52 (diff) | |
download | opie-61fa699140c5efbb6ba0bf2a62f7e8fbf62976be.zip opie-61fa699140c5efbb6ba0bf2a62f7e8fbf62976be.tar.gz opie-61fa699140c5efbb6ba0bf2a62f7e8fbf62976be.tar.bz2 |
fix index dl from main view, user 8 bit files by default, do not show audio files
-rw-r--r-- | noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | 1553 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | 27 |
2 files changed, 799 insertions, 781 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp index 7426e80..549c1d2 100644 --- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | |||
@@ -1,1078 +1,1085 @@ | |||
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" | 16 | #include "LibraryDialog.h" |
17 | #include "output.h" | 17 | #include "output.h" |
18 | 18 | ||
19 | /* OPIE */ | 19 | /* OPIE */ |
20 | #include <qpe/applnk.h> | 20 | #include <qpe/applnk.h> |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/qpedialog.h> | 22 | #include <qpe/qpedialog.h> |
23 | #include <opie2/odebug.h> | 23 | #include <opie2/odebug.h> |
24 | 24 | ||
25 | /* QT */ | 25 | /* QT */ |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qmultilineedit.h> | 27 | #include <qmultilineedit.h> |
28 | //#include <qlayout.h> | 28 | //#include <qlayout.h> |
29 | 29 | ||
30 | /* STD */ | 30 | /* STD */ |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <stdio.h> | 32 | #include <stdio.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | 34 | ||
35 | /* | 35 | /* |
36 | * 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 |
37 | * TRUE to construct a modal dialog. */ | 37 | * TRUE to construct a modal dialog. */ |
38 | LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*/, WFlags fl ) | 38 | LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*/, WFlags fl ) |
39 | : QDialog( parent, name, true/* modal*/, fl ) | 39 | : QDialog( parent, name, true/* modal*/, fl ) |
40 | { | 40 | { |
41 | if ( !name ) | 41 | if ( !name ) |
42 | setName( "LibraryDialog" ); | 42 | setName( "LibraryDialog" ); |
43 | indexLoaded=false; | 43 | indexLoaded=false; |
44 | initDialog(); | 44 | initDialog(); |
45 | 45 | ||
46 | // this->setMaximumWidth(240); | 46 | // this->setMaximumWidth(240); |
47 | 47 | ||
48 | index = "GUTINDEX.ALL"; | 48 | index = "GUTINDEX.ALL"; |
49 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; | 49 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; |
50 | local_index = local_library + index; | 50 | local_index = local_library + index; |
51 | 51 | ||
52 | QString iniFile ; | 52 | QString iniFile ; |
53 | iniFile = QPEApplication::qpeDir()+"etc/gutenbrowser/gutenbrowserrc"; | 53 | iniFile = QPEApplication::qpeDir()+"etc/gutenbrowser/gutenbrowserrc"; |
54 | 54 | ||
55 | new_index =QPEApplication::qpeDir()+"etc/gutenbrowser/PGWHOLE.TXT"; | 55 | new_index =QPEApplication::qpeDir()+"etc/gutenbrowser/PGWHOLE.TXT"; |
56 | 56 | ||
57 | old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; | 57 | old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
58 | // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; | 58 | // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
59 | 59 | ||
60 | // iniFile = local_library+"gutenbrowserrc"; | 60 | // iniFile = local_library+"gutenbrowserrc"; |
61 | // new_index = local_library + "PGWHOLE.TXT"; | 61 | // new_index = local_library + "PGWHOLE.TXT"; |
62 | // old_index = local_library + "GUTINDEX.ALL"; | 62 | // old_index = local_library + "GUTINDEX.ALL"; |
63 | 63 | ||
64 | Config config("Gutenbrowser"); | 64 | Config config("Gutenbrowser"); |
65 | 65 | ||
66 | config.setGroup( "HttpServer" ); | 66 | config.setGroup( "HttpServer" ); |
67 | proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); | 67 | proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); |
68 | 68 | ||
69 | config.setGroup( "FTPsite" ); | 69 | config.setGroup( "FTPsite" ); |
70 | ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); | 70 | ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); |
71 | odebug << "Library Dialog: ftp_host is "+ftp_host << oendl; | 71 | odebug << "Library Dialog: ftp_host is "+ftp_host << oendl; |
72 | // 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) ); |
73 | // ftp_host=ftp_host.stripWhiteSpace(); | 73 | // ftp_host=ftp_host.stripWhiteSpace(); |
74 | ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); | 74 | ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); |
75 | 75 | ||
76 | i_binary = 0; | 76 | i_binary = 0; |
77 | 77 | ||
78 | config.setGroup("SortAuth"); | 78 | config.setGroup("SortAuth"); |
79 | if( config.readEntry("authSort", "FALSE") == "TRUE") | 79 | if( config.readEntry("authSort", "FALSE") == "TRUE") |
80 | authBox->setChecked(TRUE); | 80 | authBox->setChecked(TRUE); |
81 | 81 | ||
82 | config.setGroup("General"); | 82 | config.setGroup("General"); |
83 | downDir =config.readEntry( "DownloadDirectory",local_library); | 83 | downDir =config.readEntry( "DownloadDirectory",local_library); |
84 | odebug << "downDir is "+downDir << oendl; | 84 | odebug << "downDir is "+downDir << oendl; |
85 | newindexLib.setName( old_index); | 85 | newindexLib.setName( old_index); |
86 | indexLib.setName( old_index); | 86 | indexLib.setName( old_index); |
87 | 87 | ||
88 | new QPEDialogListener(this); | 88 | new QPEDialogListener(this); |
89 | QTimer::singleShot( 1000, this, SLOT( FindLibrary()) ); | 89 | QTimer::singleShot( 1000, this, SLOT( FindLibrary()) ); |
90 | 90 | ||
91 | } | 91 | } |
92 | 92 | ||
93 | LibraryDialog::~LibraryDialog() | 93 | LibraryDialog::~LibraryDialog() |
94 | { | 94 | { |
95 | // delete QList_Item2; | 95 | // delete QList_Item2; |
96 | // delete QList_Item1; | 96 | // delete QList_Item1; |
97 | // delete QList_Item3; | 97 | // delete QList_Item3; |
98 | // delete QList_Item4; | 98 | // delete QList_Item4; |
99 | // delete QList_Item5; | 99 | // delete QList_Item5; |
100 | 100 | ||
101 | // saveConfig(); | 101 | // saveConfig(); |
102 | } | 102 | } |
103 | 103 | ||
104 | /*This groks using PGWHOLE.TXT */ | 104 | /*This groks using PGWHOLE.TXT */ |
105 | void LibraryDialog::Newlibrary() | 105 | void LibraryDialog::Newlibrary() |
106 | { | 106 | { |
107 | #ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files | 107 | #ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files |
108 | //odebug << "Opening new library index " << newindexLib << "" << oendl; | 108 | //odebug << "Opening new library index " << newindexLib << "" << oendl; |
109 | if ( newindexLib.open( IO_ReadOnly) ) { | 109 | if ( newindexLib.open( IO_ReadOnly) ) { |
110 | setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully | 110 | setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully |
111 | QTextStream indexStream( &newindexLib ); | 111 | QTextStream indexStream( &newindexLib ); |
112 | QString indexLine; | 112 | QString indexLine; |
113 | while ( !indexStream.atEnd() ) { // until end of file.. | 113 | while ( !indexStream.atEnd() ) { // until end of file.. |
114 | indexLine = indexStream.readLine(); | 114 | indexLine = indexStream.readLine(); |
115 | if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { | 115 | if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { |
116 | year = indexLine.mid(4,4); | 116 | year = indexLine.mid(4,4); |
117 | year = year.stripWhiteSpace(); | 117 | year = year.stripWhiteSpace(); |
118 | file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); | 118 | file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); |
119 | file = file.stripWhiteSpace(); | 119 | file = file.stripWhiteSpace(); |
120 | number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); | 120 | number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); |
121 | if( year.toInt() < 1984) | 121 | if( year.toInt() < 1984) |
122 | number = number.left( number.length() -1 ); | 122 | number = number.left( number.length() -1 ); |
123 | number = number.stripWhiteSpace(); | 123 | number = number.stripWhiteSpace(); |
124 | title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); | 124 | title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); |
125 | title = title.stripWhiteSpace(); | 125 | title = title.stripWhiteSpace(); |
126 | 126 | ||
127 | getAuthor(); // groks author | 127 | getAuthor(); // groks author |
128 | author = author.stripWhiteSpace(); | 128 | author = author.stripWhiteSpace(); |
129 | if (authBox->isChecked()) { // this reverses the first name and last name of the author | 129 | if (authBox->isChecked()) { // this reverses the first name and last name of the author |
130 | // odebug << "Sorting last name first" << oendl; | 130 | // odebug << "Sorting last name first" << oendl; |
131 | QString lastName, firstName=""; | 131 | QString lastName, firstName=""; |
132 | int finder=author.findRev( ' ', -1, TRUE); | 132 | int finder=author.findRev( ' ', -1, TRUE); |
133 | lastName=author.right( author.length()-finder); | 133 | lastName=author.right( author.length()-finder); |
134 | firstName=author.left(finder); | 134 | firstName=author.left(finder); |
135 | lastName=lastName.stripWhiteSpace(); | 135 | lastName=lastName.stripWhiteSpace(); |
136 | firstName=firstName.stripWhiteSpace(); | 136 | firstName=firstName.stripWhiteSpace(); |
137 | 137 | ||
138 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names | 138 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names |
139 | author=lastName+", "+firstName; | 139 | author=lastName+", "+firstName; |
140 | } | 140 | } |
141 | 141 | ||
142 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) { | 142 | if( !number.isEmpty() |
143 | 143 | && (title.find( "reserved",0, FALSE) == -1) | |
144 | // fill string list or something to be able to resort the whole library | 144 | && (file.find( "]",0, TRUE) == -1) |
145 | if( author.isEmpty() ) | 145 | && (title.find( "Audio",0, FALSE) == -1)) { |
146 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); | 146 | |
147 | else { | 147 | // fill string list or something to be able to resort the whole library |
148 | 148 | if( author.isEmpty() ) | |
149 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || | 149 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); |
150 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) | 150 | else { |
151 | QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); | 151 | |
152 | 152 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || | |
153 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || | 153 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) |
154 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) | 154 | QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); |
155 | QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file ); | 155 | |
156 | 156 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || | |
157 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || | 157 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) |
158 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) | 158 | QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file ); |
159 | QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file ); | 159 | |
160 | 160 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || | |
161 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || | 161 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) |
162 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) | 162 | QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file ); |
163 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); | 163 | |
164 | 164 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || | |
165 | else | 165 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) |
166 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); | 166 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); |
167 | } | 167 | |
168 | } | 168 | else |
169 | }// end if | 169 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); |
170 | }// end while | 170 | } |
171 | newindexLib.close(); | 171 | } |
172 | } | 172 | }// end if |
173 | }// end while | ||
174 | newindexLib.close(); | ||
175 | } | ||
173 | #ifndef Q_WS_QWS | 176 | #ifndef Q_WS_QWS |
174 | setCursor( arrowCursor); | 177 | setCursor( arrowCursor); |
175 | #endif | 178 | #endif |
176 | #endif | 179 | #endif |
177 | } // end Newlibrary() | 180 | } // end Newlibrary() |
178 | 181 | ||
179 | 182 | ||
180 | void LibraryDialog::Library() | 183 | void LibraryDialog::Library() |
181 | {// old library groking method | 184 | {// old library groking method |
182 | 185 | ||
183 | ListView1->clear(); | 186 | ListView1->clear(); |
184 | ListView2->clear(); | 187 | ListView2->clear(); |
185 | ListView3->clear(); | 188 | ListView3->clear(); |
186 | ListView4->clear(); | 189 | ListView4->clear(); |
187 | ListView5->clear(); | 190 | ListView5->clear(); |
188 | 191 | ||
189 | odebug << "opening GUTINDEX.ALL file" << oendl; | 192 | odebug << "opening GUTINDEX.ALL file" << oendl; |
190 | IDontKnowWhy = ""; | 193 | IDontKnowWhy = ""; |
191 | if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully | 194 | if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully |
192 | QTextStream indexStream( &indexLib ); | 195 | QTextStream indexStream( &indexLib ); |
193 | QString indexLine; | 196 | QString indexLine; |
194 | qApp->processEvents(); | 197 | qApp->processEvents(); |
195 | // int jig; | 198 | // int jig; |
196 | while ( !indexStream.eof() ) { | 199 | while ( !indexStream.eof() ) { |
197 | 200 | ||
198 | indexLine = indexStream.readLine(); | 201 | indexLine = indexStream.readLine(); |
199 | if ( indexLine != "") { | 202 | if ( indexLine != "") { |
200 | if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) { | 203 | if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) { |
201 | // month = indexLine.left( 3); | 204 | // month = indexLine.left( 3); |
202 | year = indexLine.mid(4,4); | 205 | year = indexLine.mid(4,4); |
203 | // title = indexLine.mid( 9, 50); | 206 | // title = indexLine.mid( 9, 50); |
204 | file = indexLine.mid(60,12); | 207 | file = indexLine.mid(60,12); |
205 | if(file.left(1).find("[",0,TRUE) != -1) | 208 | if(file.left(1).find("[",0,TRUE) != -1) |
206 | file.remove(1,1); | 209 | file.remove(1,1); |
207 | if( file.find("]",0,TRUE) != -1) | 210 | if( file.find("]",0,TRUE) != -1) |
208 | file = file.left( file.find("]",0,TRUE)); | 211 | file = file.left( file.find("]",0,TRUE)); |
209 | //odebug << "file is "+file << oendl; | 212 | |
210 | /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); | 213 | |
211 | number = indexLine.mid(55,5); | 214 | if(file.find("?", 0, false) != -1 ) { |
212 | number = number.stripWhiteSpace(); | 215 | QString tmpfile = file.replace(QRegExp("[?]"), "8"); |
213 | // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); | 216 | // qDebug( "file is now " + tmpfile ); |
214 | title = indexLine.mid( 9, 50 ); | 217 | file = tmpfile; |
215 | title = title.stripWhiteSpace(); | 218 | } |
216 | //odebug << "title is "+title << oendl; | 219 | |
217 | getAuthor(); // grok author | 220 | // number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); |
218 | author = author.stripWhiteSpace(); | 221 | number = indexLine.mid(55,5); |
219 | //odebug << "author is "+author << oendl; | 222 | number = number.stripWhiteSpace(); |
220 | if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author | 223 | // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); |
221 | QString lastName, firstName=""; | 224 | title = indexLine.mid( 9, 50 ); |
222 | int finder=author.findRev( ' ', -1, TRUE); | 225 | title = title.stripWhiteSpace(); |
223 | lastName=author.right( author.length()-finder); | 226 | //odebug << "title is "+title << oendl; |
224 | firstName=author.left(finder); | 227 | getAuthor(); // grok author |
225 | lastName=lastName.stripWhiteSpace(); | 228 | author = author.stripWhiteSpace(); |
226 | firstName=firstName.stripWhiteSpace(); | 229 | //odebug << "author is "+author << oendl; |
227 | 230 | if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author | |
228 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names | 231 | QString lastName, firstName=""; |
229 | author=lastName+", "+firstName; | 232 | int finder=author.findRev( ' ', -1, TRUE); |
230 | } | 233 | lastName=author.right( author.length()-finder); |
231 | 234 | firstName=author.left(finder); | |
232 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) /*&& (file.find( "]",0, TRUE))*/ ) { | 235 | lastName=lastName.stripWhiteSpace(); |
233 | // fill string list or something to be able to sort by Author | 236 | firstName=firstName.stripWhiteSpace(); |
234 | if( author.isEmpty() ) | 237 | |
235 | QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); | 238 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names |
236 | else { | 239 | author=lastName+", "+firstName; |
237 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || | 240 | } |
238 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) | 241 | |
239 | QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); | 242 | if( !number.isEmpty() |
240 | 243 | && (title.find( "reserved",0, FALSE) == -1) | |
241 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || | 244 | &&(title.find( "Audio",0, FALSE) == -1)) { |
242 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) | 245 | // fill string list or something to be able to sort by Author |
243 | QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); | 246 | if( author.isEmpty() ) |
244 | 247 | QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); | |
245 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || | 248 | else { |
246 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) | 249 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || |
247 | QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file ); | 250 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) |
248 | 251 | QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); | |
249 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || | 252 | |
250 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) | 253 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || |
251 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); | 254 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) |
252 | } | 255 | QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); |
253 | } | 256 | |
254 | } | 257 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || |
255 | } | 258 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) |
256 | } | 259 | QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file ); |
257 | indexLib.close(); | 260 | |
258 | } else { | 261 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || |
259 | QString sMsg; | 262 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) |
260 | sMsg = ( tr("<p>Error opening local library index:</P> "))+local_index; | 263 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); |
261 | QMessageBox::message( "Error",sMsg); | 264 | } |
262 | } | 265 | } |
266 | } | ||
267 | } | ||
268 | } | ||
269 | indexLib.close(); | ||
270 | } else { | ||
271 | QString sMsg; | ||
272 | sMsg = ( tr("<p>Error opening local library index:</P> "))+local_index; | ||
273 | QMessageBox::message( "Error",sMsg); | ||
274 | } | ||
263 | 275 | ||
264 | } //end Library() | 276 | } //end Library() |
265 | 277 | ||
266 | 278 | ||
267 | /* | 279 | /* |
268 | Groks the author out of the title */ | 280 | Groks the author out of the title */ |
269 | bool LibraryDialog::getAuthor() | 281 | bool LibraryDialog::getAuthor() |
270 | { | 282 | { |
271 | if( title.contains( ", by", TRUE)) { | 283 | if( title.contains( ", by", TRUE)) { |
272 | int auth; | 284 | int auth; |
273 | auth = title.find(", by", 0, TRUE); | 285 | auth = title.find(", by", 0, TRUE); |
274 | author = title.right(title.length() - (auth + 4) ); | 286 | author = title.right(title.length() - (auth + 4) ); |
275 | if( int finder = author.find("[", 0, TRUE)) { | 287 | if( int finder = author.find("[", 0, TRUE)) { |
276 | author = author.left(finder); | 288 | author = author.left(finder); |
277 | } | 289 | } |
278 | } | 290 | } |
279 | else if ( title.contains( "by, ", TRUE) ) { | 291 | else if ( title.contains( "by, ", TRUE) ) { |
280 | int auth; | 292 | int auth; |
281 | auth = title.find("by, ", 0, TRUE); | 293 | auth = title.find("by, ", 0, TRUE); |
282 | author = title.right(title.length() - (auth + 4) ); | 294 | author = title.right(title.length() - (auth + 4) ); |
283 | if( int finder = author.find("[", 0, TRUE)) { | 295 | if( int finder = author.find("[", 0, TRUE)) { |
284 | author = author.left( finder); | 296 | author = author.left( finder); |
285 | } | 297 | } |
286 | } | 298 | } |
287 | else if ( title.contains( " by", TRUE) ) { | 299 | else if ( title.contains( " by", TRUE) ) { |
288 | int auth; | 300 | int auth; |
289 | auth = title.find(" by", 0, TRUE); | 301 | auth = title.find(" by", 0, TRUE); |
290 | author = title.right(title.length() - (auth + 3) ); | 302 | author = title.right(title.length() - (auth + 3) ); |
291 | if( int finder = author.find("[", 0, TRUE)) { | 303 | if( int finder = author.find("[", 0, TRUE)) { |
292 | author = author.left( finder); | 304 | author = author.left( finder); |
293 | } | 305 | } |
294 | } | 306 | } |
295 | else if ( title.contains( "by ", TRUE) ) { | 307 | else if ( title.contains( "by ", TRUE) ) { |
296 | int auth; | 308 | int auth; |
297 | auth = title.find("by ", 0, TRUE); | 309 | auth = title.find("by ", 0, TRUE); |
298 | author = title.right(title.length() - (auth + 3) ); | 310 | author = title.right(title.length() - (auth + 3) ); |
299 | if( int finder = author.find("[", 0, TRUE)) { | 311 | if( int finder = author.find("[", 0, TRUE)) { |
300 | author = author.left( finder); | 312 | author = author.left( finder); |
301 | } | 313 | } |
302 | } | 314 | } |
303 | else if ( title.contains( ",", TRUE) ) { | 315 | else if ( title.contains( ",", TRUE) ) { |
304 | int auth; | 316 | int auth; |
305 | auth = title.find(",", 0, TRUE); | 317 | auth = title.find(",", 0, TRUE); |
306 | author = title.right( title.length() - (auth + 1) ); | 318 | author = title.right( title.length() - (auth + 1) ); |
307 | if ( author.contains( ",", TRUE) ) { | 319 | if ( author.contains( ",", TRUE) ) { |
308 | int auth; | 320 | int auth; |
309 | auth = author.find(",", 0, TRUE); | 321 | auth = author.find(",", 0, TRUE); |
310 | author = author.right( author.length() - (auth + 1) ); | 322 | author = author.right( author.length() - (auth + 1) ); |
311 | } | 323 | } |
312 | if( int finder = author.find("[", 0, TRUE)) { | 324 | if( int finder = author.find("[", 0, TRUE)) { |
313 | author = author.left( finder); | 325 | author = author.left( finder); |
314 | } | 326 | } |
315 | } | 327 | } |
316 | else if ( title.contains( "/", TRUE) ) { | 328 | else if ( title.contains( "/", TRUE) ) { |
317 | int auth; | 329 | int auth; |
318 | auth = title.find("/", 0, TRUE); | 330 | auth = title.find("/", 0, TRUE); |
319 | author = title.right(title.length() - (auth + 1) ); | 331 | author = title.right(title.length() - (auth + 1) ); |
320 | if( int finder = author.find("[", 0, TRUE)) { | 332 | if( int finder = author.find("[", 0, TRUE)) { |
321 | author = author.left( finder); | 333 | author = author.left( finder); |
322 | } | 334 | } |
323 | } | 335 | } |
324 | else if ( title.contains( "of", TRUE) ) { | 336 | else if ( title.contains( "of", TRUE) ) { |
325 | int auth; | 337 | int auth; |
326 | auth = title.find("of", 0, TRUE); | 338 | auth = title.find("of", 0, TRUE); |
327 | author = title.right(title.length() - (auth + 2) ); | 339 | author = title.right(title.length() - (auth + 2) ); |
328 | if( int finder = author.find("[", 0, TRUE)) | 340 | if( int finder = author.find("[", 0, TRUE)) |
329 | { | 341 | { |
330 | author = author.left( finder); | 342 | author = author.left( finder); |
331 | } | 343 | } |
332 | } else { | 344 | } else { |
333 | author = ""; | 345 | author = ""; |
334 | } | 346 | } |
335 | if ( author.contains("et. al")) { | 347 | if ( author.contains("et. al")) { |
336 | int auth; | 348 | int auth; |
337 | auth = author.find("et. al", 0, TRUE); | 349 | auth = author.find("et. al", 0, TRUE); |
338 | author = author.left( auth ); | 350 | author = author.left( auth ); |
339 | } | 351 | } |
340 | if ( author.contains("#")) { | 352 | if ( author.contains("#")) { |
341 | int auth; | 353 | int auth; |
342 | auth = author.find("#", 0, TRUE); | 354 | auth = author.find("#", 0, TRUE); |
343 | author = author.left( auth); | 355 | author = author.left( auth); |
344 | } | 356 | } |
345 | if ( author.contains("(")) { | 357 | if ( author.contains("(")) { |
346 | int auth; | 358 | int auth; |
347 | auth = author.find("(", 0, TRUE); | 359 | auth = author.find("(", 0, TRUE); |
348 | author = author.left( auth); | 360 | author = author.left( auth); |
349 | } | 361 | } |
350 | if ( author.contains("et al")) { | 362 | if ( author.contains("et al")) { |
351 | int auth; | 363 | int auth; |
352 | auth = author.find("et al", 0, TRUE); | 364 | auth = author.find("et al", 0, TRUE); |
353 | author = author.left( auth ); | 365 | author = author.left( auth ); |
354 | } | 366 | } |
355 | QRegExp r = QRegExp("[0-9]", TRUE, FALSE); | 367 | QRegExp r = QRegExp("[0-9]", TRUE, FALSE); |
356 | if ( author.left(2).find( r) != -1 ) { | 368 | if ( author.left(2).find( r) != -1 ) { |
357 | author = ""; | 369 | author = ""; |
358 | } | 370 | } |
359 | // if( author.contains(" ", TRUE)) { | 371 | // if( author.contains(" ", TRUE)) { |
360 | // int suth = author.findRev(" ", -1, TRUE); | 372 | // int suth = author.findRev(" ", -1, TRUE); |
361 | // author = author.right( author.length() - suth); | 373 | // author = author.right( author.length() - suth); |
362 | // } | 374 | // } |
363 | 375 | ||
364 | // title | 376 | // title |
365 | // author | 377 | // author |
366 | return true; | 378 | return true; |
367 | }////// end getAuthor() | 379 | }////// end getAuthor() |
368 | 380 | ||
369 | /* | 381 | /* |
370 | selected one etext*/ | 382 | selected one etext*/ |
371 | void LibraryDialog::select_title( QListViewItem * item) | 383 | void LibraryDialog::select_title( QListViewItem * item) |
372 | { | 384 | { |
373 | if(item != NULL) { | 385 | if(item != NULL) { |
374 | i++; | 386 | i++; |
375 | int index = tabWidget->currentPageIndex(); | 387 | int index = tabWidget->currentPageIndex(); |
376 | DlglistItemTitle = item->text(0); | 388 | DlglistItemTitle = item->text(0); |
377 | DlglistItemYear = item->text(2); | 389 | DlglistItemYear = item->text(2); |
378 | DlglistItemFile = item->text(3); | 390 | DlglistItemFile = item->text(3); |
379 | switch (index) { | 391 | switch (index) { |
380 | case 0: { | 392 | case 0: { |
381 | ListView1->clearSelection(); | 393 | ListView1->clearSelection(); |
382 | } | 394 | } |
383 | break; | 395 | break; |
384 | case 1: { | 396 | case 1: { |
385 | ListView2->clearSelection(); | 397 | ListView2->clearSelection(); |
386 | } | 398 | } |
387 | break; | 399 | break; |
388 | case 2: { | 400 | case 2: { |
389 | ListView3->clearSelection(); | 401 | ListView3->clearSelection(); |
390 | } | 402 | } |
391 | break; | 403 | break; |
392 | case 3: { | 404 | case 3: { |
393 | ListView4->clearSelection(); | 405 | ListView4->clearSelection(); |
394 | } | 406 | } |
395 | break; | 407 | break; |
396 | case 4: { | 408 | case 4: { |
397 | ListView5->clearSelection(); | 409 | ListView5->clearSelection(); |
398 | } | 410 | } |
399 | break; | 411 | break; |
400 | }; | 412 | }; |
401 | } | 413 | } |
402 | 414 | ||
403 | if(DlglistItemTitle.length()>2) { | 415 | if(DlglistItemTitle.length()>2) { |
404 | // DlglistItemNumber = item->text(0); | 416 | // DlglistItemNumber = item->text(0); |
405 | item = 0; | 417 | item = 0; |
406 | odebug << "string from librarydialog is:" << DlglistItemYear << " " << DlglistItemFile << " " << DlglistItemNumber << "" << oendl; | 418 | odebug << "string from librarydialog is:" << DlglistItemYear << " " << DlglistItemFile << " " << DlglistItemNumber << "" << oendl; |
407 | odebug << "Title is "+DlglistItemTitle << oendl; | 419 | odebug << "Title is "+DlglistItemTitle << oendl; |
408 | 420 | ||
409 | // check for connection here | 421 | // check for connection here |
410 | // if( get_extext()) | 422 | // if( get_extext()) |
411 | 423 | ||
412 | if(download_Etext()) { | 424 | if(download_Etext()) { |
413 | // odebug << "get here 2" << oendl; | 425 | // odebug << "get here 2" << oendl; |
414 | if(i_binary == 1) { | 426 | if(i_binary == 1) { |
415 | 427 | ||
416 | } | 428 | } |
417 | if(checkBox->isChecked () ) { | 429 | if(checkBox->isChecked () ) { |
418 | accept(); | 430 | accept(); |
419 | } | 431 | } |
420 | } | 432 | } |
421 | } | 433 | } |
422 | } | 434 | } |
423 | 435 | ||
424 | bool LibraryDialog::download_Etext() | 436 | bool LibraryDialog::download_Etext() |
425 | { // ftp method | 437 | { // ftp method |
426 | // might have to use old gpl'd ftp for embedded!! | 438 | // might have to use old gpl'd ftp for embedded!! |
427 | Config cfg("Gutenbrowser"); | 439 | Config cfg("Gutenbrowser"); |
428 | cfg.setGroup("FTPsite"); | 440 | cfg.setGroup("FTPsite"); |
429 | ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org"); | 441 | ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org"); |
430 | ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg"); | 442 | ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg"); |
431 | 443 | ||
432 | odebug << "about to network dialog" << oendl; | 444 | odebug << "about to network dialog" << oendl; |
433 | QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile; | 445 | QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile; |
434 | 446 | ||
435 | //////////////////// FIXME- if 'x' is part of real name.... | 447 | //////////////////// FIXME- if 'x' is part of real name.... |
436 | NewlistItemFile = DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).left(DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).find("x", 1, FALSE)); | 448 | NewlistItemFile = DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).left(DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).find("x", 1, FALSE)); |
437 | 449 | ||
438 | if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) { | 450 | if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) { |
439 | NewlistItemFile.replace( 0,4, DlglistItemFile.left(4)); | 451 | NewlistItemFile.replace( 0,4, DlglistItemFile.left(4)); |
440 | odebug << "NewlistItemFile is now "+NewlistItemFile << oendl; | 452 | odebug << "NewlistItemFile is now "+NewlistItemFile << oendl; |
441 | } | 453 | } |
442 | NewlistItemYear = DlglistItemYear.right(2); | 454 | NewlistItemYear = DlglistItemYear.right(2); |
443 | int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10); | 455 | int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10); |
444 | odebug << NewlistItemYear << oendl; | 456 | odebug << NewlistItemYear << oendl; |
445 | if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) { | 457 | if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) { |
446 | NewlistItemYear = "90"; | 458 | NewlistItemYear = "90"; |
447 | } | 459 | } |
448 | Edir ="etext" +NewlistItemYear; | 460 | Edir ="etext" +NewlistItemYear; |
449 | dir= ftp_base_dir + "/etext" +NewlistItemYear+"/"; | 461 | dir= ftp_base_dir + "/etext" +NewlistItemYear+"/"; |
450 | if( ftp_base_dir.find("=",0,true) ) | 462 | if( ftp_base_dir.find("=",0,true) ) |
451 | ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1); | 463 | ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1); |
452 | 464 | ||
453 | networkUrl= "ftp://"+ftp_host+dir; | 465 | networkUrl= "ftp://"+ftp_host+dir; |
454 | 466 | ||
455 | outputFile=local_library+".guten_temp"; | 467 | outputFile=local_library+".guten_temp"; |
456 | //odebug << "Download file:" << NewlistItemFile << "" << oendl; | 468 | //odebug << "Download file:" << NewlistItemFile << "" << oendl; |
457 | odebug << "Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile << oendl; | 469 | odebug << "Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile << oendl; |
458 | QStringList networkList; | 470 | QStringList networkList; |
459 | networkList.append((const char *)ftp_host); | 471 | networkList.append((const char *)ftp_host); |
460 | networkList.append((const char *)dir); | 472 | networkList.append((const char *)dir); |
461 | networkList.append((const char *)outputFile); | 473 | networkList.append((const char *)outputFile); |
462 | networkList.append((const char *)NewlistItemFile); | 474 | networkList.append((const char *)NewlistItemFile); |
463 | //<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile; | 475 | //<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile; |
464 | 476 | ||
465 | NetworkDialog *NetworkDlg; | 477 | NetworkDialog *NetworkDlg; |
466 | NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList); | 478 | NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList); |
467 | 479 | ||
468 | 480 | ||
469 | if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer | 481 | if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer |
470 | File_Name= NetworkDlg->localFileName; | 482 | File_Name= NetworkDlg->localFileName; |
471 | odebug << "back to Library from Network Dialog" << oendl; | 483 | odebug << "back to Library from Network Dialog" << oendl; |
472 | odebug << "Just downloaded "+NetworkDlg->localFileName << oendl; | 484 | odebug << "Just downloaded "+NetworkDlg->localFileName << oendl; |
473 | 485 | ||
474 | // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found | 486 | // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found |
475 | // QString oldName=File_Name; | 487 | // QString oldName=File_Name; |
476 | // File_Name.replace(0,local_library.length(),downDir); | 488 | // File_Name.replace(0,local_library.length(),downDir); |
477 | // odebug << "File_Name now is "+File_Name << oendl; | 489 | // odebug << "File_Name now is "+File_Name << oendl; |
478 | 490 | ||
479 | // } | 491 | // } |
480 | // rename .txt to .etx | 492 | // rename .txt to .etx |
481 | if(NetworkDlg->successDownload) { | 493 | if(NetworkDlg->successDownload) { |
482 | odebug << "Filename is "+File_Name << oendl; | 494 | odebug << "Filename is "+File_Name << oendl; |
483 | if(File_Name.right(4)==".txt") { | 495 | if(File_Name.right(4)==".txt") { |
484 | QString s_fileName=File_Name; | 496 | QString s_fileName=File_Name; |
485 | s_fileName.replace( s_fileName.length()-3,3,"gtn"); | 497 | s_fileName.replace( s_fileName.length()-3,3,"gtn"); |
486 | // s_fileName.replace( s_fileName.length()-3,3,"etx"); | 498 | // s_fileName.replace( s_fileName.length()-3,3,"etx"); |
487 | rename(File_Name.latin1(),s_fileName.latin1()); | 499 | rename(File_Name.latin1(),s_fileName.latin1()); |
488 | File_Name=s_fileName; | 500 | File_Name=s_fileName; |
489 | 501 | ||
490 | odebug << "Filename is now "+File_Name << oendl; | 502 | odebug << "Filename is now "+File_Name << oendl; |
491 | 503 | ||
492 | } | 504 | } |
493 | if(File_Name.length() > 5 ) { | 505 | if(File_Name.length() > 5 ) { |
494 | setTitle(); | 506 | setTitle(); |
495 | QFileInfo fi(File_Name); | 507 | QFileInfo fi(File_Name); |
496 | QString name_file=fi.fileName(); | 508 | QString name_file=fi.fileName(); |
497 | name_file=name_file.left(name_file.length()-4); | 509 | name_file=name_file.left(name_file.length()-4); |
498 | 510 | ||
499 | odebug << "Setting doclink" << oendl; | 511 | odebug << "Setting doclink" << oendl; |
500 | DocLnk lnk; | 512 | DocLnk lnk; |
501 | odebug << "name is "+name_file << oendl; | 513 | odebug << "name is "+name_file << oendl; |
502 | lnk.setName(name_file); //sets file name | 514 | lnk.setName(name_file); //sets file name |
503 | odebug << "Title is "+DlglistItemTitle << oendl; | 515 | odebug << "Title is "+DlglistItemTitle << oendl; |
504 | lnk.setComment(DlglistItemTitle); | 516 | lnk.setComment(DlglistItemTitle); |
505 | 517 | ||
506 | odebug << "Filename is "+File_Name << oendl; | 518 | odebug << "Filename is "+File_Name << oendl; |
507 | lnk.setFile(File_Name); //sets File property | 519 | lnk.setFile(File_Name); //sets File property |
508 | lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D | 520 | lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D |
509 | lnk.setExec(File_Name); | 521 | lnk.setExec(File_Name); |
510 | lnk.setIcon("gutenbrowser/Gutenbrowser"); | 522 | lnk.setIcon("gutenbrowser/Gutenbrowser"); |
511 | if(!lnk.writeLink()) { | 523 | if(!lnk.writeLink()) { |
512 | odebug << "Writing doclink did not work" << oendl; | 524 | odebug << "Writing doclink did not work" << oendl; |
513 | } else { | 525 | } else { |
514 | } | 526 | } |
515 | } else | 527 | } else |
516 | QMessageBox::message("Note","<p>There was an error with the file</p>"); | 528 | QMessageBox::message("Note","<p>There was an error with the file</p>"); |
517 | } | 529 | } |
518 | } | 530 | } |
519 | return true; | 531 | return true; |
520 | } | 532 | } |
521 | 533 | ||
522 | bool LibraryDialog::httpDownload() | 534 | bool LibraryDialog::httpDownload() |
523 | {// httpDownload | 535 | {// httpDownload |
524 | #ifndef Q_WS_QWS | 536 | #ifndef Q_WS_QWS |
525 | Config config("Gutenbrowser"); | 537 | Config config("Gutenbrowser"); |
526 | config.setGroup( "Browser" ); | 538 | config.setGroup( "Browser" ); |
527 | QString brow = config.readEntry("Preferred", ""); | 539 | QString brow = config.readEntry("Preferred", ""); |
528 | QString file_name = "./.guten_temp"; | 540 | QString file_name = "./.guten_temp"; |
529 | // config.setGroup( "HttpServer" ); | 541 | // config.setGroup( "HttpServer" ); |
530 | // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); | 542 | // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); |
531 | QString httpName = proxy_http + "/"+Edir; | 543 | QString httpName = proxy_http + "/"+Edir; |
532 | // progressBar->setProgress( i); | 544 | // progressBar->setProgress( i); |
533 | i++; | 545 | i++; |
534 | if ( brow != "Konq") { /////////// use lynx | 546 | if ( brow != "Konq") { /////////// use lynx |
535 | // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name; | 547 | // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name; |
536 | // system(cmd); | 548 | // system(cmd); |
537 | } else { //////////// use KFM | 549 | } else { //////////// use KFM |
538 | // KFM::download( httpName, file_name); | 550 | // KFM::download( httpName, file_name); |
539 | } | 551 | } |
540 | i++; | 552 | i++; |
541 | QFile tmp( file_name); | 553 | QFile tmp( file_name); |
542 | QString str; | 554 | QString str; |
543 | if (tmp.open(IO_ReadOnly)) { | 555 | if (tmp.open(IO_ReadOnly)) { |
544 | QTextStream t( &tmp ); // use a text stream | 556 | QTextStream t( &tmp ); // use a text stream |
545 | while ( !t.eof()) { | 557 | while ( !t.eof()) { |
546 | QString s = t.readLine(); | 558 | QString s = t.readLine(); |
547 | if (s.contains( NewlistItemFile, FALSE) && (s.contains(".txt")) ) { | 559 | if (s.contains( NewlistItemFile, FALSE) && (s.contains(".txt")) ) { |
548 | str = s.mid( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6, (s.find( ".txt</A>", 0, TRUE) + 4) - ( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6 ) ); | 560 | str = s.mid( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6, (s.find( ".txt</A>", 0, TRUE) + 4) - ( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6 ) ); |
549 | httpName += "/" + str; | 561 | httpName += "/" + str; |
550 | } | 562 | } |
551 | } //end of while loop | 563 | } //end of while loop |
552 | } | 564 | } |
553 | tmp.close(); | 565 | tmp.close(); |
554 | m_getFilePath = local_library + str; | 566 | m_getFilePath = local_library + str; |
555 | i++; | 567 | i++; |
556 | if ( brow != "KFM"){ ///////// use lynx | 568 | if ( brow != "KFM"){ ///////// use lynx |
557 | QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; | 569 | QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; |
558 | // QMessageBox::message("Error", cmd); | 570 | // QMessageBox::message("Error", cmd); |
559 | system(cmd); | 571 | system(cmd); |
560 | } else { ////////// use KFM | 572 | } else { ////////// use KFM |
561 | // KFM::download( httpName, m_getFilePath); | 573 | // KFM::download( httpName, m_getFilePath); |
562 | } | 574 | } |
563 | i++; | 575 | i++; |
564 | #endif | 576 | #endif |
565 | return false; | 577 | return false; |
566 | } | 578 | } |
567 | 579 | ||
568 | void LibraryDialog::cancelIt() | 580 | void LibraryDialog::cancelIt() |
569 | { | 581 | { |
570 | saveConfig(); | 582 | saveConfig(); |
571 | 583 | ||
572 | DlglistItemNumber = ""; | 584 | DlglistItemNumber = ""; |
573 | this->reject(); | 585 | this->reject(); |
574 | } | 586 | } |
575 | 587 | ||
576 | bool LibraryDialog::setTitle() | 588 | bool LibraryDialog::setTitle() |
577 | { | 589 | { |
578 | Config config("Gutenbrowser"); | 590 | Config config("Gutenbrowser"); |
579 | odebug << "setting title" << oendl; | 591 | odebug << "setting title" << oendl; |
580 | odebug << DlglistItemTitle << oendl; | 592 | odebug << DlglistItemTitle << oendl; |
581 | 593 | ||
582 | if( DlglistItemTitle.find("[",0,TRUE) != -1) | 594 | if( DlglistItemTitle.find("[",0,TRUE) != -1) |
583 | DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" ); | 595 | DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" ); |
584 | if( DlglistItemTitle.find("]",0,TRUE) !=-1) | 596 | if( DlglistItemTitle.find("]",0,TRUE) !=-1) |
585 | DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); | 597 | DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); |
586 | odebug << "Title being set is "+DlglistItemTitle << oendl; | 598 | odebug << "Title being set is "+DlglistItemTitle << oendl; |
587 | int test = 0; | 599 | int test = 0; |
588 | QString ramble, temp; | 600 | QString ramble, temp; |
589 | config.setGroup("Files"); | 601 | config.setGroup("Files"); |
590 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 602 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
591 | int i_numofFiles = s_numofFiles.toInt(); | 603 | int i_numofFiles = s_numofFiles.toInt(); |
592 | for ( int i = 0; i <= i_numofFiles; i++){ | 604 | for ( int i = 0; i <= i_numofFiles; i++){ |
593 | temp.setNum( i); | 605 | temp.setNum( i); |
594 | ramble = config.readEntry( temp, "" ); | 606 | ramble = config.readEntry( temp, "" ); |
595 | if( strcmp( ramble, File_Name) == 0){ | 607 | if( strcmp( ramble, File_Name) == 0){ |
596 | test = 1; | 608 | test = 1; |
597 | } | 609 | } |
598 | } | 610 | } |
611 | config.setGroup("Files"); | ||
612 | config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); | ||
613 | QString interger; | ||
614 | interger.setNum( i_numofFiles +1); | ||
615 | config.writeEntry( interger, File_Name); | ||
616 | config.setGroup( "Titles" ); | ||
617 | config.writeEntry( File_Name, DlglistItemTitle); | ||
599 | 618 | ||
600 | if(test == 0 ) { | ||
601 | |||
602 | config.setGroup("Files"); | ||
603 | config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); | ||
604 | QString interger; | ||
605 | interger.setNum( i_numofFiles +1); | ||
606 | config.writeEntry( interger, File_Name); | ||
607 | config.setGroup( "Titles" ); | ||
608 | config.writeEntry( File_Name, DlglistItemTitle); | ||
609 | } | ||
610 | test = 0; | 619 | test = 0; |
611 | return true; | 620 | return true; |
612 | } | 621 | } |
613 | 622 | ||
614 | 623 | ||
615 | void LibraryDialog::saveConfig() | 624 | void LibraryDialog::saveConfig() |
616 | { | 625 | { |
617 | Config config("Gutenbrowser"); | 626 | Config config("Gutenbrowser"); |
618 | if( httpBox->isChecked() == TRUE) { | 627 | if( httpBox->isChecked() == TRUE) { |
619 | checked = 1; | 628 | checked = 1; |
620 | config.setGroup( "Proxy" ); | 629 | config.setGroup( "Proxy" ); |
621 | config.writeEntry("IsChecked", "TRUE"); | 630 | config.writeEntry("IsChecked", "TRUE"); |
622 | } else { | 631 | } else { |
623 | checked = 0; | 632 | checked = 0; |
624 | config.setGroup( "Proxy" ); | 633 | config.setGroup( "Proxy" ); |
625 | config.writeEntry("IsChecked", "FALSE"); | 634 | config.writeEntry("IsChecked", "FALSE"); |
626 | } | 635 | } |
627 | if (authBox->isChecked() == TRUE) { | 636 | if (authBox->isChecked() == TRUE) { |
628 | config.setGroup("SortAuth"); | 637 | config.setGroup("SortAuth"); |
629 | config.writeEntry("authSort", "TRUE"); | 638 | config.writeEntry("authSort", "TRUE"); |
630 | } else { | 639 | } else { |
631 | config.setGroup("SortAuth"); | 640 | config.setGroup("SortAuth"); |
632 | config.writeEntry("authSort", "FALSE"); | 641 | config.writeEntry("authSort", "FALSE"); |
633 | } | 642 | } |
634 | // config.write(); | 643 | // config.write(); |
635 | } | 644 | } |
636 | 645 | ||
637 | /* | 646 | /* |
638 | searches library index for user word*/ | 647 | searches library index for user word*/ |
639 | void LibraryDialog::onButtonSearch() | 648 | void LibraryDialog::onButtonSearch() |
640 | { | 649 | { |
641 | ListView1->clearSelection(); | 650 | ListView1->clearSelection(); |
642 | ListView2->clearSelection(); | 651 | ListView2->clearSelection(); |
643 | ListView3->clearSelection(); | 652 | ListView3->clearSelection(); |
644 | ListView4->clearSelection(); | 653 | ListView4->clearSelection(); |
645 | ListView5->clearSelection(); | 654 | ListView5->clearSelection(); |
646 | 655 | ||
647 | int curTab=tabWidget->currentPageIndex(); | 656 | int curTab=tabWidget->currentPageIndex(); |
648 | SearchDialog* searchDlg; | 657 | SearchDialog* searchDlg; |
649 | 658 | ||
650 | // if( resultsList) | 659 | // if( resultsList) |
651 | searchDlg = new SearchDialog( this, "Library Search", TRUE); | 660 | searchDlg = new SearchDialog( this, "Library Search", TRUE); |
652 | searchDlg->setCaption( tr( "Library Search" ) ); | 661 | searchDlg->setCaption( tr( "Library Search" ) ); |
653 | searchDlg->setLabel( "- author or title"); | 662 | searchDlg->setLabel( "- author or title"); |
654 | QString resultString; | 663 | QString resultString; |
655 | int i_berger = 0; | 664 | int i_berger = 0; |
656 | if( searchDlg->exec() != 0 ) { | 665 | if( searchDlg->exec() != 0 ) { |
657 | QString searcherStr = searchDlg->get_text(); | 666 | QString searcherStr = searchDlg->get_text(); |
658 | int fluff=0; | 667 | int fluff=0; |
659 | 668 | ||
660 | // int tabPage = tabWidget->currentPageIndex(); | 669 | // int tabPage = tabWidget->currentPageIndex(); |
661 | // TODO ititerate here... struct<listViews>?? | 670 | // TODO ititerate here... struct<listViews>?? |
662 | 671 | ||
663 | QListViewItemIterator it1( ListView1 ); | 672 | QListViewItemIterator it1( ListView1 ); |
664 | QListViewItemIterator it2( ListView2 ); | 673 | QListViewItemIterator it2( ListView2 ); |
665 | QListViewItemIterator it3( ListView3 ); | 674 | QListViewItemIterator it3( ListView3 ); |
666 | QListViewItemIterator it4( ListView4 ); | 675 | QListViewItemIterator it4( ListView4 ); |
667 | QListViewItemIterator it5( ListView5 ); | 676 | QListViewItemIterator it5( ListView5 ); |
668 | 677 | ||
669 | //// this is really pitiful work, | 678 | //// this is really pitiful work, |
670 | /////// | 679 | /////// |
671 | bool cS; | 680 | bool cS; |
672 | if( searchDlg->caseSensitiveCheckBox->isChecked()) | 681 | if( searchDlg->caseSensitiveCheckBox->isChecked()) |
673 | cS=true; //case sensitive | 682 | cS=true; //case sensitive |
674 | else | 683 | else |
675 | cS=false; | 684 | cS=false; |
676 | 685 | ||
677 | if(fluff==0) { | 686 | if(fluff==0) { |
678 | for ( ; it1.current(); ++it1 ) { | 687 | for ( ; it1.current(); ++it1 ) { |
679 | resultString = ( it1.current() )->text(0); | 688 | resultString = ( it1.current() )->text(0); |
680 | resultString += (" : "); | 689 | resultString += (" : "); |
681 | resultString += ( it1.current() )->text(2); | 690 | resultString += ( it1.current() )->text(2); |
682 | resultString += (" : "); | 691 | resultString += (" : "); |
683 | resultString += ( it1.current() )->text(3); | 692 | resultString += ( it1.current() )->text(3); |
684 | if( resultString.find( searcherStr, 0, cS) != -1) | 693 | if( resultString.find( searcherStr, 0, cS) != -1) |
685 | { | 694 | { |
686 | Searchlist.append( resultString); | 695 | Searchlist.append( resultString); |
687 | } | 696 | } |
688 | } | 697 | } |
689 | } | 698 | } |
690 | if(fluff==0) {// search routine here | 699 | if(fluff==0) {// search routine here |
691 | for ( ; it2.current(); ++it2 ) { | 700 | for ( ; it2.current(); ++it2 ) { |
692 | resultString = ( it2.current() )->text(0); | 701 | resultString = ( it2.current() )->text(0); |
693 | resultString += (" : "); | 702 | resultString += (" : "); |
694 | resultString += ( it2.current() )->text(2); | 703 | resultString += ( it2.current() )->text(2); |
695 | resultString += (" : "); | 704 | resultString += (" : "); |
696 | resultString += ( it2.current() )->text(3); | 705 | resultString += ( it2.current() )->text(3); |
697 | if( resultString.find( searcherStr, 0, cS) != -1) { | 706 | if( resultString.find( searcherStr, 0, cS) != -1) { |
698 | Searchlist.append( resultString); | 707 | Searchlist.append( resultString); |
699 | } | 708 | } |
700 | } | 709 | } |
701 | } | 710 | } |
702 | if(fluff==0) {// search routine here | 711 | if(fluff==0) {// search routine here |
703 | for ( ; it3.current(); ++it3 ) { | 712 | for ( ; it3.current(); ++it3 ) { |
704 | resultString = ( it3.current() )->text(0); | 713 | resultString = ( it3.current() )->text(0); |
705 | resultString += (" : "); | 714 | resultString += (" : "); |
706 | resultString += ( it3.current() )->text(2); | 715 | resultString += ( it3.current() )->text(2); |
707 | resultString += (" : "); | 716 | resultString += (" : "); |
708 | resultString += ( it3.current() )->text(3); | 717 | resultString += ( it3.current() )->text(3); |
709 | 718 | ||
710 | if( resultString.find( searcherStr, 0, cS) != -1) { | 719 | if( resultString.find( searcherStr, 0, cS) != -1) { |
711 | Searchlist.append( resultString); | 720 | Searchlist.append( resultString); |
712 | } | ||
713 | } | ||
714 | } | ||
715 | if(fluff==0) { | ||
716 | // search routine here | ||
717 | for ( ; it4.current(); ++it4 ) { | ||
718 | resultString = ( it4.current() )->text(0); | ||
719 | resultString += (" : "); | ||
720 | resultString += ( it4.current() )->text(2); | ||
721 | resultString += (" : "); | ||
722 | resultString += ( it4.current() )->text(3); | ||
723 | if( resultString.find( searcherStr, 0, cS) != -1) { | ||
724 | Searchlist.append( resultString); | ||
725 | } | ||
726 | } | ||
727 | } | ||
728 | if(fluff==0) { // search routine here | ||
729 | for ( ; it5.current(); ++it5 ) { | ||
730 | resultString = ( it5.current() )->text(0); | ||
731 | resultString += (" : "); | ||
732 | resultString += ( it5.current() )->text(2); | ||
733 | resultString += (" : "); | ||
734 | resultString += ( it5.current() )->text(3); | ||
735 | if( resultString.find( searcherStr, 0, cS) != -1) { | ||
736 | Searchlist.append( resultString); | ||
737 | } | ||
738 | } | ||
739 | } | ||
740 | |||
741 | tabWidget->setCurrentPage( curTab); | ||
742 | |||
743 | Searchlist.sort(); | ||
744 | SearchResultsDlg* SearchResultsDialog; | ||
745 | SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); | ||
746 | |||
747 | SearchResultsDialog->showMaximized(); | ||
748 | if( SearchResultsDialog->exec() != 0) { | ||
749 | texter = SearchResultsDialog->selText; | ||
750 | // odebug << texter << oendl; | ||
751 | resultLs = SearchResultsDialog->resultsList; | ||
752 | i_berger = 1; | ||
753 | } else { | ||
754 | resultLs.clear(); | ||
755 | } | 721 | } |
756 | Searchlist.clear(); | 722 | } |
757 | 723 | } | |
758 | // if(SearchResultsDialog) | 724 | if(fluff==0) { |
759 | // delete SearchResultsDialog; | 725 | // search routine here |
760 | QString tester; | 726 | for ( ; it4.current(); ++it4 ) { |
761 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { | 727 | resultString = ( it4.current() )->text(0); |
762 | texter.sprintf("%s \n",(*it).latin1()); | 728 | resultString += (" : "); |
763 | // odebug << texter << oendl; | 729 | resultString += ( it4.current() )->text(2); |
764 | if( tester!=texter) | 730 | resultString += (" : "); |
765 | parseSearchResults( texter); | 731 | resultString += ( it4.current() )->text(3); |
766 | tester = texter; | 732 | if( resultString.find( searcherStr, 0, cS) != -1) { |
767 | } | 733 | Searchlist.append( resultString); |
768 | if(searchDlg) | 734 | } |
769 | delete searchDlg; | 735 | } |
770 | } | 736 | } |
771 | if(checkBox->isChecked() ) { | 737 | if(fluff==0) { // search routine here |
772 | accept(); | 738 | for ( ; it5.current(); ++it5 ) { |
773 | } else { | 739 | resultString = ( it5.current() )->text(0); |
774 | setActiveWindow(); | 740 | resultString += (" : "); |
775 | } | 741 | resultString += ( it5.current() )->text(2); |
742 | resultString += (" : "); | ||
743 | resultString += ( it5.current() )->text(3); | ||
744 | if( resultString.find( searcherStr, 0, cS) != -1) { | ||
745 | Searchlist.append( resultString); | ||
746 | } | ||
747 | } | ||
748 | } | ||
749 | |||
750 | tabWidget->setCurrentPage( curTab); | ||
751 | |||
752 | Searchlist.sort(); | ||
753 | SearchResultsDlg* SearchResultsDialog; | ||
754 | SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); | ||
755 | |||
756 | SearchResultsDialog->showMaximized(); | ||
757 | if( SearchResultsDialog->exec() != 0) { | ||
758 | texter = SearchResultsDialog->selText; | ||
759 | // odebug << texter << oendl; | ||
760 | resultLs= SearchResultsDialog->resultsList; | ||
761 | i_berger = 1; | ||
762 | } | ||
763 | Searchlist.clear(); | ||
764 | |||
765 | // if(SearchResultsDialog) | ||
766 | // delete SearchResultsDialog; | ||
767 | QString tester; | ||
768 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { | ||
769 | texter.sprintf("%s \n",(*it).latin1()); | ||
770 | // odebug << texter << oendl; | ||
771 | if( tester!=texter) | ||
772 | parseSearchResults( texter); | ||
773 | tester = texter; | ||
774 | } | ||
775 | if(searchDlg) | ||
776 | delete searchDlg; | ||
777 | } | ||
778 | if(checkBox->isChecked() ) { | ||
779 | accept(); | ||
780 | } else { | ||
781 | setActiveWindow(); | ||
782 | } | ||
776 | } | 783 | } |
777 | 784 | ||
778 | /* | 785 | /* |
779 | splits the result string and calls download for the current search result*/ | 786 | splits the result string and calls download for the current search result*/ |
780 | void LibraryDialog::parseSearchResults( QString resultStr) | 787 | void LibraryDialog::parseSearchResults( QString resultStr) |
781 | { | 788 | { |
782 | 789 | ||
783 | int stringLeng=resultStr.length(); | 790 | int stringLeng=resultStr.length(); |
784 | QString my; | 791 | QString my; |
785 | my.setNum( stringLeng, 10); | 792 | my.setNum( stringLeng, 10); |
786 | 793 | ||
787 | if( resultStr.length() > 2 && resultStr.length() < 130) { | 794 | if( resultStr.length() > 2 && resultStr.length() < 130) { |
788 | int titleInt = resultStr.find( " : ", 0, TRUE); | 795 | int titleInt = resultStr.find( " : ", 0, TRUE); |
789 | DlglistItemTitle = resultStr.left( titleInt); | 796 | DlglistItemTitle = resultStr.left( titleInt); |
790 | int yearInt = resultStr.find( " : ", titleInt+3, TRUE); | 797 | int yearInt = resultStr.find( " : ", titleInt+3, TRUE); |
791 | DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); | 798 | DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); |
792 | DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); | 799 | DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); |
793 | download_Etext(); | 800 | download_Etext(); |
794 | } | 801 | } |
795 | /* | 802 | /* |
796 | printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/ | 803 | printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/ |
797 | } | 804 | } |
798 | 805 | ||
799 | // bool LibraryDialog::UnzipIt( QString zipFile) { | 806 | // bool LibraryDialog::UnzipIt( QString zipFile) { |
800 | // //////////TODO findsome other way of dealingwithzip files. | 807 | // //////////TODO findsome other way of dealingwithzip files. |
801 | // ///usr/bin/unzip"; | 808 | // ///usr/bin/unzip"; |
802 | // if( QFile::exists( zipFile)) { | 809 | // if( QFile::exists( zipFile)) { |
803 | // // QString thatFile = local_library +"PGWHOLE.TXT"; | 810 | // // QString thatFile = local_library +"PGWHOLE.TXT"; |
804 | // QString cmd; | 811 | // QString cmd; |
805 | // #if defined(_WS_X11_) | 812 | // #if defined(_WS_X11_) |
806 | // cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; | 813 | // cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; |
807 | // #endif | 814 | // #endif |
808 | // #if defined(_WS_WIN_) | 815 | // #if defined(_WS_WIN_) |
809 | // QString temp= QDir::convertSeparators(local_library); | 816 | // QString temp= QDir::convertSeparators(local_library); |
810 | // zipFile=QDir::convertSeparators( zipFile); | 817 | // zipFile=QDir::convertSeparators( zipFile); |
811 | // cmd = temp+"unzip.exe -o " +zipFile/*newestLibraryFile */+" -d " + temp; | 818 | // cmd = temp+"unzip.exe -o " +zipFile/*newestLibraryFile */+" -d " + temp; |
812 | // #endif | 819 | // #endif |
813 | // #ifndef Q_WS_QWS | 820 | // #ifndef Q_WS_QWS |
814 | // // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; | 821 | // // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; |
815 | // cmd = "unzip " + zipFile; | 822 | // cmd = "unzip " + zipFile; |
816 | // #endif | 823 | // #endif |
817 | 824 | ||
818 | // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No); | 825 | // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No); |
819 | // if (exit==QMessageBox::Yes) { | 826 | // if (exit==QMessageBox::Yes) { |
820 | // odebug << "Issuing the command "+cmd << oendl; | 827 | // odebug << "Issuing the command "+cmd << oendl; |
821 | // #if defined(_WS_WIN_) | 828 | // #if defined(_WS_WIN_) |
822 | // WinExec( cmd, SW_HIDE ); | 829 | // WinExec( cmd, SW_HIDE ); |
823 | // #endif | 830 | // #endif |
824 | // #if defined(_WS_X11_) | 831 | // #if defined(_WS_X11_) |
825 | // system( cmd); | 832 | // system( cmd); |
826 | // #endif | 833 | // #endif |
827 | // #ifndef Q_WS_QWS | 834 | // #ifndef Q_WS_QWS |
828 | // system( cmd); | 835 | // system( cmd); |
829 | // #endif | 836 | // #endif |
830 | // // printf("unzip\n"); | 837 | // // printf("unzip\n"); |
831 | // // remove( zipFile /*newestLibraryFile*/); | 838 | // // remove( zipFile /*newestLibraryFile*/); |
832 | // return true; | 839 | // return true; |
833 | // } | 840 | // } |
834 | // else if(exit==QMessageBox::No) { | 841 | // else if(exit==QMessageBox::No) { |
835 | // // printf("unzip\n"); | 842 | // // printf("unzip\n"); |
836 | // return false; | 843 | // return false; |
837 | // } | 844 | // } |
838 | // } else { | 845 | // } else { |
839 | // // QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); | 846 | // // QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); |
840 | // return false; | 847 | // return false; |
841 | // } | 848 | // } |
842 | // return true; | 849 | // return true; |
843 | // } | 850 | // } |
844 | 851 | ||
845 | void LibraryDialog::sort() | 852 | void LibraryDialog::sort() |
846 | { | 853 | { |
847 | 854 | ||
848 | } | 855 | } |
849 | 856 | ||
850 | /* | 857 | /* |
851 | Downloads the current selected listitem*/ | 858 | Downloads the current selected listitem*/ |
852 | bool LibraryDialog::getItem(QListViewItem *it) | 859 | bool LibraryDialog::getItem(QListViewItem *it) |
853 | { | 860 | { |
854 | // odebug << "selected getItem" << oendl; | 861 | // odebug << "selected getItem" << oendl; |
855 | 862 | ||
856 | // DlglistItemNumber = it->text(0); | 863 | // DlglistItemNumber = it->text(0); |
857 | DlglistItemTitle = it->text(0); | 864 | DlglistItemTitle = it->text(0); |
858 | DlglistItemYear = it->text(2); | 865 | DlglistItemYear = it->text(2); |
859 | DlglistItemFile = it->text(3); | 866 | DlglistItemFile = it->text(3); |
860 | 867 | ||
861 | if(download_Etext()) { | 868 | if(download_Etext()) { |
862 | if(i_binary == 1) { | 869 | if(i_binary == 1) { |
863 | } | 870 | } |
864 | } | 871 | } |
865 | return true; | 872 | return true; |
866 | } | 873 | } |
867 | 874 | ||
868 | /* | 875 | /* |
869 | download button is pushed so we get the current items to download*/ | 876 | download button is pushed so we get the current items to download*/ |
870 | bool LibraryDialog::onButtonDownload() | 877 | bool LibraryDialog::onButtonDownload() |
871 | { | 878 | { |
872 | // odebug << "selected onButtonDownloadz" << oendl; | 879 | // odebug << "selected onButtonDownloadz" << oendl; |
873 | 880 | ||
874 | QListViewItemIterator it1( ListView1 ); | 881 | QListViewItemIterator it1( ListView1 ); |
875 | QListViewItemIterator it2( ListView2 ); | 882 | QListViewItemIterator it2( ListView2 ); |
876 | QListViewItemIterator it3( ListView3 ); | 883 | QListViewItemIterator it3( ListView3 ); |
877 | QListViewItemIterator it4( ListView4 ); | 884 | QListViewItemIterator it4( ListView4 ); |
878 | QListViewItemIterator it5( ListView5 ); | 885 | QListViewItemIterator it5( ListView5 ); |
879 | 886 | ||
880 | // iterate through all items of the listview | 887 | // iterate through all items of the listview |
881 | for ( ; it1.current(); ++it1 ) { | 888 | for ( ; it1.current(); ++it1 ) { |
882 | if ( it1.current()->isSelected() ) | 889 | if ( it1.current()->isSelected() ) |
883 | getItem(it1.current()); | 890 | getItem(it1.current()); |
884 | it1.current()->setSelected(FALSE); | 891 | it1.current()->setSelected(FALSE); |
885 | } | 892 | } |
886 | for ( ; it2.current(); ++it2 ) { | 893 | for ( ; it2.current(); ++it2 ) { |
887 | if ( it2.current()->isSelected() ) | 894 | if ( it2.current()->isSelected() ) |
888 | getItem(it2.current()); | 895 | getItem(it2.current()); |
889 | it2.current()->setSelected(FALSE); | 896 | it2.current()->setSelected(FALSE); |
890 | } | 897 | } |
891 | for ( ; it3.current(); ++it3 ) { | 898 | for ( ; it3.current(); ++it3 ) { |
892 | if ( it3.current()->isSelected() ) | 899 | if ( it3.current()->isSelected() ) |
893 | getItem(it3.current()); | 900 | getItem(it3.current()); |
894 | it3.current()->setSelected(FALSE); | 901 | it3.current()->setSelected(FALSE); |
895 | } | 902 | } |
896 | for ( ; it4.current(); ++it4 ) { | 903 | for ( ; it4.current(); ++it4 ) { |
897 | if ( it4.current()->isSelected() ) | 904 | if ( it4.current()->isSelected() ) |
898 | getItem(it4.current()); | 905 | getItem(it4.current()); |
899 | it4.current()->setSelected(FALSE); | 906 | it4.current()->setSelected(FALSE); |
900 | } | 907 | } |
901 | for ( ; it5.current(); ++it5 ) { | 908 | for ( ; it5.current(); ++it5 ) { |
902 | if ( it5.current()->isSelected() ) | 909 | if ( it5.current()->isSelected() ) |
903 | getItem(it5.current()); | 910 | getItem(it5.current()); |
904 | it5.current()->setSelected(FALSE); | 911 | it5.current()->setSelected(FALSE); |
905 | } | 912 | } |
906 | return true; | 913 | return true; |
907 | } | 914 | } |
908 | 915 | ||
909 | 916 | ||
910 | /* | 917 | /* |
911 | handles the sorting combo box */ | 918 | handles the sorting combo box */ |
912 | void LibraryDialog::comboSelect(int index) | 919 | void LibraryDialog::comboSelect(int index) |
913 | { | 920 | { |
914 | // odebug << "we are sorting" << oendl; | 921 | // odebug << "we are sorting" << oendl; |
915 | ListView1->setSorting( index, TRUE); | 922 | ListView1->setSorting( index, TRUE); |
916 | ListView2->setSorting( index, TRUE); | 923 | ListView2->setSorting( index, TRUE); |
917 | ListView3->setSorting( index, TRUE); | 924 | ListView3->setSorting( index, TRUE); |
918 | ListView4->setSorting( index, TRUE); | 925 | ListView4->setSorting( index, TRUE); |
919 | ListView5->setSorting( index, TRUE); | 926 | ListView5->setSorting( index, TRUE); |
920 | 927 | ||
921 | ListView1->sort(); | 928 | ListView1->sort(); |
922 | ListView2->sort(); | 929 | ListView2->sort(); |
923 | ListView3->sort(); | 930 | ListView3->sort(); |
924 | ListView4->sort(); | 931 | ListView4->sort(); |
925 | ListView5->sort(); | 932 | ListView5->sort(); |
926 | 933 | ||
927 | // ListView1->triggerUpdate(); | 934 | // ListView1->triggerUpdate(); |
928 | // ListView2->triggerUpdate(); | 935 | // ListView2->triggerUpdate(); |
929 | // ListView3->triggerUpdate(); | 936 | // ListView3->triggerUpdate(); |
930 | // ListView4->triggerUpdate(); | 937 | // ListView4->triggerUpdate(); |
931 | // ListView5->triggerUpdate(); | 938 | // ListView5->triggerUpdate(); |
932 | } | 939 | } |
933 | 940 | ||
934 | void LibraryDialog::newList() | 941 | void LibraryDialog::newList() |
935 | { | 942 | { |
936 | if(indexLoaded) { | 943 | if(indexLoaded) { |
937 | onButtonDownload(); | 944 | onButtonDownload(); |
938 | } else { | 945 | } else { |
939 | Output *outDlg; | 946 | Output *outDlg; |
940 | buttonNewList->setDown(TRUE); | 947 | buttonNewList->setDown(TRUE); |
941 | QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser"); | 948 | QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser"); |
942 | if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true); | 949 | if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true); |
943 | if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) { | 950 | if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) { |
944 | odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl; | 951 | odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl; |
945 | QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; | 952 | QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
946 | QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; | 953 | QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; |
947 | 954 | ||
948 | int result = QMessageBox::warning( this,"Download" | 955 | int result = QMessageBox::warning( this,"Download" |
949 | ,"<p>Ok to use /'wget/' to download a new library list?</P>" | 956 | ,"<p>Ok to use /'wget/' to download a new library list?</P>" |
950 | ,"Yes","No",0,0,1); | 957 | ,"Yes","No",0,0,1); |
951 | qApp->processEvents(); | 958 | qApp->processEvents(); |
952 | if(result == 0) { | 959 | if(result == 0) { |
953 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); | 960 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); |
954 | outDlg->showMaximized(); | 961 | outDlg->showMaximized(); |
955 | outDlg->show(); | 962 | outDlg->show(); |
956 | qApp->processEvents(); | 963 | qApp->processEvents(); |
957 | FILE *fp; | 964 | FILE *fp; |
958 | char line[130]; | 965 | char line[130]; |
959 | outDlg->OutputEdit->append( tr("Running wget") ); | 966 | outDlg->OutputEdit->append( tr("Running wget") ); |
960 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 967 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
961 | sleep(1); | 968 | sleep(1); |
962 | fp = popen( (const char *) cmd, "r"); | 969 | fp = popen( (const char *) cmd, "r"); |
963 | if ( !fp ) { | 970 | if ( !fp ) { |
964 | } else { | 971 | } else { |
965 | odebug << "Issuing the command\n"+cmd << oendl; | 972 | odebug << "Issuing the command\n"+cmd << oendl; |
966 | // system(cmd); | 973 | // system(cmd); |
967 | while ( fgets( line, sizeof line, fp)) { | 974 | while ( fgets( line, sizeof line, fp)) { |
968 | outDlg->OutputEdit->append(line); | 975 | outDlg->OutputEdit->append(line); |
969 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 976 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
970 | } | 977 | } |
971 | pclose(fp); | 978 | pclose(fp); |
972 | outDlg->OutputEdit->append("Finished downloading\n"); | 979 | outDlg->OutputEdit->append("Finished downloading\n"); |
973 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 980 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
974 | qApp->processEvents(); | 981 | qApp->processEvents(); |
975 | 982 | ||
976 | // if( QFile(gutenindex1).exists() ) { | 983 | // if( QFile(gutenindex1).exists() ) { |
977 | // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; | 984 | // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
978 | // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) | 985 | // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) |
979 | // odebug << "renaming error" << oendl; | 986 | // odebug << "renaming error" << oendl; |
980 | // } | 987 | // } |
981 | 988 | ||
982 | } | 989 | } |
983 | // outDlg->close(); | 990 | // outDlg->close(); |
984 | FindLibrary(); | 991 | FindLibrary(); |
985 | if(outDlg) delete outDlg; | 992 | if(outDlg) delete outDlg; |
986 | } | 993 | } |
987 | buttonNewList->setDown(FALSE); | 994 | buttonNewList->setDown(FALSE); |
988 | } else { | 995 | } else { |
989 | QMessageBox::message("Note","Could not change directories"); | 996 | QMessageBox::message("Note","Could not change directories"); |
990 | } | 997 | } |
991 | // if(outDlg) | 998 | // if(outDlg) |
992 | // delete outDlg; | 999 | // delete outDlg; |
993 | } | 1000 | } |
994 | } | 1001 | } |
995 | 1002 | ||
996 | bool LibraryDialog::moreInfo() | 1003 | bool LibraryDialog::moreInfo() |
997 | { | 1004 | { |
998 | 1005 | ||
999 | QListViewItem * item; | 1006 | QListViewItem * item; |
1000 | item = 0; | 1007 | item = 0; |
1001 | QString titleString; | 1008 | QString titleString; |
1002 | item = ListView1->currentItem(); | 1009 | item = ListView1->currentItem(); |
1003 | if( item != 0) { | 1010 | if( item != 0) { |
1004 | titleString = item->text(0); | 1011 | titleString = item->text(0); |
1005 | ListView1->clearSelection(); | 1012 | ListView1->clearSelection(); |
1006 | item = 0; | 1013 | item = 0; |
1007 | } | 1014 | } |
1008 | if( item == 0) | 1015 | if( item == 0) |
1009 | item = ListView2->currentItem(); | 1016 | item = ListView2->currentItem(); |
1010 | if( item != 0) { | 1017 | if( item != 0) { |
1011 | titleString = item->text(0); | 1018 | titleString = item->text(0); |
1012 | ListView2->clearSelection(); | 1019 | ListView2->clearSelection(); |
1013 | item = 0; | 1020 | item = 0; |
1014 | } | 1021 | } |
1015 | if( item == 0) | 1022 | if( item == 0) |
1016 | item = ListView3->currentItem(); | 1023 | item = ListView3->currentItem(); |
1017 | if( item != 0) { | 1024 | if( item != 0) { |
1018 | titleString = item->text(0); | 1025 | titleString = item->text(0); |
1019 | ListView3->clearSelection(); | 1026 | ListView3->clearSelection(); |
1020 | item = 0; | 1027 | item = 0; |
1021 | } | 1028 | } |
1022 | if( item == 0) | 1029 | if( item == 0) |
1023 | item = ListView4->currentItem(); | 1030 | item = ListView4->currentItem(); |
1024 | if( item != 0) { | 1031 | if( item != 0) { |
1025 | titleString = item->text(0); | 1032 | titleString = item->text(0); |
1026 | ListView4->clearSelection(); | 1033 | ListView4->clearSelection(); |
1027 | item = 0; | 1034 | item = 0; |
1028 | } | 1035 | } |
1029 | if( item == 0) | 1036 | if( item == 0) |
1030 | item = ListView5->currentItem(); | 1037 | item = ListView5->currentItem(); |
1031 | if( item != 0) { | 1038 | if( item != 0) { |
1032 | titleString = item->text(0); | 1039 | titleString = item->text(0); |
1033 | ListView5->clearSelection(); | 1040 | ListView5->clearSelection(); |
1034 | item = 0; | 1041 | item = 0; |
1035 | } | 1042 | } |
1036 | item=0; | 1043 | item=0; |
1037 | if(titleString.length()>2) { | 1044 | if(titleString.length()>2) { |
1038 | odebug << "Title is "+titleString << oendl; | 1045 | odebug << "Title is "+titleString << oendl; |
1039 | titleString.replace( QRegExp("\\s"), "%20"); | 1046 | titleString.replace( QRegExp("\\s"), "%20"); |
1040 | titleString.replace( QRegExp("'"), "%20"); | 1047 | titleString.replace( QRegExp("'"), "%20"); |
1041 | titleString.replace( QRegExp("\""), "%20"); | 1048 | titleString.replace( QRegExp("\""), "%20"); |
1042 | titleString.replace( QRegExp("&"), "%20"); | 1049 | titleString.replace( QRegExp("&"), "%20"); |
1043 | QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search"; | 1050 | QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search"; |
1044 | cmd="opera "+cmd; | 1051 | cmd="opera "+cmd; |
1045 | system(cmd); | 1052 | system(cmd); |
1046 | } else | 1053 | } else |
1047 | QMessageBox::message( "Note","<p>If you select a title, this will search google.com for that title.</p>"); | 1054 | QMessageBox::message( "Note","<p>If you select a title, this will search google.com for that title.</p>"); |
1048 | return true; | 1055 | return true; |
1049 | 1056 | ||
1050 | } | 1057 | } |
1051 | 1058 | ||
1052 | /* | 1059 | /* |
1053 | This loads the library Index*/ | 1060 | This loads the library Index*/ |
1054 | void LibraryDialog::FindLibrary() | 1061 | void LibraryDialog::FindLibrary() |
1055 | { | 1062 | { |
1056 | buttonLibrary->setDown(TRUE); | 1063 | buttonLibrary->setDown(TRUE); |
1057 | 1064 | ||
1058 | qApp->processEvents(); | 1065 | qApp->processEvents(); |
1059 | if( QFile( new_index).exists() /* && this->isHidden() */) { | 1066 | if( QFile( new_index).exists() /* && this->isHidden() */) { |
1060 | newindexLib.setName( new_index); | 1067 | newindexLib.setName( new_index); |
1061 | indexLib.setName( new_index); | 1068 | indexLib.setName( new_index); |
1062 | odebug << "index file is "+ new_index << oendl; | 1069 | odebug << "index file is "+ new_index << oendl; |
1063 | Newlibrary(); | 1070 | Newlibrary(); |
1064 | } else { | 1071 | } else { |
1065 | newindexLib.setName( old_index); | 1072 | newindexLib.setName( old_index); |
1066 | indexLib.setName( old_index); | 1073 | indexLib.setName( old_index); |
1067 | odebug << "new index nameis "+ old_index << oendl; | 1074 | odebug << "new index nameis "+ old_index << oendl; |
1068 | Library(); | 1075 | Library(); |
1069 | } | 1076 | } |
1070 | indexLoaded=true; | 1077 | indexLoaded=true; |
1071 | buttonSearch->setEnabled(TRUE); | 1078 | buttonSearch->setEnabled(TRUE); |
1072 | moreInfoButton->setEnabled(TRUE); | 1079 | moreInfoButton->setEnabled(TRUE); |
1073 | 1080 | ||
1074 | buttonLibrary->setDown(FALSE); | 1081 | buttonLibrary->setDown(FALSE); |
1075 | buttonNewList->setText("Download"); | 1082 | buttonNewList->setText("Download"); |
1076 | qApp->processEvents(); | 1083 | qApp->processEvents(); |
1077 | 1084 | ||
1078 | } | 1085 | } |
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp index fac21da..c7cdd83 100644 --- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp +++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | |||
@@ -1,1995 +1,2006 @@ | |||
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 | 17 | ||
18 | 18 | ||
19 | #include "editTitle.h" | 19 | #include "editTitle.h" |
20 | #include "gutenbrowser.h" | 20 | #include "gutenbrowser.h" |
21 | #include "LibraryDialog.h" | 21 | #include "LibraryDialog.h" |
22 | //#include "bookmarksdlg.h" | 22 | //#include "bookmarksdlg.h" |
23 | #include "optionsDialog.h" | 23 | #include "optionsDialog.h" |
24 | #include "helpme.h" | 24 | #include "helpme.h" |
25 | #include "NetworkDialog.h" | 25 | #include "NetworkDialog.h" |
26 | 26 | ||
27 | #include "openetext.h" | 27 | #include "openetext.h" |
28 | #include "output.h" | 28 | #include "output.h" |
29 | 29 | ||
30 | /* OPIE */ | 30 | /* OPIE */ |
31 | #include <opie2/odebug.h> | 31 | #include <opie2/odebug.h> |
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/fontdatabase.h> | 33 | #include <qpe/fontdatabase.h> |
34 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/qcopenvelope_qws.h> | 35 | #include <qpe/qcopenvelope_qws.h> |
36 | #include <qpe/mimetype.h> | 36 | #include <qpe/mimetype.h> |
37 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
38 | #include <qpe/applnk.h> | 38 | #include <qpe/applnk.h> |
39 | 39 | ||
40 | /* QT */ | 40 | /* QT */ |
41 | #include <qregexp.h> | 41 | #include <qregexp.h> |
42 | #include <qregion.h> | 42 | #include <qregion.h> |
43 | #include <qpaintdevicemetrics.h> | 43 | #include <qpaintdevicemetrics.h> |
44 | #include <qvaluelist.h> | 44 | #include <qvaluelist.h> |
45 | #include <qlabel.h> | 45 | #include <qlabel.h> |
46 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
47 | #include <qpainter.h> | 47 | #include <qpainter.h> |
48 | #include <qpalette.h> | 48 | #include <qpalette.h> |
49 | #include <qobjectlist.h> | 49 | #include <qobjectlist.h> |
50 | #include <qfontdialog.h> | 50 | #include <qfontdialog.h> |
51 | #include <qtextview.h> | 51 | #include <qtextview.h> |
52 | #include <qbrush.h> | 52 | #include <qbrush.h> |
53 | #include <qfile.h> | 53 | #include <qfile.h> |
54 | #include <qfontinfo.h> | 54 | #include <qfontinfo.h> |
55 | #include <qscrollview.h> | 55 | #include <qscrollview.h> |
56 | #include <qpoint.h> | 56 | #include <qpoint.h> |
57 | 57 | ||
58 | /* STD */ | 58 | /* STD */ |
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include <unistd.h> | 61 | #include <unistd.h> |
62 | #include <sys/stat.h> | 62 | #include <sys/stat.h> |
63 | #include <fcntl.h> | 63 | #include <fcntl.h> |
64 | #include <errno.h> | 64 | #include <errno.h> |
65 | 65 | ||
66 | static const int nfontsizes = 9; | 66 | static const int nfontsizes = 9; |
67 | static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; | 67 | static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; |
68 | 68 | ||
69 | #ifdef NOQUICKLAUNCH | 69 | #ifdef NOQUICKLAUNCH |
70 | Gutenbrowser::Gutenbrowser() | 70 | Gutenbrowser::Gutenbrowser() |
71 | Gutenbrowser(); | 71 | Gutenbrowser(); |
72 | #else | 72 | #else |
73 | Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) | 73 | Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) |
74 | #endif | 74 | #endif |
75 | : QMainWindow() | 75 | : QMainWindow() |
76 | { | 76 | { |
77 | // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 77 | // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
78 | // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); | 78 | // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); |
79 | // e << ""; | 79 | // e << ""; |
80 | // QPEApplication::grabKeyboard(); | 80 | // QPEApplication::grabKeyboard(); |
81 | showMainList=TRUE; | 81 | showMainList=TRUE; |
82 | working=false; | 82 | working=false; |
83 | this->setUpdatesEnabled(TRUE); | 83 | this->setUpdatesEnabled(TRUE); |
84 | // #ifndef Q_WS_QWS | 84 | // #ifndef Q_WS_QWS |
85 | QString msg; | 85 | QString msg; |
86 | msg="You have now entered unto gutenbrowser,\n"; | 86 | msg="You have now entered unto gutenbrowser,\n"; |
87 | 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"; |
88 | 88 | ||
89 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; | 89 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; |
90 | setCaption("Gutenbrowser");// Embedded " VERSION); | 90 | setCaption("Gutenbrowser");// Embedded " VERSION); |
91 | this->setUpdatesEnabled(TRUE); | 91 | this->setUpdatesEnabled(TRUE); |
92 | 92 | ||
93 | // bool firstTime=FALSE; | 93 | // bool firstTime=FALSE; |
94 | topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); | 94 | topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); |
95 | 95 | ||
96 | menu = new QHBoxLayout(-1,"menu"); | 96 | menu = new QHBoxLayout(-1,"menu"); |
97 | buttons2 = new QHBoxLayout(-1,"buttons2"); | 97 | buttons2 = new QHBoxLayout(-1,"buttons2"); |
98 | edits = new QHBoxLayout(-1,"edits"); | 98 | edits = new QHBoxLayout(-1,"edits"); |
99 | 99 | ||
100 | useSplitter=TRUE; | 100 | useSplitter=TRUE; |
101 | 101 | ||
102 | initConfig(); | 102 | initConfig(); |
103 | initMenuBar(); | 103 | initMenuBar(); |
104 | initButtonBar(); | 104 | initButtonBar(); |
105 | initStatusBar(); | 105 | initStatusBar(); |
106 | initView(); | 106 | initView(); |
107 | initSlots(); | 107 | initSlots(); |
108 | qDebug("init finished"); | 108 | qDebug("init finished"); |
109 | QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); | 109 | QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); |
110 | 110 | ||
111 | connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), | 111 | connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), |
112 | this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); | 112 | this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); |
113 | if( useIcons) | 113 | if( useIcons) |
114 | toggleButtonIcons( TRUE); | 114 | toggleButtonIcons( TRUE); |
115 | else | 115 | else |
116 | toggleButtonIcons( FALSE); | 116 | toggleButtonIcons( FALSE); |
117 | 117 | ||
118 | enableButtons(false); | 118 | enableButtons(false); |
119 | 119 | ||
120 | Config config("Gutenbrowser"); // populate menubuttonlist | 120 | Config config("Gutenbrowser"); // populate menubuttonlist |
121 | config.setGroup("General"); | 121 | config.setGroup("General"); |
122 | 122 | ||
123 | config.setGroup( "Files" ); | 123 | config.setGroup( "Files" ); |
124 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 124 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
125 | int i_numofFiles = s_numofFiles.toInt(); | 125 | int i_numofFiles = s_numofFiles.toInt(); |
126 | 126 | ||
127 | QString tempFileName; | 127 | QString tempFileName; |
128 | 128 | ||
129 | for (int i = 0; i <= i_numofFiles; i++) { | 129 | for (int i = 0; i <= i_numofFiles; i++) { |
130 | // tempFileName.setNum(i); | 130 | // tempFileName.setNum(i); |
131 | config.setGroup( "Files" ); | 131 | config.setGroup( "Files" ); |
132 | QString ramble = config.readEntry( QString::number(i), "" ); | 132 | QString ramble = config.readEntry( QString::number(i), "" ); |
133 | 133 | ||
134 | config.setGroup( "Titles" ); | 134 | config.setGroup( "Titles" ); |
135 | QString tempTitle = config.readEntry( ramble, ""); | 135 | QString tempTitle = config.readEntry( ramble, ""); |
136 | config.setGroup( tempTitle); | 136 | config.setGroup( tempTitle); |
137 | int index = config.readNumEntry( "LineNumber", -1 ); | 137 | int index = config.readNumEntry( "LineNumber", -1 ); |
138 | if( index != -1) { | 138 | if( index != -1) { |
139 | odebug << tempTitle << oendl; | 139 | odebug << tempTitle << oendl; |
140 | if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle); | 140 | if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | // QString gutenIndex= local_library + "GUTINDEX.ALL"; | 144 | // QString gutenIndex= local_library + "GUTINDEX.ALL"; |
145 | QString gutenIndex = QPEApplication::qpeDir()+ "etc/gutenbrowser/GUTINDEX.ALL"; | 145 | QString gutenIndex = QPEApplication::qpeDir()+ "etc/gutenbrowser/GUTINDEX.ALL"; |
146 | qDebug("gutenindex "+gutenIndex ); | 146 | qDebug("gutenindex "+gutenIndex ); |
147 | if( QFile( gutenIndex).exists() ) { | 147 | if( QFile( gutenIndex).exists() ) { |
148 | indexLib.setName( gutenIndex); | 148 | indexLib.setName( gutenIndex); |
149 | } else { | 149 | } else { |
150 | QString localLibIndexFile = QPEApplication::qpeDir()+ "etc/gutenbrowser/PGWHOLE.TXT"; | 150 | QString localLibIndexFile = QPEApplication::qpeDir()+ "etc/gutenbrowser/PGWHOLE.TXT"; |
151 | // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; | 151 | // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; |
152 | newindexLib.setName( localLibIndexFile); | 152 | newindexLib.setName( localLibIndexFile); |
153 | } | 153 | } |
154 | qDebug("attempting new library"); | 154 | qDebug("attempting new library"); |
155 | LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); | 155 | LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); |
156 | loadCheck = false; | 156 | loadCheck = false; |
157 | chdir(local_library); | 157 | chdir(local_library); |
158 | if(!showMainList) { | 158 | if(!showMainList) { |
159 | Lview->setFocus(); | 159 | Lview->setFocus(); |
160 | // if(firstTime) | 160 | // if(firstTime) |
161 | // Bookmark(); | 161 | // Bookmark(); |
162 | for (int i=1;i< qApp->argc();i++) { | 162 | for (int i=1;i< qApp->argc();i++) { |
163 | qDebug("Suppose we open somethin"); | 163 | qDebug("Suppose we open somethin"); |
164 | if(!load(qApp->argv()[i])) return; | 164 | if(!load(qApp->argv()[i])) return; |
165 | } | 165 | } |
166 | } else { | 166 | } else { |
167 | fillWithTitles(); | 167 | fillWithTitles(); |
168 | mainList->setFocus(); | 168 | mainList->setFocus(); |
169 | // mainList->setCurrentItem(0); | 169 | // mainList->setCurrentItem(0); |
170 | 170 | ||
171 | } | 171 | } |
172 | writeConfig(); | 172 | writeConfig(); |
173 | QTimer::singleShot( 250, this, SLOT(hideView()) ); | 173 | QTimer::singleShot( 250, this, SLOT(hideView()) ); |
174 | } //end init | 174 | } //end init |
175 | 175 | ||
176 | Gutenbrowser::~Gutenbrowser() { | 176 | Gutenbrowser::~Gutenbrowser() { |
177 | // QPEApplication::grabKeyboard(); | 177 | // QPEApplication::grabKeyboard(); |
178 | // QPEApplication::ungrabKeyboard(); | 178 | // QPEApplication::ungrabKeyboard(); |
179 | odebug << "Exit" << oendl; | 179 | odebug << "Exit" << oendl; |
180 | } | 180 | } |
181 | 181 | ||
182 | /* | 182 | /* |
183 | Google.com search */ | 183 | Google.com search */ |
184 | void Gutenbrowser::InfoBarClick() { | 184 | void Gutenbrowser::InfoBarClick() { |
185 | QString text; | 185 | QString text; |
186 | if( Lview->hasSelectedText()) { | 186 | if( Lview->hasSelectedText()) { |
187 | Lview->copy(); | 187 | Lview->copy(); |
188 | QClipboard *cb = QApplication::clipboard(); | 188 | QClipboard *cb = QApplication::clipboard(); |
189 | text = cb->text(); | 189 | text = cb->text(); |
190 | } else { | 190 | } else { |
191 | // text=title; | 191 | // text=title; |
192 | text=this->caption(); | 192 | text=this->caption(); |
193 | } | 193 | } |
194 | searchGoogle(text); | 194 | searchGoogle(text); |
195 | } | 195 | } |
196 | 196 | ||
197 | /* | 197 | /* |
198 | download http with wget or preferred browser */ | 198 | download http with wget or preferred browser */ |
199 | void Gutenbrowser::goGetit( const QString &url, bool showMsg) { | 199 | void Gutenbrowser::goGetit( const QString &url, bool showMsg) { |
200 | // int eexit=0; | 200 | // int eexit=0; |
201 | QString cmd; | 201 | QString cmd; |
202 | // config.read(); | 202 | // config.read(); |
203 | qApp->processEvents(); | 203 | qApp->processEvents(); |
204 | QString filename = QPEApplication::qpeDir(); | 204 | QString filename = QPEApplication::qpeDir(); |
205 | if(filename.right(1)!="/") | 205 | if(filename.right(1)!="/") |
206 | filename+="/etc/gutenbrowser/"; | 206 | filename+="/etc/gutenbrowser/"; |
207 | else | 207 | else |
208 | filename+="etc/gutenbrowser/"; | 208 | filename+="etc/gutenbrowser/"; |
209 | odebug << "filename "+filename << oendl; | 209 | odebug << "filename "+filename << oendl; |
210 | // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; | 210 | // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; |
211 | 211 | ||
212 | filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); | 212 | filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); |
213 | 213 | ||
214 | Config config("Gutenbrowser"); | 214 | Config config("Gutenbrowser"); |
215 | config.setGroup( "Browser" ); | 215 | config.setGroup( "Browser" ); |
216 | QString brow = config.readEntry("Preferred", "Opera"); | 216 | QString brow = config.readEntry("Preferred", "Opera"); |
217 | odebug << "Preferred browser is "+brow << oendl; | 217 | odebug << "Preferred browser is "+brow << oendl; |
218 | if(!showMsg) { //if we just get the gutenindex.all | 218 | if(!showMsg) { //if we just get the gutenindex.all |
219 | cmd="wget -O " + filename +" " + url+" 2>&1" ; | 219 | cmd="wget -O " + filename +" " + url+" 2>&1" ; |
220 | chdir(local_library); | 220 | chdir(local_library); |
221 | odebug << "Issuing the system command: " << cmd << "" << oendl; | 221 | odebug << "Issuing the system command: " << cmd << "" << oendl; |
222 | 222 | ||
223 | Output *outDlg; | 223 | Output *outDlg; |
224 | outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); | 224 | |
225 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); | ||
226 | |||
225 | outDlg->showMaximized(); | 227 | outDlg->showMaximized(); |
226 | outDlg->show(); | 228 | outDlg->show(); |
227 | qApp->processEvents(); | 229 | qApp->processEvents(); |
228 | FILE *fp; | 230 | FILE *fp; |
229 | char line[130]; | 231 | char line[130]; |
230 | outDlg->OutputEdit->append( tr("Running wget") ); | 232 | outDlg->OutputEdit->append( tr("Running wget") ); |
233 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
231 | sleep(1); | 234 | sleep(1); |
232 | fp = popen( (const char *) cmd, "r"); | 235 | fp = popen( (const char *) cmd, "r"); |
233 | odebug << "Issuing the command\n"+cmd << oendl; | 236 | if ( !fp ) { |
234 | // system(cmd); | 237 | } else { |
235 | while ( fgets( line, sizeof line, fp)) { | 238 | //odebug << "Issuing the command\n"+cmd << oendl; |
236 | outDlg->OutputEdit->append(line); | 239 | // system(cmd); |
237 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 240 | while ( fgets( line, sizeof line, fp)) { |
241 | outDlg->OutputEdit->append(line); | ||
242 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
243 | } | ||
244 | pclose(fp); | ||
245 | outDlg->OutputEdit->append("Finished downloading\n"); | ||
246 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
247 | qApp->processEvents(); | ||
248 | |||
238 | } | 249 | } |
239 | pclose(fp); | 250 | outDlg->close(); |
240 | outDlg->close(); | 251 | |
241 | if(outDlg) | 252 | if(outDlg) |
242 | delete outDlg; | 253 | delete outDlg; |
243 | } else { | 254 | } else { |
244 | if( brow == "Konq") { | 255 | if( brow == "Konq") { |
245 | cmd = "konqueror "+url+" &"; | 256 | cmd = "konqueror "+url+" &"; |
246 | } | 257 | } |
247 | if( brow == "Opera") { //for desktop testing | 258 | if( brow == "Opera") { //for desktop testing |
248 | cmd = "opera "+url+" &"; | 259 | cmd = "opera "+url+" &"; |
249 | } | 260 | } |
250 | // if( brow == "Opera") { // on Zaurus | 261 | // if( brow == "Opera") { // on Zaurus |
251 | // cmd = "operagui "+url+" &"; | 262 | // cmd = "operagui "+url+" &"; |
252 | // } | 263 | // } |
253 | if( brow == "Mozilla") { | 264 | if( brow == "Mozilla") { |
254 | cmd = "mozilla "+url+" &"; | 265 | cmd = "mozilla "+url+" &"; |
255 | } | 266 | } |
256 | if( brow == "Netscape") { | 267 | if( brow == "Netscape") { |
257 | cmd = "netscape "+url+" &"; | 268 | cmd = "netscape "+url+" &"; |
258 | } | 269 | } |
259 | if(brow == "wget") { | 270 | if(brow == "wget") { |
260 | // cmd="wget -q "+url+" &"; | 271 | // cmd="wget -q "+url+" &"; |
261 | QString tempHtml=local_library+"webster.html"; | 272 | QString tempHtml=local_library+"webster.html"; |
262 | cmd="wget -O "+tempHtml+" -q "+url; | 273 | cmd="wget -O "+tempHtml+" -q "+url; |
263 | } | 274 | } |
264 | 275 | ||
265 | chdir(local_library); | 276 | chdir(local_library); |
266 | odebug << "Issuing the sys command: " << cmd << "" << oendl; | 277 | odebug << "Issuing the sys command: " << cmd << "" << oendl; |
267 | system(cmd); | 278 | system(cmd); |
268 | } | 279 | } |
269 | } | 280 | } |
270 | 281 | ||
271 | void Gutenbrowser::toggleButtonIcons( bool useEm) { | 282 | void Gutenbrowser::toggleButtonIcons( bool useEm) { |
272 | QString pixDir; | 283 | QString pixDir; |
273 | if(useEm) | 284 | if(useEm) |
274 | useEm=TRUE; | 285 | useEm=TRUE; |
275 | pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; | 286 | pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; |
276 | odebug << "Docdir is "+QPEApplication::documentDir() << oendl; | 287 | odebug << "Docdir is "+QPEApplication::documentDir() << oendl; |
277 | 288 | ||
278 | if( useIcons && QDir( pixDir).exists() ) { | 289 | if( useIcons && QDir( pixDir).exists() ) { |
279 | LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline | 290 | LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline |
280 | OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook")); | 291 | OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook")); |
281 | ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline | 292 | ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline |
282 | BackButton->setPixmap( Resource::loadPixmap("back") );//in inline | 293 | BackButton->setPixmap( Resource::loadPixmap("back") );//in inline |
283 | SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline | 294 | SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline |
284 | lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder")); | 295 | lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder")); |
285 | setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") ); | 296 | setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") ); |
286 | dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") ); | 297 | dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") ); |
287 | InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google")); | 298 | InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google")); |
288 | } | 299 | } |
289 | } | 300 | } |
290 | 301 | ||
291 | 302 | ||
292 | bool Gutenbrowser::queryExit() | 303 | bool Gutenbrowser::queryExit() |
293 | { | 304 | { |
294 | int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?", | 305 | int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?", |
295 | QMessageBox::Ok, QMessageBox::Cancel); | 306 | QMessageBox::Ok, QMessageBox::Cancel); |
296 | if (exit==1) { | 307 | if (exit==1) { |
297 | writeConfig(); | 308 | writeConfig(); |
298 | qApp->quit(); | 309 | qApp->quit(); |
299 | } else { | 310 | } else { |
300 | }; | 311 | }; |
301 | return (exit==1); | 312 | return (exit==1); |
302 | } | 313 | } |
303 | 314 | ||
304 | // SLOT IMPLEMENTATION | 315 | // SLOT IMPLEMENTATION |
305 | 316 | ||
306 | void Gutenbrowser::slotFilePrint() { | 317 | void Gutenbrowser::slotFilePrint() { |
307 | } | 318 | } |
308 | 319 | ||
309 | void Gutenbrowser::ByeBye() { | 320 | void Gutenbrowser::ByeBye() { |
310 | if (b_queryExit) | 321 | if (b_queryExit) |
311 | queryExit(); | 322 | queryExit(); |
312 | else { | 323 | else { |
313 | // writeConfig(); | 324 | // writeConfig(); |
314 | qApp->quit(); | 325 | qApp->quit(); |
315 | } | 326 | } |
316 | } | 327 | } |
317 | 328 | ||
318 | void Gutenbrowser::HelpBtn() { | 329 | void Gutenbrowser::HelpBtn() { |
319 | HelpMe* HelpDlg; | 330 | HelpMe* HelpDlg; |
320 | HelpDlg = new HelpMe( this, "Help Dialog"); | 331 | HelpDlg = new HelpMe( this, "Help Dialog"); |
321 | HelpDlg->showMaximized(); | 332 | HelpDlg->showMaximized(); |
322 | } | 333 | } |
323 | 334 | ||
324 | void Gutenbrowser::DownloadIndex() { | 335 | void Gutenbrowser::DownloadIndex() { |
325 | #ifndef Q_WS_QWS | 336 | #ifndef Q_WS_QWS |
326 | { | 337 | { |
327 | switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")), | 338 | switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")), |
328 | (tr("Do you want to download the newest\n" | 339 | (tr("Do you want to download the newest\n" |
329 | "Project Gutenberg Library Index?\n" | 340 | "Project Gutenberg Library Index?\n" |
330 | "or select an ftp site?\n")), | 341 | "or select an ftp site?\n")), |
331 | (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) ) | 342 | (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) ) |
332 | { | 343 | { |
333 | case 0: // index clicked, | 344 | case 0: // index clicked, |
334 | downloadLibIndex(); | 345 | downloadLibIndex(); |
335 | break; | 346 | break; |
336 | 347 | ||
337 | case 1: // ftp selected | 348 | case 1: // ftp selected |
338 | downloadFtpList(); | 349 | downloadFtpList(); |
339 | break; | 350 | break; |
340 | 351 | ||
341 | case 2: // Cancel | 352 | case 2: // Cancel |
342 | break; | 353 | break; |
343 | }; | 354 | }; |
344 | } | 355 | } |
345 | #endif | 356 | #endif |
346 | } // end DownloadIndex | 357 | } // end DownloadIndex |
347 | 358 | ||
348 | 359 | ||
349 | void Gutenbrowser::downloadFtpList() { | 360 | void Gutenbrowser::downloadFtpList() { |
350 | // QString cmd="wget http://www.promo.net/pg/list.html"); | 361 | // QString cmd="wget http://www.promo.net/pg/list.html"); |
351 | //system(cmd); | 362 | //system(cmd); |
352 | qApp->processEvents(); | 363 | qApp->processEvents(); |
353 | optionsDialog* optDlg; | 364 | optionsDialog* optDlg; |
354 | optDlg = new optionsDialog( this,"Options_Dlg", true); | 365 | optDlg = new optionsDialog( this,"Options_Dlg", true); |
355 | optDlg->getSite(); | 366 | optDlg->getSite(); |
356 | if(optDlg) | 367 | if(optDlg) |
357 | delete optDlg; | 368 | delete optDlg; |
358 | } | 369 | } |
359 | 370 | ||
360 | 371 | ||
361 | void Gutenbrowser::downloadLibIndex() { | 372 | void Gutenbrowser::downloadLibIndex() { |
362 | // QString dwmloader = local_library + "pgwhole.zip"; | 373 | // QString dwmloader = local_library + "pgwhole.zip"; |
363 | // QString cmd = "lynx -source http://www.gutenberg.net/pgwhole.zip | cat >> " + dwmloader; | 374 | // QString cmd = "lynx -source http://www.gutenberg.net/pgwhole.zip | cat >> " + dwmloader; |
364 | // system(cmd); | 375 | // system(cmd); |
365 | 376 | ||
366 | // QString outputFile= local_library+ "GUTINDEX.ALL"; | 377 | // QString outputFile= local_library+ "GUTINDEX.ALL"; |
367 | // config.setGroup( "FTPsite" ); // ftp server config | 378 | // config.setGroup( "FTPsite" ); // ftp server config |
368 | // ftp_host=config.readEntry("SiteName", ""); | 379 | // ftp_host=config.readEntry("SiteName", ""); |
369 | // ftp_base_dir= config.readEntry("base", ""); | 380 | // ftp_base_dir= config.readEntry("base", ""); |
370 | // QString networkUrl= "ftp://"+ftp_host+ftp_base_dir+"/GUTINDEX.ALL"; | 381 | // QString networkUrl= "ftp://"+ftp_host+ftp_base_dir+"/GUTINDEX.ALL"; |
371 | QDir dir( local_library); | 382 | QDir dir( local_library); |
372 | dir.cd("", TRUE); | 383 | dir.cd("", TRUE); |
373 | goGetit( "http://sailor.gutenberg.org/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3 | 384 | goGetit( "http://sailor.gutenberg.org/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3 |
374 | // goGetit( "http://www.gutenberg.net/pgwhole.zip", true); // until ghttp works on binaries -qt3 | 385 | // goGetit( "http://www.gutenberg.net/pgwhole.zip", true); // until ghttp works on binaries -qt3 |
375 | // NetworkDialog *NetworkDlg; | 386 | // NetworkDialog *NetworkDlg; |
376 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, outputFile ); | 387 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, outputFile ); |
377 | // if( NetworkDlg->exec() != 0 ) | 388 | // if( NetworkDlg->exec() != 0 ) |
378 | // { // use new, improved, *INSTANT* network-dialog-file-getterer | 389 | // { // use new, improved, *INSTANT* network-dialog-file-getterer |
379 | //// QMessageBox::message("Note",""); | 390 | //// QMessageBox::message("Note",""); |
380 | // } | 391 | // } |
381 | // if(NetworkDlg) | 392 | // if(NetworkDlg) |
382 | // delete NetworkDlg; | 393 | // delete NetworkDlg; |
383 | } | 394 | } |
384 | 395 | ||
385 | 396 | ||
386 | void Gutenbrowser::PrintBtn() { | 397 | void Gutenbrowser::PrintBtn() { |
387 | } | 398 | } |
388 | 399 | ||
389 | void Gutenbrowser::SearchBtn() { | 400 | void Gutenbrowser::SearchBtn() { |
390 | if( loadCheck) { | 401 | if( loadCheck) { |
391 | odebug << "loadCheck: we have a loaded doc" << oendl; | 402 | odebug << "loadCheck: we have a loaded doc" << oendl; |
392 | Search(); | 403 | Search(); |
393 | } | 404 | } |
394 | // else | 405 | // else |
395 | // QMessageBox::message("Note","Sorry, can't search. No etext is loaded"); | 406 | // QMessageBox::message("Note","Sorry, can't search. No etext is loaded"); |
396 | } | 407 | } |
397 | 408 | ||
398 | 409 | ||
399 | void Gutenbrowser::ForwardBtn() { | 410 | void Gutenbrowser::ForwardBtn() { |
400 | 411 | ||
401 | if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) { | 412 | if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) { |
402 | 413 | ||
403 | QString s; | 414 | QString s; |
404 | QString insertString; | 415 | QString insertString; |
405 | int pageSize= Lview->PageSize(); | 416 | int pageSize= Lview->PageSize(); |
406 | Lview->clear(); | 417 | Lview->clear(); |
407 | 418 | ||
408 | for(int fd=0; fd < pageSize - 1;fd++) { | 419 | for(int fd=0; fd < pageSize - 1;fd++) { |
409 | f.readLine(s, 256); | 420 | f.readLine(s, 256); |
410 | if(useWrap) | 421 | if(useWrap) |
411 | s.replace(QRegExp("\n"),""); | 422 | s.replace(QRegExp("\n"),""); |
412 | insertString+=s; | 423 | insertString+=s; |
413 | Lview->insertLine( s, -1); | 424 | Lview->insertLine( s, -1); |
414 | // odebug << s << oendl; | 425 | // odebug << s << oendl; |
415 | currentLine++; | 426 | currentLine++; |
416 | } | 427 | } |
417 | // Lview->insertAt( insertString,0,0, FALSE); | 428 | // Lview->insertAt( insertString,0,0, FALSE); |
418 | currentFilePos = f.at(); | 429 | currentFilePos = f.at(); |
419 | // if( i_pageNum != pages) { | 430 | // if( i_pageNum != pages) { |
420 | // Lview->MultiLine_Ex::pageDown( FALSE); | 431 | // Lview->MultiLine_Ex::pageDown( FALSE); |
421 | i_pageNum++; | 432 | i_pageNum++; |
422 | pageStopArray.resize(i_pageNum + 1); | 433 | pageStopArray.resize(i_pageNum + 1); |
423 | // int length = Lview->length(); | 434 | // int length = Lview->length(); |
424 | 435 | ||
425 | pageStopArray[i_pageNum ] = currentFilePos; | 436 | pageStopArray[i_pageNum ] = currentFilePos; |
426 | odebug << currentFilePos << " current page is number " << i_pageNum | 437 | odebug << currentFilePos << " current page is number " << i_pageNum |
427 | << ", pagesize " << pageSize << ", length " << Lview->length() | 438 | << ", pagesize " << pageSize << ", length " << Lview->length() |
428 | << ", current " << pageStopArray[i_pageNum] << oendl; | 439 | << ", current " << pageStopArray[i_pageNum] << oendl; |
429 | setStatus(); | 440 | setStatus(); |
430 | // Lview->setCursorPosition( 0, 0, FALSE); | 441 | // Lview->setCursorPosition( 0, 0, FALSE); |
431 | // } | 442 | // } |
432 | 443 | ||
433 | } else { | 444 | } else { |
434 | odebug << "bal" << oendl; | 445 | odebug << "bal" << oendl; |
435 | // if( i_pageNum != pages) { | 446 | // if( i_pageNum != pages) { |
436 | 447 | ||
437 | // // int newTop = Lview->Top(); | 448 | // // int newTop = Lview->Top(); |
438 | // // if(Lview->lastRow() > i) | 449 | // // if(Lview->lastRow() > i) |
439 | // Lview->ScrollUp(1); | 450 | // Lview->ScrollUp(1); |
440 | // // i_pageNum++; | 451 | // // i_pageNum++; |
441 | // setStatus(); | 452 | // setStatus(); |
442 | // Lview->setCursorPosition( Lview->Top(), 0, FALSE); | 453 | // Lview->setCursorPosition( Lview->Top(), 0, FALSE); |
443 | 454 | ||
444 | // } | 455 | // } |
445 | 456 | ||
446 | } | 457 | } |
447 | Lview->setFocus(); | 458 | Lview->setFocus(); |
448 | 459 | ||
449 | odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl; | 460 | odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl; |
450 | } | 461 | } |
451 | 462 | ||
452 | 463 | ||
453 | void Gutenbrowser::BackBtn() { | 464 | void Gutenbrowser::BackBtn() { |
454 | if( i_pageNum > 0) { | 465 | if( i_pageNum > 0) { |
455 | int pageSize= Lview->PageSize(); | 466 | int pageSize= Lview->PageSize(); |
456 | // int length=Lview->length(); | 467 | // int length=Lview->length(); |
457 | 468 | ||
458 | i_pageNum--; | 469 | i_pageNum--; |
459 | currentFilePos = f.at(); | 470 | currentFilePos = f.at(); |
460 | 471 | ||
461 | odebug << currentFilePos << " move back to " << pageStopArray[i_pageNum - 1 ] | 472 | odebug << currentFilePos << " move back to " << pageStopArray[i_pageNum - 1 ] |
462 | << ", current page number " << i_pageNum | 473 | << ", current page number " << i_pageNum |
463 | << ", " << pageSize << ", length " << Lview->length() << oendl; | 474 | << ", " << pageSize << ", length " << Lview->length() << oendl; |
464 | 475 | ||
465 | if( i_pageNum < 2) { | 476 | if( i_pageNum < 2) { |
466 | f.at( 0); | 477 | f.at( 0); |
467 | } else { | 478 | } else { |
468 | if(!f.at( pageStopArray[i_pageNum - 1] )) | 479 | if(!f.at( pageStopArray[i_pageNum - 1] )) |
469 | odebug << "File positioned backward did not work" << oendl; | 480 | odebug << "File positioned backward did not work" << oendl; |
470 | } | 481 | } |
471 | QString s; | 482 | QString s; |
472 | // int sizeLine=0; | 483 | // int sizeLine=0; |
473 | Lview->clear(); | 484 | Lview->clear(); |
474 | // QString insertString; | 485 | // QString insertString; |
475 | 486 | ||
476 | for(int fd = 0; fd < pageSize ;fd++) { | 487 | for(int fd = 0; fd < pageSize ;fd++) { |
477 | // Lview->removeLine( Lview->PageSize() ); | 488 | // Lview->removeLine( Lview->PageSize() ); |
478 | f.readLine(s, 256); | 489 | f.readLine(s, 256); |
479 | if(useWrap) | 490 | if(useWrap) |
480 | s.replace(QRegExp("\n"),""); | 491 | s.replace(QRegExp("\n"),""); |
481 | currentLine++; | 492 | currentLine++; |
482 | // insertString+=s; | 493 | // insertString+=s; |
483 | Lview->insertLine( s, -1); | 494 | Lview->insertLine( s, -1); |
484 | } | 495 | } |
485 | 496 | ||
486 | // Lview->insertAt( insertString,0,0, FALSE); | 497 | // Lview->insertAt( insertString,0,0, FALSE); |
487 | 498 | ||
488 | if( !BackButton->autoRepeat() && !BackButton->isDown()) { | 499 | if( !BackButton->autoRepeat() && !BackButton->isDown()) { |
489 | QString topR; | 500 | QString topR; |
490 | QString lastR; | 501 | QString lastR; |
491 | QString pageR; | 502 | QString pageR; |
492 | // int sizer = Lview->lastRow() - Lview->topRow(); | 503 | // int sizer = Lview->lastRow() - Lview->topRow(); |
493 | // int i_topRow = Lview->topRow(); | 504 | // int i_topRow = Lview->topRow(); |
494 | if( i_pageNum < 1) | 505 | if( i_pageNum < 1) |
495 | i_pageNum = 1; | 506 | i_pageNum = 1; |
496 | setCaption(QString::number(i_pageNum)); | 507 | setCaption(QString::number(i_pageNum)); |
497 | } else { | 508 | } else { |
498 | // int newTop = Lview->Top(); | 509 | // int newTop = Lview->Top(); |
499 | // if(Lview->lastRow() > i) | 510 | // if(Lview->lastRow() > i) |
500 | Lview->MultiLine_Ex::pageUp( FALSE); | 511 | Lview->MultiLine_Ex::pageUp( FALSE); |
501 | // Lview->ScrollDown(1); | 512 | // Lview->ScrollDown(1); |
502 | // i_pageNum--; | 513 | // i_pageNum--; |
503 | if( i_pageNum < 1) | 514 | if( i_pageNum < 1) |
504 | i_pageNum = 1; | 515 | i_pageNum = 1; |
505 | setStatus(); | 516 | setStatus(); |
506 | // Lview->setCursorPosition( Lview->Top(), 0, FALSE); | 517 | // Lview->setCursorPosition( Lview->Top(), 0, FALSE); |
507 | 518 | ||
508 | } | 519 | } |
509 | } | 520 | } |
510 | Lview->setFocus(); | 521 | Lview->setFocus(); |
511 | } | 522 | } |
512 | 523 | ||
513 | void Gutenbrowser::doBeginBtn() { | 524 | void Gutenbrowser::doBeginBtn() { |
514 | if(loadCheck) { | 525 | if(loadCheck) { |
515 | qApp->processEvents(); | 526 | qApp->processEvents(); |
516 | BeginBtn(); | 527 | BeginBtn(); |
517 | } | 528 | } |
518 | } | 529 | } |
519 | 530 | ||
520 | // moves text to the very top = 0 | 531 | // moves text to the very top = 0 |
521 | void Gutenbrowser::TopBtn() { | 532 | void Gutenbrowser::TopBtn() { |
522 | 533 | ||
523 | if(loadCheck) { | 534 | if(loadCheck) { |
524 | if( i_pageNum != 0) { | 535 | if( i_pageNum != 0) { |
525 | odebug << "top" << oendl; | 536 | odebug << "top" << oendl; |
526 | qApp->processEvents(); | 537 | qApp->processEvents(); |
527 | currentLine = 0; | 538 | currentLine = 0; |
528 | i_pageNum = 1; | 539 | i_pageNum = 1; |
529 | int pageSize = Lview->PageSize() ; | 540 | int pageSize = Lview->PageSize() ; |
530 | Lview->clear(); | 541 | Lview->clear(); |
531 | QString s; | 542 | QString s; |
532 | f.at(0); | 543 | f.at(0); |
533 | for(int fd=0; fd < pageSize ;fd++) { | 544 | for(int fd=0; fd < pageSize ;fd++) { |
534 | f.readLine(s, 256); | 545 | f.readLine(s, 256); |
535 | if(useWrap) | 546 | if(useWrap) |
536 | s.replace(QRegExp("\n"),""); | 547 | s.replace(QRegExp("\n"),""); |
537 | Lview->insertLine(s ,-1); | 548 | Lview->insertLine(s ,-1); |
538 | currentLine++; | 549 | currentLine++; |
539 | } | 550 | } |
540 | // Lview->setCursorPosition( 0,0, FALSE); | 551 | // Lview->setCursorPosition( 0,0, FALSE); |
541 | i_pageNum=1; | 552 | i_pageNum=1; |
542 | setStatus(); | 553 | setStatus(); |
543 | } | 554 | } |
544 | Lview->setFocus(); | 555 | Lview->setFocus(); |
545 | } | 556 | } |
546 | } | 557 | } |
547 | 558 | ||
548 | //moves text to the start of the EText | 559 | //moves text to the start of the EText |
549 | void Gutenbrowser::BeginBtn() { | 560 | void Gutenbrowser::BeginBtn() { |
550 | i_pageNum = 1; | 561 | i_pageNum = 1; |
551 | currentLine = 0; | 562 | currentLine = 0; |
552 | QString s_pattern="*END*THE SMALL PRINT"; | 563 | QString s_pattern="*END*THE SMALL PRINT"; |
553 | QString sPattern2 = "*END THE SMALL PRINT"; | 564 | QString sPattern2 = "*END THE SMALL PRINT"; |
554 | 565 | ||
555 | int pageSize = Lview->PageSize(); | 566 | int pageSize = Lview->PageSize(); |
556 | Lview->clear(); | 567 | Lview->clear(); |
557 | 568 | ||
558 | // int lines = Lview->numLines(); | 569 | // int lines = Lview->numLines(); |
559 | int pos = 0;//, i = 0; | 570 | int pos = 0;//, i = 0; |
560 | int i_topRow = Lview->topRow(); | 571 | int i_topRow = Lview->topRow(); |
561 | 572 | ||
562 | QString LeftText;// = Lview->text(); | 573 | QString LeftText;// = Lview->text(); |
563 | 574 | ||
564 | // int linesPerPage = Lview->lastRow() - Lview->topRow(); | 575 | // int linesPerPage = Lview->lastRow() - Lview->topRow(); |
565 | // int pages = (( linesPerPage / Lview->editSize() ) ) +1; | 576 | // int pages = (( linesPerPage / Lview->editSize() ) ) +1; |
566 | // int pageN = 0; | 577 | // int pageN = 0; |
567 | i_pageNum = 1; | 578 | i_pageNum = 1; |
568 | int lastPage=1; | 579 | int lastPage=1; |
569 | int lineNo=0; | 580 | int lineNo=0; |
570 | QString s; | 581 | QString s; |
571 | f.at( 0); | 582 | f.at( 0); |
572 | 583 | ||
573 | while ( !f.atEnd() ) { | 584 | while ( !f.atEnd() ) { |
574 | f.readLine(s, 256); | 585 | f.readLine(s, 256); |
575 | lineNo++; | 586 | lineNo++; |
576 | LeftText = s; | 587 | LeftText = s; |
577 | currentFilePos = f.at(); | 588 | currentFilePos = f.at(); |
578 | 589 | ||
579 | i_pageNum = lineNo/pageSize; | 590 | i_pageNum = lineNo/pageSize; |
580 | if(lastPage < i_pageNum) { | 591 | if(lastPage < i_pageNum) { |
581 | pageStopArray.resize(i_pageNum + 1); | 592 | pageStopArray.resize(i_pageNum + 1); |
582 | pageStopArray[i_pageNum ] = currentFilePos; | 593 | pageStopArray[i_pageNum ] = currentFilePos; |
583 | // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; | 594 | // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; |
584 | } | 595 | } |
585 | // lastPage = i_pageNum; | 596 | // lastPage = i_pageNum; |
586 | if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) { | 597 | if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) { |
587 | odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; | 598 | odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; |
588 | break; | 599 | break; |
589 | } | 600 | } |
590 | } | 601 | } |
591 | if(f.atEnd()) //in case we didnt find anything, we need to show something | 602 | if(f.atEnd()) //in case we didnt find anything, we need to show something |
592 | f.at(0); | 603 | f.at(0); |
593 | Lview->clear(); | 604 | Lview->clear(); |
594 | for(int fd=0; fd < pageSize - 1;fd++) { | 605 | for(int fd=0; fd < pageSize - 1;fd++) { |
595 | f.readLine(s, 256); | 606 | f.readLine(s, 256); |
596 | if(useWrap) | 607 | if(useWrap) |
597 | s.replace(QRegExp("\n"),""); | 608 | s.replace(QRegExp("\n"),""); |
598 | Lview->insertLine( s, -1); | 609 | Lview->insertLine( s, -1); |
599 | currentLine++; | 610 | currentLine++; |
600 | } | 611 | } |
601 | 612 | ||
602 | i_pageNum = lineNo/pageSize; | 613 | i_pageNum = lineNo/pageSize; |
603 | pageStopArray.resize(i_pageNum + 1); | 614 | pageStopArray.resize(i_pageNum + 1); |
604 | // int length = Lview->length(); | 615 | // int length = Lview->length(); |
605 | 616 | ||
606 | qApp->processEvents(); | 617 | qApp->processEvents(); |
607 | 618 | ||
608 | if( pos > i_topRow ) { | 619 | if( pos > i_topRow ) { |
609 | // Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE); | 620 | // Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE); |
610 | } else { | 621 | } else { |
611 | // Lview->setCursorPosition( pos+2 , 0, FALSE ); | 622 | // Lview->setCursorPosition( pos+2 , 0, FALSE ); |
612 | } | 623 | } |
613 | 624 | ||
614 | Lview->deselect(); | 625 | Lview->deselect(); |
615 | // AdjustStatus(); | 626 | // AdjustStatus(); |
616 | Lview->setFocus(); | 627 | Lview->setFocus(); |
617 | } | 628 | } |
618 | 629 | ||
619 | /* | 630 | /* |
620 | sets the current page and place as a bookmark*/ | 631 | sets the current page and place as a bookmark*/ |
621 | void Gutenbrowser::setBookmark() { | 632 | void Gutenbrowser::setBookmark() { |
622 | int eexit=QMessageBox::information(this, "Note", | 633 | int eexit=QMessageBox::information(this, "Note", |
623 | "Do you really want to \nset this bookmark?." | 634 | "Do you really want to \nset this bookmark?." |
624 | ,QMessageBox::Yes, QMessageBox::No); | 635 | ,QMessageBox::Yes, QMessageBox::No); |
625 | if (eexit== 3) { | 636 | if (eexit== 3) { |
626 | 637 | ||
627 | currentFilePos = f.at(); | 638 | currentFilePos = f.at(); |
628 | 639 | ||
629 | Config cfg("Gutenbrowser"); | 640 | Config cfg("Gutenbrowser"); |
630 | cfg.setGroup("General"); | 641 | cfg.setGroup("General"); |
631 | file_name = cfg.readEntry("Current",""); | 642 | file_name = cfg.readEntry("Current",""); |
632 | qApp->processEvents(); | 643 | qApp->processEvents(); |
633 | odebug << "Setting book mark "+file_name << oendl; | 644 | odebug << "Setting book mark "+file_name << oendl; |
634 | 645 | ||
635 | cfg.setGroup("Titles"); | 646 | cfg.setGroup("Titles"); |
636 | title = cfg.readEntry(file_name,""); | 647 | title = cfg.readEntry(file_name,""); |
637 | odebug << "title is "+ title << oendl; | 648 | odebug << "title is "+ title << oendl; |
638 | 649 | ||
639 | cfg.setGroup( "Bookmarks" ); | 650 | cfg.setGroup( "Bookmarks" ); |
640 | 651 | ||
641 | cfg.writeEntry("File Name",file_name); | 652 | cfg.writeEntry("File Name",file_name); |
642 | cfg.writeEntry("Page Number",QString::number(i_pageNum) ); | 653 | cfg.writeEntry("Page Number",QString::number(i_pageNum) ); |
643 | cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); | 654 | cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); |
644 | cfg.writeEntry("Title", title); | 655 | cfg.writeEntry("Title", title); |
645 | 656 | ||
646 | int row = Lview->topRow();// Lview->Top(); | 657 | int row = Lview->topRow();// Lview->Top(); |
647 | cfg.writeEntry("LineNumber",QString::number(row) ); | 658 | cfg.writeEntry("LineNumber",QString::number(row) ); |
648 | 659 | ||
649 | cfg.setGroup(title); | 660 | cfg.setGroup(title); |
650 | cfg.writeEntry("File Name",file_name); | 661 | cfg.writeEntry("File Name",file_name); |
651 | cfg.writeEntry( "LineNumber", QString::number( row)); | 662 | cfg.writeEntry( "LineNumber", QString::number( row)); |
652 | cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); | 663 | cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); |
653 | cfg.writeEntry( "Page Number", QString::number( i_pageNum) ); | 664 | cfg.writeEntry( "Page Number", QString::number( i_pageNum) ); |
654 | cfg.write(); | 665 | cfg.write(); |
655 | bookmarksMenu->insertItem( title); | 666 | bookmarksMenu->insertItem( title); |
656 | } | 667 | } |
657 | } //end setBookmark | 668 | } //end setBookmark |
658 | 669 | ||
659 | 670 | ||
660 | /* goes to last set bookmark*/ | 671 | /* goes to last set bookmark*/ |
661 | void Gutenbrowser::Bookmark( int itemId) { | 672 | void Gutenbrowser::Bookmark( int itemId) { |
662 | 673 | ||
663 | // qApp->processEvents(); | 674 | // qApp->processEvents(); |
664 | Config config("Gutenbrowser"); | 675 | Config config("Gutenbrowser"); |
665 | config.setGroup( "Bookmarks" ); | 676 | config.setGroup( "Bookmarks" ); |
666 | 677 | ||
667 | odebug << "<<<<<< " << Lview->PageSize() << ", " << Lview->lastRow() - Lview->topRow() << "" << oendl; | 678 | odebug << "<<<<<< " << Lview->PageSize() << ", " << Lview->lastRow() - Lview->topRow() << "" << oendl; |
668 | 679 | ||
669 | QString itemString; | 680 | QString itemString; |
670 | 681 | ||
671 | odebug << "menu item " << itemId << "" << oendl; | 682 | odebug << "menu item " << itemId << "" << oendl; |
672 | QString tempTitle; | 683 | QString tempTitle; |
673 | QString s_Bmrkrow; | 684 | QString s_Bmrkrow; |
674 | QString s_pageNum; | 685 | QString s_pageNum; |
675 | int Bmrkrow=0; | 686 | int Bmrkrow=0; |
676 | int bookmarkPosition = 0; | 687 | int bookmarkPosition = 0; |
677 | 688 | ||
678 | // qApp->processEvents(); | 689 | // qApp->processEvents(); |
679 | config.setGroup( "Bookmarks" ); | 690 | config.setGroup( "Bookmarks" ); |
680 | title = config.readEntry("Title", ""); | 691 | title = config.readEntry("Title", ""); |
681 | file_name = config.readEntry("File Name", ""); | 692 | file_name = config.readEntry("File Name", ""); |
682 | i_pageNum = config.readNumEntry("Page Number", 0); | 693 | i_pageNum = config.readNumEntry("Page Number", 0); |
683 | bookmarkPosition = config.readNumEntry( "PagePosition",0); | 694 | bookmarkPosition = config.readNumEntry( "PagePosition",0); |
684 | Bmrkrow = config.readNumEntry("LineNumber",0); | 695 | Bmrkrow = config.readNumEntry("LineNumber",0); |
685 | if( !file_name.contains("/")) { | 696 | if( !file_name.contains("/")) { |
686 | file_name = local_library + file_name; | 697 | file_name = local_library + file_name; |
687 | } | 698 | } |
688 | 699 | ||
689 | // getTitle(file_name); | 700 | // getTitle(file_name); |
690 | // qApp->processEvents(); | 701 | // qApp->processEvents(); |
691 | // Lview->setFocus(); | 702 | // Lview->setFocus(); |
692 | this->setFocus(); | 703 | this->setFocus(); |
693 | 704 | ||
694 | Lview->clear(); | 705 | Lview->clear(); |
695 | 706 | ||
696 | if(!load(file_name)) return; | 707 | if(!load(file_name)) return; |
697 | 708 | ||
698 | int pageSize = Lview->PageSize(); | 709 | int pageSize = Lview->PageSize(); |
699 | f.at(0); | 710 | f.at(0); |
700 | // Lview->clear(); | 711 | // Lview->clear(); |
701 | QString s; | 712 | QString s; |
702 | int lineNo=0; | 713 | int lineNo=0; |
703 | int lastPage=1; | 714 | int lastPage=1; |
704 | while ( !f.atEnd() ) { | 715 | while ( !f.atEnd() ) { |
705 | f.readLine(s, 256); | 716 | f.readLine(s, 256); |
706 | lineNo++; | 717 | lineNo++; |
707 | currentFilePos = f.at(); | 718 | currentFilePos = f.at(); |
708 | 719 | ||
709 | i_pageNum = lineNo/pageSize; | 720 | i_pageNum = lineNo/pageSize; |
710 | if(lastPage < i_pageNum) { | 721 | if(lastPage < i_pageNum) { |
711 | pageStopArray.resize(i_pageNum + 1); | 722 | pageStopArray.resize(i_pageNum + 1); |
712 | pageStopArray[i_pageNum ] = currentFilePos; | 723 | pageStopArray[i_pageNum ] = currentFilePos; |
713 | // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; | 724 | // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; |
714 | } | 725 | } |
715 | if(currentFilePos == bookmarkPosition) | 726 | if(currentFilePos == bookmarkPosition) |
716 | break; | 727 | break; |
717 | } | 728 | } |
718 | if(f.atEnd()) | 729 | if(f.atEnd()) |
719 | f.at(0); | 730 | f.at(0); |
720 | else | 731 | else |
721 | f.at( bookmarkPosition); | 732 | f.at( bookmarkPosition); |
722 | 733 | ||
723 | for(int fd=0; fd < pageSize - 1;fd++) { | 734 | for(int fd=0; fd < pageSize - 1;fd++) { |
724 | f.readLine(s, 256); | 735 | f.readLine(s, 256); |
725 | lineNo++; | 736 | lineNo++; |
726 | if(useWrap) | 737 | if(useWrap) |
727 | s.replace(QRegExp("\n"),""); | 738 | s.replace(QRegExp("\n"),""); |
728 | Lview->insertLine( s, -1); | 739 | Lview->insertLine( s, -1); |
729 | currentLine++; | 740 | currentLine++; |
730 | } | 741 | } |
731 | 742 | ||
732 | i_pageNum = lineNo/pageSize; | 743 | i_pageNum = lineNo/pageSize; |
733 | pageStopArray.resize(i_pageNum + 1); | 744 | pageStopArray.resize(i_pageNum + 1); |
734 | 745 | ||
735 | if(showMainList) { | 746 | if(showMainList) { |
736 | showMainList=FALSE; | 747 | showMainList=FALSE; |
737 | mainList->hide(); | 748 | mainList->hide(); |
738 | Lview->show(); | 749 | Lview->show(); |
739 | // qApp->processEvents(); | 750 | // qApp->processEvents(); |
740 | } | 751 | } |
741 | 752 | ||
742 | odebug << "bookmark loaded" << oendl; | 753 | odebug << "bookmark loaded" << oendl; |
743 | setCaption(title); | 754 | setCaption(title); |
744 | } | 755 | } |
745 | 756 | ||
746 | 757 | ||
747 | bool Gutenbrowser::load( const char *fileName) { | 758 | bool Gutenbrowser::load( const char *fileName) { |
748 | 759 | ||
749 | // QCopEnvelope ( "QPE/System", "busy()" ); | 760 | // QCopEnvelope ( "QPE/System", "busy()" ); |
750 | odebug << "Title is already set as "+title << oendl; | 761 | odebug << "Title is already set as "+title << oendl; |
751 | odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl; | 762 | odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl; |
752 | // pointSize = Lview->fontInfo().pointSize(); | 763 | // pointSize = Lview->fontInfo().pointSize(); |
753 | // odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl; | 764 | // odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl; |
754 | if( Lview->PageSize() < 4) { | 765 | if( Lview->PageSize() < 4) { |
755 | 766 | ||
756 | //Lview->setMaximumHeight( sizeHint().height() ); | 767 | //Lview->setMaximumHeight( sizeHint().height() ); |
757 | Lview->setMinimumHeight( sizeHint().height() ); | 768 | Lview->setMinimumHeight( sizeHint().height() ); |
758 | pointSize = Lview->fontInfo().pointSize(); | 769 | pointSize = Lview->fontInfo().pointSize(); |
759 | odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl; | 770 | odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl; |
760 | if(pointSize < 15) | 771 | if(pointSize < 15) |
761 | Lview->setFixedVisibleLines(19); | 772 | Lview->setFixedVisibleLines(19); |
762 | else | 773 | else |
763 | Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2); | 774 | Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2); |
764 | } | 775 | } |
765 | 776 | ||
766 | Config cfg("Gutenbrowser"); | 777 | Config cfg("Gutenbrowser"); |
767 | cfg.setGroup("General"); | 778 | cfg.setGroup("General"); |
768 | cfg.writeEntry("Current",fileName); | 779 | cfg.writeEntry("Current",fileName); |
769 | cfg.write(); | 780 | cfg.write(); |
770 | currentLine=0; | 781 | currentLine=0; |
771 | 782 | ||
772 | file_name=fileName; | 783 | file_name=fileName; |
773 | QString o_file = fileName; | 784 | QString o_file = fileName; |
774 | 785 | ||
775 | // if (i_pageNum < 1) { | 786 | // if (i_pageNum < 1) { |
776 | i_pageNum = 1; | 787 | i_pageNum = 1; |
777 | // } | 788 | // } |
778 | odebug << "ready to open "+o_file << oendl; | 789 | odebug << "ready to open "+o_file << oendl; |
779 | 790 | ||
780 | if(f.isOpen()) f.close(); | 791 | if(f.isOpen()) f.close(); |
781 | f.setName( o_file); | 792 | f.setName( o_file); |
782 | 793 | ||
783 | if ( !f.open( IO_ReadOnly)) { | 794 | if ( !f.open( IO_ReadOnly)) { |
784 | QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) ); | 795 | QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) ); |
785 | return false; | 796 | return false; |
786 | } | 797 | } |
787 | currentFilePos = 0; | 798 | currentFilePos = 0; |
788 | pageStopArray.resize(3); | 799 | pageStopArray.resize(3); |
789 | pageStopArray[0] = currentFilePos; | 800 | pageStopArray[0] = currentFilePos; |
790 | 801 | ||
791 | fileHandle = f.handle(); | 802 | fileHandle = f.handle(); |
792 | QString insertString; | 803 | QString insertString; |
793 | QTextStream t(&f); | 804 | QTextStream t(&f); |
794 | QString s; | 805 | QString s; |
795 | for(int fd=0; fd < Lview->PageSize() ;fd++) { | 806 | for(int fd=0; fd < Lview->PageSize() ;fd++) { |
796 | s=t.readLine(); | 807 | s=t.readLine(); |
797 | // insertString+=s; | 808 | // insertString+=s; |
798 | if(useWrap) | 809 | if(useWrap) |
799 | s.replace(QRegExp("\n"),""); | 810 | s.replace(QRegExp("\n"),""); |
800 | // s.replace(QRegExp("\r"),""); | 811 | // s.replace(QRegExp("\r"),""); |
801 | Lview->insertLine( s,-1); | 812 | Lview->insertLine( s,-1); |
802 | currentLine++; | 813 | currentLine++; |
803 | } | 814 | } |
804 | 815 | ||
805 | // int length = Lview->length(); | 816 | // int length = Lview->length(); |
806 | currentFilePos = f.at(); | 817 | currentFilePos = f.at(); |
807 | 818 | ||
808 | pageStopArray[1] = currentFilePos; | 819 | pageStopArray[1] = currentFilePos; |
809 | 820 | ||
810 | odebug << "<<<<<<<<<<<" << currentFilePos << " current page is number " << i_pageNum | 821 | odebug << "<<<<<<<<<<<" << currentFilePos << " current page is number " << i_pageNum |
811 | << ", length " << Lview->length() << ", current " << pageStopArray[i_pageNum] | 822 | << ", length " << Lview->length() << ", current " << pageStopArray[i_pageNum] |
812 | << ", pageSize " << Lview->PageSize() << oendl; | 823 | << ", pageSize " << Lview->PageSize() << oendl; |
813 | 824 | ||
814 | Lview->setMaxLines(Lview->PageSize()*2); | 825 | Lview->setMaxLines(Lview->PageSize()*2); |
815 | // odebug << "Gulped " << currentLine << "" << oendl; | 826 | // odebug << "Gulped " << currentLine << "" << oendl; |
816 | setCaption(title); | 827 | setCaption(title); |
817 | Lview->setAutoUpdate( TRUE); | 828 | Lview->setAutoUpdate( TRUE); |
818 | 829 | ||
819 | // Lview->setCursorPosition(0,0,FALSE); | 830 | // Lview->setCursorPosition(0,0,FALSE); |
820 | 831 | ||
821 | // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; | 832 | // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; |
822 | //odebug << "number of pages " << pages << "" << oendl; | 833 | //odebug << "number of pages " << pages << "" << oendl; |
823 | 834 | ||
824 | loadCheck = true; | 835 | loadCheck = true; |
825 | enableButtons(true); | 836 | enableButtons(true); |
826 | if( donateMenu->count() == 3) { | 837 | if( donateMenu->count() == 3) { |
827 | donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() )); | 838 | donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() )); |
828 | } | 839 | } |
829 | Lview->setFocus(); | 840 | Lview->setFocus(); |
830 | 841 | ||
831 | // QCopEnvelope("QPE/System", "notBusy()" ); | 842 | // QCopEnvelope("QPE/System", "notBusy()" ); |
832 | return true; | 843 | return true; |
833 | } // end load | 844 | } // end load |
834 | 845 | ||
835 | void Gutenbrowser::Search() { | 846 | void Gutenbrowser::Search() { |
836 | 847 | ||
837 | // if( searchDlg->isHidden()) | 848 | // if( searchDlg->isHidden()) |
838 | { | 849 | { |
839 | odebug << "Starting search dialog" << oendl; | 850 | odebug << "Starting search dialog" << oendl; |
840 | searchDlg = new SearchDialog( this, "Etext Search", true); | 851 | searchDlg = new SearchDialog( this, "Etext Search", true); |
841 | searchDlg->setCaption( tr( "Etext Search" )); | 852 | searchDlg->setCaption( tr( "Etext Search" )); |
842 | // searchDlg->setLabel( "- searches etext"); | 853 | // searchDlg->setLabel( "- searches etext"); |
843 | connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); | 854 | connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); |
844 | connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); | 855 | connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); |
845 | 856 | ||
846 | QString resultString; | 857 | QString resultString; |
847 | QString string = searchDlg->searchString; | 858 | QString string = searchDlg->searchString; |
848 | Lview->deselect(); | 859 | Lview->deselect(); |
849 | searchDlg->show(); | 860 | searchDlg->show(); |
850 | searchDlg->result(); | 861 | searchDlg->result(); |
851 | } | 862 | } |
852 | } | 863 | } |
853 | 864 | ||
854 | void Gutenbrowser::search_slot( ) { | 865 | void Gutenbrowser::search_slot( ) { |
855 | int line, col; | 866 | int line, col; |
856 | if (!searchDlg /*&& !loadCheck */) | 867 | if (!searchDlg /*&& !loadCheck */) |
857 | return; | 868 | return; |
858 | 869 | ||
859 | Lview->getCursorPosition(&line,&col); | 870 | Lview->getCursorPosition(&line,&col); |
860 | QString to_find_string=searchDlg->get_text(); | 871 | QString to_find_string=searchDlg->get_text(); |
861 | 872 | ||
862 | // searchDlg->get_direction();// is true if searching backward | 873 | // searchDlg->get_direction();// is true if searching backward |
863 | if ( last_search != 0 && searchDlg->get_direction() ){ | 874 | if ( last_search != 0 && searchDlg->get_direction() ){ |
864 | col = col - pattern.length() - 1 ; | 875 | col = col - pattern.length() - 1 ; |
865 | } | 876 | } |
866 | again: | 877 | again: |
867 | int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col); | 878 | int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col); |
868 | if(result == 0){ | 879 | if(result == 0){ |
869 | if(!searchDlg->get_direction()){ // forward search | 880 | if(!searchDlg->get_direction()){ // forward search |
870 | int query = QMessageBox::information( searchDlg, "Find", | 881 | int query = QMessageBox::information( searchDlg, "Find", |
871 | "End of document reached.\nContinue from the beginning?", | 882 | "End of document reached.\nContinue from the beginning?", |
872 | "Yes", "No", "", 0,1); | 883 | "Yes", "No", "", 0,1); |
873 | if (query == 0){ | 884 | if (query == 0){ |
874 | line = 0; | 885 | line = 0; |
875 | col = 0; | 886 | col = 0; |
876 | goto again; | 887 | goto again; |
877 | } | 888 | } |
878 | } else { //backward search | 889 | } else { //backward search |
879 | int query = QMessageBox::information( searchDlg, "Find", | 890 | int query = QMessageBox::information( searchDlg, "Find", |
880 | "End of document reached.\nContinue from the beginning?", | 891 | "End of document reached.\nContinue from the beginning?", |
881 | "Yes", "No", "", 0,1); | 892 | "Yes", "No", "", 0,1); |
882 | if (query == 0){ | 893 | if (query == 0){ |
883 | QString string = Lview->textLine( Lview->numLines() - 1 ); | 894 | QString string = Lview->textLine( Lview->numLines() - 1 ); |
884 | line = Lview->numLines() - 1; | 895 | line = Lview->numLines() - 1; |
885 | lineCheck = line; | 896 | lineCheck = line; |
886 | col = string.length(); | 897 | col = string.length(); |
887 | last_search = -1; //BACKWARD; | 898 | last_search = -1; //BACKWARD; |
888 | goto again; | 899 | goto again; |
889 | } | 900 | } |
890 | } | 901 | } |
891 | } else { | 902 | } else { |
892 | 903 | ||
893 | //// emit CursorPositionChanged(); textLine | 904 | //// emit CursorPositionChanged(); textLine |
894 | } | 905 | } |
895 | } | 906 | } |
896 | 907 | ||
897 | int Gutenbrowser::doSearch( const QString &s_pattern , bool case_sensitive, bool forward, int line, int col ) { | 908 | int Gutenbrowser::doSearch( const QString &s_pattern , bool case_sensitive, bool forward, int line, int col ) { |
898 | int i, length; | 909 | int i, length; |
899 | int pos = -1; | 910 | int pos = -1; |
900 | if(forward) { | 911 | if(forward) { |
901 | QString string; | 912 | QString string; |
902 | for(i = line; i < Lview->numLines(); i++) { | 913 | for(i = line; i < Lview->numLines(); i++) { |
903 | 914 | ||
904 | string = Lview->textLine(i); | 915 | string = Lview->textLine(i); |
905 | pos = string.find(s_pattern, i == line ? col : 0, case_sensitive); | 916 | pos = string.find(s_pattern, i == line ? col : 0, case_sensitive); |
906 | if( pos != -1) { | 917 | if( pos != -1) { |
907 | int top = Lview->Top(); | 918 | int top = Lview->Top(); |
908 | length = s_pattern.length(); | 919 | length = s_pattern.length(); |
909 | if( i > Lview->lastRow() ) { | 920 | if( i > Lview->lastRow() ) { |
910 | // Lview->setCursorPosition(i,pos,FALSE); | 921 | // Lview->setCursorPosition(i,pos,FALSE); |
911 | for(int l = 0 ; l < length; l++) { | 922 | for(int l = 0 ; l < length; l++) { |
912 | Lview->cursorRight(TRUE); | 923 | Lview->cursorRight(TRUE); |
913 | } | 924 | } |
914 | // Lview->setCursorPosition( i , pos + length, TRUE ); | 925 | // Lview->setCursorPosition( i , pos + length, TRUE ); |
915 | int newTop = Lview->Top(); | 926 | int newTop = Lview->Top(); |
916 | if(Lview->lastRow() > i) | 927 | if(Lview->lastRow() > i) |
917 | Lview->ScrollUp( newTop - top); | 928 | Lview->ScrollUp( newTop - top); |
918 | // AdjustStatus(); | 929 | // AdjustStatus(); |
919 | } else { | 930 | } else { |
920 | // Lview->setCursorPosition(i,pos,FALSE); | 931 | // Lview->setCursorPosition(i,pos,FALSE); |
921 | for(int l = 0 ; l < length; l++) { | 932 | for(int l = 0 ; l < length; l++) { |
922 | Lview->cursorRight(TRUE); | 933 | Lview->cursorRight(TRUE); |
923 | } | 934 | } |
924 | // Lview->setCursorPosition( i , pos + length, TRUE ); | 935 | // Lview->setCursorPosition( i , pos + length, TRUE ); |
925 | // AdjustStatus(); | 936 | // AdjustStatus(); |
926 | } | 937 | } |
927 | pattern = s_pattern; | 938 | pattern = s_pattern; |
928 | last_search = 1; //FORWARD; | 939 | last_search = 1; //FORWARD; |
929 | return 1; | 940 | return 1; |
930 | } | 941 | } |
931 | } | 942 | } |
932 | } else { //////////////// searching backwards | 943 | } else { //////////////// searching backwards |
933 | QString string; | 944 | QString string; |
934 | for( i = line; i >= 0; i--) { | 945 | for( i = line; i >= 0; i--) { |
935 | string = Lview->textLine(i); | 946 | string = Lview->textLine(i); |
936 | int line_length = string.length(); | 947 | int line_length = string.length(); |
937 | pos = string.findRev(s_pattern, line == i ? col : line_length , case_sensitive); | 948 | pos = string.findRev(s_pattern, line == i ? col : line_length , case_sensitive); |
938 | if (pos != -1) { | 949 | if (pos != -1) { |
939 | // int top = Lview->Top(); | 950 | // int top = Lview->Top(); |
940 | length = s_pattern.length(); | 951 | length = s_pattern.length(); |
941 | if( i < Lview->Top() ) { | 952 | if( i < Lview->Top() ) { |
942 | Lview->ScrollDown( Lview->PageSize() ); | 953 | Lview->ScrollDown( Lview->PageSize() ); |
943 | Lview->MultiLine_Ex::pageUp( FALSE ); | 954 | Lview->MultiLine_Ex::pageUp( FALSE ); |
944 | if( ! (line == i && pos > col ) ) { | 955 | if( ! (line == i && pos > col ) ) { |
945 | // Lview->setCursorPosition( i ,pos ,FALSE ); | 956 | // Lview->setCursorPosition( i ,pos ,FALSE ); |
946 | for(int l = 0 ; l < length; l++) { | 957 | for(int l = 0 ; l < length; l++) { |
947 | Lview->cursorRight(TRUE); | 958 | Lview->cursorRight(TRUE); |
948 | } | 959 | } |
949 | // Lview->setCursorPosition(i ,pos + length ,TRUE ); | 960 | // Lview->setCursorPosition(i ,pos + length ,TRUE ); |
950 | // int newTop = Lview->Top(); | 961 | // int newTop = Lview->Top(); |
951 | /* if(useSplitter) Rview->ScrollUp( newTop - top); | 962 | /* if(useSplitter) Rview->ScrollUp( newTop - top); |
952 | */ } | 963 | */ } |
953 | } else { | 964 | } else { |
954 | if( ! (line == i && pos > col ) ) { | 965 | if( ! (line == i && pos > col ) ) { |
955 | // Lview->setCursorPosition( i, pos, FALSE ); | 966 | // Lview->setCursorPosition( i, pos, FALSE ); |
956 | for( int l = 0 ; l < length; l++) { | 967 | for( int l = 0 ; l < length; l++) { |
957 | Lview->cursorRight( TRUE); | 968 | Lview->cursorRight( TRUE); |
958 | } | 969 | } |
959 | // Lview->setCursorPosition( i, pos + length, TRUE ); | 970 | // Lview->setCursorPosition( i, pos + length, TRUE ); |
960 | } | 971 | } |
961 | pattern = s_pattern; | 972 | pattern = s_pattern; |
962 | last_search = -1; | 973 | last_search = -1; |
963 | return 1; | 974 | return 1; |
964 | } | 975 | } |
965 | } | 976 | } |
966 | } | 977 | } |
967 | } | 978 | } |
968 | return 0; | 979 | return 0; |
969 | } | 980 | } |
970 | 981 | ||
971 | void Gutenbrowser::LibraryBtn() { | 982 | void Gutenbrowser::LibraryBtn() { |
972 | 983 | ||
973 | QString newestLibraryFile ="pgwhole.zip"; | 984 | QString newestLibraryFile ="pgwhole.zip"; |
974 | QString zipFile; | 985 | QString zipFile; |
975 | // odebug << "Local Library is " << local_library << " " << oendl; | 986 | // odebug << "Local Library is " << local_library << " " << oendl; |
976 | zipFile="/usr/bin/unzip"; | 987 | zipFile="/usr/bin/unzip"; |
977 | // odebug << "newestLibraryFile is " << newestLibraryFile << " " << oendl; | 988 | // odebug << "newestLibraryFile is " << newestLibraryFile << " " << oendl; |
978 | if( QFile::exists( local_library+newestLibraryFile)) { | 989 | if( QFile::exists( local_library+newestLibraryFile)) { |
979 | if( QFile::exists(zipFile) ) { | 990 | if( QFile::exists(zipFile) ) { |
980 | UnZipIt(newestLibraryFile); | 991 | UnZipIt(newestLibraryFile); |
981 | } | 992 | } |
982 | else | 993 | else |
983 | QMessageBox::message( "Note",( tr("Please install unzip")) ); | 994 | QMessageBox::message( "Note",( tr("Please install unzip")) ); |
984 | } | 995 | } |
985 | // LibraryDlg = new LibraryDialog( this, "Library Index"); | 996 | // LibraryDlg = new LibraryDialog( this, "Library Index"); |
986 | LibraryDlg->setCaption( tr( "Gutenberg Library")); | 997 | LibraryDlg->setCaption( tr( "Gutenberg Library")); |
987 | Config config("Gutenbrowser"); | 998 | Config config("Gutenbrowser"); |
988 | config.setGroup("General"); | 999 | config.setGroup("General"); |
989 | 1000 | ||
990 | if(useSplitter) | 1001 | if(useSplitter) |
991 | LibraryDlg->useSmallInterface=FALSE; | 1002 | LibraryDlg->useSmallInterface=FALSE; |
992 | 1003 | ||
993 | LibraryDlg->showMaximized(); | 1004 | LibraryDlg->showMaximized(); |
994 | 1005 | ||
995 | if( LibraryDlg->exec() != 0 ) { | 1006 | if( LibraryDlg->exec() != 0 ) { |
996 | listItemNumber = LibraryDlg->DlglistItemNumber; | 1007 | listItemNumber = LibraryDlg->DlglistItemNumber; |
997 | listItemFile = LibraryDlg->DlglistItemFile; | 1008 | listItemFile = LibraryDlg->DlglistItemFile; |
998 | listItemYear = LibraryDlg->DlglistItemYear; | 1009 | listItemYear = LibraryDlg->DlglistItemYear; |
999 | listItemTitle = LibraryDlg->DlglistItemTitle; | 1010 | listItemTitle = LibraryDlg->DlglistItemTitle; |
1000 | file_name = LibraryDlg->File_Name; | 1011 | file_name = LibraryDlg->File_Name; |
1001 | // odebug << "title is being set as "+title << oendl; | 1012 | // odebug << "title is being set as "+title << oendl; |
1002 | title = listItemTitle; | 1013 | title = listItemTitle; |
1003 | 1014 | ||
1004 | // config.setGroup( "Proxy" ); | 1015 | // config.setGroup( "Proxy" ); |
1005 | // if( LibraryDlg->checked == 1) { | 1016 | // if( LibraryDlg->checked == 1) { |
1006 | // config.writeEntry("IsChecked", "TRUE"); | 1017 | // config.writeEntry("IsChecked", "TRUE"); |
1007 | // } else { | 1018 | // } else { |
1008 | // config.writeEntry("IsChecked", "FALSE"); | 1019 | // config.writeEntry("IsChecked", "FALSE"); |
1009 | // } | 1020 | // } |
1010 | // config.write(); | 1021 | // config.write(); |
1011 | // config.read(); | 1022 | // config.read(); |
1012 | if ( listItemNumber.isNull()) { | 1023 | if ( listItemNumber.isNull()) { |
1013 | } else { | 1024 | } else { |
1014 | i_pageNum = 1; | 1025 | i_pageNum = 1; |
1015 | if( file_name !="Error" && file_name.length() >2 && !file_name.isEmpty() ) { | 1026 | if( file_name !="Error" && file_name.length() >2 && !file_name.isEmpty() ) { |
1016 | //replace .zip with txt for opening it. | 1027 | //replace .zip with txt for opening it. |
1017 | // printf("\nFile name is now\n"); | 1028 | // printf("\nFile name is now\n"); |
1018 | // printf(file_name); | 1029 | // printf(file_name); |
1019 | // printf("\n"); | 1030 | // printf("\n"); |
1020 | // | 1031 | // |
1021 | if( file_name.find(".zip")) | 1032 | if( file_name.find(".zip")) |
1022 | { | 1033 | { |
1023 | odebug << "Found zip file\n" << oendl; | 1034 | odebug << "Found zip file\n" << oendl; |
1024 | // QStringList args; | 1035 | // QStringList args; |
1025 | // args="unzip"; | 1036 | // args="unzip"; |
1026 | // args+="-o"; | 1037 | // args+="-o"; |
1027 | // args+=local_library+file_name; | 1038 | // args+=local_library+file_name; |
1028 | // args+="-d"; | 1039 | // args+="-d"; |
1029 | // args+=local_library; | 1040 | // args+=local_library; |
1030 | QString cmd = "/usr/bin/unzip -o " + local_library+file_name + " -d " + local_library; | 1041 | QString cmd = "/usr/bin/unzip -o " + local_library+file_name + " -d " + local_library; |
1031 | odebug << "Issuing the command "+ cmd << oendl; | 1042 | odebug << "Issuing the command "+ cmd << oendl; |
1032 | // unzipProc=new QProcess( this, "unzipProc" ); /// fark that idea! | 1043 | // unzipProc=new QProcess( this, "unzipProc" ); /// fark that idea! |
1033 | // unzipProc->start(); | 1044 | // unzipProc->start(); |
1034 | system(cmd); | 1045 | system(cmd); |
1035 | remove( file_name); | 1046 | remove( file_name); |
1036 | 1047 | ||
1037 | } | 1048 | } |
1038 | // // | 1049 | // // |
1039 | // file_name = file_name.left(4)+ ".txt"; | 1050 | // file_name = file_name.left(4)+ ".txt"; |
1040 | if( LibraryDlg) | 1051 | if( LibraryDlg) |
1041 | delete LibraryDlg; | 1052 | delete LibraryDlg; |
1042 | setTitle(); | 1053 | setTitle(); |
1043 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1054 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1044 | if( !load( file_name)) return; | 1055 | if( !load( file_name)) return; |
1045 | } else { | 1056 | } else { |
1046 | printf("Not opening the file.\n"); | 1057 | printf("Not opening the file.\n"); |
1047 | } | 1058 | } |
1048 | } | 1059 | } |
1049 | } | 1060 | } |
1050 | if(showMainList) { | 1061 | if(showMainList) { |
1051 | if(!Lview->isHidden()) | 1062 | if(!Lview->isHidden()) |
1052 | Lview->hide(); | 1063 | Lview->hide(); |
1053 | qApp->processEvents(); | 1064 | qApp->processEvents(); |
1054 | showMainList=TRUE; | 1065 | showMainList=TRUE; |
1055 | if(mainList->isHidden()) | 1066 | if(mainList->isHidden()) |
1056 | mainList->show(); | 1067 | mainList->show(); |
1057 | fillWithTitles(); | 1068 | fillWithTitles(); |
1058 | qApp->processEvents(); | 1069 | qApp->processEvents(); |
1059 | } else | 1070 | } else |
1060 | setCentralWidget( Lview); | 1071 | setCentralWidget( Lview); |
1061 | // QPEApplication::grabKeyboard(); | 1072 | // QPEApplication::grabKeyboard(); |
1062 | // fixKeys(); | 1073 | // fixKeys(); |
1063 | } | 1074 | } |
1064 | 1075 | ||
1065 | void Gutenbrowser::OpenBtn() { | 1076 | void Gutenbrowser::OpenBtn() { |
1066 | QString s_temp; | 1077 | QString s_temp; |
1067 | s_temp = status; | 1078 | s_temp = status; |
1068 | OpenEtext* OpenDlg; | 1079 | OpenEtext* OpenDlg; |
1069 | OpenDlg = new OpenEtext(this,"OpenDlg"); | 1080 | OpenDlg = new OpenEtext(this,"OpenDlg"); |
1070 | OpenDlg->showMaximized(); | 1081 | OpenDlg->showMaximized(); |
1071 | 1082 | ||
1072 | if( OpenDlg->exec() != 0) { | 1083 | if( OpenDlg->exec() != 0) { |
1073 | title = OpenDlg->openFileTitle; | 1084 | title = OpenDlg->openFileTitle; |
1074 | odebug << "title open as "+title << oendl; | 1085 | odebug << "title open as "+title << oendl; |
1075 | file_name = OpenDlg->file; | 1086 | file_name = OpenDlg->file; |
1076 | i_pageNum = 1; | 1087 | i_pageNum = 1; |
1077 | 1088 | ||
1078 | if( !file_name.isEmpty() || file_name.length() > 2 ) { | 1089 | if( !file_name.isEmpty() || file_name.length() > 2 ) { |
1079 | if(showMainList) { | 1090 | if(showMainList) { |
1080 | showMainList=FALSE; | 1091 | showMainList=FALSE; |
1081 | odebug << "ShowMainList is now false" << oendl; | 1092 | odebug << "ShowMainList is now false" << oendl; |
1082 | mainList->hide(); | 1093 | mainList->hide(); |
1083 | Lview->show(); | 1094 | Lview->show(); |
1084 | qApp->processEvents(); | 1095 | qApp->processEvents(); |
1085 | } | 1096 | } |
1086 | Lview->clear(); | 1097 | Lview->clear(); |
1087 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1098 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1088 | if(!load(file_name)) return; | 1099 | if(!load(file_name)) return; |
1089 | } else { | 1100 | } else { |
1090 | odebug << "file_name is empty!" << oendl; | 1101 | odebug << "file_name is empty!" << oendl; |
1091 | if(showMainList) { | 1102 | if(showMainList) { |
1092 | if(!Lview->isHidden()) | 1103 | if(!Lview->isHidden()) |
1093 | Lview->hide(); | 1104 | Lview->hide(); |
1094 | qApp->processEvents(); | 1105 | qApp->processEvents(); |
1095 | if(mainList->isHidden()) | 1106 | if(mainList->isHidden()) |
1096 | mainList->show(); | 1107 | mainList->show(); |
1097 | fillWithTitles(); | 1108 | fillWithTitles(); |
1098 | qApp->processEvents(); | 1109 | qApp->processEvents(); |
1099 | } | 1110 | } |
1100 | 1111 | ||
1101 | } | 1112 | } |
1102 | } | 1113 | } |
1103 | if( OpenDlg) | 1114 | if( OpenDlg) |
1104 | delete OpenDlg; | 1115 | delete OpenDlg; |
1105 | /* | 1116 | /* |
1106 | Config config("Gutenbrowser"); | 1117 | Config config("Gutenbrowser"); |
1107 | config.setGroup( title); | 1118 | config.setGroup( title); |
1108 | file_name = config.readEntry("File Name", ""); | 1119 | file_name = config.readEntry("File Name", ""); |
1109 | i_pageNum = config.readNumEntry("Page Number", -1); | 1120 | i_pageNum = config.readNumEntry("Page Number", -1); |
1110 | int Bmrkrow = config.readNumEntry("LineNumber", -1); | 1121 | int Bmrkrow = config.readNumEntry("LineNumber", -1); |
1111 | if(Bmrkrow > -1) { | 1122 | if(Bmrkrow > -1) { |
1112 | if( Bmrkrow > Lview->topRow() ) { | 1123 | if( Bmrkrow > Lview->topRow() ) { |
1113 | Lview->setCursorPosition( Bmrkrow ,0, FALSE ); | 1124 | Lview->setCursorPosition( Bmrkrow ,0, FALSE ); |
1114 | Lview->ScrollUp( Bmrkrow - Lview->topRow() ); | 1125 | Lview->ScrollUp( Bmrkrow - Lview->topRow() ); |
1115 | // AdjustStatus(); | 1126 | // AdjustStatus(); |
1116 | } | 1127 | } |
1117 | else if( Bmrkrow < Lview->topRow() ) { | 1128 | else if( Bmrkrow < Lview->topRow() ) { |
1118 | Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE ); | 1129 | Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE ); |
1119 | Lview->ScrollDown( Lview->topRow() - Bmrkrow ); | 1130 | Lview->ScrollDown( Lview->topRow() - Bmrkrow ); |
1120 | // AdjustStatus(); | 1131 | // AdjustStatus(); |
1121 | } | 1132 | } |
1122 | } | 1133 | } |
1123 | */ | 1134 | */ |
1124 | // ResizeEdits(); | 1135 | // ResizeEdits(); |
1125 | 1136 | ||
1126 | } | 1137 | } |
1127 | 1138 | ||
1128 | void Gutenbrowser::ChangeFont() { | 1139 | void Gutenbrowser::ChangeFont() { |
1129 | #ifndef Q_WS_QWS | 1140 | #ifndef Q_WS_QWS |
1130 | bool ok; | 1141 | bool ok; |
1131 | 1142 | ||
1132 | weight= Lview->fontInfo().weight(); | 1143 | weight= Lview->fontInfo().weight(); |
1133 | italic = Lview->fontInfo().italic(); | 1144 | italic = Lview->fontInfo().italic(); |
1134 | bold=Lview->fontInfo().bold(); | 1145 | bold=Lview->fontInfo().bold(); |
1135 | pointSize= Lview->fontInfo().pointSize(); | 1146 | pointSize= Lview->fontInfo().pointSize(); |
1136 | fontStr=Lview->fontInfo().family(); | 1147 | fontStr=Lview->fontInfo().family(); |
1137 | 1148 | ||
1138 | if(italic == true) | 1149 | if(italic == true) |
1139 | italicStr="TRUE"; | 1150 | italicStr="TRUE"; |
1140 | else | 1151 | else |
1141 | italicStr="FALSE"; | 1152 | italicStr="FALSE"; |
1142 | 1153 | ||
1143 | QFont currentfont( fontStr, pointSize, weight, italic ); | 1154 | QFont currentfont( fontStr, pointSize, weight, italic ); |
1144 | 1155 | ||
1145 | if (ok) { | 1156 | if (ok) { |
1146 | QFontInfo fontInfo(font ); | 1157 | QFontInfo fontInfo(font ); |
1147 | fontStr=fontInfo.family(); | 1158 | fontStr=fontInfo.family(); |
1148 | 1159 | ||
1149 | pointSize= fontInfo.pointSize(); | 1160 | pointSize= fontInfo.pointSize(); |
1150 | 1161 | ||
1151 | font.setFontSize(pointSize); | 1162 | font.setFontSize(pointSize); |
1152 | 1163 | ||
1153 | pointSizeStr.setNum( pointSize); | 1164 | pointSizeStr.setNum( pointSize); |
1154 | 1165 | ||
1155 | weight= fontInfo.weight(); | 1166 | weight= fontInfo.weight(); |
1156 | weightStr.setNum( weight); | 1167 | weightStr.setNum( weight); |
1157 | italic =fontInfo.italic(); | 1168 | italic =fontInfo.italic(); |
1158 | bold=fontInfo.bold(); | 1169 | bold=fontInfo.bold(); |
1159 | 1170 | ||
1160 | if(italic == true) | 1171 | if(italic == true) |
1161 | italicStr="TRUE"; | 1172 | italicStr="TRUE"; |
1162 | else | 1173 | else |
1163 | italicStr="FALSE"; | 1174 | italicStr="FALSE"; |
1164 | if(bold == true) | 1175 | if(bold == true) |
1165 | boldStr="TRUE"; | 1176 | boldStr="TRUE"; |
1166 | else | 1177 | else |
1167 | boldStr="FALSE"; | 1178 | boldStr="FALSE"; |
1168 | 1179 | ||
1169 | pointSizeStr.setNum( pointSize); | 1180 | pointSizeStr.setNum( pointSize); |
1170 | config.setGroup( "Font" ); | 1181 | config.setGroup( "Font" ); |
1171 | config.writeEntry("Family", fontStr ); | 1182 | config.writeEntry("Family", fontStr ); |
1172 | config.writeEntry("Size", pointSizeStr ); | 1183 | config.writeEntry("Size", pointSizeStr ); |
1173 | config.writeEntry("Weight", weightStr ); | 1184 | config.writeEntry("Weight", weightStr ); |
1174 | config.writeEntry("Italic", italicStr ); | 1185 | config.writeEntry("Italic", italicStr ); |
1175 | config.writeEntry("Bold", boldStr ); | 1186 | config.writeEntry("Bold", boldStr ); |
1176 | // config.write(); | 1187 | // config.write(); |
1177 | 1188 | ||
1178 | Lview->setFont(font); | 1189 | Lview->setFont(font); |
1179 | 1190 | ||
1180 | QRect lRect; | 1191 | QRect lRect; |
1181 | QRect rRect; | 1192 | QRect rRect; |
1182 | lRect = Lview->rect(); | 1193 | lRect = Lview->rect(); |
1183 | if(useSplitter) { | 1194 | if(useSplitter) { |
1184 | } | 1195 | } |
1185 | // if(loadCheck) { | 1196 | // if(loadCheck) { |
1186 | // ResizeEdits(); | 1197 | // ResizeEdits(); |
1187 | // } | 1198 | // } |
1188 | update(); | 1199 | update(); |
1189 | } | 1200 | } |
1190 | #endif | 1201 | #endif |
1191 | } | 1202 | } |
1192 | 1203 | ||
1193 | 1204 | ||
1194 | /* | 1205 | /* |
1195 | performs dictionary look ups on the web */ | 1206 | performs dictionary look ups on the web */ |
1196 | void Gutenbrowser::LookupBtn() { | 1207 | void Gutenbrowser::LookupBtn() { |
1197 | QString text; | 1208 | QString text; |
1198 | if( Lview->hasSelectedText()) { | 1209 | if( Lview->hasSelectedText()) { |
1199 | Lview->copy(); | 1210 | Lview->copy(); |
1200 | } | 1211 | } |
1201 | QClipboard *cb = QApplication::clipboard(); | 1212 | QClipboard *cb = QApplication::clipboard(); |
1202 | text = cb->text(); | 1213 | text = cb->text(); |
1203 | int eexit=QMessageBox::information(this, | 1214 | int eexit=QMessageBox::information(this, |
1204 | "Note","Do you want to lookup\n\""+text+"\"\non websters web dictionary?", | 1215 | "Note","Do you want to lookup\n\""+text+"\"\non websters web dictionary?", |
1205 | QMessageBox::Yes, QMessageBox::No); | 1216 | QMessageBox::Yes, QMessageBox::No); |
1206 | if (eexit== 3) { | 1217 | if (eexit== 3) { |
1207 | // this link for sale!! | 1218 | // this link for sale!! |
1208 | qApp->processEvents(); | 1219 | qApp->processEvents(); |
1209 | goGetit( "http://www.m-w.com/cgi-bin/dictionary?" + text, true); | 1220 | goGetit( "http://www.m-w.com/cgi-bin/dictionary?" + text, true); |
1210 | } | 1221 | } |
1211 | } | 1222 | } |
1212 | 1223 | ||
1213 | void Gutenbrowser::ClearEdit() { | 1224 | void Gutenbrowser::ClearEdit() { |
1214 | Lview->setText(""); | 1225 | Lview->setText(""); |
1215 | loadCheck = false; | 1226 | loadCheck = false; |
1216 | status = ( tr("Gutenbrowser")); | 1227 | status = ( tr("Gutenbrowser")); |
1217 | InfoBar->setText( ""); | 1228 | InfoBar->setText( ""); |
1218 | setCaption( tr("Gutenbrowser")); | 1229 | setCaption( tr("Gutenbrowser")); |
1219 | i_pageNum = 0; | 1230 | i_pageNum = 0; |
1220 | enableButtons(false); | 1231 | enableButtons(false); |
1221 | 1232 | ||
1222 | if(!showMainList) { | 1233 | if(!showMainList) { |
1223 | Lview->hide(); | 1234 | Lview->hide(); |
1224 | showMainList=TRUE; | 1235 | showMainList=TRUE; |
1225 | mainList->show(); | 1236 | mainList->show(); |
1226 | fillWithTitles(); | 1237 | fillWithTitles(); |
1227 | qApp->processEvents(); | 1238 | qApp->processEvents(); |
1228 | } | 1239 | } |
1229 | if(donateMenu->idAt(3) != -1) | 1240 | if(donateMenu->idAt(3) != -1) |
1230 | donateMenu->removeItemAt(3); | 1241 | donateMenu->removeItemAt(3); |
1231 | } | 1242 | } |
1232 | 1243 | ||
1233 | 1244 | ||
1234 | bool Gutenbrowser::getTitle( const char *file ) { | 1245 | bool Gutenbrowser::getTitle( const char *file ) { |
1235 | QString s_file; | 1246 | QString s_file; |
1236 | QString filer = file; | 1247 | QString filer = file; |
1237 | if( filer.contains(local_library, TRUE)) { | 1248 | if( filer.contains(local_library, TRUE)) { |
1238 | QFileInfo f(file); | 1249 | QFileInfo f(file); |
1239 | s_file = f.fileName(); | 1250 | s_file = f.fileName(); |
1240 | } else { | 1251 | } else { |
1241 | s_file = filer; | 1252 | s_file = filer; |
1242 | } | 1253 | } |
1243 | Config config("Gutenbrowser"); | 1254 | Config config("Gutenbrowser"); |
1244 | config.setGroup( "Files" ); | 1255 | config.setGroup( "Files" ); |
1245 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 1256 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
1246 | int i_numofFiles = s_numofFiles.toInt(); | 1257 | int i_numofFiles = s_numofFiles.toInt(); |
1247 | 1258 | ||
1248 | for (int i = 1; i <= i_numofFiles; i++) { | 1259 | for (int i = 1; i <= i_numofFiles; i++) { |
1249 | QString temp; | 1260 | QString temp; |
1250 | temp.setNum(i); | 1261 | temp.setNum(i); |
1251 | QString ramble = config.readEntry(temp, "" ); | 1262 | QString ramble = config.readEntry(temp, "" ); |
1252 | 1263 | ||
1253 | if( strcmp(ramble, s_file) == 0) { | 1264 | if( strcmp(ramble, s_file) == 0) { |
1254 | config.setGroup( "Titles" ); | 1265 | config.setGroup( "Titles" ); |
1255 | title = config.readEntry(ramble, ""); | 1266 | title = config.readEntry(ramble, ""); |
1256 | // odebug << "(getTitle)title is being set as "+title << oendl; | 1267 | // odebug << "(getTitle)title is being set as "+title << oendl; |
1257 | } | 1268 | } |
1258 | } | 1269 | } |
1259 | return true; | 1270 | return true; |
1260 | } | 1271 | } |
1261 | 1272 | ||
1262 | void Gutenbrowser::searchdone_slot() { | 1273 | void Gutenbrowser::searchdone_slot() { |
1263 | // if (!searchDlg) | 1274 | // if (!searchDlg) |
1264 | // return; | 1275 | // return; |
1265 | // searchDlg->hide(); | 1276 | // searchDlg->hide(); |
1266 | // Lview->setFocus(); | 1277 | // Lview->setFocus(); |
1267 | this->setFocus(); | 1278 | this->setFocus(); |
1268 | last_search = 0; | 1279 | last_search = 0; |
1269 | // ResizeEdits(); | 1280 | // ResizeEdits(); |
1270 | } | 1281 | } |
1271 | 1282 | ||
1272 | /* | 1283 | /* |
1273 | sets the status message */ | 1284 | sets the status message */ |
1274 | bool Gutenbrowser::setStatus() { | 1285 | bool Gutenbrowser::setStatus() { |
1275 | 1286 | ||
1276 | #ifndef Q_WS_QWS | 1287 | #ifndef Q_WS_QWS |
1277 | QString s_pages; | 1288 | QString s_pages; |
1278 | s_pages.setNum( pages); | 1289 | s_pages.setNum( pages); |
1279 | QString chNum; | 1290 | QString chNum; |
1280 | statusTop = status.left( status.find(" ", TRUE) ); | 1291 | statusTop = status.left( status.find(" ", TRUE) ); |
1281 | status.append(chNum.setNum( i_pageNum)); | 1292 | status.append(chNum.setNum( i_pageNum)); |
1282 | status += " / " + s_pages; | 1293 | status += " / " + s_pages; |
1283 | 1294 | ||
1284 | if(loadCheck) { | 1295 | if(loadCheck) { |
1285 | statusBar->message( status); | 1296 | statusBar->message( status); |
1286 | InfoBar->setText( title); | 1297 | InfoBar->setText( title); |
1287 | } else { | 1298 | } else { |
1288 | } | 1299 | } |
1289 | #else | 1300 | #else |
1290 | QString msg; | 1301 | QString msg; |
1291 | msg.sprintf(title+" %d", i_pageNum); | 1302 | msg.sprintf(title+" %d", i_pageNum); |
1292 | setCaption( msg); | 1303 | setCaption( msg); |
1293 | #endif | 1304 | #endif |
1294 | return true; | 1305 | return true; |
1295 | } | 1306 | } |
1296 | 1307 | ||
1297 | void Gutenbrowser::keyReleaseEvent( QKeyEvent *e) { | 1308 | void Gutenbrowser::keyReleaseEvent( QKeyEvent *e) { |
1298 | switch ( e->key() ) { | 1309 | switch ( e->key() ) { |
1299 | 1310 | ||
1300 | case Key_M: | 1311 | case Key_M: |
1301 | // Bookmark(); | 1312 | // Bookmark(); |
1302 | break; | 1313 | break; |
1303 | case Key_D: | 1314 | case Key_D: |
1304 | DownloadIndex(); | 1315 | DownloadIndex(); |
1305 | break; | 1316 | break; |
1306 | case Key_L: | 1317 | case Key_L: |
1307 | LibraryBtn(); | 1318 | LibraryBtn(); |
1308 | break; | 1319 | break; |
1309 | case Key_O: | 1320 | case Key_O: |
1310 | OpenBtn(); | 1321 | OpenBtn(); |
1311 | break; | 1322 | break; |
1312 | case Key_F: | 1323 | case Key_F: |
1313 | ForwardBtn(); | 1324 | ForwardBtn(); |
1314 | break; | 1325 | break; |
1315 | case Key_B: | 1326 | case Key_B: |
1316 | BackBtn(); | 1327 | BackBtn(); |
1317 | break; | 1328 | break; |
1318 | case Key_P: | 1329 | case Key_P: |
1319 | PrintBtn(); | 1330 | PrintBtn(); |
1320 | break; | 1331 | break; |
1321 | case Key_S: | 1332 | case Key_S: |
1322 | SearchBtn(); | 1333 | SearchBtn(); |
1323 | break; | 1334 | break; |
1324 | case Key_E: | 1335 | case Key_E: |
1325 | ByeBye(); | 1336 | ByeBye(); |
1326 | break; | 1337 | break; |
1327 | case Key_R: | 1338 | case Key_R: |
1328 | // setBookmark(); | 1339 | // setBookmark(); |
1329 | break; | 1340 | break; |
1330 | case Key_T: | 1341 | case Key_T: |
1331 | ChangeFont(); | 1342 | ChangeFont(); |
1332 | break; | 1343 | break; |
1333 | case Key_C: | 1344 | case Key_C: |
1334 | ClearEdit(); | 1345 | ClearEdit(); |
1335 | break; | 1346 | break; |
1336 | case Key_H: | 1347 | case Key_H: |
1337 | HelpBtn(); | 1348 | HelpBtn(); |
1338 | break; | 1349 | break; |
1339 | case Key_K: | 1350 | case Key_K: |
1340 | LookupBtn(); | 1351 | LookupBtn(); |
1341 | break; | 1352 | break; |
1342 | case Key_U:// hide menu | 1353 | case Key_U:// hide menu |
1343 | if(menubar->isHidden() ) | 1354 | if(menubar->isHidden() ) |
1344 | menubar->show(); | 1355 | menubar->show(); |
1345 | else | 1356 | else |
1346 | menubar->hide(); | 1357 | menubar->hide(); |
1347 | break; | 1358 | break; |
1348 | case Key_I: | 1359 | case Key_I: |
1349 | hideButtons(); | 1360 | hideButtons(); |
1350 | break; | 1361 | break; |
1351 | ////////////////////////////// Zaurus keys | 1362 | ////////////////////////////// Zaurus keys |
1352 | case Key_Home: | 1363 | case Key_Home: |
1353 | // BeginBtn(); | 1364 | // BeginBtn(); |
1354 | break; | 1365 | break; |
1355 | case Key_F9: //activity | 1366 | case Key_F9: //activity |
1356 | OpenBtn(); | 1367 | OpenBtn(); |
1357 | break; | 1368 | break; |
1358 | case Key_F10: //contacts | 1369 | case Key_F10: //contacts |
1359 | hideButtons(); | 1370 | hideButtons(); |
1360 | break; | 1371 | break; |
1361 | case Key_F11: //menu | 1372 | case Key_F11: //menu |
1362 | if(menubar->isHidden() ) | 1373 | if(menubar->isHidden() ) |
1363 | menubar->show(); | 1374 | menubar->show(); |
1364 | else | 1375 | else |
1365 | menubar->hide(); | 1376 | menubar->hide(); |
1366 | break; | 1377 | break; |
1367 | case Key_F12: //home | 1378 | case Key_F12: //home |
1368 | BeginBtn(); | 1379 | BeginBtn(); |
1369 | break; | 1380 | break; |
1370 | case Key_F13: //mail | 1381 | case Key_F13: //mail |
1371 | LibraryBtn(); | 1382 | LibraryBtn(); |
1372 | break; | 1383 | break; |
1373 | case Key_Space: | 1384 | case Key_Space: |
1374 | if(loadCheck) | 1385 | if(loadCheck) |
1375 | ForwardBtn(); | 1386 | ForwardBtn(); |
1376 | // else | 1387 | // else |
1377 | // Bookmark(); | 1388 | // Bookmark(); |
1378 | break; | 1389 | break; |
1379 | case Key_Down: | 1390 | case Key_Down: |
1380 | if(loadCheck) { | 1391 | if(loadCheck) { |
1381 | // if( !e->isAutoRepeat() ) | 1392 | // if( !e->isAutoRepeat() ) |
1382 | // AdjustStatus(); | 1393 | // AdjustStatus(); |
1383 | // } else { | 1394 | // } else { |
1384 | // LibraryBtn(); | 1395 | // LibraryBtn(); |
1385 | // ForwardBtn(); | 1396 | // ForwardBtn(); |
1386 | } | 1397 | } |
1387 | 1398 | ||
1388 | // ForwardButton->setFocus(); | 1399 | // ForwardButton->setFocus(); |
1389 | // Lview->setFocus(); | 1400 | // Lview->setFocus(); |
1390 | // if(s_Wrap=="FALSE") | 1401 | // if(s_Wrap=="FALSE") |
1391 | // Lview->MultiLine_Ex::ScrollDown( 1); | 1402 | // Lview->MultiLine_Ex::ScrollDown( 1); |
1392 | // LibraryBtn(); | 1403 | // LibraryBtn(); |
1393 | break; | 1404 | break; |
1394 | case Key_Up: | 1405 | case Key_Up: |
1395 | if(loadCheck) { | 1406 | if(loadCheck) { |
1396 | // if( !e->isAutoRepeat() ) | 1407 | // if( !e->isAutoRepeat() ) |
1397 | // AdjustStatus(); | 1408 | // AdjustStatus(); |
1398 | // } else { | 1409 | // } else { |
1399 | // OpenBtn(); | 1410 | // OpenBtn(); |
1400 | // BackBtn(); | 1411 | // BackBtn(); |
1401 | } | 1412 | } |
1402 | // BackButton->setFocus(); | 1413 | // BackButton->setFocus(); |
1403 | // Lview->setFocus(); | 1414 | // Lview->setFocus(); |
1404 | // if(s_Wrap=="FALSE") | 1415 | // if(s_Wrap=="FALSE") |
1405 | // Lview->MultiLine_Ex::ScrollUp( 1); | 1416 | // Lview->MultiLine_Ex::ScrollUp( 1); |
1406 | 1417 | ||
1407 | // LibraryBtn(); | 1418 | // LibraryBtn(); |
1408 | break; | 1419 | break; |
1409 | case Key_Right: | 1420 | case Key_Right: |
1410 | ForwardButton->setFocus(); | 1421 | ForwardButton->setFocus(); |
1411 | ForwardBtn(); | 1422 | ForwardBtn(); |
1412 | // LibraryBtn(); | 1423 | // LibraryBtn(); |
1413 | break; | 1424 | break; |
1414 | case Key_Left: | 1425 | case Key_Left: |
1415 | BackBtn(); | 1426 | BackBtn(); |
1416 | BackButton->setFocus(); | 1427 | BackButton->setFocus(); |
1417 | // OpenBtn(); | 1428 | // OpenBtn(); |
1418 | break; | 1429 | break; |
1419 | case Key_Escape: | 1430 | case Key_Escape: |
1420 | ByeBye(); | 1431 | ByeBye(); |
1421 | break; | 1432 | break; |
1422 | case Key_PageUp: | 1433 | case Key_PageUp: |
1423 | BackBtn(); | 1434 | BackBtn(); |
1424 | break; | 1435 | break; |
1425 | case Key_PageDown: | 1436 | case Key_PageDown: |
1426 | ForwardBtn(); | 1437 | ForwardBtn(); |
1427 | break; | 1438 | break; |
1428 | 1439 | ||
1429 | ////////////////////////////// Zaurus keys | 1440 | ////////////////////////////// Zaurus keys |
1430 | }; | 1441 | }; |
1431 | } | 1442 | } |
1432 | 1443 | ||
1433 | void Gutenbrowser::keyPressEvent( QKeyEvent *e) { | 1444 | void Gutenbrowser::keyPressEvent( QKeyEvent *e) { |
1434 | switch ( e->key() ) { | 1445 | switch ( e->key() ) { |
1435 | // case Key_Next: | 1446 | // case Key_Next: |
1436 | // ForwardBtn(); | 1447 | // ForwardBtn(); |
1437 | // break; | 1448 | // break; |
1438 | // case Key_Prior: | 1449 | // case Key_Prior: |
1439 | // BackBtn(); | 1450 | // BackBtn(); |
1440 | // break; | 1451 | // break; |
1441 | // case Key_Space: | 1452 | // case Key_Space: |
1442 | // ForwardBtn(); | 1453 | // ForwardBtn(); |
1443 | // break; | 1454 | // break; |
1444 | // case Key_Down: | 1455 | // case Key_Down: |
1445 | // Lview->MultiLine_Ex::ScrollUp( 1); | 1456 | // Lview->MultiLine_Ex::ScrollUp( 1); |
1446 | // if(useSplitter) Rview->MultiLine_Ex::ScrollUp( 1); | 1457 | // if(useSplitter) Rview->MultiLine_Ex::ScrollUp( 1); |
1447 | // break; | 1458 | // break; |
1448 | // case Key_Up: | 1459 | // case Key_Up: |
1449 | // if( Lview->Top() != 0) { | 1460 | // if( Lview->Top() != 0) { |
1450 | // Lview->MultiLine_Ex::ScrollDown( 1); | 1461 | // Lview->MultiLine_Ex::ScrollDown( 1); |
1451 | // if(useSplitter) Rview->MultiLine_Ex::ScrollDown( 1); | 1462 | // if(useSplitter) Rview->MultiLine_Ex::ScrollDown( 1); |
1452 | // } | 1463 | // } |
1453 | // break; | 1464 | // break; |
1454 | } | 1465 | } |
1455 | } | 1466 | } |
1456 | 1467 | ||
1457 | void Gutenbrowser::resizeEvent( QResizeEvent *ev) { | 1468 | void Gutenbrowser::resizeEvent( QResizeEvent *ev) { |
1458 | // odebug << "resize: " << ev->size().width() << "," << ev->size().height() << "\n" << oendl; | 1469 | // odebug << "resize: " << ev->size().width() << "," << ev->size().height() << "\n" << oendl; |
1459 | 1470 | ||
1460 | if( !LibraryDlg->isHidden()) | 1471 | if( !LibraryDlg->isHidden()) |
1461 | LibraryDlg->resize(ev->size().width(),ev->size().height() ); | 1472 | LibraryDlg->resize(ev->size().width(),ev->size().height() ); |
1462 | 1473 | ||
1463 | // if( loadCheck == true) { | 1474 | // if( loadCheck == true) { |
1464 | // ResizeEdits(); | 1475 | // ResizeEdits(); |
1465 | // AdjustStatus(); | 1476 | // AdjustStatus(); |
1466 | // } | 1477 | // } |
1467 | } | 1478 | } |
1468 | 1479 | ||
1469 | 1480 | ||
1470 | void Gutenbrowser::doOptions() { | 1481 | void Gutenbrowser::doOptions() { |
1471 | optionsDialog* optDlg; | 1482 | optionsDialog* optDlg; |
1472 | optDlg = new optionsDialog( this,"Options_Dlg", true); | 1483 | optDlg = new optionsDialog( this,"Options_Dlg", true); |
1473 | QString Ddir; | 1484 | QString Ddir; |
1474 | Config config("Gutenbrowser"); | 1485 | Config config("Gutenbrowser"); |
1475 | config.setGroup( "General" ); | 1486 | config.setGroup( "General" ); |
1476 | QFont myFont; | 1487 | QFont myFont; |
1477 | optDlg->showMaximized(); | 1488 | optDlg->showMaximized(); |
1478 | 1489 | ||
1479 | if( optDlg->exec() !=0) { | 1490 | if( optDlg->exec() !=0) { |
1480 | qApp->processEvents(); | 1491 | qApp->processEvents(); |
1481 | brow=optDlg->browserName; | 1492 | brow=optDlg->browserName; |
1482 | toggleButtonIcons( optDlg->useIcon); | 1493 | toggleButtonIcons( optDlg->useIcon); |
1483 | ftp_host= optDlg->ftp_host; | 1494 | ftp_host= optDlg->ftp_host; |
1484 | ftp_base_dir= optDlg->ftp_base_dir; | 1495 | ftp_base_dir= optDlg->ftp_base_dir; |
1485 | brow=optDlg->browserName; | 1496 | brow=optDlg->browserName; |
1486 | Ddir=optDlg->downloadDirEdit->text(); | 1497 | Ddir=optDlg->downloadDirEdit->text(); |
1487 | 1498 | ||
1488 | odebug << "writing library config" << oendl; | 1499 | odebug << "writing library config" << oendl; |
1489 | Config config("Gutenbrowser"); | 1500 | Config config("Gutenbrowser"); |
1490 | config.setGroup("General"); | 1501 | config.setGroup("General"); |
1491 | 1502 | ||
1492 | QString dirname= optDlg->downloadDirEdit->text(); | 1503 | QString dirname= optDlg->downloadDirEdit->text(); |
1493 | if(dirname.right(1)!="/") | 1504 | if(dirname.right(1)!="/") |
1494 | dirname+="/"; | 1505 | dirname+="/"; |
1495 | config.writeEntry( "DownloadDirectory",dirname); | 1506 | config.writeEntry( "DownloadDirectory",dirname); |
1496 | QDir newDir( optDlg->downloadDirEdit->text()); | 1507 | QDir newDir( optDlg->downloadDirEdit->text()); |
1497 | 1508 | ||
1498 | if( !newDir.exists() ) { | 1509 | if( !newDir.exists() ) { |
1499 | int exit=QMessageBox::information(this, "Note", "Ok, to make a new directory\n"+Ddir+" ?", | 1510 | int exit=QMessageBox::information(this, "Note", "Ok, to make a new directory\n"+Ddir+" ?", |
1500 | QMessageBox::Ok, QMessageBox::Cancel); | 1511 | QMessageBox::Ok, QMessageBox::Cancel); |
1501 | if (exit==1) { | 1512 | if (exit==1) { |
1502 | QString cmd="mkdir -p "; | 1513 | QString cmd="mkdir -p "; |
1503 | cmd+=Ddir.latin1(); | 1514 | cmd+=Ddir.latin1(); |
1504 | system(cmd); | 1515 | system(cmd); |
1505 | odebug << "Making new dir "+cmd << oendl; | 1516 | odebug << "Making new dir "+cmd << oendl; |
1506 | if(Ddir.right(1)!="/") { | 1517 | if(Ddir.right(1)!="/") { |
1507 | Ddir+="/"; | 1518 | Ddir+="/"; |
1508 | } | 1519 | } |
1509 | config.writeEntry("DownloadDirectory",Ddir); | 1520 | config.writeEntry("DownloadDirectory",Ddir); |
1510 | } | 1521 | } |
1511 | } | 1522 | } |
1512 | 1523 | ||
1513 | // if(optDlg->styleChanged) | 1524 | // if(optDlg->styleChanged) |
1514 | // setStyle( optDlg->styleInt); | 1525 | // setStyle( optDlg->styleInt); |
1515 | if(optDlg->b_qExit==TRUE) | 1526 | if(optDlg->b_qExit==TRUE) |
1516 | b_queryExit=TRUE; | 1527 | b_queryExit=TRUE; |
1517 | else | 1528 | else |
1518 | b_queryExit=FALSE; | 1529 | b_queryExit=FALSE; |
1519 | 1530 | ||
1520 | if(optDlg->fontDlg-> changedFonts) { | 1531 | if(optDlg->fontDlg-> changedFonts) { |
1521 | odebug << "Setting font" << oendl; | 1532 | odebug << "Setting font" << oendl; |
1522 | myFont=optDlg->fontDlg->selectedFont; | 1533 | myFont=optDlg->fontDlg->selectedFont; |
1523 | Lview->setFont( myFont); | 1534 | Lview->setFont( myFont); |
1524 | } | 1535 | } |
1525 | 1536 | ||
1526 | if(optDlg->useWordWrap_CheckBox->isChecked() ) { | 1537 | if(optDlg->useWordWrap_CheckBox->isChecked() ) { |
1527 | odebug << "WORD WRAP is set" << oendl; | 1538 | odebug << "WORD WRAP is set" << oendl; |
1528 | Lview->setWordWrap(QMultiLineEdit::WidgetWidth); | 1539 | Lview->setWordWrap(QMultiLineEdit::WidgetWidth); |
1529 | useWrap=true; | 1540 | useWrap=true; |
1530 | } else { | 1541 | } else { |
1531 | odebug << "Word wrap is NOT set" << oendl; | 1542 | odebug << "Word wrap is NOT set" << oendl; |
1532 | Lview->setWordWrap(QMultiLineEdit::NoWrap); | 1543 | Lview->setWordWrap(QMultiLineEdit::NoWrap); |
1533 | useWrap=false; | 1544 | useWrap=false; |
1534 | } | 1545 | } |
1535 | } | 1546 | } |
1536 | if(showMainList) { | 1547 | if(showMainList) { |
1537 | if(!Lview->isHidden()) | 1548 | if(!Lview->isHidden()) |
1538 | Lview->hide(); | 1549 | Lview->hide(); |
1539 | qApp->processEvents(); | 1550 | qApp->processEvents(); |
1540 | if(mainList->isHidden()) | 1551 | if(mainList->isHidden()) |
1541 | mainList->show(); | 1552 | mainList->show(); |
1542 | fillWithTitles(); | 1553 | fillWithTitles(); |
1543 | } else { | 1554 | } else { |
1544 | Lview->show(); | 1555 | Lview->show(); |
1545 | showMainList=FALSE; | 1556 | showMainList=FALSE; |
1546 | mainList->hide(); | 1557 | mainList->hide(); |
1547 | } | 1558 | } |
1548 | qApp->processEvents(); | 1559 | qApp->processEvents(); |
1549 | update(); | 1560 | update(); |
1550 | } | 1561 | } |
1551 | 1562 | ||
1552 | bool Gutenbrowser::setTitle() { | 1563 | bool Gutenbrowser::setTitle() { |
1553 | if( file_name.contains( local_library)) { | 1564 | if( file_name.contains( local_library)) { |
1554 | QFileInfo f( file_name); | 1565 | QFileInfo f( file_name); |
1555 | QString s_file = f.fileName(); | 1566 | QString s_file = f.fileName(); |
1556 | file_name = s_file; | 1567 | file_name = s_file; |
1557 | } | 1568 | } |
1558 | 1569 | ||
1559 | int test = 0; | 1570 | int test = 0; |
1560 | Config config("Gutenbrowser"); | 1571 | Config config("Gutenbrowser"); |
1561 | config.setGroup( "Files" ); | 1572 | config.setGroup( "Files" ); |
1562 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 1573 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
1563 | int i_numofFiles = s_numofFiles.toInt(); | 1574 | int i_numofFiles = s_numofFiles.toInt(); |
1564 | 1575 | ||
1565 | for (int i = 1; i <= i_numofFiles; i++) { | 1576 | for (int i = 1; i <= i_numofFiles; i++) { |
1566 | QString temp; | 1577 | QString temp; |
1567 | temp.setNum(i); | 1578 | temp.setNum(i); |
1568 | QString ramble = config.readEntry(temp, "" ); | 1579 | QString ramble = config.readEntry(temp, "" ); |
1569 | 1580 | ||
1570 | if( strcmp(ramble, file_name) == 0) { | 1581 | if( strcmp(ramble, file_name) == 0) { |
1571 | test = 1; | 1582 | test = 1; |
1572 | } | 1583 | } |
1573 | } | 1584 | } |
1574 | if (test == 0) { | 1585 | if (test == 0) { |
1575 | config.writeEntry("NumberOfFiles",i_numofFiles +1 ); | 1586 | config.writeEntry("NumberOfFiles",i_numofFiles +1 ); |
1576 | QString interger; | 1587 | QString interger; |
1577 | interger.setNum( i_numofFiles +1); | 1588 | interger.setNum( i_numofFiles +1); |
1578 | config.writeEntry(interger, file_name); | 1589 | config.writeEntry(interger, file_name); |
1579 | 1590 | ||
1580 | config.setGroup( "Titles" ); | 1591 | config.setGroup( "Titles" ); |
1581 | config.writeEntry(file_name,listItemTitle); | 1592 | config.writeEntry(file_name,listItemTitle); |
1582 | } | 1593 | } |
1583 | test = 0; | 1594 | test = 0; |
1584 | // config.write(); | 1595 | // config.write(); |
1585 | return true; | 1596 | return true; |
1586 | } | 1597 | } |
1587 | /*Calls new fangled network dialog */ | 1598 | /*Calls new fangled network dialog */ |
1588 | void Gutenbrowser::OnNetworkDialog( const QString &/*networkUrl*/, const QString &/*output*/) | 1599 | void Gutenbrowser::OnNetworkDialog( const QString &/*networkUrl*/, const QString &/*output*/) |
1589 | { | 1600 | { |
1590 | // odebug << networkUrl << oendl; | 1601 | // odebug << networkUrl << oendl; |
1591 | // odebug << output << oendl; | 1602 | // odebug << output << oendl; |
1592 | // #ifndef Q_WS_QWS | 1603 | // #ifndef Q_WS_QWS |
1593 | // NetworkDialog *NetworkDlg; | 1604 | // NetworkDialog *NetworkDlg; |
1594 | // if( networkUrl.length() < 4 ) networkUrl= "http://sailor.gutenberg.org/mirror.sites.html"; | 1605 | // if( networkUrl.length() < 4 ) networkUrl= "http://sailor.gutenberg.org/mirror.sites.html"; |
1595 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, output); | 1606 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, output); |
1596 | // if( NetworkDlg->exec() != 0 ) { | 1607 | // if( NetworkDlg->exec() != 0 ) { |
1597 | // } | 1608 | // } |
1598 | // if(NetworkDlg) | 1609 | // if(NetworkDlg) |
1599 | // delete NetworkDlg; | 1610 | // delete NetworkDlg; |
1600 | // #endif | 1611 | // #endif |
1601 | } | 1612 | } |
1602 | 1613 | ||
1603 | void Gutenbrowser::donateGutenberg() | 1614 | void Gutenbrowser::donateGutenberg() |
1604 | { | 1615 | { |
1605 | int exit=QMessageBox::information(this, "Info", "http://www.gutenberg.org\ndonate@gutenberg.net", | 1616 | int exit=QMessageBox::information(this, "Info", "http://www.gutenberg.org\ndonate@gutenberg.net", |
1606 | QMessageBox::Ok, QMessageBox::Cancel); | 1617 | QMessageBox::Ok, QMessageBox::Cancel); |
1607 | 1618 | ||
1608 | if (exit==1) { | 1619 | if (exit==1) { |
1609 | } else { | 1620 | } else { |
1610 | }; | 1621 | }; |
1611 | } | 1622 | } |
1612 | 1623 | ||
1613 | void Gutenbrowser::donateByteMonkie() | 1624 | void Gutenbrowser::donateByteMonkie() |
1614 | { | 1625 | { |
1615 | } | 1626 | } |
1616 | 1627 | ||
1617 | void Gutenbrowser::writeConfig() | 1628 | void Gutenbrowser::writeConfig() |
1618 | { | 1629 | { |
1619 | // config.read(); | 1630 | // config.read(); |
1620 | // Config config("Gutenbrowser"); | 1631 | // Config config("Gutenbrowser"); |
1621 | // #ifndef Q_WS_QWS | 1632 | // #ifndef Q_WS_QWS |
1622 | // config.setGroup( "Geometry" ); | 1633 | // config.setGroup( "Geometry" ); |
1623 | // QString s; | 1634 | // QString s; |
1624 | // QString globalPosition; | 1635 | // QString globalPosition; |
1625 | // QPoint point; | 1636 | // QPoint point; |
1626 | // point=mapToGlobal(QPoint(0,0) ); | 1637 | // point=mapToGlobal(QPoint(0,0) ); |
1627 | // int posiX, posiY; | 1638 | // int posiX, posiY; |
1628 | // posiX=point.x(); | 1639 | // posiX=point.x(); |
1629 | // posiY=point.y(); | 1640 | // posiY=point.y(); |
1630 | // globalPosition.sprintf("%i,%i", posiX, posiY); | 1641 | // globalPosition.sprintf("%i,%i", posiX, posiY); |
1631 | 1642 | ||
1632 | // QRect frameRect; | 1643 | // QRect frameRect; |
1633 | // frameRect = geometry(); | 1644 | // frameRect = geometry(); |
1634 | // s.sprintf("%i,%i", frameRect.width(), frameRect.height()); | 1645 | // s.sprintf("%i,%i", frameRect.width(), frameRect.height()); |
1635 | // config.writeEntry("Frame", s); | 1646 | // config.writeEntry("Frame", s); |
1636 | // config.writeEntry("Position", globalPosition); | 1647 | // config.writeEntry("Position", globalPosition); |
1637 | 1648 | ||
1638 | // if( useIcons==TRUE) | 1649 | // if( useIcons==TRUE) |
1639 | // config.writeEntry("Icons", "TRUE"); | 1650 | // config.writeEntry("Icons", "TRUE"); |
1640 | // else | 1651 | // else |
1641 | // config.writeEntry("Icons", "FALSE"); | 1652 | // config.writeEntry("Icons", "FALSE"); |
1642 | // #endif | 1653 | // #endif |
1643 | 1654 | ||
1644 | // #ifndef Q_WS_QWS | 1655 | // #ifndef Q_WS_QWS |
1645 | // QString temp; | 1656 | // QString temp; |
1646 | // temp.setNum(styleI, 10); | 1657 | // temp.setNum(styleI, 10); |
1647 | // config.setGroup( "StyleIze" ); | 1658 | // config.setGroup( "StyleIze" ); |
1648 | // config.writeEntry( "Style", temp); | 1659 | // config.writeEntry( "Style", temp); |
1649 | // #endif | 1660 | // #endif |
1650 | 1661 | ||
1651 | // config.setGroup("General"); | 1662 | // config.setGroup("General"); |
1652 | } | 1663 | } |
1653 | 1664 | ||
1654 | void Gutenbrowser::annotations() | 1665 | void Gutenbrowser::annotations() |
1655 | { | 1666 | { |
1656 | // #ifndef Q_WS_QWS | 1667 | // #ifndef Q_WS_QWS |
1657 | // QMessageBox::message("Note","hi annotate"); | 1668 | // QMessageBox::message("Note","hi annotate"); |
1658 | // lastBmkButton->setDown(FALSE); | 1669 | // lastBmkButton->setDown(FALSE); |
1659 | // #endif | 1670 | // #endif |
1660 | } | 1671 | } |
1661 | 1672 | ||
1662 | void Gutenbrowser::hideButtons() | 1673 | void Gutenbrowser::hideButtons() |
1663 | { | 1674 | { |
1664 | 1675 | ||
1665 | if( !buttonsHidden) { | 1676 | if( !buttonsHidden) { |
1666 | buttonsHidden=TRUE; | 1677 | buttonsHidden=TRUE; |
1667 | LibraryButton->hide(); | 1678 | LibraryButton->hide(); |
1668 | SearchButton->hide(); | 1679 | SearchButton->hide(); |
1669 | InfoBar->hide(); | 1680 | InfoBar->hide(); |
1670 | OpenButton->hide(); | 1681 | OpenButton->hide(); |
1671 | BackButton->hide(); | 1682 | BackButton->hide(); |
1672 | ForwardButton->hide(); | 1683 | ForwardButton->hide(); |
1673 | setBookmarkButton->hide(); | 1684 | setBookmarkButton->hide(); |
1674 | lastBmkButton->hide(); | 1685 | lastBmkButton->hide(); |
1675 | dictionaryButton->hide(); | 1686 | dictionaryButton->hide(); |
1676 | if(useSplitter) { | 1687 | if(useSplitter) { |
1677 | ClearButton->hide(); | 1688 | ClearButton->hide(); |
1678 | PrintButton->hide(); | 1689 | PrintButton->hide(); |
1679 | beginButton->hide(); | 1690 | beginButton->hide(); |
1680 | HelpButton->hide(); | 1691 | HelpButton->hide(); |
1681 | FontButton->hide(); | 1692 | FontButton->hide(); |
1682 | ExitButton->hide(); | 1693 | ExitButton->hide(); |
1683 | OptionsButton->hide(); | 1694 | OptionsButton->hide(); |
1684 | DownloadButton->hide(); | 1695 | DownloadButton->hide(); |
1685 | } | 1696 | } |
1686 | } else { | 1697 | } else { |
1687 | buttonsHidden=FALSE; | 1698 | buttonsHidden=FALSE; |
1688 | 1699 | ||
1689 | LibraryButton->show(); | 1700 | LibraryButton->show(); |
1690 | SearchButton->show(); | 1701 | SearchButton->show(); |
1691 | InfoBar->show(); | 1702 | InfoBar->show(); |
1692 | OpenButton->show(); | 1703 | OpenButton->show(); |
1693 | BackButton->show(); | 1704 | BackButton->show(); |
1694 | ForwardButton->show(); | 1705 | ForwardButton->show(); |
1695 | setBookmarkButton->show(); | 1706 | setBookmarkButton->show(); |
1696 | lastBmkButton->show(); | 1707 | lastBmkButton->show(); |
1697 | dictionaryButton->show(); | 1708 | dictionaryButton->show(); |
1698 | if(useSplitter) { | 1709 | if(useSplitter) { |
1699 | ClearButton->show(); | 1710 | ClearButton->show(); |
1700 | PrintButton->show(); | 1711 | PrintButton->show(); |
1701 | beginButton->show(); | 1712 | beginButton->show(); |
1702 | HelpButton->show(); | 1713 | HelpButton->show(); |
1703 | FontButton->show(); | 1714 | FontButton->show(); |
1704 | ExitButton->show(); | 1715 | ExitButton->show(); |
1705 | OptionsButton->show(); | 1716 | OptionsButton->show(); |
1706 | DownloadButton->show(); | 1717 | DownloadButton->show(); |
1707 | } | 1718 | } |
1708 | } | 1719 | } |
1709 | } | 1720 | } |
1710 | 1721 | ||
1711 | void Gutenbrowser::focusInEvent( QFocusEvent* ) | 1722 | void Gutenbrowser::focusInEvent( QFocusEvent* ) |
1712 | { | 1723 | { |
1713 | } | 1724 | } |
1714 | void Gutenbrowser::focusOutEvent( QFocusEvent* ) | 1725 | void Gutenbrowser::focusOutEvent( QFocusEvent* ) |
1715 | { | 1726 | { |
1716 | } | 1727 | } |
1717 | 1728 | ||
1718 | void Gutenbrowser::cleanUp( ) | 1729 | void Gutenbrowser::cleanUp( ) |
1719 | { | 1730 | { |
1720 | writeConfig(); | 1731 | writeConfig(); |
1721 | QPEApplication::grabKeyboard(); | 1732 | QPEApplication::grabKeyboard(); |
1722 | 1733 | ||
1723 | QPEApplication::ungrabKeyboard(); | 1734 | QPEApplication::ungrabKeyboard(); |
1724 | // odebug << "Cleanup" << oendl; | 1735 | // odebug << "Cleanup" << oendl; |
1725 | if(f.isOpen()) f.close(); | 1736 | if(f.isOpen()) f.close(); |
1726 | } | 1737 | } |
1727 | 1738 | ||
1728 | void Gutenbrowser::fixKeys() | 1739 | void Gutenbrowser::fixKeys() |
1729 | { | 1740 | { |
1730 | odebug << "Attempting to fix keys" << oendl; | 1741 | odebug << "Attempting to fix keys" << oendl; |
1731 | 1742 | ||
1732 | } | 1743 | } |
1733 | 1744 | ||
1734 | void Gutenbrowser::enableButtons(bool b) | 1745 | void Gutenbrowser::enableButtons(bool b) |
1735 | { | 1746 | { |
1736 | BackButton->setEnabled(b); | 1747 | BackButton->setEnabled(b); |
1737 | ForwardButton->setEnabled(b); | 1748 | ForwardButton->setEnabled(b); |
1738 | SearchButton->setEnabled(b); | 1749 | SearchButton->setEnabled(b); |
1739 | setBookmarkButton->setEnabled(b); | 1750 | setBookmarkButton->setEnabled(b); |
1740 | dictionaryButton->setEnabled(b); | 1751 | dictionaryButton->setEnabled(b); |
1741 | InfoBar->setEnabled(b); | 1752 | InfoBar->setEnabled(b); |
1742 | 1753 | ||
1743 | editMenu->setItemEnabled( -5, b); | 1754 | editMenu->setItemEnabled( -5, b); |
1744 | editMenu->setItemEnabled( -6, b); | 1755 | editMenu->setItemEnabled( -6, b); |
1745 | editMenu->setItemEnabled( -7, b); | 1756 | editMenu->setItemEnabled( -7, b); |
1746 | editMenu->setItemEnabled( -8, b); | 1757 | editMenu->setItemEnabled( -8, b); |
1747 | 1758 | ||
1748 | } | 1759 | } |
1749 | 1760 | ||
1750 | void Gutenbrowser::fillWithTitles() { | 1761 | void Gutenbrowser::fillWithTitles() { |
1751 | Config config("Gutenbrowser"); | 1762 | Config config("Gutenbrowser"); |
1752 | config.setGroup( "Files" ); | 1763 | config.setGroup( "Files" ); |
1753 | int i_numofFiles = config.readNumEntry("NumberOfFiles", 0); | 1764 | int i_numofFiles = config.readNumEntry("NumberOfFiles", 0); |
1754 | mainList->clear(); | 1765 | mainList->clear(); |
1755 | QString temp; | 1766 | QString temp; |
1756 | for (int i = 1; i <= i_numofFiles; i++) { | 1767 | for (int i = 1; i <= i_numofFiles; i++) { |
1757 | temp.setNum(i); | 1768 | temp.setNum(i); |
1758 | config.setGroup( "Files" ); | 1769 | config.setGroup( "Files" ); |
1759 | QString ramble = config.readEntry(temp, "" ); | 1770 | QString ramble = config.readEntry(temp, "" ); |
1760 | config.setGroup( "Titles" ); | 1771 | config.setGroup( "Titles" ); |
1761 | temp = config.readEntry(ramble, ""); | 1772 | temp = config.readEntry(ramble, ""); |
1762 | if( !temp.isEmpty()) { | 1773 | if( !temp.isEmpty()) { |
1763 | mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), temp, -1); | 1774 | mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), temp, -1); |
1764 | } | 1775 | } |
1765 | } | 1776 | } |
1766 | } | 1777 | } |
1767 | 1778 | ||
1768 | void Gutenbrowser::listClickedSlot( QListBoxItem * index) { | 1779 | void Gutenbrowser::listClickedSlot( QListBoxItem * index) { |
1769 | // if( !working) { | 1780 | // if( !working) { |
1770 | // working=true; | 1781 | // working=true; |
1771 | if(index) { | 1782 | if(index) { |
1772 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1783 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1773 | title = index->text(); | 1784 | title = index->text(); |
1774 | showMainList=FALSE; | 1785 | showMainList=FALSE; |
1775 | mainList->hide(); | 1786 | mainList->hide(); |
1776 | Lview->show(); | 1787 | Lview->show(); |
1777 | qApp->processEvents(); | 1788 | qApp->processEvents(); |
1778 | QString temp; | 1789 | QString temp; |
1779 | temp.setNum( mainList->currentItem() + 1); | 1790 | temp.setNum( mainList->currentItem() + 1); |
1780 | // openFileTitle = title; | 1791 | // openFileTitle = title; |
1781 | Config config("Gutenbrowser"); | 1792 | Config config("Gutenbrowser"); |
1782 | config.setGroup( "Files" ); | 1793 | config.setGroup( "Files" ); |
1783 | QString file = config.readEntry(temp, ""); | 1794 | QString file = config.readEntry(temp, ""); |
1784 | odebug << "About to load" << oendl; | 1795 | odebug << "About to load" << oendl; |
1785 | if( Lview->isVisible()) | 1796 | if( Lview->isVisible()) |
1786 | if(!load(file)) return; | 1797 | if(!load(file)) return; |
1787 | 1798 | ||
1788 | config.setGroup( title); | 1799 | config.setGroup( title); |
1789 | file_name = config.readEntry("File Name", ""); | 1800 | file_name = config.readEntry("File Name", ""); |
1790 | i_pageNum = config.readNumEntry("Page Number", 1); | 1801 | i_pageNum = config.readNumEntry("Page Number", 1); |
1791 | int Bmrkrow = config.readNumEntry("LineNumber", -1); | 1802 | int Bmrkrow = config.readNumEntry("LineNumber", -1); |
1792 | if(Bmrkrow > -1) { | 1803 | if(Bmrkrow > -1) { |
1793 | if( Bmrkrow > Lview->topRow() ) { | 1804 | if( Bmrkrow > Lview->topRow() ) { |
1794 | // Lview->setCursorPosition( Bmrkrow /* - Lview->topRow() */,0, FALSE ); | 1805 | // Lview->setCursorPosition( Bmrkrow /* - Lview->topRow() */,0, FALSE ); |
1795 | Lview->ScrollUp( Bmrkrow - Lview->topRow() ); | 1806 | Lview->ScrollUp( Bmrkrow - Lview->topRow() ); |
1796 | // AdjustStatus(); | 1807 | // AdjustStatus(); |
1797 | } | 1808 | } |
1798 | else if( Bmrkrow < Lview->topRow() ) { | 1809 | else if( Bmrkrow < Lview->topRow() ) { |
1799 | // Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE ); | 1810 | // Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE ); |
1800 | Lview->ScrollDown( Lview->topRow() - Bmrkrow ); | 1811 | Lview->ScrollDown( Lview->topRow() - Bmrkrow ); |
1801 | // AdjustStatus(); | 1812 | // AdjustStatus(); |
1802 | } | 1813 | } |
1803 | } | 1814 | } |
1804 | } | 1815 | } |
1805 | } | 1816 | } |
1806 | 1817 | ||
1807 | void Gutenbrowser::infoGutenbrowser() { | 1818 | void Gutenbrowser::infoGutenbrowser() { |
1808 | QMessageBox::message("Info","Gutenbrowser was developed by\n" | 1819 | QMessageBox::message("Info","Gutenbrowser was developed by\n" |
1809 | "Lorn Potter\n" | 1820 | "Lorn Potter\n" |
1810 | "ljp<ljp@llornkcor.com>\n"); | 1821 | "ljp<ljp@llornkcor.com>\n"); |
1811 | } | 1822 | } |
1812 | 1823 | ||
1813 | void Gutenbrowser::setDocument(const QString & frozenBoogers) { | 1824 | void Gutenbrowser::setDocument(const QString & frozenBoogers) { |
1814 | // this->hide(); | 1825 | // this->hide(); |
1815 | qWarning("\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXSET DOCUMENT\n"); | 1826 | qWarning("\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXSET DOCUMENT\n"); |
1816 | if(showMainList) { | 1827 | if(showMainList) { |
1817 | showMainList=FALSE; | 1828 | showMainList=FALSE; |
1818 | if(!mainList->isHidden()) | 1829 | if(!mainList->isHidden()) |
1819 | mainList->hide(); | 1830 | mainList->hide(); |
1820 | if(Lview->isHidden()) | 1831 | if(Lview->isHidden()) |
1821 | Lview->show(); | 1832 | Lview->show(); |
1822 | qApp->processEvents(); | 1833 | qApp->processEvents(); |
1823 | } | 1834 | } |
1824 | DocLnk lnk; | 1835 | DocLnk lnk; |
1825 | lnk = DocLnk(frozenBoogers); | 1836 | lnk = DocLnk(frozenBoogers); |
1826 | qWarning("open "+frozenBoogers); | 1837 | qWarning("open "+frozenBoogers); |
1827 | // odebug << lnk.file() << oendl; | 1838 | // odebug << lnk.file() << oendl; |
1828 | title=lnk.comment(); | 1839 | title=lnk.comment(); |
1829 | if(!load( lnk.file())) return; | 1840 | if(!load( lnk.file())) return; |
1830 | this->show(); | 1841 | this->show(); |
1831 | // odebug << title << oendl; | 1842 | // odebug << title << oendl; |
1832 | // qApp->processEvents(); | 1843 | // qApp->processEvents(); |
1833 | // repaint(); | 1844 | // repaint(); |
1834 | } | 1845 | } |
1835 | 1846 | ||
1836 | void Gutenbrowser::mainListPressed(int mouse, QListBoxItem * , const QPoint & ) | 1847 | void Gutenbrowser::mainListPressed(int mouse, QListBoxItem * , const QPoint & ) |
1837 | { | 1848 | { |
1838 | switch (mouse) { | 1849 | switch (mouse) { |
1839 | case 1: | 1850 | case 1: |
1840 | break; | 1851 | break; |
1841 | case 2: { | 1852 | case 2: { |
1842 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 1853 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
1843 | m.insertItem( tr( "Open" ), this, SLOT( menuOpen() )); | 1854 | m.insertItem( tr( "Open" ), this, SLOT( menuOpen() )); |
1844 | m.insertSeparator(); | 1855 | m.insertSeparator(); |
1845 | m.insertItem( tr( "Search google.com" ), this, SLOT( menuGoogle())); | 1856 | m.insertItem( tr( "Search google.com" ), this, SLOT( menuGoogle())); |
1846 | m.insertItem( tr( "Edit Title" ), this, SLOT( menuEditTitle())); | 1857 | m.insertItem( tr( "Edit Title" ), this, SLOT( menuEditTitle())); |
1847 | // m.insertSeparator(); | 1858 | // m.insertSeparator(); |
1848 | // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 1859 | // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
1849 | m.exec( QCursor::pos() ); | 1860 | m.exec( QCursor::pos() ); |
1850 | } | 1861 | } |
1851 | break; | 1862 | break; |
1852 | }; | 1863 | }; |
1853 | } | 1864 | } |
1854 | 1865 | ||
1855 | void Gutenbrowser::menuOpen() { | 1866 | void Gutenbrowser::menuOpen() { |
1856 | listClickedSlot( mainList->item( mainList->currentItem())); | 1867 | listClickedSlot( mainList->item( mainList->currentItem())); |
1857 | } | 1868 | } |
1858 | 1869 | ||
1859 | void Gutenbrowser::menuGoogle() { | 1870 | void Gutenbrowser::menuGoogle() { |
1860 | searchGoogle( mainList->text(mainList->currentItem())); | 1871 | searchGoogle( mainList->text(mainList->currentItem())); |
1861 | } | 1872 | } |
1862 | 1873 | ||
1863 | void Gutenbrowser::searchGoogle( const QString &tempText) { | 1874 | void Gutenbrowser::searchGoogle( const QString &tempText) { |
1864 | QString text = tempText; | 1875 | QString text = tempText; |
1865 | 1876 | ||
1866 | int eexit=QMessageBox::information(this, "Note","Do you want to search for\n"+text+ | 1877 | int eexit=QMessageBox::information(this, "Note","Do you want to search for\n"+text+ |
1867 | "\non google.com?",QMessageBox::Yes, QMessageBox::No); | 1878 | "\non google.com?",QMessageBox::Yes, QMessageBox::No); |
1868 | if (eexit== 3) { | 1879 | if (eexit== 3) { |
1869 | qApp->processEvents(); | 1880 | qApp->processEvents(); |
1870 | text.replace( QRegExp("\\s"), "%20"); | 1881 | text.replace( QRegExp("\\s"), "%20"); |
1871 | text.replace( QRegExp("#"), ""); | 1882 | text.replace( QRegExp("#"), ""); |
1872 | text.replace( QRegExp(","), "%20"); | 1883 | text.replace( QRegExp(","), "%20"); |
1873 | text.replace( QRegExp("'"), "%20"); | 1884 | text.replace( QRegExp("'"), "%20"); |
1874 | text.replace( QRegExp("("), ""); | 1885 | text.replace( QRegExp("("), ""); |
1875 | text.replace( QRegExp(")"), ""); | 1886 | text.replace( QRegExp(")"), ""); |
1876 | // text.replace( QRegExp("[0-9]"), ""); | 1887 | // text.replace( QRegExp("[0-9]"), ""); |
1877 | QString s_lookup = "http://google.com/search?q="+text+"&num=30&sa=Google+Search"; | 1888 | QString s_lookup = "http://google.com/search?q="+text+"&num=30&sa=Google+Search"; |
1878 | goGetit( s_lookup, true); | 1889 | goGetit( s_lookup, true); |
1879 | } | 1890 | } |
1880 | 1891 | ||
1881 | } | 1892 | } |
1882 | 1893 | ||
1883 | void Gutenbrowser::menuEditTitle() | 1894 | void Gutenbrowser::menuEditTitle() |
1884 | { | 1895 | { |
1885 | int currentItem = mainList->currentItem(); | 1896 | int currentItem = mainList->currentItem(); |
1886 | QString title_text = mainList->text( currentItem); | 1897 | QString title_text = mainList->text( currentItem); |
1887 | //odebug << "Selected "+title_text << oendl; | 1898 | //odebug << "Selected "+title_text << oendl; |
1888 | 1899 | ||
1889 | Config config("Gutenbrowser"); | 1900 | Config config("Gutenbrowser"); |
1890 | config.setGroup( "Files" ); | 1901 | config.setGroup( "Files" ); |
1891 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0"); | 1902 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0"); |
1892 | int i_numofFiles = s_numofFiles.toInt(); | 1903 | int i_numofFiles = s_numofFiles.toInt(); |
1893 | QString fileNum; | 1904 | QString fileNum; |
1894 | for (int i = 1; i <= i_numofFiles+1; i++) { | 1905 | for (int i = 1; i <= i_numofFiles+1; i++) { |
1895 | 1906 | ||
1896 | fileNum.setNum(i); | 1907 | fileNum.setNum(i); |
1897 | config.setGroup( "Files" ); | 1908 | config.setGroup( "Files" ); |
1898 | QString s_filename = config.readEntry(fileNum, "" ); | 1909 | QString s_filename = config.readEntry(fileNum, "" ); |
1899 | config.setGroup( "Titles" ); | 1910 | config.setGroup( "Titles" ); |
1900 | QString file_title = config.readEntry( s_filename, ""); | 1911 | QString file_title = config.readEntry( s_filename, ""); |
1901 | //odebug << "file_title is "+file_title << oendl; | 1912 | //odebug << "file_title is "+file_title << oendl; |
1902 | if(title_text == file_title ) { | 1913 | if(title_text == file_title ) { |
1903 | // selFile = s_filename; | 1914 | // selFile = s_filename; |
1904 | //odebug << "Edit: "+ file_title << oendl; | 1915 | //odebug << "Edit: "+ file_title << oendl; |
1905 | i=i_numofFiles+1; | 1916 | i=i_numofFiles+1; |
1906 | Edit_Title *titleEdit; | 1917 | Edit_Title *titleEdit; |
1907 | titleEdit = new Edit_Title(this,file_title ,TRUE); | 1918 | titleEdit = new Edit_Title(this,file_title ,TRUE); |
1908 | if(titleEdit->exec() !=0) { | 1919 | if(titleEdit->exec() !=0) { |
1909 | //odebug << titleEdit->newTitle << oendl; | 1920 | //odebug << titleEdit->newTitle << oendl; |
1910 | config.writeEntry( s_filename, titleEdit->newTitle); | 1921 | config.writeEntry( s_filename, titleEdit->newTitle); |
1911 | mainList->removeItem(currentItem); | 1922 | mainList->removeItem(currentItem); |
1912 | mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), titleEdit->newTitle, currentItem); | 1923 | mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), titleEdit->newTitle, currentItem); |
1913 | } | 1924 | } |
1914 | } | 1925 | } |
1915 | } | 1926 | } |
1916 | 1927 | ||
1917 | // getTitles(); | 1928 | // getTitles(); |
1918 | mainList->triggerUpdate(true); | 1929 | mainList->triggerUpdate(true); |
1919 | 1930 | ||
1920 | } | 1931 | } |
1921 | 1932 | ||
1922 | 1933 | ||
1923 | 1934 | ||
1924 | bool Gutenbrowser::UnZipIt(const QString &zipFile) { | 1935 | bool Gutenbrowser::UnZipIt(const QString &zipFile) { |
1925 | odebug << zipFile << oendl; | 1936 | odebug << zipFile << oendl; |
1926 | #ifndef Q_WS_QWS | 1937 | #ifndef Q_WS_QWS |
1927 | if( QFile::exists( zipFile)) { // TODO findsome other way of dealingwithzip files. | 1938 | if( QFile::exists( zipFile)) { // TODO findsome other way of dealingwithzip files. |
1928 | bool isPgWhole=false; | 1939 | bool isPgWhole=false; |
1929 | QString thatFile; | 1940 | QString thatFile; |
1930 | if(zipFile.find("pgwhole",0,TRUE)) { | 1941 | if(zipFile.find("pgwhole",0,TRUE)) { |
1931 | isPgWhole=TRUE; | 1942 | isPgWhole=TRUE; |
1932 | thatFile= local_library +"PGWHOLE.TXT"; | 1943 | thatFile= local_library +"PGWHOLE.TXT"; |
1933 | } | 1944 | } |
1934 | // else { | 1945 | // else { |
1935 | // thatFile=zipFile.left(4); | 1946 | // thatFile=zipFile.left(4); |
1936 | // } | 1947 | // } |
1937 | // odebug << (const char*)local_library.latin1() << oendl; | 1948 | // odebug << (const char*)local_library.latin1() << oendl; |
1938 | QString cmd; | 1949 | QString cmd; |
1939 | #if defined(_WS_X11_) | 1950 | #if defined(_WS_X11_) |
1940 | if( chdir((const char*)local_library.latin1())!=0) | 1951 | if( chdir((const char*)local_library.latin1())!=0) |
1941 | odebug << "chdir failed." << oendl; | 1952 | odebug << "chdir failed." << oendl; |
1942 | cmd = "gunzip -S .zip " + local_library+zipFile; | 1953 | cmd = "gunzip -S .zip " + local_library+zipFile; |
1943 | //cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; | 1954 | //cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; |
1944 | #endif | 1955 | #endif |
1945 | #ifdef Q_WS_QWS | 1956 | #ifdef Q_WS_QWS |
1946 | if( chdir((const char*)local_library.latin1())!=0) | 1957 | if( chdir((const char*)local_library.latin1())!=0) |
1947 | odebug << "chdir failed." << oendl; | 1958 | odebug << "chdir failed." << oendl; |
1948 | cmd = "unzip " + local_library+zipFile; | 1959 | cmd = "unzip " + local_library+zipFile; |
1949 | // cmd = "/usr/bin/unzip -o " + local_library+zipFile +" -d /usr/share/doc/gutenbrowser" ;//+ local_library; | 1960 | // cmd = "/usr/bin/unzip -o " + local_library+zipFile +" -d /usr/share/doc/gutenbrowser" ;//+ local_library; |
1950 | #endif | 1961 | #endif |
1951 | int exit=QMessageBox::information(this, "Ok to unzip?", | 1962 | int exit=QMessageBox::information(this, "Ok to unzip?", |
1952 | "Ok to unnzip\n"+ zipFile+" ?", | 1963 | "Ok to unnzip\n"+ zipFile+" ?", |
1953 | QMessageBox::Yes, QMessageBox::No); | 1964 | QMessageBox::Yes, QMessageBox::No); |
1954 | if (exit==QMessageBox::Yes) { | 1965 | if (exit==QMessageBox::Yes) { |
1955 | #if defined(_WS_X11_)// | 1966 | #if defined(_WS_X11_)// |
1956 | odebug << "Issuing the command "+cmd << oendl; | 1967 | odebug << "Issuing the command "+cmd << oendl; |
1957 | system( cmd); | 1968 | system( cmd); |
1958 | if( QFile::exists(thatFile)) | 1969 | if( QFile::exists(thatFile)) |
1959 | remove (thatFile); | 1970 | remove (thatFile); |
1960 | if(isPgWhole) { | 1971 | if(isPgWhole) { |
1961 | if( rename("pgwhole","PGWHOLE.TXT") !=0) | 1972 | if( rename("pgwhole","PGWHOLE.TXT") !=0) |
1962 | odebug << "rename failed" << oendl; | 1973 | odebug << "rename failed" << oendl; |
1963 | } else { | 1974 | } else { |
1964 | if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) | 1975 | if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) |
1965 | odebug << "rename failed" << oendl; | 1976 | odebug << "rename failed" << oendl; |
1966 | } | 1977 | } |
1967 | #endif | 1978 | #endif |
1968 | #ifdef Q_WS_QWS | 1979 | #ifdef Q_WS_QWS |
1969 | odebug << "Issuing the command "+cmd << oendl; | 1980 | odebug << "Issuing the command "+cmd << oendl; |
1970 | system( cmd); | 1981 | system( cmd); |
1971 | if( QFile::exists(thatFile)) | 1982 | if( QFile::exists(thatFile)) |
1972 | remove(thatFile); | 1983 | remove(thatFile); |
1973 | if(isPgWhole) { | 1984 | if(isPgWhole) { |
1974 | if( rename("pgwhole","PGWHOLE.TXT") !=0) | 1985 | if( rename("pgwhole","PGWHOLE.TXT") !=0) |
1975 | odebug << "rename failed" << oendl; | 1986 | odebug << "rename failed" << oendl; |
1976 | } else { | 1987 | } else { |
1977 | if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) | 1988 | if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) |
1978 | odebug << "rename failed" << oendl; | 1989 | odebug << "rename failed" << oendl; |
1979 | } | 1990 | } |
1980 | #endif | 1991 | #endif |
1981 | // remove( zipFile); | 1992 | // remove( zipFile); |
1982 | return true; | 1993 | return true; |
1983 | } | 1994 | } |
1984 | else if(exit==QMessageBox::No) { | 1995 | else if(exit==QMessageBox::No) { |
1985 | // odebug << "unzip" << oendl; | 1996 | // odebug << "unzip" << oendl; |
1986 | return false; | 1997 | return false; |
1987 | } | 1998 | } |
1988 | } | 1999 | } |
1989 | else | 2000 | else |
1990 | QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); | 2001 | QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); |
1991 | #endif | 2002 | #endif |
1992 | return false; | 2003 | return false; |
1993 | } | 2004 | } |
1994 | 2005 | ||
1995 | 2006 | ||