-rw-r--r-- | noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | 10 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/LibraryDialogData.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | 82 |
3 files changed, 47 insertions, 48 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp index 270a4cf..124b6f3 100644 --- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | |||
@@ -1,1071 +1,1073 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | // LibraryDialog.cpp - description | 2 | // LibraryDialog.cpp - description |
3 | // ------------------- | 3 | // ------------------- |
4 | // begin : Sat Aug 19 2000 | 4 | // begin : Sat Aug 19 2000 |
5 | // copyright : (C) 2000 - 2004 by llornkcor | 5 | // copyright : (C) 2000 - 2004 by llornkcor |
6 | // email : ljp@llornkcor.com | 6 | // email : ljp@llornkcor.com |
7 | // ***************************************************/ | 7 | // ***************************************************/ |
8 | // /*************************************************************************** | 8 | // /*************************************************************************** |
9 | // * This program is free software; you can redistribute it and/or modify * | 9 | // * This program is free software; you can redistribute it and/or modify * |
10 | // * it under the terms of the GNU General Public License as published by * | 10 | // * it under the terms of the GNU General Public License as published by * |
11 | // * the Free Software Foundation; either version 2 of the License, or * | 11 | // * the Free Software Foundation; either version 2 of the License, or * |
12 | // * (at your option) any later version. * | 12 | // * (at your option) any later version. * |
13 | // ***************************************************************************/ | 13 | // ***************************************************************************/ |
14 | //ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL | 14 | //ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL |
15 | 15 | ||
16 | #include "LibraryDialog.h" | 16 | #include "LibraryDialog.h" |
17 | #include "output.h" | 17 | #include "output.h" |
18 | 18 | ||
19 | /* OPIE */ | 19 | /* OPIE */ |
20 | #include <qpe/applnk.h> | 20 | #include <qpe/applnk.h> |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/qpedialog.h> | 22 | #include <qpe/qpedialog.h> |
23 | #include <opie2/odebug.h> | 23 | #include <opie2/odebug.h> |
24 | 24 | ||
25 | /* QT */ | 25 | /* QT */ |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qmultilineedit.h> | 27 | #include <qmultilineedit.h> |
28 | //#include <qlayout.h> | 28 | //#include <qlayout.h> |
29 | 29 | ||
30 | /* STD */ | 30 | /* STD */ |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <stdio.h> | 32 | #include <stdio.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | 34 | ||
35 | /* | 35 | /* |
36 | * The dialog will by default be modeless, unless you set 'modal' to | 36 | * The dialog will by default be modeless, unless you set 'modal' to |
37 | * TRUE to construct a modal dialog. */ | 37 | * TRUE to construct a modal dialog. */ |
38 | LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool modal, WFlags fl ) | 38 | LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool modal, WFlags fl ) |
39 | : QDialog( parent, name, true/* modal*/, fl ) | 39 | : QDialog( parent, name, true/* modal*/, fl ) |
40 | { | 40 | { |
41 | if ( !name ) | 41 | if ( !name ) |
42 | setName( "LibraryDialog" ); | 42 | setName( "LibraryDialog" ); |
43 | indexLoaded=false; | 43 | indexLoaded=false; |
44 | initDialog(); | 44 | initDialog(); |
45 | 45 | ||
46 | // this->setMaximumWidth(240); | 46 | // this->setMaximumWidth(240); |
47 | 47 | ||
48 | index = "GUTINDEX.ALL"; | 48 | index = "GUTINDEX.ALL"; |
49 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; | 49 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; |
50 | local_index = local_library + index; | 50 | local_index = local_library + index; |
51 | 51 | ||
52 | QString iniFile ; | 52 | QString iniFile ; |
53 | iniFile = QPEApplication::qpeDir()+"/etc/gutenbrowser/gutenbrowserrc"; | 53 | iniFile = QPEApplication::qpeDir()+"/etc/gutenbrowser/gutenbrowserrc"; |
54 | 54 | ||
55 | new_index =QPEApplication::qpeDir()+"/etc/gutenbrowser/PGWHOLE.TXT"; | 55 | new_index =QPEApplication::qpeDir()+"/etc/gutenbrowser/PGWHOLE.TXT"; |
56 | 56 | ||
57 | old_index = QPEApplication::qpeDir()+"/etc/gutenbrowser/GUTINDEX.ALL"; | 57 | old_index = QPEApplication::qpeDir()+"/etc/gutenbrowser/GUTINDEX.ALL"; |
58 | // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; | 58 | // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
59 | 59 | ||
60 | // iniFile = local_library+"gutenbrowserrc"; | 60 | // iniFile = local_library+"gutenbrowserrc"; |
61 | // new_index = local_library + "PGWHOLE.TXT"; | 61 | // new_index = local_library + "PGWHOLE.TXT"; |
62 | // old_index = local_library + "GUTINDEX.ALL"; | 62 | // old_index = local_library + "GUTINDEX.ALL"; |
63 | 63 | ||
64 | Config config("Gutenbrowser"); | 64 | Config config("Gutenbrowser"); |
65 | 65 | ||
66 | config.setGroup( "HttpServer" ); | 66 | config.setGroup( "HttpServer" ); |
67 | proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); | 67 | proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); |
68 | 68 | ||
69 | config.setGroup( "FTPsite" ); | 69 | config.setGroup( "FTPsite" ); |
70 | ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); | 70 | ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); |
71 | odebug << "Library Dialog: ftp_host is "+ftp_host << oendl; | 71 | odebug << "Library Dialog: ftp_host is "+ftp_host << oendl; |
72 | // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); | 72 | // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); |
73 | // ftp_host=ftp_host.stripWhiteSpace(); | 73 | // ftp_host=ftp_host.stripWhiteSpace(); |
74 | ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); | 74 | ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); |
75 | 75 | ||
76 | i_binary = 0; | 76 | i_binary = 0; |
77 | 77 | ||
78 | config.setGroup("SortAuth"); | 78 | config.setGroup("SortAuth"); |
79 | if( config.readEntry("authSort", "FALSE") == "TRUE") | 79 | if( config.readEntry("authSort", "FALSE") == "TRUE") |
80 | authBox->setChecked(TRUE); | 80 | authBox->setChecked(TRUE); |
81 | 81 | ||
82 | config.setGroup("General"); | 82 | config.setGroup("General"); |
83 | downDir =config.readEntry( "DownloadDirectory",local_library); | 83 | downDir =config.readEntry( "DownloadDirectory",local_library); |
84 | odebug << "downDir is "+downDir << oendl; | 84 | odebug << "downDir is "+downDir << oendl; |
85 | newindexLib.setName( old_index); | 85 | newindexLib.setName( old_index); |
86 | indexLib.setName( old_index); | 86 | indexLib.setName( old_index); |
87 | 87 | ||
88 | new QPEDialogListener(this); | 88 | new QPEDialogListener(this); |
89 | QTimer::singleShot( 1000, this, SLOT( FindLibrary()) ); | ||
90 | |||
89 | } | 91 | } |
90 | 92 | ||
91 | LibraryDialog::~LibraryDialog() | 93 | LibraryDialog::~LibraryDialog() |
92 | { | 94 | { |
93 | // delete QList_Item2; | 95 | // delete QList_Item2; |
94 | // delete QList_Item1; | 96 | // delete QList_Item1; |
95 | // delete QList_Item3; | 97 | // delete QList_Item3; |
96 | // delete QList_Item4; | 98 | // delete QList_Item4; |
97 | // delete QList_Item5; | 99 | // delete QList_Item5; |
98 | 100 | ||
99 | // saveConfig(); | 101 | // saveConfig(); |
100 | } | 102 | } |
101 | 103 | ||
102 | /*This groks using PGWHOLE.TXT */ | 104 | /*This groks using PGWHOLE.TXT */ |
103 | void LibraryDialog::Newlibrary() | 105 | void LibraryDialog::Newlibrary() |
104 | { | 106 | { |
105 | #ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files | 107 | #ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files |
106 | //odebug << "Opening new library index " << newindexLib << "" << oendl; | 108 | //odebug << "Opening new library index " << newindexLib << "" << oendl; |
107 | if ( newindexLib.open( IO_ReadOnly) ) { | 109 | if ( newindexLib.open( IO_ReadOnly) ) { |
108 | setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully | 110 | setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully |
109 | QTextStream indexStream( &newindexLib ); | 111 | QTextStream indexStream( &newindexLib ); |
110 | QString indexLine; | 112 | QString indexLine; |
111 | while ( !indexStream.atEnd() ) { // until end of file.. | 113 | while ( !indexStream.atEnd() ) { // until end of file.. |
112 | indexLine = indexStream.readLine(); | 114 | indexLine = indexStream.readLine(); |
113 | if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { | 115 | if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { |
114 | year = indexLine.mid(4,4); | 116 | year = indexLine.mid(4,4); |
115 | year = year.stripWhiteSpace(); | 117 | year = year.stripWhiteSpace(); |
116 | file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); | 118 | file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); |
117 | file = file.stripWhiteSpace(); | 119 | file = file.stripWhiteSpace(); |
118 | 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 ); |
119 | if( year.toInt() < 1984) | 121 | if( year.toInt() < 1984) |
120 | number = number.left( number.length() -1 ); | 122 | number = number.left( number.length() -1 ); |
121 | number = number.stripWhiteSpace(); | 123 | number = number.stripWhiteSpace(); |
122 | title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); | 124 | title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); |
123 | title = title.stripWhiteSpace(); | 125 | title = title.stripWhiteSpace(); |
124 | 126 | ||
125 | getAuthor(); // groks author | 127 | getAuthor(); // groks author |
126 | author = author.stripWhiteSpace(); | 128 | author = author.stripWhiteSpace(); |
127 | 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 |
128 | // odebug << "Sorting last name first" << oendl; | 130 | // odebug << "Sorting last name first" << oendl; |
129 | QString lastName, firstName=""; | 131 | QString lastName, firstName=""; |
130 | int finder=author.findRev( ' ', -1, TRUE); | 132 | int finder=author.findRev( ' ', -1, TRUE); |
131 | lastName=author.right( author.length()-finder); | 133 | lastName=author.right( author.length()-finder); |
132 | firstName=author.left(finder); | 134 | firstName=author.left(finder); |
133 | lastName=lastName.stripWhiteSpace(); | 135 | lastName=lastName.stripWhiteSpace(); |
134 | firstName=firstName.stripWhiteSpace(); | 136 | firstName=firstName.stripWhiteSpace(); |
135 | 137 | ||
136 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names | 138 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names |
137 | author=lastName+", "+firstName; | 139 | author=lastName+", "+firstName; |
138 | } | 140 | } |
139 | 141 | ||
140 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) { | 142 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) { |
141 | 143 | ||
142 | // fill string list or something to be able to resort the whole library | 144 | // fill string list or something to be able to resort the whole library |
143 | if( author.isEmpty() ) | 145 | if( author.isEmpty() ) |
144 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); | 146 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); |
145 | else { | 147 | else { |
146 | 148 | ||
147 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || | 149 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || |
148 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) | 150 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) |
149 | QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); | 151 | QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); |
150 | 152 | ||
151 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || | 153 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || |
152 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) | 154 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) |
153 | QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file ); | 155 | QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file ); |
154 | 156 | ||
155 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || | 157 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || |
156 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) | 158 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) |
157 | QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file ); | 159 | QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file ); |
158 | 160 | ||
159 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || | 161 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || |
160 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) | 162 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) |
161 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); | 163 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); |
162 | 164 | ||
163 | else | 165 | else |
164 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); | 166 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); |
165 | } | 167 | } |
166 | } | 168 | } |
167 | }// end if | 169 | }// end if |
168 | }// end while | 170 | }// end while |
169 | newindexLib.close(); | 171 | newindexLib.close(); |
170 | } | 172 | } |
171 | #ifndef Q_WS_QWS | 173 | #ifndef Q_WS_QWS |
172 | setCursor( arrowCursor); | 174 | setCursor( arrowCursor); |
173 | #endif | 175 | #endif |
174 | #endif | 176 | #endif |
175 | } // end Newlibrary() | 177 | } // end Newlibrary() |
176 | 178 | ||
177 | 179 | ||
178 | void LibraryDialog::Library() | 180 | void LibraryDialog::Library() |
179 | {// old library groking method | 181 | {// old library groking method |
180 | 182 | ||
181 | ListView1->clear(); | 183 | ListView1->clear(); |
182 | ListView2->clear(); | 184 | ListView2->clear(); |
183 | ListView3->clear(); | 185 | ListView3->clear(); |
184 | ListView4->clear(); | 186 | ListView4->clear(); |
185 | ListView5->clear(); | 187 | ListView5->clear(); |
186 | 188 | ||
187 | odebug << "opening GUTINDEX.ALL file" << oendl; | 189 | odebug << "opening GUTINDEX.ALL file" << oendl; |
188 | IDontKnowWhy = ""; | 190 | IDontKnowWhy = ""; |
189 | if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully | 191 | if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully |
190 | QTextStream indexStream( &indexLib ); | 192 | QTextStream indexStream( &indexLib ); |
191 | QString indexLine; | 193 | QString indexLine; |
192 | qApp->processEvents(); | 194 | qApp->processEvents(); |
193 | // int jig; | 195 | // int jig; |
194 | while ( !indexStream.eof() ) { | 196 | while ( !indexStream.eof() ) { |
195 | 197 | ||
196 | indexLine = indexStream.readLine(); | 198 | indexLine = indexStream.readLine(); |
197 | if ( indexLine != "") { | 199 | if ( indexLine != "") { |
198 | if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) { | 200 | if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) { |
199 | // month = indexLine.left( 3); | 201 | // month = indexLine.left( 3); |
200 | year = indexLine.mid(4,4); | 202 | year = indexLine.mid(4,4); |
201 | // title = indexLine.mid( 9, 50); | 203 | // title = indexLine.mid( 9, 50); |
202 | file = indexLine.mid(60,12); | 204 | file = indexLine.mid(60,12); |
203 | if(file.left(1).find("[",0,TRUE) != -1) | 205 | if(file.left(1).find("[",0,TRUE) != -1) |
204 | file.remove(1,1); | 206 | file.remove(1,1); |
205 | if( file.find("]",0,TRUE) != -1) | 207 | if( file.find("]",0,TRUE) != -1) |
206 | file = file.left( file.find("]",0,TRUE)); | 208 | file = file.left( file.find("]",0,TRUE)); |
207 | //odebug << "file is "+file << oendl; | 209 | //odebug << "file is "+file << oendl; |
208 | /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); | 210 | /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); |
209 | number = indexLine.mid(55,5); | 211 | number = indexLine.mid(55,5); |
210 | number = number.stripWhiteSpace(); | 212 | number = number.stripWhiteSpace(); |
211 | // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); | 213 | // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); |
212 | title = indexLine.mid( 9, 50 ); | 214 | title = indexLine.mid( 9, 50 ); |
213 | title = title.stripWhiteSpace(); | 215 | title = title.stripWhiteSpace(); |
214 | //odebug << "title is "+title << oendl; | 216 | //odebug << "title is "+title << oendl; |
215 | getAuthor(); // grok author | 217 | getAuthor(); // grok author |
216 | author = author.stripWhiteSpace(); | 218 | author = author.stripWhiteSpace(); |
217 | //odebug << "author is "+author << oendl; | 219 | //odebug << "author is "+author << oendl; |
218 | if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author | 220 | if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author |
219 | QString lastName, firstName=""; | 221 | QString lastName, firstName=""; |
220 | int finder=author.findRev( ' ', -1, TRUE); | 222 | int finder=author.findRev( ' ', -1, TRUE); |
221 | lastName=author.right( author.length()-finder); | 223 | lastName=author.right( author.length()-finder); |
222 | firstName=author.left(finder); | 224 | firstName=author.left(finder); |
223 | lastName=lastName.stripWhiteSpace(); | 225 | lastName=lastName.stripWhiteSpace(); |
224 | firstName=firstName.stripWhiteSpace(); | 226 | firstName=firstName.stripWhiteSpace(); |
225 | 227 | ||
226 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names | 228 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names |
227 | author=lastName+", "+firstName; | 229 | author=lastName+", "+firstName; |
228 | } | 230 | } |
229 | 231 | ||
230 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) /*&& (file.find( "]",0, TRUE))*/ ) { | 232 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) /*&& (file.find( "]",0, TRUE))*/ ) { |
231 | // fill string list or something to be able to sort by Author | 233 | // fill string list or something to be able to sort by Author |
232 | if( author.isEmpty() ) | 234 | if( author.isEmpty() ) |
233 | QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); | 235 | QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); |
234 | else { | 236 | else { |
235 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || | 237 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || |
236 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) | 238 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) |
237 | QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); | 239 | QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); |
238 | 240 | ||
239 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || | 241 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || |
240 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) | 242 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) |
241 | QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); | 243 | QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); |
242 | 244 | ||
243 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || | 245 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || |
244 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) | 246 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) |
245 | QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file ); | 247 | QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file ); |
246 | 248 | ||
247 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || | 249 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || |
248 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) | 250 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) |
249 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); | 251 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); |
250 | } | 252 | } |
251 | } | 253 | } |
252 | } | 254 | } |
253 | } | 255 | } |
254 | } | 256 | } |
255 | indexLib.close(); | 257 | indexLib.close(); |
256 | } else { | 258 | } else { |
257 | QString sMsg; | 259 | QString sMsg; |
258 | sMsg = ( tr("Error opening local library index:\n "))+local_index; | 260 | sMsg = ( tr("<p>Error opening local library index:</P> "))+local_index; |
259 | QMessageBox::message( "Error",sMsg); | 261 | QMessageBox::message( "Error",sMsg); |
260 | } | 262 | } |
261 | 263 | ||
262 | } //end Library() | 264 | } //end Library() |
263 | 265 | ||
264 | 266 | ||
265 | /* | 267 | /* |
266 | Groks the author out of the title */ | 268 | Groks the author out of the title */ |
267 | bool LibraryDialog::getAuthor() | 269 | bool LibraryDialog::getAuthor() |
268 | { | 270 | { |
269 | if( title.contains( ", by", TRUE)) { | 271 | if( title.contains( ", by", TRUE)) { |
270 | int auth; | 272 | int auth; |
271 | auth = title.find(", by", 0, TRUE); | 273 | auth = title.find(", by", 0, TRUE); |
272 | author = title.right(title.length() - (auth + 4) ); | 274 | author = title.right(title.length() - (auth + 4) ); |
273 | if( int finder = author.find("[", 0, TRUE)) { | 275 | if( int finder = author.find("[", 0, TRUE)) { |
274 | author = author.left(finder); | 276 | author = author.left(finder); |
275 | } | 277 | } |
276 | } | 278 | } |
277 | else if ( title.contains( "by, ", TRUE) ) { | 279 | else if ( title.contains( "by, ", TRUE) ) { |
278 | int auth; | 280 | int auth; |
279 | auth = title.find("by, ", 0, TRUE); | 281 | auth = title.find("by, ", 0, TRUE); |
280 | author = title.right(title.length() - (auth + 4) ); | 282 | author = title.right(title.length() - (auth + 4) ); |
281 | if( int finder = author.find("[", 0, TRUE)) { | 283 | if( int finder = author.find("[", 0, TRUE)) { |
282 | author = author.left( finder); | 284 | author = author.left( finder); |
283 | } | 285 | } |
284 | } | 286 | } |
285 | else if ( title.contains( " by", TRUE) ) { | 287 | else if ( title.contains( " by", TRUE) ) { |
286 | int auth; | 288 | int auth; |
287 | auth = title.find(" by", 0, TRUE); | 289 | auth = title.find(" by", 0, TRUE); |
288 | author = title.right(title.length() - (auth + 3) ); | 290 | author = title.right(title.length() - (auth + 3) ); |
289 | if( int finder = author.find("[", 0, TRUE)) { | 291 | if( int finder = author.find("[", 0, TRUE)) { |
290 | author = author.left( finder); | 292 | author = author.left( finder); |
291 | } | 293 | } |
292 | } | 294 | } |
293 | else if ( title.contains( "by ", TRUE) ) { | 295 | else if ( title.contains( "by ", TRUE) ) { |
294 | int auth; | 296 | int auth; |
295 | auth = title.find("by ", 0, TRUE); | 297 | auth = title.find("by ", 0, TRUE); |
296 | author = title.right(title.length() - (auth + 3) ); | 298 | author = title.right(title.length() - (auth + 3) ); |
297 | if( int finder = author.find("[", 0, TRUE)) { | 299 | if( int finder = author.find("[", 0, TRUE)) { |
298 | author = author.left( finder); | 300 | author = author.left( finder); |
299 | } | 301 | } |
300 | } | 302 | } |
301 | else if ( title.contains( ",", TRUE) ) { | 303 | else if ( title.contains( ",", TRUE) ) { |
302 | int auth; | 304 | int auth; |
303 | auth = title.find(",", 0, TRUE); | 305 | auth = title.find(",", 0, TRUE); |
304 | author = title.right( title.length() - (auth + 1) ); | 306 | author = title.right( title.length() - (auth + 1) ); |
305 | if ( author.contains( ",", TRUE) ) { | 307 | if ( author.contains( ",", TRUE) ) { |
306 | int auth; | 308 | int auth; |
307 | auth = author.find(",", 0, TRUE); | 309 | auth = author.find(",", 0, TRUE); |
308 | author = author.right( author.length() - (auth + 1) ); | 310 | author = author.right( author.length() - (auth + 1) ); |
309 | } | 311 | } |
310 | if( int finder = author.find("[", 0, TRUE)) { | 312 | if( int finder = author.find("[", 0, TRUE)) { |
311 | author = author.left( finder); | 313 | author = author.left( finder); |
312 | } | 314 | } |
313 | } | 315 | } |
314 | else if ( title.contains( "/", TRUE) ) { | 316 | else if ( title.contains( "/", TRUE) ) { |
315 | int auth; | 317 | int auth; |
316 | auth = title.find("/", 0, TRUE); | 318 | auth = title.find("/", 0, TRUE); |
317 | author = title.right(title.length() - (auth + 1) ); | 319 | author = title.right(title.length() - (auth + 1) ); |
318 | if( int finder = author.find("[", 0, TRUE)) { | 320 | if( int finder = author.find("[", 0, TRUE)) { |
319 | author = author.left( finder); | 321 | author = author.left( finder); |
320 | } | 322 | } |
321 | } | 323 | } |
322 | else if ( title.contains( "of", TRUE) ) { | 324 | else if ( title.contains( "of", TRUE) ) { |
323 | int auth; | 325 | int auth; |
324 | auth = title.find("of", 0, TRUE); | 326 | auth = title.find("of", 0, TRUE); |
325 | author = title.right(title.length() - (auth + 2) ); | 327 | author = title.right(title.length() - (auth + 2) ); |
326 | if( int finder = author.find("[", 0, TRUE)) | 328 | if( int finder = author.find("[", 0, TRUE)) |
327 | { | 329 | { |
328 | author = author.left( finder); | 330 | author = author.left( finder); |
329 | } | 331 | } |
330 | } else { | 332 | } else { |
331 | author = ""; | 333 | author = ""; |
332 | } | 334 | } |
333 | if ( author.contains("et. al")) { | 335 | if ( author.contains("et. al")) { |
334 | int auth; | 336 | int auth; |
335 | auth = author.find("et. al", 0, TRUE); | 337 | auth = author.find("et. al", 0, TRUE); |
336 | author = author.left( auth ); | 338 | author = author.left( auth ); |
337 | } | 339 | } |
338 | if ( author.contains("#")) { | 340 | if ( author.contains("#")) { |
339 | int auth; | 341 | int auth; |
340 | auth = author.find("#", 0, TRUE); | 342 | auth = author.find("#", 0, TRUE); |
341 | author = author.left( auth); | 343 | author = author.left( auth); |
342 | } | 344 | } |
343 | if ( author.contains("(")) { | 345 | if ( author.contains("(")) { |
344 | int auth; | 346 | int auth; |
345 | auth = author.find("(", 0, TRUE); | 347 | auth = author.find("(", 0, TRUE); |
346 | author = author.left( auth); | 348 | author = author.left( auth); |
347 | } | 349 | } |
348 | if ( author.contains("et al")) { | 350 | if ( author.contains("et al")) { |
349 | int auth; | 351 | int auth; |
350 | auth = author.find("et al", 0, TRUE); | 352 | auth = author.find("et al", 0, TRUE); |
351 | author = author.left( auth ); | 353 | author = author.left( auth ); |
352 | } | 354 | } |
353 | QRegExp r = QRegExp("[0-9]", TRUE, FALSE); | 355 | QRegExp r = QRegExp("[0-9]", TRUE, FALSE); |
354 | if ( author.left(2).find( r) != -1 ) { | 356 | if ( author.left(2).find( r) != -1 ) { |
355 | author = ""; | 357 | author = ""; |
356 | } | 358 | } |
357 | // if( author.contains(" ", TRUE)) { | 359 | // if( author.contains(" ", TRUE)) { |
358 | // int suth = author.findRev(" ", -1, TRUE); | 360 | // int suth = author.findRev(" ", -1, TRUE); |
359 | // author = author.right( author.length() - suth); | 361 | // author = author.right( author.length() - suth); |
360 | // } | 362 | // } |
361 | 363 | ||
362 | // title | 364 | // title |
363 | // author | 365 | // author |
364 | return true; | 366 | return true; |
365 | }////// end getAuthor() | 367 | }////// end getAuthor() |
366 | 368 | ||
367 | /* | 369 | /* |
368 | selected one etext*/ | 370 | selected one etext*/ |
369 | void LibraryDialog::select_title( QListViewItem * item) | 371 | void LibraryDialog::select_title( QListViewItem * item) |
370 | { | 372 | { |
371 | if(item != NULL) { | 373 | if(item != NULL) { |
372 | i++; | 374 | i++; |
373 | int index = tabWidget->currentPageIndex(); | 375 | int index = tabWidget->currentPageIndex(); |
374 | DlglistItemTitle = item->text(0); | 376 | DlglistItemTitle = item->text(0); |
375 | DlglistItemYear = item->text(2); | 377 | DlglistItemYear = item->text(2); |
376 | DlglistItemFile = item->text(3); | 378 | DlglistItemFile = item->text(3); |
377 | switch (index) { | 379 | switch (index) { |
378 | case 0: { | 380 | case 0: { |
379 | ListView1->clearSelection(); | 381 | ListView1->clearSelection(); |
380 | } | 382 | } |
381 | break; | 383 | break; |
382 | case 1: { | 384 | case 1: { |
383 | ListView2->clearSelection(); | 385 | ListView2->clearSelection(); |
384 | } | 386 | } |
385 | break; | 387 | break; |
386 | case 2: { | 388 | case 2: { |
387 | ListView3->clearSelection(); | 389 | ListView3->clearSelection(); |
388 | } | 390 | } |
389 | break; | 391 | break; |
390 | case 3: { | 392 | case 3: { |
391 | ListView4->clearSelection(); | 393 | ListView4->clearSelection(); |
392 | } | 394 | } |
393 | break; | 395 | break; |
394 | case 4: { | 396 | case 4: { |
395 | ListView5->clearSelection(); | 397 | ListView5->clearSelection(); |
396 | } | 398 | } |
397 | break; | 399 | break; |
398 | }; | 400 | }; |
399 | } | 401 | } |
400 | 402 | ||
401 | if(DlglistItemTitle.length()>2) { | 403 | if(DlglistItemTitle.length()>2) { |
402 | // DlglistItemNumber = item->text(0); | 404 | // DlglistItemNumber = item->text(0); |
403 | item = 0; | 405 | item = 0; |
404 | odebug << "string from librarydialog is:" << DlglistItemYear << " " << DlglistItemFile << " " << DlglistItemNumber << "" << oendl; | 406 | odebug << "string from librarydialog is:" << DlglistItemYear << " " << DlglistItemFile << " " << DlglistItemNumber << "" << oendl; |
405 | odebug << "Title is "+DlglistItemTitle << oendl; | 407 | odebug << "Title is "+DlglistItemTitle << oendl; |
406 | 408 | ||
407 | // check for connection here | 409 | // check for connection here |
408 | // if( get_extext()) | 410 | // if( get_extext()) |
409 | 411 | ||
410 | if(download_Etext()) { | 412 | if(download_Etext()) { |
411 | // odebug << "get here 2" << oendl; | 413 | // odebug << "get here 2" << oendl; |
412 | if(i_binary == 1) { | 414 | if(i_binary == 1) { |
413 | 415 | ||
414 | } | 416 | } |
415 | if(checkBox->isChecked () ) { | 417 | if(checkBox->isChecked () ) { |
416 | accept(); | 418 | accept(); |
417 | } | 419 | } |
418 | } | 420 | } |
419 | } | 421 | } |
420 | } | 422 | } |
421 | 423 | ||
422 | bool LibraryDialog::download_Etext() | 424 | bool LibraryDialog::download_Etext() |
423 | { // ftp method | 425 | { // ftp method |
424 | // might have to use old gpl'd ftp for embedded!! | 426 | // might have to use old gpl'd ftp for embedded!! |
425 | Config cfg("Gutenbrowser"); | 427 | Config cfg("Gutenbrowser"); |
426 | cfg.setGroup("FTPsite"); | 428 | cfg.setGroup("FTPsite"); |
427 | ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org"); | 429 | ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org"); |
428 | ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg"); | 430 | ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg"); |
429 | 431 | ||
430 | odebug << "about to network dialog" << oendl; | 432 | odebug << "about to network dialog" << oendl; |
431 | QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile; | 433 | QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile; |
432 | 434 | ||
433 | //////////////////// FIXME- if 'x' is part of real name.... | 435 | //////////////////// FIXME- if 'x' is part of real name.... |
434 | NewlistItemFile = DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).left(DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).find("x", 1, FALSE)); | 436 | NewlistItemFile = DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).left(DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).find("x", 1, FALSE)); |
435 | 437 | ||
436 | if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) { | 438 | if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) { |
437 | NewlistItemFile.replace( 0,4, DlglistItemFile.left(4)); | 439 | NewlistItemFile.replace( 0,4, DlglistItemFile.left(4)); |
438 | odebug << "NewlistItemFile is now "+NewlistItemFile << oendl; | 440 | odebug << "NewlistItemFile is now "+NewlistItemFile << oendl; |
439 | } | 441 | } |
440 | NewlistItemYear = DlglistItemYear.right(2); | 442 | NewlistItemYear = DlglistItemYear.right(2); |
441 | int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10); | 443 | int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10); |
442 | odebug << NewlistItemYear << oendl; | 444 | odebug << NewlistItemYear << oendl; |
443 | if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) { | 445 | if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) { |
444 | NewlistItemYear = "90"; | 446 | NewlistItemYear = "90"; |
445 | } | 447 | } |
446 | Edir ="etext" +NewlistItemYear; | 448 | Edir ="etext" +NewlistItemYear; |
447 | dir= ftp_base_dir + "/etext" +NewlistItemYear+"/"; | 449 | dir= ftp_base_dir + "/etext" +NewlistItemYear+"/"; |
448 | if( ftp_base_dir.find("=",0,true) ) | 450 | if( ftp_base_dir.find("=",0,true) ) |
449 | ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1); | 451 | ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1); |
450 | 452 | ||
451 | networkUrl= "ftp://"+ftp_host+dir; | 453 | networkUrl= "ftp://"+ftp_host+dir; |
452 | 454 | ||
453 | outputFile=local_library+".guten_temp"; | 455 | outputFile=local_library+".guten_temp"; |
454 | //odebug << "Download file:" << NewlistItemFile << "" << oendl; | 456 | //odebug << "Download file:" << NewlistItemFile << "" << oendl; |
455 | odebug << "Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile << oendl; | 457 | odebug << "Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile << oendl; |
456 | QStringList networkList; | 458 | QStringList networkList; |
457 | networkList.append((const char *)ftp_host); | 459 | networkList.append((const char *)ftp_host); |
458 | networkList.append((const char *)dir); | 460 | networkList.append((const char *)dir); |
459 | networkList.append((const char *)outputFile); | 461 | networkList.append((const char *)outputFile); |
460 | networkList.append((const char *)NewlistItemFile); | 462 | networkList.append((const char *)NewlistItemFile); |
461 | //<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile; | 463 | //<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile; |
462 | 464 | ||
463 | NetworkDialog *NetworkDlg; | 465 | NetworkDialog *NetworkDlg; |
464 | NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList); | 466 | NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList); |
465 | 467 | ||
466 | 468 | ||
467 | if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer | 469 | if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer |
468 | File_Name= NetworkDlg->localFileName; | 470 | File_Name= NetworkDlg->localFileName; |
469 | odebug << "back to Library from Network Dialog" << oendl; | 471 | odebug << "back to Library from Network Dialog" << oendl; |
470 | odebug << "Just downloaded "+NetworkDlg->localFileName << oendl; | 472 | odebug << "Just downloaded "+NetworkDlg->localFileName << oendl; |
471 | 473 | ||
472 | // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found | 474 | // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found |
473 | // QString oldName=File_Name; | 475 | // QString oldName=File_Name; |
474 | // File_Name.replace(0,local_library.length(),downDir); | 476 | // File_Name.replace(0,local_library.length(),downDir); |
475 | // odebug << "File_Name now is "+File_Name << oendl; | 477 | // odebug << "File_Name now is "+File_Name << oendl; |
476 | 478 | ||
477 | // } | 479 | // } |
478 | // rename .txt to .etx | 480 | // rename .txt to .etx |
479 | if(NetworkDlg->successDownload) { | 481 | if(NetworkDlg->successDownload) { |
480 | odebug << "Filename is "+File_Name << oendl; | 482 | odebug << "Filename is "+File_Name << oendl; |
481 | if(File_Name.right(4)==".txt") { | 483 | if(File_Name.right(4)==".txt") { |
482 | QString s_fileName=File_Name; | 484 | QString s_fileName=File_Name; |
483 | s_fileName.replace( s_fileName.length()-3,3,"gtn"); | 485 | s_fileName.replace( s_fileName.length()-3,3,"gtn"); |
484 | // s_fileName.replace( s_fileName.length()-3,3,"etx"); | 486 | // s_fileName.replace( s_fileName.length()-3,3,"etx"); |
485 | rename(File_Name.latin1(),s_fileName.latin1()); | 487 | rename(File_Name.latin1(),s_fileName.latin1()); |
486 | File_Name=s_fileName; | 488 | File_Name=s_fileName; |
487 | 489 | ||
488 | odebug << "Filename is now "+File_Name << oendl; | 490 | odebug << "Filename is now "+File_Name << oendl; |
489 | 491 | ||
490 | } | 492 | } |
491 | if(File_Name.length() > 5 ) { | 493 | if(File_Name.length() > 5 ) { |
492 | setTitle(); | 494 | setTitle(); |
493 | QFileInfo fi(File_Name); | 495 | QFileInfo fi(File_Name); |
494 | QString name_file=fi.fileName(); | 496 | QString name_file=fi.fileName(); |
495 | name_file=name_file.left(name_file.length()-4); | 497 | name_file=name_file.left(name_file.length()-4); |
496 | 498 | ||
497 | odebug << "Setting doclink" << oendl; | 499 | odebug << "Setting doclink" << oendl; |
498 | DocLnk lnk; | 500 | DocLnk lnk; |
499 | odebug << "name is "+name_file << oendl; | 501 | odebug << "name is "+name_file << oendl; |
500 | lnk.setName(name_file); //sets file name | 502 | lnk.setName(name_file); //sets file name |
501 | odebug << "Title is "+DlglistItemTitle << oendl; | 503 | odebug << "Title is "+DlglistItemTitle << oendl; |
502 | lnk.setComment(DlglistItemTitle); | 504 | lnk.setComment(DlglistItemTitle); |
503 | 505 | ||
504 | odebug << "Filename is "+File_Name << oendl; | 506 | odebug << "Filename is "+File_Name << oendl; |
505 | lnk.setFile(File_Name); //sets File property | 507 | lnk.setFile(File_Name); //sets File property |
506 | lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D | 508 | lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D |
507 | lnk.setExec(File_Name); | 509 | lnk.setExec(File_Name); |
508 | lnk.setIcon("gutenbrowser/Gutenbrowser"); | 510 | lnk.setIcon("gutenbrowser/Gutenbrowser"); |
509 | if(!lnk.writeLink()) { | 511 | if(!lnk.writeLink()) { |
510 | odebug << "Writing doclink did not work" << oendl; | 512 | odebug << "Writing doclink did not work" << oendl; |
511 | } else { | 513 | } else { |
512 | } | 514 | } |
513 | } else | 515 | } else |
514 | QMessageBox::message("Note","There was an error\nwith the file"); | 516 | QMessageBox::message("Note","<p>There was an error with the file</p>"); |
515 | } | 517 | } |
516 | } | 518 | } |
517 | return true; | 519 | return true; |
518 | } | 520 | } |
519 | 521 | ||
520 | bool LibraryDialog::httpDownload() | 522 | bool LibraryDialog::httpDownload() |
521 | {// httpDownload | 523 | {// httpDownload |
522 | #ifndef Q_WS_QWS | 524 | #ifndef Q_WS_QWS |
523 | Config config("Gutenbrowser"); | 525 | Config config("Gutenbrowser"); |
524 | config.setGroup( "Browser" ); | 526 | config.setGroup( "Browser" ); |
525 | QString brow = config.readEntry("Preferred", ""); | 527 | QString brow = config.readEntry("Preferred", ""); |
526 | QString file_name = "./.guten_temp"; | 528 | QString file_name = "./.guten_temp"; |
527 | // config.setGroup( "HttpServer" ); | 529 | // config.setGroup( "HttpServer" ); |
528 | // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); | 530 | // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); |
529 | QString httpName = proxy_http + "/"+Edir; | 531 | QString httpName = proxy_http + "/"+Edir; |
530 | // progressBar->setProgress( i); | 532 | // progressBar->setProgress( i); |
531 | i++; | 533 | i++; |
532 | if ( brow != "Konq") { /////////// use lynx | 534 | if ( brow != "Konq") { /////////// use lynx |
533 | // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name; | 535 | // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name; |
534 | // system(cmd); | 536 | // system(cmd); |
535 | } else { //////////// use KFM | 537 | } else { //////////// use KFM |
536 | // KFM::download( httpName, file_name); | 538 | // KFM::download( httpName, file_name); |
537 | } | 539 | } |
538 | i++; | 540 | i++; |
539 | QFile tmp( file_name); | 541 | QFile tmp( file_name); |
540 | QString str; | 542 | QString str; |
541 | if (tmp.open(IO_ReadOnly)) { | 543 | if (tmp.open(IO_ReadOnly)) { |
542 | QTextStream t( &tmp ); // use a text stream | 544 | QTextStream t( &tmp ); // use a text stream |
543 | while ( !t.eof()) { | 545 | while ( !t.eof()) { |
544 | QString s = t.readLine(); | 546 | QString s = t.readLine(); |
545 | if (s.contains( NewlistItemFile, FALSE) && (s.contains(".txt")) ) { | 547 | if (s.contains( NewlistItemFile, FALSE) && (s.contains(".txt")) ) { |
546 | str = s.mid( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6, (s.find( ".txt</A>", 0, TRUE) + 4) - ( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6 ) ); | 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 ) ); |
547 | httpName += "/" + str; | 549 | httpName += "/" + str; |
548 | } | 550 | } |
549 | } //end of while loop | 551 | } //end of while loop |
550 | } | 552 | } |
551 | tmp.close(); | 553 | tmp.close(); |
552 | m_getFilePath = local_library + str; | 554 | m_getFilePath = local_library + str; |
553 | i++; | 555 | i++; |
554 | if ( brow != "KFM"){ ///////// use lynx | 556 | if ( brow != "KFM"){ ///////// use lynx |
555 | QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; | 557 | QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; |
556 | // QMessageBox::message("Error", cmd); | 558 | // QMessageBox::message("Error", cmd); |
557 | system(cmd); | 559 | system(cmd); |
558 | } else { ////////// use KFM | 560 | } else { ////////// use KFM |
559 | // KFM::download( httpName, m_getFilePath); | 561 | // KFM::download( httpName, m_getFilePath); |
560 | } | 562 | } |
561 | i++; | 563 | i++; |
562 | #endif | 564 | #endif |
563 | return false; | 565 | return false; |
564 | } | 566 | } |
565 | 567 | ||
566 | void LibraryDialog::cancelIt() | 568 | void LibraryDialog::cancelIt() |
567 | { | 569 | { |
568 | saveConfig(); | 570 | saveConfig(); |
569 | 571 | ||
570 | DlglistItemNumber = ""; | 572 | DlglistItemNumber = ""; |
571 | this->reject(); | 573 | this->reject(); |
572 | } | 574 | } |
573 | 575 | ||
574 | bool LibraryDialog::setTitle() | 576 | bool LibraryDialog::setTitle() |
575 | { | 577 | { |
576 | Config config("Gutenbrowser"); | 578 | Config config("Gutenbrowser"); |
577 | odebug << "setting title" << oendl; | 579 | odebug << "setting title" << oendl; |
578 | odebug << DlglistItemTitle << oendl; | 580 | odebug << DlglistItemTitle << oendl; |
579 | 581 | ||
580 | if( DlglistItemTitle.find("[",0,TRUE) != -1) | 582 | if( DlglistItemTitle.find("[",0,TRUE) != -1) |
581 | DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" ); | 583 | DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" ); |
582 | if( DlglistItemTitle.find("]",0,TRUE) !=-1) | 584 | if( DlglistItemTitle.find("]",0,TRUE) !=-1) |
583 | DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); | 585 | DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); |
584 | odebug << "Title being set is "+DlglistItemTitle << oendl; | 586 | odebug << "Title being set is "+DlglistItemTitle << oendl; |
585 | int test = 0; | 587 | int test = 0; |
586 | QString ramble, temp; | 588 | QString ramble, temp; |
587 | config.setGroup("Files"); | 589 | config.setGroup("Files"); |
588 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 590 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
589 | int i_numofFiles = s_numofFiles.toInt(); | 591 | int i_numofFiles = s_numofFiles.toInt(); |
590 | for ( int i = 0; i <= i_numofFiles; i++){ | 592 | for ( int i = 0; i <= i_numofFiles; i++){ |
591 | temp.setNum( i); | 593 | temp.setNum( i); |
592 | ramble = config.readEntry( temp, "" ); | 594 | ramble = config.readEntry( temp, "" ); |
593 | if( strcmp( ramble, File_Name) == 0){ | 595 | if( strcmp( ramble, File_Name) == 0){ |
594 | test = 1; | 596 | test = 1; |
595 | } | 597 | } |
596 | } | 598 | } |
597 | config.setGroup("Files"); | 599 | config.setGroup("Files"); |
598 | config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); | 600 | config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); |
599 | QString interger; | 601 | QString interger; |
600 | interger.setNum( i_numofFiles +1); | 602 | interger.setNum( i_numofFiles +1); |
601 | config.writeEntry( interger, File_Name); | 603 | config.writeEntry( interger, File_Name); |
602 | config.setGroup( "Titles" ); | 604 | config.setGroup( "Titles" ); |
603 | config.writeEntry( File_Name, DlglistItemTitle); | 605 | config.writeEntry( File_Name, DlglistItemTitle); |
604 | 606 | ||
605 | test = 0; | 607 | test = 0; |
606 | return true; | 608 | return true; |
607 | } | 609 | } |
608 | 610 | ||
609 | 611 | ||
610 | void LibraryDialog::saveConfig() | 612 | void LibraryDialog::saveConfig() |
611 | { | 613 | { |
612 | Config config("Gutenbrowser"); | 614 | Config config("Gutenbrowser"); |
613 | if( httpBox->isChecked() == TRUE) { | 615 | if( httpBox->isChecked() == TRUE) { |
614 | checked = 1; | 616 | checked = 1; |
615 | config.setGroup( "Proxy" ); | 617 | config.setGroup( "Proxy" ); |
616 | config.writeEntry("IsChecked", "TRUE"); | 618 | config.writeEntry("IsChecked", "TRUE"); |
617 | } else { | 619 | } else { |
618 | checked = 0; | 620 | checked = 0; |
619 | config.setGroup( "Proxy" ); | 621 | config.setGroup( "Proxy" ); |
620 | config.writeEntry("IsChecked", "FALSE"); | 622 | config.writeEntry("IsChecked", "FALSE"); |
621 | } | 623 | } |
622 | if (authBox->isChecked() == TRUE) { | 624 | if (authBox->isChecked() == TRUE) { |
623 | config.setGroup("SortAuth"); | 625 | config.setGroup("SortAuth"); |
624 | config.writeEntry("authSort", "TRUE"); | 626 | config.writeEntry("authSort", "TRUE"); |
625 | } else { | 627 | } else { |
626 | config.setGroup("SortAuth"); | 628 | config.setGroup("SortAuth"); |
627 | config.writeEntry("authSort", "FALSE"); | 629 | config.writeEntry("authSort", "FALSE"); |
628 | } | 630 | } |
629 | // config.write(); | 631 | // config.write(); |
630 | } | 632 | } |
631 | 633 | ||
632 | /* | 634 | /* |
633 | searches library index for user word*/ | 635 | searches library index for user word*/ |
634 | void LibraryDialog::onButtonSearch() | 636 | void LibraryDialog::onButtonSearch() |
635 | { | 637 | { |
636 | ListView1->clearSelection(); | 638 | ListView1->clearSelection(); |
637 | ListView2->clearSelection(); | 639 | ListView2->clearSelection(); |
638 | ListView3->clearSelection(); | 640 | ListView3->clearSelection(); |
639 | ListView4->clearSelection(); | 641 | ListView4->clearSelection(); |
640 | ListView5->clearSelection(); | 642 | ListView5->clearSelection(); |
641 | 643 | ||
642 | int curTab=tabWidget->currentPageIndex(); | 644 | int curTab=tabWidget->currentPageIndex(); |
643 | SearchDialog* searchDlg; | 645 | SearchDialog* searchDlg; |
644 | 646 | ||
645 | // if( resultsList) | 647 | // if( resultsList) |
646 | searchDlg = new SearchDialog( this, "Library Search", TRUE); | 648 | searchDlg = new SearchDialog( this, "Library Search", TRUE); |
647 | searchDlg->setCaption( tr( "Library Search" ) ); | 649 | searchDlg->setCaption( tr( "Library Search" ) ); |
648 | searchDlg->setLabel( "- author or title"); | 650 | searchDlg->setLabel( "- author or title"); |
649 | QString resultString; | 651 | QString resultString; |
650 | int i_berger = 0; | 652 | int i_berger = 0; |
651 | if( searchDlg->exec() != 0 ) { | 653 | if( searchDlg->exec() != 0 ) { |
652 | QString searcherStr = searchDlg->get_text(); | 654 | QString searcherStr = searchDlg->get_text(); |
653 | int fluff=0; | 655 | int fluff=0; |
654 | 656 | ||
655 | // int tabPage = tabWidget->currentPageIndex(); | 657 | // int tabPage = tabWidget->currentPageIndex(); |
656 | // TODO ititerate here... struct<listViews>?? | 658 | // TODO ititerate here... struct<listViews>?? |
657 | 659 | ||
658 | QListViewItemIterator it1( ListView1 ); | 660 | QListViewItemIterator it1( ListView1 ); |
659 | QListViewItemIterator it2( ListView2 ); | 661 | QListViewItemIterator it2( ListView2 ); |
660 | QListViewItemIterator it3( ListView3 ); | 662 | QListViewItemIterator it3( ListView3 ); |
661 | QListViewItemIterator it4( ListView4 ); | 663 | QListViewItemIterator it4( ListView4 ); |
662 | QListViewItemIterator it5( ListView5 ); | 664 | QListViewItemIterator it5( ListView5 ); |
663 | 665 | ||
664 | //// this is really pitiful work, | 666 | //// this is really pitiful work, |
665 | /////// | 667 | /////// |
666 | bool cS; | 668 | bool cS; |
667 | if( searchDlg->caseSensitiveCheckBox->isChecked()) | 669 | if( searchDlg->caseSensitiveCheckBox->isChecked()) |
668 | cS=true; //case sensitive | 670 | cS=true; //case sensitive |
669 | else | 671 | else |
670 | cS=false; | 672 | cS=false; |
671 | 673 | ||
672 | if(fluff==0) { | 674 | if(fluff==0) { |
673 | for ( ; it1.current(); ++it1 ) { | 675 | for ( ; it1.current(); ++it1 ) { |
674 | resultString = ( it1.current() )->text(0); | 676 | resultString = ( it1.current() )->text(0); |
675 | resultString += (" : "); | 677 | resultString += (" : "); |
676 | resultString += ( it1.current() )->text(2); | 678 | resultString += ( it1.current() )->text(2); |
677 | resultString += (" : "); | 679 | resultString += (" : "); |
678 | resultString += ( it1.current() )->text(3); | 680 | resultString += ( it1.current() )->text(3); |
679 | if( resultString.find( searcherStr, 0, cS) != -1) | 681 | if( resultString.find( searcherStr, 0, cS) != -1) |
680 | { | 682 | { |
681 | Searchlist.append( resultString); | 683 | Searchlist.append( resultString); |
682 | } | 684 | } |
683 | } | 685 | } |
684 | } | 686 | } |
685 | if(fluff==0) {// search routine here | 687 | if(fluff==0) {// search routine here |
686 | for ( ; it2.current(); ++it2 ) { | 688 | for ( ; it2.current(); ++it2 ) { |
687 | resultString = ( it2.current() )->text(0); | 689 | resultString = ( it2.current() )->text(0); |
688 | resultString += (" : "); | 690 | resultString += (" : "); |
689 | resultString += ( it2.current() )->text(2); | 691 | resultString += ( it2.current() )->text(2); |
690 | resultString += (" : "); | 692 | resultString += (" : "); |
691 | resultString += ( it2.current() )->text(3); | 693 | resultString += ( it2.current() )->text(3); |
692 | if( resultString.find( searcherStr, 0, cS) != -1) { | 694 | if( resultString.find( searcherStr, 0, cS) != -1) { |
693 | Searchlist.append( resultString); | 695 | Searchlist.append( resultString); |
694 | } | 696 | } |
695 | } | 697 | } |
696 | } | 698 | } |
697 | if(fluff==0) {// search routine here | 699 | if(fluff==0) {// search routine here |
698 | for ( ; it3.current(); ++it3 ) { | 700 | for ( ; it3.current(); ++it3 ) { |
699 | resultString = ( it3.current() )->text(0); | 701 | resultString = ( it3.current() )->text(0); |
700 | resultString += (" : "); | 702 | resultString += (" : "); |
701 | resultString += ( it3.current() )->text(2); | 703 | resultString += ( it3.current() )->text(2); |
702 | resultString += (" : "); | 704 | resultString += (" : "); |
703 | resultString += ( it3.current() )->text(3); | 705 | resultString += ( it3.current() )->text(3); |
704 | 706 | ||
705 | if( resultString.find( searcherStr, 0, cS) != -1) { | 707 | if( resultString.find( searcherStr, 0, cS) != -1) { |
706 | Searchlist.append( resultString); | 708 | Searchlist.append( resultString); |
707 | } | 709 | } |
708 | } | 710 | } |
709 | } | 711 | } |
710 | if(fluff==0) { | 712 | if(fluff==0) { |
711 | // search routine here | 713 | // search routine here |
712 | for ( ; it4.current(); ++it4 ) { | 714 | for ( ; it4.current(); ++it4 ) { |
713 | resultString = ( it4.current() )->text(0); | 715 | resultString = ( it4.current() )->text(0); |
714 | resultString += (" : "); | 716 | resultString += (" : "); |
715 | resultString += ( it4.current() )->text(2); | 717 | resultString += ( it4.current() )->text(2); |
716 | resultString += (" : "); | 718 | resultString += (" : "); |
717 | resultString += ( it4.current() )->text(3); | 719 | resultString += ( it4.current() )->text(3); |
718 | if( resultString.find( searcherStr, 0, cS) != -1) { | 720 | if( resultString.find( searcherStr, 0, cS) != -1) { |
719 | Searchlist.append( resultString); | 721 | Searchlist.append( resultString); |
720 | } | 722 | } |
721 | } | 723 | } |
722 | } | 724 | } |
723 | if(fluff==0) { // search routine here | 725 | if(fluff==0) { // search routine here |
724 | for ( ; it5.current(); ++it5 ) { | 726 | for ( ; it5.current(); ++it5 ) { |
725 | resultString = ( it5.current() )->text(0); | 727 | resultString = ( it5.current() )->text(0); |
726 | resultString += (" : "); | 728 | resultString += (" : "); |
727 | resultString += ( it5.current() )->text(2); | 729 | resultString += ( it5.current() )->text(2); |
728 | resultString += (" : "); | 730 | resultString += (" : "); |
729 | resultString += ( it5.current() )->text(3); | 731 | resultString += ( it5.current() )->text(3); |
730 | if( resultString.find( searcherStr, 0, cS) != -1) { | 732 | if( resultString.find( searcherStr, 0, cS) != -1) { |
731 | Searchlist.append( resultString); | 733 | Searchlist.append( resultString); |
732 | } | 734 | } |
733 | } | 735 | } |
734 | } | 736 | } |
735 | 737 | ||
736 | tabWidget->setCurrentPage( curTab); | 738 | tabWidget->setCurrentPage( curTab); |
737 | 739 | ||
738 | Searchlist.sort(); | 740 | Searchlist.sort(); |
739 | SearchResultsDlg* SearchResultsDialog; | 741 | SearchResultsDlg* SearchResultsDialog; |
740 | SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); | 742 | SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); |
741 | 743 | ||
742 | SearchResultsDialog->showMaximized(); | 744 | SearchResultsDialog->showMaximized(); |
743 | if( SearchResultsDialog->exec() != 0) { | 745 | if( SearchResultsDialog->exec() != 0) { |
744 | texter = SearchResultsDialog->selText; | 746 | texter = SearchResultsDialog->selText; |
745 | // odebug << texter << oendl; | 747 | // odebug << texter << oendl; |
746 | resultLs= SearchResultsDialog->resultsList; | 748 | resultLs= SearchResultsDialog->resultsList; |
747 | i_berger = 1; | 749 | i_berger = 1; |
748 | } | 750 | } |
749 | Searchlist.clear(); | 751 | Searchlist.clear(); |
750 | 752 | ||
751 | // if(SearchResultsDialog) | 753 | // if(SearchResultsDialog) |
752 | // delete SearchResultsDialog; | 754 | // delete SearchResultsDialog; |
753 | QString tester; | 755 | QString tester; |
754 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { | 756 | for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { |
755 | texter.sprintf("%s \n",(*it).latin1()); | 757 | texter.sprintf("%s \n",(*it).latin1()); |
756 | // odebug << texter << oendl; | 758 | // odebug << texter << oendl; |
757 | if( tester!=texter) | 759 | if( tester!=texter) |
758 | parseSearchResults( texter); | 760 | parseSearchResults( texter); |
759 | tester = texter; | 761 | tester = texter; |
760 | } | 762 | } |
761 | if(searchDlg) | 763 | if(searchDlg) |
762 | delete searchDlg; | 764 | delete searchDlg; |
763 | } | 765 | } |
764 | if(checkBox->isChecked() ) { | 766 | if(checkBox->isChecked() ) { |
765 | accept(); | 767 | accept(); |
766 | } else { | 768 | } else { |
767 | setActiveWindow(); | 769 | setActiveWindow(); |
768 | } | 770 | } |
769 | } | 771 | } |
770 | 772 | ||
771 | /* | 773 | /* |
772 | splits the result string and calls download for the current search result*/ | 774 | splits the result string and calls download for the current search result*/ |
773 | void LibraryDialog::parseSearchResults( QString resultStr) | 775 | void LibraryDialog::parseSearchResults( QString resultStr) |
774 | { | 776 | { |
775 | 777 | ||
776 | int stringLeng=resultStr.length(); | 778 | int stringLeng=resultStr.length(); |
777 | QString my; | 779 | QString my; |
778 | my.setNum( stringLeng, 10); | 780 | my.setNum( stringLeng, 10); |
779 | 781 | ||
780 | if( resultStr.length() > 2 && resultStr.length() < 130) { | 782 | if( resultStr.length() > 2 && resultStr.length() < 130) { |
781 | int titleInt = resultStr.find( " : ", 0, TRUE); | 783 | int titleInt = resultStr.find( " : ", 0, TRUE); |
782 | DlglistItemTitle = resultStr.left( titleInt); | 784 | DlglistItemTitle = resultStr.left( titleInt); |
783 | int yearInt = resultStr.find( " : ", titleInt+3, TRUE); | 785 | int yearInt = resultStr.find( " : ", titleInt+3, TRUE); |
784 | DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); | 786 | DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); |
785 | DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); | 787 | DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); |
786 | download_Etext(); | 788 | download_Etext(); |
787 | } | 789 | } |
788 | /* | 790 | /* |
789 | printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/ | 791 | printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/ |
790 | } | 792 | } |
791 | 793 | ||
792 | // bool LibraryDialog::UnzipIt( QString zipFile) { | 794 | // bool LibraryDialog::UnzipIt( QString zipFile) { |
793 | // //////////TODO findsome other way of dealingwithzip files. | 795 | // //////////TODO findsome other way of dealingwithzip files. |
794 | // ///usr/bin/unzip"; | 796 | // ///usr/bin/unzip"; |
795 | // if( QFile::exists( zipFile)) { | 797 | // if( QFile::exists( zipFile)) { |
796 | // // QString thatFile = local_library +"PGWHOLE.TXT"; | 798 | // // QString thatFile = local_library +"PGWHOLE.TXT"; |
797 | // QString cmd; | 799 | // QString cmd; |
798 | // #if defined(_WS_X11_) | 800 | // #if defined(_WS_X11_) |
799 | // cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; | 801 | // cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; |
800 | // #endif | 802 | // #endif |
801 | // #if defined(_WS_WIN_) | 803 | // #if defined(_WS_WIN_) |
802 | // QString temp= QDir::convertSeparators(local_library); | 804 | // QString temp= QDir::convertSeparators(local_library); |
803 | // zipFile=QDir::convertSeparators( zipFile); | 805 | // zipFile=QDir::convertSeparators( zipFile); |
804 | // cmd = temp+"unzip.exe -o " +zipFile/*newestLibraryFile */+" -d " + temp; | 806 | // cmd = temp+"unzip.exe -o " +zipFile/*newestLibraryFile */+" -d " + temp; |
805 | // #endif | 807 | // #endif |
806 | // #ifndef Q_WS_QWS | 808 | // #ifndef Q_WS_QWS |
807 | // // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; | 809 | // // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; |
808 | // cmd = "unzip " + zipFile; | 810 | // cmd = "unzip " + zipFile; |
809 | // #endif | 811 | // #endif |
810 | 812 | ||
811 | // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No); | 813 | // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No); |
812 | // if (exit==QMessageBox::Yes) { | 814 | // if (exit==QMessageBox::Yes) { |
813 | // odebug << "Issuing the command "+cmd << oendl; | 815 | // odebug << "Issuing the command "+cmd << oendl; |
814 | // #if defined(_WS_WIN_) | 816 | // #if defined(_WS_WIN_) |
815 | // WinExec( cmd, SW_HIDE ); | 817 | // WinExec( cmd, SW_HIDE ); |
816 | // #endif | 818 | // #endif |
817 | // #if defined(_WS_X11_) | 819 | // #if defined(_WS_X11_) |
818 | // system( cmd); | 820 | // system( cmd); |
819 | // #endif | 821 | // #endif |
820 | // #ifndef Q_WS_QWS | 822 | // #ifndef Q_WS_QWS |
821 | // system( cmd); | 823 | // system( cmd); |
822 | // #endif | 824 | // #endif |
823 | // // printf("unzip\n"); | 825 | // // printf("unzip\n"); |
824 | // // remove( zipFile /*newestLibraryFile*/); | 826 | // // remove( zipFile /*newestLibraryFile*/); |
825 | // return true; | 827 | // return true; |
826 | // } | 828 | // } |
827 | // else if(exit==QMessageBox::No) { | 829 | // else if(exit==QMessageBox::No) { |
828 | // // printf("unzip\n"); | 830 | // // printf("unzip\n"); |
829 | // return false; | 831 | // return false; |
830 | // } | 832 | // } |
831 | // } else { | 833 | // } else { |
832 | // // QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); | 834 | // // QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); |
833 | // return false; | 835 | // return false; |
834 | // } | 836 | // } |
835 | // return true; | 837 | // return true; |
836 | // } | 838 | // } |
837 | 839 | ||
838 | void LibraryDialog::sort() | 840 | void LibraryDialog::sort() |
839 | { | 841 | { |
840 | 842 | ||
841 | } | 843 | } |
842 | 844 | ||
843 | /* | 845 | /* |
844 | Downloads the current selected listitem*/ | 846 | Downloads the current selected listitem*/ |
845 | bool LibraryDialog::getItem(QListViewItem *it) | 847 | bool LibraryDialog::getItem(QListViewItem *it) |
846 | { | 848 | { |
847 | // odebug << "selected getItem" << oendl; | 849 | // odebug << "selected getItem" << oendl; |
848 | 850 | ||
849 | // DlglistItemNumber = it->text(0); | 851 | // DlglistItemNumber = it->text(0); |
850 | DlglistItemTitle = it->text(0); | 852 | DlglistItemTitle = it->text(0); |
851 | DlglistItemYear = it->text(2); | 853 | DlglistItemYear = it->text(2); |
852 | DlglistItemFile = it->text(3); | 854 | DlglistItemFile = it->text(3); |
853 | 855 | ||
854 | if(download_Etext()) { | 856 | if(download_Etext()) { |
855 | if(i_binary == 1) { | 857 | if(i_binary == 1) { |
856 | } | 858 | } |
857 | } | 859 | } |
858 | return true; | 860 | return true; |
859 | } | 861 | } |
860 | 862 | ||
861 | /* | 863 | /* |
862 | download button is pushed so we get the current items to download*/ | 864 | download button is pushed so we get the current items to download*/ |
863 | bool LibraryDialog::onButtonDownload() | 865 | bool LibraryDialog::onButtonDownload() |
864 | { | 866 | { |
865 | // odebug << "selected onButtonDownloadz" << oendl; | 867 | // odebug << "selected onButtonDownloadz" << oendl; |
866 | 868 | ||
867 | QListViewItemIterator it1( ListView1 ); | 869 | QListViewItemIterator it1( ListView1 ); |
868 | QListViewItemIterator it2( ListView2 ); | 870 | QListViewItemIterator it2( ListView2 ); |
869 | QListViewItemIterator it3( ListView3 ); | 871 | QListViewItemIterator it3( ListView3 ); |
870 | QListViewItemIterator it4( ListView4 ); | 872 | QListViewItemIterator it4( ListView4 ); |
871 | QListViewItemIterator it5( ListView5 ); | 873 | QListViewItemIterator it5( ListView5 ); |
872 | 874 | ||
873 | // iterate through all items of the listview | 875 | // iterate through all items of the listview |
874 | for ( ; it1.current(); ++it1 ) { | 876 | for ( ; it1.current(); ++it1 ) { |
875 | if ( it1.current()->isSelected() ) | 877 | if ( it1.current()->isSelected() ) |
876 | getItem(it1.current()); | 878 | getItem(it1.current()); |
877 | it1.current()->setSelected(FALSE); | 879 | it1.current()->setSelected(FALSE); |
878 | } | 880 | } |
879 | for ( ; it2.current(); ++it2 ) { | 881 | for ( ; it2.current(); ++it2 ) { |
880 | if ( it2.current()->isSelected() ) | 882 | if ( it2.current()->isSelected() ) |
881 | getItem(it2.current()); | 883 | getItem(it2.current()); |
882 | it2.current()->setSelected(FALSE); | 884 | it2.current()->setSelected(FALSE); |
883 | } | 885 | } |
884 | for ( ; it3.current(); ++it3 ) { | 886 | for ( ; it3.current(); ++it3 ) { |
885 | if ( it3.current()->isSelected() ) | 887 | if ( it3.current()->isSelected() ) |
886 | getItem(it3.current()); | 888 | getItem(it3.current()); |
887 | it3.current()->setSelected(FALSE); | 889 | it3.current()->setSelected(FALSE); |
888 | } | 890 | } |
889 | for ( ; it4.current(); ++it4 ) { | 891 | for ( ; it4.current(); ++it4 ) { |
890 | if ( it4.current()->isSelected() ) | 892 | if ( it4.current()->isSelected() ) |
891 | getItem(it4.current()); | 893 | getItem(it4.current()); |
892 | it4.current()->setSelected(FALSE); | 894 | it4.current()->setSelected(FALSE); |
893 | } | 895 | } |
894 | for ( ; it5.current(); ++it5 ) { | 896 | for ( ; it5.current(); ++it5 ) { |
895 | if ( it5.current()->isSelected() ) | 897 | if ( it5.current()->isSelected() ) |
896 | getItem(it5.current()); | 898 | getItem(it5.current()); |
897 | it5.current()->setSelected(FALSE); | 899 | it5.current()->setSelected(FALSE); |
898 | } | 900 | } |
899 | return true; | 901 | return true; |
900 | } | 902 | } |
901 | 903 | ||
902 | 904 | ||
903 | /* | 905 | /* |
904 | handles the sorting combo box */ | 906 | handles the sorting combo box */ |
905 | void LibraryDialog::comboSelect(int index) | 907 | void LibraryDialog::comboSelect(int index) |
906 | { | 908 | { |
907 | // odebug << "we are sorting" << oendl; | 909 | // odebug << "we are sorting" << oendl; |
908 | ListView1->setSorting( index, TRUE); | 910 | ListView1->setSorting( index, TRUE); |
909 | ListView2->setSorting( index, TRUE); | 911 | ListView2->setSorting( index, TRUE); |
910 | ListView3->setSorting( index, TRUE); | 912 | ListView3->setSorting( index, TRUE); |
911 | ListView4->setSorting( index, TRUE); | 913 | ListView4->setSorting( index, TRUE); |
912 | ListView5->setSorting( index, TRUE); | 914 | ListView5->setSorting( index, TRUE); |
913 | 915 | ||
914 | ListView1->sort(); | 916 | ListView1->sort(); |
915 | ListView2->sort(); | 917 | ListView2->sort(); |
916 | ListView3->sort(); | 918 | ListView3->sort(); |
917 | ListView4->sort(); | 919 | ListView4->sort(); |
918 | ListView5->sort(); | 920 | ListView5->sort(); |
919 | 921 | ||
920 | // ListView1->triggerUpdate(); | 922 | // ListView1->triggerUpdate(); |
921 | // ListView2->triggerUpdate(); | 923 | // ListView2->triggerUpdate(); |
922 | // ListView3->triggerUpdate(); | 924 | // ListView3->triggerUpdate(); |
923 | // ListView4->triggerUpdate(); | 925 | // ListView4->triggerUpdate(); |
924 | // ListView5->triggerUpdate(); | 926 | // ListView5->triggerUpdate(); |
925 | } | 927 | } |
926 | 928 | ||
927 | void LibraryDialog::newList() | 929 | void LibraryDialog::newList() |
928 | { | 930 | { |
929 | if(indexLoaded) { | 931 | if(indexLoaded) { |
930 | onButtonDownload(); | 932 | onButtonDownload(); |
931 | } else { | 933 | } else { |
932 | Output *outDlg; | 934 | Output *outDlg; |
933 | buttonNewList->setDown(TRUE); | 935 | buttonNewList->setDown(TRUE); |
934 | QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser"); | 936 | QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser"); |
935 | if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true); | 937 | if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true); |
936 | if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) { | 938 | if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) { |
937 | odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl; | 939 | odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl; |
938 | QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; | 940 | QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
939 | QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; | 941 | QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; |
940 | 942 | ||
941 | int result = QMessageBox::warning( this,"Download" | 943 | int result = QMessageBox::warning( this,"Download" |
942 | ,"Ok to use /'wget/' to download\na new library list?\n" | 944 | ,"<p>Ok to use /'wget/' to download a new library list?</P>" |
943 | ,"Yes","No",0,0,1); | 945 | ,"Yes","No",0,0,1); |
944 | qApp->processEvents(); | 946 | qApp->processEvents(); |
945 | if(result == 0) { | 947 | if(result == 0) { |
946 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); | 948 | outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); |
947 | outDlg->showMaximized(); | 949 | outDlg->showMaximized(); |
948 | outDlg->show(); | 950 | outDlg->show(); |
949 | qApp->processEvents(); | 951 | qApp->processEvents(); |
950 | FILE *fp; | 952 | FILE *fp; |
951 | char line[130]; | 953 | char line[130]; |
952 | outDlg->OutputEdit->append( tr("Running wget") ); | 954 | outDlg->OutputEdit->append( tr("Running wget") ); |
953 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 955 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
954 | sleep(1); | 956 | sleep(1); |
955 | fp = popen( (const char *) cmd, "r"); | 957 | fp = popen( (const char *) cmd, "r"); |
956 | if ( !fp ) { | 958 | if ( !fp ) { |
957 | } else { | 959 | } else { |
958 | odebug << "Issuing the command\n"+cmd << oendl; | 960 | odebug << "Issuing the command\n"+cmd << oendl; |
959 | // system(cmd); | 961 | // system(cmd); |
960 | while ( fgets( line, sizeof line, fp)) { | 962 | while ( fgets( line, sizeof line, fp)) { |
961 | outDlg->OutputEdit->append(line); | 963 | outDlg->OutputEdit->append(line); |
962 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 964 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
963 | } | 965 | } |
964 | pclose(fp); | 966 | pclose(fp); |
965 | outDlg->OutputEdit->append("Finished downloading\n"); | 967 | outDlg->OutputEdit->append("Finished downloading\n"); |
966 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 968 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
967 | qApp->processEvents(); | 969 | qApp->processEvents(); |
968 | 970 | ||
969 | // if( QFile(gutenindex1).exists() ) { | 971 | // if( QFile(gutenindex1).exists() ) { |
970 | // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; | 972 | // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
971 | // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) | 973 | // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) |
972 | // odebug << "renaming error" << oendl; | 974 | // odebug << "renaming error" << oendl; |
973 | // } | 975 | // } |
974 | 976 | ||
975 | } | 977 | } |
976 | // outDlg->close(); | 978 | // outDlg->close(); |
977 | FindLibrary(); | 979 | FindLibrary(); |
978 | if(outDlg) delete outDlg; | 980 | if(outDlg) delete outDlg; |
979 | } | 981 | } |
980 | buttonNewList->setDown(FALSE); | 982 | buttonNewList->setDown(FALSE); |
981 | } else { | 983 | } else { |
982 | QMessageBox::message("Note","Could not change directories"); | 984 | QMessageBox::message("Note","Could not change directories"); |
983 | } | 985 | } |
984 | // if(outDlg) | 986 | // if(outDlg) |
985 | // delete outDlg; | 987 | // delete outDlg; |
986 | } | 988 | } |
987 | } | 989 | } |
988 | 990 | ||
989 | bool LibraryDialog::moreInfo() | 991 | bool LibraryDialog::moreInfo() |
990 | { | 992 | { |
991 | 993 | ||
992 | QListViewItem * item; | 994 | QListViewItem * item; |
993 | item = 0; | 995 | item = 0; |
994 | QString titleString; | 996 | QString titleString; |
995 | item = ListView1->currentItem(); | 997 | item = ListView1->currentItem(); |
996 | if( item != 0) { | 998 | if( item != 0) { |
997 | titleString = item->text(0); | 999 | titleString = item->text(0); |
998 | ListView1->clearSelection(); | 1000 | ListView1->clearSelection(); |
999 | item = 0; | 1001 | item = 0; |
1000 | } | 1002 | } |
1001 | if( item == 0) | 1003 | if( item == 0) |
1002 | item = ListView2->currentItem(); | 1004 | item = ListView2->currentItem(); |
1003 | if( item != 0) { | 1005 | if( item != 0) { |
1004 | titleString = item->text(0); | 1006 | titleString = item->text(0); |
1005 | ListView2->clearSelection(); | 1007 | ListView2->clearSelection(); |
1006 | item = 0; | 1008 | item = 0; |
1007 | } | 1009 | } |
1008 | if( item == 0) | 1010 | if( item == 0) |
1009 | item = ListView3->currentItem(); | 1011 | item = ListView3->currentItem(); |
1010 | if( item != 0) { | 1012 | if( item != 0) { |
1011 | titleString = item->text(0); | 1013 | titleString = item->text(0); |
1012 | ListView3->clearSelection(); | 1014 | ListView3->clearSelection(); |
1013 | item = 0; | 1015 | item = 0; |
1014 | } | 1016 | } |
1015 | if( item == 0) | 1017 | if( item == 0) |
1016 | item = ListView4->currentItem(); | 1018 | item = ListView4->currentItem(); |
1017 | if( item != 0) { | 1019 | if( item != 0) { |
1018 | titleString = item->text(0); | 1020 | titleString = item->text(0); |
1019 | ListView4->clearSelection(); | 1021 | ListView4->clearSelection(); |
1020 | item = 0; | 1022 | item = 0; |
1021 | } | 1023 | } |
1022 | if( item == 0) | 1024 | if( item == 0) |
1023 | item = ListView5->currentItem(); | 1025 | item = ListView5->currentItem(); |
1024 | if( item != 0) { | 1026 | if( item != 0) { |
1025 | titleString = item->text(0); | 1027 | titleString = item->text(0); |
1026 | ListView5->clearSelection(); | 1028 | ListView5->clearSelection(); |
1027 | item = 0; | 1029 | item = 0; |
1028 | } | 1030 | } |
1029 | item=0; | 1031 | item=0; |
1030 | if(titleString.length()>2) { | 1032 | if(titleString.length()>2) { |
1031 | odebug << "Title is "+titleString << oendl; | 1033 | odebug << "Title is "+titleString << oendl; |
1032 | titleString.replace( QRegExp("\\s"), "%20"); | 1034 | titleString.replace( QRegExp("\\s"), "%20"); |
1033 | titleString.replace( QRegExp("'"), "%20"); | 1035 | titleString.replace( QRegExp("'"), "%20"); |
1034 | titleString.replace( QRegExp("\""), "%20"); | 1036 | titleString.replace( QRegExp("\""), "%20"); |
1035 | titleString.replace( QRegExp("&"), "%20"); | 1037 | titleString.replace( QRegExp("&"), "%20"); |
1036 | QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search"; | 1038 | QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search"; |
1037 | cmd="opera "+cmd; | 1039 | cmd="opera "+cmd; |
1038 | system(cmd); | 1040 | system(cmd); |
1039 | } else | 1041 | } else |
1040 | QMessageBox::message( "Note","If you select a title, this will\nsearch google.com for that title."); | 1042 | QMessageBox::message( "Note","<p>If you select a title, this will search google.com for that title.</p>"); |
1041 | return true; | 1043 | return true; |
1042 | 1044 | ||
1043 | } | 1045 | } |
1044 | 1046 | ||
1045 | /* | 1047 | /* |
1046 | This loads the library Index*/ | 1048 | This loads the library Index*/ |
1047 | void LibraryDialog::FindLibrary() | 1049 | void LibraryDialog::FindLibrary() |
1048 | { | 1050 | { |
1049 | buttonLibrary->setDown(TRUE); | 1051 | buttonLibrary->setDown(TRUE); |
1050 | 1052 | ||
1051 | qApp->processEvents(); | 1053 | qApp->processEvents(); |
1052 | if( QFile( new_index).exists() /* && this->isHidden() */) { | 1054 | if( QFile( new_index).exists() /* && this->isHidden() */) { |
1053 | newindexLib.setName( new_index); | 1055 | newindexLib.setName( new_index); |
1054 | indexLib.setName( new_index); | 1056 | indexLib.setName( new_index); |
1055 | odebug << "index file is "+ new_index << oendl; | 1057 | odebug << "index file is "+ new_index << oendl; |
1056 | Newlibrary(); | 1058 | Newlibrary(); |
1057 | } else { | 1059 | } else { |
1058 | newindexLib.setName( old_index); | 1060 | newindexLib.setName( old_index); |
1059 | indexLib.setName( old_index); | 1061 | indexLib.setName( old_index); |
1060 | odebug << "new index nameis "+ old_index << oendl; | 1062 | odebug << "new index nameis "+ old_index << oendl; |
1061 | Library(); | 1063 | Library(); |
1062 | } | 1064 | } |
1063 | indexLoaded=true; | 1065 | indexLoaded=true; |
1064 | buttonSearch->setEnabled(TRUE); | 1066 | buttonSearch->setEnabled(TRUE); |
1065 | moreInfoButton->setEnabled(TRUE); | 1067 | moreInfoButton->setEnabled(TRUE); |
1066 | 1068 | ||
1067 | buttonLibrary->setDown(FALSE); | 1069 | buttonLibrary->setDown(FALSE); |
1068 | buttonNewList->setText("Download"); | 1070 | buttonNewList->setText("Download"); |
1069 | qApp->processEvents(); | 1071 | qApp->processEvents(); |
1070 | 1072 | ||
1071 | } | 1073 | } |
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialogData.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialogData.cpp index 72d605e..60c1c75 100644 --- a/noncore/apps/opie-gutenbrowser/LibraryDialogData.cpp +++ b/noncore/apps/opie-gutenbrowser/LibraryDialogData.cpp | |||
@@ -1,281 +1,282 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | LibraryDialogData.cpp - description | 2 | LibraryDialogData.cpp - description |
3 | begin : Sat Dec 4 1999 | 3 | begin : Sat Dec 4 1999 |
4 | begin : Tue Jul 25 2000 | 4 | begin : Tue Jul 25 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 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | ***************************************************************************/ | 14 | ***************************************************************************/ |
15 | #include "LibraryDialog.h" | 15 | #include "LibraryDialog.h" |
16 | #include <qpe/config.h> | 16 | #include <qpe/config.h> |
17 | 17 | ||
18 | #include <qpushbutton.h> | 18 | #include <qpushbutton.h> |
19 | #include <qtabwidget.h> | 19 | #include <qtabwidget.h> |
20 | #include <qwidget.h> | 20 | #include <qwidget.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | 22 | ||
23 | #include <qimage.h> | 23 | #include <qimage.h> |
24 | #include <qpixmap.h> | 24 | #include <qpixmap.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qtooltip.h> | 27 | #include <qtooltip.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qcheckbox.h> | 29 | #include <qcheckbox.h> |
30 | #include <qdatetime.h> | 30 | #include <qdatetime.h> |
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qheader.h> | 32 | #include <qheader.h> |
33 | #include <qlistview.h> | 33 | #include <qlistview.h> |
34 | #include <qmessagebox.h> | 34 | #include <qmessagebox.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | #include <qstring.h> | 36 | #include <qstring.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qlabel.h> | 40 | #include <qlabel.h> |
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | 42 | ||
43 | 43 | ||
44 | void LibraryDialog::initDialog(){ | 44 | void LibraryDialog::initDialog(){ |
45 | 45 | ||
46 | 46 | ||
47 | QGridLayout *layout = new QGridLayout( this ); | 47 | QGridLayout *layout = new QGridLayout( this ); |
48 | layout->setSpacing(2); | 48 | layout->setSpacing(2); |
49 | layout->setMargin(4); | 49 | layout->setMargin(4); |
50 | 50 | ||
51 | tabWidget = new QTabWidget( this, "tabWidget" ); | 51 | tabWidget = new QTabWidget( this, "tabWidget" ); |
52 | layout->addMultiCellWidget( tabWidget, 0, 0, 0, 3); | 52 | layout->addMultiCellWidget( tabWidget, 0, 0, 0, 3); |
53 | 53 | ||
54 | widget_1 = new QWidget( tabWidget, "widget" ); | 54 | widget_1 = new QWidget( tabWidget, "widget" ); |
55 | ListView1 = new QListView( widget_1, "ListView1" ); | 55 | ListView1 = new QListView( widget_1, "ListView1" ); |
56 | QGridLayout *layout1 = new QGridLayout(widget_1 ); | 56 | QGridLayout *layout1 = new QGridLayout(widget_1 ); |
57 | 57 | ||
58 | widget_2 = new QWidget( tabWidget, "widget_2" ); | 58 | widget_2 = new QWidget( tabWidget, "widget_2" ); |
59 | ListView2 = new QListView( widget_2, "ListView2" ); | 59 | ListView2 = new QListView( widget_2, "ListView2" ); |
60 | QGridLayout *layout2 = new QGridLayout(widget_2 ); | 60 | QGridLayout *layout2 = new QGridLayout(widget_2 ); |
61 | 61 | ||
62 | widget_3 = new QWidget( tabWidget, "widget_3" ); | 62 | widget_3 = new QWidget( tabWidget, "widget_3" ); |
63 | ListView3 = new QListView( widget_3, "ListView3" ); | 63 | ListView3 = new QListView( widget_3, "ListView3" ); |
64 | QGridLayout *layout3 = new QGridLayout(widget_3 ); | 64 | QGridLayout *layout3 = new QGridLayout(widget_3 ); |
65 | 65 | ||
66 | widget_4 = new QWidget( tabWidget, "widget_4" ); | 66 | widget_4 = new QWidget( tabWidget, "widget_4" ); |
67 | ListView4 = new QListView( widget_4, "ListView4" ); | 67 | ListView4 = new QListView( widget_4, "ListView4" ); |
68 | QGridLayout *layout4 = new QGridLayout(widget_4 ); | 68 | QGridLayout *layout4 = new QGridLayout(widget_4 ); |
69 | 69 | ||
70 | widget_5 = new QWidget( tabWidget, "widget_5" ); | 70 | widget_5 = new QWidget( tabWidget, "widget_5" ); |
71 | ListView5 = new QListView( widget_5, "ListView5" ); | 71 | ListView5 = new QListView( widget_5, "ListView5" ); |
72 | QGridLayout *layout5 = new QGridLayout(widget_5 ); | 72 | QGridLayout *layout5 = new QGridLayout(widget_5 ); |
73 | 73 | ||
74 | 74 | ||
75 | ListView1->addColumn( tr( "Title" ) ); | 75 | ListView1->addColumn( tr( "Title" ) ); |
76 | ListView1->setColumnWidthMode( 0, QListView::Manual ); | 76 | ListView1->setColumnWidthMode( 0, QListView::Manual ); |
77 | ListView1->setColumnWidth(0, 330); | 77 | ListView1->setColumnWidth(0, 330); |
78 | ListView1->setColumnAlignment( 0, 1 ); | 78 | ListView1->setColumnAlignment( 0, 1 ); |
79 | 79 | ||
80 | ListView1->addColumn( tr( "Author" ) ); | 80 | ListView1->addColumn( tr( "Author" ) ); |
81 | ListView1->setColumnWidthMode( 1, QListView::Manual ); | 81 | ListView1->setColumnWidthMode( 1, QListView::Manual ); |
82 | ListView1->setColumnWidth(1, 170); | 82 | ListView1->setColumnWidth(1, 170); |
83 | ListView1->setColumnAlignment( 1, 1 ); | 83 | ListView1->setColumnAlignment( 1, 1 ); |
84 | 84 | ||
85 | ListView1->addColumn( tr( "Year" ) ); | 85 | ListView1->addColumn( tr( "Year" ) ); |
86 | ListView1->setColumnWidthMode( 2, QListView::Manual ); | 86 | ListView1->setColumnWidthMode( 2, QListView::Manual ); |
87 | ListView1->setColumnWidth(2, 50); | 87 | ListView1->setColumnWidth(2, 50); |
88 | ListView1->setColumnAlignment( 2, 1 ); | 88 | ListView1->setColumnAlignment( 2, 1 ); |
89 | 89 | ||
90 | ListView1->addColumn( tr( "File" ) ); | 90 | ListView1->addColumn( tr( "File" ) ); |
91 | ListView1->setColumnWidthMode( 2, QListView::Manual ); | 91 | ListView1->setColumnWidthMode( 2, QListView::Manual ); |
92 | ListView1->setColumnWidth(2, 100); | 92 | ListView1->setColumnWidth(2, 100); |
93 | ListView1->setColumnAlignment( 2, 1 ); | 93 | ListView1->setColumnAlignment( 2, 1 ); |
94 | 94 | ||
95 | ListView2->addColumn( tr( "Title" ) ); | 95 | ListView2->addColumn( tr( "Title" ) ); |
96 | ListView2->setColumnWidthMode( 0, QListView::Manual ); | 96 | ListView2->setColumnWidthMode( 0, QListView::Manual ); |
97 | ListView2->setColumnWidth(0, 330); | 97 | ListView2->setColumnWidth(0, 330); |
98 | ListView2->setColumnAlignment( 0, 1 ); | 98 | ListView2->setColumnAlignment( 0, 1 ); |
99 | 99 | ||
100 | ListView2->addColumn( tr( "Author" ) ); | 100 | ListView2->addColumn( tr( "Author" ) ); |
101 | ListView2->setColumnWidthMode( 1, QListView::Manual ); | 101 | ListView2->setColumnWidthMode( 1, QListView::Manual ); |
102 | ListView2->setColumnWidth(1, 170); | 102 | ListView2->setColumnWidth(1, 170); |
103 | ListView2->setColumnAlignment( 1, 1 ); | 103 | ListView2->setColumnAlignment( 1, 1 ); |
104 | 104 | ||
105 | ListView2->addColumn( tr( "Year" ) ); | 105 | ListView2->addColumn( tr( "Year" ) ); |
106 | ListView2->setColumnWidthMode( 2, QListView::Manual ); | 106 | ListView2->setColumnWidthMode( 2, QListView::Manual ); |
107 | ListView2->setColumnWidth(2, 50); | 107 | ListView2->setColumnWidth(2, 50); |
108 | ListView2->setColumnAlignment( 2, 1 ); | 108 | ListView2->setColumnAlignment( 2, 1 ); |
109 | 109 | ||
110 | ListView2->addColumn( tr( "File" ) ); | 110 | ListView2->addColumn( tr( "File" ) ); |
111 | ListView2->setColumnWidthMode( 3, QListView::Manual ); | 111 | ListView2->setColumnWidthMode( 3, QListView::Manual ); |
112 | ListView2->setColumnWidth(3, 100); | 112 | ListView2->setColumnWidth(3, 100); |
113 | ListView2->setColumnAlignment( 3, 1 ); | 113 | ListView2->setColumnAlignment( 3, 1 ); |
114 | 114 | ||
115 | ListView3->addColumn( tr( "Title" ) ); | 115 | ListView3->addColumn( tr( "Title" ) ); |
116 | ListView3->setColumnWidthMode( 0, QListView::Manual ); | 116 | ListView3->setColumnWidthMode( 0, QListView::Manual ); |
117 | ListView3->setColumnWidth(0, 330); | 117 | ListView3->setColumnWidth(0, 330); |
118 | ListView3->setColumnAlignment( 0, 1 ); | 118 | ListView3->setColumnAlignment( 0, 1 ); |
119 | 119 | ||
120 | ListView3->addColumn( tr( "Author" ) ); | 120 | ListView3->addColumn( tr( "Author" ) ); |
121 | ListView3->setColumnWidthMode( 1, QListView::Manual ); | 121 | ListView3->setColumnWidthMode( 1, QListView::Manual ); |
122 | ListView3->setColumnWidth(1, 170); | 122 | ListView3->setColumnWidth(1, 170); |
123 | ListView3->setColumnAlignment( 1, 1 ); | 123 | ListView3->setColumnAlignment( 1, 1 ); |
124 | 124 | ||
125 | ListView3->addColumn( tr( "Year" ) ); | 125 | ListView3->addColumn( tr( "Year" ) ); |
126 | ListView3->setColumnWidthMode( 2, QListView::Manual ); | 126 | ListView3->setColumnWidthMode( 2, QListView::Manual ); |
127 | ListView3->setColumnWidth(2, 50); | 127 | ListView3->setColumnWidth(2, 50); |
128 | ListView3->setColumnAlignment( 2, 1 ); | 128 | ListView3->setColumnAlignment( 2, 1 ); |
129 | 129 | ||
130 | ListView3->addColumn( tr( "File" ) ); | 130 | ListView3->addColumn( tr( "File" ) ); |
131 | ListView3->setColumnWidthMode( 3, QListView::Manual ); | 131 | ListView3->setColumnWidthMode( 3, QListView::Manual ); |
132 | ListView3->setColumnWidth(3, 100); | 132 | ListView3->setColumnWidth(3, 100); |
133 | ListView3->setColumnAlignment( 3, 1 ); | 133 | ListView3->setColumnAlignment( 3, 1 ); |
134 | 134 | ||
135 | 135 | ||
136 | ListView4->addColumn( tr( "Title" ) ); | 136 | ListView4->addColumn( tr( "Title" ) ); |
137 | ListView4->setColumnWidthMode( 0, QListView::Manual ); | 137 | ListView4->setColumnWidthMode( 0, QListView::Manual ); |
138 | ListView4->setColumnWidth(0, 330); | 138 | ListView4->setColumnWidth(0, 330); |
139 | ListView4->setColumnAlignment( 0, 1 ); | 139 | ListView4->setColumnAlignment( 0, 1 ); |
140 | 140 | ||
141 | ListView4->addColumn( tr( "Author" ) ); | 141 | ListView4->addColumn( tr( "Author" ) ); |
142 | ListView4->setColumnWidthMode( 1, QListView::Manual ); | 142 | ListView4->setColumnWidthMode( 1, QListView::Manual ); |
143 | ListView4->setColumnWidth(1, 170); | 143 | ListView4->setColumnWidth(1, 170); |
144 | ListView4->setColumnAlignment( 1, 1 ); | 144 | ListView4->setColumnAlignment( 1, 1 ); |
145 | 145 | ||
146 | ListView4->addColumn( tr( "Year" ) ); | 146 | ListView4->addColumn( tr( "Year" ) ); |
147 | ListView4->setColumnWidthMode( 2, QListView::Manual ); | 147 | ListView4->setColumnWidthMode( 2, QListView::Manual ); |
148 | ListView4->setColumnWidth(2, 50); | 148 | ListView4->setColumnWidth(2, 50); |
149 | ListView4->setColumnAlignment( 2, 1 ); | 149 | ListView4->setColumnAlignment( 2, 1 ); |
150 | 150 | ||
151 | ListView4->addColumn( tr( "File" ) ); | 151 | ListView4->addColumn( tr( "File" ) ); |
152 | ListView4->setColumnWidthMode( 3, QListView::Manual ); | 152 | ListView4->setColumnWidthMode( 3, QListView::Manual ); |
153 | ListView4->setColumnWidth(3, 100); | 153 | ListView4->setColumnWidth(3, 100); |
154 | ListView4->setColumnAlignment( 3, 1 ); | 154 | ListView4->setColumnAlignment( 3, 1 ); |
155 | 155 | ||
156 | ListView5->addColumn( tr( "Title" ) ); | 156 | ListView5->addColumn( tr( "Title" ) ); |
157 | ListView5->setColumnWidthMode( 0, QListView::Manual ); | 157 | ListView5->setColumnWidthMode( 0, QListView::Manual ); |
158 | ListView5->setColumnWidth(0, 330); | 158 | ListView5->setColumnWidth(0, 330); |
159 | ListView5->setColumnAlignment( 0, 1 ); | 159 | ListView5->setColumnAlignment( 0, 1 ); |
160 | 160 | ||
161 | ListView5->addColumn( tr( "Author" ) ); | 161 | ListView5->addColumn( tr( "Author" ) ); |
162 | ListView5->setColumnWidthMode( 1, QListView::Manual ); | 162 | ListView5->setColumnWidthMode( 1, QListView::Manual ); |
163 | ListView5->setColumnWidth(1, 170); | 163 | ListView5->setColumnWidth(1, 170); |
164 | ListView5->setColumnAlignment( 1, 1 ); | 164 | ListView5->setColumnAlignment( 1, 1 ); |
165 | 165 | ||
166 | ListView5->addColumn( tr( "Year" ) ); | 166 | ListView5->addColumn( tr( "Year" ) ); |
167 | ListView5->setColumnWidthMode( 2, QListView::Manual ); | 167 | ListView5->setColumnWidthMode( 2, QListView::Manual ); |
168 | ListView5->setColumnWidth(2, 50); | 168 | ListView5->setColumnWidth(2, 50); |
169 | ListView5->setColumnAlignment( 2, 1 ); | 169 | ListView5->setColumnAlignment( 2, 1 ); |
170 | 170 | ||
171 | ListView5->addColumn( tr( "File" ) ); | 171 | ListView5->addColumn( tr( "File" ) ); |
172 | ListView5->setColumnWidthMode( 3, QListView::Manual ); | 172 | ListView5->setColumnWidthMode( 3, QListView::Manual ); |
173 | ListView5->setColumnWidth(3, 100); | 173 | ListView5->setColumnWidth(3, 100); |
174 | ListView5->setColumnAlignment( 3, 1 ); | 174 | ListView5->setColumnAlignment( 3, 1 ); |
175 | 175 | ||
176 | tabWidget->insertTab( widget_1, tr( "A-F" ) ); | 176 | tabWidget->insertTab( widget_1, tr( "A-F" ) ); |
177 | tabWidget->insertTab( widget_2, tr( "G-M" ) ); | 177 | tabWidget->insertTab( widget_2, tr( "G-M" ) ); |
178 | tabWidget->insertTab( widget_3, tr( "N-R" ) ); | 178 | tabWidget->insertTab( widget_3, tr( "N-R" ) ); |
179 | tabWidget->insertTab( widget_4, tr( "S-Z" ) ); | 179 | tabWidget->insertTab( widget_4, tr( "S-Z" ) ); |
180 | tabWidget->insertTab( widget_5, tr( " " ) ); | 180 | tabWidget->insertTab( widget_5, tr( " " ) ); |
181 | 181 | ||
182 | ListView1->setMultiSelection(TRUE); | 182 | ListView1->setMultiSelection(TRUE); |
183 | ListView2->setMultiSelection(TRUE); | 183 | ListView2->setMultiSelection(TRUE); |
184 | ListView3->setMultiSelection(TRUE); | 184 | ListView3->setMultiSelection(TRUE); |
185 | ListView4->setMultiSelection(TRUE); | 185 | ListView4->setMultiSelection(TRUE); |
186 | ListView5->setMultiSelection(TRUE); | 186 | ListView5->setMultiSelection(TRUE); |
187 | 187 | ||
188 | widget_6 = new QWidget( tabWidget, "widget_6" ); | 188 | widget_6 = new QWidget( tabWidget, "widget_6" ); |
189 | tabWidget->insertTab(widget_6,tr("Options")); | 189 | tabWidget->insertTab(widget_6,tr("Options")); |
190 | 190 | ||
191 | ListView1->setSorting( 2, TRUE); | 191 | ListView1->setSorting( 2, TRUE); |
192 | ListView2->setSorting( 2, TRUE); | 192 | ListView2->setSorting( 2, TRUE); |
193 | ListView3->setSorting( 2, TRUE); | 193 | ListView3->setSorting( 2, TRUE); |
194 | ListView4->setSorting( 2, TRUE); | 194 | ListView4->setSorting( 2, TRUE); |
195 | ListView5->setSorting( 2, TRUE); | 195 | ListView5->setSorting( 2, TRUE); |
196 | ListView1->setAllColumnsShowFocus( TRUE ); | 196 | ListView1->setAllColumnsShowFocus( TRUE ); |
197 | ListView2->setAllColumnsShowFocus( TRUE ); | 197 | ListView2->setAllColumnsShowFocus( TRUE ); |
198 | ListView3->setAllColumnsShowFocus( TRUE ); | 198 | ListView3->setAllColumnsShowFocus( TRUE ); |
199 | ListView4->setAllColumnsShowFocus( TRUE ); | 199 | ListView4->setAllColumnsShowFocus( TRUE ); |
200 | ListView5->setAllColumnsShowFocus( TRUE ); | 200 | ListView5->setAllColumnsShowFocus( TRUE ); |
201 | 201 | ||
202 | QGridLayout *layout6 = new QGridLayout(widget_6 ); | 202 | QGridLayout *layout6 = new QGridLayout(widget_6 ); |
203 | QComboBox * sortingCombo; | 203 | QComboBox * sortingCombo; |
204 | buttonCancel = new QPushButton( widget_6, "buttonCancel" ); | 204 | buttonCancel = new QPushButton( widget_6, "buttonCancel" ); |
205 | checkBox = new QCheckBox( ( tr("Open Automatically")), widget_6); | 205 | checkBox = new QCheckBox( ( tr("Open Automatically")), widget_6); |
206 | checkBox->setChecked( FALSE); | 206 | checkBox->setChecked( FALSE); |
207 | // httpBox = new QCheckBox( ( tr("Use http")),widget_6); | 207 | // httpBox = new QCheckBox( ( tr("Use http")),widget_6); |
208 | // httpBox->setChecked( FALSE); | 208 | // httpBox->setChecked( FALSE); |
209 | // QToolTip::add( httpBox, ( tr("Use http to download \nproxy users should probably use this.")) ); | 209 | // QToolTip::add( httpBox, ( tr("Use http to download \nproxy users should probably use this.")) ); |
210 | authBox= new QCheckBox( ( tr("Last name first \n(requires library restart)")),widget_6); | 210 | authBox= new QCheckBox( ( tr("Last name first \n(requires library restart)")),widget_6); |
211 | authBox->setChecked( FALSE); | 211 | authBox->setChecked( FALSE); |
212 | 212 | ||
213 | layout1->addMultiCellWidget( ListView1, 0, 0, 0, 4); | 213 | layout1->addMultiCellWidget( ListView1, 0, 0, 0, 4); |
214 | layout2->addMultiCellWidget( ListView2, 0, 0, 0, 4); | 214 | layout2->addMultiCellWidget( ListView2, 0, 0, 0, 4); |
215 | layout3->addMultiCellWidget( ListView3, 0, 0, 0, 4); | 215 | layout3->addMultiCellWidget( ListView3, 0, 0, 0, 4); |
216 | layout4->addMultiCellWidget( ListView4, 0, 0, 0, 4); | 216 | layout4->addMultiCellWidget( ListView4, 0, 0, 0, 4); |
217 | layout5->addMultiCellWidget( ListView5, 0, 0, 0, 4); | 217 | layout5->addMultiCellWidget( ListView5, 0, 0, 0, 4); |
218 | 218 | ||
219 | buttonSearch = new QPushButton(this,"buttonSearch"); | 219 | buttonSearch = new QPushButton(this,"buttonSearch"); |
220 | buttonLibrary=new QPushButton(this,"buttenLibrary"); | 220 | buttonLibrary=new QPushButton(this,"buttenLibrary"); |
221 | buttonNewList=new QPushButton(this,"NewList"); | 221 | buttonNewList=new QPushButton(this,"NewList"); |
222 | moreInfoButton= new QPushButton(this,"moreInfo"); | 222 | moreInfoButton= new QPushButton(this,"moreInfo"); |
223 | sortingCombo=new QComboBox(widget_6,"sort by combo"); | 223 | sortingCombo=new QComboBox(widget_6,"sort by combo"); |
224 | 224 | ||
225 | 225 | ||
226 | layout6->addMultiCellWidget(buttonCancel, 0, 0, 4, 4); | 226 | layout6->addMultiCellWidget(buttonCancel, 0, 0, 4, 4); |
227 | layout6->addMultiCellWidget(checkBox, 1, 1, 0, 0); | 227 | layout6->addMultiCellWidget(checkBox, 1, 1, 0, 0); |
228 | layout6->addMultiCellWidget(sortingCombo, 2, 2, 0, 0); | 228 | layout6->addMultiCellWidget(sortingCombo, 2, 2, 0, 0); |
229 | layout6->addMultiCellWidget(authBox, 3, 3, 0, 0); | 229 | layout6->addMultiCellWidget(authBox, 3, 3, 0, 0); |
230 | 230 | ||
231 | layout->addMultiCellWidget( buttonSearch, 1, 1, 0, 0); | 231 | layout->addMultiCellWidget( buttonSearch, 1, 1, 0, 0); |
232 | layout->addMultiCellWidget( buttonLibrary, 1, 1, 1, 1); | 232 | layout->addMultiCellWidget( buttonLibrary, 1, 1, 1, 1); |
233 | layout->addMultiCellWidget( moreInfoButton, 1, 1, 2, 2); | 233 | layout->addMultiCellWidget( moreInfoButton, 1, 1, 2, 2); |
234 | layout->addMultiCellWidget( buttonNewList, 1, 1, 3, 3); | 234 | layout->addMultiCellWidget( buttonNewList, 1, 1, 3, 3); |
235 | 235 | ||
236 | moreInfoButton->setText("Info"); | 236 | moreInfoButton->setText("Info"); |
237 | moreInfoButton->setDisabled(TRUE); | 237 | moreInfoButton->setDisabled(TRUE); |
238 | buttonSearch->setDisabled(TRUE); | 238 | buttonSearch->setDisabled(TRUE); |
239 | buttonSearch->setDefault(TRUE); | ||
239 | 240 | ||
240 | buttonSearch->setText(tr("Search")); | 241 | buttonSearch->setText(tr("Search")); |
241 | 242 | ||
242 | buttonCancel->setText(tr("Close")); | 243 | buttonCancel->setText(tr("Close")); |
243 | buttonLibrary->setText("Load"); | 244 | buttonLibrary->setText("Load"); |
244 | buttonLibrary->setDefault(TRUE); | 245 | // buttonLibrary->setDefault(TRUE); |
245 | buttonNewList->setText("New List"); | 246 | buttonNewList->setText("New List"); |
246 | 247 | ||
247 | QStrList sortingList; | 248 | QStrList sortingList; |
248 | sortingList.append( "Sort by Number"); | 249 | sortingList.append( "Sort by Number"); |
249 | sortingList.append("Sort by Title"); | 250 | sortingList.append("Sort by Title"); |
250 | sortingList.append( "Sort by Author"); | 251 | sortingList.append( "Sort by Author"); |
251 | sortingList.append("Sort by Year"); | 252 | sortingList.append("Sort by Year"); |
252 | 253 | ||
253 | sortingCombo->insertStrList(sortingList,0); | 254 | sortingCombo->insertStrList(sortingList,0); |
254 | sortingCombo->setCurrentItem(2); | 255 | sortingCombo->setCurrentItem(2); |
255 | sortingCombo->setMaximumWidth(180); | 256 | sortingCombo->setMaximumWidth(180); |
256 | 257 | ||
257 | // signals and slots connections | 258 | // signals and slots connections |
258 | connect(buttonSearch,SIGNAL(clicked()),this,SLOT(onButtonSearch())); | 259 | connect(buttonSearch,SIGNAL(clicked()),this,SLOT(onButtonSearch())); |
259 | connect(buttonLibrary,SIGNAL(clicked()),this,SLOT(FindLibrary())); | 260 | connect(buttonLibrary,SIGNAL(clicked()),this,SLOT(FindLibrary())); |
260 | connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject())); | 261 | connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject())); |
261 | connect(moreInfoButton,SIGNAL(clicked()),this,SLOT(moreInfo())); | 262 | connect(moreInfoButton,SIGNAL(clicked()),this,SLOT(moreInfo())); |
262 | connect(buttonNewList,SIGNAL(clicked()),this,SLOT(newList())); | 263 | connect(buttonNewList,SIGNAL(clicked()),this,SLOT(newList())); |
263 | 264 | ||
264 | connect(ListView1,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*))); | 265 | connect(ListView1,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*))); |
265 | connect(ListView1,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*))); | 266 | connect(ListView1,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*))); |
266 | connect(ListView2,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*))); | 267 | connect(ListView2,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*))); |
267 | connect(ListView2,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*))); | 268 | connect(ListView2,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*))); |
268 | connect(ListView3,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*))); | 269 | connect(ListView3,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*))); |
269 | connect(ListView3,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*))); | 270 | connect(ListView3,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*))); |
270 | connect(ListView4,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*))); | 271 | connect(ListView4,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*))); |
271 | connect(ListView4,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*))); | 272 | connect(ListView4,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*))); |
272 | connect(ListView5,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*))); | 273 | connect(ListView5,SIGNAL(doubleClicked(QListViewItem*)),SLOT(select_title(QListViewItem*))); |
273 | connect(ListView5,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*))); | 274 | connect(ListView5,SIGNAL(returnPressed(QListViewItem*)),SLOT(select_title(QListViewItem*))); |
274 | 275 | ||
275 | connect(sortingCombo,SIGNAL(activated(int)),SLOT(comboSelect(int))); | 276 | connect(sortingCombo,SIGNAL(activated(int)),SLOT(comboSelect(int))); |
276 | 277 | ||
277 | } | 278 | } |
278 | 279 | ||
279 | void LibraryDialog::doListView() { | 280 | void LibraryDialog::doListView() { |
280 | 281 | ||
281 | } | 282 | } |
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp index f14080f..be920dd 100644 --- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp +++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | |||
@@ -1,1992 +1,1988 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | gutenbrowser.cpp - description | 2 | gutenbrowser.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Jul 24 22:33:12 MDT 2000 | 4 | begin : Mon Jul 24 22:33:12 MDT 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 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | // http search | 12 | // http search |
13 | // http://digital.library.upenn.edu/books/authors.html | 13 | // http://digital.library.upenn.edu/books/authors.html |
14 | // http://digital.library.upenn.edu/books/titles.html | 14 | // http://digital.library.upenn.edu/books/titles.html |
15 | // ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL | 15 | // ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL |
16 | // donate@gutenberg.net | 16 | // donate@gutenberg.net |
17 | 17 | ||
18 | 18 | ||
19 | #include "editTitle.h" | 19 | #include "editTitle.h" |
20 | #include "gutenbrowser.h" | 20 | #include "gutenbrowser.h" |
21 | #include "LibraryDialog.h" | 21 | #include "LibraryDialog.h" |
22 | //#include "bookmarksdlg.h" | 22 | //#include "bookmarksdlg.h" |
23 | #include "optionsDialog.h" | 23 | #include "optionsDialog.h" |
24 | #include "helpme.h" | 24 | #include "helpme.h" |
25 | #include "NetworkDialog.h" | 25 | #include "NetworkDialog.h" |
26 | 26 | ||
27 | #include "openetext.h" | 27 | #include "openetext.h" |
28 | #include "output.h" | 28 | #include "output.h" |
29 | 29 | ||
30 | /* OPIE */ | 30 | /* OPIE */ |
31 | #include <opie2/odebug.h> | 31 | #include <opie2/odebug.h> |
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/fontdatabase.h> | 33 | #include <qpe/fontdatabase.h> |
34 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/qcopenvelope_qws.h> | 35 | #include <qpe/qcopenvelope_qws.h> |
36 | #include <qpe/mimetype.h> | 36 | #include <qpe/mimetype.h> |
37 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
38 | #include <qpe/applnk.h> | 38 | #include <qpe/applnk.h> |
39 | 39 | ||
40 | /* QT */ | 40 | /* QT */ |
41 | #include <qregexp.h> | 41 | #include <qregexp.h> |
42 | #include <qregion.h> | 42 | #include <qregion.h> |
43 | #include <qpaintdevicemetrics.h> | 43 | #include <qpaintdevicemetrics.h> |
44 | #include <qvaluelist.h> | 44 | #include <qvaluelist.h> |
45 | #include <qlabel.h> | 45 | #include <qlabel.h> |
46 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
47 | #include <qpainter.h> | 47 | #include <qpainter.h> |
48 | #include <qpalette.h> | 48 | #include <qpalette.h> |
49 | #include <qobjectlist.h> | 49 | #include <qobjectlist.h> |
50 | #include <qfontdialog.h> | 50 | #include <qfontdialog.h> |
51 | #include <qtextview.h> | 51 | #include <qtextview.h> |
52 | #include <qbrush.h> | 52 | #include <qbrush.h> |
53 | #include <qfile.h> | 53 | #include <qfile.h> |
54 | #include <qfontinfo.h> | 54 | #include <qfontinfo.h> |
55 | #include <qscrollview.h> | 55 | #include <qscrollview.h> |
56 | #include <qpoint.h> | 56 | #include <qpoint.h> |
57 | 57 | ||
58 | /* STD */ | 58 | /* STD */ |
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include <unistd.h> | 61 | #include <unistd.h> |
62 | #include <sys/stat.h> | 62 | #include <sys/stat.h> |
63 | #include <fcntl.h> | 63 | #include <fcntl.h> |
64 | #include <errno.h> | 64 | #include <errno.h> |
65 | 65 | ||
66 | static const int nfontsizes = 9; | 66 | static const int nfontsizes = 9; |
67 | static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; | 67 | static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; |
68 | 68 | ||
69 | #ifdef NOQUICKLAUNCH | 69 | #ifdef NOQUICKLAUNCH |
70 | Gutenbrowser::Gutenbrowser() | 70 | Gutenbrowser::Gutenbrowser() |
71 | Gutenbrowser(); | 71 | Gutenbrowser(); |
72 | #else | 72 | #else |
73 | Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) | 73 | Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) |
74 | #endif | 74 | #endif |
75 | : QMainWindow() | 75 | : QMainWindow() |
76 | { | 76 | { |
77 | // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 77 | // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
78 | // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); | 78 | // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); |
79 | // e << ""; | 79 | // e << ""; |
80 | // QPEApplication::grabKeyboard(); | 80 | // QPEApplication::grabKeyboard(); |
81 | showMainList=TRUE; | 81 | showMainList=TRUE; |
82 | working=false; | 82 | working=false; |
83 | this->setUpdatesEnabled(TRUE); | 83 | this->setUpdatesEnabled(TRUE); |
84 | // #ifndef Q_WS_QWS | 84 | // #ifndef Q_WS_QWS |
85 | QString msg; | 85 | QString msg; |
86 | msg="You have now entered unto gutenbrowser,\n"; | 86 | msg="You have now entered unto gutenbrowser,\n"; |
87 | msg+="make your self at home, sit back, relax and read something great.\n"; | 87 | msg+="make your self at home, sit back, relax and read something great.\n"; |
88 | 88 | ||
89 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; | 89 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; |
90 | setCaption("Gutenbrowser");// Embedded " VERSION); | 90 | setCaption("Gutenbrowser");// Embedded " VERSION); |
91 | this->setUpdatesEnabled(TRUE); | 91 | this->setUpdatesEnabled(TRUE); |
92 | 92 | ||
93 | // bool firstTime=FALSE; | 93 | // bool firstTime=FALSE; |
94 | topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); | 94 | topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); |
95 | 95 | ||
96 | menu = new QHBoxLayout(-1,"menu"); | 96 | menu = new QHBoxLayout(-1,"menu"); |
97 | buttons2 = new QHBoxLayout(-1,"buttons2"); | 97 | buttons2 = new QHBoxLayout(-1,"buttons2"); |
98 | edits = new QHBoxLayout(-1,"edits"); | 98 | edits = new QHBoxLayout(-1,"edits"); |
99 | 99 | ||
100 | useSplitter=TRUE; | 100 | useSplitter=TRUE; |
101 | 101 | ||
102 | initConfig(); | 102 | initConfig(); |
103 | initMenuBar(); | 103 | initMenuBar(); |
104 | initButtonBar(); | 104 | initButtonBar(); |
105 | initStatusBar(); | 105 | initStatusBar(); |
106 | initView(); | 106 | initView(); |
107 | initSlots(); | 107 | initSlots(); |
108 | 108 | qDebug("init finished"); | |
109 | QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); | 109 | QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); |
110 | 110 | ||
111 | connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), | 111 | connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), |
112 | this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); | 112 | this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); |
113 | if( useIcons) | 113 | if( useIcons) |
114 | toggleButtonIcons( TRUE); | 114 | toggleButtonIcons( TRUE); |
115 | else | 115 | else |
116 | toggleButtonIcons( FALSE); | 116 | toggleButtonIcons( FALSE); |
117 | 117 | ||
118 | enableButtons(false); | 118 | enableButtons(false); |
119 | 119 | ||
120 | Config config("Gutenbrowser"); // populate menubuttonlist | 120 | Config config("Gutenbrowser"); // populate menubuttonlist |
121 | config.setGroup("General"); | 121 | config.setGroup("General"); |
122 | 122 | ||
123 | config.setGroup( "Files" ); | 123 | config.setGroup( "Files" ); |
124 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 124 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
125 | int i_numofFiles = s_numofFiles.toInt(); | 125 | int i_numofFiles = s_numofFiles.toInt(); |
126 | 126 | ||
127 | QString tempFileName; | 127 | QString tempFileName; |
128 | 128 | ||
129 | for (int i = 0; i <= i_numofFiles; i++) { | 129 | for (int i = 0; i <= i_numofFiles; i++) { |
130 | // tempFileName.setNum(i); | 130 | // tempFileName.setNum(i); |
131 | config.setGroup( "Files" ); | 131 | config.setGroup( "Files" ); |
132 | QString ramble = config.readEntry( QString::number(i), "" ); | 132 | QString ramble = config.readEntry( QString::number(i), "" ); |
133 | 133 | ||
134 | config.setGroup( "Titles" ); | 134 | config.setGroup( "Titles" ); |
135 | QString tempTitle = config.readEntry( ramble, ""); | 135 | QString tempTitle = config.readEntry( ramble, ""); |
136 | config.setGroup( tempTitle); | 136 | config.setGroup( tempTitle); |
137 | int index=config.readNumEntry( "LineNumber", -1 ); | 137 | int index=config.readNumEntry( "LineNumber", -1 ); |
138 | if( index != -1) { | 138 | if( index != -1) { |
139 | // odebug << tempTitle << oendl; | 139 | odebug << tempTitle << oendl; |
140 | bookmarksMenu->insertItem( tempTitle); | 140 | bookmarksMenu->insertItem( tempTitle); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | // QString gutenIndex= local_library + "GUTINDEX.ALL"; | 144 | // QString gutenIndex= local_library + "GUTINDEX.ALL"; |
145 | QString gutenIndex= QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL"; | 145 | QString gutenIndex = QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL"; |
146 | 146 | qDebug("gutenindex "+gutenIndex ); | |
147 | if( QFile( gutenIndex).exists() ) { | 147 | if( QFile( gutenIndex).exists() ) { |
148 | indexLib.setName( gutenIndex); | 148 | indexLib.setName( gutenIndex); |
149 | } else { | 149 | } else { |
150 | QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT"; | 150 | QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT"; |
151 | // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; | 151 | // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; |
152 | newindexLib.setName( localLibIndexFile); | 152 | newindexLib.setName( localLibIndexFile); |
153 | } | 153 | } |
154 | qDebug("attempting new library"); | ||
154 | LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); | 155 | LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); |
155 | loadCheck=false; | 156 | loadCheck = false; |
156 | chdir(local_library); | 157 | chdir(local_library); |
157 | if(!showMainList) { | 158 | if(!showMainList) { |
158 | Lview->setFocus(); | 159 | Lview->setFocus(); |
159 | // if(firstTime) | 160 | // if(firstTime) |
160 | // Bookmark(); | 161 | // Bookmark(); |
161 | for (int i=1;i< qApp->argc();i++) { | 162 | for (int i=1;i< qApp->argc();i++) { |
162 | odebug << "Suppose we open somethin" << oendl; | 163 | qDebug("Suppose we open somethin"); |
163 | load(qApp->argv()[i]); | 164 | load(qApp->argv()[i]); |
164 | } | 165 | } |
165 | } else { | 166 | } else { |
166 | fillWithTitles(); | 167 | fillWithTitles(); |
167 | mainList->setFocus(); | 168 | mainList->setFocus(); |
168 | // mainList->setCurrentItem(0); | 169 | // mainList->setCurrentItem(0); |
169 | 170 | ||
170 | } | 171 | } |
171 | writeConfig(); | 172 | writeConfig(); |
172 | } //end init | 173 | } //end init |
173 | 174 | ||
174 | Gutenbrowser::~Gutenbrowser() { | 175 | Gutenbrowser::~Gutenbrowser() { |
175 | // QPEApplication::grabKeyboard(); | 176 | // QPEApplication::grabKeyboard(); |
176 | // QPEApplication::ungrabKeyboard(); | 177 | // QPEApplication::ungrabKeyboard(); |
177 | odebug << "Exit" << oendl; | 178 | odebug << "Exit" << oendl; |
178 | } | 179 | } |
179 | 180 | ||
180 | /* | 181 | /* |
181 | Google.com search */ | 182 | Google.com search */ |
182 | void Gutenbrowser::InfoBarClick() { | 183 | void Gutenbrowser::InfoBarClick() { |
183 | QString text; | 184 | QString text; |
184 | if( Lview->hasSelectedText()) { | 185 | if( Lview->hasSelectedText()) { |
185 | Lview->copy(); | 186 | Lview->copy(); |
186 | QClipboard *cb = QApplication::clipboard(); | 187 | QClipboard *cb = QApplication::clipboard(); |
187 | text = cb->text(); | 188 | text = cb->text(); |
188 | } else { | 189 | } else { |
189 | // text=title; | 190 | // text=title; |
190 | text=this->caption(); | 191 | text=this->caption(); |
191 | } | 192 | } |
192 | searchGoogle(text); | 193 | searchGoogle(text); |
193 | } | 194 | } |
194 | 195 | ||
195 | /* | 196 | /* |
196 | download http with wget or preferred browser */ | 197 | download http with wget or preferred browser */ |
197 | void Gutenbrowser::goGetit( const QString &url, bool showMsg) { | 198 | void Gutenbrowser::goGetit( const QString &url, bool showMsg) { |
198 | // int eexit=0; | 199 | // int eexit=0; |
199 | QString cmd; | 200 | QString cmd; |
200 | // config.read(); | 201 | // config.read(); |
201 | qApp->processEvents(); | 202 | qApp->processEvents(); |
202 | QString filename = QPEApplication::qpeDir(); | 203 | QString filename = QPEApplication::qpeDir(); |
203 | if(filename.right(1)!="/") | 204 | if(filename.right(1)!="/") |
204 | filename+="/etc/gutenbrowser/"; | 205 | filename+="/etc/gutenbrowser/"; |
205 | else | 206 | else |
206 | filename+="etc/gutenbrowser/"; | 207 | filename+="etc/gutenbrowser/"; |
207 | odebug << "filename "+filename << oendl; | 208 | odebug << "filename "+filename << oendl; |
208 | // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; | 209 | // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; |
209 | 210 | ||
210 | filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); | 211 | filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); |
211 | 212 | ||
212 | Config config("Gutenbrowser"); | 213 | Config config("Gutenbrowser"); |
213 | config.setGroup( "Browser" ); | 214 | config.setGroup( "Browser" ); |
214 | QString brow = config.readEntry("Preferred", "Opera"); | 215 | QString brow = config.readEntry("Preferred", "Opera"); |
215 | odebug << "Preferred browser is "+brow << oendl; | 216 | odebug << "Preferred browser is "+brow << oendl; |
216 | if(!showMsg) { //if we just get the gutenindex.all | 217 | if(!showMsg) { //if we just get the gutenindex.all |
217 | cmd="wget -O " + filename +" " + url+" 2>&1" ; | 218 | cmd="wget -O " + filename +" " + url+" 2>&1" ; |
218 | chdir(local_library); | 219 | chdir(local_library); |
219 | odebug << "Issuing the system command: " << cmd << "" << oendl; | 220 | odebug << "Issuing the system command: " << cmd << "" << oendl; |
220 | 221 | ||
221 | Output *outDlg; | 222 | Output *outDlg; |
222 | outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); | 223 | outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); |
223 | outDlg->showMaximized(); | 224 | outDlg->showMaximized(); |
224 | outDlg->show(); | 225 | outDlg->show(); |
225 | qApp->processEvents(); | 226 | qApp->processEvents(); |
226 | FILE *fp; | 227 | FILE *fp; |
227 | char line[130]; | 228 | char line[130]; |
228 | outDlg->OutputEdit->append( tr("Running wget") ); | 229 | outDlg->OutputEdit->append( tr("Running wget") ); |
229 | sleep(1); | 230 | sleep(1); |
230 | fp = popen( (const char *) cmd, "r"); | 231 | fp = popen( (const char *) cmd, "r"); |
231 | // odebug << "Issuing the command\n"+cmd << oendl; | 232 | odebug << "Issuing the command\n"+cmd << oendl; |
232 | // system(cmd); | 233 | // system(cmd); |
233 | while ( fgets( line, sizeof line, fp)) { | 234 | while ( fgets( line, sizeof line, fp)) { |
234 | outDlg->OutputEdit->append(line); | 235 | outDlg->OutputEdit->append(line); |
235 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 236 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
236 | } | 237 | } |
237 | pclose(fp); | 238 | pclose(fp); |
238 | outDlg->close(); | 239 | outDlg->close(); |
239 | if(outDlg) | 240 | if(outDlg) |
240 | delete outDlg; | 241 | delete outDlg; |
241 | } else { | 242 | } else { |
242 | if( brow == "Konq") { | 243 | if( brow == "Konq") { |
243 | cmd = "konqueror "+url+" &"; | 244 | cmd = "konqueror "+url+" &"; |
244 | } | 245 | } |
245 | if( brow == "Opera") { //for desktop testing | 246 | if( brow == "Opera") { //for desktop testing |
246 | cmd = "opera "+url+" &"; | 247 | cmd = "opera "+url+" &"; |
247 | } | 248 | } |
248 | // if( brow == "Opera") { // on Zaurus | 249 | // if( brow == "Opera") { // on Zaurus |
249 | // cmd = "operagui "+url+" &"; | 250 | // cmd = "operagui "+url+" &"; |
250 | // } | 251 | // } |
251 | if( brow == "Mozilla") { | 252 | if( brow == "Mozilla") { |
252 | cmd = "mozilla "+url+" &"; | 253 | cmd = "mozilla "+url+" &"; |
253 | } | 254 | } |
254 | if( brow == "Netscape") { | 255 | if( brow == "Netscape") { |
255 | cmd = "netscape "+url+" &"; | 256 | cmd = "netscape "+url+" &"; |
256 | } | 257 | } |
257 | if(brow == "wget") { | 258 | if(brow == "wget") { |
258 | // cmd="wget -q "+url+" &"; | 259 | // cmd="wget -q "+url+" &"; |
259 | QString tempHtml=local_library+"webster.html"; | 260 | QString tempHtml=local_library+"webster.html"; |
260 | cmd="wget -O "+tempHtml+" -q "+url; | 261 | cmd="wget -O "+tempHtml+" -q "+url; |
261 | } | 262 | } |
262 | 263 | ||
263 | chdir(local_library); | 264 | chdir(local_library); |
264 | odebug << "Issuing the sys command: " << cmd << "" << oendl; | 265 | odebug << "Issuing the sys command: " << cmd << "" << oendl; |
265 | system(cmd); | 266 | system(cmd); |
266 | } | 267 | } |
267 | } | 268 | } |
268 | 269 | ||
269 | void Gutenbrowser::toggleButtonIcons( bool useEm) { | 270 | void Gutenbrowser::toggleButtonIcons( bool useEm) { |
270 | QString pixDir; | 271 | QString pixDir; |
271 | if(useEm) | 272 | if(useEm) |
272 | useEm=TRUE; | 273 | useEm=TRUE; |
273 | pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; | 274 | pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; |
274 | odebug << "Docdir is "+QPEApplication::documentDir() << oendl; | 275 | odebug << "Docdir is "+QPEApplication::documentDir() << oendl; |
275 | 276 | ||
276 | if( useIcons && QDir( pixDir).exists() ) { | 277 | if( useIcons && QDir( pixDir).exists() ) { |
277 | LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline | 278 | LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline |
278 | OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook")); | 279 | OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook")); |
279 | ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline | 280 | ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline |
280 | BackButton->setPixmap( Resource::loadPixmap("back") );//in inline | 281 | BackButton->setPixmap( Resource::loadPixmap("back") );//in inline |
281 | SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline | 282 | SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline |
282 | lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder")); | 283 | lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder")); |
283 | setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") ); | 284 | setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") ); |
284 | dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") ); | 285 | dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") ); |
285 | InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google")); | 286 | InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google")); |
286 | } | 287 | } |
287 | } | 288 | } |
288 | 289 | ||
289 | 290 | ||
290 | bool Gutenbrowser::queryExit() | 291 | bool Gutenbrowser::queryExit() |
291 | { | 292 | { |
292 | int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?", | 293 | int exit=QMessageBox::information(this, "Quit...", "Do your really want to quit?", |
293 | QMessageBox::Ok, QMessageBox::Cancel); | 294 | QMessageBox::Ok, QMessageBox::Cancel); |
294 | if (exit==1) { | 295 | if (exit==1) { |
295 | writeConfig(); | 296 | writeConfig(); |
296 | qApp->quit(); | 297 | qApp->quit(); |
297 | } else { | 298 | } else { |
298 | }; | 299 | }; |
299 | return (exit==1); | 300 | return (exit==1); |
300 | } | 301 | } |
301 | 302 | ||
302 | // SLOT IMPLEMENTATION | 303 | // SLOT IMPLEMENTATION |
303 | 304 | ||
304 | void Gutenbrowser::slotFilePrint() { | 305 | void Gutenbrowser::slotFilePrint() { |
305 | } | 306 | } |
306 | 307 | ||
307 | void Gutenbrowser::ByeBye() { | 308 | void Gutenbrowser::ByeBye() { |
308 | if (b_queryExit) | 309 | if (b_queryExit) |
309 | queryExit(); | 310 | queryExit(); |
310 | else { | 311 | else { |
311 | // writeConfig(); | 312 | // writeConfig(); |
312 | qApp->quit(); | 313 | qApp->quit(); |
313 | } | 314 | } |
314 | } | 315 | } |
315 | 316 | ||
316 | void Gutenbrowser::HelpBtn() { | 317 | void Gutenbrowser::HelpBtn() { |
317 | HelpMe* HelpDlg; | 318 | HelpMe* HelpDlg; |
318 | HelpDlg = new HelpMe( this, "Help Dialog"); | 319 | HelpDlg = new HelpMe( this, "Help Dialog"); |
319 | HelpDlg->showMaximized(); | 320 | HelpDlg->showMaximized(); |
320 | } | 321 | } |
321 | 322 | ||
322 | void Gutenbrowser::DownloadIndex() { | 323 | void Gutenbrowser::DownloadIndex() { |
323 | #ifndef Q_WS_QWS | 324 | #ifndef Q_WS_QWS |
324 | { | 325 | { |
325 | switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")), | 326 | switch( QMessageBox::information( 0, (tr("Download Library Index, or FTP sites?")), |
326 | (tr("Do you want to download the newest\n" | 327 | (tr("Do you want to download the newest\n" |
327 | "Project Gutenberg Library Index?\n" | 328 | "Project Gutenberg Library Index?\n" |
328 | "or select an ftp site?\n")), | 329 | "or select an ftp site?\n")), |
329 | (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) ) | 330 | (tr("&Library Index")), (tr("&Ftp Site")), (tr("&Cancel")), 2, 2 ) ) |
330 | { | 331 | { |
331 | case 0: // index clicked, | 332 | case 0: // index clicked, |
332 | downloadLibIndex(); | 333 | downloadLibIndex(); |
333 | break; | 334 | break; |
334 | 335 | ||
335 | case 1: // ftp selected | 336 | case 1: // ftp selected |
336 | downloadFtpList(); | 337 | downloadFtpList(); |
337 | break; | 338 | break; |
338 | 339 | ||
339 | case 2: // Cancel | 340 | case 2: // Cancel |
340 | break; | 341 | break; |
341 | }; | 342 | }; |
342 | } | 343 | } |
343 | #endif | 344 | #endif |
344 | } // end DownloadIndex | 345 | } // end DownloadIndex |
345 | 346 | ||
346 | 347 | ||
347 | void Gutenbrowser::downloadFtpList() { | 348 | void Gutenbrowser::downloadFtpList() { |
348 | // QString cmd="wget http://www.promo.net/pg/list.html"); | 349 | // QString cmd="wget http://www.promo.net/pg/list.html"); |
349 | //system(cmd); | 350 | //system(cmd); |
350 | qApp->processEvents(); | 351 | qApp->processEvents(); |
351 | optionsDialog* optDlg; | 352 | optionsDialog* optDlg; |
352 | optDlg = new optionsDialog( this,"Options_Dlg", true); | 353 | optDlg = new optionsDialog( this,"Options_Dlg", true); |
353 | optDlg->getSite(); | 354 | optDlg->getSite(); |
354 | if(optDlg) | 355 | if(optDlg) |
355 | delete optDlg; | 356 | delete optDlg; |
356 | } | 357 | } |
357 | 358 | ||
358 | 359 | ||
359 | void Gutenbrowser::downloadLibIndex() { | 360 | void Gutenbrowser::downloadLibIndex() { |
360 | // QString dwmloader = local_library + "pgwhole.zip"; | 361 | // QString dwmloader = local_library + "pgwhole.zip"; |
361 | // QString cmd = "lynx -source http://www.gutenberg.net/pgwhole.zip | cat >> " + dwmloader; | 362 | // QString cmd = "lynx -source http://www.gutenberg.net/pgwhole.zip | cat >> " + dwmloader; |
362 | // system(cmd); | 363 | // system(cmd); |
363 | 364 | ||
364 | // QString outputFile= local_library+ "GUTINDEX.ALL"; | 365 | // QString outputFile= local_library+ "GUTINDEX.ALL"; |
365 | // config.setGroup( "FTPsite" ); // ftp server config | 366 | // config.setGroup( "FTPsite" ); // ftp server config |
366 | // ftp_host=config.readEntry("SiteName", ""); | 367 | // ftp_host=config.readEntry("SiteName", ""); |
367 | // ftp_base_dir= config.readEntry("base", ""); | 368 | // ftp_base_dir= config.readEntry("base", ""); |
368 | // QString networkUrl= "ftp://"+ftp_host+ftp_base_dir+"/GUTINDEX.ALL"; | 369 | // QString networkUrl= "ftp://"+ftp_host+ftp_base_dir+"/GUTINDEX.ALL"; |
369 | QDir dir( local_library); | 370 | QDir dir( local_library); |
370 | dir.cd("", TRUE); | 371 | dir.cd("", TRUE); |
371 | goGetit( "http://sailor.gutenberg.org/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3 | 372 | goGetit( "http://sailor.gutenberg.org/GUTINDEX.ALL", false); // until ghttp works on binaries -qt3 |
372 | // goGetit( "http://www.gutenberg.net/pgwhole.zip", true); // until ghttp works on binaries -qt3 | 373 | // goGetit( "http://www.gutenberg.net/pgwhole.zip", true); // until ghttp works on binaries -qt3 |
373 | // NetworkDialog *NetworkDlg; | 374 | // NetworkDialog *NetworkDlg; |
374 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, outputFile ); | 375 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, outputFile ); |
375 | // if( NetworkDlg->exec() != 0 ) | 376 | // if( NetworkDlg->exec() != 0 ) |
376 | // { // use new, improved, *INSTANT* network-dialog-file-getterer | 377 | // { // use new, improved, *INSTANT* network-dialog-file-getterer |
377 | //// QMessageBox::message("Note",""); | 378 | //// QMessageBox::message("Note",""); |
378 | // } | 379 | // } |
379 | // if(NetworkDlg) | 380 | // if(NetworkDlg) |
380 | // delete NetworkDlg; | 381 | // delete NetworkDlg; |
381 | } | 382 | } |
382 | 383 | ||
383 | 384 | ||
384 | void Gutenbrowser::PrintBtn() { | 385 | void Gutenbrowser::PrintBtn() { |
385 | } | 386 | } |
386 | 387 | ||
387 | void Gutenbrowser::SearchBtn() { | 388 | void Gutenbrowser::SearchBtn() { |
388 | if( loadCheck) { | 389 | if( loadCheck) { |
389 | odebug << "loadCheck: we have a loaded doc" << oendl; | 390 | odebug << "loadCheck: we have a loaded doc" << oendl; |
390 | Search(); | 391 | Search(); |
391 | } | 392 | } |
392 | // else | 393 | // else |
393 | // QMessageBox::message("Note","Sorry, can't search. No etext is loaded"); | 394 | // QMessageBox::message("Note","Sorry, can't search. No etext is loaded"); |
394 | } | 395 | } |
395 | 396 | ||
396 | 397 | ||
397 | void Gutenbrowser::ForwardBtn() { | 398 | void Gutenbrowser::ForwardBtn() { |
398 | 399 | ||
399 | if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) { | 400 | if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) { |
400 | 401 | ||
401 | QString s; | 402 | QString s; |
402 | QString insertString; | 403 | QString insertString; |
403 | int pageSize= Lview->PageSize(); | 404 | int pageSize= Lview->PageSize(); |
404 | Lview->clear(); | 405 | Lview->clear(); |
405 | 406 | ||
406 | for(int fd=0; fd < pageSize - 1;fd++) { | 407 | for(int fd=0; fd < pageSize - 1;fd++) { |
407 | f.readLine(s, 256); | 408 | f.readLine(s, 256); |
408 | if(useWrap) | 409 | if(useWrap) |
409 | s.replace(QRegExp("\n"),""); | 410 | s.replace(QRegExp("\n"),""); |
410 | insertString+=s; | 411 | insertString+=s; |
411 | Lview->insertLine( s, -1); | 412 | Lview->insertLine( s, -1); |
412 | // odebug << s << oendl; | 413 | odebug << s << oendl; |
413 | currentLine++; | 414 | currentLine++; |
414 | } | 415 | } |
415 | // Lview->insertAt( insertString,0,0, FALSE); | 416 | // Lview->insertAt( insertString,0,0, FALSE); |
416 | currentFilePos = f.at(); | 417 | currentFilePos = f.at(); |
417 | // if( i_pageNum != pages) { | 418 | // if( i_pageNum != pages) { |
418 | // Lview->MultiLine_Ex::pageDown( FALSE); | 419 | // Lview->MultiLine_Ex::pageDown( FALSE); |
419 | i_pageNum++; | 420 | i_pageNum++; |
420 | pageStopArray.resize(i_pageNum + 1); | 421 | pageStopArray.resize(i_pageNum + 1); |
421 | // int length = Lview->length(); | 422 | // int length = Lview->length(); |
422 | 423 | ||
423 | pageStopArray[i_pageNum ] = currentFilePos; | 424 | pageStopArray[i_pageNum ] = currentFilePos; |
424 | // odebug << currentFilePos << " current page is number " << i_pageNum | 425 | odebug << currentFilePos << " current page is number " << i_pageNum |
425 | // << ", pagesize " << pageSize << ", length " << Lview->length() | 426 | << ", pagesize " << pageSize << ", length " << Lview->length() |
426 | // << ", current " << pageStopArray[i_pageNum] << oendl; | 427 | << ", current " << pageStopArray[i_pageNum] << oendl; |
427 | setStatus(); | 428 | setStatus(); |
428 | Lview->setCursorPosition( 0, 0, FALSE); | 429 | // Lview->setCursorPosition( 0, 0, FALSE); |
429 | // } | 430 | // } |
430 | 431 | ||
431 | } else { | 432 | } else { |
432 | // odebug << "bal" << oendl; | 433 | odebug << "bal" << oendl; |
433 | // if( i_pageNum != pages) { | 434 | // if( i_pageNum != pages) { |
434 | 435 | ||
435 | // // int newTop = Lview->Top(); | 436 | // // int newTop = Lview->Top(); |
436 | // // if(Lview->lastRow() > i) | 437 | // // if(Lview->lastRow() > i) |
437 | // Lview->ScrollUp(1); | 438 | // Lview->ScrollUp(1); |
438 | // // i_pageNum++; | 439 | // // i_pageNum++; |
439 | // setStatus(); | 440 | // setStatus(); |
440 | // Lview->setCursorPosition( Lview->Top(), 0, FALSE); | 441 | // Lview->setCursorPosition( Lview->Top(), 0, FALSE); |
441 | 442 | ||
442 | // } | 443 | // } |
443 | 444 | ||
444 | } | 445 | } |
445 | Lview->setFocus(); | 446 | Lview->setFocus(); |
446 | 447 | ||
447 | // odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl; | 448 | odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl; |
448 | } | 449 | } |
449 | 450 | ||
450 | 451 | ||
451 | void Gutenbrowser::BackBtn() { | 452 | void Gutenbrowser::BackBtn() { |
452 | if( i_pageNum > 0) { | 453 | if( i_pageNum > 0) { |
453 | int pageSize= Lview->PageSize(); | 454 | int pageSize= Lview->PageSize(); |
454 | // int length=Lview->length(); | 455 | // int length=Lview->length(); |
455 | 456 | ||
456 | i_pageNum--; | 457 | i_pageNum--; |
457 | currentFilePos = f.at(); | 458 | currentFilePos = f.at(); |
458 | 459 | ||
459 | // odebug << currentFilePos << " move back to " << pageStopArray[i_pageNum - 1 ] | 460 | odebug << currentFilePos << " move back to " << pageStopArray[i_pageNum - 1 ] |
460 | // << ", current page number " << i_pageNum | 461 | << ", current page number " << i_pageNum |
461 | // << ", " << pageSize << ", length " << Lview->length() << oendl; | 462 | << ", " << pageSize << ", length " << Lview->length() << oendl; |
462 | 463 | ||
463 | if( i_pageNum < 2) { | 464 | if( i_pageNum < 2) { |
464 | f.at( 0); | 465 | f.at( 0); |
465 | } else { | 466 | } else { |
466 | if(!f.at( pageStopArray[i_pageNum - 1] )) | 467 | if(!f.at( pageStopArray[i_pageNum - 1] )) |
467 | odebug << "File positioned backward did not work" << oendl; | 468 | odebug << "File positioned backward did not work" << oendl; |
468 | } | 469 | } |
469 | QString s; | 470 | QString s; |
470 | // int sizeLine=0; | 471 | // int sizeLine=0; |
471 | Lview->clear(); | 472 | Lview->clear(); |
472 | // QString insertString; | 473 | // QString insertString; |
473 | 474 | ||
474 | for(int fd = 0; fd < pageSize ;fd++) { | 475 | for(int fd = 0; fd < pageSize ;fd++) { |
475 | // Lview->removeLine( Lview->PageSize() ); | 476 | // Lview->removeLine( Lview->PageSize() ); |
476 | f.readLine(s, 256); | 477 | f.readLine(s, 256); |
477 | if(useWrap) | 478 | if(useWrap) |
478 | s.replace(QRegExp("\n"),""); | 479 | s.replace(QRegExp("\n"),""); |
479 | currentLine++; | 480 | currentLine++; |
480 | // insertString+=s; | 481 | // insertString+=s; |
481 | Lview->insertLine( s, -1); | 482 | Lview->insertLine( s, -1); |
482 | } | 483 | } |
483 | 484 | ||
484 | // Lview->insertAt( insertString,0,0, FALSE); | 485 | // Lview->insertAt( insertString,0,0, FALSE); |
485 | 486 | ||
486 | if( !BackButton->autoRepeat() && !BackButton->isDown()) { | 487 | if( !BackButton->autoRepeat() && !BackButton->isDown()) { |
487 | QString topR; | 488 | QString topR; |
488 | QString lastR; | 489 | QString lastR; |
489 | QString pageR; | 490 | QString pageR; |
490 | // int sizer = Lview->lastRow() - Lview->topRow(); | 491 | // int sizer = Lview->lastRow() - Lview->topRow(); |
491 | // int i_topRow = Lview->topRow(); | 492 | // int i_topRow = Lview->topRow(); |
492 | if( i_pageNum < 1) | 493 | if( i_pageNum < 1) |
493 | i_pageNum = 1; | 494 | i_pageNum = 1; |
494 | setCaption(QString::number(i_pageNum)); | 495 | setCaption(QString::number(i_pageNum)); |
495 | } else { | 496 | } else { |
496 | // int newTop = Lview->Top(); | 497 | // int newTop = Lview->Top(); |
497 | // if(Lview->lastRow() > i) | 498 | // if(Lview->lastRow() > i) |
498 | Lview->MultiLine_Ex::pageUp( FALSE); | 499 | Lview->MultiLine_Ex::pageUp( FALSE); |
499 | // Lview->ScrollDown(1); | 500 | // Lview->ScrollDown(1); |
500 | // i_pageNum--; | 501 | // i_pageNum--; |
501 | if( i_pageNum < 1) | 502 | if( i_pageNum < 1) |
502 | i_pageNum = 1; | 503 | i_pageNum = 1; |
503 | setStatus(); | 504 | setStatus(); |
504 | Lview->setCursorPosition( Lview->Top(), 0, FALSE); | 505 | // Lview->setCursorPosition( Lview->Top(), 0, FALSE); |
505 | 506 | ||
506 | } | 507 | } |
507 | } | 508 | } |
508 | Lview->setFocus(); | 509 | Lview->setFocus(); |
509 | } | 510 | } |
510 | 511 | ||
511 | void Gutenbrowser::doBeginBtn() { | 512 | void Gutenbrowser::doBeginBtn() { |
512 | if(loadCheck) { | 513 | if(loadCheck) { |
513 | qApp->processEvents(); | 514 | qApp->processEvents(); |
514 | BeginBtn(); | 515 | BeginBtn(); |
515 | } | 516 | } |
516 | } | 517 | } |
517 | 518 | ||
518 | // moves text to the very top = 0 | 519 | // moves text to the very top = 0 |
519 | void Gutenbrowser::TopBtn() { | 520 | void Gutenbrowser::TopBtn() { |
520 | 521 | ||
521 | if(loadCheck) { | 522 | if(loadCheck) { |
522 | if( i_pageNum != 0) { | 523 | if( i_pageNum != 0) { |
523 | odebug << "top" << oendl; | 524 | odebug << "top" << oendl; |
524 | qApp->processEvents(); | 525 | qApp->processEvents(); |
525 | currentLine = 0; | 526 | currentLine = 0; |
526 | i_pageNum = 1; | 527 | i_pageNum = 1; |
527 | int pageSize = Lview->PageSize() ; | 528 | int pageSize = Lview->PageSize() ; |
528 | Lview->clear(); | 529 | Lview->clear(); |
529 | QString s; | 530 | QString s; |
530 | f.at(0); | 531 | f.at(0); |
531 | for(int fd=0; fd < pageSize ;fd++) { | 532 | for(int fd=0; fd < pageSize ;fd++) { |
532 | f.readLine(s, 256); | 533 | f.readLine(s, 256); |
533 | if(useWrap) | 534 | if(useWrap) |
534 | s.replace(QRegExp("\n"),""); | 535 | s.replace(QRegExp("\n"),""); |
535 | Lview->insertLine(s ,-1); | 536 | Lview->insertLine(s ,-1); |
536 | currentLine++; | 537 | currentLine++; |
537 | } | 538 | } |
538 | Lview->setCursorPosition( 0,0, FALSE); | 539 | // Lview->setCursorPosition( 0,0, FALSE); |
539 | i_pageNum=1; | 540 | i_pageNum=1; |
540 | setStatus(); | 541 | setStatus(); |
541 | } | 542 | } |
542 | Lview->setFocus(); | 543 | Lview->setFocus(); |
543 | } | 544 | } |
544 | } | 545 | } |
545 | 546 | ||
546 | //moves text to the start of the EText | 547 | //moves text to the start of the EText |
547 | void Gutenbrowser::BeginBtn() { | 548 | void Gutenbrowser::BeginBtn() { |
548 | i_pageNum = 1; | 549 | i_pageNum = 1; |
549 | currentLine = 0; | 550 | currentLine = 0; |
550 | QString s_pattern="*END*THE SMALL PRINT"; | 551 | QString s_pattern="*END*THE SMALL PRINT"; |
551 | QString sPattern2 = "*END THE SMALL PRINT"; | 552 | QString sPattern2 = "*END THE SMALL PRINT"; |
552 | 553 | ||
553 | int pageSize = Lview->PageSize(); | 554 | int pageSize = Lview->PageSize(); |
554 | Lview->clear(); | 555 | Lview->clear(); |
555 | 556 | ||
556 | // int lines = Lview->numLines(); | 557 | // int lines = Lview->numLines(); |
557 | int pos = 0;//, i = 0; | 558 | int pos = 0;//, i = 0; |
558 | int i_topRow = Lview->topRow(); | 559 | int i_topRow = Lview->topRow(); |
559 | 560 | ||
560 | QString LeftText;// = Lview->text(); | 561 | QString LeftText;// = Lview->text(); |
561 | 562 | ||
562 | int linesPerPage = Lview->lastRow() - Lview->topRow(); | 563 | int linesPerPage = Lview->lastRow() - Lview->topRow(); |
563 | // int pages = (( linesPerPage / Lview->editSize() ) ) +1; | 564 | // int pages = (( linesPerPage / Lview->editSize() ) ) +1; |
564 | // int pageN = 0; | 565 | // int pageN = 0; |
565 | i_pageNum = 1; | 566 | i_pageNum = 1; |
566 | int lastPage=1; | 567 | int lastPage=1; |
567 | int lineNo=0; | 568 | int lineNo=0; |
568 | QString s; | 569 | QString s; |
569 | f.at( 0); | 570 | f.at( 0); |
570 | 571 | ||
571 | while ( !f.atEnd() ) { | 572 | while ( !f.atEnd() ) { |
572 | f.readLine(s, 256); | 573 | f.readLine(s, 256); |
573 | lineNo++; | 574 | lineNo++; |
574 | LeftText = s; | 575 | LeftText = s; |
575 | currentFilePos = f.at(); | 576 | currentFilePos = f.at(); |
576 | 577 | ||
577 | i_pageNum = lineNo/pageSize; | 578 | i_pageNum = lineNo/pageSize; |
578 | if(lastPage < i_pageNum) { | 579 | if(lastPage < i_pageNum) { |
579 | pageStopArray.resize(i_pageNum + 1); | 580 | pageStopArray.resize(i_pageNum + 1); |
580 | pageStopArray[i_pageNum ] = currentFilePos; | 581 | pageStopArray[i_pageNum ] = currentFilePos; |
581 | // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; | 582 | odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; |
582 | } | 583 | } |
583 | // lastPage = i_pageNum; | 584 | // lastPage = i_pageNum; |
584 | if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) { | 585 | if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) { |
585 | odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; | 586 | odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; |
586 | break; | 587 | break; |
587 | } | 588 | } |
588 | } | 589 | } |
589 | if(f.atEnd()) //in case we didnt find anything, we need to show something | 590 | if(f.atEnd()) //in case we didnt find anything, we need to show something |
590 | f.at(0); | 591 | f.at(0); |
591 | Lview->clear(); | 592 | Lview->clear(); |
592 | for(int fd=0; fd < pageSize - 1;fd++) { | 593 | for(int fd=0; fd < pageSize - 1;fd++) { |
593 | f.readLine(s, 256); | 594 | f.readLine(s, 256); |
594 | if(useWrap) | 595 | if(useWrap) |
595 | s.replace(QRegExp("\n"),""); | 596 | s.replace(QRegExp("\n"),""); |
596 | Lview->insertLine( s, -1); | 597 | Lview->insertLine( s, -1); |
597 | currentLine++; | 598 | currentLine++; |
598 | } | 599 | } |
599 | 600 | ||
600 | i_pageNum = lineNo/pageSize; | 601 | i_pageNum = lineNo/pageSize; |
601 | pageStopArray.resize(i_pageNum + 1); | 602 | pageStopArray.resize(i_pageNum + 1); |
602 | // int length = Lview->length(); | 603 | // int length = Lview->length(); |
603 | 604 | ||
604 | qApp->processEvents(); | 605 | qApp->processEvents(); |
605 | 606 | ||
606 | if( pos > i_topRow ) { | 607 | if( pos > i_topRow ) { |
607 | Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE); | 608 | // Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE); |
608 | } else { | 609 | } else { |
609 | Lview->setCursorPosition( pos+2 , 0, FALSE ); | 610 | // Lview->setCursorPosition( pos+2 , 0, FALSE ); |
610 | } | 611 | } |
611 | 612 | ||
612 | Lview->deselect(); | 613 | Lview->deselect(); |
613 | // AdjustStatus(); | 614 | // AdjustStatus(); |
614 | Lview->setFocus(); | 615 | Lview->setFocus(); |
615 | } | 616 | } |
616 | 617 | ||
617 | /* | 618 | /* |
618 | sets the current page and place as a bookmark*/ | 619 | sets the current page and place as a bookmark*/ |
619 | void Gutenbrowser::setBookmark() { | 620 | void Gutenbrowser::setBookmark() { |
620 | int eexit=QMessageBox::information(this, "Note", | 621 | int eexit=QMessageBox::information(this, "Note", |
621 | "Do you really want to \nset this bookmark?." | 622 | "Do you really want to \nset this bookmark?." |
622 | ,QMessageBox::Yes, QMessageBox::No); | 623 | ,QMessageBox::Yes, QMessageBox::No); |
623 | if (eexit== 3) { | 624 | if (eexit== 3) { |
624 | 625 | ||
625 | currentFilePos = f.at(); | 626 | currentFilePos = f.at(); |
626 | 627 | ||
627 | Config cfg("Gutenbrowser"); | 628 | Config cfg("Gutenbrowser"); |
628 | cfg.setGroup("General"); | 629 | cfg.setGroup("General"); |
629 | file_name=cfg.readEntry("Current",""); | 630 | file_name=cfg.readEntry("Current",""); |
630 | qApp->processEvents(); | 631 | qApp->processEvents(); |
631 | odebug << "Settingbook mark "+file_name << oendl; | 632 | odebug << "Settingbook mark "+file_name << oendl; |
632 | 633 | ||
633 | cfg.setGroup("Titles"); | 634 | cfg.setGroup("Titles"); |
634 | title=cfg.readEntry(file_name,""); | 635 | title=cfg.readEntry(file_name,""); |
635 | odebug << "title is "+ title << oendl; | 636 | odebug << "title is "+ title << oendl; |
636 | 637 | ||
637 | cfg.setGroup( "Bookmarks" ); | 638 | cfg.setGroup( "Bookmarks" ); |
638 | 639 | ||
639 | cfg.writeEntry("File Name",file_name); | 640 | cfg.writeEntry("File Name",file_name); |
640 | cfg.writeEntry("Page Number",QString::number(i_pageNum) ); | 641 | cfg.writeEntry("Page Number",QString::number(i_pageNum) ); |
641 | cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); | 642 | cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); |
642 | cfg.writeEntry("Title", title); | 643 | cfg.writeEntry("Title", title); |
643 | 644 | ||
644 | int row = Lview->topRow();// Lview->Top(); | 645 | int row = Lview->topRow();// Lview->Top(); |
645 | cfg.writeEntry("LineNumber",QString::number(row) ); | 646 | cfg.writeEntry("LineNumber",QString::number(row) ); |
646 | 647 | ||
647 | cfg.setGroup(title); | 648 | cfg.setGroup(title); |
648 | cfg.writeEntry("File Name",file_name); | 649 | cfg.writeEntry("File Name",file_name); |
649 | cfg.writeEntry( "LineNumber", QString::number( row)); | 650 | cfg.writeEntry( "LineNumber", QString::number( row)); |
650 | cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); | 651 | cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); |
651 | cfg.writeEntry( "Page Number", QString::number( i_pageNum) ); | 652 | cfg.writeEntry( "Page Number", QString::number( i_pageNum) ); |
652 | bookmarksMenu->insertItem( title); | 653 | bookmarksMenu->insertItem( title); |
653 | } | 654 | } |
654 | } //end setBookmark | 655 | } //end setBookmark |
655 | 656 | ||
656 | 657 | ||
657 | /* goes to last set bookmark*/ | 658 | /* goes to last set bookmark*/ |
658 | void Gutenbrowser::Bookmark( int itemId) { | 659 | void Gutenbrowser::Bookmark( int itemId) { |
659 | 660 | ||
660 | // qApp->processEvents(); | 661 | // qApp->processEvents(); |
661 | Config config("Gutenbrowser"); | 662 | Config config("Gutenbrowser"); |
662 | config.setGroup( "Bookmarks" ); | 663 | config.setGroup( "Bookmarks" ); |
663 | 664 | ||
664 | // odebug << "<<<<<< " << Lview->PageSize() << ", " << Lview->lastRow() - Lview->topRow() << "" << oendl; | 665 | odebug << "<<<<<< " << Lview->PageSize() << ", " << Lview->lastRow() - Lview->topRow() << "" << oendl; |
665 | 666 | ||
666 | QString itemString; | 667 | QString itemString; |
667 | 668 | ||
668 | odebug << "menu item " << itemId << "" << oendl; | 669 | odebug << "menu item " << itemId << "" << oendl; |
669 | QString tempTitle; | 670 | QString tempTitle; |
670 | QString s_Bmrkrow; | 671 | QString s_Bmrkrow; |
671 | QString s_pageNum; | 672 | QString s_pageNum; |
672 | int Bmrkrow=0; | 673 | int Bmrkrow=0; |
673 | int bookmarkPosition = 0; | 674 | int bookmarkPosition = 0; |
674 | 675 | ||
675 | // qApp->processEvents(); | 676 | // qApp->processEvents(); |
676 | config.setGroup( "Bookmarks" ); | 677 | config.setGroup( "Bookmarks" ); |
677 | title = config.readEntry("Title", ""); | 678 | title = config.readEntry("Title", ""); |
678 | file_name = config.readEntry("File Name", ""); | 679 | file_name = config.readEntry("File Name", ""); |
679 | i_pageNum = config.readNumEntry("Page Number", 0); | 680 | i_pageNum = config.readNumEntry("Page Number", 0); |
680 | bookmarkPosition = config.readNumEntry( "PagePosition",0); | 681 | bookmarkPosition = config.readNumEntry( "PagePosition",0); |
681 | Bmrkrow = config.readNumEntry("LineNumber",0); | 682 | Bmrkrow = config.readNumEntry("LineNumber",0); |
682 | if( !file_name.contains("/")) { | 683 | if( !file_name.contains("/")) { |
683 | file_name = local_library + file_name; | 684 | file_name = local_library + file_name; |
684 | } | 685 | } |
685 | 686 | ||
686 | // getTitle(file_name); | 687 | // getTitle(file_name); |
687 | // qApp->processEvents(); | 688 | // qApp->processEvents(); |
688 | // Lview->setFocus(); | 689 | // Lview->setFocus(); |
689 | this->setFocus(); | 690 | this->setFocus(); |
690 | 691 | ||
691 | Lview->clear(); | 692 | Lview->clear(); |
692 | 693 | ||
693 | load(file_name); | 694 | load(file_name); |
694 | 695 | ||
695 | int pageSize= Lview->PageSize(); | 696 | int pageSize= Lview->PageSize(); |
696 | f.at(0); | 697 | f.at(0); |
697 | // Lview->clear(); | 698 | // Lview->clear(); |
698 | QString s; | 699 | QString s; |
699 | int lineNo=0; | 700 | int lineNo=0; |
700 | int lastPage=1; | 701 | int lastPage=1; |
701 | while ( !f.atEnd() ) { | 702 | while ( !f.atEnd() ) { |
702 | f.readLine(s, 256); | 703 | f.readLine(s, 256); |
703 | lineNo++; | 704 | lineNo++; |
704 | currentFilePos = f.at(); | 705 | currentFilePos = f.at(); |
705 | 706 | ||
706 | i_pageNum = lineNo/pageSize; | 707 | i_pageNum = lineNo/pageSize; |
707 | if(lastPage < i_pageNum) { | 708 | if(lastPage < i_pageNum) { |
708 | pageStopArray.resize(i_pageNum + 1); | 709 | pageStopArray.resize(i_pageNum + 1); |
709 | pageStopArray[i_pageNum ] = currentFilePos; | 710 | pageStopArray[i_pageNum ] = currentFilePos; |
710 | // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; | 711 | odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; |
711 | } | 712 | } |
712 | if(currentFilePos == bookmarkPosition) | 713 | if(currentFilePos == bookmarkPosition) |
713 | break; | 714 | break; |
714 | } | 715 | } |
715 | if(f.atEnd()) | 716 | if(f.atEnd()) |
716 | f.at(0); | 717 | f.at(0); |
717 | else | 718 | else |
718 | f.at( bookmarkPosition); | 719 | f.at( bookmarkPosition); |
719 | 720 | ||
720 | for(int fd=0; fd < pageSize - 1;fd++) { | 721 | for(int fd=0; fd < pageSize - 1;fd++) { |
721 | f.readLine(s, 256); | 722 | f.readLine(s, 256); |
722 | lineNo++; | 723 | lineNo++; |
723 | if(useWrap) | 724 | if(useWrap) |
724 | s.replace(QRegExp("\n"),""); | 725 | s.replace(QRegExp("\n"),""); |
725 | Lview->insertLine( s, -1); | 726 | Lview->insertLine( s, -1); |
726 | currentLine++; | 727 | currentLine++; |
727 | } | 728 | } |
728 | 729 | ||
729 | i_pageNum = lineNo/pageSize; | 730 | i_pageNum = lineNo/pageSize; |
730 | pageStopArray.resize(i_pageNum + 1); | 731 | pageStopArray.resize(i_pageNum + 1); |
731 | 732 | ||
732 | if(showMainList) { | 733 | if(showMainList) { |
733 | showMainList=FALSE; | 734 | showMainList=FALSE; |
734 | mainList->hide(); | 735 | mainList->hide(); |
735 | Lview->show(); | 736 | Lview->show(); |
736 | // qApp->processEvents(); | 737 | // qApp->processEvents(); |
737 | } | 738 | } |
738 | 739 | ||
739 | odebug << "bookmark loaded" << oendl; | 740 | odebug << "bookmark loaded" << oendl; |
740 | setCaption(title); | 741 | setCaption(title); |
741 | } | 742 | } |
742 | 743 | ||
743 | 744 | ||
744 | bool Gutenbrowser::load( const char *fileName) { | 745 | bool Gutenbrowser::load( const char *fileName) { |
745 | 746 | ||
746 | // QCopEnvelope ( "QPE/System", "busy()" ); | 747 | // QCopEnvelope ( "QPE/System", "busy()" ); |
747 | // odebug << "Title is already set as "+title << oendl; | 748 | odebug << "Title is already set as "+title << oendl; |
748 | odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl; | 749 | odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl; |
749 | if( Lview->PageSize() < 4) { | 750 | if( Lview->PageSize() < 4) { |
750 | 751 | ||
751 | Lview->setMaximumHeight( sizeHint().height() ); | 752 | Lview->setMaximumHeight( sizeHint().height() ); |
752 | Lview->setMinimumHeight( sizeHint().height() ); | 753 | Lview->setMinimumHeight( sizeHint().height() ); |
753 | pointSize = Lview->fontInfo().pointSize(); | 754 | pointSize = Lview->fontInfo().pointSize(); |
754 | odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl; | 755 | odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl; |
755 | if(pointSize < 10) | 756 | if(pointSize < 10) |
756 | Lview->setFixedVisibleLines(19); | 757 | Lview->setFixedVisibleLines(19); |
757 | else | 758 | else |
758 | Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2); | 759 | Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2); |
759 | } | 760 | } |
760 | 761 | ||
761 | Config cfg("Gutenbrowser"); | 762 | Config cfg("Gutenbrowser"); |
762 | cfg.setGroup("General"); | 763 | cfg.setGroup("General"); |
763 | cfg.writeEntry("Current",fileName); | 764 | cfg.writeEntry("Current",fileName); |
764 | currentLine=0; | 765 | currentLine=0; |
765 | 766 | ||
766 | file_name=fileName; | 767 | file_name=fileName; |
767 | QString o_file = fileName; | 768 | QString o_file = fileName; |
768 | 769 | ||
769 | // if (i_pageNum < 1) { | 770 | // if (i_pageNum < 1) { |
770 | i_pageNum = 1; | 771 | i_pageNum = 1; |
771 | // } | 772 | // } |
772 | odebug << "ready to open "+o_file << oendl; | 773 | odebug << "ready to open "+o_file << oendl; |
773 | 774 | ||
774 | if(f.isOpen()) f.close(); | 775 | if(f.isOpen()) f.close(); |
775 | f.setName( o_file); | 776 | f.setName( o_file); |
776 | 777 | ||
777 | if ( !f.open( IO_ReadOnly)) { | 778 | if ( !f.open( IO_ReadOnly)) { |
778 | QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) ); | 779 | QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) ); |
779 | return false; | 780 | return false; |
780 | } | 781 | } |
781 | currentFilePos = 0; | 782 | currentFilePos = 0; |
782 | pageStopArray.resize(3); | 783 | pageStopArray.resize(3); |
783 | pageStopArray[0] = currentFilePos; | 784 | pageStopArray[0] = currentFilePos; |
784 | 785 | ||
785 | fileHandle = f.handle(); | 786 | fileHandle = f.handle(); |
786 | QString insertString; | 787 | QString insertString; |
787 | QTextStream t(&f); | 788 | QTextStream t(&f); |
788 | QString s; | 789 | QString s; |
789 | for(int fd=0; fd < Lview->PageSize() ;fd++) { | 790 | for(int fd=0; fd < Lview->PageSize() ;fd++) { |
790 | s=t.readLine(); | 791 | s=t.readLine(); |
791 | // insertString+=s; | 792 | // insertString+=s; |
792 | if(useWrap) | 793 | if(useWrap) |
793 | s.replace(QRegExp("\n"),""); | 794 | s.replace(QRegExp("\n"),""); |
794 | // s.replace(QRegExp("\r"),""); | 795 | // s.replace(QRegExp("\r"),""); |
795 | Lview->insertLine( s,-1); | 796 | Lview->insertLine( s,-1); |
796 | currentLine++; | 797 | currentLine++; |
797 | } | 798 | } |
798 | 799 | ||
799 | // int length = Lview->length(); | 800 | // int length = Lview->length(); |
800 | currentFilePos = f.at(); | 801 | currentFilePos = f.at(); |
801 | 802 | ||
802 | pageStopArray[1] = currentFilePos; | 803 | pageStopArray[1] = currentFilePos; |
803 | 804 | ||
804 | odebug << "<<<<<<<<<<<" << currentFilePos << " current page is number " << i_pageNum | 805 | odebug << "<<<<<<<<<<<" << currentFilePos << " current page is number " << i_pageNum |
805 | << ", length " << Lview->length() << ", current " << pageStopArray[i_pageNum] | 806 | << ", length " << Lview->length() << ", current " << pageStopArray[i_pageNum] |
806 | << ", pageSize " << Lview->PageSize() << oendl; | 807 | << ", pageSize " << Lview->PageSize() << oendl; |
807 | 808 | ||
808 | Lview->setMaxLines(Lview->PageSize()*2); | 809 | Lview->setMaxLines(Lview->PageSize()*2); |
809 | odebug << "Gulped " << currentLine << "" << oendl; | 810 | odebug << "Gulped " << currentLine << "" << oendl; |
810 | setCaption(title); | 811 | setCaption(title); |
811 | Lview->setAutoUpdate( TRUE); | 812 | Lview->setAutoUpdate( TRUE); |
812 | 813 | ||
813 | Lview->setCursorPosition(0,0,FALSE); | 814 | // Lview->setCursorPosition(0,0,FALSE); |
814 | 815 | ||
815 | // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; | 816 | // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; |
816 | //odebug << "number of pages " << pages << "" << oendl; | 817 | //odebug << "number of pages " << pages << "" << oendl; |
817 | 818 | ||
818 | loadCheck = true; | 819 | loadCheck = true; |
819 | enableButtons(true); | 820 | enableButtons(true); |
820 | if( donateMenu->count() == 3) { | 821 | if( donateMenu->count() == 3) { |
821 | donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() )); | 822 | donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() )); |
822 | } | 823 | } |
823 | Lview->setFocus(); | 824 | Lview->setFocus(); |
824 | 825 | ||
825 | // QCopEnvelope("QPE/System", "notBusy()" ); | 826 | // QCopEnvelope("QPE/System", "notBusy()" ); |
826 | return true; | 827 | return true; |
827 | } // end load | 828 | } // end load |
828 | 829 | ||
829 | void Gutenbrowser::Search() { | 830 | void Gutenbrowser::Search() { |
830 | 831 | ||
831 | // if( searchDlg->isHidden()) | 832 | // if( searchDlg->isHidden()) |
832 | { | 833 | { |
833 | odebug << "Starting search dialog" << oendl; | 834 | odebug << "Starting search dialog" << oendl; |
834 | searchDlg = new SearchDialog( this, "Etext Search", true); | 835 | searchDlg = new SearchDialog( this, "Etext Search", true); |
835 | searchDlg->setCaption( tr( "Etext Search" )); | 836 | searchDlg->setCaption( tr( "Etext Search" )); |
836 | // searchDlg->setLabel( "- searches etext"); | 837 | // searchDlg->setLabel( "- searches etext"); |
837 | connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); | 838 | connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); |
838 | connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); | 839 | connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); |
839 | 840 | ||
840 | QString resultString; | 841 | QString resultString; |
841 | QString string = searchDlg->searchString; | 842 | QString string = searchDlg->searchString; |
842 | Lview->deselect(); | 843 | Lview->deselect(); |
843 | searchDlg->show(); | 844 | searchDlg->show(); |
844 | searchDlg->result(); | 845 | searchDlg->result(); |
845 | } | 846 | } |
846 | } | 847 | } |
847 | 848 | ||
848 | void Gutenbrowser::search_slot( ) { | 849 | void Gutenbrowser::search_slot( ) { |
849 | int line, col; | 850 | int line, col; |
850 | if (!searchDlg /*&& !loadCheck */) | 851 | if (!searchDlg /*&& !loadCheck */) |
851 | return; | 852 | return; |
852 | 853 | ||
853 | Lview->getCursorPosition(&line,&col); | 854 | Lview->getCursorPosition(&line,&col); |
854 | QString to_find_string=searchDlg->get_text(); | 855 | QString to_find_string=searchDlg->get_text(); |
855 | 856 | ||
856 | // searchDlg->get_direction();// is true if searching backward | 857 | // searchDlg->get_direction();// is true if searching backward |
857 | if ( last_search != 0 && searchDlg->get_direction() ){ | 858 | if ( last_search != 0 && searchDlg->get_direction() ){ |
858 | col = col - pattern.length() - 1 ; | 859 | col = col - pattern.length() - 1 ; |
859 | } | 860 | } |
860 | again: | 861 | again: |
861 | int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col); | 862 | int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col); |
862 | if(result == 0){ | 863 | if(result == 0){ |
863 | if(!searchDlg->get_direction()){ // forward search | 864 | if(!searchDlg->get_direction()){ // forward search |
864 | int query = QMessageBox::information( searchDlg, "Find", | 865 | int query = QMessageBox::information( searchDlg, "Find", |
865 | "End of document reached.\nContinue from the beginning?", | 866 | "End of document reached.\nContinue from the beginning?", |
866 | "Yes", "No", "", 0,1); | 867 | "Yes", "No", "", 0,1); |
867 | if (query == 0){ | 868 | if (query == 0){ |
868 | line = 0; | 869 | line = 0; |
869 | col = 0; | 870 | col = 0; |
870 | goto again; | 871 | goto again; |
871 | } | 872 | } |
872 | } else { //backward search | 873 | } else { //backward search |
873 | int query = QMessageBox::information( searchDlg, "Find", | 874 | int query = QMessageBox::information( searchDlg, "Find", |
874 | "End of document reached.\nContinue from the beginning?", | 875 | "End of document reached.\nContinue from the beginning?", |
875 | "Yes", "No", "", 0,1); | 876 | "Yes", "No", "", 0,1); |
876 | if (query == 0){ | 877 | if (query == 0){ |
877 | QString string = Lview->textLine( Lview->numLines() - 1 ); | 878 | QString string = Lview->textLine( Lview->numLines() - 1 ); |
878 | line = Lview->numLines() - 1; | 879 | line = Lview->numLines() - 1; |
879 | lineCheck = line; | 880 | lineCheck = line; |
880 | col = string.length(); | 881 | col = string.length(); |
881 | last_search = -1; //BACKWARD; | 882 | last_search = -1; //BACKWARD; |
882 | goto again; | 883 | goto again; |
883 | } | 884 | } |
884 | } | 885 | } |
885 | } else { | 886 | } else { |
886 | 887 | ||
887 | //// emit CursorPositionChanged(); textLine | 888 | //// emit CursorPositionChanged(); textLine |
888 | } | 889 | } |
889 | } | 890 | } |
890 | 891 | ||
891 | int Gutenbrowser::doSearch( const QString &s_pattern , bool case_sensitive, bool forward, int line, int col ) { | 892 | int Gutenbrowser::doSearch( const QString &s_pattern , bool case_sensitive, bool forward, int line, int col ) { |
892 | int i, length; | 893 | int i, length; |
893 | int pos = -1; | 894 | int pos = -1; |
894 | if(forward) { | 895 | if(forward) { |
895 | QString string; | 896 | QString string; |
896 | for(i = line; i < Lview->numLines(); i++) { | 897 | for(i = line; i < Lview->numLines(); i++) { |
897 | 898 | ||
898 | string = Lview->textLine(i); | 899 | string = Lview->textLine(i); |
899 | pos = string.find(s_pattern, i == line ? col : 0, case_sensitive); | 900 | pos = string.find(s_pattern, i == line ? col : 0, case_sensitive); |
900 | if( pos != -1) { | 901 | if( pos != -1) { |
901 | int top = Lview->Top(); | 902 | int top = Lview->Top(); |
902 | length = s_pattern.length(); | 903 | length = s_pattern.length(); |
903 | if( i > Lview->lastRow() ) { | 904 | if( i > Lview->lastRow() ) { |
904 | Lview->setCursorPosition(i,pos,FALSE); | 905 | // Lview->setCursorPosition(i,pos,FALSE); |
905 | for(int l = 0 ; l < length; l++) { | 906 | for(int l = 0 ; l < length; l++) { |
906 | Lview->cursorRight(TRUE); | 907 | Lview->cursorRight(TRUE); |
907 | } | 908 | } |
908 | Lview->setCursorPosition( i , pos + length, TRUE ); | 909 | // Lview->setCursorPosition( i , pos + length, TRUE ); |
909 | int newTop = Lview->Top(); | 910 | int newTop = Lview->Top(); |
910 | if(Lview->lastRow() > i) | 911 | if(Lview->lastRow() > i) |
911 | Lview->ScrollUp( newTop - top); | 912 | Lview->ScrollUp( newTop - top); |
912 | // AdjustStatus(); | 913 | // AdjustStatus(); |
913 | } else { | 914 | } else { |
914 | Lview->setCursorPosition(i,pos,FALSE); | 915 | // Lview->setCursorPosition(i,pos,FALSE); |
915 | for(int l = 0 ; l < length; l++) { | 916 | for(int l = 0 ; l < length; l++) { |
916 | Lview->cursorRight(TRUE); | 917 | Lview->cursorRight(TRUE); |
917 | } | 918 | } |
918 | Lview->setCursorPosition( i , pos + length, TRUE ); | 919 | // Lview->setCursorPosition( i , pos + length, TRUE ); |
919 | // AdjustStatus(); | 920 | // AdjustStatus(); |
920 | } | 921 | } |
921 | pattern = s_pattern; | 922 | pattern = s_pattern; |
922 | last_search = 1; //FORWARD; | 923 | last_search = 1; //FORWARD; |
923 | return 1; | 924 | return 1; |
924 | } | 925 | } |
925 | } | 926 | } |
926 | } else { //////////////// searching backwards | 927 | } else { //////////////// searching backwards |
927 | QString string; | 928 | QString string; |
928 | for( i = line; i >= 0; i--) { | 929 | for( i = line; i >= 0; i--) { |
929 | string = Lview->textLine(i); | 930 | string = Lview->textLine(i); |
930 | int line_length = string.length(); | 931 | int line_length = string.length(); |
931 | pos = string.findRev(s_pattern, line == i ? col : line_length , case_sensitive); | 932 | pos = string.findRev(s_pattern, line == i ? col : line_length , case_sensitive); |
932 | if (pos != -1) { | 933 | if (pos != -1) { |
933 | // int top = Lview->Top(); | 934 | // int top = Lview->Top(); |
934 | length = s_pattern.length(); | 935 | length = s_pattern.length(); |
935 | if( i < Lview->Top() ) { | 936 | if( i < Lview->Top() ) { |
936 | Lview->ScrollDown( Lview->PageSize() ); | 937 | Lview->ScrollDown( Lview->PageSize() ); |
937 | Lview->MultiLine_Ex::pageUp( FALSE ); | 938 | Lview->MultiLine_Ex::pageUp( FALSE ); |
938 | if( ! (line == i && pos > col ) ) { | 939 | if( ! (line == i && pos > col ) ) { |
939 | Lview->setCursorPosition( i ,pos ,FALSE ); | 940 | // Lview->setCursorPosition( i ,pos ,FALSE ); |
940 | for(int l = 0 ; l < length; l++) { | 941 | for(int l = 0 ; l < length; l++) { |
941 | Lview->cursorRight(TRUE); | 942 | Lview->cursorRight(TRUE); |
942 | } | 943 | } |
943 | Lview->setCursorPosition(i ,pos + length ,TRUE ); | 944 | // Lview->setCursorPosition(i ,pos + length ,TRUE ); |
944 | // int newTop = Lview->Top(); | 945 | // int newTop = Lview->Top(); |
945 | /* if(useSplitter) Rview->ScrollUp( newTop - top); | 946 | /* if(useSplitter) Rview->ScrollUp( newTop - top); |
946 | */ } | 947 | */ } |
947 | } else { | 948 | } else { |
948 | if( ! (line == i && pos > col ) ) { | 949 | if( ! (line == i && pos > col ) ) { |
949 | Lview->setCursorPosition( i, pos, FALSE ); | 950 | // Lview->setCursorPosition( i, pos, FALSE ); |
950 | for( int l = 0 ; l < length; l++) { | 951 | for( int l = 0 ; l < length; l++) { |
951 | Lview->cursorRight( TRUE); | 952 | Lview->cursorRight( TRUE); |
952 | } | 953 | } |
953 | Lview->setCursorPosition( i, pos + length, TRUE ); | 954 | // Lview->setCursorPosition( i, pos + length, TRUE ); |
954 | } | 955 | } |
955 | pattern = s_pattern; | 956 | pattern = s_pattern; |
956 | last_search = -1; | 957 | last_search = -1; |
957 | return 1; | 958 | return 1; |
958 | } | 959 | } |
959 | } | 960 | } |
960 | } | 961 | } |
961 | } | 962 | } |
962 | return 0; | 963 | return 0; |
963 | } | 964 | } |
964 | 965 | ||
965 | void Gutenbrowser::LibraryBtn() { | 966 | void Gutenbrowser::LibraryBtn() { |
966 | 967 | ||
967 | QString newestLibraryFile ="pgwhole.zip"; | 968 | QString newestLibraryFile ="pgwhole.zip"; |
968 | QString zipFile; | 969 | QString zipFile; |
969 | // odebug << "Local Library is " << local_library << " " << oendl; | 970 | // odebug << "Local Library is " << local_library << " " << oendl; |
970 | zipFile="/usr/bin/unzip"; | 971 | zipFile="/usr/bin/unzip"; |
971 | // odebug << "newestLibraryFile is " << newestLibraryFile << " " << oendl; | 972 | // odebug << "newestLibraryFile is " << newestLibraryFile << " " << oendl; |
972 | if( QFile::exists( local_library+newestLibraryFile)) { | 973 | if( QFile::exists( local_library+newestLibraryFile)) { |
973 | if( QFile::exists(zipFile) ) { | 974 | if( QFile::exists(zipFile) ) { |
974 | UnZipIt(newestLibraryFile); | 975 | UnZipIt(newestLibraryFile); |
975 | } | 976 | } |
976 | else | 977 | else |
977 | QMessageBox::message( "Note",( tr("Please install unzip")) ); | 978 | QMessageBox::message( "Note",( tr("Please install unzip")) ); |
978 | } | 979 | } |
979 | // LibraryDlg = new LibraryDialog( this, "Library Index"); | 980 | // LibraryDlg = new LibraryDialog( this, "Library Index"); |
980 | LibraryDlg->setCaption( tr( "Gutenberg Library")); | 981 | LibraryDlg->setCaption( tr( "Gutenberg Library")); |
981 | Config config("Gutenbrowser"); | 982 | Config config("Gutenbrowser"); |
982 | config.setGroup("General"); | 983 | config.setGroup("General"); |
983 | QString tmp=config.readEntry("RunBefore","FALSE"); | 984 | |
984 | if(tmp=="FALSE") { | ||
985 | QMessageBox::message( "Note", | ||
986 | "<P>Your first time running gutenbrowser. You'll need to click the \"load library\" button to load the gutenberg index.</P>"); | ||
987 | config.writeEntry("RunBefore","TRUE"); | ||
988 | } | ||
989 | if(useSplitter) | 985 | if(useSplitter) |
990 | LibraryDlg->useSmallInterface=FALSE; | 986 | LibraryDlg->useSmallInterface=FALSE; |
991 | 987 | ||
992 | LibraryDlg->showMaximized(); | 988 | LibraryDlg->showMaximized(); |
993 | 989 | ||
994 | if( LibraryDlg->exec() != 0 ) { | 990 | if( LibraryDlg->exec() != 0 ) { |
995 | listItemNumber = LibraryDlg->DlglistItemNumber; | 991 | listItemNumber = LibraryDlg->DlglistItemNumber; |
996 | listItemFile = LibraryDlg->DlglistItemFile; | 992 | listItemFile = LibraryDlg->DlglistItemFile; |
997 | listItemYear = LibraryDlg->DlglistItemYear; | 993 | listItemYear = LibraryDlg->DlglistItemYear; |
998 | listItemTitle = LibraryDlg->DlglistItemTitle; | 994 | listItemTitle = LibraryDlg->DlglistItemTitle; |
999 | file_name = LibraryDlg->File_Name; | 995 | file_name = LibraryDlg->File_Name; |
1000 | // odebug << "title is being set as "+title << oendl; | 996 | // odebug << "title is being set as "+title << oendl; |
1001 | title = listItemTitle; | 997 | title = listItemTitle; |
1002 | 998 | ||
1003 | // config.setGroup( "Proxy" ); | 999 | // config.setGroup( "Proxy" ); |
1004 | // if( LibraryDlg->checked == 1) { | 1000 | // if( LibraryDlg->checked == 1) { |
1005 | // config.writeEntry("IsChecked", "TRUE"); | 1001 | // config.writeEntry("IsChecked", "TRUE"); |
1006 | // } else { | 1002 | // } else { |
1007 | // config.writeEntry("IsChecked", "FALSE"); | 1003 | // config.writeEntry("IsChecked", "FALSE"); |
1008 | // } | 1004 | // } |
1009 | // config.write(); | 1005 | // config.write(); |
1010 | // config.read(); | 1006 | // config.read(); |
1011 | if ( listItemNumber.isNull()) { | 1007 | if ( listItemNumber.isNull()) { |
1012 | } else { | 1008 | } else { |
1013 | i_pageNum = 1; | 1009 | i_pageNum = 1; |
1014 | if( file_name !="Error" && file_name.length() >2 && !file_name.isEmpty() ) { | 1010 | if( file_name !="Error" && file_name.length() >2 && !file_name.isEmpty() ) { |
1015 | //replace .zip with txt for opening it. | 1011 | //replace .zip with txt for opening it. |
1016 | // printf("\nFile name is now\n"); | 1012 | // printf("\nFile name is now\n"); |
1017 | // printf(file_name); | 1013 | // printf(file_name); |
1018 | // printf("\n"); | 1014 | // printf("\n"); |
1019 | // | 1015 | // |
1020 | if( file_name.find(".zip")) | 1016 | if( file_name.find(".zip")) |
1021 | { | 1017 | { |
1022 | odebug << "Found zip file\n" << oendl; | 1018 | odebug << "Found zip file\n" << oendl; |
1023 | // QStringList args; | 1019 | // QStringList args; |
1024 | // args="unzip"; | 1020 | // args="unzip"; |
1025 | // args+="-o"; | 1021 | // args+="-o"; |
1026 | // args+=local_library+file_name; | 1022 | // args+=local_library+file_name; |
1027 | // args+="-d"; | 1023 | // args+="-d"; |
1028 | // args+=local_library; | 1024 | // args+=local_library; |
1029 | QString cmd = "/usr/bin/unzip -o " + local_library+file_name + " -d " + local_library; | 1025 | QString cmd = "/usr/bin/unzip -o " + local_library+file_name + " -d " + local_library; |
1030 | odebug << "Issuing the command "+ cmd << oendl; | 1026 | odebug << "Issuing the command "+ cmd << oendl; |
1031 | // unzipProc=new QProcess( this, "unzipProc" ); /// fark that idea! | 1027 | // unzipProc=new QProcess( this, "unzipProc" ); /// fark that idea! |
1032 | // unzipProc->start(); | 1028 | // unzipProc->start(); |
1033 | system(cmd); | 1029 | system(cmd); |
1034 | remove( file_name); | 1030 | remove( file_name); |
1035 | 1031 | ||
1036 | } | 1032 | } |
1037 | // // | 1033 | // // |
1038 | // file_name = file_name.left(4)+ ".txt"; | 1034 | // file_name = file_name.left(4)+ ".txt"; |
1039 | if( LibraryDlg) | 1035 | if( LibraryDlg) |
1040 | delete LibraryDlg; | 1036 | delete LibraryDlg; |
1041 | setTitle(); | 1037 | setTitle(); |
1042 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1038 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1043 | load( file_name); | 1039 | load( file_name); |
1044 | } else { | 1040 | } else { |
1045 | printf("Not opening the file.\n"); | 1041 | printf("Not opening the file.\n"); |
1046 | } | 1042 | } |
1047 | } | 1043 | } |
1048 | } | 1044 | } |
1049 | if(showMainList) { | 1045 | if(showMainList) { |
1050 | if(!Lview->isHidden()) | 1046 | if(!Lview->isHidden()) |
1051 | Lview->hide(); | 1047 | Lview->hide(); |
1052 | qApp->processEvents(); | 1048 | qApp->processEvents(); |
1053 | showMainList=TRUE; | 1049 | showMainList=TRUE; |
1054 | if(mainList->isHidden()) | 1050 | if(mainList->isHidden()) |
1055 | mainList->show(); | 1051 | mainList->show(); |
1056 | fillWithTitles(); | 1052 | fillWithTitles(); |
1057 | qApp->processEvents(); | 1053 | qApp->processEvents(); |
1058 | } else | 1054 | } else |
1059 | setCentralWidget( Lview); | 1055 | setCentralWidget( Lview); |
1060 | // QPEApplication::grabKeyboard(); | 1056 | // QPEApplication::grabKeyboard(); |
1061 | // fixKeys(); | 1057 | // fixKeys(); |
1062 | } | 1058 | } |
1063 | 1059 | ||
1064 | void Gutenbrowser::OpenBtn() { | 1060 | void Gutenbrowser::OpenBtn() { |
1065 | QString s_temp; | 1061 | QString s_temp; |
1066 | s_temp = status; | 1062 | s_temp = status; |
1067 | OpenEtext* OpenDlg; | 1063 | OpenEtext* OpenDlg; |
1068 | OpenDlg = new OpenEtext(this,"OpenDlg"); | 1064 | OpenDlg = new OpenEtext(this,"OpenDlg"); |
1069 | OpenDlg->showMaximized(); | 1065 | OpenDlg->showMaximized(); |
1070 | 1066 | ||
1071 | if( OpenDlg->exec() != 0) { | 1067 | if( OpenDlg->exec() != 0) { |
1072 | title = OpenDlg->openFileTitle; | 1068 | title = OpenDlg->openFileTitle; |
1073 | odebug << "title open as "+title << oendl; | 1069 | odebug << "title open as "+title << oendl; |
1074 | file_name = OpenDlg->file; | 1070 | file_name = OpenDlg->file; |
1075 | i_pageNum = 1; | 1071 | i_pageNum = 1; |
1076 | 1072 | ||
1077 | if( !file_name.isEmpty() || file_name.length() > 2 ) { | 1073 | if( !file_name.isEmpty() || file_name.length() > 2 ) { |
1078 | if(showMainList) { | 1074 | if(showMainList) { |
1079 | showMainList=FALSE; | 1075 | showMainList=FALSE; |
1080 | odebug << "ShowMainList is now false" << oendl; | 1076 | odebug << "ShowMainList is now false" << oendl; |
1081 | mainList->hide(); | 1077 | mainList->hide(); |
1082 | Lview->show(); | 1078 | Lview->show(); |
1083 | qApp->processEvents(); | 1079 | qApp->processEvents(); |
1084 | } | 1080 | } |
1085 | Lview->clear(); | 1081 | Lview->clear(); |
1086 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1082 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1087 | load(file_name); | 1083 | load(file_name); |
1088 | } else { | 1084 | } else { |
1089 | odebug << "file_name is empty!" << oendl; | 1085 | odebug << "file_name is empty!" << oendl; |
1090 | if(showMainList) { | 1086 | if(showMainList) { |
1091 | if(!Lview->isHidden()) | 1087 | if(!Lview->isHidden()) |
1092 | Lview->hide(); | 1088 | Lview->hide(); |
1093 | qApp->processEvents(); | 1089 | qApp->processEvents(); |
1094 | if(mainList->isHidden()) | 1090 | if(mainList->isHidden()) |
1095 | mainList->show(); | 1091 | mainList->show(); |
1096 | fillWithTitles(); | 1092 | fillWithTitles(); |
1097 | qApp->processEvents(); | 1093 | qApp->processEvents(); |
1098 | } | 1094 | } |
1099 | 1095 | ||
1100 | } | 1096 | } |
1101 | } | 1097 | } |
1102 | if( OpenDlg) | 1098 | if( OpenDlg) |
1103 | delete OpenDlg; | 1099 | delete OpenDlg; |
1104 | /* | 1100 | /* |
1105 | Config config("Gutenbrowser"); | 1101 | Config config("Gutenbrowser"); |
1106 | config.setGroup( title); | 1102 | config.setGroup( title); |
1107 | file_name = config.readEntry("File Name", ""); | 1103 | file_name = config.readEntry("File Name", ""); |
1108 | i_pageNum = config.readNumEntry("Page Number", -1); | 1104 | i_pageNum = config.readNumEntry("Page Number", -1); |
1109 | int Bmrkrow = config.readNumEntry("LineNumber", -1); | 1105 | int Bmrkrow = config.readNumEntry("LineNumber", -1); |
1110 | if(Bmrkrow > -1) { | 1106 | if(Bmrkrow > -1) { |
1111 | if( Bmrkrow > Lview->topRow() ) { | 1107 | if( Bmrkrow > Lview->topRow() ) { |
1112 | Lview->setCursorPosition( Bmrkrow ,0, FALSE ); | 1108 | Lview->setCursorPosition( Bmrkrow ,0, FALSE ); |
1113 | Lview->ScrollUp( Bmrkrow - Lview->topRow() ); | 1109 | Lview->ScrollUp( Bmrkrow - Lview->topRow() ); |
1114 | // AdjustStatus(); | 1110 | // AdjustStatus(); |
1115 | } | 1111 | } |
1116 | else if( Bmrkrow < Lview->topRow() ) { | 1112 | else if( Bmrkrow < Lview->topRow() ) { |
1117 | Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE ); | 1113 | Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE ); |
1118 | Lview->ScrollDown( Lview->topRow() - Bmrkrow ); | 1114 | Lview->ScrollDown( Lview->topRow() - Bmrkrow ); |
1119 | // AdjustStatus(); | 1115 | // AdjustStatus(); |
1120 | } | 1116 | } |
1121 | } | 1117 | } |
1122 | */ | 1118 | */ |
1123 | // ResizeEdits(); | 1119 | // ResizeEdits(); |
1124 | 1120 | ||
1125 | } | 1121 | } |
1126 | 1122 | ||
1127 | void Gutenbrowser::ChangeFont() { | 1123 | void Gutenbrowser::ChangeFont() { |
1128 | #ifndef Q_WS_QWS | 1124 | #ifndef Q_WS_QWS |
1129 | bool ok; | 1125 | bool ok; |
1130 | 1126 | ||
1131 | weight= Lview->fontInfo().weight(); | 1127 | weight= Lview->fontInfo().weight(); |
1132 | italic = Lview->fontInfo().italic(); | 1128 | italic = Lview->fontInfo().italic(); |
1133 | bold=Lview->fontInfo().bold(); | 1129 | bold=Lview->fontInfo().bold(); |
1134 | pointSize= Lview->fontInfo().pointSize(); | 1130 | pointSize= Lview->fontInfo().pointSize(); |
1135 | fontStr=Lview->fontInfo().family(); | 1131 | fontStr=Lview->fontInfo().family(); |
1136 | 1132 | ||
1137 | if(italic == true) | 1133 | if(italic == true) |
1138 | italicStr="TRUE"; | 1134 | italicStr="TRUE"; |
1139 | else | 1135 | else |
1140 | italicStr="FALSE"; | 1136 | italicStr="FALSE"; |
1141 | 1137 | ||
1142 | QFont currentfont( fontStr, pointSize, weight, italic ); | 1138 | QFont currentfont( fontStr, pointSize, weight, italic ); |
1143 | 1139 | ||
1144 | if (ok) { | 1140 | if (ok) { |
1145 | QFontInfo fontInfo(font ); | 1141 | QFontInfo fontInfo(font ); |
1146 | fontStr=fontInfo.family(); | 1142 | fontStr=fontInfo.family(); |
1147 | 1143 | ||
1148 | pointSize= fontInfo.pointSize(); | 1144 | pointSize= fontInfo.pointSize(); |
1149 | 1145 | ||
1150 | font.setFontSize(pointSize); | 1146 | font.setFontSize(pointSize); |
1151 | 1147 | ||
1152 | pointSizeStr.setNum( pointSize); | 1148 | pointSizeStr.setNum( pointSize); |
1153 | 1149 | ||
1154 | weight= fontInfo.weight(); | 1150 | weight= fontInfo.weight(); |
1155 | weightStr.setNum( weight); | 1151 | weightStr.setNum( weight); |
1156 | italic =fontInfo.italic(); | 1152 | italic =fontInfo.italic(); |
1157 | bold=fontInfo.bold(); | 1153 | bold=fontInfo.bold(); |
1158 | 1154 | ||
1159 | if(italic == true) | 1155 | if(italic == true) |
1160 | italicStr="TRUE"; | 1156 | italicStr="TRUE"; |
1161 | else | 1157 | else |
1162 | italicStr="FALSE"; | 1158 | italicStr="FALSE"; |
1163 | if(bold == true) | 1159 | if(bold == true) |
1164 | boldStr="TRUE"; | 1160 | boldStr="TRUE"; |
1165 | else | 1161 | else |
1166 | boldStr="FALSE"; | 1162 | boldStr="FALSE"; |
1167 | 1163 | ||
1168 | pointSizeStr.setNum( pointSize); | 1164 | pointSizeStr.setNum( pointSize); |
1169 | config.setGroup( "Font" ); | 1165 | config.setGroup( "Font" ); |
1170 | config.writeEntry("Family", fontStr ); | 1166 | config.writeEntry("Family", fontStr ); |
1171 | config.writeEntry("Size", pointSizeStr ); | 1167 | config.writeEntry("Size", pointSizeStr ); |
1172 | config.writeEntry("Weight", weightStr ); | 1168 | config.writeEntry("Weight", weightStr ); |
1173 | config.writeEntry("Italic", italicStr ); | 1169 | config.writeEntry("Italic", italicStr ); |
1174 | config.writeEntry("Bold", boldStr ); | 1170 | config.writeEntry("Bold", boldStr ); |
1175 | // config.write(); | 1171 | // config.write(); |
1176 | 1172 | ||
1177 | Lview->setFont(font); | 1173 | Lview->setFont(font); |
1178 | 1174 | ||
1179 | QRect lRect; | 1175 | QRect lRect; |
1180 | QRect rRect; | 1176 | QRect rRect; |
1181 | lRect = Lview->rect(); | 1177 | lRect = Lview->rect(); |
1182 | if(useSplitter) { | 1178 | if(useSplitter) { |
1183 | } | 1179 | } |
1184 | // if(loadCheck) { | 1180 | // if(loadCheck) { |
1185 | // ResizeEdits(); | 1181 | // ResizeEdits(); |
1186 | // } | 1182 | // } |
1187 | update(); | 1183 | update(); |
1188 | } | 1184 | } |
1189 | #endif | 1185 | #endif |
1190 | } | 1186 | } |
1191 | 1187 | ||
1192 | 1188 | ||
1193 | /* | 1189 | /* |
1194 | performs dictionary look ups on the web */ | 1190 | performs dictionary look ups on the web */ |
1195 | void Gutenbrowser::LookupBtn() { | 1191 | void Gutenbrowser::LookupBtn() { |
1196 | QString text; | 1192 | QString text; |
1197 | if( Lview->hasSelectedText()) { | 1193 | if( Lview->hasSelectedText()) { |
1198 | Lview->copy(); | 1194 | Lview->copy(); |
1199 | } | 1195 | } |
1200 | QClipboard *cb = QApplication::clipboard(); | 1196 | QClipboard *cb = QApplication::clipboard(); |
1201 | text = cb->text(); | 1197 | text = cb->text(); |
1202 | int eexit=QMessageBox::information(this, | 1198 | int eexit=QMessageBox::information(this, |
1203 | "Note","Do you want to lookup\n\""+text+"\"\non websters web dictionary?", | 1199 | "Note","Do you want to lookup\n\""+text+"\"\non websters web dictionary?", |
1204 | QMessageBox::Yes, QMessageBox::No); | 1200 | QMessageBox::Yes, QMessageBox::No); |
1205 | if (eexit== 3) { | 1201 | if (eexit== 3) { |
1206 | // this link for sale!! | 1202 | // this link for sale!! |
1207 | qApp->processEvents(); | 1203 | qApp->processEvents(); |
1208 | goGetit( "http://www.m-w.com/cgi-bin/dictionary?" + text, true); | 1204 | goGetit( "http://www.m-w.com/cgi-bin/dictionary?" + text, true); |
1209 | } | 1205 | } |
1210 | } | 1206 | } |
1211 | 1207 | ||
1212 | void Gutenbrowser::ClearEdit() { | 1208 | void Gutenbrowser::ClearEdit() { |
1213 | Lview->setText(""); | 1209 | Lview->setText(""); |
1214 | loadCheck = false; | 1210 | loadCheck = false; |
1215 | status = ( tr("Gutenbrowser")); | 1211 | status = ( tr("Gutenbrowser")); |
1216 | InfoBar->setText( ""); | 1212 | InfoBar->setText( ""); |
1217 | setCaption( tr("Gutenbrowser")); | 1213 | setCaption( tr("Gutenbrowser")); |
1218 | i_pageNum = 0; | 1214 | i_pageNum = 0; |
1219 | enableButtons(false); | 1215 | enableButtons(false); |
1220 | 1216 | ||
1221 | if(!showMainList) { | 1217 | if(!showMainList) { |
1222 | Lview->hide(); | 1218 | Lview->hide(); |
1223 | showMainList=TRUE; | 1219 | showMainList=TRUE; |
1224 | mainList->show(); | 1220 | mainList->show(); |
1225 | fillWithTitles(); | 1221 | fillWithTitles(); |
1226 | qApp->processEvents(); | 1222 | qApp->processEvents(); |
1227 | } | 1223 | } |
1228 | if(donateMenu->idAt(3) != -1) | 1224 | if(donateMenu->idAt(3) != -1) |
1229 | donateMenu->removeItemAt(3); | 1225 | donateMenu->removeItemAt(3); |
1230 | } | 1226 | } |
1231 | 1227 | ||
1232 | 1228 | ||
1233 | bool Gutenbrowser::getTitle( const char *file ) { | 1229 | bool Gutenbrowser::getTitle( const char *file ) { |
1234 | QString s_file; | 1230 | QString s_file; |
1235 | QString filer = file; | 1231 | QString filer = file; |
1236 | if( filer.contains(local_library, TRUE)) { | 1232 | if( filer.contains(local_library, TRUE)) { |
1237 | QFileInfo f(file); | 1233 | QFileInfo f(file); |
1238 | s_file = f.fileName(); | 1234 | s_file = f.fileName(); |
1239 | } else { | 1235 | } else { |
1240 | s_file = filer; | 1236 | s_file = filer; |
1241 | } | 1237 | } |
1242 | Config config("Gutenbrowser"); | 1238 | Config config("Gutenbrowser"); |
1243 | config.setGroup( "Files" ); | 1239 | config.setGroup( "Files" ); |
1244 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 1240 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
1245 | int i_numofFiles = s_numofFiles.toInt(); | 1241 | int i_numofFiles = s_numofFiles.toInt(); |
1246 | 1242 | ||
1247 | for (int i = 1; i <= i_numofFiles; i++) { | 1243 | for (int i = 1; i <= i_numofFiles; i++) { |
1248 | QString temp; | 1244 | QString temp; |
1249 | temp.setNum(i); | 1245 | temp.setNum(i); |
1250 | QString ramble = config.readEntry(temp, "" ); | 1246 | QString ramble = config.readEntry(temp, "" ); |
1251 | 1247 | ||
1252 | if( strcmp(ramble, s_file) == 0) { | 1248 | if( strcmp(ramble, s_file) == 0) { |
1253 | config.setGroup( "Titles" ); | 1249 | config.setGroup( "Titles" ); |
1254 | title = config.readEntry(ramble, ""); | 1250 | title = config.readEntry(ramble, ""); |
1255 | // odebug << "(getTitle)title is being set as "+title << oendl; | 1251 | // odebug << "(getTitle)title is being set as "+title << oendl; |
1256 | } | 1252 | } |
1257 | } | 1253 | } |
1258 | return true; | 1254 | return true; |
1259 | } | 1255 | } |
1260 | 1256 | ||
1261 | void Gutenbrowser::searchdone_slot() { | 1257 | void Gutenbrowser::searchdone_slot() { |
1262 | // if (!searchDlg) | 1258 | // if (!searchDlg) |
1263 | // return; | 1259 | // return; |
1264 | // searchDlg->hide(); | 1260 | // searchDlg->hide(); |
1265 | // Lview->setFocus(); | 1261 | // Lview->setFocus(); |
1266 | this->setFocus(); | 1262 | this->setFocus(); |
1267 | last_search = 0; | 1263 | last_search = 0; |
1268 | // ResizeEdits(); | 1264 | // ResizeEdits(); |
1269 | } | 1265 | } |
1270 | 1266 | ||
1271 | /* | 1267 | /* |
1272 | sets the status message */ | 1268 | sets the status message */ |
1273 | bool Gutenbrowser::setStatus() { | 1269 | bool Gutenbrowser::setStatus() { |
1274 | 1270 | ||
1275 | #ifndef Q_WS_QWS | 1271 | #ifndef Q_WS_QWS |
1276 | QString s_pages; | 1272 | QString s_pages; |
1277 | s_pages.setNum( pages); | 1273 | s_pages.setNum( pages); |
1278 | QString chNum; | 1274 | QString chNum; |
1279 | statusTop = status.left( status.find(" ", TRUE) ); | 1275 | statusTop = status.left( status.find(" ", TRUE) ); |
1280 | status.append(chNum.setNum( i_pageNum)); | 1276 | status.append(chNum.setNum( i_pageNum)); |
1281 | status += " / " + s_pages; | 1277 | status += " / " + s_pages; |
1282 | 1278 | ||
1283 | if(loadCheck) { | 1279 | if(loadCheck) { |
1284 | statusBar->message( status); | 1280 | statusBar->message( status); |
1285 | InfoBar->setText( title); | 1281 | InfoBar->setText( title); |
1286 | } else { | 1282 | } else { |
1287 | } | 1283 | } |
1288 | #else | 1284 | #else |
1289 | QString msg; | 1285 | QString msg; |
1290 | msg.sprintf(title+" %d", i_pageNum); | 1286 | msg.sprintf(title+" %d", i_pageNum); |
1291 | setCaption( msg); | 1287 | setCaption( msg); |
1292 | #endif | 1288 | #endif |
1293 | return true; | 1289 | return true; |
1294 | } | 1290 | } |
1295 | 1291 | ||
1296 | void Gutenbrowser::keyReleaseEvent( QKeyEvent *e) { | 1292 | void Gutenbrowser::keyReleaseEvent( QKeyEvent *e) { |
1297 | switch ( e->key() ) { | 1293 | switch ( e->key() ) { |
1298 | 1294 | ||
1299 | case Key_M: | 1295 | case Key_M: |
1300 | // Bookmark(); | 1296 | // Bookmark(); |
1301 | break; | 1297 | break; |
1302 | case Key_D: | 1298 | case Key_D: |
1303 | DownloadIndex(); | 1299 | DownloadIndex(); |
1304 | break; | 1300 | break; |
1305 | case Key_L: | 1301 | case Key_L: |
1306 | LibraryBtn(); | 1302 | LibraryBtn(); |
1307 | break; | 1303 | break; |
1308 | case Key_O: | 1304 | case Key_O: |
1309 | OpenBtn(); | 1305 | OpenBtn(); |
1310 | break; | 1306 | break; |
1311 | case Key_F: | 1307 | case Key_F: |
1312 | ForwardBtn(); | 1308 | ForwardBtn(); |
1313 | break; | 1309 | break; |
1314 | case Key_B: | 1310 | case Key_B: |
1315 | BackBtn(); | 1311 | BackBtn(); |
1316 | break; | 1312 | break; |
1317 | case Key_P: | 1313 | case Key_P: |
1318 | PrintBtn(); | 1314 | PrintBtn(); |
1319 | break; | 1315 | break; |
1320 | case Key_S: | 1316 | case Key_S: |
1321 | SearchBtn(); | 1317 | SearchBtn(); |
1322 | break; | 1318 | break; |
1323 | case Key_E: | 1319 | case Key_E: |
1324 | ByeBye(); | 1320 | ByeBye(); |
1325 | break; | 1321 | break; |
1326 | case Key_R: | 1322 | case Key_R: |
1327 | // setBookmark(); | 1323 | // setBookmark(); |
1328 | break; | 1324 | break; |
1329 | case Key_T: | 1325 | case Key_T: |
1330 | ChangeFont(); | 1326 | ChangeFont(); |
1331 | break; | 1327 | break; |
1332 | case Key_C: | 1328 | case Key_C: |
1333 | ClearEdit(); | 1329 | ClearEdit(); |
1334 | break; | 1330 | break; |
1335 | case Key_H: | 1331 | case Key_H: |
1336 | HelpBtn(); | 1332 | HelpBtn(); |
1337 | break; | 1333 | break; |
1338 | case Key_K: | 1334 | case Key_K: |
1339 | LookupBtn(); | 1335 | LookupBtn(); |
1340 | break; | 1336 | break; |
1341 | case Key_U:// hide menu | 1337 | case Key_U:// hide menu |
1342 | if(menubar->isHidden() ) | 1338 | if(menubar->isHidden() ) |
1343 | menubar->show(); | 1339 | menubar->show(); |
1344 | else | 1340 | else |
1345 | menubar->hide(); | 1341 | menubar->hide(); |
1346 | break; | 1342 | break; |
1347 | case Key_I: | 1343 | case Key_I: |
1348 | hideButtons(); | 1344 | hideButtons(); |
1349 | break; | 1345 | break; |
1350 | ////////////////////////////// Zaurus keys | 1346 | ////////////////////////////// Zaurus keys |
1351 | case Key_Home: | 1347 | case Key_Home: |
1352 | // BeginBtn(); | 1348 | // BeginBtn(); |
1353 | break; | 1349 | break; |
1354 | case Key_F9: //activity | 1350 | case Key_F9: //activity |
1355 | OpenBtn(); | 1351 | OpenBtn(); |
1356 | break; | 1352 | break; |
1357 | case Key_F10: //contacts | 1353 | case Key_F10: //contacts |
1358 | hideButtons(); | 1354 | hideButtons(); |
1359 | break; | 1355 | break; |
1360 | case Key_F11: //menu | 1356 | case Key_F11: //menu |
1361 | if(menubar->isHidden() ) | 1357 | if(menubar->isHidden() ) |
1362 | menubar->show(); | 1358 | menubar->show(); |
1363 | else | 1359 | else |
1364 | menubar->hide(); | 1360 | menubar->hide(); |
1365 | break; | 1361 | break; |
1366 | case Key_F12: //home | 1362 | case Key_F12: //home |
1367 | BeginBtn(); | 1363 | BeginBtn(); |
1368 | break; | 1364 | break; |
1369 | case Key_F13: //mail | 1365 | case Key_F13: //mail |
1370 | LibraryBtn(); | 1366 | LibraryBtn(); |
1371 | break; | 1367 | break; |
1372 | case Key_Space: | 1368 | case Key_Space: |
1373 | if(loadCheck) | 1369 | if(loadCheck) |
1374 | ForwardBtn(); | 1370 | ForwardBtn(); |
1375 | // else | 1371 | // else |
1376 | // Bookmark(); | 1372 | // Bookmark(); |
1377 | break; | 1373 | break; |
1378 | case Key_Down: | 1374 | case Key_Down: |
1379 | if(loadCheck) { | 1375 | if(loadCheck) { |
1380 | // if( !e->isAutoRepeat() ) | 1376 | // if( !e->isAutoRepeat() ) |
1381 | // AdjustStatus(); | 1377 | // AdjustStatus(); |
1382 | // } else { | 1378 | // } else { |
1383 | // LibraryBtn(); | 1379 | // LibraryBtn(); |
1384 | // ForwardBtn(); | 1380 | // ForwardBtn(); |
1385 | } | 1381 | } |
1386 | 1382 | ||
1387 | // ForwardButton->setFocus(); | 1383 | // ForwardButton->setFocus(); |
1388 | // Lview->setFocus(); | 1384 | // Lview->setFocus(); |
1389 | // if(s_Wrap=="FALSE") | 1385 | // if(s_Wrap=="FALSE") |
1390 | // Lview->MultiLine_Ex::ScrollDown( 1); | 1386 | // Lview->MultiLine_Ex::ScrollDown( 1); |
1391 | // LibraryBtn(); | 1387 | // LibraryBtn(); |
1392 | break; | 1388 | break; |
1393 | case Key_Up: | 1389 | case Key_Up: |
1394 | if(loadCheck) { | 1390 | if(loadCheck) { |
1395 | // if( !e->isAutoRepeat() ) | 1391 | // if( !e->isAutoRepeat() ) |
1396 | // AdjustStatus(); | 1392 | // AdjustStatus(); |
1397 | // } else { | 1393 | // } else { |
1398 | // OpenBtn(); | 1394 | // OpenBtn(); |
1399 | // BackBtn(); | 1395 | // BackBtn(); |
1400 | } | 1396 | } |
1401 | // BackButton->setFocus(); | 1397 | // BackButton->setFocus(); |
1402 | // Lview->setFocus(); | 1398 | // Lview->setFocus(); |
1403 | // if(s_Wrap=="FALSE") | 1399 | // if(s_Wrap=="FALSE") |
1404 | // Lview->MultiLine_Ex::ScrollUp( 1); | 1400 | // Lview->MultiLine_Ex::ScrollUp( 1); |
1405 | 1401 | ||
1406 | // LibraryBtn(); | 1402 | // LibraryBtn(); |
1407 | break; | 1403 | break; |
1408 | case Key_Right: | 1404 | case Key_Right: |
1409 | ForwardButton->setFocus(); | 1405 | ForwardButton->setFocus(); |
1410 | ForwardBtn(); | 1406 | ForwardBtn(); |
1411 | // LibraryBtn(); | 1407 | // LibraryBtn(); |
1412 | break; | 1408 | break; |
1413 | case Key_Left: | 1409 | case Key_Left: |
1414 | BackBtn(); | 1410 | BackBtn(); |
1415 | BackButton->setFocus(); | 1411 | BackButton->setFocus(); |
1416 | // OpenBtn(); | 1412 | // OpenBtn(); |
1417 | break; | 1413 | break; |
1418 | case Key_Escape: | 1414 | case Key_Escape: |
1419 | ByeBye(); | 1415 | ByeBye(); |
1420 | break; | 1416 | break; |
1421 | case Key_PageUp: | 1417 | case Key_PageUp: |
1422 | BackBtn(); | 1418 | BackBtn(); |
1423 | break; | 1419 | break; |
1424 | case Key_PageDown: | 1420 | case Key_PageDown: |
1425 | ForwardBtn(); | 1421 | ForwardBtn(); |
1426 | break; | 1422 | break; |
1427 | 1423 | ||
1428 | ////////////////////////////// Zaurus keys | 1424 | ////////////////////////////// Zaurus keys |
1429 | }; | 1425 | }; |
1430 | } | 1426 | } |
1431 | 1427 | ||
1432 | void Gutenbrowser::keyPressEvent( QKeyEvent *e) { | 1428 | void Gutenbrowser::keyPressEvent( QKeyEvent *e) { |
1433 | switch ( e->key() ) { | 1429 | switch ( e->key() ) { |
1434 | // case Key_Next: | 1430 | // case Key_Next: |
1435 | // ForwardBtn(); | 1431 | // ForwardBtn(); |
1436 | // break; | 1432 | // break; |
1437 | // case Key_Prior: | 1433 | // case Key_Prior: |
1438 | // BackBtn(); | 1434 | // BackBtn(); |
1439 | // break; | 1435 | // break; |
1440 | // case Key_Space: | 1436 | // case Key_Space: |
1441 | // ForwardBtn(); | 1437 | // ForwardBtn(); |
1442 | // break; | 1438 | // break; |
1443 | // case Key_Down: | 1439 | // case Key_Down: |
1444 | // Lview->MultiLine_Ex::ScrollUp( 1); | 1440 | // Lview->MultiLine_Ex::ScrollUp( 1); |
1445 | // if(useSplitter) Rview->MultiLine_Ex::ScrollUp( 1); | 1441 | // if(useSplitter) Rview->MultiLine_Ex::ScrollUp( 1); |
1446 | // break; | 1442 | // break; |
1447 | // case Key_Up: | 1443 | // case Key_Up: |
1448 | // if( Lview->Top() != 0) { | 1444 | // if( Lview->Top() != 0) { |
1449 | // Lview->MultiLine_Ex::ScrollDown( 1); | 1445 | // Lview->MultiLine_Ex::ScrollDown( 1); |
1450 | // if(useSplitter) Rview->MultiLine_Ex::ScrollDown( 1); | 1446 | // if(useSplitter) Rview->MultiLine_Ex::ScrollDown( 1); |
1451 | // } | 1447 | // } |
1452 | // break; | 1448 | // break; |
1453 | } | 1449 | } |
1454 | } | 1450 | } |
1455 | 1451 | ||
1456 | void Gutenbrowser::resizeEvent( QResizeEvent *ev) { | 1452 | void Gutenbrowser::resizeEvent( QResizeEvent *ev) { |
1457 | // odebug << "resize: " << ev->size().width() << "," << ev->size().height() << "\n" << oendl; | 1453 | // odebug << "resize: " << ev->size().width() << "," << ev->size().height() << "\n" << oendl; |
1458 | 1454 | ||
1459 | if( !LibraryDlg->isHidden()) | 1455 | if( !LibraryDlg->isHidden()) |
1460 | LibraryDlg->resize(ev->size().width(),ev->size().height() ); | 1456 | LibraryDlg->resize(ev->size().width(),ev->size().height() ); |
1461 | 1457 | ||
1462 | // if( loadCheck == true) { | 1458 | // if( loadCheck == true) { |
1463 | // ResizeEdits(); | 1459 | // ResizeEdits(); |
1464 | // AdjustStatus(); | 1460 | // AdjustStatus(); |
1465 | // } | 1461 | // } |
1466 | } | 1462 | } |
1467 | 1463 | ||
1468 | 1464 | ||
1469 | void Gutenbrowser::doOptions() { | 1465 | void Gutenbrowser::doOptions() { |
1470 | optionsDialog* optDlg; | 1466 | optionsDialog* optDlg; |
1471 | optDlg = new optionsDialog( this,"Options_Dlg", true); | 1467 | optDlg = new optionsDialog( this,"Options_Dlg", true); |
1472 | QString Ddir; | 1468 | QString Ddir; |
1473 | Config config("Gutenbrowser"); | 1469 | Config config("Gutenbrowser"); |
1474 | config.setGroup( "General" ); | 1470 | config.setGroup( "General" ); |
1475 | QFont myFont; | 1471 | QFont myFont; |
1476 | optDlg->showMaximized(); | 1472 | optDlg->showMaximized(); |
1477 | 1473 | ||
1478 | if( optDlg->exec() !=0) { | 1474 | if( optDlg->exec() !=0) { |
1479 | qApp->processEvents(); | 1475 | qApp->processEvents(); |
1480 | brow=optDlg->browserName; | 1476 | brow=optDlg->browserName; |
1481 | toggleButtonIcons( optDlg->useIcon); | 1477 | toggleButtonIcons( optDlg->useIcon); |
1482 | ftp_host= optDlg->ftp_host; | 1478 | ftp_host= optDlg->ftp_host; |
1483 | ftp_base_dir= optDlg->ftp_base_dir; | 1479 | ftp_base_dir= optDlg->ftp_base_dir; |
1484 | brow=optDlg->browserName; | 1480 | brow=optDlg->browserName; |
1485 | Ddir=optDlg->downloadDirEdit->text(); | 1481 | Ddir=optDlg->downloadDirEdit->text(); |
1486 | 1482 | ||
1487 | odebug << "writing library config" << oendl; | 1483 | odebug << "writing library config" << oendl; |
1488 | Config config("Gutenbrowser"); | 1484 | Config config("Gutenbrowser"); |
1489 | config.setGroup("General"); | 1485 | config.setGroup("General"); |
1490 | 1486 | ||
1491 | QString dirname= optDlg->downloadDirEdit->text(); | 1487 | QString dirname= optDlg->downloadDirEdit->text(); |
1492 | if(dirname.right(1)!="/") | 1488 | if(dirname.right(1)!="/") |
1493 | dirname+="/"; | 1489 | dirname+="/"; |
1494 | config.writeEntry( "DownloadDirectory",dirname); | 1490 | config.writeEntry( "DownloadDirectory",dirname); |
1495 | QDir newDir( optDlg->downloadDirEdit->text()); | 1491 | QDir newDir( optDlg->downloadDirEdit->text()); |
1496 | 1492 | ||
1497 | if( !newDir.exists() ) { | 1493 | if( !newDir.exists() ) { |
1498 | int exit=QMessageBox::information(this, "Note", "Ok, to make a new directory\n"+Ddir+" ?", | 1494 | int exit=QMessageBox::information(this, "Note", "Ok, to make a new directory\n"+Ddir+" ?", |
1499 | QMessageBox::Ok, QMessageBox::Cancel); | 1495 | QMessageBox::Ok, QMessageBox::Cancel); |
1500 | if (exit==1) { | 1496 | if (exit==1) { |
1501 | QString cmd="mkdir -p "; | 1497 | QString cmd="mkdir -p "; |
1502 | cmd+=Ddir.latin1(); | 1498 | cmd+=Ddir.latin1(); |
1503 | system(cmd); | 1499 | system(cmd); |
1504 | odebug << "Making new dir "+cmd << oendl; | 1500 | odebug << "Making new dir "+cmd << oendl; |
1505 | if(Ddir.right(1)!="/") { | 1501 | if(Ddir.right(1)!="/") { |
1506 | Ddir+="/"; | 1502 | Ddir+="/"; |
1507 | } | 1503 | } |
1508 | config.writeEntry("DownloadDirectory",Ddir); | 1504 | config.writeEntry("DownloadDirectory",Ddir); |
1509 | } | 1505 | } |
1510 | } | 1506 | } |
1511 | 1507 | ||
1512 | // if(optDlg->styleChanged) | 1508 | // if(optDlg->styleChanged) |
1513 | // setStyle( optDlg->styleInt); | 1509 | // setStyle( optDlg->styleInt); |
1514 | if(optDlg->b_qExit==TRUE) | 1510 | if(optDlg->b_qExit==TRUE) |
1515 | b_queryExit=TRUE; | 1511 | b_queryExit=TRUE; |
1516 | else | 1512 | else |
1517 | b_queryExit=FALSE; | 1513 | b_queryExit=FALSE; |
1518 | 1514 | ||
1519 | if(optDlg->fontDlg-> changedFonts) { | 1515 | if(optDlg->fontDlg-> changedFonts) { |
1520 | odebug << "Setting font" << oendl; | 1516 | odebug << "Setting font" << oendl; |
1521 | myFont=optDlg->fontDlg->selectedFont; | 1517 | myFont=optDlg->fontDlg->selectedFont; |
1522 | Lview->setFont( myFont); | 1518 | Lview->setFont( myFont); |
1523 | } | 1519 | } |
1524 | 1520 | ||
1525 | if(optDlg->useWordWrap_CheckBox->isChecked() ) { | 1521 | if(optDlg->useWordWrap_CheckBox->isChecked() ) { |
1526 | odebug << "WORD WRAP is set" << oendl; | 1522 | odebug << "WORD WRAP is set" << oendl; |
1527 | Lview->setWordWrap(QMultiLineEdit::WidgetWidth); | 1523 | Lview->setWordWrap(QMultiLineEdit::WidgetWidth); |
1528 | useWrap=true; | 1524 | useWrap=true; |
1529 | } else { | 1525 | } else { |
1530 | odebug << "Word wrap is NOT set" << oendl; | 1526 | odebug << "Word wrap is NOT set" << oendl; |
1531 | Lview->setWordWrap(QMultiLineEdit::NoWrap); | 1527 | Lview->setWordWrap(QMultiLineEdit::NoWrap); |
1532 | useWrap=false; | 1528 | useWrap=false; |
1533 | } | 1529 | } |
1534 | } | 1530 | } |
1535 | if(showMainList) { | 1531 | if(showMainList) { |
1536 | if(!Lview->isHidden()) | 1532 | if(!Lview->isHidden()) |
1537 | Lview->hide(); | 1533 | Lview->hide(); |
1538 | qApp->processEvents(); | 1534 | qApp->processEvents(); |
1539 | if(mainList->isHidden()) | 1535 | if(mainList->isHidden()) |
1540 | mainList->show(); | 1536 | mainList->show(); |
1541 | fillWithTitles(); | 1537 | fillWithTitles(); |
1542 | } else { | 1538 | } else { |
1543 | Lview->show(); | 1539 | Lview->show(); |
1544 | showMainList=FALSE; | 1540 | showMainList=FALSE; |
1545 | mainList->hide(); | 1541 | mainList->hide(); |
1546 | } | 1542 | } |
1547 | qApp->processEvents(); | 1543 | qApp->processEvents(); |
1548 | update(); | 1544 | update(); |
1549 | } | 1545 | } |
1550 | 1546 | ||
1551 | bool Gutenbrowser::setTitle() { | 1547 | bool Gutenbrowser::setTitle() { |
1552 | if( file_name.contains( local_library)) { | 1548 | if( file_name.contains( local_library)) { |
1553 | QFileInfo f( file_name); | 1549 | QFileInfo f( file_name); |
1554 | QString s_file = f.fileName(); | 1550 | QString s_file = f.fileName(); |
1555 | file_name = s_file; | 1551 | file_name = s_file; |
1556 | } | 1552 | } |
1557 | 1553 | ||
1558 | int test = 0; | 1554 | int test = 0; |
1559 | Config config("Gutenbrowser"); | 1555 | Config config("Gutenbrowser"); |
1560 | config.setGroup( "Files" ); | 1556 | config.setGroup( "Files" ); |
1561 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 1557 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
1562 | int i_numofFiles = s_numofFiles.toInt(); | 1558 | int i_numofFiles = s_numofFiles.toInt(); |
1563 | 1559 | ||
1564 | for (int i = 1; i <= i_numofFiles; i++) { | 1560 | for (int i = 1; i <= i_numofFiles; i++) { |
1565 | QString temp; | 1561 | QString temp; |
1566 | temp.setNum(i); | 1562 | temp.setNum(i); |
1567 | QString ramble = config.readEntry(temp, "" ); | 1563 | QString ramble = config.readEntry(temp, "" ); |
1568 | 1564 | ||
1569 | if( strcmp(ramble, file_name) == 0) { | 1565 | if( strcmp(ramble, file_name) == 0) { |
1570 | test = 1; | 1566 | test = 1; |
1571 | } | 1567 | } |
1572 | } | 1568 | } |
1573 | if (test == 0) { | 1569 | if (test == 0) { |
1574 | config.writeEntry("NumberOfFiles",i_numofFiles +1 ); | 1570 | config.writeEntry("NumberOfFiles",i_numofFiles +1 ); |
1575 | QString interger; | 1571 | QString interger; |
1576 | interger.setNum( i_numofFiles +1); | 1572 | interger.setNum( i_numofFiles +1); |
1577 | config.writeEntry(interger, file_name); | 1573 | config.writeEntry(interger, file_name); |
1578 | 1574 | ||
1579 | config.setGroup( "Titles" ); | 1575 | config.setGroup( "Titles" ); |
1580 | config.writeEntry(file_name,listItemTitle); | 1576 | config.writeEntry(file_name,listItemTitle); |
1581 | } | 1577 | } |
1582 | test = 0; | 1578 | test = 0; |
1583 | // config.write(); | 1579 | // config.write(); |
1584 | return true; | 1580 | return true; |
1585 | } | 1581 | } |
1586 | /*Calls new fangled network dialog */ | 1582 | /*Calls new fangled network dialog */ |
1587 | void Gutenbrowser::OnNetworkDialog( const QString &/*networkUrl*/, const QString &/*output*/) | 1583 | void Gutenbrowser::OnNetworkDialog( const QString &/*networkUrl*/, const QString &/*output*/) |
1588 | { | 1584 | { |
1589 | // odebug << networkUrl << oendl; | 1585 | // odebug << networkUrl << oendl; |
1590 | // odebug << output << oendl; | 1586 | // odebug << output << oendl; |
1591 | // #ifndef Q_WS_QWS | 1587 | // #ifndef Q_WS_QWS |
1592 | // NetworkDialog *NetworkDlg; | 1588 | // NetworkDialog *NetworkDlg; |
1593 | // if( networkUrl.length() < 4 ) networkUrl= "http://sailor.gutenberg.org/mirror.sites.html"; | 1589 | // if( networkUrl.length() < 4 ) networkUrl= "http://sailor.gutenberg.org/mirror.sites.html"; |
1594 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, output); | 1590 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkUrl, output); |
1595 | // if( NetworkDlg->exec() != 0 ) { | 1591 | // if( NetworkDlg->exec() != 0 ) { |
1596 | // } | 1592 | // } |
1597 | // if(NetworkDlg) | 1593 | // if(NetworkDlg) |
1598 | // delete NetworkDlg; | 1594 | // delete NetworkDlg; |
1599 | // #endif | 1595 | // #endif |
1600 | } | 1596 | } |
1601 | 1597 | ||
1602 | void Gutenbrowser::donateGutenberg() | 1598 | void Gutenbrowser::donateGutenberg() |
1603 | { | 1599 | { |
1604 | int exit=QMessageBox::information(this, "Info", "http://www.gutenberg.org\ndonate@gutenberg.net", | 1600 | int exit=QMessageBox::information(this, "Info", "http://www.gutenberg.org\ndonate@gutenberg.net", |
1605 | QMessageBox::Ok, QMessageBox::Cancel); | 1601 | QMessageBox::Ok, QMessageBox::Cancel); |
1606 | 1602 | ||
1607 | if (exit==1) { | 1603 | if (exit==1) { |
1608 | } else { | 1604 | } else { |
1609 | }; | 1605 | }; |
1610 | } | 1606 | } |
1611 | 1607 | ||
1612 | void Gutenbrowser::donateByteMonkie() | 1608 | void Gutenbrowser::donateByteMonkie() |
1613 | { | 1609 | { |
1614 | } | 1610 | } |
1615 | 1611 | ||
1616 | void Gutenbrowser::writeConfig() | 1612 | void Gutenbrowser::writeConfig() |
1617 | { | 1613 | { |
1618 | // config.read(); | 1614 | // config.read(); |
1619 | // Config config("Gutenbrowser"); | 1615 | // Config config("Gutenbrowser"); |
1620 | // #ifndef Q_WS_QWS | 1616 | // #ifndef Q_WS_QWS |
1621 | // config.setGroup( "Geometry" ); | 1617 | // config.setGroup( "Geometry" ); |
1622 | // QString s; | 1618 | // QString s; |
1623 | // QString globalPosition; | 1619 | // QString globalPosition; |
1624 | // QPoint point; | 1620 | // QPoint point; |
1625 | // point=mapToGlobal(QPoint(0,0) ); | 1621 | // point=mapToGlobal(QPoint(0,0) ); |
1626 | // int posiX, posiY; | 1622 | // int posiX, posiY; |
1627 | // posiX=point.x(); | 1623 | // posiX=point.x(); |
1628 | // posiY=point.y(); | 1624 | // posiY=point.y(); |
1629 | // globalPosition.sprintf("%i,%i", posiX, posiY); | 1625 | // globalPosition.sprintf("%i,%i", posiX, posiY); |
1630 | 1626 | ||
1631 | // QRect frameRect; | 1627 | // QRect frameRect; |
1632 | // frameRect = geometry(); | 1628 | // frameRect = geometry(); |
1633 | // s.sprintf("%i,%i", frameRect.width(), frameRect.height()); | 1629 | // s.sprintf("%i,%i", frameRect.width(), frameRect.height()); |
1634 | // config.writeEntry("Frame", s); | 1630 | // config.writeEntry("Frame", s); |
1635 | // config.writeEntry("Position", globalPosition); | 1631 | // config.writeEntry("Position", globalPosition); |
1636 | 1632 | ||
1637 | // if( useIcons==TRUE) | 1633 | // if( useIcons==TRUE) |
1638 | // config.writeEntry("Icons", "TRUE"); | 1634 | // config.writeEntry("Icons", "TRUE"); |
1639 | // else | 1635 | // else |
1640 | // config.writeEntry("Icons", "FALSE"); | 1636 | // config.writeEntry("Icons", "FALSE"); |
1641 | // #endif | 1637 | // #endif |
1642 | 1638 | ||
1643 | // #ifndef Q_WS_QWS | 1639 | // #ifndef Q_WS_QWS |
1644 | // QString temp; | 1640 | // QString temp; |
1645 | // temp.setNum(styleI, 10); | 1641 | // temp.setNum(styleI, 10); |
1646 | // config.setGroup( "StyleIze" ); | 1642 | // config.setGroup( "StyleIze" ); |
1647 | // config.writeEntry( "Style", temp); | 1643 | // config.writeEntry( "Style", temp); |
1648 | // #endif | 1644 | // #endif |
1649 | 1645 | ||
1650 | // config.setGroup("General"); | 1646 | // config.setGroup("General"); |
1651 | } | 1647 | } |
1652 | 1648 | ||
1653 | void Gutenbrowser::annotations() | 1649 | void Gutenbrowser::annotations() |
1654 | { | 1650 | { |
1655 | // #ifndef Q_WS_QWS | 1651 | // #ifndef Q_WS_QWS |
1656 | // QMessageBox::message("Note","hi annotate"); | 1652 | // QMessageBox::message("Note","hi annotate"); |
1657 | // lastBmkButton->setDown(FALSE); | 1653 | // lastBmkButton->setDown(FALSE); |
1658 | // #endif | 1654 | // #endif |
1659 | } | 1655 | } |
1660 | 1656 | ||
1661 | void Gutenbrowser::hideButtons() | 1657 | void Gutenbrowser::hideButtons() |
1662 | { | 1658 | { |
1663 | 1659 | ||
1664 | if( !buttonsHidden) { | 1660 | if( !buttonsHidden) { |
1665 | buttonsHidden=TRUE; | 1661 | buttonsHidden=TRUE; |
1666 | LibraryButton->hide(); | 1662 | LibraryButton->hide(); |
1667 | SearchButton->hide(); | 1663 | SearchButton->hide(); |
1668 | InfoBar->hide(); | 1664 | InfoBar->hide(); |
1669 | OpenButton->hide(); | 1665 | OpenButton->hide(); |
1670 | BackButton->hide(); | 1666 | BackButton->hide(); |
1671 | ForwardButton->hide(); | 1667 | ForwardButton->hide(); |
1672 | setBookmarkButton->hide(); | 1668 | setBookmarkButton->hide(); |
1673 | lastBmkButton->hide(); | 1669 | lastBmkButton->hide(); |
1674 | dictionaryButton->hide(); | 1670 | dictionaryButton->hide(); |
1675 | if(useSplitter) { | 1671 | if(useSplitter) { |
1676 | ClearButton->hide(); | 1672 | ClearButton->hide(); |
1677 | PrintButton->hide(); | 1673 | PrintButton->hide(); |
1678 | beginButton->hide(); | 1674 | beginButton->hide(); |
1679 | HelpButton->hide(); | 1675 | HelpButton->hide(); |
1680 | FontButton->hide(); | 1676 | FontButton->hide(); |
1681 | ExitButton->hide(); | 1677 | ExitButton->hide(); |
1682 | OptionsButton->hide(); | 1678 | OptionsButton->hide(); |
1683 | DownloadButton->hide(); | 1679 | DownloadButton->hide(); |
1684 | } | 1680 | } |
1685 | } else { | 1681 | } else { |
1686 | buttonsHidden=FALSE; | 1682 | buttonsHidden=FALSE; |
1687 | 1683 | ||
1688 | LibraryButton->show(); | 1684 | LibraryButton->show(); |
1689 | SearchButton->show(); | 1685 | SearchButton->show(); |
1690 | InfoBar->show(); | 1686 | InfoBar->show(); |
1691 | OpenButton->show(); | 1687 | OpenButton->show(); |
1692 | BackButton->show(); | 1688 | BackButton->show(); |
1693 | ForwardButton->show(); | 1689 | ForwardButton->show(); |
1694 | setBookmarkButton->show(); | 1690 | setBookmarkButton->show(); |
1695 | lastBmkButton->show(); | 1691 | lastBmkButton->show(); |
1696 | dictionaryButton->show(); | 1692 | dictionaryButton->show(); |
1697 | if(useSplitter) { | 1693 | if(useSplitter) { |
1698 | ClearButton->show(); | 1694 | ClearButton->show(); |
1699 | PrintButton->show(); | 1695 | PrintButton->show(); |
1700 | beginButton->show(); | 1696 | beginButton->show(); |
1701 | HelpButton->show(); | 1697 | HelpButton->show(); |
1702 | FontButton->show(); | 1698 | FontButton->show(); |
1703 | ExitButton->show(); | 1699 | ExitButton->show(); |
1704 | OptionsButton->show(); | 1700 | OptionsButton->show(); |
1705 | DownloadButton->show(); | 1701 | DownloadButton->show(); |
1706 | } | 1702 | } |
1707 | } | 1703 | } |
1708 | } | 1704 | } |
1709 | 1705 | ||
1710 | void Gutenbrowser::focusInEvent( QFocusEvent* ) | 1706 | void Gutenbrowser::focusInEvent( QFocusEvent* ) |
1711 | { | 1707 | { |
1712 | } | 1708 | } |
1713 | void Gutenbrowser::focusOutEvent( QFocusEvent* ) | 1709 | void Gutenbrowser::focusOutEvent( QFocusEvent* ) |
1714 | { | 1710 | { |
1715 | } | 1711 | } |
1716 | 1712 | ||
1717 | void Gutenbrowser::cleanUp( ) | 1713 | void Gutenbrowser::cleanUp( ) |
1718 | { | 1714 | { |
1719 | writeConfig(); | 1715 | writeConfig(); |
1720 | QPEApplication::grabKeyboard(); | 1716 | QPEApplication::grabKeyboard(); |
1721 | 1717 | ||
1722 | QPEApplication::ungrabKeyboard(); | 1718 | QPEApplication::ungrabKeyboard(); |
1723 | // odebug << "Cleanup" << oendl; | 1719 | // odebug << "Cleanup" << oendl; |
1724 | if(f.isOpen()) f.close(); | 1720 | if(f.isOpen()) f.close(); |
1725 | } | 1721 | } |
1726 | 1722 | ||
1727 | void Gutenbrowser::fixKeys() | 1723 | void Gutenbrowser::fixKeys() |
1728 | { | 1724 | { |
1729 | odebug << "Attempting to fix keys" << oendl; | 1725 | odebug << "Attempting to fix keys" << oendl; |
1730 | 1726 | ||
1731 | } | 1727 | } |
1732 | 1728 | ||
1733 | void Gutenbrowser::enableButtons(bool b) | 1729 | void Gutenbrowser::enableButtons(bool b) |
1734 | { | 1730 | { |
1735 | BackButton->setEnabled(b); | 1731 | BackButton->setEnabled(b); |
1736 | ForwardButton->setEnabled(b); | 1732 | ForwardButton->setEnabled(b); |
1737 | SearchButton->setEnabled(b); | 1733 | SearchButton->setEnabled(b); |
1738 | setBookmarkButton->setEnabled(b); | 1734 | setBookmarkButton->setEnabled(b); |
1739 | dictionaryButton->setEnabled(b); | 1735 | dictionaryButton->setEnabled(b); |
1740 | InfoBar->setEnabled(b); | 1736 | InfoBar->setEnabled(b); |
1741 | 1737 | ||
1742 | editMenu->setItemEnabled( -5, b); | 1738 | editMenu->setItemEnabled( -5, b); |
1743 | editMenu->setItemEnabled( -6, b); | 1739 | editMenu->setItemEnabled( -6, b); |
1744 | editMenu->setItemEnabled( -7, b); | 1740 | editMenu->setItemEnabled( -7, b); |
1745 | editMenu->setItemEnabled( -8, b); | 1741 | editMenu->setItemEnabled( -8, b); |
1746 | 1742 | ||
1747 | } | 1743 | } |
1748 | 1744 | ||
1749 | void Gutenbrowser::fillWithTitles() { | 1745 | void Gutenbrowser::fillWithTitles() { |
1750 | Config config("Gutenbrowser"); | 1746 | Config config("Gutenbrowser"); |
1751 | config.setGroup( "Files" ); | 1747 | config.setGroup( "Files" ); |
1752 | int i_numofFiles = config.readNumEntry("NumberOfFiles", 0); | 1748 | int i_numofFiles = config.readNumEntry("NumberOfFiles", 0); |
1753 | mainList->clear(); | 1749 | mainList->clear(); |
1754 | QString temp; | 1750 | QString temp; |
1755 | for (int i = 1; i <= i_numofFiles; i++) { | 1751 | for (int i = 1; i <= i_numofFiles; i++) { |
1756 | temp.setNum(i); | 1752 | temp.setNum(i); |
1757 | config.setGroup( "Files" ); | 1753 | config.setGroup( "Files" ); |
1758 | QString ramble = config.readEntry(temp, "" ); | 1754 | QString ramble = config.readEntry(temp, "" ); |
1759 | config.setGroup( "Titles" ); | 1755 | config.setGroup( "Titles" ); |
1760 | temp = config.readEntry(ramble, ""); | 1756 | temp = config.readEntry(ramble, ""); |
1761 | if( !temp.isEmpty()) { | 1757 | if( !temp.isEmpty()) { |
1762 | mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), temp, -1); | 1758 | mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), temp, -1); |
1763 | } | 1759 | } |
1764 | } | 1760 | } |
1765 | } | 1761 | } |
1766 | 1762 | ||
1767 | void Gutenbrowser::listClickedSlot( QListBoxItem * index) { | 1763 | void Gutenbrowser::listClickedSlot( QListBoxItem * index) { |
1768 | // if( !working) { | 1764 | // if( !working) { |
1769 | // working=true; | 1765 | // working=true; |
1770 | if(index) { | 1766 | if(index) { |
1771 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1767 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1772 | title = index->text(); | 1768 | title = index->text(); |
1773 | showMainList=FALSE; | 1769 | showMainList=FALSE; |
1774 | mainList->hide(); | 1770 | mainList->hide(); |
1775 | Lview->show(); | 1771 | Lview->show(); |
1776 | qApp->processEvents(); | 1772 | qApp->processEvents(); |
1777 | QString temp; | 1773 | QString temp; |
1778 | temp.setNum( mainList->currentItem() + 1); | 1774 | temp.setNum( mainList->currentItem() + 1); |
1779 | // openFileTitle = title; | 1775 | // openFileTitle = title; |
1780 | Config config("Gutenbrowser"); | 1776 | Config config("Gutenbrowser"); |
1781 | config.setGroup( "Files" ); | 1777 | config.setGroup( "Files" ); |
1782 | QString file = config.readEntry(temp, ""); | 1778 | QString file = config.readEntry(temp, ""); |
1783 | odebug << "About to load" << oendl; | 1779 | odebug << "About to load" << oendl; |
1784 | if( Lview->isVisible()) | 1780 | if( Lview->isVisible()) |
1785 | load(file); | 1781 | load(file); |
1786 | 1782 | ||
1787 | config.setGroup( title); | 1783 | config.setGroup( title); |
1788 | file_name = config.readEntry("File Name", ""); | 1784 | file_name = config.readEntry("File Name", ""); |
1789 | i_pageNum = config.readNumEntry("Page Number", 1); | 1785 | i_pageNum = config.readNumEntry("Page Number", 1); |
1790 | int Bmrkrow = config.readNumEntry("LineNumber", -1); | 1786 | int Bmrkrow = config.readNumEntry("LineNumber", -1); |
1791 | if(Bmrkrow > -1) { | 1787 | if(Bmrkrow > -1) { |
1792 | if( Bmrkrow > Lview->topRow() ) { | 1788 | if( Bmrkrow > Lview->topRow() ) { |
1793 | Lview->setCursorPosition( Bmrkrow /* - Lview->topRow() */,0, FALSE ); | 1789 | // Lview->setCursorPosition( Bmrkrow /* - Lview->topRow() */,0, FALSE ); |
1794 | Lview->ScrollUp( Bmrkrow - Lview->topRow() ); | 1790 | Lview->ScrollUp( Bmrkrow - Lview->topRow() ); |
1795 | // AdjustStatus(); | 1791 | // AdjustStatus(); |
1796 | } | 1792 | } |
1797 | else if( Bmrkrow < Lview->topRow() ) { | 1793 | else if( Bmrkrow < Lview->topRow() ) { |
1798 | Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE ); | 1794 | // Lview->setCursorPosition( Lview->topRow() - Bmrkrow ,0, FALSE ); |
1799 | Lview->ScrollDown( Lview->topRow() - Bmrkrow ); | 1795 | Lview->ScrollDown( Lview->topRow() - Bmrkrow ); |
1800 | // AdjustStatus(); | 1796 | // AdjustStatus(); |
1801 | } | 1797 | } |
1802 | } | 1798 | } |
1803 | } | 1799 | } |
1804 | } | 1800 | } |
1805 | 1801 | ||
1806 | void Gutenbrowser::infoGutenbrowser() { | 1802 | void Gutenbrowser::infoGutenbrowser() { |
1807 | QMessageBox::message("Info","Gutenbrowser was developed by\n" | 1803 | QMessageBox::message("Info","Gutenbrowser was developed by\n" |
1808 | "Lorn Potter\n" | 1804 | "Lorn Potter\n" |
1809 | "ljp<ljp@llornkcor.com>\n"); | 1805 | "ljp<ljp@llornkcor.com>\n"); |
1810 | } | 1806 | } |
1811 | 1807 | ||
1812 | void Gutenbrowser::setDocument(const QString & frozenBoogers) { | 1808 | void Gutenbrowser::setDocument(const QString & frozenBoogers) { |
1813 | this->hide(); | 1809 | this->hide(); |
1814 | if(showMainList) { | 1810 | if(showMainList) { |
1815 | showMainList=FALSE; | 1811 | showMainList=FALSE; |
1816 | if(!mainList->isHidden()) | 1812 | if(!mainList->isHidden()) |
1817 | mainList->hide(); | 1813 | mainList->hide(); |
1818 | if(Lview->isHidden()) | 1814 | if(Lview->isHidden()) |
1819 | Lview->show(); | 1815 | Lview->show(); |
1820 | qApp->processEvents(); | 1816 | qApp->processEvents(); |
1821 | } | 1817 | } |
1822 | DocLnk lnk; | 1818 | DocLnk lnk; |
1823 | lnk = DocLnk(frozenBoogers); | 1819 | lnk = DocLnk(frozenBoogers); |
1824 | // odebug << lnk.file() << oendl; | 1820 | // odebug << lnk.file() << oendl; |
1825 | title=lnk.comment(); | 1821 | title=lnk.comment(); |
1826 | load( lnk.file()); | 1822 | load( lnk.file()); |
1827 | this->show(); | 1823 | this->show(); |
1828 | // odebug << title << oendl; | 1824 | // odebug << title << oendl; |
1829 | // qApp->processEvents(); | 1825 | // qApp->processEvents(); |
1830 | // repaint(); | 1826 | // repaint(); |
1831 | } | 1827 | } |
1832 | 1828 | ||
1833 | void Gutenbrowser::mainListPressed(int mouse, QListBoxItem * , const QPoint & ) | 1829 | void Gutenbrowser::mainListPressed(int mouse, QListBoxItem * , const QPoint & ) |
1834 | { | 1830 | { |
1835 | switch (mouse) { | 1831 | switch (mouse) { |
1836 | case 1: | 1832 | case 1: |
1837 | break; | 1833 | break; |
1838 | case 2: { | 1834 | case 2: { |
1839 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 1835 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
1840 | m.insertItem( tr( "Open" ), this, SLOT( menuOpen() )); | 1836 | m.insertItem( tr( "Open" ), this, SLOT( menuOpen() )); |
1841 | m.insertSeparator(); | 1837 | m.insertSeparator(); |
1842 | m.insertItem( tr( "Search google.com" ), this, SLOT( menuGoogle())); | 1838 | m.insertItem( tr( "Search google.com" ), this, SLOT( menuGoogle())); |
1843 | m.insertItem( tr( "Edit Title" ), this, SLOT( menuEditTitle())); | 1839 | m.insertItem( tr( "Edit Title" ), this, SLOT( menuEditTitle())); |
1844 | // m.insertSeparator(); | 1840 | // m.insertSeparator(); |
1845 | // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 1841 | // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
1846 | m.exec( QCursor::pos() ); | 1842 | m.exec( QCursor::pos() ); |
1847 | } | 1843 | } |
1848 | break; | 1844 | break; |
1849 | }; | 1845 | }; |
1850 | } | 1846 | } |
1851 | 1847 | ||
1852 | void Gutenbrowser::menuOpen() { | 1848 | void Gutenbrowser::menuOpen() { |
1853 | listClickedSlot( mainList->item( mainList->currentItem())); | 1849 | listClickedSlot( mainList->item( mainList->currentItem())); |
1854 | } | 1850 | } |
1855 | 1851 | ||
1856 | void Gutenbrowser::menuGoogle() { | 1852 | void Gutenbrowser::menuGoogle() { |
1857 | searchGoogle( mainList->text(mainList->currentItem())); | 1853 | searchGoogle( mainList->text(mainList->currentItem())); |
1858 | } | 1854 | } |
1859 | 1855 | ||
1860 | void Gutenbrowser::searchGoogle( const QString &tempText) { | 1856 | void Gutenbrowser::searchGoogle( const QString &tempText) { |
1861 | QString text = tempText; | 1857 | QString text = tempText; |
1862 | 1858 | ||
1863 | int eexit=QMessageBox::information(this, "Note","Do you want to search for\n"+text+ | 1859 | int eexit=QMessageBox::information(this, "Note","Do you want to search for\n"+text+ |
1864 | "\non google.com?",QMessageBox::Yes, QMessageBox::No); | 1860 | "\non google.com?",QMessageBox::Yes, QMessageBox::No); |
1865 | if (eexit== 3) { | 1861 | if (eexit== 3) { |
1866 | qApp->processEvents(); | 1862 | qApp->processEvents(); |
1867 | text.replace( QRegExp("\\s"), "%20"); | 1863 | text.replace( QRegExp("\\s"), "%20"); |
1868 | text.replace( QRegExp("#"), ""); | 1864 | text.replace( QRegExp("#"), ""); |
1869 | text.replace( QRegExp(","), "%20"); | 1865 | text.replace( QRegExp(","), "%20"); |
1870 | text.replace( QRegExp("'"), "%20"); | 1866 | text.replace( QRegExp("'"), "%20"); |
1871 | text.replace( QRegExp("("), ""); | 1867 | text.replace( QRegExp("("), ""); |
1872 | text.replace( QRegExp(")"), ""); | 1868 | text.replace( QRegExp(")"), ""); |
1873 | // text.replace( QRegExp("[0-9]"), ""); | 1869 | // text.replace( QRegExp("[0-9]"), ""); |
1874 | QString s_lookup = "http://google.com/search?q="+text+"&num=30&sa=Google+Search"; | 1870 | QString s_lookup = "http://google.com/search?q="+text+"&num=30&sa=Google+Search"; |
1875 | goGetit( s_lookup, true); | 1871 | goGetit( s_lookup, true); |
1876 | } | 1872 | } |
1877 | 1873 | ||
1878 | } | 1874 | } |
1879 | 1875 | ||
1880 | void Gutenbrowser::menuEditTitle() | 1876 | void Gutenbrowser::menuEditTitle() |
1881 | { | 1877 | { |
1882 | int currentItem = mainList->currentItem(); | 1878 | int currentItem = mainList->currentItem(); |
1883 | QString title_text = mainList->text( currentItem); | 1879 | QString title_text = mainList->text( currentItem); |
1884 | //odebug << "Selected "+title_text << oendl; | 1880 | //odebug << "Selected "+title_text << oendl; |
1885 | 1881 | ||
1886 | Config config("Gutenbrowser"); | 1882 | Config config("Gutenbrowser"); |
1887 | config.setGroup( "Files" ); | 1883 | config.setGroup( "Files" ); |
1888 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0"); | 1884 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0"); |
1889 | int i_numofFiles = s_numofFiles.toInt(); | 1885 | int i_numofFiles = s_numofFiles.toInt(); |
1890 | QString fileNum; | 1886 | QString fileNum; |
1891 | for (int i = 1; i <= i_numofFiles+1; i++) { | 1887 | for (int i = 1; i <= i_numofFiles+1; i++) { |
1892 | 1888 | ||
1893 | fileNum.setNum(i); | 1889 | fileNum.setNum(i); |
1894 | config.setGroup( "Files" ); | 1890 | config.setGroup( "Files" ); |
1895 | QString s_filename = config.readEntry(fileNum, "" ); | 1891 | QString s_filename = config.readEntry(fileNum, "" ); |
1896 | config.setGroup( "Titles" ); | 1892 | config.setGroup( "Titles" ); |
1897 | QString file_title = config.readEntry( s_filename, ""); | 1893 | QString file_title = config.readEntry( s_filename, ""); |
1898 | //odebug << "file_title is "+file_title << oendl; | 1894 | //odebug << "file_title is "+file_title << oendl; |
1899 | if(title_text == file_title ) { | 1895 | if(title_text == file_title ) { |
1900 | // selFile = s_filename; | 1896 | // selFile = s_filename; |
1901 | //odebug << "Edit: "+ file_title << oendl; | 1897 | //odebug << "Edit: "+ file_title << oendl; |
1902 | i=i_numofFiles+1; | 1898 | i=i_numofFiles+1; |
1903 | Edit_Title *titleEdit; | 1899 | Edit_Title *titleEdit; |
1904 | titleEdit = new Edit_Title(this,file_title ,TRUE); | 1900 | titleEdit = new Edit_Title(this,file_title ,TRUE); |
1905 | if(titleEdit->exec() !=0) { | 1901 | if(titleEdit->exec() !=0) { |
1906 | //odebug << titleEdit->newTitle << oendl; | 1902 | //odebug << titleEdit->newTitle << oendl; |
1907 | config.writeEntry( s_filename, titleEdit->newTitle); | 1903 | config.writeEntry( s_filename, titleEdit->newTitle); |
1908 | mainList->removeItem(currentItem); | 1904 | mainList->removeItem(currentItem); |
1909 | mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), titleEdit->newTitle, currentItem); | 1905 | mainList->insertItem ( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"), titleEdit->newTitle, currentItem); |
1910 | } | 1906 | } |
1911 | } | 1907 | } |
1912 | } | 1908 | } |
1913 | 1909 | ||
1914 | // getTitles(); | 1910 | // getTitles(); |
1915 | mainList->triggerUpdate(true); | 1911 | mainList->triggerUpdate(true); |
1916 | 1912 | ||
1917 | } | 1913 | } |
1918 | 1914 | ||
1919 | 1915 | ||
1920 | 1916 | ||
1921 | bool Gutenbrowser::UnZipIt(const QString &zipFile) { | 1917 | bool Gutenbrowser::UnZipIt(const QString &zipFile) { |
1922 | odebug << zipFile << oendl; | 1918 | odebug << zipFile << oendl; |
1923 | #ifndef Q_WS_QWS | 1919 | #ifndef Q_WS_QWS |
1924 | if( QFile::exists( zipFile)) { // TODO findsome other way of dealingwithzip files. | 1920 | if( QFile::exists( zipFile)) { // TODO findsome other way of dealingwithzip files. |
1925 | bool isPgWhole=false; | 1921 | bool isPgWhole=false; |
1926 | QString thatFile; | 1922 | QString thatFile; |
1927 | if(zipFile.find("pgwhole",0,TRUE)) { | 1923 | if(zipFile.find("pgwhole",0,TRUE)) { |
1928 | isPgWhole=TRUE; | 1924 | isPgWhole=TRUE; |
1929 | thatFile= local_library +"PGWHOLE.TXT"; | 1925 | thatFile= local_library +"PGWHOLE.TXT"; |
1930 | } | 1926 | } |
1931 | // else { | 1927 | // else { |
1932 | // thatFile=zipFile.left(4); | 1928 | // thatFile=zipFile.left(4); |
1933 | // } | 1929 | // } |
1934 | // odebug << (const char*)local_library.latin1() << oendl; | 1930 | // odebug << (const char*)local_library.latin1() << oendl; |
1935 | QString cmd; | 1931 | QString cmd; |
1936 | #if defined(_WS_X11_) | 1932 | #if defined(_WS_X11_) |
1937 | if( chdir((const char*)local_library.latin1())!=0) | 1933 | if( chdir((const char*)local_library.latin1())!=0) |
1938 | odebug << "chdir failed." << oendl; | 1934 | odebug << "chdir failed." << oendl; |
1939 | cmd = "gunzip -S .zip " + local_library+zipFile; | 1935 | cmd = "gunzip -S .zip " + local_library+zipFile; |
1940 | //cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; | 1936 | //cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library; |
1941 | #endif | 1937 | #endif |
1942 | #ifdef Q_WS_QWS | 1938 | #ifdef Q_WS_QWS |
1943 | if( chdir((const char*)local_library.latin1())!=0) | 1939 | if( chdir((const char*)local_library.latin1())!=0) |
1944 | odebug << "chdir failed." << oendl; | 1940 | odebug << "chdir failed." << oendl; |
1945 | cmd = "unzip " + local_library+zipFile; | 1941 | cmd = "unzip " + local_library+zipFile; |
1946 | // cmd = "/usr/bin/unzip -o " + local_library+zipFile +" -d /usr/share/doc/gutenbrowser" ;//+ local_library; | 1942 | // cmd = "/usr/bin/unzip -o " + local_library+zipFile +" -d /usr/share/doc/gutenbrowser" ;//+ local_library; |
1947 | #endif | 1943 | #endif |
1948 | int exit=QMessageBox::information(this, "Ok to unzip?", | 1944 | int exit=QMessageBox::information(this, "Ok to unzip?", |
1949 | "Ok to unnzip\n"+ zipFile+" ?", | 1945 | "Ok to unnzip\n"+ zipFile+" ?", |
1950 | QMessageBox::Yes, QMessageBox::No); | 1946 | QMessageBox::Yes, QMessageBox::No); |
1951 | if (exit==QMessageBox::Yes) { | 1947 | if (exit==QMessageBox::Yes) { |
1952 | #if defined(_WS_X11_)// | 1948 | #if defined(_WS_X11_)// |
1953 | odebug << "Issuing the command "+cmd << oendl; | 1949 | odebug << "Issuing the command "+cmd << oendl; |
1954 | system( cmd); | 1950 | system( cmd); |
1955 | if( QFile::exists(thatFile)) | 1951 | if( QFile::exists(thatFile)) |
1956 | remove (thatFile); | 1952 | remove (thatFile); |
1957 | if(isPgWhole) { | 1953 | if(isPgWhole) { |
1958 | if( rename("pgwhole","PGWHOLE.TXT") !=0) | 1954 | if( rename("pgwhole","PGWHOLE.TXT") !=0) |
1959 | odebug << "rename failed" << oendl; | 1955 | odebug << "rename failed" << oendl; |
1960 | } else { | 1956 | } else { |
1961 | if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) | 1957 | if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) |
1962 | odebug << "rename failed" << oendl; | 1958 | odebug << "rename failed" << oendl; |
1963 | } | 1959 | } |
1964 | #endif | 1960 | #endif |
1965 | #ifdef Q_WS_QWS | 1961 | #ifdef Q_WS_QWS |
1966 | odebug << "Issuing the command "+cmd << oendl; | 1962 | odebug << "Issuing the command "+cmd << oendl; |
1967 | system( cmd); | 1963 | system( cmd); |
1968 | if( QFile::exists(thatFile)) | 1964 | if( QFile::exists(thatFile)) |
1969 | remove(thatFile); | 1965 | remove(thatFile); |
1970 | if(isPgWhole) { | 1966 | if(isPgWhole) { |
1971 | if( rename("pgwhole","PGWHOLE.TXT") !=0) | 1967 | if( rename("pgwhole","PGWHOLE.TXT") !=0) |
1972 | odebug << "rename failed" << oendl; | 1968 | odebug << "rename failed" << oendl; |
1973 | } else { | 1969 | } else { |
1974 | if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) | 1970 | if( rename(thatFile.left(4),thatFile.left(4)+".txt") !=0) |
1975 | odebug << "rename failed" << oendl; | 1971 | odebug << "rename failed" << oendl; |
1976 | } | 1972 | } |
1977 | #endif | 1973 | #endif |
1978 | // remove( zipFile); | 1974 | // remove( zipFile); |
1979 | return true; | 1975 | return true; |
1980 | } | 1976 | } |
1981 | else if(exit==QMessageBox::No) { | 1977 | else if(exit==QMessageBox::No) { |
1982 | // odebug << "unzip" << oendl; | 1978 | // odebug << "unzip" << oendl; |
1983 | return false; | 1979 | return false; |
1984 | } | 1980 | } |
1985 | } | 1981 | } |
1986 | else | 1982 | else |
1987 | QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); | 1983 | QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) ); |
1988 | #endif | 1984 | #endif |
1989 | return false; | 1985 | return false; |
1990 | } | 1986 | } |
1991 | 1987 | ||
1992 | 1988 | ||