summaryrefslogtreecommitdiff
authorar <ar>2004-05-27 22:04:46 (UTC)
committer ar <ar>2004-05-27 22:04:46 (UTC)
commit4f7c3c4d0d634706d13950b3827714b168e279e3 (patch) (unidiff)
tree2df448e7a4dcd538c26365873e194be2b55e83b7
parent46f81a089ba8febdb79e0d150b69f74bb1ea7d18 (diff)
downloadopie-4f7c3c4d0d634706d13950b3827714b168e279e3.zip
opie-4f7c3c4d0d634706d13950b3827714b168e279e3.tar.gz
opie-4f7c3c4d0d634706d13950b3827714b168e279e3.tar.bz2
- convert qDebug to odebug
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/keyz-cfg/zkb.cpp26
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp15
-rw-r--r--noncore/apps/opie-reader/BuffDoc.h2
-rw-r--r--noncore/apps/opie-reader/CEncoding.h4
-rw-r--r--noncore/apps/opie-reader/CExpander.h0
-rw-r--r--noncore/apps/opie-reader/Filedata.h4
-rw-r--r--noncore/apps/opie-reader/FontControl.h4
-rw-r--r--noncore/apps/opie-reader/Palm2QImage.cpp55
-rw-r--r--noncore/apps/opie-reader/QTReader.h12
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.h4
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.h2
-rw-r--r--noncore/apps/tinykate/libkate/qt3back/qregexp3.cpp80
12 files changed, 114 insertions, 94 deletions
diff --git a/noncore/apps/keyz-cfg/zkb.cpp b/noncore/apps/keyz-cfg/zkb.cpp
index 58bde2a..c9e1dc5 100644
--- a/noncore/apps/keyz-cfg/zkb.cpp
+++ b/noncore/apps/keyz-cfg/zkb.cpp
@@ -1,49 +1,53 @@
1#include "zkb.h" 1#include "zkb.h"
2
3/* OPIE */
4#include <opie2/odebug.h>
5
2#include <stdio.h> 6#include <stdio.h>
3 7
4// Implementation of Action class 8// Implementation of Action class
5Action::Action():state(0), keycode(0), unicode(0), flags(0) { 9Action::Action():state(0), keycode(0), unicode(0), flags(0) {
6} 10}
7 11
8Action::Action(State* s, ushort kc, ushort uni, int f): 12Action::Action(State* s, ushort kc, ushort uni, int f):
9 state(s), keycode(kc), unicode(uni), flags(f) { 13 state(s), keycode(kc), unicode(uni), flags(f) {
10} 14}
11 15
12Action::~Action() { 16Action::~Action() {
13} 17}
14 18
15State* Action::getState() const { 19State* Action::getState() const {
16 return state; 20 return state;
17} 21}
18 22
19void Action::setState(State* s) { 23void Action::setState(State* s) {
20 state = s; 24 state = s;
21 setDefined(true); 25 setDefined(true);
22} 26}
23 27
24bool Action::hasEvent() const { 28bool Action::hasEvent() const {
25 return flags & Event; 29 return flags & Event;
26} 30}
27 31
28void Action::setEvent(bool e) { 32void Action::setEvent(bool e) {
29 flags = (flags & ~Event) | ((e) ? Event : 0); 33 flags = (flags & ~Event) | ((e) ? Event : 0);
30 34
31 if (e) { 35 if (e) {
32 setDefined(true); 36 setDefined(true);
33 } else { 37 } else {
34 if (state == 0) { 38 if (state == 0) {
35 setDefined(false); 39 setDefined(false);
36 } 40 }
37 } 41 }
38} 42}
39 43
40bool Action::isDefined() const { 44bool Action::isDefined() const {
41 return flags & Defined; 45 return flags & Defined;
42} 46}
43 47
44void Action::setDefined(bool d) { 48void Action::setDefined(bool d) {
45 flags = (flags & ~Defined) | ((d) ? Defined : 0); 49 flags = (flags & ~Defined) | ((d) ? Defined : 0);
46} 50}
47 51
48int Action::getKeycode() const { 52int Action::getKeycode() const {
49 return keycode; 53 return keycode;
@@ -207,123 +211,121 @@ bool State::set(int keycode, bool pressed, Action& action) {
207} 211}
208 212
209State* State::getParent() const { 213State* State::getParent() const {
210 return parent; 214 return parent;
211} 215}
212 216
213void State::setParent(State* s) { 217void State::setParent(State* s) {
214 parent = s; 218 parent = s;
215} 219}
216 220
217int State::translateKeycode(int keycode) const { 221int State::translateKeycode(int keycode) const {
218 if (keycode < 0x20) { 222 if (keycode < 0x20) {
219 return -1; 223 return -1;
220 } 224 }
221 225
222 if (keycode < 0x80) { 226 if (keycode < 0x80) {
223 return x1[keycode - 0x20]; 227 return x1[keycode - 0x20];
224 } 228 }
225 229
226 if (keycode < 0x1000) { 230 if (keycode < 0x1000) {
227 return -1; 231 return -1;
228 } 232 }
229 233
230 if (keycode < 0x1057) { 234 if (keycode < 0x1057) {
231 return x2[keycode - 0x1000]; 235 return x2[keycode - 0x1000];
232 } 236 }
233 237
234 return -1; 238 return -1;
235} 239}
236 240
237// Implementation of Keymap class 241// Implementation of Keymap class
238Keymap::Keymap():enabled(true), currentState(0), autoRepeatAction(0), repeater(this) { 242Keymap::Keymap():enabled(true), currentState(0), autoRepeatAction(0), repeater(this) {
239 repeatDelay=400; 243 repeatDelay=400;
240 repeatPeriod=80; 244 repeatPeriod=80;
241 connect(&repeater, SIGNAL(timeout()), this, SLOT(autoRepeat())); 245 connect(&repeater, SIGNAL(timeout()), this, SLOT(autoRepeat()));
242} 246}
243 247
244Keymap::~Keymap() { 248Keymap::~Keymap() {
245 QMap<QString, State*>::Iterator it; 249 QMap<QString, State*>::Iterator it;
246 for(it = states.begin(); it != states.end(); ++it) { 250 for(it = states.begin(); it != states.end(); ++it) {
247 delete it.data(); 251 delete it.data();
248 } 252 }
249 states.clear(); 253 states.clear();
250} 254}
251 255
252bool Keymap::filter(int unicode, int keycode, int modifiers, 256bool Keymap::filter(int unicode, int keycode, int modifiers,
253 bool isPress, bool autoRepeat) { 257 bool isPress, bool autoRepeat) {
254 258
255 qDebug("filter: >>> unicode=%x, keycode=%x, modifiers=%x, " 259 odebug << "filter: >>> unicode=" << unicode << ", keycode=" << keycode
256 "ispressed=%x\n", unicode, keycode, modifiers, isPress); 260 << ", modifiers=" << modifiers << ", ispressed=" << isPress << oendl;
257 261
258 if (!enabled) { 262 if (!enabled) {
259 return false; 263 return false;
260 } 264 }
261 265
262 // the second check is workaround to make suspend work if 266 // the second check is workaround to make suspend work if
263 // the user pressed it right after he did resume. for some 267 // the user pressed it right after he did resume. for some
264 // reason the event sent by qt has autoRepeat true in this 268 // reason the event sent by qt has autoRepeat true in this
265 // case 269 // case
266 if (autoRepeat && keycode != 4177) { 270 if (autoRepeat && keycode != 4177) {
267 return true; 271 return true;
268 } 272 }
269 273
270 (void) unicode; (void) modifiers; 274 (void) unicode; (void) modifiers;
271 275
272 Action* action = currentState->get(keycode, isPress, true); 276 Action* action = currentState->get(keycode, isPress, true);
273 if (action==0 || !action->isDefined()) { 277 if (action==0 || !action->isDefined()) {
274 return true; 278 return true;
275 } 279 }
276 280
277 if (action->hasEvent()) { 281 if (action->hasEvent()) {
278 qDebug("filter:<<< unicode=%x, keycode=%x, modifiers=%x, " 282 odebug << "filter:<<< unicode=" << action->getUnicode() << ", keycode=" << action->getKeycode()
279 "ispressed=%x\n", action->getUnicode(), 283 << ", modifiers=" << action->getModifiers() << ", ispressed=" << action->isPressed() << oendl;
280 action->getKeycode(), action->getModifiers(),
281 action->isPressed());
282 284
283 QWSServer::sendKeyEvent(action->getUnicode(), 285 QWSServer::sendKeyEvent(action->getUnicode(),
284 action->getKeycode(), action->getModifiers(), 286 action->getKeycode(), action->getModifiers(),
285 action->isPressed(), false); 287 action->isPressed(), false);
286 } 288 }
287 289
288 if (action->isAutorepeat()) { 290 if (action->isAutorepeat()) {
289 autoRepeatAction = action; 291 autoRepeatAction = action;
290 repeater.start(repeatDelay, TRUE); 292 repeater.start(repeatDelay, TRUE);
291 } else { 293 } else {
292 autoRepeatAction = 0; 294 autoRepeatAction = 0;
293 } 295 }
294 296
295 State* nstate = action->getState(); 297 State* nstate = action->getState();
296 if (nstate != 0) { 298 if (nstate != 0) {
297 setCurrentState(nstate); 299 setCurrentState(nstate);
298 QString lbl = getCurrentLabel(); 300 QString lbl = getCurrentLabel();
299 if (!lbl.isEmpty()) { 301 if (!lbl.isEmpty()) {
300 emit stateChanged(lbl); 302 emit stateChanged(lbl);
301 } 303 }
302 } 304 }
303 305
304 306
305 return true; 307 return true;
306} 308}
307 309
308void Keymap::enable() { 310void Keymap::enable() {
309 enabled = true; 311 enabled = true;
310} 312}
311 313
312void Keymap::disable() { 314void Keymap::disable() {
313 enabled = false; 315 enabled = false;
314} 316}
315 317
316QStringList Keymap::listStates() { 318QStringList Keymap::listStates() {
317 QStringList ret; 319 QStringList ret;
318 320
319 QMap<QString, State*>::Iterator it; 321 QMap<QString, State*>::Iterator it;
320 for(it = states.begin(); it != states.end(); ++it) { 322 for(it = states.begin(); it != states.end(); ++it) {
321 ret.append(it.key()); 323 ret.append(it.key());
322 } 324 }
323 325
324 return ret; 326 return ret;
325} 327}
326 328
327State* Keymap::getStateByName(const QString& name) { 329State* Keymap::getStateByName(const QString& name) {
328 QMap<QString, State*>::Iterator it = states.find(name); 330 QMap<QString, State*>::Iterator it = states.find(name);
329 331
@@ -359,160 +361,158 @@ State* Keymap::getStateByLabel(const QString& label) {
359 name=name.left(name.length() - 1); 361 name=name.left(name.length() - 1);
360 362
361 n = currentStateName.findRev(":"); 363 n = currentStateName.findRev(":");
362 if (n >= 0) { 364 if (n >= 0) {
363 name += currentStateName.mid(n+1); 365 name += currentStateName.mid(n+1);
364 } 366 }
365 } 367 }
366 368
367 //odebug << "look for: " << name.utf8() << "\n" << oendl; 369 //odebug << "look for: " << name.utf8() << "\n" << oendl;
368 QMap<QString, State*>::Iterator sit = states.find(name); 370 QMap<QString, State*>::Iterator sit = states.find(name);
369 if (sit != states.end()) { 371 if (sit != states.end()) {
370 state = sit.data(); 372 state = sit.data();
371 } 373 }
372 374
373 return state; 375 return state;
374} 376}
375 377
376bool Keymap::addState(const QString& name, State* state) { 378bool Keymap::addState(const QString& name, State* state) {
377 if (states.find(name) != states.end()) { 379 if (states.find(name) != states.end()) {
378 return false; 380 return false;
379 } 381 }
380 382
381 states.insert(name, state); 383 states.insert(name, state);
382 lsmapInSync = false; 384 lsmapInSync = false;
383 385
384 if (currentState == 0) { 386 if (currentState == 0) {
385 setCurrentState(state); 387 setCurrentState(state);
386 } 388 }
387 389
388 return true; 390 return true;
389} 391}
390 392
391State* Keymap::getCurrentState() const { 393State* Keymap::getCurrentState() const {
392 return currentState; 394 return currentState;
393} 395}
394 396
395QString Keymap::getCurrentLabel() { 397QString Keymap::getCurrentLabel() {
396 return currentLabel; 398 return currentLabel;
397} 399}
398 400
399bool Keymap::setCurrentState(State* state) { 401bool Keymap::setCurrentState(State* state) {
400 QMap<QString, State*>::Iterator it; 402 QMap<QString, State*>::Iterator it;
401 for(it = states.begin(); it != states.end(); ++it) { 403 for(it = states.begin(); it != states.end(); ++it) {
402 State* s = it.data(); 404 State* s = it.data();
403 if (s == state) { 405 if (s == state) {
404 currentState = s; 406 currentState = s;
405 currentStateName = it.key(); 407 currentStateName = it.key();
406 408
407 qDebug("state changed: %s\n", (const char*) 409 odebug << "state changed: " << (const char*)currentStateName.utf8() << oendl;
408 currentStateName.utf8());
409 410
410 if (!lsmapInSync) { 411 if (!lsmapInSync) {
411 generateLabelStateMaps(); 412 generateLabelStateMaps();
412 } 413 }
413 414
414 QMap<State*, QString>::Iterator tit; 415 QMap<State*, QString>::Iterator tit;
415 tit = stateLabelMap.find(state); 416 tit = stateLabelMap.find(state);
416 if (tit != stateLabelMap.end()) { 417 if (tit != stateLabelMap.end()) {
417 currentLabel = tit.data(); 418 currentLabel = tit.data();
418 } else { 419 } else {
419 // odebug << "no label for: " + currentStateName + "\n" << oendl; 420 // odebug << "no label for: " + currentStateName + "\n" << oendl;
420 currentLabel = ""; 421 currentLabel = "";
421 } 422 }
422 423
423 return true; 424 return true;
424 } 425 }
425 } 426 }
426 427
427 return false; 428 return false;
428} 429}
429 430
430bool Keymap::removeState(const QString& name, bool force) { 431bool Keymap::removeState(const QString& name, bool force) {
431 QMap<QString, State*>::Iterator it = states.find(name); 432 QMap<QString, State*>::Iterator it = states.find(name);
432 433
433 if (it == states.end()) { 434 if (it == states.end()) {
434 return false; 435 return false;
435 } 436 }
436 437
437 State* state = it.data(); 438 State* state = it.data();
438 QList<Action> acts = findStateUsage(state); 439 QList<Action> acts = findStateUsage(state);
439 440
440 if (!acts.isEmpty()) { 441 if (!acts.isEmpty()) {
441 if (!force) { 442 if (!force) {
442 return false; 443 return false;
443 } else { 444 } else {
444 for(Action* a = acts.first(); a != 0; a = acts.next()) { 445 for(Action* a = acts.first(); a != 0; a = acts.next()) {
445 a->setState(0); 446 a->setState(0);
446 } 447 }
447 } 448 }
448 } 449 }
449 450
450 if (state == currentState) { 451 if (state == currentState) {
451 if (states.begin() != states.end()) { 452 if (states.begin() != states.end()) {
452 setCurrentState(states.begin().data()); 453 setCurrentState(states.begin().data());
453 } 454 }
454 } 455 }
455 456
456 states.remove(it); 457 states.remove(it);
457 delete state; 458 delete state;
458 459
459 lsmapInSync = false; 460 lsmapInSync = false;
460 461
461 return true; 462 return true;
462} 463}
463 464
464void Keymap::autoRepeat() { 465void Keymap::autoRepeat() {
465 if (autoRepeatAction != 0) { 466 if (autoRepeatAction != 0) {
466 qDebug("filter:<<< unicode=%x, keycode=%x, modifiers=%x, " 467 odebug << "filter:<<< unicode=" << autoRepeatAction->getUnicode()
467 "ispressed=%x\n", autoRepeatAction->getUnicode(), 468 << ", keycode=" << autoRepeatAction->getKeycode()
468 autoRepeatAction->getKeycode(), 469 << ", modifiers=" << autoRepeatAction->getModifiers()
469 autoRepeatAction->getModifiers(), 470 << "ispressed=" << autoRepeatAction->isPressed() << oendl;
470 autoRepeatAction->isPressed());
471 471
472 QWSServer::sendKeyEvent(autoRepeatAction->getUnicode(), 472 QWSServer::sendKeyEvent(autoRepeatAction->getUnicode(),
473 autoRepeatAction->getKeycode(), 473 autoRepeatAction->getKeycode(),
474 autoRepeatAction->getModifiers(), 474 autoRepeatAction->getModifiers(),
475 autoRepeatAction->isPressed(), true); 475 autoRepeatAction->isPressed(), true);
476 } 476 }
477 477
478 repeater.start(repeatPeriod, TRUE); 478 repeater.start(repeatPeriod, TRUE);
479} 479}
480 480
481bool Keymap::addLabel(const QString& label, const QString& state, int index) { 481bool Keymap::addLabel(const QString& label, const QString& state, int index) {
482 if (labels.find(label) != labels.end()) { 482 if (labels.find(label) != labels.end()) {
483 return false; 483 return false;
484 } 484 }
485 485
486 labels.insert(label, state); 486 labels.insert(label, state);
487 const QString& l = labels.find(label).key(); 487 const QString& l = labels.find(label).key();
488 if (index == -1) { 488 if (index == -1) {
489 labelList.append(l); 489 labelList.append(l);
490 } else { 490 } else {
491 labelList.insert(labelList.at(index), l); 491 labelList.insert(labelList.at(index), l);
492 } 492 }
493 493
494 lsmapInSync = false; 494 lsmapInSync = false;
495 495
496 return true; 496 return true;
497} 497}
498 498
499bool Keymap::removeLabel(const QString& label) { 499bool Keymap::removeLabel(const QString& label) {
500 500
501 if (labels.find(label) == labels.end()) { 501 if (labels.find(label) == labels.end()) {
502 return false; 502 return false;
503 } 503 }
504 504
505 labels.remove(label); 505 labels.remove(label);
506 labelList.remove(label); 506 labelList.remove(label);
507 lsmapInSync = false; 507 lsmapInSync = false;
508 508
509 if (label == currentLabel) { 509 if (label == currentLabel) {
510 currentLabel = ""; 510 currentLabel = "";
511 } 511 }
512 512
513 return true; 513 return true;
514} 514}
515 515
516int Keymap::getAutorepeatDelay() const { 516int Keymap::getAutorepeatDelay() const {
517 return repeatDelay; 517 return repeatDelay;
518} 518}
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
index be2b897..f14080f 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
@@ -376,132 +376,134 @@ void Gutenbrowser::downloadLibIndex() {
376 // { // use new, improved, *INSTANT* network-dialog-file-getterer 376 // { // use new, improved, *INSTANT* network-dialog-file-getterer
377 //// QMessageBox::message("Note",""); 377 //// QMessageBox::message("Note","");
378 // } 378 // }
379 // if(NetworkDlg) 379 // if(NetworkDlg)
380 // delete NetworkDlg; 380 // delete NetworkDlg;
381} 381}
382 382
383 383
384void Gutenbrowser::PrintBtn() { 384void Gutenbrowser::PrintBtn() {
385} 385}
386 386
387void Gutenbrowser::SearchBtn() { 387void Gutenbrowser::SearchBtn() {
388 if( loadCheck) { 388 if( loadCheck) {
389 odebug << "loadCheck: we have a loaded doc" << oendl; 389 odebug << "loadCheck: we have a loaded doc" << oendl;
390 Search(); 390 Search();
391 } 391 }
392 // else 392 // else
393 // QMessageBox::message("Note","Sorry, can't search. No etext is loaded"); 393 // QMessageBox::message("Note","Sorry, can't search. No etext is loaded");
394} 394}
395 395
396 396
397void Gutenbrowser::ForwardBtn() { 397void Gutenbrowser::ForwardBtn() {
398 398
399 if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) { 399 if( !ForwardButton->autoRepeat() && !ForwardButton->isDown()) {
400 400
401 QString s; 401 QString s;
402 QString insertString; 402 QString insertString;
403 int pageSize= Lview->PageSize(); 403 int pageSize= Lview->PageSize();
404 Lview->clear(); 404 Lview->clear();
405 405
406 for(int fd=0; fd < pageSize - 1;fd++) { 406 for(int fd=0; fd < pageSize - 1;fd++) {
407 f.readLine(s, 256); 407 f.readLine(s, 256);
408 if(useWrap) 408 if(useWrap)
409 s.replace(QRegExp("\n"),""); 409 s.replace(QRegExp("\n"),"");
410 insertString+=s; 410 insertString+=s;
411 Lview->insertLine( s, -1); 411 Lview->insertLine( s, -1);
412 // odebug << s << oendl; 412 // odebug << s << oendl;
413 currentLine++; 413 currentLine++;
414 } 414 }
415 // Lview->insertAt( insertString,0,0, FALSE); 415 // Lview->insertAt( insertString,0,0, FALSE);
416 currentFilePos = f.at(); 416 currentFilePos = f.at();
417 // if( i_pageNum != pages) { 417 // if( i_pageNum != pages) {
418 // Lview->MultiLine_Ex::pageDown( FALSE); 418 // Lview->MultiLine_Ex::pageDown( FALSE);
419 i_pageNum++; 419 i_pageNum++;
420 pageStopArray.resize(i_pageNum + 1); 420 pageStopArray.resize(i_pageNum + 1);
421 // int length = Lview->length(); 421 // int length = Lview->length();
422 422
423 pageStopArray[i_pageNum ] = currentFilePos; 423 pageStopArray[i_pageNum ] = currentFilePos;
424 // qDebug("%d current page is number %d, pagesize %d, length %d, current %d", 424 // odebug << currentFilePos << " current page is number " << i_pageNum
425 // currentFilePos, i_pageNum, pageSize, Lview->length(), pageStopArray[i_pageNum] ); 425 // << ", pagesize " << pageSize << ", length " << Lview->length()
426 // << ", current " << pageStopArray[i_pageNum] << oendl;
426 setStatus(); 427 setStatus();
427 Lview->setCursorPosition( 0, 0, FALSE); 428 Lview->setCursorPosition( 0, 0, FALSE);
428 // } 429 // }
429 430
430 } else { 431 } else {
431 // odebug << "bal" << oendl; 432 // odebug << "bal" << oendl;
432 // if( i_pageNum != pages) { 433 // if( i_pageNum != pages) {
433 434
434 // // int newTop = Lview->Top(); 435 // // int newTop = Lview->Top();
435 // // if(Lview->lastRow() > i) 436 // // if(Lview->lastRow() > i)
436 // Lview->ScrollUp(1); 437 // Lview->ScrollUp(1);
437 // // i_pageNum++; 438 // // i_pageNum++;
438 // setStatus(); 439 // setStatus();
439 // Lview->setCursorPosition( Lview->Top(), 0, FALSE); 440 // Lview->setCursorPosition( Lview->Top(), 0, FALSE);
440 441
441 // } 442 // }
442 443
443 } 444 }
444 Lview->setFocus(); 445 Lview->setFocus();
445 446
446 // odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl; 447 // odebug << "page number " << i_pageNum << " line number " << currentLine << "" << oendl;
447} 448}
448 449
449 450
450void Gutenbrowser::BackBtn() { 451void Gutenbrowser::BackBtn() {
451 if( i_pageNum > 0) { 452 if( i_pageNum > 0) {
452 int pageSize= Lview->PageSize(); 453 int pageSize= Lview->PageSize();
453 // int length=Lview->length(); 454 // int length=Lview->length();
454 455
455 i_pageNum--; 456 i_pageNum--;
456 currentFilePos = f.at(); 457 currentFilePos = f.at();
457 458
458 // qDebug("%d move back to %d, current page number %d, %d, length %d", 459 // odebug << currentFilePos << " move back to " << pageStopArray[i_pageNum - 1 ]
459 // currentFilePos, pageStopArray[i_pageNum - 1 ], i_pageNum, pageSize, Lview->length() ); 460 // << ", current page number " << i_pageNum
461 // << ", " << pageSize << ", length " << Lview->length() << oendl;
460 462
461 if( i_pageNum < 2) { 463 if( i_pageNum < 2) {
462 f.at( 0); 464 f.at( 0);
463 } else { 465 } else {
464 if(!f.at( pageStopArray[i_pageNum - 1] )) 466 if(!f.at( pageStopArray[i_pageNum - 1] ))
465 odebug << "File positioned backward did not work" << oendl; 467 odebug << "File positioned backward did not work" << oendl;
466 } 468 }
467 QString s; 469 QString s;
468 // int sizeLine=0; 470 // int sizeLine=0;
469 Lview->clear(); 471 Lview->clear();
470 // QString insertString; 472 // QString insertString;
471 473
472 for(int fd = 0; fd < pageSize ;fd++) { 474 for(int fd = 0; fd < pageSize ;fd++) {
473 // Lview->removeLine( Lview->PageSize() ); 475 // Lview->removeLine( Lview->PageSize() );
474 f.readLine(s, 256); 476 f.readLine(s, 256);
475 if(useWrap) 477 if(useWrap)
476 s.replace(QRegExp("\n"),""); 478 s.replace(QRegExp("\n"),"");
477 currentLine++; 479 currentLine++;
478 // insertString+=s; 480 // insertString+=s;
479 Lview->insertLine( s, -1); 481 Lview->insertLine( s, -1);
480 } 482 }
481 483
482 // Lview->insertAt( insertString,0,0, FALSE); 484 // Lview->insertAt( insertString,0,0, FALSE);
483 485
484 if( !BackButton->autoRepeat() && !BackButton->isDown()) { 486 if( !BackButton->autoRepeat() && !BackButton->isDown()) {
485 QString topR; 487 QString topR;
486 QString lastR; 488 QString lastR;
487 QString pageR; 489 QString pageR;
488 // int sizer = Lview->lastRow() - Lview->topRow(); 490 // int sizer = Lview->lastRow() - Lview->topRow();
489 // int i_topRow = Lview->topRow(); 491 // int i_topRow = Lview->topRow();
490 if( i_pageNum < 1) 492 if( i_pageNum < 1)
491 i_pageNum = 1; 493 i_pageNum = 1;
492 setCaption(QString::number(i_pageNum)); 494 setCaption(QString::number(i_pageNum));
493 } else { 495 } else {
494 // int newTop = Lview->Top(); 496 // int newTop = Lview->Top();
495 // if(Lview->lastRow() > i) 497 // if(Lview->lastRow() > i)
496 Lview->MultiLine_Ex::pageUp( FALSE); 498 Lview->MultiLine_Ex::pageUp( FALSE);
497 // Lview->ScrollDown(1); 499 // Lview->ScrollDown(1);
498 // i_pageNum--; 500 // i_pageNum--;
499 if( i_pageNum < 1) 501 if( i_pageNum < 1)
500 i_pageNum = 1; 502 i_pageNum = 1;
501 setStatus(); 503 setStatus();
502 Lview->setCursorPosition( Lview->Top(), 0, FALSE); 504 Lview->setCursorPosition( Lview->Top(), 0, FALSE);
503 505
504 } 506 }
505 } 507 }
506 Lview->setFocus(); 508 Lview->setFocus();
507} 509}
@@ -754,98 +756,99 @@ bool Gutenbrowser::load( const char *fileName) {
754 Lview->setFixedVisibleLines(19); 756 Lview->setFixedVisibleLines(19);
755 else 757 else
756 Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2); 758 Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2);
757 } 759 }
758 760
759 Config cfg("Gutenbrowser"); 761 Config cfg("Gutenbrowser");
760 cfg.setGroup("General"); 762 cfg.setGroup("General");
761 cfg.writeEntry("Current",fileName); 763 cfg.writeEntry("Current",fileName);
762 currentLine=0; 764 currentLine=0;
763 765
764 file_name=fileName; 766 file_name=fileName;
765 QString o_file = fileName; 767 QString o_file = fileName;
766 768
767 // if (i_pageNum < 1) { 769 // if (i_pageNum < 1) {
768 i_pageNum = 1; 770 i_pageNum = 1;
769 // } 771 // }
770 odebug << "ready to open "+o_file << oendl; 772 odebug << "ready to open "+o_file << oendl;
771 773
772 if(f.isOpen()) f.close(); 774 if(f.isOpen()) f.close();
773 f.setName( o_file); 775 f.setName( o_file);
774 776
775 if ( !f.open( IO_ReadOnly)) { 777 if ( !f.open( IO_ReadOnly)) {
776 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) ); 778 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n" +o_file)) );
777 return false; 779 return false;
778 } 780 }
779 currentFilePos = 0; 781 currentFilePos = 0;
780 pageStopArray.resize(3); 782 pageStopArray.resize(3);
781 pageStopArray[0] = currentFilePos; 783 pageStopArray[0] = currentFilePos;
782 784
783 fileHandle = f.handle(); 785 fileHandle = f.handle();
784 QString insertString; 786 QString insertString;
785 QTextStream t(&f); 787 QTextStream t(&f);
786 QString s; 788 QString s;
787 for(int fd=0; fd < Lview->PageSize() ;fd++) { 789 for(int fd=0; fd < Lview->PageSize() ;fd++) {
788 s=t.readLine(); 790 s=t.readLine();
789 // insertString+=s; 791 // insertString+=s;
790 if(useWrap) 792 if(useWrap)
791 s.replace(QRegExp("\n"),""); 793 s.replace(QRegExp("\n"),"");
792 // s.replace(QRegExp("\r"),""); 794 // s.replace(QRegExp("\r"),"");
793 Lview->insertLine( s,-1); 795 Lview->insertLine( s,-1);
794 currentLine++; 796 currentLine++;
795 } 797 }
796 798
797 // int length = Lview->length(); 799 // int length = Lview->length();
798 currentFilePos = f.at(); 800 currentFilePos = f.at();
799 801
800 pageStopArray[1] = currentFilePos; 802 pageStopArray[1] = currentFilePos;
801 803
802 qDebug("<<<<<<<<<<<%d current page is number %d, length %d, current %d, pageSize %d", 804 odebug << "<<<<<<<<<<<" << currentFilePos << " current page is number " << i_pageNum
803 currentFilePos, i_pageNum, Lview->length(), pageStopArray[i_pageNum], Lview->PageSize() ); 805 << ", length " << Lview->length() << ", current " << pageStopArray[i_pageNum]
806 << ", pageSize " << Lview->PageSize() << oendl;
804 807
805 Lview->setMaxLines(Lview->PageSize()*2); 808 Lview->setMaxLines(Lview->PageSize()*2);
806 odebug << "Gulped " << currentLine << "" << oendl; 809 odebug << "Gulped " << currentLine << "" << oendl;
807 setCaption(title); 810 setCaption(title);
808 Lview->setAutoUpdate( TRUE); 811 Lview->setAutoUpdate( TRUE);
809 812
810 Lview->setCursorPosition(0,0,FALSE); 813 Lview->setCursorPosition(0,0,FALSE);
811 814
812 // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; 815 // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1;
813 //odebug << "number of pages " << pages << "" << oendl; 816 //odebug << "number of pages " << pages << "" << oendl;
814 817
815 loadCheck = true; 818 loadCheck = true;
816 enableButtons(true); 819 enableButtons(true);
817 if( donateMenu->count() == 3) { 820 if( donateMenu->count() == 3) {
818 donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() )); 821 donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() ));
819 } 822 }
820 Lview->setFocus(); 823 Lview->setFocus();
821 824
822 // QCopEnvelope("QPE/System", "notBusy()" ); 825 // QCopEnvelope("QPE/System", "notBusy()" );
823 return true; 826 return true;
824} // end load 827} // end load
825 828
826void Gutenbrowser::Search() { 829void Gutenbrowser::Search() {
827 830
828 // if( searchDlg->isHidden()) 831 // if( searchDlg->isHidden())
829 { 832 {
830 odebug << "Starting search dialog" << oendl; 833 odebug << "Starting search dialog" << oendl;
831 searchDlg = new SearchDialog( this, "Etext Search", true); 834 searchDlg = new SearchDialog( this, "Etext Search", true);
832 searchDlg->setCaption( tr( "Etext Search" )); 835 searchDlg->setCaption( tr( "Etext Search" ));
833 // searchDlg->setLabel( "- searches etext"); 836 // searchDlg->setLabel( "- searches etext");
834 connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); 837 connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot()));
835 connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); 838 connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot()));
836 839
837 QString resultString; 840 QString resultString;
838 QString string = searchDlg->searchString; 841 QString string = searchDlg->searchString;
839 Lview->deselect(); 842 Lview->deselect();
840 searchDlg->show(); 843 searchDlg->show();
841 searchDlg->result(); 844 searchDlg->result();
842 } 845 }
843} 846}
844 847
845void Gutenbrowser::search_slot( ) { 848void Gutenbrowser::search_slot( ) {
846 int line, col; 849 int line, col;
847 if (!searchDlg /*&& !loadCheck */) 850 if (!searchDlg /*&& !loadCheck */)
848 return; 851 return;
849 852
850 Lview->getCursorPosition(&line,&col); 853 Lview->getCursorPosition(&line,&col);
851 QString to_find_string=searchDlg->get_text(); 854 QString to_find_string=searchDlg->get_text();
diff --git a/noncore/apps/opie-reader/BuffDoc.h b/noncore/apps/opie-reader/BuffDoc.h
index 29d0329..61531c0 100644
--- a/noncore/apps/opie-reader/BuffDoc.h
+++ b/noncore/apps/opie-reader/BuffDoc.h
@@ -11,97 +11,97 @@
11#include <qfontmetrics.h> 11#include <qfontmetrics.h>
12#include <qmessagebox.h> 12#include <qmessagebox.h>
13 13
14class BuffDoc 14class BuffDoc
15{ 15{
16 CDrawBuffer lastword; 16 CDrawBuffer lastword;
17 CSizeBuffer lastsizes, allsizes; 17 CSizeBuffer lastsizes, allsizes;
18 size_t laststartline; 18 size_t laststartline;
19 bool lastispara; 19 bool lastispara;
20 CExpander* exp; 20 CExpander* exp;
21 CFilterChain* filt; 21 CFilterChain* filt;
22 public: 22 public:
23 void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) 23 void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
24 { 24 {
25 if (exp == NULL) 25 if (exp == NULL)
26 { 26 {
27 data = NULL; 27 data = NULL;
28 len = 0; 28 len = 0;
29 } 29 }
30 else 30 else
31 { 31 {
32 exp->setSaveData(data, len, src, srclen); 32 exp->setSaveData(data, len, src, srclen);
33 } 33 }
34 } 34 }
35 void putSaveData(unsigned char*& src, unsigned short& srclen) 35 void putSaveData(unsigned char*& src, unsigned short& srclen)
36 { 36 {
37 if (exp != NULL) 37 if (exp != NULL)
38 { 38 {
39 exp->putSaveData(src, srclen); 39 exp->putSaveData(src, srclen);
40 } 40 }
41 } 41 }
42#ifdef USEQPE 42#ifdef USEQPE
43 void suspend() { if (exp != NULL) exp->suspend(); } 43 void suspend() { if (exp != NULL) exp->suspend(); }
44 void unsuspend() { if (exp != NULL) exp->unsuspend(); } 44 void unsuspend() { if (exp != NULL) exp->unsuspend(); }
45#else 45#else
46 void suspend() {} 46 void suspend() {}
47 void unsuspend() {} 47 void unsuspend() {}
48#endif 48#endif
49 ~BuffDoc() 49 ~BuffDoc()
50 { 50 {
51 delete filt; 51 delete filt;
52 delete exp; 52 delete exp;
53 } 53 }
54 BuffDoc() 54 BuffDoc()
55 { 55 {
56 exp = NULL; 56 exp = NULL;
57 filt = NULL; 57 filt = NULL;
58 lastword.empty(); 58 lastword.empty();
59 // // qDebug("Buffdoc created"); 59 // odebug << "Buffdoc created" << oendl;
60 } 60 }
61 bool empty() { return (exp == NULL); } 61 bool empty() { return (exp == NULL); }
62 void setfilter(CFilterChain* _f) 62 void setfilter(CFilterChain* _f)
63 { 63 {
64 if (filt != NULL) delete filt; 64 if (filt != NULL) delete filt;
65 filt = _f; 65 filt = _f;
66 filt->setsource(exp); 66 filt->setsource(exp);
67 } 67 }
68 CList<Bkmk>* getbkmklist() { return exp->getbkmklist(); } 68 CList<Bkmk>* getbkmklist() { return exp->getbkmklist(); }
69 bool hasrandomaccess() { return (exp == NULL) ? false : exp->hasrandomaccess(); } 69 bool hasrandomaccess() { return (exp == NULL) ? false : exp->hasrandomaccess(); }
70 bool iseol() { return (lastword[0] == '\0'); } 70 bool iseol() { return (lastword[0] == '\0'); }
71 int openfile(QWidget* _parent, const char *src); 71 int openfile(QWidget* _parent, const char *src);
72 tchar getch() 72 tchar getch()
73 { 73 {
74 tchar ch = UEOF; 74 tchar ch = UEOF;
75 CStyle sty; 75 CStyle sty;
76 if (exp != NULL) 76 if (exp != NULL)
77 { 77 {
78 filt->getch(ch, sty); 78 filt->getch(ch, sty);
79 } 79 }
80 return ch; 80 return ch;
81 } 81 }
82 void getch(tchar& ch, CStyle& sty) 82 void getch(tchar& ch, CStyle& sty)
83 { 83 {
84 if (exp != NULL) 84 if (exp != NULL)
85 { 85 {
86 filt->getch(ch, sty); 86 filt->getch(ch, sty);
87 } 87 }
88 else 88 else
89 ch = UEOF; 89 ch = UEOF;
90 } 90 }
91 void setwidth(int w) { if (exp != NULL) exp->setwidth(w); } 91 void setwidth(int w) { if (exp != NULL) exp->setwidth(w); }
92 QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); } 92 QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); }
93 unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); } 93 unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); }
94 unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); } 94 unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); }
95 unsigned int locate() { return (exp == NULL) ? 0 : laststartline; } 95 unsigned int locate() { return (exp == NULL) ? 0 : laststartline; }
96 unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); } 96 unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); }
97 void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); } 97 void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); }
98 MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); } 98 MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); }
99 linkType hyperlink(unsigned int n, QString& wrd); 99 linkType hyperlink(unsigned int n, QString& wrd);
100 size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); } 100 size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); }
101 void locate(unsigned int n); 101 void locate(unsigned int n);
102 bool getline(CDrawBuffer* buff, int w, unsigned char _border); 102 bool getline(CDrawBuffer* buff, int w, unsigned char _border);
103 bool getline(CDrawBuffer* buff, int w, int cw, unsigned char _border); 103 bool getline(CDrawBuffer* buff, int w, int cw, unsigned char _border);
104 void sizes(unsigned long& fs, unsigned long& ts) { exp->sizes(fs,ts); } 104 void sizes(unsigned long& fs, unsigned long& ts) { exp->sizes(fs,ts); }
105 int getpara(CBuffer& buff) 105 int getpara(CBuffer& buff)
106 { 106 {
107 tchar ch; 107 tchar ch;
diff --git a/noncore/apps/opie-reader/CEncoding.h b/noncore/apps/opie-reader/CEncoding.h
index 463fba9..df0104a 100644
--- a/noncore/apps/opie-reader/CEncoding.h
+++ b/noncore/apps/opie-reader/CEncoding.h
@@ -16,59 +16,59 @@ public:
16 void setparent(CExpander* p) { parent = p; } 16 void setparent(CExpander* p) { parent = p; }
17 virtual ~CEncoding() {}; 17 virtual ~CEncoding() {};
18}; 18};
19 19
20class CUtf8 : public CEncoding 20class CUtf8 : public CEncoding
21{ 21{
22public: 22public:
23 void getch(tchar& ch, CStyle& sty); 23 void getch(tchar& ch, CStyle& sty);
24}; 24};
25 25
26class CUcs16be : public CEncoding 26class CUcs16be : public CEncoding
27{ 27{
28public: 28public:
29 void getch(tchar& ch, CStyle& sty); 29 void getch(tchar& ch, CStyle& sty);
30}; 30};
31 31
32class CUcs16le : public CEncoding 32class CUcs16le : public CEncoding
33{ 33{
34public: 34public:
35 void getch(tchar& ch, CStyle& sty); 35 void getch(tchar& ch, CStyle& sty);
36}; 36};
37 37
38class Ccp1252 : public CEncoding 38class Ccp1252 : public CEncoding
39{ 39{
40public: 40public:
41 void getch(tchar& ch, CStyle& sty); 41 void getch(tchar& ch, CStyle& sty);
42}; 42};
43 43
44class CPalm : public Ccp1252 44class CPalm : public Ccp1252
45{ 45{
46public: 46public:
47 void getch(tchar& ch, CStyle& sty); 47 void getch(tchar& ch, CStyle& sty);
48}; 48};
49 49
50class CAscii : public CEncoding 50class CAscii : public CEncoding
51{ 51{
52public: 52public:
53 void getch(tchar& ch, CStyle& sty); 53 void getch(tchar& ch, CStyle& sty);
54}; 54};
55 55
56#include "CEncoding_tables.h" 56#include "CEncoding_tables.h"
57 57
58class CGeneral8Bit : public CEncoding 58class CGeneral8Bit : public CEncoding
59{ 59{
60 int m_index; 60 int m_index;
61 public: 61 public:
62 CGeneral8Bit(int _i) : m_index(_i) 62 CGeneral8Bit(int _i) : m_index(_i)
63 { 63 {
64 // qDebug("8Bit:%d", _i); 64// odebug << "8Bit: " << _i << oendl;
65 // qDebug("%s", unicodetable::iterator(_i)->mime); 65// odebug << unicodetable::iterator(_i)->mime << oendl;
66 } 66 }
67 void getch(tchar& ch, CStyle& sty) 67 void getch(tchar& ch, CStyle& sty)
68 { 68 {
69 parent->getch(ch, sty); 69 parent->getch(ch, sty);
70 ch = unicodetable::unicodevalue(m_index, ch); 70 ch = unicodetable::unicodevalue(m_index, ch);
71 } 71 }
72}; 72};
73 73
74#endif 74#endif
diff --git a/noncore/apps/opie-reader/CExpander.h b/noncore/apps/opie-reader/CExpander.h
index 7b21d3e..9fae245 100644
--- a/noncore/apps/opie-reader/CExpander.h
+++ b/noncore/apps/opie-reader/CExpander.h
diff --git a/noncore/apps/opie-reader/Filedata.h b/noncore/apps/opie-reader/Filedata.h
index 096dd31..1b85b71 100644
--- a/noncore/apps/opie-reader/Filedata.h
+++ b/noncore/apps/opie-reader/Filedata.h
@@ -1,51 +1,51 @@
1#ifndef __FILEDATA_H 1#ifndef __FILEDATA_H
2#define __FILEDATA_H 2#define __FILEDATA_H
3 3
4#include <time.h> 4#include <time.h>
5 5
6class CFiledata 6class CFiledata
7{ 7{
8 unsigned char* data; 8 unsigned char* data;
9 bool m_own; 9 bool m_own;
10 public: 10 public:
11 CFiledata(tchar* d) 11 CFiledata(tchar* d)
12 { 12 {
13 data = (unsigned char*)d; 13 data = (unsigned char*)d;
14 m_own = false; 14 m_own = false;
15 } 15 }
16 CFiledata(time_t dt, tchar* nm) 16 CFiledata(time_t dt, tchar* nm)
17 { 17 {
18 int nlen = ustrlen(nm)+1; 18 int nlen = ustrlen(nm)+1;
19 data = new unsigned char[sizeof(time_t)+sizeof(tchar)*nlen]; 19 data = new unsigned char[sizeof(time_t)+sizeof(tchar)*nlen];
20 *((time_t *)data) = dt; 20 *((time_t *)data) = dt;
21 memcpy(data+sizeof(time_t), nm, sizeof(tchar)*nlen); 21 memcpy(data+sizeof(time_t), nm, sizeof(tchar)*nlen);
22 m_own = true; 22 m_own = true;
23 } 23 }
24 ~CFiledata() 24 ~CFiledata()
25 { 25 {
26 if (m_own && data != NULL) 26 if (m_own && data != NULL)
27 { 27 {
28 delete [] data; 28 delete [] data;
29 // qDebug("~Filedata: deleting"); 29// odebug << "~Filedata: deleting" << oendl;
30 } 30 }
31 else 31 else
32 { 32 {
33 // qDebug("~Filedata: not deleting"); 33// odebug << "~Filedata: not deleting" << oendl;
34 } 34 }
35 } 35 }
36 tchar* name() const { return (tchar*)(data+sizeof(time_t)); } 36 tchar* name() const { return (tchar*)(data+sizeof(time_t)); }
37 time_t date() { return *((time_t *)data); } 37 time_t date() { return *((time_t *)data); }
38 void setdate(time_t _t) { *((time_t *)data) = _t; } 38 void setdate(time_t _t) { *((time_t *)data) = _t; }
39 unsigned char* content() { return data; } 39 unsigned char* content() { return data; }
40 size_t length() const { return sizeof(time_t)+sizeof(tchar)*(ustrlen(name())+1); } 40 size_t length() const { return sizeof(time_t)+sizeof(tchar)*(ustrlen(name())+1); }
41 bool operator==(const CFiledata& rhs) 41 bool operator==(const CFiledata& rhs)
42 { 42 {
43 return ((length() == rhs.length()) && (memcmp(data, rhs.data, length()) == 0)); 43 return ((length() == rhs.length()) && (memcmp(data, rhs.data, length()) == 0));
44 } 44 }
45 bool samename(const CFiledata& rhs) 45 bool samename(const CFiledata& rhs)
46 { 46 {
47 return (ustrcmp((tchar *)(data+sizeof(time_t)),(tchar *)(rhs.data+sizeof(time_t))) == 0); 47 return (ustrcmp((tchar *)(data+sizeof(time_t)),(tchar *)(rhs.data+sizeof(time_t))) == 0);
48 } 48 }
49}; 49};
50 50
51#endif 51#endif
diff --git a/noncore/apps/opie-reader/FontControl.h b/noncore/apps/opie-reader/FontControl.h
index 5681496..e56b619 100644
--- a/noncore/apps/opie-reader/FontControl.h
+++ b/noncore/apps/opie-reader/FontControl.h
@@ -59,95 +59,95 @@ class FontControl
59 } 59 }
60 int ascent(const CStyle& ch) 60 int ascent(const CStyle& ch)
61 { 61 {
62 QFont f(name(), getsize(ch)); 62 QFont f(name(), getsize(ch));
63 QFontMetrics fm(f); 63 QFontMetrics fm(f);
64 return fm.ascent(); 64 return fm.ascent();
65 } 65 }
66 int descent() 66 int descent()
67 { 67 {
68 QFont f(name(), currentsize()); 68 QFont f(name(), currentsize());
69 QFontMetrics fm(f); 69 QFontMetrics fm(f);
70 return fm.descent(); 70 return fm.descent();
71 } 71 }
72 int descent(const CStyle& ch) 72 int descent(const CStyle& ch)
73 { 73 {
74 QFont f(name(), getsize(ch)); 74 QFont f(name(), getsize(ch));
75 QFontMetrics fm(f); 75 QFontMetrics fm(f);
76 return fm.descent(); 76 return fm.descent();
77 } 77 }
78 int lineSpacing() 78 int lineSpacing()
79 { 79 {
80 QFont f(name(), currentsize()); 80 QFont f(name(), currentsize());
81 QFontMetrics fm(f); 81 QFontMetrics fm(f);
82 return fm.lineSpacing(); 82 return fm.lineSpacing();
83 } 83 }
84 int lineSpacing(const CStyle& ch) 84 int lineSpacing(const CStyle& ch)
85 { 85 {
86 QFont f(name(), getsize(ch)); 86 QFont f(name(), getsize(ch));
87 QFontMetrics fm(f); 87 QFontMetrics fm(f);
88 return fm.lineSpacing(); 88 return fm.lineSpacing();
89 } 89 }
90 bool decreasesize() 90 bool decreasesize()
91 { 91 {
92/* 92/*
93 if (--m_size < 0) 93 if (--m_size < 0)
94 { 94 {
95 m_size = 0; 95 m_size = 0;
96 return false; 96 return false;
97 } 97 }
98 else return true; 98 else return true;
99*/ 99*/
100 if (g_size-- == m_size) 100 if (g_size-- == m_size)
101 { 101 {
102 if (--m_size < 0) 102 if (--m_size < 0)
103 { 103 {
104 m_size = 0; 104 m_size = 0;
105 } 105 }
106 } 106 }
107 // qDebug("Font:%d Graphics:%d", m_size, g_size); 107// odebug << "Font:" << m_size << " Graphics:" << g_size << oendl;
108 return true; 108 return true;
109 } 109 }
110 bool increasesize() 110 bool increasesize()
111 { 111 {
112/* 112/*
113 if (++m_size >= m_maxsize) 113 if (++m_size >= m_maxsize)
114 { 114 {
115 m_size = m_maxsize - 1; 115 m_size = m_maxsize - 1;
116 return false; 116 return false;
117 } 117 }
118 else return true; 118 else return true;
119*/ 119*/
120 if (g_size++ == m_size) 120 if (g_size++ == m_size)
121 { 121 {
122 if (++m_size >= m_maxsize) 122 if (++m_size >= m_maxsize)
123 { 123 {
124 m_size = m_maxsize - 1; 124 m_size = m_maxsize - 1;
125 } 125 }
126 } 126 }
127 // qDebug("Font:%d Graphics:%d", m_size, g_size); 127// odebug << "Font:" << m_size << " Graphics:" << g_size << oendl;
128 return true; 128 return true;
129 } 129 }
130 bool ChangeFont(QString& n) 130 bool ChangeFont(QString& n)
131 { 131 {
132 return ChangeFont(n, currentsize()); 132 return ChangeFont(n, currentsize());
133 } 133 }
134 bool ChangeFont(QString& n, int tgt); 134 bool ChangeFont(QString& n, int tgt);
135 void setlead(int _lead) 135 void setlead(int _lead)
136 { 136 {
137 m_leading = _lead; 137 m_leading = _lead;
138 } 138 }
139 int getlead() 139 int getlead()
140 { 140 {
141 return m_leading; 141 return m_leading;
142 } 142 }
143 void setextraspace(int _lead) 143 void setextraspace(int _lead)
144 { 144 {
145 m_extraspace = _lead; 145 m_extraspace = _lead;
146 } 146 }
147 int getextraspace() 147 int getextraspace()
148 { 148 {
149 return m_extraspace; 149 return m_extraspace;
150 } 150 }
151}; 151};
152 152
153#endif 153#endif
diff --git a/noncore/apps/opie-reader/Palm2QImage.cpp b/noncore/apps/opie-reader/Palm2QImage.cpp
index 9339595..b0d4e00 100644
--- a/noncore/apps/opie-reader/Palm2QImage.cpp
+++ b/noncore/apps/opie-reader/Palm2QImage.cpp
@@ -1,60 +1,67 @@
1/* -*- mode: c; indent-tabs-mode: nil; -*- */ 1/* -*- mode: c; indent-tabs-mode: nil; -*- */
2
3/* OPIE */
4#include <opie2/odebug.h>
5
6/* QT */
7#include <qimage.h>
8
9/* STD */
2#include <stdio.h> 10#include <stdio.h>
3#include <stdlib.h> 11#include <stdlib.h>
4#include <string.h> 12#include <string.h>
5#ifndef _WINDOWS 13#ifndef _WINDOWS
6#include <unistd.h> /* for link */ 14#include <unistd.h> /* for link */
7#endif 15#endif
8#include <sys/types.h> 16#include <sys/types.h>
9#include <sys/stat.h> 17#include <sys/stat.h>
10#include <stdarg.h> 18#include <stdarg.h>
11 19
12#include <qimage.h>
13 20
14/***********************************************************************/ 21/***********************************************************************/
15/***********************************************************************/ 22/***********************************************************************/
16/***** *****/ 23/***** *****/
17/***** Code to decode the Palm image format to JPEG *****/ 24/***** Code to decode the Palm image format to JPEG *****/
18/***** *****/ 25/***** *****/
19/***********************************************************************/ 26/***********************************************************************/
20/***********************************************************************/ 27/***********************************************************************/
21 28
22#define READ_BIGENDIAN_SHORT(p) (((p)[0] << 8)|((p)[1])) 29#define READ_BIGENDIAN_SHORT(p) (((p)[0] << 8)|((p)[1]))
23#define READ_BIGENDIAN_LONG(p) (((p)[0] << 24)|((p)[1] << 16)|((p)[2] << 8)|((p)[3])) 30#define READ_BIGENDIAN_LONG(p) (((p)[0] << 24)|((p)[1] << 16)|((p)[2] << 8)|((p)[3]))
24 31
25#define PALM_IS_COMPRESSED_FLAG 0x8000 32#define PALM_IS_COMPRESSED_FLAG 0x8000
26#define PALM_HAS_COLORMAP_FLAG 0x4000 33#define PALM_HAS_COLORMAP_FLAG 0x4000
27#define PALM_HAS_TRANSPARENCY_FLAG 0x2000 34#define PALM_HAS_TRANSPARENCY_FLAG 0x2000
28#define PALM_DIRECT_COLOR_FLAG 0x0400 35#define PALM_DIRECT_COLOR_FLAG 0x0400
29#define PALM_4_BYTE_FIELD_FLAG 0x0200 36#define PALM_4_BYTE_FIELD_FLAG 0x0200
30 37
31#define PALM_COMPRESSION_SCANLINE 0x00 38#define PALM_COMPRESSION_SCANLINE 0x00
32#define PALM_COMPRESSION_RLE 0x01 39#define PALM_COMPRESSION_RLE 0x01
33#define PALM_COMPRESSION_PACKBITS 0x02 40#define PALM_COMPRESSION_PACKBITS 0x02
34#define PALM_COMPRESSION_NONE 0xFF 41#define PALM_COMPRESSION_NONE 0xFF
35 42
36#define PALM_COLORMAP_SIZE 232 43#define PALM_COLORMAP_SIZE 232
37 44
38typedef struct { 45typedef struct {
39 unsigned char red; 46 unsigned char red;
40 unsigned char green; 47 unsigned char green;
41 unsigned char blue; 48 unsigned char blue;
42} ColorMapEntry; 49} ColorMapEntry;
43 50
44static ColorMapEntry Palm8BitColormap[] = { 51static ColorMapEntry Palm8BitColormap[] = {
45 { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 }, 52 { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 },
46 { 255, 51, 255 }, { 255, 0, 255 }, { 255, 255, 204 }, { 255, 204, 204 }, 53 { 255, 51, 255 }, { 255, 0, 255 }, { 255, 255, 204 }, { 255, 204, 204 },
47 { 255, 153, 204 }, { 255, 102, 204 }, { 255, 51, 204 }, { 255, 0, 204 }, 54 { 255, 153, 204 }, { 255, 102, 204 }, { 255, 51, 204 }, { 255, 0, 204 },
48 { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 }, 55 { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 },
49 { 255, 51, 153 }, { 255, 0, 153 }, { 204, 255, 255 }, { 204, 204, 255 }, 56 { 255, 51, 153 }, { 255, 0, 153 }, { 204, 255, 255 }, { 204, 204, 255 },
50 { 204, 153, 255 }, { 204, 102, 255 }, { 204, 51, 255 }, { 204, 0, 255 }, 57 { 204, 153, 255 }, { 204, 102, 255 }, { 204, 51, 255 }, { 204, 0, 255 },
51 { 204, 255, 204 }, { 204, 204, 204 }, { 204, 153, 204 }, { 204, 102, 204 }, 58 { 204, 255, 204 }, { 204, 204, 204 }, { 204, 153, 204 }, { 204, 102, 204 },
52 { 204, 51, 204 }, { 204, 0, 204 }, { 204, 255, 153 }, { 204, 204, 153 }, 59 { 204, 51, 204 }, { 204, 0, 204 }, { 204, 255, 153 }, { 204, 204, 153 },
53 { 204, 153, 153 }, { 204, 102, 153 }, { 204, 51, 153 }, { 204, 0, 153 }, 60 { 204, 153, 153 }, { 204, 102, 153 }, { 204, 51, 153 }, { 204, 0, 153 },
54 { 153, 255, 255 }, { 153, 204, 255 }, { 153, 153, 255 }, { 153, 102, 255 }, 61 { 153, 255, 255 }, { 153, 204, 255 }, { 153, 153, 255 }, { 153, 102, 255 },
55 { 153, 51, 255 }, { 153, 0, 255 }, { 153, 255, 204 }, { 153, 204, 204 }, 62 { 153, 51, 255 }, { 153, 0, 255 }, { 153, 255, 204 }, { 153, 204, 204 },
56 { 153, 153, 204 }, { 153, 102, 204 }, { 153, 51, 204 }, { 153, 0, 204 }, 63 { 153, 153, 204 }, { 153, 102, 204 }, { 153, 51, 204 }, { 153, 0, 204 },
57 { 153, 255, 153 }, { 153, 204, 153 }, { 153, 153, 153 }, { 153, 102, 153 }, 64 { 153, 255, 153 }, { 153, 204, 153 }, { 153, 153, 153 }, { 153, 102, 153 },
58 { 153, 51, 153 }, { 153, 0, 153 }, { 102, 255, 255 }, { 102, 204, 255 }, 65 { 153, 51, 153 }, { 153, 0, 153 }, { 102, 255, 255 }, { 102, 204, 255 },
59 { 102, 153, 255 }, { 102, 102, 255 }, { 102, 51, 255 }, { 102, 0, 255 }, 66 { 102, 153, 255 }, { 102, 102, 255 }, { 102, 51, 255 }, { 102, 0, 255 },
60 { 102, 255, 204 }, { 102, 204, 204 }, { 102, 153, 204 }, { 102, 102, 204 }, 67 { 102, 255, 204 }, { 102, 204, 204 }, { 102, 153, 204 }, { 102, 102, 204 },
@@ -96,213 +103,217 @@ static ColorMapEntry Palm8BitColormap[] = {
96 { 0, 255, 51 }, { 0, 204, 51 }, { 0, 153, 51 }, { 0, 102, 51 }, 103 { 0, 255, 51 }, { 0, 204, 51 }, { 0, 153, 51 }, { 0, 102, 51 },
97 { 0, 51, 51 }, { 0, 0, 51 }, { 0, 255, 0 }, { 0, 204, 0 }, 104 { 0, 51, 51 }, { 0, 0, 51 }, { 0, 255, 0 }, { 0, 204, 0 },
98 { 0, 153, 0 }, { 0, 102, 0 }, { 0, 51, 0 }, { 17, 17, 17 }, 105 { 0, 153, 0 }, { 0, 102, 0 }, { 0, 51, 0 }, { 17, 17, 17 },
99 { 34, 34, 34 }, { 68, 68, 68 }, { 85, 85, 85 }, { 119, 119, 119 }, 106 { 34, 34, 34 }, { 68, 68, 68 }, { 85, 85, 85 }, { 119, 119, 119 },
100 { 136, 136, 136 }, { 170, 170, 170 }, { 187, 187, 187 }, { 221, 221, 221 }, 107 { 136, 136, 136 }, { 170, 170, 170 }, { 187, 187, 187 }, { 221, 221, 221 },
101 { 238, 238, 238 }, { 192, 192, 192 }, { 128, 0, 0 }, { 128, 0, 128 }, 108 { 238, 238, 238 }, { 192, 192, 192 }, { 128, 0, 0 }, { 128, 0, 128 },
102 { 0, 128, 0 }, { 0, 128, 128 }, { 0, 0, 0 }, { 0, 0, 0 }, 109 { 0, 128, 0 }, { 0, 128, 128 }, { 0, 0, 0 }, { 0, 0, 0 },
103 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, 110 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 },
104 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, 111 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 },
105 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, 112 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 },
106 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, 113 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 },
107 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, 114 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 },
108 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }}; 115 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }};
109 116
110static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }}; 117static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }};
111 118
112static ColorMapEntry Palm2BitColormap[] = { 119static ColorMapEntry Palm2BitColormap[] = {
113 { 255, 255, 255 }, { 192, 192, 192 }, { 128, 128, 128 }, { 0, 0, 0 }}; 120 { 255, 255, 255 }, { 192, 192, 192 }, { 128, 128, 128 }, { 0, 0, 0 }};
114 121
115static ColorMapEntry Palm4BitColormap[] = { 122static ColorMapEntry Palm4BitColormap[] = {
116 { 255, 255, 255 }, { 238, 238, 238 }, { 221, 221, 221 }, { 204, 204, 204 }, 123 { 255, 255, 255 }, { 238, 238, 238 }, { 221, 221, 221 }, { 204, 204, 204 },
117 { 187, 187, 187 }, { 170, 170, 170 }, { 153, 153, 153 }, { 136, 136, 136 }, 124 { 187, 187, 187 }, { 170, 170, 170 }, { 153, 153, 153 }, { 136, 136, 136 },
118 { 119, 119, 119 }, { 102, 102, 102 }, { 85, 85, 85 }, { 68, 68, 68 }, 125 { 119, 119, 119 }, { 102, 102, 102 }, { 85, 85, 85 }, { 68, 68, 68 },
119 { 51, 51, 51 }, { 34, 34, 34 }, { 17, 17, 17 }, { 0, 0, 0 }}; 126 { 51, 51, 51 }, { 34, 34, 34 }, { 17, 17, 17 }, { 0, 0, 0 }};
120 127
121QImage* Palm2QImage 128QImage* Palm2QImage
122 (unsigned char *image_bytes_in, int byte_count_in) 129 (unsigned char *image_bytes_in, int byte_count_in)
123{ 130{
124 unsigned int width, height, bytes_per_row, flags, next_depth_offset; 131 unsigned int width, height, bytes_per_row, flags, next_depth_offset;
125 unsigned int bits_per_pixel, version, transparent_index, compression_type, i, j, inval, inbit, mask, incount; 132 unsigned int bits_per_pixel, version, transparent_index, compression_type, i, j, inval, inbit, mask, incount;
126 unsigned int palm_red_bits, palm_green_bits, palm_blue_bits; 133 unsigned int palm_red_bits, palm_green_bits, palm_blue_bits;
127 unsigned char *palm_ptr, *x_ptr, *imagedata, *inbyte, *rowbuf, *lastrow, 134 unsigned char *palm_ptr, *x_ptr, *imagedata, *inbyte, *rowbuf, *lastrow,
128 *imagedatastart, *palmimage; 135 *imagedatastart, *palmimage;
129 ColorMapEntry *colormap; 136 ColorMapEntry *colormap;
130 137
131 palmimage = image_bytes_in; 138 palmimage = image_bytes_in;
132 width = READ_BIGENDIAN_SHORT(palmimage + 0); 139 width = READ_BIGENDIAN_SHORT(palmimage + 0);
133 height = READ_BIGENDIAN_SHORT(palmimage + 2); 140 height = READ_BIGENDIAN_SHORT(palmimage + 2);
134 bytes_per_row = READ_BIGENDIAN_SHORT(palmimage + 4); 141 bytes_per_row = READ_BIGENDIAN_SHORT(palmimage + 4);
135 flags = READ_BIGENDIAN_SHORT(palmimage + 6); 142 flags = READ_BIGENDIAN_SHORT(palmimage + 6);
136 bits_per_pixel = palmimage[8]; 143 bits_per_pixel = palmimage[8];
137 version = palmimage[9]; 144 version = palmimage[9];
138 next_depth_offset = READ_BIGENDIAN_SHORT(palmimage + 10); 145 next_depth_offset = READ_BIGENDIAN_SHORT(palmimage + 10);
139 transparent_index = palmimage[12]; 146 transparent_index = palmimage[12];
140 compression_type = palmimage[13]; 147 compression_type = palmimage[13];
141 /* bytes 14 and 15 are reserved by Palm and always 0 */ 148 /* bytes 14 and 15 are reserved by Palm and always 0 */
142 149
143#if 0 150#if 0
144// qDebug ("Palm image is %dx%d, %d bpp, version %d, flags 0x%x, compression %d", width, height, bits_per_pixel, version, flags, compression_type); 151// odebug << "Palm image is " << width << "x" << height
152// << ", " << bits_per_pixel << " bpp, version " << version
153// << ", flags 0x" << flags << ", compression " << compression_type << oendl;
145#endif 154#endif
146 155
147 if (compression_type == PALM_COMPRESSION_PACKBITS) { 156 if (compression_type == PALM_COMPRESSION_PACKBITS) {
148// qDebug ("Image uses packbits compression; not yet supported"); 157// odebug << "Image uses packbits compression; not yet supported" << oendl;
149 return NULL; 158 return NULL;
150 } else if ((compression_type != PALM_COMPRESSION_NONE) && 159 } else if ((compression_type != PALM_COMPRESSION_NONE) &&
151 (compression_type != PALM_COMPRESSION_RLE) && 160 (compression_type != PALM_COMPRESSION_RLE) &&
152 (compression_type != PALM_COMPRESSION_SCANLINE)) { 161 (compression_type != PALM_COMPRESSION_SCANLINE)) {
153// qDebug ("Image uses unknown compression, code 0x%x", compression_type); 162// odebug << "Image uses unknown compression, code 0x" << compression_type << oendl;
154 return NULL; 163 return NULL;
155 } 164 }
156 165
157 /* as of PalmOS 4.0, there are 6 different kinds of Palm pixmaps: 166 /* as of PalmOS 4.0, there are 6 different kinds of Palm pixmaps:
158 167
159 1, 2, or 4 bit grayscale 168 1, 2, or 4 bit grayscale
160 8-bit StaticColor using the Palm standard colormap 169 8-bit StaticColor using the Palm standard colormap
161 8-bit PseudoColor using a user-specified colormap 170 8-bit PseudoColor using a user-specified colormap
162 16-bit DirectColor using 5 bits for red, 6 for green, and 5 for blue 171 16-bit DirectColor using 5 bits for red, 6 for green, and 5 for blue
163 172
164 Each of these can be compressed with one of four compression schemes, 173 Each of these can be compressed with one of four compression schemes,
165 "RLE", "Scanline", "PackBits", or none. 174 "RLE", "Scanline", "PackBits", or none.
166 175
167 We begin by constructing the colormap. 176 We begin by constructing the colormap.
168 */ 177 */
169 178
170 if (flags & PALM_HAS_COLORMAP_FLAG) { 179 if (flags & PALM_HAS_COLORMAP_FLAG) {
171// qDebug("Palm images with custom colormaps are not currently supported.\n"); 180// odebug << "Palm images with custom colormaps are not currently supported." << oendl;
172 return NULL; 181 return NULL;
173 } else if (bits_per_pixel == 1) { 182 } else if (bits_per_pixel == 1) {
174 colormap = Palm1BitColormap; 183 colormap = Palm1BitColormap;
175 imagedatastart = palmimage + 16; 184 imagedatastart = palmimage + 16;
176 } else if (bits_per_pixel == 2) { 185 } else if (bits_per_pixel == 2) {
177 colormap = Palm2BitColormap; 186 colormap = Palm2BitColormap;
178 imagedatastart = palmimage + 16; 187 imagedatastart = palmimage + 16;
179 } else if (bits_per_pixel == 4) { 188 } else if (bits_per_pixel == 4) {
180 colormap = Palm4BitColormap; 189 colormap = Palm4BitColormap;
181 imagedatastart = palmimage + 16; 190 imagedatastart = palmimage + 16;
182 } else if (bits_per_pixel == 8) { 191 } else if (bits_per_pixel == 8) {
183 colormap = Palm8BitColormap; 192 colormap = Palm8BitColormap;
184 imagedatastart = palmimage + 16; 193 imagedatastart = palmimage + 16;
185 } else if (bits_per_pixel == 16 && (flags & PALM_DIRECT_COLOR_FLAG)) { 194 } else if (bits_per_pixel == 16 && (flags & PALM_DIRECT_COLOR_FLAG)) {
186 colormap = NULL; 195 colormap = NULL;
187 palm_red_bits = palmimage[16]; 196 palm_red_bits = palmimage[16];
188 palm_green_bits = palmimage[17]; 197 palm_green_bits = palmimage[17];
189 palm_blue_bits = palmimage[18]; 198 palm_blue_bits = palmimage[18];
190// qDebug("Bits:%d, %d, %d", palm_red_bits, palm_green_bits, palm_blue_bits); 199// odebug << "Bits:" << palm_red_bits << ", " << palm_green_bits << ", " << palm_blue_bits << oendl;
191 if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) { 200 if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) {
192// qDebug("Can't handle this format DirectColor image -- too wide in some color (%d:%d:%d)\n", palm_red_bits, palm_green_bits, palm_blue_bits); 201// odebug << "Can't handle this format DirectColor image -- too wide in some color ("
202// << palm_red_bits << ":" << palm_green_bits << ":" << palm_blue_bits << oendl;
193 return NULL; 203 return NULL;
194 } 204 }
195 if (bits_per_pixel > (8 * sizeof(unsigned long))) { 205 if (bits_per_pixel > (8 * sizeof(unsigned long))) {
196// qDebug ("Can't handle this format DirectColor image -- too many bits per pixel (%d)\n", bits_per_pixel); 206// odebug << "Can't handle this format DirectColor image -- too many bits per pixel ("
207// << bits_per_pixel << ")" << oendl;
197 return NULL; 208 return NULL;
198 } 209 }
199 imagedatastart = palmimage + 24; 210 imagedatastart = palmimage + 24;
200 } else { 211 } else {
201// qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel); 212// odebug << "Unknown bits-per-pixel of " << bits_per_pixel << " encountered" << oendl;
202 return NULL; 213 return NULL;
203 } 214 }
204 215
205#ifndef USEQPE 216#ifndef USEQPE
206 QImage* qimage = new QImage(width, height, 32); 217 QImage* qimage = new QImage(width, height, 32);
207#else 218#else
208 QImage* qimage = new QImage(width, height, 16); 219 QImage* qimage = new QImage(width, height, 16);
209#endif 220#endif
210 221
211 /* row by row, uncompress the Palm image and copy it to the JPEG buffer */ 222 /* row by row, uncompress the Palm image and copy it to the JPEG buffer */
212 rowbuf = new unsigned char[bytes_per_row * width]; 223 rowbuf = new unsigned char[bytes_per_row * width];
213 lastrow = new unsigned char[bytes_per_row * width]; 224 lastrow = new unsigned char[bytes_per_row * width];
214 225
215 for (i=0, palm_ptr = imagedatastart , x_ptr = imagedata; i < height; ++i) { 226 for (i=0, palm_ptr = imagedatastart , x_ptr = imagedata; i < height; ++i) {
216// qDebug("inval:%x palm_ptr:%x x_ptr:%x bpr:%x", inval, palm_ptr, x_ptr, bytes_per_row); 227// odebug << "inval:" << inval << " palm_ptr:" << palm_ptr << " x_ptr:" << x_ptr
228// << " bpr:" << bytes_per_row << oendl;
217 229
218 /* first, uncompress the Palm image */ 230 /* first, uncompress the Palm image */
219 if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_RLE)) { 231 if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_RLE)) {
220 for (j = 0; j < bytes_per_row; ) { 232 for (j = 0; j < bytes_per_row; ) {
221 incount = *palm_ptr++; 233 incount = *palm_ptr++;
222 inval = *palm_ptr++; 234 inval = *palm_ptr++;
223 memset(rowbuf + j, inval, incount); 235 memset(rowbuf + j, inval, incount);
224 j += incount; 236 j += incount;
225 } 237 }
226 } else if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_SCANLINE)) { 238 } else if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_SCANLINE)) {
227 for (j = 0; j < bytes_per_row; j += 8) { 239 for (j = 0; j < bytes_per_row; j += 8) {
228 incount = *palm_ptr++; 240 incount = *palm_ptr++;
229 inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8; 241 inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8;
230 for (inbit = 0; inbit < inval; inbit += 1) { 242 for (inbit = 0; inbit < inval; inbit += 1) {
231 if (incount & (1 << (7 - inbit))) 243 if (incount & (1 << (7 - inbit)))
232 rowbuf[j + inbit] = *palm_ptr++; 244 rowbuf[j + inbit] = *palm_ptr++;
233 else 245 else
234 rowbuf[j + inbit] = lastrow[j + inbit]; 246 rowbuf[j + inbit] = lastrow[j + inbit];
235 } 247 }
236 } 248 }
237 memcpy (lastrow, rowbuf, bytes_per_row); 249 memcpy (lastrow, rowbuf, bytes_per_row);
238 } else if (((flags & PALM_IS_COMPRESSED_FLAG) && 250 } else if (((flags & PALM_IS_COMPRESSED_FLAG) &&
239 (compression_type == PALM_COMPRESSION_NONE)) || 251 (compression_type == PALM_COMPRESSION_NONE)) ||
240 ((flags & PALM_IS_COMPRESSED_FLAG) == 0)) 252 ((flags & PALM_IS_COMPRESSED_FLAG) == 0))
241 { 253 {
242 memcpy (rowbuf, palm_ptr, bytes_per_row); 254 memcpy (rowbuf, palm_ptr, bytes_per_row);
243 palm_ptr += bytes_per_row; 255 palm_ptr += bytes_per_row;
244 } 256 }
245 else { 257 else {
246 qDebug("Case 4"); 258 odebug << "Case 4" << oendl;
247 qDebug("Is compressed:%s", ((flags & PALM_IS_COMPRESSED_FLAG) == 0) ? "false" : "true"); 259 odebug << "Is compressed:" << (((flags & PALM_IS_COMPRESSED_FLAG) == 0) ? "false" : "true") << oendl;
248 qDebug("Has colourmap:%s", ((flags & PALM_HAS_COLORMAP_FLAG) == 0) ? "false" : "true"); 260 odebug << "Has colourmap:" << (((flags & PALM_HAS_COLORMAP_FLAG) == 0) ? "false" : "true") << oendl;
249 qDebug("Has transparency:%s", ((flags & PALM_HAS_TRANSPARENCY_FLAG) == 0) ? "false" : "true"); 261 odebug << "Has transparency:" << (((flags & PALM_HAS_TRANSPARENCY_FLAG) == 0) ? "false" : "true") << oendl;
250 qDebug("Direct colour:%s", ((flags & PALM_DIRECT_COLOR_FLAG) == 0) ? "false" : "true"); 262 odebug << "Direct colour:" << (((flags & PALM_DIRECT_COLOR_FLAG) == 0) ? "false" : "true") << oendl;
251 qDebug("four byte field:%s", ((flags & PALM_4_BYTE_FIELD_FLAG) == 0) ? "false" : "true"); 263 odebug << "four byte field:" << (((flags & PALM_4_BYTE_FIELD_FLAG) == 0) ? "false" : "true") << oendl;
252 memcpy (rowbuf, palm_ptr, bytes_per_row); 264 memcpy (rowbuf, palm_ptr, bytes_per_row);
253 palm_ptr += bytes_per_row; 265 palm_ptr += bytes_per_row;
254 } 266 }
255 /* next, write it to the GDK bitmap */ 267 /* next, write it to the GDK bitmap */
256 if (colormap) { 268 if (colormap) {
257 mask = (1 << bits_per_pixel) - 1; 269 mask = (1 << bits_per_pixel) - 1;
258 for (inbit = 8 - bits_per_pixel, inbyte = rowbuf, j = 0; j < width; ++j) { 270 for (inbit = 8 - bits_per_pixel, inbyte = rowbuf, j = 0; j < width; ++j) {
259 inval = ((*inbyte) & (mask << inbit)) >> inbit; 271 inval = ((*inbyte) & (mask << inbit)) >> inbit;
260 /* correct for oddity of the 8-bit color Palm pixmap... */ 272 /* correct for oddity of the 8-bit color Palm pixmap... */
261 if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231; 273 if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231;
262 /* now lookup the correct color and set the pixel in the GTK bitmap */ 274 /* now lookup the correct color and set the pixel in the GTK bitmap */
263 QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue); 275 QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue);
264 qimage->setPixel(j, i, colour); 276 qimage->setPixel(j, i, colour);
265 if (!inbit) { 277 if (!inbit) {
266 ++inbyte; 278 ++inbyte;
267 inbit = 8 - bits_per_pixel; 279 inbit = 8 - bits_per_pixel;
268 } else { 280 } else {
269 inbit -= bits_per_pixel; 281 inbit -= bits_per_pixel;
270 } 282 }
271 } 283 }
272 } else if (!colormap && 284 } else if (!colormap &&
273 bits_per_pixel == 16) { 285 bits_per_pixel == 16) {
274 for (inbyte = rowbuf, j = 0; j < width; ++j) { 286 for (inbyte = rowbuf, j = 0; j < width; ++j) {
275 inval = ((unsigned short)inbyte[0] << (unsigned short)8) | inbyte[1]; 287 inval = ((unsigned short)inbyte[0] << (unsigned short)8) | inbyte[1];
276 288
277/* 289/*
278 qDebug ("pixel is %d,%d (%d:%d:%d)", 290 odebug << "pixel is " << j << "," << i << " ("
279 j, i, 291 << (((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits)) << ":"
280 ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), 292 << (((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits)) << ":"
281 ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), 293 << (((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)) << ")" << oendl;
282 ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits));
283*/ 294*/
284 QRgb colour = qRgb( 295 QRgb colour = qRgb(
285 ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), 296 ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits),
286 ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), 297 ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits),
287 ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); 298 ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits));
288 qimage->setPixel(j, i, colour); 299 qimage->setPixel(j, i, colour);
289 inbyte += 2; 300 inbyte += 2;
290 } 301 }
291 } 302 }
292 } 303 }
293 304
294 delete [] rowbuf; 305 delete [] rowbuf;
295 delete [] lastrow; 306 delete [] lastrow;
296 307
297 return qimage; 308 return qimage;
298} 309}
299 310
300QImage* hRule(int w, int h, unsigned char r, unsigned char g, unsigned char b) 311QImage* hRule(int w, int h, unsigned char r, unsigned char g, unsigned char b)
301{ 312{
302//// qDebug("hrule [%d, %d]", w, h); 313// odebug << "hrule [" << w << ", " << h << "]" << oendl;
303 QPixmap* qimage = new QPixmap(w, h); 314 QPixmap* qimage = new QPixmap(w, h);
304 qimage->fill(QColor(r,g,b)); 315 qimage->fill(QColor(r,g,b));
305 QImage* ret = new QImage(qimage->convertToImage()); 316 QImage* ret = new QImage(qimage->convertToImage());
306 delete qimage; 317 delete qimage;
307 return ret; 318 return ret;
308} 319}
diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h
index dfbdfb9..f89de63 100644
--- a/noncore/apps/opie-reader/QTReader.h
+++ b/noncore/apps/opie-reader/QTReader.h
@@ -91,113 +91,113 @@ public:
91 /* 91 /*
92 void setText(bool oldfile) 92 void setText(bool oldfile)
93 { 93 {
94 if (oldfile) 94 if (oldfile)
95 { 95 {
96 m_string = m_lastfile; 96 m_string = m_lastfile;
97 load_file((const tchar*)m_string); 97 load_file((const tchar*)m_string);
98 } 98 }
99 else 99 else
100 { 100 {
101 m_string = QString::null; 101 m_string = QString::null;
102 } 102 }
103 }; 103 };
104 */ 104 */
105 void setlead(int _lead) 105 void setlead(int _lead)
106 { 106 {
107 m_fontControl.setlead(_lead); 107 m_fontControl.setlead(_lead);
108 } 108 }
109 int getlead() 109 int getlead()
110 { 110 {
111 return m_fontControl.getlead(); 111 return m_fontControl.getlead();
112 } 112 }
113 void setextraspace(int _lead) 113 void setextraspace(int _lead)
114 { 114 {
115 m_fontControl.setextraspace(_lead); 115 m_fontControl.setextraspace(_lead);
116 } 116 }
117 int getextraspace() 117 int getextraspace()
118 { 118 {
119 return m_fontControl.getextraspace(); 119 return m_fontControl.getextraspace();
120 } 120 }
121 void setpagemode(bool _b) 121 void setpagemode(bool _b)
122 { 122 {
123 m_bpagemode = _b; 123 m_bpagemode = _b;
124 } 124 }
125 void setmono(bool _b) 125 void setmono(bool _b)
126 { 126 {
127 m_bMonoSpaced = _b; 127 m_bMonoSpaced = _b;
128 ChangeFont(m_fontControl.currentsize()); 128 ChangeFont(m_fontControl.currentsize());
129 locate(pagelocate()); 129 locate(pagelocate());
130 } 130 }
131 void setencoding(int _f) 131 void setencoding(int _f)
132 { 132 {
133 m_encd = _f; 133 m_encd = _f;
134 setfilter(getfilter()); 134 setfilter(getfilter());
135 } 135 }
136 MarkupType PreferredMarkup(); 136 MarkupType PreferredMarkup();
137 CEncoding* getencoding() 137 CEncoding* getencoding()
138 { 138 {
139 // qDebug("m_encd:%d", m_encd); 139// odebug << "m_encd:" << m_encd << oendl;
140 switch (m_encd) 140 switch (m_encd)
141 { 141 {
142 case 4: 142 case 4:
143 // qDebug("palm"); 143// odebug << "palm" << oendl;
144 return new CPalm; 144 return new CPalm;
145 case 1: 145 case 1:
146 // qDebug("utf8"); 146// odebug << "utf8" << oendl;
147 return new CUtf8; 147 return new CUtf8;
148 case 2: 148 case 2:
149 // qDebug("ucs16be"); 149// odebug << "ucs16be" << oendl;
150 return new CUcs16be; 150 return new CUcs16be;
151 case 3: 151 case 3:
152 // qDebug("ucs16le"); 152// odebug << "ucs16le" << oendl;
153 return new CUcs16le; 153 return new CUcs16le;
154 case 0: 154 case 0:
155 // qDebug("ascii"); 155// odebug << "ascii" << oendl;
156 return new CAscii; 156 return new CAscii;
157 default: 157 default:
158 return new CGeneral8Bit(m_encd-MAX_ENCODING+1); 158 return new CGeneral8Bit(m_encd-MAX_ENCODING+1);
159 } 159 }
160 } 160 }
161 CFilterChain* getfilter() 161 CFilterChain* getfilter()
162 { 162 {
163 CFilterChain * filt = new CFilterChain(getencoding()); 163 CFilterChain * filt = new CFilterChain(getencoding());
164 if (bstripcr) filt->addfilter(new stripcr); 164 if (bstripcr) filt->addfilter(new stripcr);
165 165
166 if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); 166 if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt);
167 if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); 167 if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter);
168 if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml); 168 if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml);
169 169
170 if (bdehyphen) filt->addfilter(new dehyphen); 170 if (bdehyphen) filt->addfilter(new dehyphen);
171 if (bunindent) filt->addfilter(new unindent); 171 if (bunindent) filt->addfilter(new unindent);
172 if (brepara) filt->addfilter(new repara); 172 if (brepara) filt->addfilter(new repara);
173 if (bonespace) filt->addfilter(new OnePara); 173 if (bonespace) filt->addfilter(new OnePara);
174 if (bindenter) filt->addfilter(new indenter(bindenter)); 174 if (bindenter) filt->addfilter(new indenter(bindenter));
175 if (bdblspce) filt->addfilter(new dblspce); 175 if (bdblspce) filt->addfilter(new dblspce);
176#ifdef REPALM 176#ifdef REPALM
177 if (brepalm) filt->addfilter(new repalm); 177 if (brepalm) filt->addfilter(new repalm);
178#endif 178#endif
179 if (bremap) filt->addfilter(new remap); 179 if (bremap) filt->addfilter(new remap);
180 if (bdepluck) filt->addfilter(new DePluck(pluckernextpart)); 180 if (bdepluck) filt->addfilter(new DePluck(pluckernextpart));
181 if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart)); 181 if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart));
182 if (bmakebold) filt->addfilter(new embolden); 182 if (bmakebold) filt->addfilter(new embolden);
183 if (bfulljust) filt->addfilter(new FullJust); 183 if (bfulljust) filt->addfilter(new FullJust);
184 return filt; 184 return filt;
185 } 185 }
186 186
187 187
188private slots: 188private slots:
189 void goHome(); 189 void goHome();
190 void goBack(); 190 void goBack();
191 void goForward(); 191 void goForward();
192 void doscroll(); 192 void doscroll();
193 void drawIt( QPainter * ); 193 void drawIt( QPainter * );
194 void paintEvent( QPaintEvent * ); 194 void paintEvent( QPaintEvent * );
195// void resizeEvent( QResizeEvent * p ) { update(); } 195// void resizeEvent( QResizeEvent * p ) { update(); }
196 void keyPressEvent(QKeyEvent*); 196 void keyPressEvent(QKeyEvent*);
197 void drawFonts(QPainter*); 197 void drawFonts(QPainter*);
198 private: 198 private:
199 void setTwoTouch(bool _b); 199 void setTwoTouch(bool _b);
200 void init(); 200 void init();
201 void mousePressEvent( QMouseEvent* ); 201 void mousePressEvent( QMouseEvent* );
202 void mouseReleaseEvent( QMouseEvent* ); 202 void mouseReleaseEvent( QMouseEvent* );
203// void mouseDoubleClickEvent( QMouseEvent* ); 203// void mouseDoubleClickEvent( QMouseEvent* );
diff --git a/noncore/apps/opie-reader/QTReaderApp.h b/noncore/apps/opie-reader/QTReaderApp.h
index ab6f60e..fe3eebf 100644
--- a/noncore/apps/opie-reader/QTReaderApp.h
+++ b/noncore/apps/opie-reader/QTReaderApp.h
@@ -354,89 +354,89 @@ private slots:
354 void colorChanged( const QColor &c ); 354 void colorChanged( const QColor &c );
355 void clear(); 355 void clear();
356 void updateCaption(); 356 void updateCaption();
357 void do_autogen(const QString&); 357 void do_autogen(const QString&);
358 void do_addbkmk(const QString&); 358 void do_addbkmk(const QString&);
359 bool findNextBookmark(size_t start); 359 bool findNextBookmark(size_t start);
360 360
361 private: 361 private:
362 362
363 QAction* m_scrollButton; 363 QAction* m_scrollButton;
364 364
365 QAction* m_buttonAction[MAX_ACTIONS]; 365 QAction* m_buttonAction[MAX_ACTIONS];
366 366
367 CBkmkSelector* bkmkselector; 367 CBkmkSelector* bkmkselector;
368 368
369 ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget, 369 ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget,
370 m_upTarget, m_downTarget; 370 m_upTarget, m_downTarget;
371 bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll; 371 bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll;
372 bool m_bcloseDisabled, m_disableesckey; 372 bool m_bcloseDisabled, m_disableesckey;
373 size_t searchStart; 373 size_t searchStart;
374#ifdef __ISEARCH 374#ifdef __ISEARCH
375 QStack<searchrecord>* searchStack; 375 QStack<searchrecord>* searchStack;
376 bool dosearch(size_t start, CDrawBuffer& test, const QString& arg); 376 bool dosearch(size_t start, CDrawBuffer& test, const QString& arg);
377#else 377#else
378 bool dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg); 378 bool dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg);
379#endif 379#endif
380 QWidgetStack *editorStack; 380 QWidgetStack *editorStack;
381 QTReader* reader; 381 QTReader* reader;
382 QComboBox* m_fontSelector; 382 QComboBox* m_fontSelector;
383// QToolBar /* *menu,*/ *fileBar; 383// QToolBar /* *menu,*/ *fileBar;
384 QToolBar *menubar, *fileBar, *navBar, *viewBar, *markBar; 384 QToolBar *menubar, *fileBar, *navBar, *viewBar, *markBar;
385#ifdef USEQPE 385#ifdef USEQPE
386 QMenuBar *mb; 386 QMenuBar *mb;
387#else 387#else
388 QMenuBar *mb; 388 QMenuBar *mb;
389#endif 389#endif
390 QFloatBar *searchBar, *regBar/*, *m_fontBar*/; 390 QFloatBar *searchBar, *regBar/*, *m_fontBar*/;
391 QToolBar /* *searchBar, *regBar,*/ *m_fontBar; 391 QToolBar /* *searchBar, *regBar,*/ *m_fontBar;
392 QLineEdit *searchEdit, *regEdit; 392 QLineEdit *searchEdit, *regEdit;
393 bool searchVisible; 393 bool searchVisible;
394 bool regVisible; 394 bool regVisible;
395 bool m_fontVisible, m_twoTouch; 395 bool m_fontVisible, m_twoTouch;
396 bool bFromDocView; 396 bool bFromDocView;
397 static unsigned long m_uid; 397 static unsigned long m_uid;
398 long unsigned get_unique_id() { return m_uid++; } 398 long unsigned get_unique_id() { return m_uid++; }
399 /* 399 /*
400 void resizeEvent( QResizeEvent * r) 400 void resizeEvent( QResizeEvent * r)
401 { 401 {
402// qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height()); 402// odebug << "resize:(" << r->oldSize().width() << "," << r->oldSize().height() << ")" << oendl;
403// qDebug("resize:(%u,%u)", r->size().width(), r->size().height()); 403// odebug << "resize:(" << r->size().width() << "," << r->size().height() << ")" << oendl;
404 // bgroup->move( width()-bgroup->width(), 0 ); 404 // bgroup->move( width()-bgroup->width(), 0 );
405 } 405 }
406 */ 406 */
407 CList<Bkmk>* pBkmklist; 407 CList<Bkmk>* pBkmklist;
408 CList<Bkmk>* pOpenlist; 408 CList<Bkmk>* pOpenlist;
409 infowin* m_infoWin; 409 infowin* m_infoWin;
410 GraphicWin* m_graphicwin; 410 GraphicWin* m_graphicwin;
411 QProgressBar* pbar; 411 QProgressBar* pbar;
412 bool m_fBkmksChanged; 412 bool m_fBkmksChanged;
413// int m_nRegAction; 413// int m_nRegAction;
414 regedit_type m_nRegAction; 414 regedit_type m_nRegAction;
415 bkmk_action m_nBkmkAction; 415 bkmk_action m_nBkmkAction;
416 QString m_autogenstr; 416 QString m_autogenstr;
417 bool m_dontSave; 417 bool m_dontSave;
418}; 418};
419 419
420//const int cAutoGen = 0; 420//const int cAutoGen = 0;
421//const int cAddBkmk = 1; 421//const int cAddBkmk = 1;
422//const int cDelBkmk = 2; 422//const int cDelBkmk = 2;
423//const int cGotoBkmk = 3; 423//const int cGotoBkmk = 3;
424//const int cRmBkmkFile = 4; 424//const int cRmBkmkFile = 4;
425//const int cJump = 5; 425//const int cJump = 5;
426//const int cMonoSpace = 6; 426//const int cMonoSpace = 6;
427//const int cOverlap = 7; 427//const int cOverlap = 7;
428//const int cSetTarget = 8; 428//const int cSetTarget = 8;
429//const int cOpenFile = 9; 429//const int cOpenFile = 9;
430//const int cSetPipeTarget = 10; 430//const int cSetPipeTarget = 10;
431//const int cSetConfigName = 11; 431//const int cSetConfigName = 11;
432//const int cMargin = 12; 432//const int cMargin = 12;
433//const int cExtraSpace = 14; 433//const int cExtraSpace = 14;
434//const int cExtraLead = 15; 434//const int cExtraLead = 15;
435//const int cGfxSize = 16; 435//const int cGfxSize = 16;
436//const int cChooseFont = 2; 436//const int cChooseFont = 2;
437//const int cChooseEncoding = 1; 437//const int cChooseEncoding = 1;
438 438
439#endif 439#endif
440 440
441 441
442 442
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.h b/noncore/apps/tinykate/libkate/document/katedocument.h
index 9d8ec6a..969be87 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.h
+++ b/noncore/apps/tinykate/libkate/document/katedocument.h
@@ -31,97 +31,97 @@
31 but WITHOUT ANY WARRANTY; without even the implied warranty of 31 but WITHOUT ANY WARRANTY; without even the implied warranty of
32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 Library General Public License for more details. 33 Library General Public License for more details.
34 34
35 You should have received a copy of the GNU Library General Public License 35 You should have received a copy of the GNU Library General Public License
36 along with this library; see the file COPYING.LIB. If not, write to 36 along with this library; see the file COPYING.LIB. If not, write to
37 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 37 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
38 Boston, MA 02111-1307, USA. 38 Boston, MA 02111-1307, USA.
39*/ 39*/
40 40
41#ifndef kate_document_h 41#ifndef kate_document_h
42#define kate_document_h 42#define kate_document_h
43 43
44 44
45#include <qobject.h> 45#include <qobject.h>
46#include <qlist.h> 46#include <qlist.h>
47#include <qcolor.h> 47#include <qcolor.h>
48#include <qfont.h> 48#include <qfont.h>
49#include <qfontmetrics.h> 49#include <qfontmetrics.h>
50#include <qdatetime.h> 50#include <qdatetime.h>
51#include <qfileinfo.h> 51#include <qfileinfo.h>
52 52
53#include "../view/kateview.h" 53#include "../view/kateview.h"
54#include "katehighlight.h" 54#include "katehighlight.h"
55#include "katebuffer.h" 55#include "katebuffer.h"
56#include "katetextline.h" 56#include "katetextline.h"
57 57
58 58
59#include <qptrdict.h> 59#include <qptrdict.h>
60 60
61class KateCmd; 61class KateCmd;
62 62
63class CachedFontMetrics : public QFontMetrics { 63class CachedFontMetrics : public QFontMetrics {
64private: 64private:
65 short *warray[256]; 65 short *warray[256];
66public: 66public:
67 CachedFontMetrics(const QFont& f) : QFontMetrics(f) { 67 CachedFontMetrics(const QFont& f) : QFontMetrics(f) {
68 for (int i=0; i<256; i++) warray[i]=0; 68 for (int i=0; i<256; i++) warray[i]=0;
69 } 69 }
70 ~CachedFontMetrics() { 70 ~CachedFontMetrics() {
71 for (int i=0; i<256; i++) 71 for (int i=0; i<256; i++)
72 if (warray[i]) delete[] warray[i]; 72 if (warray[i]) delete[] warray[i];
73 } 73 }
74 int width(QChar c) { 74 int width(QChar c) {
75 uchar cell=c.cell(); 75 uchar cell=c.cell();
76 uchar row=c.row(); 76 uchar row=c.row();
77 short *wa=warray[row]; 77 short *wa=warray[row];
78 if (!wa) { 78 if (!wa) {
79 // qDebug("create row: %d",row); 79 // odebug << "create row: " << row << oendl;
80 wa=warray[row]=new short[256]; 80 wa=warray[row]=new short[256];
81 for (int i=0; i<256; i++) wa[i]=-1; 81 for (int i=0; i<256; i++) wa[i]=-1;
82 } 82 }
83 if (wa[cell]<0) wa[cell]=(short) QFontMetrics::width(c); 83 if (wa[cell]<0) wa[cell]=(short) QFontMetrics::width(c);
84 return (int)wa[cell]; 84 return (int)wa[cell];
85 } 85 }
86 int width(QString s) { return QFontMetrics::width(s); } 86 int width(QString s) { return QFontMetrics::width(s); }
87}; 87};
88 88
89class Attribute { 89class Attribute {
90 public: 90 public:
91 Attribute() { ; }; 91 Attribute() { ; };
92 92
93 QColor col; 93 QColor col;
94 QColor selCol; 94 QColor selCol;
95 bool bold; 95 bool bold;
96 bool italic; 96 bool italic;
97}; 97};
98 98
99class KateAction { 99class KateAction {
100 public: 100 public:
101 enum Action {replace, wordWrap, wordUnWrap, newLine, delLine, 101 enum Action {replace, wordWrap, wordUnWrap, newLine, delLine,
102 insLine, killLine};//, doubleLine, removeLine}; 102 insLine, killLine};//, doubleLine, removeLine};
103 103
104 KateAction(Action, PointStruc &cursor, int len = 0, 104 KateAction(Action, PointStruc &cursor, int len = 0,
105 const QString &text = QString::null); 105 const QString &text = QString::null);
106 106
107 Action action; 107 Action action;
108 PointStruc cursor; 108 PointStruc cursor;
109 int len; 109 int len;
110 QString text; 110 QString text;
111 KateAction *next; 111 KateAction *next;
112}; 112};
113 113
114class KateActionGroup { 114class KateActionGroup {
115 public: 115 public:
116 // the undo group types 116 // the undo group types
117 enum { ugNone, // 117 enum { ugNone, //
118 ugPaste, // paste 118 ugPaste, // paste
119 ugDelBlock, // delete/replace selected text 119 ugDelBlock, // delete/replace selected text
120 ugIndent, // indent 120 ugIndent, // indent
121 ugUnindent, // unindent 121 ugUnindent, // unindent
122 ugComment, // comment 122 ugComment, // comment
123 ugUncomment, // uncomment 123 ugUncomment, // uncomment
124 ugReplace, // text search/replace 124 ugReplace, // text search/replace
125 ugSpell, // spell check 125 ugSpell, // spell check
126 ugInsChar, // char type/deleting 126 ugInsChar, // char type/deleting
127 ugDelChar, // '' '' 127 ugDelChar, // '' ''
diff --git a/noncore/apps/tinykate/libkate/qt3back/qregexp3.cpp b/noncore/apps/tinykate/libkate/qt3back/qregexp3.cpp
index a2c680f..78635b2 100644
--- a/noncore/apps/tinykate/libkate/qt3back/qregexp3.cpp
+++ b/noncore/apps/tinykate/libkate/qt3back/qregexp3.cpp
@@ -1,102 +1,108 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of QRegExp class 4** Implementation of QRegExp class
5** 5**
6** Created : 950126 6** Created : 950126
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#if QT_VERSION >=300 37#if QT_VERSION >=300
38#error QRegExp3 is now in QT 3 use QRegExp instead 38#error QRegExp3 is now in QT 3 use QRegExp instead
39#endif 39#endif
40 40
41#include "qarray.h"
42#include "qbitarray.h"
43#include "qcache.h"
44#include "qintdict.h"
45#include "qmap.h"
46#if QT_VERSION < 300 41#if QT_VERSION < 300
47#include "./qregexp3.h" 42#include "./qregexp3.h"
48#else 43#else
49#include "qregexp.h" 44#include "qregexp.h"
50#endif 45#endif
51#include "qstring.h"
52#include "qtl.h"
53#include "qvector.h"
54 46
47/* OPIE */
48#include <opie2/odebug.h>
49
50/* QT */
51#include <qarray.h>
52#include <qbitarray.h>
53#include <qcache.h>
54#include <qintdict.h>
55#include <qmap.h>
56#include <qstring.h>
57#include <qtl.h>
58#include <qvector.h>
59
60/* STD */
55#include <limits.h> 61#include <limits.h>
56 62
57/* 63/*
58 WARNING! Be sure to read qregexp.tex before modifying this file. 64 WARNING! Be sure to read qregexp.tex before modifying this file.
59*/ 65*/
60 66
61/*! 67/*!
62 \class QRegExp3 qregexp.h 68 \class QRegExp3 qregexp.h
63 69
64 \brief The QRegExp class provides pattern matching using regular expressions. 70 \brief The QRegExp class provides pattern matching using regular expressions.
65 71
66 \ingroup tools 72 \ingroup tools
67 \ingroup misc 73 \ingroup misc
68 \ingroup shared 74 \ingroup shared
69 75
70 76
71 Regular expressions, "regexps", provide a way to find patterns 77 Regular expressions, "regexps", provide a way to find patterns
72 within text. This is useful in many contexts, for example: 78 within text. This is useful in many contexts, for example:
73 79
74 <ol> 80 <ol>
75 <li>\e Validation. A regexp can be used to check whether a piece of 81 <li>\e Validation. A regexp can be used to check whether a piece of
76 text meets some criteria, e.g. is an integer or contains no 82 text meets some criteria, e.g. is an integer or contains no
77 whitespace. 83 whitespace.
78 <li>\e Searching. Regexps provide a much more powerful means of 84 <li>\e Searching. Regexps provide a much more powerful means of
79 searching text than simple string matching does. For example we can 85 searching text than simple string matching does. For example we can
80 create a regexp which says "find one of the words 'mail', 'letter' 86 create a regexp which says "find one of the words 'mail', 'letter'
81 or 'correspondence' but not any of the words 'email', 'mailman' 87 or 'correspondence' but not any of the words 'email', 'mailman'
82 'mailer', 'letterbox' etc." 88 'mailer', 'letterbox' etc."
83 <li><em>Search and Replace.</em> A regexp can be used to replace a 89 <li><em>Search and Replace.</em> A regexp can be used to replace a
84 pattern with a piece of text, for example replace all occurrences of 90 pattern with a piece of text, for example replace all occurrences of
85 '&' with '\&amp;' except where the '&' is already followed by 91 '&' with '\&amp;' except where the '&' is already followed by
86 'amp;'. 92 'amp;'.
87 <li><em>String Splitting.</em> A regexp can be used to identify 93 <li><em>String Splitting.</em> A regexp can be used to identify
88 where a string should be split into its component fields, e.g. 94 where a string should be split into its component fields, e.g.
89 splitting tab delimited strings. 95 splitting tab delimited strings.
90 </ol> 96 </ol>
91 97
92 We present a very brief introduction to regexps, a description of 98 We present a very brief introduction to regexps, a description of
93 Qt's regexp language, some code examples, and finally the function 99 Qt's regexp language, some code examples, and finally the function
94 documentation. QRegExp is modelled on Perl's regexp engine and fully 100 documentation. QRegExp is modelled on Perl's regexp engine and fully
95 supports Unicode. QRegExp may also be used in the weaker 'wildcard' 101 supports Unicode. QRegExp may also be used in the weaker 'wildcard'
96 (globbing) mode which works in a similar way to command shells. A 102 (globbing) mode which works in a similar way to command shells. A
97 good text on regexps is <i>Mastering Regular Expressions: Powerful 103 good text on regexps is <i>Mastering Regular Expressions: Powerful
98 Techniques for Perl and Other Tools</i> by Jeffrey E. Friedl, ISBN 104 Techniques for Perl and Other Tools</i> by Jeffrey E. Friedl, ISBN
99 1565922573. 105 1565922573.
100 106
101 Experienced regexp users may prefer to skip the introduction and 107 Experienced regexp users may prefer to skip the introduction and
102 go directly to the relevant information: 108 go directly to the relevant information:
@@ -1386,140 +1392,140 @@ void QRegExpEngine::setupBadCharHeuristic( int minLen,
1386/* 1392/*
1387 This function chooses between the good-string and the bad-character 1393 This function chooses between the good-string and the bad-character
1388 heuristics. It computes two scores and chooses the heuristic with the highest 1394 heuristics. It computes two scores and chooses the heuristic with the highest
1389 score. 1395 score.
1390 1396
1391 Here are some common-sense constraints on the scores that should be respected 1397 Here are some common-sense constraints on the scores that should be respected
1392 if the formulas are ever modified: (1) If goodStr is empty, the good-string 1398 if the formulas are ever modified: (1) If goodStr is empty, the good-string
1393 heuristic scores 0. (2) If the search is case insensitive, the good-string 1399 heuristic scores 0. (2) If the search is case insensitive, the good-string
1394 heuristic should be used, unless it scores 0. (Case insensitivity 1400 heuristic should be used, unless it scores 0. (Case insensitivity
1395 turns all entries of occ1 to 0.) (3) If (goodLateStart - goodEarlyStart) is 1401 turns all entries of occ1 to 0.) (3) If (goodLateStart - goodEarlyStart) is
1396 big, the good-string heuristic should score less. 1402 big, the good-string heuristic should score less.
1397*/ 1403*/
1398void QRegExpEngine::heuristicallyChooseHeuristic() 1404void QRegExpEngine::heuristicallyChooseHeuristic()
1399{ 1405{
1400 int i; 1406 int i;
1401 1407
1402 if ( minl == 0 ) 1408 if ( minl == 0 )
1403 return; 1409 return;
1404 1410
1405 /* 1411 /*
1406 Magic formula: The good string has to constitute a good proportion of the 1412 Magic formula: The good string has to constitute a good proportion of the
1407 minimum-length string, and appear at a more-or-less known index. 1413 minimum-length string, and appear at a more-or-less known index.
1408 */ 1414 */
1409 int goodStringScore = ( 64 * goodStr.length() / minl ) - 1415 int goodStringScore = ( 64 * goodStr.length() / minl ) -
1410 ( goodLateStart - goodEarlyStart ); 1416 ( goodLateStart - goodEarlyStart );
1411 1417
1412 /* 1418 /*
1413 Less magic formula: We pick a couple of characters at random, and check 1419 Less magic formula: We pick a couple of characters at random, and check
1414 whether they are good or bad. 1420 whether they are good or bad.
1415 */ 1421 */
1416 int badCharScore = 0; 1422 int badCharScore = 0;
1417 int step = QMAX( 1, NumBadChars / 32 ); 1423 int step = QMAX( 1, NumBadChars / 32 );
1418 for ( i = 1; i < NumBadChars; i += step ) { 1424 for ( i = 1; i < NumBadChars; i += step ) {
1419 if ( occ1[i] == NoOccurrence ) 1425 if ( occ1[i] == NoOccurrence )
1420 badCharScore += minl; 1426 badCharScore += minl;
1421 else 1427 else
1422 badCharScore += occ1[i]; 1428 badCharScore += occ1[i];
1423 } 1429 }
1424 badCharScore /= minl; 1430 badCharScore /= minl;
1425 1431
1426 useGoodStringHeuristic = ( goodStringScore > badCharScore ); 1432 useGoodStringHeuristic = ( goodStringScore > badCharScore );
1427} 1433}
1428#endif 1434#endif
1429 1435
1430#if defined(QT_DEBUG) 1436#if defined(QT_DEBUG)
1431void QRegExpEngine::dump() const 1437void QRegExpEngine::dump() const
1432{ 1438{
1433 int i, j; 1439 int i, j;
1434 qDebug( "Case %ssensitive engine", cs ? "" : "in" ); 1440 odebug << "Case " << (cs ? "" : "in") << "sensitive engine" << oendl;
1435 qDebug( " States" ); 1441 odebug << " States" << oendl;
1436 for ( i = 0; i < ns; i++ ) { 1442 for ( i = 0; i < ns; i++ ) {
1437 qDebug( " %d%s", i, 1443 odebug << " " << i
1438 i == InitialState ? " (initial)" : 1444 << (i == InitialState ? " (initial)" : i == FinalState ? " (final)" : "") << oendl;
1439 i == FinalState ? " (final)" : "" ); 1445
1440#ifndef QT_NO_REGEXP_CAPTURE 1446#ifndef QT_NO_REGEXP_CAPTURE
1441 qDebug( " in atom %d", s[i]->atom ); 1447 odebug << " in atom " << s[i]->atom << oendl;
1442#endif 1448#endif
1443 int m = s[i]->match; 1449 int m = s[i]->match;
1444 if ( (m & CharClassBit) != 0 ) { 1450 if ( (m & CharClassBit) != 0 ) {
1445 qDebug( " match character class %d", m ^ CharClassBit ); 1451 odebug << " match character class " << (m ^ CharClassBit) << oendl;
1446#ifndef QT_NO_REGEXP_CCLASS 1452#ifndef QT_NO_REGEXP_CCLASS
1447 cl[m ^ CharClassBit]->dump(); 1453 cl[m ^ CharClassBit]->dump();
1448#else 1454#else
1449 qDebug( " negative character class" ); 1455 odebug << " negative character class" << oendl;
1450#endif 1456#endif
1451 } else if ( (m & BackRefBit) != 0 ) { 1457 } else if ( (m & BackRefBit) != 0 ) {
1452 qDebug( " match back-reference %d", m ^ BackRefBit ); 1458 odebug << " match back-reference " << (m ^ BackRefBit) << oendl;
1453 } else if ( m >= 0x20 && m <= 0x7e ) { 1459 } else if ( m >= 0x20 && m <= 0x7e ) {
1454 qDebug( " match 0x%.4x (%c)", m, m ); 1460 odebug << " match " << QString().sprintf( "0x%.4x", m) << " (" << m << ")" << oendl;
1461
1455 } else { 1462 } else {
1456 qDebug( " match 0x%.4x", m ); 1463 odebug << " match " << QString().sprintf( "0x%.4x", m) << oendl;
1457 } 1464 }
1458 for ( j = 0; j < (int) s[i]->outs.size(); j++ ) { 1465 for ( j = 0; j < (int) s[i]->outs.size(); j++ ) {
1459 int next = s[i]->outs[j]; 1466 int next = s[i]->outs[j];
1460 qDebug( " -> %d", next ); 1467 odebug << " -> " << next << oendl;
1461 if ( s[i]->reenter != 0 && s[i]->reenter->contains(next) ) 1468 if ( s[i]->reenter != 0 && s[i]->reenter->contains(next) )
1462 qDebug( " [reenter %d]", (*s[i]->reenter)[next] ); 1469 odebug << " [reenter " << (*s[i]->reenter)[next] << "]" << oendl;
1463 if ( s[i]->anchors != 0 && at(*s[i]->anchors, next) != 0 ) 1470 if ( s[i]->anchors != 0 && at(*s[i]->anchors, next) != 0 )
1464 qDebug( " [anchors 0x%.8x]", (*s[i]->anchors)[next] ); 1471 odebug << " [anchors " << QString().sprintf( "0x%.8x]", (*s[i]->anchors)[next] ) << oendl;
1465 } 1472 }
1466 } 1473 }
1467#ifndef QT_NO_REGEXP_CAPTURE 1474#ifndef QT_NO_REGEXP_CAPTURE
1468 if ( nf > 0 ) { 1475 if ( nf > 0 ) {
1469 qDebug( " Atom Parent Capture" ); 1476 odebug << " Atom Parent Capture" << oendl;
1470 for ( i = 0; i < nf; i++ ) 1477 for ( i = 0; i < nf; i++ )
1471 qDebug( " %6d %6d %6d", i, f[i].parent, f[i].capture ); 1478 odebug << QString().sprintf(" %6d %6d %6d", i, f[i].parent, f[i].capture ) << oendl;
1472 } 1479 }
1473#endif 1480#endif
1474#ifndef QT_NO_REGEXP_ANCHOR_ALT 1481#ifndef QT_NO_REGEXP_ANCHOR_ALT
1475 for ( i = 0; i < (int) aa.size(); i++ ) 1482 for ( i = 0; i < (int) aa.size(); i++ )
1476 qDebug( " Anchor alternation 0x%.8x: 0x%.8x 0x%.9x", i, aa[i].a, 1483 odebug << QString().sprintf(" Anchor alternation 0x%.8x: 0x%.8x 0x%.9x", i, aa[i].a, aa[i].b ) << oendl;
1477 aa[i].b );
1478#endif 1484#endif
1479} 1485}
1480#endif 1486#endif
1481 1487
1482void QRegExpEngine::setup( bool caseSensitive ) 1488void QRegExpEngine::setup( bool caseSensitive )
1483{ 1489{
1484#ifndef QT_NO_REGEXP_OPTIM 1490#ifndef QT_NO_REGEXP_OPTIM
1485 if ( engCount++ == 0 ) { 1491 if ( engCount++ == 0 ) {
1486 noOccurrences = new QArray<int>( NumBadChars ); 1492 noOccurrences = new QArray<int>( NumBadChars );
1487 firstOccurrenceAtZero = new QArray<int>( NumBadChars ); 1493 firstOccurrenceAtZero = new QArray<int>( NumBadChars );
1488 noOccurrences->fill( NoOccurrence ); 1494 noOccurrences->fill( NoOccurrence );
1489 firstOccurrenceAtZero->fill( 0 ); 1495 firstOccurrenceAtZero->fill( 0 );
1490 } 1496 }
1491#endif 1497#endif
1492 s.setAutoDelete( TRUE ); 1498 s.setAutoDelete( TRUE );
1493 s.resize( 32 ); 1499 s.resize( 32 );
1494 ns = 0; 1500 ns = 0;
1495#ifndef QT_NO_REGEXP_CAPTURE 1501#ifndef QT_NO_REGEXP_CAPTURE
1496 f.resize( 32 ); 1502 f.resize( 32 );
1497 nf = 0; 1503 nf = 0;
1498 cf = -1; 1504 cf = -1;
1499#endif 1505#endif
1500 realncap = 0; 1506 realncap = 0;
1501 ncap = 0; 1507 ncap = 0;
1502#ifndef QT_NO_REGEXP_CCLASS 1508#ifndef QT_NO_REGEXP_CCLASS
1503 cl.setAutoDelete( TRUE ); 1509 cl.setAutoDelete( TRUE );
1504#endif 1510#endif
1505#ifndef QT_NO_REGEXP_LOOKAHEAD 1511#ifndef QT_NO_REGEXP_LOOKAHEAD
1506 ahead.setAutoDelete( TRUE ); 1512 ahead.setAutoDelete( TRUE );
1507#endif 1513#endif
1508#ifndef QT_NO_REGEXP_OPTIM 1514#ifndef QT_NO_REGEXP_OPTIM
1509 caretAnchored = TRUE; 1515 caretAnchored = TRUE;
1510#endif 1516#endif
1511 valid = FALSE; 1517 valid = FALSE;
1512 cs = caseSensitive; 1518 cs = caseSensitive;
1513#ifndef QT_NO_REGEXP_BACKREF 1519#ifndef QT_NO_REGEXP_BACKREF
1514 nbrefs = 0; 1520 nbrefs = 0;
1515#endif 1521#endif
1516#ifndef QT_NO_REGEXP_OPTIM 1522#ifndef QT_NO_REGEXP_OPTIM
1517 useGoodStringHeuristic = FALSE; 1523 useGoodStringHeuristic = FALSE;
1518 minl = 0; 1524 minl = 0;
1519 occ1 = *firstOccurrenceAtZero; 1525 occ1 = *firstOccurrenceAtZero;
1520#endif 1526#endif
1521 mmCapturedNoMatch.fill( -1, 2 ); 1527 mmCapturedNoMatch.fill( -1, 2 );
1522} 1528}
1523 1529
1524int QRegExpEngine::setupState( int match ) 1530int QRegExpEngine::setupState( int match )
1525{ 1531{
@@ -2151,103 +2157,103 @@ void QRegExpEngine::CharClass::addRange( ushort from, ushort to )
2151{ 2157{
2152 if ( from > to ) 2158 if ( from > to )
2153 qSwap( from, to ); 2159 qSwap( from, to );
2154 int n = r.size(); 2160 int n = r.size();
2155 r.resize( n + 1 ); 2161 r.resize( n + 1 );
2156 r[n].from = from; 2162 r[n].from = from;
2157 r[n].to = to; 2163 r[n].to = to;
2158 2164
2159#ifndef QT_NO_REGEXP_OPTIM 2165#ifndef QT_NO_REGEXP_OPTIM
2160 int i; 2166 int i;
2161 2167
2162 if ( to - from < NumBadChars ) { 2168 if ( to - from < NumBadChars ) {
2163 occ1.detach(); 2169 occ1.detach();
2164 if ( from % NumBadChars <= to % NumBadChars ) { 2170 if ( from % NumBadChars <= to % NumBadChars ) {
2165 for ( i = from % NumBadChars; i <= to % NumBadChars; i++ ) 2171 for ( i = from % NumBadChars; i <= to % NumBadChars; i++ )
2166 occ1[i] = 0; 2172 occ1[i] = 0;
2167 } else { 2173 } else {
2168 for ( i = 0; i <= to % NumBadChars; i++ ) 2174 for ( i = 0; i <= to % NumBadChars; i++ )
2169 occ1[i] = 0; 2175 occ1[i] = 0;
2170 for ( i = from % NumBadChars; i < NumBadChars; i++ ) 2176 for ( i = from % NumBadChars; i < NumBadChars; i++ )
2171 occ1[i] = 0; 2177 occ1[i] = 0;
2172 } 2178 }
2173 } else { 2179 } else {
2174 occ1 = *firstOccurrenceAtZero; 2180 occ1 = *firstOccurrenceAtZero;
2175 } 2181 }
2176#endif 2182#endif
2177} 2183}
2178 2184
2179bool QRegExpEngine::CharClass::in( QChar ch ) const 2185bool QRegExpEngine::CharClass::in( QChar ch ) const
2180{ 2186{
2181#ifndef QT_NO_REGEXP_OPTIM 2187#ifndef QT_NO_REGEXP_OPTIM
2182 if ( occ1[BadChar(ch)] == NoOccurrence ) 2188 if ( occ1[BadChar(ch)] == NoOccurrence )
2183 return n; 2189 return n;
2184#endif 2190#endif
2185 2191
2186 if ( c != 0 && (c & (1 << (int) ch.category())) != 0 ) 2192 if ( c != 0 && (c & (1 << (int) ch.category())) != 0 )
2187 return !n; 2193 return !n;
2188 for ( int i = 0; i < (int) r.size(); i++ ) { 2194 for ( int i = 0; i < (int) r.size(); i++ ) {
2189 if ( ch.unicode() >= r[i].from && ch.unicode() <= r[i].to ) 2195 if ( ch.unicode() >= r[i].from && ch.unicode() <= r[i].to )
2190 return !n; 2196 return !n;
2191 } 2197 }
2192 return n; 2198 return n;
2193} 2199}
2194 2200
2195#if defined(QT_DEBUG) 2201#if defined(QT_DEBUG)
2196void QRegExpEngine::CharClass::dump() const 2202void QRegExpEngine::CharClass::dump() const
2197{ 2203{
2198 int i; 2204 int i;
2199 qDebug( " %stive character class", n ? "nega" : "posi" ); 2205 odebug << " " << (n ? "nega" : "posi") << "tive character class" << oendl;
2200#ifndef QT_NO_REGEXP_CCLASS 2206#ifndef QT_NO_REGEXP_CCLASS
2201 if ( c != 0 ) 2207 if ( c != 0 )
2202 qDebug( " categories 0x%.8x", c ); 2208 odebug << QString().sprintf(" categories 0x%.8x", c ) << oendl;
2203#endif 2209#endif
2204 for ( i = 0; i < (int) r.size(); i++ ) 2210 for ( i = 0; i < (int) r.size(); i++ )
2205 qDebug( " 0x%.4x through 0x%.4x", r[i].from, r[i].to ); 2211 odebug << QString().sprintf(" 0x%.4x through 0x%.4x", r[i].from, r[i].to ) << oendl;
2206} 2212}
2207#endif 2213#endif
2208#endif 2214#endif
2209 2215
2210QRegExpEngine::Box::Box( QRegExpEngine *engine ) 2216QRegExpEngine::Box::Box( QRegExpEngine *engine )
2211 : eng( engine ), skipanchors( 0 ) 2217 : eng( engine ), skipanchors( 0 )
2212#ifndef QT_NO_REGEXP_OPTIM 2218#ifndef QT_NO_REGEXP_OPTIM
2213 , earlyStart( 0 ), lateStart( 0 ), maxl( 0 ), occ1( *noOccurrences ) 2219 , earlyStart( 0 ), lateStart( 0 ), maxl( 0 ), occ1( *noOccurrences )
2214#endif 2220#endif
2215{ 2221{
2216 minl = 0; 2222 minl = 0;
2217} 2223}
2218 2224
2219QRegExpEngine::Box& QRegExpEngine::Box::operator=( const Box& b ) 2225QRegExpEngine::Box& QRegExpEngine::Box::operator=( const Box& b )
2220{ 2226{
2221 eng = b.eng; 2227 eng = b.eng;
2222 ls = b.ls; 2228 ls = b.ls;
2223 rs = b.rs; 2229 rs = b.rs;
2224 lanchors = b.lanchors; 2230 lanchors = b.lanchors;
2225 ranchors = b.ranchors; 2231 ranchors = b.ranchors;
2226 skipanchors = b.skipanchors; 2232 skipanchors = b.skipanchors;
2227#ifndef QT_NO_REGEXP_OPTIM 2233#ifndef QT_NO_REGEXP_OPTIM
2228 earlyStart = b.earlyStart; 2234 earlyStart = b.earlyStart;
2229 lateStart = b.lateStart; 2235 lateStart = b.lateStart;
2230 str = b.str; 2236 str = b.str;
2231 leftStr = b.leftStr; 2237 leftStr = b.leftStr;
2232 rightStr = b.rightStr; 2238 rightStr = b.rightStr;
2233 maxl = b.maxl; 2239 maxl = b.maxl;
2234 occ1 = b.occ1; 2240 occ1 = b.occ1;
2235#endif 2241#endif
2236 minl = b.minl; 2242 minl = b.minl;
2237 return *this; 2243 return *this;
2238} 2244}
2239 2245
2240void QRegExpEngine::Box::set( QChar ch ) 2246void QRegExpEngine::Box::set( QChar ch )
2241{ 2247{
2242 ls.resize( 1 ); 2248 ls.resize( 1 );
2243 ls[0] = eng->createState( ch ); 2249 ls[0] = eng->createState( ch );
2244 rs = ls; 2250 rs = ls;
2245 rs.detach(); 2251 rs.detach();
2246#ifndef QT_NO_REGEXP_OPTIM 2252#ifndef QT_NO_REGEXP_OPTIM
2247 str = ch; 2253 str = ch;
2248 leftStr = ch; 2254 leftStr = ch;
2249 rightStr = ch; 2255 rightStr = ch;
2250 maxl = 1; 2256 maxl = 1;
2251 occ1.detach(); 2257 occ1.detach();
2252 occ1[BadChar(ch)] = 0; 2258 occ1[BadChar(ch)] = 0;
2253#endif 2259#endif
@@ -2401,112 +2407,112 @@ void QRegExpEngine::Box::opt()
2401 str = QString::null; 2407 str = QString::null;
2402 leftStr = QString::null; 2408 leftStr = QString::null;
2403 rightStr = QString::null; 2409 rightStr = QString::null;
2404#endif 2410#endif
2405 skipanchors = 0; 2411 skipanchors = 0;
2406 minl = 0; 2412 minl = 0;
2407} 2413}
2408 2414
2409void QRegExpEngine::Box::catAnchor( int a ) 2415void QRegExpEngine::Box::catAnchor( int a )
2410{ 2416{
2411 if ( a != 0 ) { 2417 if ( a != 0 ) {
2412 for ( int i = 0; i < (int) rs.size(); i++ ) { 2418 for ( int i = 0; i < (int) rs.size(); i++ ) {
2413 a = eng->anchorConcatenation( at(ranchors, rs[i]), a ); 2419 a = eng->anchorConcatenation( at(ranchors, rs[i]), a );
2414 ranchors.insert( rs[i], a ); 2420 ranchors.insert( rs[i], a );
2415 } 2421 }
2416 if ( minl == 0 ) 2422 if ( minl == 0 )
2417 skipanchors = eng->anchorConcatenation( skipanchors, a ); 2423 skipanchors = eng->anchorConcatenation( skipanchors, a );
2418 } 2424 }
2419} 2425}
2420 2426
2421#ifndef QT_NO_REGEXP_OPTIM 2427#ifndef QT_NO_REGEXP_OPTIM
2422void QRegExpEngine::Box::setupHeuristics() 2428void QRegExpEngine::Box::setupHeuristics()
2423{ 2429{
2424 eng->setupGoodStringHeuristic( earlyStart, lateStart, str ); 2430 eng->setupGoodStringHeuristic( earlyStart, lateStart, str );
2425 2431
2426 /* 2432 /*
2427 A regular expression such as 112|1 has occ1['2'] = 2 and minl = 1 at this 2433 A regular expression such as 112|1 has occ1['2'] = 2 and minl = 1 at this
2428 point. An entry of occ1 has to be at most minl or infinity for the rest 2434 point. An entry of occ1 has to be at most minl or infinity for the rest
2429 of the algorithm to go well. 2435 of the algorithm to go well.
2430 2436
2431 We waited until here before normalizing these cases (instead of doing it 2437 We waited until here before normalizing these cases (instead of doing it
2432 in Box::orx()) because sometimes things improve by themselves; consider 2438 in Box::orx()) because sometimes things improve by themselves; consider
2433 (112|1)34. 2439 (112|1)34.
2434 */ 2440 */
2435 for ( int i = 0; i < NumBadChars; i++ ) { 2441 for ( int i = 0; i < NumBadChars; i++ ) {
2436 if ( occ1[i] != NoOccurrence && occ1[i] >= minl ) 2442 if ( occ1[i] != NoOccurrence && occ1[i] >= minl )
2437 occ1[i] = minl; 2443 occ1[i] = minl;
2438 } 2444 }
2439 eng->setupBadCharHeuristic( minl, occ1 ); 2445 eng->setupBadCharHeuristic( minl, occ1 );
2440 2446
2441 eng->heuristicallyChooseHeuristic(); 2447 eng->heuristicallyChooseHeuristic();
2442} 2448}
2443#endif 2449#endif
2444 2450
2445#if defined(QT_DEBUG) 2451#if defined(QT_DEBUG)
2446void QRegExpEngine::Box::dump() const 2452void QRegExpEngine::Box::dump() const
2447{ 2453{
2448 int i; 2454 int i;
2449 qDebug( "Box of at least %d character%s", minl, minl == 1 ? "" : "s" ); 2455 odebug << "Box of at least " << minl << " character" << (minl == 1 ? "" : "s") << oendl;
2450 qDebug( " Left states:" ); 2456 odebug << " Left states:" << oendl;
2451 for ( i = 0; i < (int) ls.size(); i++ ) { 2457 for ( i = 0; i < (int) ls.size(); i++ ) {
2452 if ( at(lanchors, ls[i]) == 0 ) 2458 if ( at(lanchors, ls[i]) == 0 )
2453 qDebug( " %d", ls[i] ); 2459 odebug << " " << ls[i] << oendl;
2454 else 2460 else
2455 qDebug( " %d [anchors 0x%.8x]", ls[i], lanchors[ls[i]] ); 2461 odebug << " " << ls[i] << QString().sprintf(" [anchors 0x%.8x]", lanchors[ls[i]]) << oendl;
2456 } 2462 }
2457 qDebug( " Right states:" ); 2463 odebug << " Right states:" << oendl;
2458 for ( i = 0; i < (int) rs.size(); i++ ) { 2464 for ( i = 0; i < (int) rs.size(); i++ ) {
2459 if ( at(ranchors, ls[i]) == 0 ) 2465 if ( at(ranchors, ls[i]) == 0 )
2460 qDebug( " %d", rs[i] ); 2466 odebug << " " << rs[i] << oendl;
2461 else 2467 else
2462 qDebug( " %d [anchors 0x%.8x]", rs[i], ranchors[rs[i]] ); 2468 odebug << " " << rs[i] << QString().sprintf(" [anchors 0x%.8x]", ranchors[rs[i]]) << oendl;
2463 } 2469 }
2464 qDebug( " Skip anchors: 0x%.8x", skipanchors ); 2470 odebug << QString().sprintf(" Skip anchors: 0x%.8x", skipanchors) << oendl;
2465} 2471}
2466#endif 2472#endif
2467 2473
2468void QRegExpEngine::Box::addAnchorsToEngine( const Box& to ) const 2474void QRegExpEngine::Box::addAnchorsToEngine( const Box& to ) const
2469{ 2475{
2470 for ( int i = 0; i < (int) to.ls.size(); i++ ) { 2476 for ( int i = 0; i < (int) to.ls.size(); i++ ) {
2471 for ( int j = 0; j < (int) rs.size(); j++ ) { 2477 for ( int j = 0; j < (int) rs.size(); j++ ) {
2472 int a = eng->anchorConcatenation( at(ranchors, rs[j]), 2478 int a = eng->anchorConcatenation( at(ranchors, rs[j]),
2473 at(to.lanchors, to.ls[i]) ); 2479 at(to.lanchors, to.ls[i]) );
2474 eng->addAnchors( rs[j], to.ls[i], a ); 2480 eng->addAnchors( rs[j], to.ls[i], a );
2475 } 2481 }
2476 } 2482 }
2477} 2483}
2478 2484
2479int QRegExpEngine::getChar() 2485int QRegExpEngine::getChar()
2480{ 2486{
2481 return ( yyPos == yyLen ) ? EOS : yyIn[yyPos++].unicode(); 2487 return ( yyPos == yyLen ) ? EOS : yyIn[yyPos++].unicode();
2482} 2488}
2483 2489
2484int QRegExpEngine::getEscape() 2490int QRegExpEngine::getEscape()
2485{ 2491{
2486#ifndef QT_NO_REGEXP_ESCAPE 2492#ifndef QT_NO_REGEXP_ESCAPE
2487 const char tab[] = "afnrtv"; // no b, as \b means word boundary 2493 const char tab[] = "afnrtv"; // no b, as \b means word boundary
2488 const char backTab[] = "\a\f\n\r\t\v"; 2494 const char backTab[] = "\a\f\n\r\t\v";
2489 ushort low; 2495 ushort low;
2490 int i; 2496 int i;
2491#endif 2497#endif
2492 ushort val; 2498 ushort val;
2493 int prevCh = yyCh; 2499 int prevCh = yyCh;
2494 2500
2495 if ( prevCh == EOS ) { 2501 if ( prevCh == EOS ) {
2496 yyError = TRUE; 2502 yyError = TRUE;
2497 return Tok_Char | '\\'; 2503 return Tok_Char | '\\';
2498 } 2504 }
2499 yyCh = getChar(); 2505 yyCh = getChar();
2500#ifndef QT_NO_REGEXP_ESCAPE 2506#ifndef QT_NO_REGEXP_ESCAPE
2501 if ( (prevCh & ~0xff) == 0 ) { 2507 if ( (prevCh & ~0xff) == 0 ) {
2502 const char *p = strchr( tab, prevCh ); 2508 const char *p = strchr( tab, prevCh );
2503 if ( p != 0 ) 2509 if ( p != 0 )
2504 return Tok_Char | backTab[p - tab]; 2510 return Tok_Char | backTab[p - tab];
2505 } 2511 }
2506#endif 2512#endif
2507 2513
2508 switch ( prevCh ) { 2514 switch ( prevCh ) {
2509#ifndef QT_NO_REGEXP_ESCAPE 2515#ifndef QT_NO_REGEXP_ESCAPE
2510 case '0': 2516 case '0':
2511 val = 0; 2517 val = 0;
2512 for ( i = 0; i < 3; i++ ) { 2518 for ( i = 0; i < 3; i++ ) {