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