Diffstat (limited to 'noncore/apps/opie-gutenbrowser/LibraryDialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | 213 |
1 files changed, 98 insertions, 115 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp index 58babe9..9858188 100644 --- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | |||
@@ -137,19 +137,48 @@ void LibraryDialog::Library() { | |||
137 | // qDebug( "opening GUTINDEX.ALL file"); | 137 | // qDebug( "opening GUTINDEX.ALL file"); |
138 | IDontKnowWhy = ""; | 138 | IDontKnowWhy = ""; |
139 | if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully | 139 | system("date"); |
140 | if ( indexLib.open( IO_ReadOnly) ) { | ||
141 | // file opened successfully | ||
140 | QTextStream indexStream( &indexLib ); | 142 | QTextStream indexStream( &indexLib ); |
141 | QString indexLine; | 143 | QString indexLine; |
142 | qApp->processEvents(); | 144 | qApp->processEvents(); |
143 | 145 | ||
146 | bool okToRead = false; | ||
144 | while ( !indexStream.eof() ) { | 147 | while ( !indexStream.eof() ) { |
145 | |||
146 | indexLine = indexStream.readLine(); | 148 | indexLine = indexStream.readLine(); |
147 | if ( indexLine != "") { | 149 | if(indexLine == "<==Start GUTINDEX.ALL listings==>") |
150 | okToRead = true; | ||
151 | if(indexLine == "<==End of GUTINDEX.ALL==>") { | ||
152 | okToRead = false; | ||
153 | indexLib.at(indexLib.size()); | ||
154 | } | ||
155 | |||
156 | if(okToRead) { | ||
157 | QStringList token = QStringList::split(' ', indexLine); | ||
158 | int textNumber; | ||
159 | if(( textNumber = token.last().toInt() )) | ||
160 | if(textNumber > 10001) { | ||
161 | // qWarning("Last "+token.last()); | ||
162 | // newer files with numbers > 100000 have new dir structure and need to be parsed differently.. | ||
163 | if(textNumber < 10626) | ||
164 | year = "2003"; | ||
165 | else if(textNumber >= 10626 && textNumber < 14600) | ||
166 | year = "2004"; | ||
167 | else if(textNumber >= 14600) | ||
168 | year = "2005"; | ||
148 | 169 | ||
149 | if( (indexLine.mid(4,4)).toInt() ) { | 170 | file = token.last(); |
171 | title = indexLine.mid(0,72); | ||
150 | 172 | ||
151 | year = indexLine.mid(4,4); | 173 | addItems(); //author and qlistview |
174 | //qDebug("file number is " + number + " title is " + title ); | ||
175 | |||
176 | } else { //end new etexts | ||
177 | |||
178 | if(token[1].toInt() && token[1].toInt() > 1969) { | ||
179 | year = token[1]; | ||
152 | file = indexLine.mid(60,12); | 180 | file = indexLine.mid(60,12); |
153 | if(file.left(1).find("[",0,TRUE) != -1) | 181 | |
182 | if(file.left(1).find("[",0,TRUE) != -1) { | ||
154 | file.remove(1,1); | 183 | file.remove(1,1); |
155 | if( file.find("]",0,TRUE) != -1) | 184 | if( file.find("]",0,TRUE) != -1) |
@@ -160,29 +189,18 @@ void LibraryDialog::Library() { | |||
160 | file = tmpfile; | 189 | file = tmpfile; |
161 | } | 190 | } |
162 | |||
163 | number = indexLine.mid(55,5); | ||
164 | title = indexLine.mid( 9, 50 ); | 191 | title = indexLine.mid( 9, 50 ); |
165 | 192 | ||
166 | addItems(); | 193 | addItems(); |
167 | |||
168 | } | 194 | } |
169 | else if ( indexLine.mid(73,5).toInt() && indexLine.mid(73,5).toInt() > 10000 ) { | 195 | } else { // then try new format texts |
170 | // newer files with numbers > 100000 have new dir structure and need to be parsed differently.. | 196 | file = token.last(); |
171 | number = indexLine.mid(73,5); | ||
172 | int num = number.toInt(); | ||
173 | if(num < 10626) | ||
174 | year = "2003"; | ||
175 | else if(num >= 10626 && num < 14600) | ||
176 | year = "2004"; | ||
177 | else if(num >= 14600) | ||
178 | year = "2005"; | ||
179 | |||
180 | file = number;// + ".txt"; | ||
181 | title = indexLine.mid(0,72); | 197 | title = indexLine.mid(0,72); |
198 | year = "1980"; | ||
182 | 199 | ||
183 | addItems(); | 200 | addItems(); //author and qlistview |
184 | //qDebug("file number is " + number + " title is " + title ); | ||
185 | } | ||
186 | } | 201 | } |
202 | } //end old etexts | ||
203 | |||
204 | } //end okToTRead | ||
187 | } | 205 | } |
188 | indexLib.close(); | 206 | indexLib.close(); |
@@ -193,4 +211,7 @@ void LibraryDialog::Library() { | |||
193 | QMessageBox::message( "Error",sMsg); | 211 | QMessageBox::message( "Error",sMsg); |
194 | } | 212 | } |
213 | system("date"); | ||
214 | sortLists(0); | ||
215 | |||
195 | } //end Library() | 216 | } //end Library() |
196 | 217 | ||
@@ -304,31 +325,38 @@ bool LibraryDialog::getAuthor() | |||
304 | }////// end getAuthor() | 325 | }////// end getAuthor() |
305 | 326 | ||
306 | void LibraryDialog::addItems() { | 327 | void LibraryDialog::addItems() |
328 | { | ||
307 | cleanStrings(); | 329 | cleanStrings(); |
308 | getAuthor(); // grok author | 330 | getAuthor(); // grok author |
309 | if( !number.isEmpty() | 331 | |
310 | && (title.find( "reserved",0, FALSE) == -1) | 332 | etext etextStruct; |
333 | if( /*!number.isEmpty() | ||
334 | && */ | ||
335 | (title.find( "reserved",0, FALSE) == -1) | ||
311 | && (file.find( "]",0, true) == -1) | 336 | && (file.find( "]",0, true) == -1) |
312 | &&(title.find( "Audio",0, FALSE) == -1)) { | 337 | &&(title.find( "Audio",0, FALSE) == -1)) { |
313 | // qDebug("new item "+title); | 338 | // qDebug("new item "+title); |
314 | // fill string list or something to be able to sort by Author | 339 | // fill string list or something to be able to sort by Author |
340 | etextStruct.title = title; | ||
341 | etextStruct.author = author; | ||
342 | etextStruct.year = year; | ||
343 | etextStruct.file = file; | ||
344 | |||
345 | etextLibrary.append( etextStruct); | ||
346 | |||
315 | if( author.isEmpty() ) | 347 | if( author.isEmpty() ) |
316 | QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); | 348 | QList_Item5 = new QListViewItem( ListView5, /*number, */author, title, year, file ); |
317 | else { | 349 | else { |
318 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || | 350 | if( author.find(QRegExp("[^a-fA-F]")) ) |
319 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) | 351 | QList_Item1 = new QListViewItem( ListView1, /* number,*/author, title, year, file ); |
320 | QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); | ||
321 | 352 | ||
322 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || | 353 | else if(author.find(QRegExp("[^g-mG-M]")) ) |
323 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) | 354 | QList_Item2 = new QListViewItem( ListView2, /* number,*/ author, title,year, file ); |
324 | QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); | ||
325 | 355 | ||
326 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || | 356 | else if(author.find(QRegExp("[^n-rN-R]")) ) |
327 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) | 357 | QList_Item3 = new QListViewItem( ListView3, /* number,*/ author, title, year, file ); |
328 | QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file ); | ||
329 | 358 | ||
330 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || | 359 | else if(author.find(QRegExp("[^s-zS-Z]")) ) |
331 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) | 360 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ author, title, year, file ); |
332 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); | ||
333 | } | 361 | } |
334 | } | 362 | } |
@@ -676,15 +704,4 @@ void LibraryDialog::onButtonSearch() | |||
676 | int fluff = 0; | 704 | int fluff = 0; |
677 | 705 | ||
678 | // int tabPage = tabWidget->currentPageIndex(); | ||
679 | // TODO ititerate here... struct<listViews>?? | ||
680 | |||
681 | QListViewItemIterator it1( ListView1 ); | ||
682 | QListViewItemIterator it2( ListView2 ); | ||
683 | QListViewItemIterator it3( ListView3 ); | ||
684 | QListViewItemIterator it4( ListView4 ); | ||
685 | QListViewItemIterator it5( ListView5 ); | ||
686 | |||
687 | //// this is really pitiful work, | ||
688 | /////// | ||
689 | bool cS; | 706 | bool cS; |
690 | if( searchDlg->caseSensitiveCheckBox->isChecked()) | 707 | if( searchDlg->caseSensitiveCheckBox->isChecked()) |
@@ -693,68 +710,20 @@ void LibraryDialog::onButtonSearch() | |||
693 | cS=false; | 710 | cS=false; |
694 | 711 | ||
695 | if(fluff==0) { | 712 | etext etextStruct; |
696 | for ( ; it1.current(); ++it1 ) { | 713 | QValueList<etext>::Iterator it; |
697 | resultString = ( it1.current() )->text(0); | ||
698 | resultString += (" : "); | ||
699 | resultString += ( it1.current() )->text(2); | ||
700 | resultString += (" : "); | ||
701 | resultString += ( it1.current() )->text(3); | ||
702 | if( resultString.find( searcherStr, 0, cS) != -1) | ||
703 | { | ||
704 | Searchlist.append( resultString); | ||
705 | } | ||
706 | } | ||
707 | } | ||
708 | if(fluff==0) {// search routine here | ||
709 | for ( ; it2.current(); ++it2 ) { | ||
710 | resultString = ( it2.current() )->text(0); | ||
711 | resultString += (" : "); | ||
712 | resultString += ( it2.current() )->text(2); | ||
713 | resultString += (" : "); | ||
714 | resultString += ( it2.current() )->text(3); | ||
715 | if( resultString.find( searcherStr, 0, cS) != -1) { | ||
716 | Searchlist.append( resultString); | ||
717 | } | ||
718 | } | ||
719 | } | ||
720 | if(fluff==0) {// search routine here | ||
721 | for ( ; it3.current(); ++it3 ) { | ||
722 | resultString = ( it3.current() )->text(0); | ||
723 | resultString += (" : "); | ||
724 | resultString += ( it3.current() )->text(2); | ||
725 | resultString += (" : "); | ||
726 | resultString += ( it3.current() )->text(3); | ||
727 | 714 | ||
728 | if( resultString.find( searcherStr, 0, cS) != -1) { | 715 | for( it = etextLibrary.begin(); it != etextLibrary.end(); ++it ) { |
729 | Searchlist.append( resultString); | 716 | QString tempTitle = (*it).title; |
730 | } | 717 | QString tempAuthor = (*it).author; |
731 | } | 718 | QString tempFile = (*it).file; |
732 | } | 719 | QString tempYear = (*it).year; |
733 | if(fluff==0) { | 720 | if(tempTitle.find( searcherStr, 0, cS) != -1 |
734 | // search routine here | 721 | || tempAuthor.find( searcherStr, 0, cS) != -1) { |
735 | for ( ; it4.current(); ++it4 ) { | 722 | qWarning(tempTitle); |
736 | resultString = ( it4.current() )->text(0); | 723 | Searchlist.append( tempTitle + " : " + tempYear + " : " + tempFile); |
737 | resultString += (" : "); | ||
738 | resultString += ( it4.current() )->text(2); | ||
739 | resultString += (" : "); | ||
740 | resultString += ( it4.current() )->text(3); | ||
741 | if( resultString.find( searcherStr, 0, cS) != -1) { | ||
742 | Searchlist.append( resultString); | ||
743 | } | ||
744 | } | ||
745 | } | ||
746 | if(fluff==0) { // search routine here | ||
747 | for ( ; it5.current(); ++it5 ) { | ||
748 | resultString = ( it5.current() )->text(0); | ||
749 | resultString += (" : "); | ||
750 | resultString += ( it5.current() )->text(2); | ||
751 | resultString += (" : "); | ||
752 | resultString += ( it5.current() )->text(3); | ||
753 | if( resultString.find( searcherStr, 0, cS) != -1) { | ||
754 | Searchlist.append( resultString); | ||
755 | } | ||
756 | } | 724 | } |
757 | } | 725 | } |
758 | 726 | ||
727 | |||
759 | tabWidget->setCurrentPage( curTab); | 728 | tabWidget->setCurrentPage( curTab); |
760 | 729 | ||
@@ -774,6 +743,4 @@ void LibraryDialog::onButtonSearch() | |||
774 | Searchlist.clear(); | 743 | Searchlist.clear(); |
775 | 744 | ||
776 | // if(SearchResultsDialog) | ||
777 | // delete SearchResultsDialog; | ||
778 | QString tester; | 745 | QString tester; |
779 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { | 746 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { |
@@ -821,5 +788,5 @@ void LibraryDialog::parseSearchResults( QString resultStr) | |||
821 | 788 | ||
822 | 789 | ||
823 | if(DlglistItemFile.toInt() > 10000 ) { | 790 | if(DlglistItemFile.toInt() > 10000 || yearInt == 1980 ) { |
824 | // new directory sturcture | 791 | // new directory sturcture |
825 | download_newEtext(); //) | 792 | download_newEtext(); //) |
@@ -830,7 +797,17 @@ void LibraryDialog::parseSearchResults( QString resultStr) | |||
830 | } | 797 | } |
831 | 798 | ||
832 | void LibraryDialog::sort() | 799 | void LibraryDialog::sortLists(int index) |
833 | { | 800 | { |
834 | 801 | ||
802 | ListView1->setSorting(index); | ||
803 | ListView2->setSorting(index); | ||
804 | ListView3->setSorting(index); | ||
805 | ListView4->setSorting(index); | ||
806 | ListView5->setSorting(index); | ||
807 | ListView1->sort(); | ||
808 | ListView2->sort(); | ||
809 | ListView3->sort(); | ||
810 | ListView4->sort(); | ||
811 | ListView5->sort(); | ||
835 | } | 812 | } |
836 | 813 | ||
@@ -1068,2 +1045,8 @@ void LibraryDialog::cleanStrings() { | |||
1068 | 1045 | ||
1069 | } | 1046 | } |
1047 | |||
1048 | void LibraryDialog::authBoxClicked() | ||
1049 | { | ||
1050 | qApp->processEvents(); | ||
1051 | FindLibrary(); | ||
1052 | } | ||