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