author | llornkcor <llornkcor> | 2005-02-06 04:30:34 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-02-06 04:30:34 (UTC) |
commit | 60a856903eb688b56c61fa787ac26b6be9f6d6c4 (patch) (unidiff) | |
tree | 81848a11c6b006ed4b6ac5a036de8402dde8e25d | |
parent | e23dd592fc71aa22c449363231eac2f8ebd2a45b (diff) | |
download | opie-60a856903eb688b56c61fa787ac26b6be9f6d6c4.zip opie-60a856903eb688b56c61fa787ac26b6be9f6d6c4.tar.gz opie-60a856903eb688b56c61fa787ac26b6be9f6d6c4.tar.bz2 |
fix #1494 - download of file when search is canceled
-rw-r--r-- | noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | 185 |
1 files changed, 95 insertions, 90 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp index 3c096ed..7426e80 100644 --- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | |||
@@ -1,1073 +1,1078 @@ | |||
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() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) { |
143 | 143 | ||
144 | // fill string list or something to be able to resort the whole library | 144 | // fill string list or something to be able to resort the whole library |
145 | if( author.isEmpty() ) | 145 | if( author.isEmpty() ) |
146 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); | 146 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); |
147 | else { | 147 | else { |
148 | 148 | ||
149 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || | 149 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || |
150 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) | 150 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) |
151 | QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); | 151 | QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); |
152 | 152 | ||
153 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || | 153 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || |
154 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) | 154 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) |
155 | QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file ); | 155 | QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file ); |
156 | 156 | ||
157 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || | 157 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || |
158 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) | 158 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) |
159 | QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file ); | 159 | QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file ); |
160 | 160 | ||
161 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || | 161 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || |
162 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) | 162 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) |
163 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); | 163 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); |
164 | 164 | ||
165 | else | 165 | else |
166 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); | 166 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); |
167 | } | 167 | } |
168 | } | 168 | } |
169 | }// end if | 169 | }// end if |
170 | }// end while | 170 | }// end while |
171 | newindexLib.close(); | 171 | newindexLib.close(); |
172 | } | 172 | } |
173 | #ifndef Q_WS_QWS | 173 | #ifndef Q_WS_QWS |
174 | setCursor( arrowCursor); | 174 | setCursor( arrowCursor); |
175 | #endif | 175 | #endif |
176 | #endif | 176 | #endif |
177 | } // end Newlibrary() | 177 | } // end Newlibrary() |
178 | 178 | ||
179 | 179 | ||
180 | void LibraryDialog::Library() | 180 | void LibraryDialog::Library() |
181 | {// old library groking method | 181 | {// old library groking method |
182 | 182 | ||
183 | ListView1->clear(); | 183 | ListView1->clear(); |
184 | ListView2->clear(); | 184 | ListView2->clear(); |
185 | ListView3->clear(); | 185 | ListView3->clear(); |
186 | ListView4->clear(); | 186 | ListView4->clear(); |
187 | ListView5->clear(); | 187 | ListView5->clear(); |
188 | 188 | ||
189 | odebug << "opening GUTINDEX.ALL file" << oendl; | 189 | odebug << "opening GUTINDEX.ALL file" << oendl; |
190 | IDontKnowWhy = ""; | 190 | IDontKnowWhy = ""; |
191 | if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully | 191 | if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully |
192 | QTextStream indexStream( &indexLib ); | 192 | QTextStream indexStream( &indexLib ); |
193 | QString indexLine; | 193 | QString indexLine; |
194 | qApp->processEvents(); | 194 | qApp->processEvents(); |
195 | // int jig; | 195 | // int jig; |
196 | while ( !indexStream.eof() ) { | 196 | while ( !indexStream.eof() ) { |
197 | 197 | ||
198 | indexLine = indexStream.readLine(); | 198 | indexLine = indexStream.readLine(); |
199 | if ( indexLine != "") { | 199 | if ( indexLine != "") { |
200 | if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) { | 200 | if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) { |
201 | // month = indexLine.left( 3); | 201 | // month = indexLine.left( 3); |
202 | year = indexLine.mid(4,4); | 202 | year = indexLine.mid(4,4); |
203 | // title = indexLine.mid( 9, 50); | 203 | // title = indexLine.mid( 9, 50); |
204 | file = indexLine.mid(60,12); | 204 | file = indexLine.mid(60,12); |
205 | if(file.left(1).find("[",0,TRUE) != -1) | 205 | if(file.left(1).find("[",0,TRUE) != -1) |
206 | file.remove(1,1); | 206 | file.remove(1,1); |
207 | if( file.find("]",0,TRUE) != -1) | 207 | if( file.find("]",0,TRUE) != -1) |
208 | file = file.left( file.find("]",0,TRUE)); | 208 | file = file.left( file.find("]",0,TRUE)); |
209 | //odebug << "file is "+file << oendl; | 209 | //odebug << "file is "+file << oendl; |
210 | /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); | 210 | /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); |
211 | number = indexLine.mid(55,5); | 211 | number = indexLine.mid(55,5); |
212 | number = number.stripWhiteSpace(); | 212 | number = number.stripWhiteSpace(); |
213 | // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); | 213 | // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); |
214 | title = indexLine.mid( 9, 50 ); | 214 | title = indexLine.mid( 9, 50 ); |
215 | title = title.stripWhiteSpace(); | 215 | title = title.stripWhiteSpace(); |
216 | //odebug << "title is "+title << oendl; | 216 | //odebug << "title is "+title << oendl; |
217 | getAuthor(); // grok author | 217 | getAuthor(); // grok author |
218 | author = author.stripWhiteSpace(); | 218 | author = author.stripWhiteSpace(); |
219 | //odebug << "author is "+author << oendl; | 219 | //odebug << "author is "+author << oendl; |
220 | if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author | 220 | if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author |
221 | QString lastName, firstName=""; | 221 | QString lastName, firstName=""; |
222 | int finder=author.findRev( ' ', -1, TRUE); | 222 | int finder=author.findRev( ' ', -1, TRUE); |
223 | lastName=author.right( author.length()-finder); | 223 | lastName=author.right( author.length()-finder); |
224 | firstName=author.left(finder); | 224 | firstName=author.left(finder); |
225 | lastName=lastName.stripWhiteSpace(); | 225 | lastName=lastName.stripWhiteSpace(); |
226 | firstName=firstName.stripWhiteSpace(); | 226 | firstName=firstName.stripWhiteSpace(); |
227 | 227 | ||
228 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names | 228 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names |
229 | author=lastName+", "+firstName; | 229 | author=lastName+", "+firstName; |
230 | } | 230 | } |
231 | 231 | ||
232 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) /*&& (file.find( "]",0, TRUE))*/ ) { | 232 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) /*&& (file.find( "]",0, TRUE))*/ ) { |
233 | // fill string list or something to be able to sort by Author | 233 | // fill string list or something to be able to sort by Author |
234 | if( author.isEmpty() ) | 234 | if( author.isEmpty() ) |
235 | QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); | 235 | QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); |
236 | else { | 236 | else { |
237 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || | 237 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || |
238 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) | 238 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) |
239 | QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); | 239 | QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); |
240 | 240 | ||
241 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || | 241 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || |
242 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) | 242 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) |
243 | QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); | 243 | QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); |
244 | 244 | ||
245 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || | 245 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || |
246 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) | 246 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) |
247 | QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file ); | 247 | QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file ); |
248 | 248 | ||
249 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || | 249 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || |
250 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) | 250 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) |
251 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); | 251 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | } | 254 | } |
255 | } | 255 | } |
256 | } | 256 | } |
257 | indexLib.close(); | 257 | indexLib.close(); |
258 | } else { | 258 | } else { |
259 | QString sMsg; | 259 | QString sMsg; |
260 | sMsg = ( tr("<p>Error opening local library index:</P> "))+local_index; | 260 | sMsg = ( tr("<p>Error opening local library index:</P> "))+local_index; |
261 | QMessageBox::message( "Error",sMsg); | 261 | QMessageBox::message( "Error",sMsg); |
262 | } | 262 | } |
263 | 263 | ||
264 | } //end Library() | 264 | } //end Library() |
265 | 265 | ||
266 | 266 | ||
267 | /* | 267 | /* |
268 | Groks the author out of the title */ | 268 | Groks the author out of the title */ |
269 | bool LibraryDialog::getAuthor() | 269 | bool LibraryDialog::getAuthor() |
270 | { | 270 | { |
271 | if( title.contains( ", by", TRUE)) { | 271 | if( title.contains( ", by", TRUE)) { |
272 | int auth; | 272 | int auth; |
273 | auth = title.find(", by", 0, TRUE); | 273 | auth = title.find(", by", 0, TRUE); |
274 | author = title.right(title.length() - (auth + 4) ); | 274 | author = title.right(title.length() - (auth + 4) ); |
275 | if( int finder = author.find("[", 0, TRUE)) { | 275 | if( int finder = author.find("[", 0, TRUE)) { |
276 | author = author.left(finder); | 276 | author = author.left(finder); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | else if ( title.contains( "by, ", TRUE) ) { | 279 | else if ( title.contains( "by, ", TRUE) ) { |
280 | int auth; | 280 | int auth; |
281 | auth = title.find("by, ", 0, TRUE); | 281 | auth = title.find("by, ", 0, TRUE); |
282 | author = title.right(title.length() - (auth + 4) ); | 282 | author = title.right(title.length() - (auth + 4) ); |
283 | if( int finder = author.find("[", 0, TRUE)) { | 283 | if( int finder = author.find("[", 0, TRUE)) { |
284 | author = author.left( finder); | 284 | author = author.left( finder); |
285 | } | 285 | } |
286 | } | 286 | } |
287 | else if ( title.contains( " by", TRUE) ) { | 287 | else if ( title.contains( " by", TRUE) ) { |
288 | int auth; | 288 | int auth; |
289 | auth = title.find(" by", 0, TRUE); | 289 | auth = title.find(" by", 0, TRUE); |
290 | author = title.right(title.length() - (auth + 3) ); | 290 | author = title.right(title.length() - (auth + 3) ); |
291 | if( int finder = author.find("[", 0, TRUE)) { | 291 | if( int finder = author.find("[", 0, TRUE)) { |
292 | author = author.left( finder); | 292 | author = author.left( finder); |
293 | } | 293 | } |
294 | } | 294 | } |
295 | else if ( title.contains( "by ", TRUE) ) { | 295 | else if ( title.contains( "by ", TRUE) ) { |
296 | int auth; | 296 | int auth; |
297 | auth = title.find("by ", 0, TRUE); | 297 | auth = title.find("by ", 0, TRUE); |
298 | author = title.right(title.length() - (auth + 3) ); | 298 | author = title.right(title.length() - (auth + 3) ); |
299 | if( int finder = author.find("[", 0, TRUE)) { | 299 | if( int finder = author.find("[", 0, TRUE)) { |
300 | author = author.left( finder); | 300 | author = author.left( finder); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | else if ( title.contains( ",", TRUE) ) { | 303 | else if ( title.contains( ",", TRUE) ) { |
304 | int auth; | 304 | int auth; |
305 | auth = title.find(",", 0, TRUE); | 305 | auth = title.find(",", 0, TRUE); |
306 | author = title.right( title.length() - (auth + 1) ); | 306 | author = title.right( title.length() - (auth + 1) ); |
307 | if ( author.contains( ",", TRUE) ) { | 307 | if ( author.contains( ",", TRUE) ) { |
308 | int auth; | 308 | int auth; |
309 | auth = author.find(",", 0, TRUE); | 309 | auth = author.find(",", 0, TRUE); |
310 | author = author.right( author.length() - (auth + 1) ); | 310 | author = author.right( author.length() - (auth + 1) ); |
311 | } | 311 | } |
312 | if( int finder = author.find("[", 0, TRUE)) { | 312 | if( int finder = author.find("[", 0, TRUE)) { |
313 | author = author.left( finder); | 313 | author = author.left( finder); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | else if ( title.contains( "/", TRUE) ) { | 316 | else if ( title.contains( "/", TRUE) ) { |
317 | int auth; | 317 | int auth; |
318 | auth = title.find("/", 0, TRUE); | 318 | auth = title.find("/", 0, TRUE); |
319 | author = title.right(title.length() - (auth + 1) ); | 319 | author = title.right(title.length() - (auth + 1) ); |
320 | if( int finder = author.find("[", 0, TRUE)) { | 320 | if( int finder = author.find("[", 0, TRUE)) { |
321 | author = author.left( finder); | 321 | author = author.left( finder); |
322 | } | 322 | } |
323 | } | 323 | } |
324 | else if ( title.contains( "of", TRUE) ) { | 324 | else if ( title.contains( "of", TRUE) ) { |
325 | int auth; | 325 | int auth; |
326 | auth = title.find("of", 0, TRUE); | 326 | auth = title.find("of", 0, TRUE); |
327 | author = title.right(title.length() - (auth + 2) ); | 327 | author = title.right(title.length() - (auth + 2) ); |
328 | if( int finder = author.find("[", 0, TRUE)) | 328 | if( int finder = author.find("[", 0, TRUE)) |
329 | { | 329 | { |
330 | author = author.left( finder); | 330 | author = author.left( finder); |
331 | } | 331 | } |
332 | } else { | 332 | } else { |
333 | author = ""; | 333 | author = ""; |
334 | } | 334 | } |
335 | if ( author.contains("et. al")) { | 335 | if ( author.contains("et. al")) { |
336 | int auth; | 336 | int auth; |
337 | auth = author.find("et. al", 0, TRUE); | 337 | auth = author.find("et. al", 0, TRUE); |
338 | author = author.left( auth ); | 338 | author = author.left( auth ); |
339 | } | 339 | } |
340 | if ( author.contains("#")) { | 340 | if ( author.contains("#")) { |
341 | int auth; | 341 | int auth; |
342 | auth = author.find("#", 0, TRUE); | 342 | auth = author.find("#", 0, TRUE); |
343 | author = author.left( auth); | 343 | author = author.left( auth); |
344 | } | 344 | } |
345 | if ( author.contains("(")) { | 345 | if ( author.contains("(")) { |
346 | int auth; | 346 | int auth; |
347 | auth = author.find("(", 0, TRUE); | 347 | auth = author.find("(", 0, TRUE); |
348 | author = author.left( auth); | 348 | author = author.left( auth); |
349 | } | 349 | } |
350 | if ( author.contains("et al")) { | 350 | if ( author.contains("et al")) { |
351 | int auth; | 351 | int auth; |
352 | auth = author.find("et al", 0, TRUE); | 352 | auth = author.find("et al", 0, TRUE); |
353 | author = author.left( auth ); | 353 | author = author.left( auth ); |
354 | } | 354 | } |
355 | QRegExp r = QRegExp("[0-9]", TRUE, FALSE); | 355 | QRegExp r = QRegExp("[0-9]", TRUE, FALSE); |
356 | if ( author.left(2).find( r) != -1 ) { | 356 | if ( author.left(2).find( r) != -1 ) { |
357 | author = ""; | 357 | author = ""; |
358 | } | 358 | } |
359 | // if( author.contains(" ", TRUE)) { | 359 | // if( author.contains(" ", TRUE)) { |
360 | // int suth = author.findRev(" ", -1, TRUE); | 360 | // int suth = author.findRev(" ", -1, TRUE); |
361 | // author = author.right( author.length() - suth); | 361 | // author = author.right( author.length() - suth); |
362 | // } | 362 | // } |
363 | 363 | ||
364 | // title | 364 | // title |
365 | // author | 365 | // author |
366 | return true; | 366 | return true; |
367 | }////// end getAuthor() | 367 | }////// end getAuthor() |
368 | 368 | ||
369 | /* | 369 | /* |
370 | selected one etext*/ | 370 | selected one etext*/ |
371 | void LibraryDialog::select_title( QListViewItem * item) | 371 | void LibraryDialog::select_title( QListViewItem * item) |
372 | { | 372 | { |
373 | if(item != NULL) { | 373 | if(item != NULL) { |
374 | i++; | 374 | i++; |
375 | int index = tabWidget->currentPageIndex(); | 375 | int index = tabWidget->currentPageIndex(); |
376 | DlglistItemTitle = item->text(0); | 376 | DlglistItemTitle = item->text(0); |
377 | DlglistItemYear = item->text(2); | 377 | DlglistItemYear = item->text(2); |
378 | DlglistItemFile = item->text(3); | 378 | DlglistItemFile = item->text(3); |
379 | switch (index) { | 379 | switch (index) { |
380 | case 0: { | 380 | case 0: { |
381 | ListView1->clearSelection(); | 381 | ListView1->clearSelection(); |
382 | } | 382 | } |
383 | break; | 383 | break; |
384 | case 1: { | 384 | case 1: { |
385 | ListView2->clearSelection(); | 385 | ListView2->clearSelection(); |
386 | } | 386 | } |
387 | break; | 387 | break; |
388 | case 2: { | 388 | case 2: { |
389 | ListView3->clearSelection(); | 389 | ListView3->clearSelection(); |
390 | } | 390 | } |
391 | break; | 391 | break; |
392 | case 3: { | 392 | case 3: { |
393 | ListView4->clearSelection(); | 393 | ListView4->clearSelection(); |
394 | } | 394 | } |
395 | break; | 395 | break; |
396 | case 4: { | 396 | case 4: { |
397 | ListView5->clearSelection(); | 397 | ListView5->clearSelection(); |
398 | } | 398 | } |
399 | break; | 399 | break; |
400 | }; | 400 | }; |
401 | } | 401 | } |
402 | 402 | ||
403 | if(DlglistItemTitle.length()>2) { | 403 | if(DlglistItemTitle.length()>2) { |
404 | // DlglistItemNumber = item->text(0); | 404 | // DlglistItemNumber = item->text(0); |
405 | item = 0; | 405 | item = 0; |
406 | odebug << "string from librarydialog is:" << DlglistItemYear << " " << DlglistItemFile << " " << DlglistItemNumber << "" << oendl; | 406 | odebug << "string from librarydialog is:" << DlglistItemYear << " " << DlglistItemFile << " " << DlglistItemNumber << "" << oendl; |
407 | odebug << "Title is "+DlglistItemTitle << oendl; | 407 | odebug << "Title is "+DlglistItemTitle << oendl; |
408 | 408 | ||
409 | // check for connection here | 409 | // check for connection here |
410 | // if( get_extext()) | 410 | // if( get_extext()) |
411 | 411 | ||
412 | if(download_Etext()) { | 412 | if(download_Etext()) { |
413 | // odebug << "get here 2" << oendl; | 413 | // odebug << "get here 2" << oendl; |
414 | if(i_binary == 1) { | 414 | if(i_binary == 1) { |
415 | 415 | ||
416 | } | 416 | } |
417 | if(checkBox->isChecked () ) { | 417 | if(checkBox->isChecked () ) { |
418 | accept(); | 418 | accept(); |
419 | } | 419 | } |
420 | } | 420 | } |
421 | } | 421 | } |
422 | } | 422 | } |
423 | 423 | ||
424 | bool LibraryDialog::download_Etext() | 424 | bool LibraryDialog::download_Etext() |
425 | { // ftp method | 425 | { // ftp method |
426 | // might have to use old gpl'd ftp for embedded!! | 426 | // might have to use old gpl'd ftp for embedded!! |
427 | Config cfg("Gutenbrowser"); | 427 | Config cfg("Gutenbrowser"); |
428 | cfg.setGroup("FTPsite"); | 428 | cfg.setGroup("FTPsite"); |
429 | ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org"); | 429 | ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org"); |
430 | ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg"); | 430 | ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg"); |
431 | 431 | ||
432 | odebug << "about to network dialog" << oendl; | 432 | odebug << "about to network dialog" << oendl; |
433 | QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile; | 433 | QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile; |
434 | 434 | ||
435 | //////////////////// FIXME- if 'x' is part of real name.... | 435 | //////////////////// 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)); | 436 | NewlistItemFile = DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).left(DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).find("x", 1, FALSE)); |
437 | 437 | ||
438 | if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) { | 438 | if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) { |
439 | NewlistItemFile.replace( 0,4, DlglistItemFile.left(4)); | 439 | NewlistItemFile.replace( 0,4, DlglistItemFile.left(4)); |
440 | odebug << "NewlistItemFile is now "+NewlistItemFile << oendl; | 440 | odebug << "NewlistItemFile is now "+NewlistItemFile << oendl; |
441 | } | 441 | } |
442 | NewlistItemYear = DlglistItemYear.right(2); | 442 | NewlistItemYear = DlglistItemYear.right(2); |
443 | int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10); | 443 | int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10); |
444 | odebug << NewlistItemYear << oendl; | 444 | odebug << NewlistItemYear << oendl; |
445 | if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) { | 445 | if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) { |
446 | NewlistItemYear = "90"; | 446 | NewlistItemYear = "90"; |
447 | } | 447 | } |
448 | Edir ="etext" +NewlistItemYear; | 448 | Edir ="etext" +NewlistItemYear; |
449 | dir= ftp_base_dir + "/etext" +NewlistItemYear+"/"; | 449 | dir= ftp_base_dir + "/etext" +NewlistItemYear+"/"; |
450 | if( ftp_base_dir.find("=",0,true) ) | 450 | if( ftp_base_dir.find("=",0,true) ) |
451 | ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1); | 451 | ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1); |
452 | 452 | ||
453 | networkUrl= "ftp://"+ftp_host+dir; | 453 | networkUrl= "ftp://"+ftp_host+dir; |
454 | 454 | ||
455 | outputFile=local_library+".guten_temp"; | 455 | outputFile=local_library+".guten_temp"; |
456 | //odebug << "Download file:" << NewlistItemFile << "" << oendl; | 456 | //odebug << "Download file:" << NewlistItemFile << "" << oendl; |
457 | odebug << "Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile << oendl; | 457 | odebug << "Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile << oendl; |
458 | QStringList networkList; | 458 | QStringList networkList; |
459 | networkList.append((const char *)ftp_host); | 459 | networkList.append((const char *)ftp_host); |
460 | networkList.append((const char *)dir); | 460 | networkList.append((const char *)dir); |
461 | networkList.append((const char *)outputFile); | 461 | networkList.append((const char *)outputFile); |
462 | networkList.append((const char *)NewlistItemFile); | 462 | networkList.append((const char *)NewlistItemFile); |
463 | //<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile; | 463 | //<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile; |
464 | 464 | ||
465 | NetworkDialog *NetworkDlg; | 465 | NetworkDialog *NetworkDlg; |
466 | NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList); | 466 | NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList); |
467 | 467 | ||
468 | 468 | ||
469 | if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer | 469 | if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer |
470 | File_Name= NetworkDlg->localFileName; | 470 | File_Name= NetworkDlg->localFileName; |
471 | odebug << "back to Library from Network Dialog" << oendl; | 471 | odebug << "back to Library from Network Dialog" << oendl; |
472 | odebug << "Just downloaded "+NetworkDlg->localFileName << oendl; | 472 | odebug << "Just downloaded "+NetworkDlg->localFileName << oendl; |
473 | 473 | ||
474 | // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found | 474 | // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found |
475 | // QString oldName=File_Name; | 475 | // QString oldName=File_Name; |
476 | // File_Name.replace(0,local_library.length(),downDir); | 476 | // File_Name.replace(0,local_library.length(),downDir); |
477 | // odebug << "File_Name now is "+File_Name << oendl; | 477 | // odebug << "File_Name now is "+File_Name << oendl; |
478 | 478 | ||
479 | // } | 479 | // } |
480 | // rename .txt to .etx | 480 | // rename .txt to .etx |
481 | if(NetworkDlg->successDownload) { | 481 | if(NetworkDlg->successDownload) { |
482 | odebug << "Filename is "+File_Name << oendl; | 482 | odebug << "Filename is "+File_Name << oendl; |
483 | if(File_Name.right(4)==".txt") { | 483 | if(File_Name.right(4)==".txt") { |
484 | QString s_fileName=File_Name; | 484 | QString s_fileName=File_Name; |
485 | s_fileName.replace( s_fileName.length()-3,3,"gtn"); | 485 | s_fileName.replace( s_fileName.length()-3,3,"gtn"); |
486 | // s_fileName.replace( s_fileName.length()-3,3,"etx"); | 486 | // s_fileName.replace( s_fileName.length()-3,3,"etx"); |
487 | rename(File_Name.latin1(),s_fileName.latin1()); | 487 | rename(File_Name.latin1(),s_fileName.latin1()); |
488 | File_Name=s_fileName; | 488 | File_Name=s_fileName; |
489 | 489 | ||
490 | odebug << "Filename is now "+File_Name << oendl; | 490 | odebug << "Filename is now "+File_Name << oendl; |
491 | 491 | ||
492 | } | 492 | } |
493 | if(File_Name.length() > 5 ) { | 493 | if(File_Name.length() > 5 ) { |
494 | setTitle(); | 494 | setTitle(); |
495 | QFileInfo fi(File_Name); | 495 | QFileInfo fi(File_Name); |
496 | QString name_file=fi.fileName(); | 496 | QString name_file=fi.fileName(); |
497 | name_file=name_file.left(name_file.length()-4); | 497 | name_file=name_file.left(name_file.length()-4); |
498 | 498 | ||
499 | odebug << "Setting doclink" << oendl; | 499 | odebug << "Setting doclink" << oendl; |
500 | DocLnk lnk; | 500 | DocLnk lnk; |
501 | odebug << "name is "+name_file << oendl; | 501 | odebug << "name is "+name_file << oendl; |
502 | lnk.setName(name_file); //sets file name | 502 | lnk.setName(name_file); //sets file name |
503 | odebug << "Title is "+DlglistItemTitle << oendl; | 503 | odebug << "Title is "+DlglistItemTitle << oendl; |
504 | lnk.setComment(DlglistItemTitle); | 504 | lnk.setComment(DlglistItemTitle); |
505 | 505 | ||
506 | odebug << "Filename is "+File_Name << oendl; | 506 | odebug << "Filename is "+File_Name << oendl; |
507 | lnk.setFile(File_Name); //sets File property | 507 | lnk.setFile(File_Name); //sets File property |
508 | lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D | 508 | lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D |
509 | lnk.setExec(File_Name); | 509 | lnk.setExec(File_Name); |
510 | lnk.setIcon("gutenbrowser/Gutenbrowser"); | 510 | lnk.setIcon("gutenbrowser/Gutenbrowser"); |
511 | if(!lnk.writeLink()) { | 511 | if(!lnk.writeLink()) { |
512 | odebug << "Writing doclink did not work" << oendl; | 512 | odebug << "Writing doclink did not work" << oendl; |
513 | } else { | 513 | } else { |
514 | } | 514 | } |
515 | } else | 515 | } else |
516 | QMessageBox::message("Note","<p>There was an error with the file</p>"); | 516 | QMessageBox::message("Note","<p>There was an error with the file</p>"); |
517 | } | 517 | } |
518 | } | 518 | } |
519 | return true; | 519 | return true; |
520 | } | 520 | } |
521 | 521 | ||
522 | bool LibraryDialog::httpDownload() | 522 | bool LibraryDialog::httpDownload() |
523 | {// httpDownload | 523 | {// httpDownload |
524 | #ifndef Q_WS_QWS | 524 | #ifndef Q_WS_QWS |
525 | Config config("Gutenbrowser"); | 525 | Config config("Gutenbrowser"); |
526 | config.setGroup( "Browser" ); | 526 | config.setGroup( "Browser" ); |
527 | QString brow = config.readEntry("Preferred", ""); | 527 | QString brow = config.readEntry("Preferred", ""); |
528 | QString file_name = "./.guten_temp"; | 528 | QString file_name = "./.guten_temp"; |
529 | // config.setGroup( "HttpServer" ); | 529 | // config.setGroup( "HttpServer" ); |
530 | // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); | 530 | // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); |
531 | QString httpName = proxy_http + "/"+Edir; | 531 | QString httpName = proxy_http + "/"+Edir; |
532 | // progressBar->setProgress( i); | 532 | // progressBar->setProgress( i); |
533 | i++; | 533 | i++; |
534 | if ( brow != "Konq") { /////////// use lynx | 534 | if ( brow != "Konq") { /////////// use lynx |
535 | // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name; | 535 | // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name; |
536 | // system(cmd); | 536 | // system(cmd); |
537 | } else { //////////// use KFM | 537 | } else { //////////// use KFM |
538 | // KFM::download( httpName, file_name); | 538 | // KFM::download( httpName, file_name); |
539 | } | 539 | } |
540 | i++; | 540 | i++; |
541 | QFile tmp( file_name); | 541 | QFile tmp( file_name); |
542 | QString str; | 542 | QString str; |
543 | if (tmp.open(IO_ReadOnly)) { | 543 | if (tmp.open(IO_ReadOnly)) { |
544 | QTextStream t( &tmp ); // use a text stream | 544 | QTextStream t( &tmp ); // use a text stream |
545 | while ( !t.eof()) { | 545 | while ( !t.eof()) { |
546 | QString s = t.readLine(); | 546 | QString s = t.readLine(); |
547 | if (s.contains( NewlistItemFile, FALSE) && (s.contains(".txt")) ) { | 547 | 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 ) ); | 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 ) ); |
549 | httpName += "/" + str; | 549 | httpName += "/" + str; |
550 | } | 550 | } |
551 | } //end of while loop | 551 | } //end of while loop |
552 | } | 552 | } |
553 | tmp.close(); | 553 | tmp.close(); |
554 | m_getFilePath = local_library + str; | 554 | m_getFilePath = local_library + str; |
555 | i++; | 555 | i++; |
556 | if ( brow != "KFM"){ ///////// use lynx | 556 | if ( brow != "KFM"){ ///////// use lynx |
557 | QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; | 557 | QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; |
558 | // QMessageBox::message("Error", cmd); | 558 | // QMessageBox::message("Error", cmd); |
559 | system(cmd); | 559 | system(cmd); |
560 | } else { ////////// use KFM | 560 | } else { ////////// use KFM |
561 | // KFM::download( httpName, m_getFilePath); | 561 | // KFM::download( httpName, m_getFilePath); |
562 | } | 562 | } |
563 | i++; | 563 | i++; |
564 | #endif | 564 | #endif |
565 | return false; | 565 | return false; |
566 | } | 566 | } |
567 | 567 | ||
568 | void LibraryDialog::cancelIt() | 568 | void LibraryDialog::cancelIt() |
569 | { | 569 | { |
570 | saveConfig(); | 570 | saveConfig(); |
571 | 571 | ||
572 | DlglistItemNumber = ""; | 572 | DlglistItemNumber = ""; |
573 | this->reject(); | 573 | this->reject(); |
574 | } | 574 | } |
575 | 575 | ||
576 | bool LibraryDialog::setTitle() | 576 | bool LibraryDialog::setTitle() |
577 | { | 577 | { |
578 | Config config("Gutenbrowser"); | 578 | Config config("Gutenbrowser"); |
579 | odebug << "setting title" << oendl; | 579 | odebug << "setting title" << oendl; |
580 | odebug << DlglistItemTitle << oendl; | 580 | odebug << DlglistItemTitle << oendl; |
581 | 581 | ||
582 | if( DlglistItemTitle.find("[",0,TRUE) != -1) | 582 | if( DlglistItemTitle.find("[",0,TRUE) != -1) |
583 | DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" ); | 583 | DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" ); |
584 | if( DlglistItemTitle.find("]",0,TRUE) !=-1) | 584 | if( DlglistItemTitle.find("]",0,TRUE) !=-1) |
585 | DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); | 585 | DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); |
586 | odebug << "Title being set is "+DlglistItemTitle << oendl; | 586 | odebug << "Title being set is "+DlglistItemTitle << oendl; |
587 | int test = 0; | 587 | int test = 0; |
588 | QString ramble, temp; | 588 | QString ramble, temp; |
589 | config.setGroup("Files"); | 589 | config.setGroup("Files"); |
590 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 590 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
591 | int i_numofFiles = s_numofFiles.toInt(); | 591 | int i_numofFiles = s_numofFiles.toInt(); |
592 | for ( int i = 0; i <= i_numofFiles; i++){ | 592 | for ( int i = 0; i <= i_numofFiles; i++){ |
593 | temp.setNum( i); | 593 | temp.setNum( i); |
594 | ramble = config.readEntry( temp, "" ); | 594 | ramble = config.readEntry( temp, "" ); |
595 | if( strcmp( ramble, File_Name) == 0){ | 595 | if( strcmp( ramble, File_Name) == 0){ |
596 | test = 1; | 596 | test = 1; |
597 | } | 597 | } |
598 | } | 598 | } |
599 | |||
600 | if(test == 0 ) { | ||
601 | |||
599 | config.setGroup("Files"); | 602 | config.setGroup("Files"); |
600 | config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); | 603 | config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); |
601 | QString interger; | 604 | QString interger; |
602 | interger.setNum( i_numofFiles +1); | 605 | interger.setNum( i_numofFiles +1); |
603 | config.writeEntry( interger, File_Name); | 606 | config.writeEntry( interger, File_Name); |
604 | config.setGroup( "Titles" ); | 607 | config.setGroup( "Titles" ); |
605 | config.writeEntry( File_Name, DlglistItemTitle); | 608 | config.writeEntry( File_Name, DlglistItemTitle); |
606 | 609 | } | |
607 | test = 0; | 610 | test = 0; |
608 | return true; | 611 | return true; |
609 | } | 612 | } |
610 | 613 | ||
611 | 614 | ||
612 | void LibraryDialog::saveConfig() | 615 | void LibraryDialog::saveConfig() |
613 | { | 616 | { |
614 | Config config("Gutenbrowser"); | 617 | Config config("Gutenbrowser"); |
615 | if( httpBox->isChecked() == TRUE) { | 618 | if( httpBox->isChecked() == TRUE) { |
616 | checked = 1; | 619 | checked = 1; |
617 | config.setGroup( "Proxy" ); | 620 | config.setGroup( "Proxy" ); |
618 | config.writeEntry("IsChecked", "TRUE"); | 621 | config.writeEntry("IsChecked", "TRUE"); |
619 | } else { | 622 | } else { |
620 | checked = 0; | 623 | checked = 0; |
621 | config.setGroup( "Proxy" ); | 624 | config.setGroup( "Proxy" ); |
622 | config.writeEntry("IsChecked", "FALSE"); | 625 | config.writeEntry("IsChecked", "FALSE"); |
623 | } | 626 | } |
624 | if (authBox->isChecked() == TRUE) { | 627 | if (authBox->isChecked() == TRUE) { |
625 | config.setGroup("SortAuth"); | 628 | config.setGroup("SortAuth"); |
626 | config.writeEntry("authSort", "TRUE"); | 629 | config.writeEntry("authSort", "TRUE"); |
627 | } else { | 630 | } else { |
628 | config.setGroup("SortAuth"); | 631 | config.setGroup("SortAuth"); |
629 | config.writeEntry("authSort", "FALSE"); | 632 | config.writeEntry("authSort", "FALSE"); |
630 | } | 633 | } |
631 | // config.write(); | 634 | // config.write(); |
632 | } | 635 | } |
633 | 636 | ||
634 | /* | 637 | /* |
635 | searches library index for user word*/ | 638 | searches library index for user word*/ |
636 | void LibraryDialog::onButtonSearch() | 639 | void LibraryDialog::onButtonSearch() |
637 | { | 640 | { |
638 | ListView1->clearSelection(); | 641 | ListView1->clearSelection(); |
639 | ListView2->clearSelection(); | 642 | ListView2->clearSelection(); |
640 | ListView3->clearSelection(); | 643 | ListView3->clearSelection(); |
641 | ListView4->clearSelection(); | 644 | ListView4->clearSelection(); |
642 | ListView5->clearSelection(); | 645 | ListView5->clearSelection(); |
643 | 646 | ||
644 | int curTab=tabWidget->currentPageIndex(); | 647 | int curTab=tabWidget->currentPageIndex(); |
645 | SearchDialog* searchDlg; | 648 | SearchDialog* searchDlg; |
646 | 649 | ||
647 | // if( resultsList) | 650 | // if( resultsList) |
648 | searchDlg = new SearchDialog( this, "Library Search", TRUE); | 651 | searchDlg = new SearchDialog( this, "Library Search", TRUE); |
649 | searchDlg->setCaption( tr( "Library Search" ) ); | 652 | searchDlg->setCaption( tr( "Library Search" ) ); |
650 | searchDlg->setLabel( "- author or title"); | 653 | searchDlg->setLabel( "- author or title"); |
651 | QString resultString; | 654 | QString resultString; |
652 | int i_berger = 0; | 655 | int i_berger = 0; |
653 | if( searchDlg->exec() != 0 ) { | 656 | if( searchDlg->exec() != 0 ) { |
654 | QString searcherStr = searchDlg->get_text(); | 657 | QString searcherStr = searchDlg->get_text(); |
655 | int fluff=0; | 658 | int fluff=0; |
656 | 659 | ||
657 | // int tabPage = tabWidget->currentPageIndex(); | 660 | // int tabPage = tabWidget->currentPageIndex(); |
658 | // TODO ititerate here... struct<listViews>?? | 661 | // TODO ititerate here... struct<listViews>?? |
659 | 662 | ||
660 | QListViewItemIterator it1( ListView1 ); | 663 | QListViewItemIterator it1( ListView1 ); |
661 | QListViewItemIterator it2( ListView2 ); | 664 | QListViewItemIterator it2( ListView2 ); |
662 | QListViewItemIterator it3( ListView3 ); | 665 | QListViewItemIterator it3( ListView3 ); |
663 | QListViewItemIterator it4( ListView4 ); | 666 | QListViewItemIterator it4( ListView4 ); |
664 | QListViewItemIterator it5( ListView5 ); | 667 | QListViewItemIterator it5( ListView5 ); |
665 | 668 | ||
666 | //// this is really pitiful work, | 669 | //// this is really pitiful work, |
667 | /////// | 670 | /////// |
668 | bool cS; | 671 | bool cS; |
669 | if( searchDlg->caseSensitiveCheckBox->isChecked()) | 672 | if( searchDlg->caseSensitiveCheckBox->isChecked()) |
670 | cS=true; //case sensitive | 673 | cS=true; //case sensitive |
671 | else | 674 | else |
672 | cS=false; | 675 | cS=false; |
673 | 676 | ||
674 | if(fluff==0) { | 677 | if(fluff==0) { |
675 | for ( ; it1.current(); ++it1 ) { | 678 | for ( ; it1.current(); ++it1 ) { |
676 | resultString = ( it1.current() )->text(0); | 679 | resultString = ( it1.current() )->text(0); |
677 | resultString += (" : "); | 680 | resultString += (" : "); |
678 | resultString += ( it1.current() )->text(2); | 681 | resultString += ( it1.current() )->text(2); |
679 | resultString += (" : "); | 682 | resultString += (" : "); |
680 | resultString += ( it1.current() )->text(3); | 683 | resultString += ( it1.current() )->text(3); |
681 | if( resultString.find( searcherStr, 0, cS) != -1) | 684 | if( resultString.find( searcherStr, 0, cS) != -1) |
682 | { | 685 | { |
683 | Searchlist.append( resultString); | 686 | Searchlist.append( resultString); |
684 | } | 687 | } |
685 | } | 688 | } |
686 | } | 689 | } |
687 | if(fluff==0) {// search routine here | 690 | if(fluff==0) {// search routine here |
688 | for ( ; it2.current(); ++it2 ) { | 691 | for ( ; it2.current(); ++it2 ) { |
689 | resultString = ( it2.current() )->text(0); | 692 | resultString = ( it2.current() )->text(0); |
690 | resultString += (" : "); | 693 | resultString += (" : "); |
691 | resultString += ( it2.current() )->text(2); | 694 | resultString += ( it2.current() )->text(2); |
692 | resultString += (" : "); | 695 | resultString += (" : "); |
693 | resultString += ( it2.current() )->text(3); | 696 | resultString += ( it2.current() )->text(3); |
694 | if( resultString.find( searcherStr, 0, cS) != -1) { | 697 | if( resultString.find( searcherStr, 0, cS) != -1) { |
695 | Searchlist.append( resultString); | 698 | Searchlist.append( resultString); |
696 | } | 699 | } |
697 | } | 700 | } |
698 | } | 701 | } |
699 | if(fluff==0) {// search routine here | 702 | if(fluff==0) {// search routine here |
700 | for ( ; it3.current(); ++it3 ) { | 703 | for ( ; it3.current(); ++it3 ) { |
701 | resultString = ( it3.current() )->text(0); | 704 | resultString = ( it3.current() )->text(0); |
702 | resultString += (" : "); | 705 | resultString += (" : "); |
703 | resultString += ( it3.current() )->text(2); | 706 | resultString += ( it3.current() )->text(2); |
704 | resultString += (" : "); | 707 | resultString += (" : "); |
705 | resultString += ( it3.current() )->text(3); | 708 | resultString += ( it3.current() )->text(3); |
706 | 709 | ||
707 | if( resultString.find( searcherStr, 0, cS) != -1) { | 710 | if( resultString.find( searcherStr, 0, cS) != -1) { |
708 | Searchlist.append( resultString); | 711 | Searchlist.append( resultString); |
709 | } | 712 | } |
710 | } | 713 | } |
711 | } | 714 | } |
712 | if(fluff==0) { | 715 | if(fluff==0) { |
713 | // search routine here | 716 | // search routine here |
714 | for ( ; it4.current(); ++it4 ) { | 717 | for ( ; it4.current(); ++it4 ) { |
715 | resultString = ( it4.current() )->text(0); | 718 | resultString = ( it4.current() )->text(0); |
716 | resultString += (" : "); | 719 | resultString += (" : "); |
717 | resultString += ( it4.current() )->text(2); | 720 | resultString += ( it4.current() )->text(2); |
718 | resultString += (" : "); | 721 | resultString += (" : "); |
719 | resultString += ( it4.current() )->text(3); | 722 | resultString += ( it4.current() )->text(3); |
720 | if( resultString.find( searcherStr, 0, cS) != -1) { | 723 | if( resultString.find( searcherStr, 0, cS) != -1) { |
721 | Searchlist.append( resultString); | 724 | Searchlist.append( resultString); |
722 | } | 725 | } |
723 | } | 726 | } |
724 | } | 727 | } |
725 | if(fluff==0) { // search routine here | 728 | if(fluff==0) { // search routine here |
726 | for ( ; it5.current(); ++it5 ) { | 729 | for ( ; it5.current(); ++it5 ) { |
727 | resultString = ( it5.current() )->text(0); | 730 | resultString = ( it5.current() )->text(0); |
728 | resultString += (" : "); | 731 | resultString += (" : "); |
729 | resultString += ( it5.current() )->text(2); | 732 | resultString += ( it5.current() )->text(2); |
730 | resultString += (" : "); | 733 | resultString += (" : "); |
731 | resultString += ( it5.current() )->text(3); | 734 | resultString += ( it5.current() )->text(3); |
732 | if( resultString.find( searcherStr, 0, cS) != -1) { | 735 | if( resultString.find( searcherStr, 0, cS) != -1) { |
733 | Searchlist.append( resultString); | 736 | Searchlist.append( resultString); |
734 | } | 737 | } |
735 | } | 738 | } |
736 | } | 739 | } |
737 | 740 | ||
738 | tabWidget->setCurrentPage( curTab); | 741 | tabWidget->setCurrentPage( curTab); |
739 | 742 | ||
740 | Searchlist.sort(); | 743 | Searchlist.sort(); |
741 | SearchResultsDlg* SearchResultsDialog; | 744 | SearchResultsDlg* SearchResultsDialog; |
742 | SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); | 745 | SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); |
743 | 746 | ||
744 | SearchResultsDialog->showMaximized(); | 747 | SearchResultsDialog->showMaximized(); |
745 | if( SearchResultsDialog->exec() != 0) { | 748 | if( SearchResultsDialog->exec() != 0) { |
746 | texter = SearchResultsDialog->selText; | 749 | texter = SearchResultsDialog->selText; |
747 | // odebug << texter << oendl; | 750 | // odebug << texter << oendl; |
748 | resultLs= SearchResultsDialog->resultsList; | 751 | resultLs = SearchResultsDialog->resultsList; |
749 | i_berger = 1; | 752 | i_berger = 1; |
750 | } | 753 | } else { |
754 | resultLs.clear(); | ||
755 | } | ||
751 | Searchlist.clear(); | 756 | Searchlist.clear(); |
752 | 757 | ||
753 | // if(SearchResultsDialog) | 758 | // if(SearchResultsDialog) |
754 | // delete SearchResultsDialog; | 759 | // delete SearchResultsDialog; |
755 | QString tester; | 760 | QString tester; |
756 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { | 761 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { |
757 | texter.sprintf("%s \n",(*it).latin1()); | 762 | texter.sprintf("%s \n",(*it).latin1()); |
758 | // odebug << texter << oendl; | 763 | // odebug << texter << oendl; |
759 | if( tester!=texter) | 764 | if( tester!=texter) |
760 | parseSearchResults( texter); | 765 | parseSearchResults( texter); |
761 | tester = texter; | 766 | tester = texter; |
762 | } | 767 | } |
763 | if(searchDlg) | 768 | if(searchDlg) |
764 | delete searchDlg; | 769 | delete searchDlg; |
765 | } | 770 | } |
766 | if(checkBox->isChecked() ) { | 771 | if(checkBox->isChecked() ) { |
767 | accept(); | 772 | accept(); |
768 | } else { | 773 | } else { |
769 | setActiveWindow(); | 774 | setActiveWindow(); |
770 | } | 775 | } |
771 | } | 776 | } |
772 | 777 | ||
773 | /* | 778 | /* |
774 | splits the result string and calls download for the current search result*/ | 779 | splits the result string and calls download for the current search result*/ |
775 | void LibraryDialog::parseSearchResults( QString resultStr) | 780 | void LibraryDialog::parseSearchResults( QString resultStr) |
776 | { | 781 | { |
777 | 782 | ||
778 | int stringLeng=resultStr.length(); | 783 | int stringLeng=resultStr.length(); |
779 | QString my; | 784 | QString my; |
780 | my.setNum( stringLeng, 10); | 785 | my.setNum( stringLeng, 10); |
781 | 786 | ||
782 | if( resultStr.length() > 2 && resultStr.length() < 130) { | 787 | if( resultStr.length() > 2 && resultStr.length() < 130) { |
783 | int titleInt = resultStr.find( " : ", 0, TRUE); | 788 | int titleInt = resultStr.find( " : ", 0, TRUE); |
784 | DlglistItemTitle = resultStr.left( titleInt); | 789 | DlglistItemTitle = resultStr.left( titleInt); |
785 | int yearInt = resultStr.find( " : ", titleInt+3, TRUE); | 790 | int yearInt = resultStr.find( " : ", titleInt+3, TRUE); |
786 | DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); | 791 | DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); |
787 | DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); | 792 | DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); |
788 | download_Etext(); | 793 | download_Etext(); |
789 | } | 794 | } |
790 | /* | 795 | /* |
791 | printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/ | 796 | printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/ |
792 | } | 797 | } |
793 | 798 | ||
794 | // bool LibraryDialog::UnzipIt( QString zipFile) { | 799 | // bool LibraryDialog::UnzipIt( QString zipFile) { |
795 | // //////////TODO findsome other way of dealingwithzip files. | 800 | // //////////TODO findsome other way of dealingwithzip files. |
796 | // ///usr/bin/unzip"; | 801 | // ///usr/bin/unzip"; |
797 | // if( QFile::exists( zipFile)) { | 802 | // if( QFile::exists( zipFile)) { |
798 | // // QString thatFile = local_library +"PGWHOLE.TXT"; | 803 | // // QString thatFile = local_library +"PGWHOLE.TXT"; |
799 | // QString cmd; | 804 | // QString cmd; |
800 | // #if defined(_WS_X11_) | 805 | // #if defined(_WS_X11_) |
801 | // cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; | 806 | // cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; |
802 | // #endif | 807 | // #endif |
803 | // #if defined(_WS_WIN_) | 808 | // #if defined(_WS_WIN_) |
804 | // QString temp= QDir::convertSeparators(local_library); | 809 | // QString temp= QDir::convertSeparators(local_library); |
805 | // zipFile=QDir::convertSeparators( zipFile); | 810 | // zipFile=QDir::convertSeparators( zipFile); |
806 | // cmd = temp+"unzip.exe -o " +zipFile/*newestLibraryFile */+" -d " + temp; | 811 | // cmd = temp+"unzip.exe -o " +zipFile/*newestLibraryFile */+" -d " + temp; |
807 | // #endif | 812 | // #endif |
808 | // #ifndef Q_WS_QWS | 813 | // #ifndef Q_WS_QWS |
809 | // // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; | 814 | // // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; |
810 | // cmd = "unzip " + zipFile; | 815 | // cmd = "unzip " + zipFile; |
811 | // #endif | 816 | // #endif |
812 | 817 | ||
813 | // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No); | 818 | // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No); |
814 | // if (exit==QMessageBox::Yes) { | 819 | // if (exit==QMessageBox::Yes) { |
815 | // odebug << "Issuing the command "+cmd << oendl; | 820 | // odebug << "Issuing the command "+cmd << oendl; |
816 | // #if defined(_WS_WIN_) | 821 | // #if defined(_WS_WIN_) |
817 | // WinExec( cmd, SW_HIDE ); | 822 | // WinExec( cmd, SW_HIDE ); |
818 | // #endif | 823 | // #endif |
819 | // #if defined(_WS_X11_) | 824 | // #if defined(_WS_X11_) |
820 | // system( cmd); | 825 | // system( cmd); |
821 | // #endif | 826 | // #endif |
822 | // #ifndef Q_WS_QWS | 827 | // #ifndef Q_WS_QWS |
823 | // system( cmd); | 828 | // system( cmd); |
824 | // #endif | 829 | // #endif |
825 | // // printf("unzip\n"); | 830 | // // printf("unzip\n"); |
826 | // // remove( zipFile /*newestLibraryFile*/); | 831 | // // remove( zipFile /*newestLibraryFile*/); |
827 | // return true; | 832 | // return true; |
828 | // } | 833 | // } |
829 | // else if(exit==QMessageBox::No) { | 834 | // else if(exit==QMessageBox::No) { |
830 | // // printf("unzip\n"); | 835 | // // printf("unzip\n"); |
831 | // return false; | 836 | // return false; |
832 | // } | 837 | // } |
833 | // } else { | 838 | // } else { |
834 | // // QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); | 839 | // // QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); |
835 | // return false; | 840 | // return false; |
836 | // } | 841 | // } |
837 | // return true; | 842 | // return true; |
838 | // } | 843 | // } |
839 | 844 | ||
840 | void LibraryDialog::sort() | 845 | void LibraryDialog::sort() |
841 | { | 846 | { |
842 | 847 | ||
843 | } | 848 | } |
844 | 849 | ||
845 | /* | 850 | /* |
846 | Downloads the current selected listitem*/ | 851 | Downloads the current selected listitem*/ |
847 | bool LibraryDialog::getItem(QListViewItem *it) | 852 | bool LibraryDialog::getItem(QListViewItem *it) |
848 | { | 853 | { |
849 | // odebug << "selected getItem" << oendl; | 854 | // odebug << "selected getItem" << oendl; |
850 | 855 | ||
851 | // DlglistItemNumber = it->text(0); | 856 | // DlglistItemNumber = it->text(0); |
852 | DlglistItemTitle = it->text(0); | 857 | DlglistItemTitle = it->text(0); |
853 | DlglistItemYear = it->text(2); | 858 | DlglistItemYear = it->text(2); |
854 | DlglistItemFile = it->text(3); | 859 | DlglistItemFile = it->text(3); |
855 | 860 | ||
856 | if(download_Etext()) { | 861 | if(download_Etext()) { |
857 | if(i_binary == 1) { | 862 | if(i_binary == 1) { |
858 | } | 863 | } |
859 | } | 864 | } |
860 | return true; | 865 | return true; |
861 | } | 866 | } |
862 | 867 | ||
863 | /* | 868 | /* |
864 | download button is pushed so we get the current items to download*/ | 869 | download button is pushed so we get the current items to download*/ |
865 | bool LibraryDialog::onButtonDownload() | 870 | bool LibraryDialog::onButtonDownload() |
866 | { | 871 | { |
867 | // odebug << "selected onButtonDownloadz" << oendl; | 872 | // odebug << "selected onButtonDownloadz" << oendl; |
868 | 873 | ||
869 | QListViewItemIterator it1( ListView1 ); | 874 | QListViewItemIterator it1( ListView1 ); |
870 | QListViewItemIterator it2( ListView2 ); | 875 | QListViewItemIterator it2( ListView2 ); |
871 | QListViewItemIterator it3( ListView3 ); | 876 | QListViewItemIterator it3( ListView3 ); |
872 | QListViewItemIterator it4( ListView4 ); | 877 | QListViewItemIterator it4( ListView4 ); |
873 | QListViewItemIterator it5( ListView5 ); | 878 | QListViewItemIterator it5( ListView5 ); |
874 | 879 | ||
875 | // iterate through all items of the listview | 880 | // iterate through all items of the listview |
876 | for ( ; it1.current(); ++it1 ) { | 881 | for ( ; it1.current(); ++it1 ) { |
877 | if ( it1.current()->isSelected() ) | 882 | if ( it1.current()->isSelected() ) |
878 | getItem(it1.current()); | 883 | getItem(it1.current()); |
879 | it1.current()->setSelected(FALSE); | 884 | it1.current()->setSelected(FALSE); |
880 | } | 885 | } |
881 | for ( ; it2.current(); ++it2 ) { | 886 | for ( ; it2.current(); ++it2 ) { |
882 | if ( it2.current()->isSelected() ) | 887 | if ( it2.current()->isSelected() ) |
883 | getItem(it2.current()); | 888 | getItem(it2.current()); |
884 | it2.current()->setSelected(FALSE); | 889 | it2.current()->setSelected(FALSE); |
885 | } | 890 | } |
886 | for ( ; it3.current(); ++it3 ) { | 891 | for ( ; it3.current(); ++it3 ) { |
887 | if ( it3.current()->isSelected() ) | 892 | if ( it3.current()->isSelected() ) |
888 | getItem(it3.current()); | 893 | getItem(it3.current()); |
889 | it3.current()->setSelected(FALSE); | 894 | it3.current()->setSelected(FALSE); |
890 | } | 895 | } |
891 | for ( ; it4.current(); ++it4 ) { | 896 | for ( ; it4.current(); ++it4 ) { |
892 | if ( it4.current()->isSelected() ) | 897 | if ( it4.current()->isSelected() ) |
893 | getItem(it4.current()); | 898 | getItem(it4.current()); |
894 | it4.current()->setSelected(FALSE); | 899 | it4.current()->setSelected(FALSE); |
895 | } | 900 | } |
896 | for ( ; it5.current(); ++it5 ) { | 901 | for ( ; it5.current(); ++it5 ) { |
897 | if ( it5.current()->isSelected() ) | 902 | if ( it5.current()->isSelected() ) |
898 | getItem(it5.current()); | 903 | getItem(it5.current()); |
899 | it5.current()->setSelected(FALSE); | 904 | it5.current()->setSelected(FALSE); |
900 | } | 905 | } |
901 | return true; | 906 | return true; |
902 | } | 907 | } |
903 | 908 | ||
904 | 909 | ||
905 | /* | 910 | /* |
906 | handles the sorting combo box */ | 911 | handles the sorting combo box */ |
907 | void LibraryDialog::comboSelect(int index) | 912 | void LibraryDialog::comboSelect(int index) |
908 | { | 913 | { |
909 | // odebug << "we are sorting" << oendl; | 914 | // odebug << "we are sorting" << oendl; |
910 | ListView1->setSorting( index, TRUE); | 915 | ListView1->setSorting( index, TRUE); |
911 | ListView2->setSorting( index, TRUE); | 916 | ListView2->setSorting( index, TRUE); |
912 | ListView3->setSorting( index, TRUE); | 917 | ListView3->setSorting( index, TRUE); |
913 | ListView4->setSorting( index, TRUE); | 918 | ListView4->setSorting( index, TRUE); |
914 | ListView5->setSorting( index, TRUE); | 919 | ListView5->setSorting( index, TRUE); |
915 | 920 | ||
916 | ListView1->sort(); | 921 | ListView1->sort(); |
917 | ListView2->sort(); | 922 | ListView2->sort(); |
918 | ListView3->sort(); | 923 | ListView3->sort(); |
919 | ListView4->sort(); | 924 | ListView4->sort(); |
920 | ListView5->sort(); | 925 | ListView5->sort(); |
921 | 926 | ||
922 | // ListView1->triggerUpdate(); | 927 | // ListView1->triggerUpdate(); |
923 | // ListView2->triggerUpdate(); | 928 | // ListView2->triggerUpdate(); |
924 | // ListView3->triggerUpdate(); | 929 | // ListView3->triggerUpdate(); |
925 | // ListView4->triggerUpdate(); | 930 | // ListView4->triggerUpdate(); |
926 | // ListView5->triggerUpdate(); | 931 | // ListView5->triggerUpdate(); |
927 | } | 932 | } |
928 | 933 | ||
929 | void LibraryDialog::newList() | 934 | void LibraryDialog::newList() |
930 | { | 935 | { |
931 | if(indexLoaded) { | 936 | if(indexLoaded) { |
932 | onButtonDownload(); | 937 | onButtonDownload(); |
933 | } else { | 938 | } else { |
934 | Output *outDlg; | 939 | Output *outDlg; |
935 | buttonNewList->setDown(TRUE); | 940 | buttonNewList->setDown(TRUE); |
936 | QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser"); | 941 | QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser"); |
937 | if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true); | 942 | if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true); |
938 | if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) { | 943 | if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) { |
939 | odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl; | 944 | odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl; |
940 | QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; | 945 | QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
941 | QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; | 946 | QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; |
942 | 947 | ||
943 | int result = QMessageBox::warning( this,"Download" | 948 | int result = QMessageBox::warning( this,"Download" |
944 | ,"<p>Ok to use /'wget/' to download a new library list?</P>" | 949 | ,"<p>Ok to use /'wget/' to download a new library list?</P>" |
945 | ,"Yes","No",0,0,1); | 950 | ,"Yes","No",0,0,1); |
946 | qApp->processEvents(); | 951 | qApp->processEvents(); |
947 | if(result == 0) { | 952 | if(result == 0) { |
948 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); | 953 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); |
949 | outDlg->showMaximized(); | 954 | outDlg->showMaximized(); |
950 | outDlg->show(); | 955 | outDlg->show(); |
951 | qApp->processEvents(); | 956 | qApp->processEvents(); |
952 | FILE *fp; | 957 | FILE *fp; |
953 | char line[130]; | 958 | char line[130]; |
954 | outDlg->OutputEdit->append( tr("Running wget") ); | 959 | outDlg->OutputEdit->append( tr("Running wget") ); |
955 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 960 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
956 | sleep(1); | 961 | sleep(1); |
957 | fp = popen( (const char *) cmd, "r"); | 962 | fp = popen( (const char *) cmd, "r"); |
958 | if ( !fp ) { | 963 | if ( !fp ) { |
959 | } else { | 964 | } else { |
960 | odebug << "Issuing the command\n"+cmd << oendl; | 965 | odebug << "Issuing the command\n"+cmd << oendl; |
961 | // system(cmd); | 966 | // system(cmd); |
962 | while ( fgets( line, sizeof line, fp)) { | 967 | while ( fgets( line, sizeof line, fp)) { |
963 | outDlg->OutputEdit->append(line); | 968 | outDlg->OutputEdit->append(line); |
964 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 969 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
965 | } | 970 | } |
966 | pclose(fp); | 971 | pclose(fp); |
967 | outDlg->OutputEdit->append("Finished downloading\n"); | 972 | outDlg->OutputEdit->append("Finished downloading\n"); |
968 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 973 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
969 | qApp->processEvents(); | 974 | qApp->processEvents(); |
970 | 975 | ||
971 | // if( QFile(gutenindex1).exists() ) { | 976 | // if( QFile(gutenindex1).exists() ) { |
972 | // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; | 977 | // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
973 | // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) | 978 | // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) |
974 | // odebug << "renaming error" << oendl; | 979 | // odebug << "renaming error" << oendl; |
975 | // } | 980 | // } |
976 | 981 | ||
977 | } | 982 | } |
978 | // outDlg->close(); | 983 | // outDlg->close(); |
979 | FindLibrary(); | 984 | FindLibrary(); |
980 | if(outDlg) delete outDlg; | 985 | if(outDlg) delete outDlg; |
981 | } | 986 | } |
982 | buttonNewList->setDown(FALSE); | 987 | buttonNewList->setDown(FALSE); |
983 | } else { | 988 | } else { |
984 | QMessageBox::message("Note","Could not change directories"); | 989 | QMessageBox::message("Note","Could not change directories"); |
985 | } | 990 | } |
986 | // if(outDlg) | 991 | // if(outDlg) |
987 | // delete outDlg; | 992 | // delete outDlg; |
988 | } | 993 | } |
989 | } | 994 | } |
990 | 995 | ||
991 | bool LibraryDialog::moreInfo() | 996 | bool LibraryDialog::moreInfo() |
992 | { | 997 | { |
993 | 998 | ||
994 | QListViewItem * item; | 999 | QListViewItem * item; |
995 | item = 0; | 1000 | item = 0; |
996 | QString titleString; | 1001 | QString titleString; |
997 | item = ListView1->currentItem(); | 1002 | item = ListView1->currentItem(); |
998 | if( item != 0) { | 1003 | if( item != 0) { |
999 | titleString = item->text(0); | 1004 | titleString = item->text(0); |
1000 | ListView1->clearSelection(); | 1005 | ListView1->clearSelection(); |
1001 | item = 0; | 1006 | item = 0; |
1002 | } | 1007 | } |
1003 | if( item == 0) | 1008 | if( item == 0) |
1004 | item = ListView2->currentItem(); | 1009 | item = ListView2->currentItem(); |
1005 | if( item != 0) { | 1010 | if( item != 0) { |
1006 | titleString = item->text(0); | 1011 | titleString = item->text(0); |
1007 | ListView2->clearSelection(); | 1012 | ListView2->clearSelection(); |
1008 | item = 0; | 1013 | item = 0; |
1009 | } | 1014 | } |
1010 | if( item == 0) | 1015 | if( item == 0) |
1011 | item = ListView3->currentItem(); | 1016 | item = ListView3->currentItem(); |
1012 | if( item != 0) { | 1017 | if( item != 0) { |
1013 | titleString = item->text(0); | 1018 | titleString = item->text(0); |
1014 | ListView3->clearSelection(); | 1019 | ListView3->clearSelection(); |
1015 | item = 0; | 1020 | item = 0; |
1016 | } | 1021 | } |
1017 | if( item == 0) | 1022 | if( item == 0) |
1018 | item = ListView4->currentItem(); | 1023 | item = ListView4->currentItem(); |
1019 | if( item != 0) { | 1024 | if( item != 0) { |
1020 | titleString = item->text(0); | 1025 | titleString = item->text(0); |
1021 | ListView4->clearSelection(); | 1026 | ListView4->clearSelection(); |
1022 | item = 0; | 1027 | item = 0; |
1023 | } | 1028 | } |
1024 | if( item == 0) | 1029 | if( item == 0) |
1025 | item = ListView5->currentItem(); | 1030 | item = ListView5->currentItem(); |
1026 | if( item != 0) { | 1031 | if( item != 0) { |
1027 | titleString = item->text(0); | 1032 | titleString = item->text(0); |
1028 | ListView5->clearSelection(); | 1033 | ListView5->clearSelection(); |
1029 | item = 0; | 1034 | item = 0; |
1030 | } | 1035 | } |
1031 | item=0; | 1036 | item=0; |
1032 | if(titleString.length()>2) { | 1037 | if(titleString.length()>2) { |
1033 | odebug << "Title is "+titleString << oendl; | 1038 | odebug << "Title is "+titleString << oendl; |
1034 | titleString.replace( QRegExp("\\s"), "%20"); | 1039 | titleString.replace( QRegExp("\\s"), "%20"); |
1035 | titleString.replace( QRegExp("'"), "%20"); | 1040 | titleString.replace( QRegExp("'"), "%20"); |
1036 | titleString.replace( QRegExp("\""), "%20"); | 1041 | titleString.replace( QRegExp("\""), "%20"); |
1037 | titleString.replace( QRegExp("&"), "%20"); | 1042 | titleString.replace( QRegExp("&"), "%20"); |
1038 | QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search"; | 1043 | QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search"; |
1039 | cmd="opera "+cmd; | 1044 | cmd="opera "+cmd; |
1040 | system(cmd); | 1045 | system(cmd); |
1041 | } else | 1046 | } else |
1042 | QMessageBox::message( "Note","<p>If you select a title, this will search google.com for that title.</p>"); | 1047 | QMessageBox::message( "Note","<p>If you select a title, this will search google.com for that title.</p>"); |
1043 | return true; | 1048 | return true; |
1044 | 1049 | ||
1045 | } | 1050 | } |
1046 | 1051 | ||
1047 | /* | 1052 | /* |
1048 | This loads the library Index*/ | 1053 | This loads the library Index*/ |
1049 | void LibraryDialog::FindLibrary() | 1054 | void LibraryDialog::FindLibrary() |
1050 | { | 1055 | { |
1051 | buttonLibrary->setDown(TRUE); | 1056 | buttonLibrary->setDown(TRUE); |
1052 | 1057 | ||
1053 | qApp->processEvents(); | 1058 | qApp->processEvents(); |
1054 | if( QFile( new_index).exists() /* && this->isHidden() */) { | 1059 | if( QFile( new_index).exists() /* && this->isHidden() */) { |
1055 | newindexLib.setName( new_index); | 1060 | newindexLib.setName( new_index); |
1056 | indexLib.setName( new_index); | 1061 | indexLib.setName( new_index); |
1057 | odebug << "index file is "+ new_index << oendl; | 1062 | odebug << "index file is "+ new_index << oendl; |
1058 | Newlibrary(); | 1063 | Newlibrary(); |
1059 | } else { | 1064 | } else { |
1060 | newindexLib.setName( old_index); | 1065 | newindexLib.setName( old_index); |
1061 | indexLib.setName( old_index); | 1066 | indexLib.setName( old_index); |
1062 | odebug << "new index nameis "+ old_index << oendl; | 1067 | odebug << "new index nameis "+ old_index << oendl; |
1063 | Library(); | 1068 | Library(); |
1064 | } | 1069 | } |
1065 | indexLoaded=true; | 1070 | indexLoaded=true; |
1066 | buttonSearch->setEnabled(TRUE); | 1071 | buttonSearch->setEnabled(TRUE); |
1067 | moreInfoButton->setEnabled(TRUE); | 1072 | moreInfoButton->setEnabled(TRUE); |
1068 | 1073 | ||
1069 | buttonLibrary->setDown(FALSE); | 1074 | buttonLibrary->setDown(FALSE); |
1070 | buttonNewList->setText("Download"); | 1075 | buttonNewList->setText("Download"); |
1071 | qApp->processEvents(); | 1076 | qApp->processEvents(); |
1072 | 1077 | ||
1073 | } | 1078 | } |