summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
index 157a3da..5b22b00 100644
--- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
@@ -1,863 +1,863 @@
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 <qpe/applnk.h> 16#include <qpe/applnk.h>
17#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
18#include <qpe/qpedialog.h> 18#include <qpe/qpedialog.h>
19 19
20#include "LibraryDialog.h" 20#include "LibraryDialog.h"
21#include "output.h" 21#include "output.h"
22 22
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24#include <qmultilineedit.h> 24#include <qmultilineedit.h>
25//#include <qlayout.h> 25//#include <qlayout.h>
26 26
27#include <unistd.h> 27#include <unistd.h>
28#include <stdio.h> 28#include <stdio.h>
29#include <stdlib.h> 29#include <stdlib.h>
30 30
31/* 31/*
32 * The dialog will by default be modeless, unless you set 'modal' to 32 * The dialog will by default be modeless, unless you set 'modal' to
33 * TRUE to construct a modal dialog. */ 33 * TRUE to construct a modal dialog. */
34LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool modal, WFlags fl ) 34LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool modal, WFlags fl )
35 : QDialog( parent, name, true/* modal*/, fl ) 35 : QDialog( parent, name, true/* modal*/, fl )
36{ 36{
37 if ( !name ) 37 if ( !name )
38 setName( "LibraryDialog" ); 38 setName( "LibraryDialog" );
39 indexLoaded=false; 39 indexLoaded=false;
40 initDialog(); 40 initDialog();
41 41
42 // this->setMaximumWidth(240); 42 // this->setMaximumWidth(240);
43 43
44 index = "GUTINDEX.ALL"; 44 index = "GUTINDEX.ALL";
45 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 45 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
46 local_index = local_library + index; 46 local_index = local_library + index;
47 47
48 QString iniFile ; 48 QString iniFile ;
49 iniFile = QPEApplication::qpeDir()+"/etc/gutenbrowser/gutenbrowserrc"; 49 iniFile = QPEApplication::qpeDir()+"/etc/gutenbrowser/gutenbrowserrc";
50 50
51 new_index =QPEApplication::qpeDir()+"/etc/gutenbrowser/PGWHOLE.TXT"; 51 new_index =QPEApplication::qpeDir()+"/etc/gutenbrowser/PGWHOLE.TXT";
52 52
53 old_index = QPEApplication::qpeDir()+"/etc/gutenbrowser/GUTINDEX.ALL"; 53 old_index = QPEApplication::qpeDir()+"/etc/gutenbrowser/GUTINDEX.ALL";
54 // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 54 // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
55 55
56 // iniFile = local_library+"gutenbrowserrc"; 56 // iniFile = local_library+"gutenbrowserrc";
57 // new_index = local_library + "PGWHOLE.TXT"; 57 // new_index = local_library + "PGWHOLE.TXT";
58 // old_index = local_library + "GUTINDEX.ALL"; 58 // old_index = local_library + "GUTINDEX.ALL";
59 59
60 Config config("Gutenbrowser"); 60 Config config("Gutenbrowser");
61 61
62 config.setGroup( "HttpServer" ); 62 config.setGroup( "HttpServer" );
63 proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); 63 proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org");
64 64
65 config.setGroup( "FTPsite" ); 65 config.setGroup( "FTPsite" );
66 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); 66 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
67 qDebug("Library Dialog: ftp_host is "+ftp_host); 67 qDebug("Library Dialog: ftp_host is "+ftp_host);
68 // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); 68 // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) );
69 // ftp_host=ftp_host.stripWhiteSpace(); 69 // ftp_host=ftp_host.stripWhiteSpace();
70 ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); 70 ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
71 71
72 i_binary = 0; 72 i_binary = 0;
73 73
74 config.setGroup("SortAuth"); 74 config.setGroup("SortAuth");
75 if( config.readEntry("authSort", "FALSE") == "TRUE") 75 if( config.readEntry("authSort", "FALSE") == "TRUE")
76 authBox->setChecked(TRUE); 76 authBox->setChecked(TRUE);
77 77
78 config.setGroup("General"); 78 config.setGroup("General");
79 downDir =config.readEntry( "DownloadDirectory",local_library); 79 downDir =config.readEntry( "DownloadDirectory",local_library);
80 qDebug("downDir is "+downDir); 80 qDebug("downDir is "+downDir);
81 newindexLib.setName( old_index); 81 newindexLib.setName( old_index);
82 indexLib.setName( old_index); 82 indexLib.setName( old_index);
83 83
84 new QPEDialogListener(this); 84 new QPEDialogListener(this);
85} 85}
86 86
87LibraryDialog::~LibraryDialog() 87LibraryDialog::~LibraryDialog()
88{ 88{
89 delete QList_Item2; 89 // delete QList_Item2;
90 delete QList_Item1; 90 // delete QList_Item1;
91 delete QList_Item3; 91 // delete QList_Item3;
92 delete QList_Item4; 92 // delete QList_Item4;
93 delete QList_Item5; 93 // delete QList_Item5;
94 94
95 saveConfig(); 95 //saveConfig();
96} 96}
97 97
98 /*This groks using PGWHOLE.TXT */ 98 /*This groks using PGWHOLE.TXT */
99void LibraryDialog::Newlibrary() 99void LibraryDialog::Newlibrary()
100{ 100{
101#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files 101#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files
102 //qDebug("Opening new library index %s",newindexLib); 102 //qDebug("Opening new library index %s",newindexLib);
103 if ( newindexLib.open( IO_ReadOnly) ) { 103 if ( newindexLib.open( IO_ReadOnly) ) {
104 setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully 104 setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully
105 QTextStream indexStream( &newindexLib ); 105 QTextStream indexStream( &newindexLib );
106 QString indexLine; 106 QString indexLine;
107 while ( !indexStream.atEnd() ) { // until end of file.. 107 while ( !indexStream.atEnd() ) { // until end of file..
108 indexLine = indexStream.readLine(); 108 indexLine = indexStream.readLine();
109 if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { 109 if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) {
110 year = indexLine.mid(4,4); 110 year = indexLine.mid(4,4);
111 year = year.stripWhiteSpace(); 111 year = year.stripWhiteSpace();
112 file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); 112 file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 );
113 file = file.stripWhiteSpace(); 113 file = file.stripWhiteSpace();
114 number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); 114 number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 );
115 if( year.toInt() < 1984) 115 if( year.toInt() < 1984)
116 number = number.left( number.length() -1 ); 116 number = number.left( number.length() -1 );
117 number = number.stripWhiteSpace(); 117 number = number.stripWhiteSpace();
118 title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); 118 title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() );
119 title = title.stripWhiteSpace(); 119 title = title.stripWhiteSpace();
120 120
121 getAuthor(); // groks author 121 getAuthor(); // groks author
122 author = author.stripWhiteSpace(); 122 author = author.stripWhiteSpace();
123 if (authBox->isChecked()) { // this reverses the first name and last name of the author 123 if (authBox->isChecked()) { // this reverses the first name and last name of the author
124 // qDebug("Sorting last name first"); 124 // qDebug("Sorting last name first");
125 QString lastName, firstName=""; 125 QString lastName, firstName="";
126 int finder=author.findRev( ' ', -1, TRUE); 126 int finder=author.findRev( ' ', -1, TRUE);
127 lastName=author.right( author.length()-finder); 127 lastName=author.right( author.length()-finder);
128 firstName=author.left(finder); 128 firstName=author.left(finder);
129 lastName=lastName.stripWhiteSpace(); 129 lastName=lastName.stripWhiteSpace();
130 firstName=firstName.stripWhiteSpace(); 130 firstName=firstName.stripWhiteSpace();
131 131
132 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names 132 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names
133 author=lastName+", "+firstName; 133 author=lastName+", "+firstName;
134 } 134 }
135 135
136 if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) { 136 if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) {
137 137
138 // fill string list or something to be able to resort the whole library 138 // fill string list or something to be able to resort the whole library
139 if( author.isEmpty() ) 139 if( author.isEmpty() )
140 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); 140 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file );
141 else { 141 else {
142 142
143 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || 143 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) ||
144 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) 144 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) )
145 QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); 145 QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file );
146 146
147 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || 147 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) ||
148 (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) 148 (author.left(1) >= QString("g") && author.left(1) <= QString("m")) )
149 QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file ); 149 QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file );
150 150
151 else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || 151 else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) ||
152 (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) 152 (author.left(1) >= QString("n") && author.left(1) <= QString("r")) )
153 QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file ); 153 QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file );
154 154
155 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || 155 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) ||
156 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) 156 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) )
157 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); 157 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file );
158 158
159 else 159 else
160 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); 160 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file );
161 } 161 }
162 } 162 }
163 }// end if 163 }// end if
164 }// end while 164 }// end while
165 newindexLib.close(); 165 newindexLib.close();
166 } 166 }
167#ifndef Q_WS_QWS 167#ifndef Q_WS_QWS
168 setCursor( arrowCursor); 168 setCursor( arrowCursor);
169#endif 169#endif
170#endif 170#endif
171} // end Newlibrary() 171} // end Newlibrary()
172 172
173 173
174void LibraryDialog::Library() 174void LibraryDialog::Library()
175{// old library groking method 175{// old library groking method
176 176
177 ListView1->clear(); 177 ListView1->clear();
178 ListView2->clear(); 178 ListView2->clear();
179 ListView3->clear(); 179 ListView3->clear();
180 ListView4->clear(); 180 ListView4->clear();
181 ListView5->clear(); 181 ListView5->clear();
182 182
183 qDebug("opening GUTINDEX.ALL file"); 183 qDebug("opening GUTINDEX.ALL file");
184 IDontKnowWhy = ""; 184 IDontKnowWhy = "";
185 if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully 185 if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully
186 QTextStream indexStream( &indexLib ); 186 QTextStream indexStream( &indexLib );
187 QString indexLine; 187 QString indexLine;
188 qApp->processEvents(); 188 qApp->processEvents();
189 // int jig; 189 // int jig;
190 while ( !indexStream.eof() ) { 190 while ( !indexStream.eof() ) {
191 191
192 indexLine = indexStream.readLine(); 192 indexLine = indexStream.readLine();
193 if ( indexLine != "") { 193 if ( indexLine != "") {
194 if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) { 194 if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) {
195 // month = indexLine.left( 3); 195 // month = indexLine.left( 3);
196 year = indexLine.mid(4,4); 196 year = indexLine.mid(4,4);
197 // title = indexLine.mid( 9, 50); 197 // title = indexLine.mid( 9, 50);
198 file = indexLine.mid(60,12); 198 file = indexLine.mid(60,12);
199 if(file.left(1).find("[",0,TRUE) != -1) 199 if(file.left(1).find("[",0,TRUE) != -1)
200 file.remove(1,1); 200 file.remove(1,1);
201 if( file.find("]",0,TRUE) != -1) 201 if( file.find("]",0,TRUE) != -1)
202 file = file.left( file.find("]",0,TRUE)); 202 file = file.left( file.find("]",0,TRUE));
203 //qDebug("file is "+file); 203 //qDebug("file is "+file);
204 /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); 204 /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 );
205 number = indexLine.mid(55,5); 205 number = indexLine.mid(55,5);
206 number = number.stripWhiteSpace(); 206 number = number.stripWhiteSpace();
207 // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); 207 // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() );
208 title = indexLine.mid( 9, 50 ); 208 title = indexLine.mid( 9, 50 );
209 title = title.stripWhiteSpace(); 209 title = title.stripWhiteSpace();
210 //qDebug("title is "+title); 210 //qDebug("title is "+title);
211 getAuthor(); // grok author 211 getAuthor(); // grok author
212 author = author.stripWhiteSpace(); 212 author = author.stripWhiteSpace();
213 //qDebug("author is "+author); 213 //qDebug("author is "+author);
214 if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author 214 if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author
215 QString lastName, firstName=""; 215 QString lastName, firstName="";
216 int finder=author.findRev( ' ', -1, TRUE); 216 int finder=author.findRev( ' ', -1, TRUE);
217 lastName=author.right( author.length()-finder); 217 lastName=author.right( author.length()-finder);
218 firstName=author.left(finder); 218 firstName=author.left(finder);
219 lastName=lastName.stripWhiteSpace(); 219 lastName=lastName.stripWhiteSpace();
220 firstName=firstName.stripWhiteSpace(); 220 firstName=firstName.stripWhiteSpace();
221 221
222 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names 222 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names
223 author=lastName+", "+firstName; 223 author=lastName+", "+firstName;
224 } 224 }
225 225
226 if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) /*&& (file.find( "]",0, TRUE))*/ ) { 226 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 227 // fill string list or something to be able to sort by Author
228 if( author.isEmpty() ) 228 if( author.isEmpty() )
229 QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); 229 QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file );
230 else { 230 else {
231 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || 231 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) ||
232 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) 232 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) )
233 QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); 233 QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file );
234 234
235 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || 235 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) ||
236 (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) 236 (author.left(1) >= QString("g") && author.left(1) <= QString("m")) )
237 QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); 237 QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file );
238 238
239 else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || 239 else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) ||
240 (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) 240 (author.left(1) >= QString("n") && author.left(1) <= QString("r")) )
241 QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file ); 241 QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file );
242 242
243 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || 243 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) ||
244 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) 244 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) )
245 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); 245 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file );
246 } 246 }
247 } 247 }
248 } 248 }
249 } 249 }
250 } 250 }
251 indexLib.close(); 251 indexLib.close();
252 } else { 252 } else {
253 QString sMsg; 253 QString sMsg;
254 sMsg = ( tr("Error opening local library index:\n "))+local_index; 254 sMsg = ( tr("Error opening local library index:\n "))+local_index;
255 QMessageBox::message( "Error",sMsg); 255 QMessageBox::message( "Error",sMsg);
256 } 256 }
257 257
258} //end Library() 258} //end Library()
259 259
260 260
261 /* 261 /*
262 Groks the author out of the title */ 262 Groks the author out of the title */
263bool LibraryDialog::getAuthor() 263bool LibraryDialog::getAuthor()
264{ 264{
265 if( title.contains( ", by", TRUE)) { 265 if( title.contains( ", by", TRUE)) {
266 int auth; 266 int auth;
267 auth = title.find(", by", 0, TRUE); 267 auth = title.find(", by", 0, TRUE);
268 author = title.right(title.length() - (auth + 4) ); 268 author = title.right(title.length() - (auth + 4) );
269 if( int finder = author.find("[", 0, TRUE)) { 269 if( int finder = author.find("[", 0, TRUE)) {
270 author = author.left(finder); 270 author = author.left(finder);
271 } 271 }
272 } 272 }
273 else if ( title.contains( "by, ", TRUE) ) { 273 else if ( title.contains( "by, ", TRUE) ) {
274 int auth; 274 int auth;
275 auth = title.find("by, ", 0, TRUE); 275 auth = title.find("by, ", 0, TRUE);
276 author = title.right(title.length() - (auth + 4) ); 276 author = title.right(title.length() - (auth + 4) );
277 if( int finder = author.find("[", 0, TRUE)) { 277 if( int finder = author.find("[", 0, TRUE)) {
278 author = author.left( finder); 278 author = author.left( finder);
279 } 279 }
280 } 280 }
281 else if ( title.contains( " by", TRUE) ) { 281 else if ( title.contains( " by", TRUE) ) {
282 int auth; 282 int auth;
283 auth = title.find(" by", 0, TRUE); 283 auth = title.find(" by", 0, TRUE);
284 author = title.right(title.length() - (auth + 3) ); 284 author = title.right(title.length() - (auth + 3) );
285 if( int finder = author.find("[", 0, TRUE)) { 285 if( int finder = author.find("[", 0, TRUE)) {
286 author = author.left( finder); 286 author = author.left( finder);
287 } 287 }
288 } 288 }
289 else if ( title.contains( "by ", TRUE) ) { 289 else if ( title.contains( "by ", TRUE) ) {
290 int auth; 290 int auth;
291 auth = title.find("by ", 0, TRUE); 291 auth = title.find("by ", 0, TRUE);
292 author = title.right(title.length() - (auth + 3) ); 292 author = title.right(title.length() - (auth + 3) );
293 if( int finder = author.find("[", 0, TRUE)) { 293 if( int finder = author.find("[", 0, TRUE)) {
294 author = author.left( finder); 294 author = author.left( finder);
295 } 295 }
296 } 296 }
297 else if ( title.contains( ",", TRUE) ) { 297 else if ( title.contains( ",", TRUE) ) {
298 int auth; 298 int auth;
299 auth = title.find(",", 0, TRUE); 299 auth = title.find(",", 0, TRUE);
300 author = title.right( title.length() - (auth + 1) ); 300 author = title.right( title.length() - (auth + 1) );
301 if ( author.contains( ",", TRUE) ) { 301 if ( author.contains( ",", TRUE) ) {
302 int auth; 302 int auth;
303 auth = author.find(",", 0, TRUE); 303 auth = author.find(",", 0, TRUE);
304 author = author.right( author.length() - (auth + 1) ); 304 author = author.right( author.length() - (auth + 1) );
305 } 305 }
306 if( int finder = author.find("[", 0, TRUE)) { 306 if( int finder = author.find("[", 0, TRUE)) {
307 author = author.left( finder); 307 author = author.left( finder);
308 } 308 }
309 } 309 }
310 else if ( title.contains( "/", TRUE) ) { 310 else if ( title.contains( "/", TRUE) ) {
311 int auth; 311 int auth;
312 auth = title.find("/", 0, TRUE); 312 auth = title.find("/", 0, TRUE);
313 author = title.right(title.length() - (auth + 1) ); 313 author = title.right(title.length() - (auth + 1) );
314 if( int finder = author.find("[", 0, TRUE)) { 314 if( int finder = author.find("[", 0, TRUE)) {
315 author = author.left( finder); 315 author = author.left( finder);
316 } 316 }
317 } 317 }
318 else if ( title.contains( "of", TRUE) ) { 318 else if ( title.contains( "of", TRUE) ) {
319 int auth; 319 int auth;
320 auth = title.find("of", 0, TRUE); 320 auth = title.find("of", 0, TRUE);
321 author = title.right(title.length() - (auth + 2) ); 321 author = title.right(title.length() - (auth + 2) );
322 if( int finder = author.find("[", 0, TRUE)) 322 if( int finder = author.find("[", 0, TRUE))
323 { 323 {
324 author = author.left( finder); 324 author = author.left( finder);
325 } 325 }
326 } else { 326 } else {
327 author = ""; 327 author = "";
328 } 328 }
329 if ( author.contains("et. al")) { 329 if ( author.contains("et. al")) {
330 int auth; 330 int auth;
331 auth = author.find("et. al", 0, TRUE); 331 auth = author.find("et. al", 0, TRUE);
332 author = author.left( auth ); 332 author = author.left( auth );
333 } 333 }
334 if ( author.contains("#")) { 334 if ( author.contains("#")) {
335 int auth; 335 int auth;
336 auth = author.find("#", 0, TRUE); 336 auth = author.find("#", 0, TRUE);
337 author = author.left( auth); 337 author = author.left( auth);
338 } 338 }
339 if ( author.contains("(")) { 339 if ( author.contains("(")) {
340 int auth; 340 int auth;
341 auth = author.find("(", 0, TRUE); 341 auth = author.find("(", 0, TRUE);
342 author = author.left( auth); 342 author = author.left( auth);
343 } 343 }
344 if ( author.contains("et al")) { 344 if ( author.contains("et al")) {
345 int auth; 345 int auth;
346 auth = author.find("et al", 0, TRUE); 346 auth = author.find("et al", 0, TRUE);
347 author = author.left( auth ); 347 author = author.left( auth );
348 } 348 }
349 QRegExp r = QRegExp("[0-9]", TRUE, FALSE); 349 QRegExp r = QRegExp("[0-9]", TRUE, FALSE);
350 if ( author.left(2).find( r) != -1 ) { 350 if ( author.left(2).find( r) != -1 ) {
351 author = ""; 351 author = "";
352 } 352 }
353 // if( author.contains(" ", TRUE)) { 353 // if( author.contains(" ", TRUE)) {
354 // int suth = author.findRev(" ", -1, TRUE); 354 // int suth = author.findRev(" ", -1, TRUE);
355 // author = author.right( author.length() - suth); 355 // author = author.right( author.length() - suth);
356 // } 356 // }
357 357
358 // title 358 // title
359 // author 359 // author
360 return true; 360 return true;
361}////// end getAuthor() 361}////// end getAuthor()
362 362
363 /* 363 /*
364 selected one etext*/ 364 selected one etext*/
365void LibraryDialog::select_title( QListViewItem * item) 365void LibraryDialog::select_title( QListViewItem * item)
366{ 366{
367 if(item != NULL) { 367 if(item != NULL) {
368 i++; 368 i++;
369 int index = tabWidget->currentPageIndex(); 369 int index = tabWidget->currentPageIndex();
370 DlglistItemTitle = item->text(0); 370 DlglistItemTitle = item->text(0);
371 DlglistItemYear = item->text(2); 371 DlglistItemYear = item->text(2);
372 DlglistItemFile = item->text(3); 372 DlglistItemFile = item->text(3);
373 switch (index) { 373 switch (index) {
374 case 0: { 374 case 0: {
375 ListView1->clearSelection(); 375 ListView1->clearSelection();
376 } 376 }
377 break; 377 break;
378 case 1: { 378 case 1: {
379 ListView2->clearSelection(); 379 ListView2->clearSelection();
380 } 380 }
381 break; 381 break;
382 case 2: { 382 case 2: {
383 ListView3->clearSelection(); 383 ListView3->clearSelection();
384 } 384 }
385 break; 385 break;
386 case 3: { 386 case 3: {
387 ListView4->clearSelection(); 387 ListView4->clearSelection();
388 } 388 }
389 break; 389 break;
390 case 4: { 390 case 4: {
391 ListView5->clearSelection(); 391 ListView5->clearSelection();
392 } 392 }
393 break; 393 break;
394 }; 394 };
395 } 395 }
396 396
397 if(DlglistItemTitle.length()>2) { 397 if(DlglistItemTitle.length()>2) {
398 // DlglistItemNumber = item->text(0); 398 // DlglistItemNumber = item->text(0);
399 item = 0; 399 item = 0;
400 qDebug( "string from librarydialog is:%s %s %s", DlglistItemYear.latin1(),DlglistItemFile.latin1(),DlglistItemNumber.latin1()); 400 qDebug( "string from librarydialog is:%s %s %s", DlglistItemYear.latin1(),DlglistItemFile.latin1(),DlglistItemNumber.latin1());
401 qDebug("Title is "+DlglistItemTitle); 401 qDebug("Title is "+DlglistItemTitle);
402 402
403 // check for connection here 403 // check for connection here
404 // if( get_extext()) 404 // if( get_extext())
405 405
406 if(download_Etext()) { 406 if(download_Etext()) {
407 // qDebug("get here 2"); 407 // qDebug("get here 2");
408 if(i_binary == 1) { 408 if(i_binary == 1) {
409 409
410 } 410 }
411 if(checkBox->isChecked () ) { 411 if(checkBox->isChecked () ) {
412 accept(); 412 accept();
413 } 413 }
414 } 414 }
415 } 415 }
416} 416}
417 417
418bool LibraryDialog::download_Etext() 418bool LibraryDialog::download_Etext()
419{ // ftp method 419{ // ftp method
420 // might have to use old gpl'd ftp for embedded!! 420 // might have to use old gpl'd ftp for embedded!!
421 Config cfg("Gutenbrowser"); 421 Config cfg("Gutenbrowser");
422 cfg.setGroup("FTPsite"); 422 cfg.setGroup("FTPsite");
423 ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org"); 423 ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org");
424 ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg"); 424 ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg");
425 425
426 qDebug("about to network dialog"); 426 qDebug("about to network dialog");
427 QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile; 427 QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile;
428 428
429 //////////////////// FIXME- if 'x' is part of real name.... 429 //////////////////// 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)); 430 NewlistItemFile = DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).left(DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).find("x", 1, FALSE));
431 431
432 if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) { 432 if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) {
433 NewlistItemFile.replace( 0,4, DlglistItemFile.left(4)); 433 NewlistItemFile.replace( 0,4, DlglistItemFile.left(4));
434 qDebug("NewlistItemFile is now "+NewlistItemFile); 434 qDebug("NewlistItemFile is now "+NewlistItemFile);
435 } 435 }
436 NewlistItemYear = DlglistItemYear.right(2); 436 NewlistItemYear = DlglistItemYear.right(2);
437 int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10); 437 int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10);
438 qDebug(NewlistItemYear); 438 qDebug(NewlistItemYear);
439 if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) { 439 if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) {
440 NewlistItemYear = "90"; 440 NewlistItemYear = "90";
441 } 441 }
442 Edir ="etext" +NewlistItemYear; 442 Edir ="etext" +NewlistItemYear;
443 dir= ftp_base_dir + "/etext" +NewlistItemYear+"/"; 443 dir= ftp_base_dir + "/etext" +NewlistItemYear+"/";
444 if( ftp_base_dir.find("=",0,true) ) 444 if( ftp_base_dir.find("=",0,true) )
445 ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1); 445 ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1);
446 446
447 networkUrl= "ftp://"+ftp_host+dir; 447 networkUrl= "ftp://"+ftp_host+dir;
448 448
449 outputFile=local_library+".guten_temp"; 449 outputFile=local_library+".guten_temp";
450 //qDebug("Download file:%s",NewlistItemFile.latin1() ); 450 //qDebug("Download file:%s",NewlistItemFile.latin1() );
451 qDebug("Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile); 451 qDebug("Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile);
452 QStringList networkList; 452 QStringList networkList;
453 networkList.append((const char *)ftp_host); 453 networkList.append((const char *)ftp_host);
454 networkList.append((const char *)dir); 454 networkList.append((const char *)dir);
455 networkList.append((const char *)outputFile); 455 networkList.append((const char *)outputFile);
456 networkList.append((const char *)NewlistItemFile); 456 networkList.append((const char *)NewlistItemFile);
457//<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile; 457//<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile;
458 458
459 NetworkDialog *NetworkDlg; 459 NetworkDialog *NetworkDlg;
460 NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList); 460 NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList);
461 461
462 462
463 if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer 463 if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer
464 File_Name= NetworkDlg->localFileName; 464 File_Name= NetworkDlg->localFileName;
465 qDebug("back to Library from Network Dialog"); 465 qDebug("back to Library from Network Dialog");
466 qDebug("Just downloaded "+NetworkDlg->localFileName); 466 qDebug("Just downloaded "+NetworkDlg->localFileName);
467 467
468 // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found 468 // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found
469 // QString oldName=File_Name; 469 // QString oldName=File_Name;
470 // File_Name.replace(0,local_library.length(),downDir); 470 // File_Name.replace(0,local_library.length(),downDir);
471 // qDebug("File_Name now is "+File_Name); 471 // qDebug("File_Name now is "+File_Name);
472 472
473 // } 473 // }
474 // rename .txt to .etx 474 // rename .txt to .etx
475 if(NetworkDlg->successDownload) { 475 if(NetworkDlg->successDownload) {
476 qDebug("Filename is "+File_Name); 476 qDebug("Filename is "+File_Name);
477 if(File_Name.right(4)==".txt") { 477 if(File_Name.right(4)==".txt") {
478 QString s_fileName=File_Name; 478 QString s_fileName=File_Name;
479 s_fileName.replace( s_fileName.length()-3,3,"gtn"); 479 s_fileName.replace( s_fileName.length()-3,3,"gtn");
480 // s_fileName.replace( s_fileName.length()-3,3,"etx"); 480 // s_fileName.replace( s_fileName.length()-3,3,"etx");
481 rename(File_Name.latin1(),s_fileName.latin1()); 481 rename(File_Name.latin1(),s_fileName.latin1());
482 File_Name=s_fileName; 482 File_Name=s_fileName;
483 483
484 qDebug("Filename is now "+File_Name); 484 qDebug("Filename is now "+File_Name);
485 485
486 } 486 }
487 if(File_Name.length() > 5 ) { 487 if(File_Name.length() > 5 ) {
488 setTitle(); 488 setTitle();
489 QFileInfo fi(File_Name); 489 QFileInfo fi(File_Name);
490 QString name_file=fi.fileName(); 490 QString name_file=fi.fileName();
491 name_file=name_file.left(name_file.length()-4); 491 name_file=name_file.left(name_file.length()-4);
492 492
493 qDebug("Setting doclink"); 493 qDebug("Setting doclink");
494 DocLnk lnk; 494 DocLnk lnk;
495 qDebug("name is "+name_file); 495 qDebug("name is "+name_file);
496 lnk.setName(name_file); //sets file name 496 lnk.setName(name_file); //sets file name
497 qDebug("Title is "+DlglistItemTitle); 497 qDebug("Title is "+DlglistItemTitle);
498 lnk.setComment(DlglistItemTitle); 498 lnk.setComment(DlglistItemTitle);
499 499
500 qDebug("Filename is "+File_Name); 500 qDebug("Filename is "+File_Name);
501 lnk.setFile(File_Name); //sets File property 501 lnk.setFile(File_Name); //sets File property
502 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D 502 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
503 lnk.setExec(File_Name); 503 lnk.setExec(File_Name);
504 lnk.setIcon("gutenbrowser/Gutenbrowser"); 504 lnk.setIcon("gutenbrowser/Gutenbrowser");
505 if(!lnk.writeLink()) { 505 if(!lnk.writeLink()) {
506 qDebug("Writing doclink did not work"); 506 qDebug("Writing doclink did not work");
507 } else { 507 } else {
508 } 508 }
509 } else 509 } else
510 QMessageBox::message("Note","There was an error\nwith the file"); 510 QMessageBox::message("Note","There was an error\nwith the file");
511 } 511 }
512 } 512 }
513 return true; 513 return true;
514} 514}
515 515
516bool LibraryDialog::httpDownload() 516bool LibraryDialog::httpDownload()
517{// httpDownload 517{// httpDownload
518#ifndef Q_WS_QWS 518#ifndef Q_WS_QWS
519 Config config("Gutenbrowser"); 519 Config config("Gutenbrowser");
520 config.setGroup( "Browser" ); 520 config.setGroup( "Browser" );
521 QString brow = config.readEntry("Preferred", ""); 521 QString brow = config.readEntry("Preferred", "");
522 QString file_name = "./.guten_temp"; 522 QString file_name = "./.guten_temp";
523 // config.setGroup( "HttpServer" ); 523 // config.setGroup( "HttpServer" );
524 // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); 524 // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org");
525 QString httpName = proxy_http + "/"+Edir; 525 QString httpName = proxy_http + "/"+Edir;
526 // progressBar->setProgress( i); 526 // progressBar->setProgress( i);
527 i++; 527 i++;
528 if ( brow != "Konq") { /////////// use lynx 528 if ( brow != "Konq") { /////////// use lynx
529 // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name; 529 // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name;
530 // system(cmd); 530 // system(cmd);
531 } else { //////////// use KFM 531 } else { //////////// use KFM
532 // KFM::download( httpName, file_name); 532 // KFM::download( httpName, file_name);
533 } 533 }
534 i++; 534 i++;
535 QFile tmp( file_name); 535 QFile tmp( file_name);
536 QString str; 536 QString str;
537 if (tmp.open(IO_ReadOnly)) { 537 if (tmp.open(IO_ReadOnly)) {
538 QTextStream t( &tmp ); // use a text stream 538 QTextStream t( &tmp ); // use a text stream
539 while ( !t.eof()) { 539 while ( !t.eof()) {
540 QString s = t.readLine(); 540 QString s = t.readLine();
541 if (s.contains( NewlistItemFile, FALSE) && (s.contains(".txt")) ) { 541 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 ) ); 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 ) );
543 httpName += "/" + str; 543 httpName += "/" + str;
544 } 544 }
545 } //end of while loop 545 } //end of while loop
546 } 546 }
547 tmp.close(); 547 tmp.close();
548 m_getFilePath = local_library + str; 548 m_getFilePath = local_library + str;
549 i++; 549 i++;
550 if ( brow != "KFM"){ ///////// use lynx 550 if ( brow != "KFM"){ ///////// use lynx
551 QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; 551 QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath;
552 // QMessageBox::message("Error", cmd); 552 // QMessageBox::message("Error", cmd);
553 system(cmd); 553 system(cmd);
554 } else { ////////// use KFM 554 } else { ////////// use KFM
555 // KFM::download( httpName, m_getFilePath); 555 // KFM::download( httpName, m_getFilePath);
556 } 556 }
557 i++; 557 i++;
558#endif 558#endif
559 return false; 559 return false;
560} 560}
561 561
562void LibraryDialog::cancelIt() 562void LibraryDialog::cancelIt()
563{ 563{
564 saveConfig(); 564 saveConfig();
565 565
566 DlglistItemNumber = ""; 566 DlglistItemNumber = "";
567 this->reject(); 567 this->reject();
568} 568}
569 569
570bool LibraryDialog::setTitle() 570bool LibraryDialog::setTitle()
571{ 571{
572 Config config("Gutenbrowser"); 572 Config config("Gutenbrowser");
573 qDebug("setting title"); 573 qDebug("setting title");
574 qDebug(DlglistItemTitle); 574 qDebug(DlglistItemTitle);
575 575
576 if( DlglistItemTitle.find("[",0,TRUE) != -1) 576 if( DlglistItemTitle.find("[",0,TRUE) != -1)
577 DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" ); 577 DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" );
578 if( DlglistItemTitle.find("]",0,TRUE) !=-1) 578 if( DlglistItemTitle.find("]",0,TRUE) !=-1)
579 DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); 579 DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" );
580 qDebug("Title being set is "+DlglistItemTitle); 580 qDebug("Title being set is "+DlglistItemTitle);
581 int test = 0; 581 int test = 0;
582 QString ramble, temp; 582 QString ramble, temp;
583 config.setGroup("Files"); 583 config.setGroup("Files");
584 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 584 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
585 int i_numofFiles = s_numofFiles.toInt(); 585 int i_numofFiles = s_numofFiles.toInt();
586 for ( int i = 0; i <= i_numofFiles; i++){ 586 for ( int i = 0; i <= i_numofFiles; i++){
587 temp.setNum( i); 587 temp.setNum( i);
588 ramble = config.readEntry( temp, "" ); 588 ramble = config.readEntry( temp, "" );
589 if( strcmp( ramble, File_Name) == 0){ 589 if( strcmp( ramble, File_Name) == 0){
590 test = 1; 590 test = 1;
591 } 591 }
592 } 592 }
593 config.setGroup("Files"); 593 config.setGroup("Files");
594 config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); 594 config.writeEntry( "NumberOfFiles", i_numofFiles +1 );
595 QString interger; 595 QString interger;
596 interger.setNum( i_numofFiles +1); 596 interger.setNum( i_numofFiles +1);
597 config.writeEntry( interger, File_Name); 597 config.writeEntry( interger, File_Name);
598 config.setGroup( "Titles" ); 598 config.setGroup( "Titles" );
599 config.writeEntry( File_Name, DlglistItemTitle); 599 config.writeEntry( File_Name, DlglistItemTitle);
600 600
601 test = 0; 601 test = 0;
602 return true; 602 return true;
603} 603}
604 604
605 605
606void LibraryDialog::saveConfig() 606void LibraryDialog::saveConfig()
607{ 607{
608 Config config("Gutenbrowser"); 608 Config config("Gutenbrowser");
609 if( httpBox->isChecked() == TRUE) { 609 if( httpBox->isChecked() == TRUE) {
610 checked = 1; 610 checked = 1;
611 config.setGroup( "Proxy" ); 611 config.setGroup( "Proxy" );
612 config.writeEntry("IsChecked", "TRUE"); 612 config.writeEntry("IsChecked", "TRUE");
613 } else { 613 } else {
614 checked = 0; 614 checked = 0;
615 config.setGroup( "Proxy" ); 615 config.setGroup( "Proxy" );
616 config.writeEntry("IsChecked", "FALSE"); 616 config.writeEntry("IsChecked", "FALSE");
617 } 617 }
618 if (authBox->isChecked() == TRUE) { 618 if (authBox->isChecked() == TRUE) {
619 config.setGroup("SortAuth"); 619 config.setGroup("SortAuth");
620 config.writeEntry("authSort", "TRUE"); 620 config.writeEntry("authSort", "TRUE");
621 } else { 621 } else {
622 config.setGroup("SortAuth"); 622 config.setGroup("SortAuth");
623 config.writeEntry("authSort", "FALSE"); 623 config.writeEntry("authSort", "FALSE");
624 } 624 }
625 // config.write(); 625 // config.write();
626} 626}
627 627
628 /* 628 /*
629 searches library index for user word*/ 629 searches library index for user word*/
630void LibraryDialog::onButtonSearch() 630void LibraryDialog::onButtonSearch()
631{ 631{
632 ListView1->clearSelection(); 632 ListView1->clearSelection();
633 ListView2->clearSelection(); 633 ListView2->clearSelection();
634 ListView3->clearSelection(); 634 ListView3->clearSelection();
635 ListView4->clearSelection(); 635 ListView4->clearSelection();
636 ListView5->clearSelection(); 636 ListView5->clearSelection();
637 637
638 int curTab=tabWidget->currentPageIndex(); 638 int curTab=tabWidget->currentPageIndex();
639 SearchDialog* searchDlg; 639 SearchDialog* searchDlg;
640 640
641 // if( resultsList) 641 // if( resultsList)
642 searchDlg = new SearchDialog( this, "Library Search", TRUE); 642 searchDlg = new SearchDialog( this, "Library Search", TRUE);
643 searchDlg->setCaption( tr( "Library Search" ) ); 643 searchDlg->setCaption( tr( "Library Search" ) );
644 searchDlg->setLabel( "- author or title"); 644 searchDlg->setLabel( "- author or title");
645 QString resultString; 645 QString resultString;
646 int i_berger = 0; 646 int i_berger = 0;
647 if( searchDlg->exec() != 0 ) { 647 if( searchDlg->exec() != 0 ) {
648 QString searcherStr = searchDlg->get_text(); 648 QString searcherStr = searchDlg->get_text();
649 int fluff=0; 649 int fluff=0;
650 650
651 // int tabPage = tabWidget->currentPageIndex(); 651 // int tabPage = tabWidget->currentPageIndex();
652 // TODO ititerate here... struct<listViews>?? 652 // TODO ititerate here... struct<listViews>??
653 653
654 QListViewItemIterator it1( ListView1 ); 654 QListViewItemIterator it1( ListView1 );
655 QListViewItemIterator it2( ListView2 ); 655 QListViewItemIterator it2( ListView2 );
656 QListViewItemIterator it3( ListView3 ); 656 QListViewItemIterator it3( ListView3 );
657 QListViewItemIterator it4( ListView4 ); 657 QListViewItemIterator it4( ListView4 );
658 QListViewItemIterator it5( ListView5 ); 658 QListViewItemIterator it5( ListView5 );
659 659
660 //// this is really pitiful work, 660 //// this is really pitiful work,
661 /////// 661 ///////
662 bool cS; 662 bool cS;
663 if( searchDlg->caseSensitiveCheckBox->isChecked()) 663 if( searchDlg->caseSensitiveCheckBox->isChecked())
664 cS=true; //case sensitive 664 cS=true; //case sensitive
665 else 665 else
666 cS=false; 666 cS=false;
667 667
668 if(fluff==0) { 668 if(fluff==0) {
669 for ( ; it1.current(); ++it1 ) { 669 for ( ; it1.current(); ++it1 ) {
670 resultString = ( it1.current() )->text(0); 670 resultString = ( it1.current() )->text(0);
671 resultString += (" : "); 671 resultString += (" : ");
672 resultString += ( it1.current() )->text(2); 672 resultString += ( it1.current() )->text(2);
673 resultString += (" : "); 673 resultString += (" : ");
674 resultString += ( it1.current() )->text(3); 674 resultString += ( it1.current() )->text(3);
675 if( resultString.find( searcherStr, 0, cS) != -1) 675 if( resultString.find( searcherStr, 0, cS) != -1)
676 { 676 {
677 Searchlist.append( resultString); 677 Searchlist.append( resultString);
678 } 678 }
679 } 679 }
680 } 680 }
681 if(fluff==0) {// search routine here 681 if(fluff==0) {// search routine here
682 for ( ; it2.current(); ++it2 ) { 682 for ( ; it2.current(); ++it2 ) {
683 resultString = ( it2.current() )->text(0); 683 resultString = ( it2.current() )->text(0);
684 resultString += (" : "); 684 resultString += (" : ");
685 resultString += ( it2.current() )->text(2); 685 resultString += ( it2.current() )->text(2);
686 resultString += (" : "); 686 resultString += (" : ");
687 resultString += ( it2.current() )->text(3); 687 resultString += ( it2.current() )->text(3);
688 if( resultString.find( searcherStr, 0, cS) != -1) { 688 if( resultString.find( searcherStr, 0, cS) != -1) {
689 Searchlist.append( resultString); 689 Searchlist.append( resultString);
690 } 690 }
691 } 691 }
692 } 692 }
693 if(fluff==0) {// search routine here 693 if(fluff==0) {// search routine here
694 for ( ; it3.current(); ++it3 ) { 694 for ( ; it3.current(); ++it3 ) {
695 resultString = ( it3.current() )->text(0); 695 resultString = ( it3.current() )->text(0);
696 resultString += (" : "); 696 resultString += (" : ");
697 resultString += ( it3.current() )->text(2); 697 resultString += ( it3.current() )->text(2);
698 resultString += (" : "); 698 resultString += (" : ");
699 resultString += ( it3.current() )->text(3); 699 resultString += ( it3.current() )->text(3);
700 700
701 if( resultString.find( searcherStr, 0, cS) != -1) { 701 if( resultString.find( searcherStr, 0, cS) != -1) {
702 Searchlist.append( resultString); 702 Searchlist.append( resultString);
703 } 703 }
704 } 704 }
705 } 705 }
706 if(fluff==0) { 706 if(fluff==0) {
707 // search routine here 707 // search routine here
708 for ( ; it4.current(); ++it4 ) { 708 for ( ; it4.current(); ++it4 ) {
709 resultString = ( it4.current() )->text(0); 709 resultString = ( it4.current() )->text(0);
710 resultString += (" : "); 710 resultString += (" : ");
711 resultString += ( it4.current() )->text(2); 711 resultString += ( it4.current() )->text(2);
712 resultString += (" : "); 712 resultString += (" : ");
713 resultString += ( it4.current() )->text(3); 713 resultString += ( it4.current() )->text(3);
714 if( resultString.find( searcherStr, 0, cS) != -1) { 714 if( resultString.find( searcherStr, 0, cS) != -1) {
715 Searchlist.append( resultString); 715 Searchlist.append( resultString);
716 } 716 }
717 } 717 }
718 } 718 }
719 if(fluff==0) { // search routine here 719 if(fluff==0) { // search routine here
720 for ( ; it5.current(); ++it5 ) { 720 for ( ; it5.current(); ++it5 ) {
721 resultString = ( it5.current() )->text(0); 721 resultString = ( it5.current() )->text(0);
722 resultString += (" : "); 722 resultString += (" : ");
723 resultString += ( it5.current() )->text(2); 723 resultString += ( it5.current() )->text(2);
724 resultString += (" : "); 724 resultString += (" : ");
725 resultString += ( it5.current() )->text(3); 725 resultString += ( it5.current() )->text(3);
726 if( resultString.find( searcherStr, 0, cS) != -1) { 726 if( resultString.find( searcherStr, 0, cS) != -1) {
727 Searchlist.append( resultString); 727 Searchlist.append( resultString);
728 } 728 }
729 } 729 }
730 } 730 }
731 731
732 tabWidget->setCurrentPage( curTab); 732 tabWidget->setCurrentPage( curTab);
733 733
734 Searchlist.sort(); 734 Searchlist.sort();
735 SearchResultsDlg* SearchResultsDialog; 735 SearchResultsDlg* SearchResultsDialog;
736 SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); 736 SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist);
737 737
738 SearchResultsDialog->showMaximized(); 738 SearchResultsDialog->showMaximized();
739 if( SearchResultsDialog->exec() != 0) { 739 if( SearchResultsDialog->exec() != 0) {
740 texter = SearchResultsDialog->selText; 740 texter = SearchResultsDialog->selText;
741 // qDebug(texter); 741 // qDebug(texter);
742 resultLs= SearchResultsDialog->resultsList; 742 resultLs= SearchResultsDialog->resultsList;
743 i_berger = 1; 743 i_berger = 1;
744 } 744 }
745 Searchlist.clear(); 745 Searchlist.clear();
746 746
747 // if(SearchResultsDialog) 747 // if(SearchResultsDialog)
748 // delete SearchResultsDialog; 748 // delete SearchResultsDialog;
749 QString tester; 749 QString tester;
750 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { 750 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) {
751 texter.sprintf("%s \n",(*it).latin1()); 751 texter.sprintf("%s \n",(*it).latin1());
752 // qDebug(texter); 752 // qDebug(texter);
753 if( tester!=texter) 753 if( tester!=texter)
754 parseSearchResults( texter); 754 parseSearchResults( texter);
755 tester = texter; 755 tester = texter;
756 } 756 }
757 if(searchDlg) 757 if(searchDlg)
758 delete searchDlg; 758 delete searchDlg;
759 } 759 }
760 if(checkBox->isChecked() ) { 760 if(checkBox->isChecked() ) {
761 accept(); 761 accept();
762 } else { 762 } else {
763 setActiveWindow(); 763 setActiveWindow();
764 } 764 }
765} 765}
766 766
767 /* 767 /*
768 splits the result string and calls download for the current search result*/ 768 splits the result string and calls download for the current search result*/
769void LibraryDialog::parseSearchResults( QString resultStr) 769void LibraryDialog::parseSearchResults( QString resultStr)
770{ 770{
771 771
772 int stringLeng=resultStr.length(); 772 int stringLeng=resultStr.length();
773 QString my; 773 QString my;
774 my.setNum( stringLeng, 10); 774 my.setNum( stringLeng, 10);
775 775
776 if( resultStr.length() > 2 && resultStr.length() < 130) { 776 if( resultStr.length() > 2 && resultStr.length() < 130) {
777 int titleInt = resultStr.find( " : ", 0, TRUE); 777 int titleInt = resultStr.find( " : ", 0, TRUE);
778 DlglistItemTitle = resultStr.left( titleInt); 778 DlglistItemTitle = resultStr.left( titleInt);
779 int yearInt = resultStr.find( " : ", titleInt+3, TRUE); 779 int yearInt = resultStr.find( " : ", titleInt+3, TRUE);
780 DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); 780 DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3);
781 DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); 781 DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3));
782 download_Etext(); 782 download_Etext();
783 } 783 }
784 /* 784 /*
785 printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/ 785 printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/
786} 786}
787 787
788 // bool LibraryDialog::UnzipIt( QString zipFile) { 788 // bool LibraryDialog::UnzipIt( QString zipFile) {
789 // //////////TODO findsome other way of dealingwithzip files. 789 // //////////TODO findsome other way of dealingwithzip files.
790 // ///usr/bin/unzip"; 790 // ///usr/bin/unzip";
791 // if( QFile::exists( zipFile)) { 791 // if( QFile::exists( zipFile)) {
792 // // QString thatFile = local_library +"PGWHOLE.TXT"; 792 // // QString thatFile = local_library +"PGWHOLE.TXT";
793 // QString cmd; 793 // QString cmd;
794 // #if defined(_WS_X11_) 794 // #if defined(_WS_X11_)
795 // cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; 795 // cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library;
796 // #endif 796 // #endif
797 // #if defined(_WS_WIN_) 797 // #if defined(_WS_WIN_)
798 // QString temp= QDir::convertSeparators(local_library); 798 // QString temp= QDir::convertSeparators(local_library);
799 // zipFile=QDir::convertSeparators( zipFile); 799 // zipFile=QDir::convertSeparators( zipFile);
800 // cmd = temp+"unzip.exe -o " +zipFile/*newestLibraryFile */+" -d " + temp; 800 // cmd = temp+"unzip.exe -o " +zipFile/*newestLibraryFile */+" -d " + temp;
801 // #endif 801 // #endif
802 // #ifndef Q_WS_QWS 802 // #ifndef Q_WS_QWS
803 // // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; 803 // // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library;
804 // cmd = "unzip " + zipFile; 804 // cmd = "unzip " + zipFile;
805 // #endif 805 // #endif
806 806
807 // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No); 807 // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No);
808 // if (exit==QMessageBox::Yes) { 808 // if (exit==QMessageBox::Yes) {
809 // qDebug("Issuing the command "+cmd); 809 // qDebug("Issuing the command "+cmd);
810 // #if defined(_WS_WIN_) 810 // #if defined(_WS_WIN_)
811 // WinExec( cmd, SW_HIDE ); 811 // WinExec( cmd, SW_HIDE );
812 // #endif 812 // #endif
813 // #if defined(_WS_X11_) 813 // #if defined(_WS_X11_)
814 // system( cmd); 814 // system( cmd);
815 // #endif 815 // #endif
816 // #ifndef Q_WS_QWS 816 // #ifndef Q_WS_QWS
817 // system( cmd); 817 // system( cmd);
818 // #endif 818 // #endif
819 // // printf("unzip\n"); 819 // // printf("unzip\n");
820 // // remove( zipFile /*newestLibraryFile*/); 820 // // remove( zipFile /*newestLibraryFile*/);
821 // return true; 821 // return true;
822 // } 822 // }
823 // else if(exit==QMessageBox::No) { 823 // else if(exit==QMessageBox::No) {
824 // // printf("unzip\n"); 824 // // printf("unzip\n");
825 // return false; 825 // return false;
826 // } 826 // }
827 // } else { 827 // } else {
828 // // QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); 828 // // QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) );
829 // return false; 829 // return false;
830 // } 830 // }
831 // return true; 831 // return true;
832 // } 832 // }
833 833
834void LibraryDialog::sort() 834void LibraryDialog::sort()
835{ 835{
836 836
837} 837}
838 838
839 /* 839 /*
840 Downloads the current selected listitem*/ 840 Downloads the current selected listitem*/
841bool LibraryDialog::getItem(QListViewItem *it) 841bool LibraryDialog::getItem(QListViewItem *it)
842{ 842{
843 // qDebug("selected getItem"); 843 // qDebug("selected getItem");
844 844
845 // DlglistItemNumber = it->text(0); 845 // DlglistItemNumber = it->text(0);
846 DlglistItemTitle = it->text(0); 846 DlglistItemTitle = it->text(0);
847 DlglistItemYear = it->text(2); 847 DlglistItemYear = it->text(2);
848 DlglistItemFile = it->text(3); 848 DlglistItemFile = it->text(3);
849 849
850 if(download_Etext()) { 850 if(download_Etext()) {
851 if(i_binary == 1) { 851 if(i_binary == 1) {
852 } 852 }
853 } 853 }
854 return true; 854 return true;
855} 855}
856 856
857 /* 857 /*
858 download button is pushed so we get the current items to download*/ 858 download button is pushed so we get the current items to download*/
859bool LibraryDialog::onButtonDownload() 859bool LibraryDialog::onButtonDownload()
860{ 860{
861 // qDebug("selected onButtonDownloadz"); 861 // qDebug("selected onButtonDownloadz");
862 862
863 QListViewItemIterator it1( ListView1 ); 863 QListViewItemIterator it1( ListView1 );