-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index b985094..4f0f0a1 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -2305,513 +2305,513 @@ void QTReaderApp::showtoolbarprefs() | |||
2305 | { // "/tmp" | 2305 | { // "/tmp" |
2306 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | 2306 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
2307 | d = QDir::home(); | 2307 | d = QDir::home(); |
2308 | d.mkdir(APPDIR); | 2308 | d.mkdir(APPDIR); |
2309 | d.cd(APPDIR); | 2309 | d.cd(APPDIR); |
2310 | } | 2310 | } |
2311 | fi.setFile(d, INIFILE); | 2311 | fi.setFile(d, INIFILE); |
2312 | Config config( fi.absFilePath() ); | 2312 | Config config( fi.absFilePath() ); |
2313 | #endif | 2313 | #endif |
2314 | if (isChanged) addtoolbars(&config); | 2314 | if (isChanged) addtoolbars(&config); |
2315 | } | 2315 | } |
2316 | else | 2316 | else |
2317 | { | 2317 | { |
2318 | delete prefwin; | 2318 | delete prefwin; |
2319 | } | 2319 | } |
2320 | } | 2320 | } |
2321 | 2321 | ||
2322 | void QTReaderApp::showinfo() | 2322 | void QTReaderApp::showinfo() |
2323 | { | 2323 | { |
2324 | unsigned long ds, fs, ts, pl, dl; | 2324 | unsigned long ds, fs, ts, pl, dl; |
2325 | if (reader->empty()) | 2325 | if (reader->empty()) |
2326 | { | 2326 | { |
2327 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 2327 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
2328 | } | 2328 | } |
2329 | else | 2329 | else |
2330 | { | 2330 | { |
2331 | reader->sizes(fs,ts); | 2331 | reader->sizes(fs,ts); |
2332 | ds = reader->buffdoc.endSection() - reader->buffdoc.startSection(); | 2332 | ds = reader->buffdoc.endSection() - reader->buffdoc.startSection(); |
2333 | pl = reader->pagelocate(); | 2333 | pl = reader->pagelocate(); |
2334 | dl = pl - reader->buffdoc.startSection(); | 2334 | dl = pl - reader->buffdoc.startSection(); |
2335 | m_infoWin->setFileSize(fs); | 2335 | m_infoWin->setFileSize(fs); |
2336 | m_infoWin->setTextSize(ts); | 2336 | m_infoWin->setTextSize(ts); |
2337 | if (fs > UINT_MAX/100) | 2337 | if (fs > UINT_MAX/100) |
2338 | { | 2338 | { |
2339 | unsigned long t1 = (ts+50)/100; | 2339 | unsigned long t1 = (ts+50)/100; |
2340 | m_infoWin->setRatio(100-(fs + (t1 >> 1))/t1); | 2340 | m_infoWin->setRatio(100-(fs + (t1 >> 1))/t1); |
2341 | } | 2341 | } |
2342 | else | 2342 | else |
2343 | { | 2343 | { |
2344 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); | 2344 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); |
2345 | } | 2345 | } |
2346 | m_infoWin->setLocation(pl); | 2346 | m_infoWin->setLocation(pl); |
2347 | if (pl > UINT_MAX/100) | 2347 | if (pl > UINT_MAX/100) |
2348 | { | 2348 | { |
2349 | unsigned long t1 = (ts+50)/100; | 2349 | unsigned long t1 = (ts+50)/100; |
2350 | m_infoWin->setRead((pl + (t1 >> 1))/t1); | 2350 | m_infoWin->setRead((pl + (t1 >> 1))/t1); |
2351 | } | 2351 | } |
2352 | else | 2352 | else |
2353 | { | 2353 | { |
2354 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); | 2354 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); |
2355 | } | 2355 | } |
2356 | m_infoWin->setDocSize(ds); | 2356 | m_infoWin->setDocSize(ds); |
2357 | m_infoWin->setDocLocation(dl); | 2357 | m_infoWin->setDocLocation(dl); |
2358 | if (dl > UINT_MAX/100) | 2358 | if (dl > UINT_MAX/100) |
2359 | { | 2359 | { |
2360 | unsigned long d1 = (ds+50)/100; | 2360 | unsigned long d1 = (ds+50)/100; |
2361 | m_infoWin->setDocRead((dl + (d1 >> 1))/d1); | 2361 | m_infoWin->setDocRead((dl + (d1 >> 1))/d1); |
2362 | } | 2362 | } |
2363 | else | 2363 | else |
2364 | { | 2364 | { |
2365 | m_infoWin->setDocRead((100*dl + (ds >> 1))/ds); | 2365 | m_infoWin->setDocRead((100*dl + (ds >> 1))/ds); |
2366 | } | 2366 | } |
2367 | m_infoWin->setZoom(reader->m_fontControl.currentsize()*10); | 2367 | m_infoWin->setZoom(reader->m_fontControl.currentsize()*10); |
2368 | m_infoWin->setAbout(QString("\nApplication (c) Tim Wentford\n")+reader->about()); | 2368 | m_infoWin->setAbout(QString("\nApplication (c) Tim Wentford\n")+reader->about()); |
2369 | editorStack->raiseWidget( m_infoWin ); | 2369 | editorStack->raiseWidget( m_infoWin ); |
2370 | hidetoolbars(); | 2370 | hidetoolbars(); |
2371 | m_infoWin->setFocus(); | 2371 | m_infoWin->setFocus(); |
2372 | } | 2372 | } |
2373 | } | 2373 | } |
2374 | 2374 | ||
2375 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn, size_t posn2) | 2375 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn, size_t posn2) |
2376 | { | 2376 | { |
2377 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; | 2377 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; |
2378 | #ifdef _UNICODE | 2378 | #ifdef _UNICODE |
2379 | CBuffer buff(name.length()+1); | 2379 | CBuffer buff(name.length()+1); |
2380 | int i; | 2380 | int i; |
2381 | for (i = 0; i < name.length(); i++) | 2381 | for (i = 0; i < name.length(); i++) |
2382 | { | 2382 | { |
2383 | buff[i] = name[i].unicode(); | 2383 | buff[i] = name[i].unicode(); |
2384 | } | 2384 | } |
2385 | buff[i] = 0; | 2385 | buff[i] = 0; |
2386 | CBuffer buff2(text.length()+1); | 2386 | CBuffer buff2(text.length()+1); |
2387 | for (i = 0; i < text.length(); i++) | 2387 | for (i = 0; i < text.length(); i++) |
2388 | { | 2388 | { |
2389 | buff2[i] = text[i].unicode(); | 2389 | buff2[i] = text[i].unicode(); |
2390 | } | 2390 | } |
2391 | buff2[i] = 0; | 2391 | buff2[i] = 0; |
2392 | Bkmk b(buff.data(), buff2.data(), posn, posn2); | 2392 | Bkmk b(buff.data(), buff2.data(), posn, posn2); |
2393 | QColor c = m_annoWin->getColor(); | 2393 | QColor c = m_annoWin->getColor(); |
2394 | int red,green,blue; | 2394 | int red,green,blue; |
2395 | c.rgb(&red, &green, &blue); | 2395 | c.rgb(&red, &green, &blue); |
2396 | b.red(red); | 2396 | b.red(red); |
2397 | b.green(green); | 2397 | b.green(green); |
2398 | b.blue(blue); | 2398 | b.blue(blue); |
2399 | pBkmklist->push_front(b); | 2399 | pBkmklist->push_front(b); |
2400 | #else | 2400 | #else |
2401 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); | 2401 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); |
2402 | #endif | 2402 | #endif |
2403 | m_fBkmksChanged = true; | 2403 | m_fBkmksChanged = true; |
2404 | pBkmklist->sort(); | 2404 | pBkmklist->sort(); |
2405 | } | 2405 | } |
2406 | 2406 | ||
2407 | void QTReaderApp::addAnno(const QString& name, const QString& text) | 2407 | void QTReaderApp::addAnno(const QString& name, const QString& text) |
2408 | { | 2408 | { |
2409 | if (m_annoIsEditing) | 2409 | if (m_annoIsEditing) |
2410 | { | 2410 | { |
2411 | if (name.isEmpty()) | 2411 | if (name.isEmpty()) |
2412 | { | 2412 | { |
2413 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); | 2413 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); |
2414 | } | 2414 | } |
2415 | else | 2415 | else |
2416 | { | 2416 | { |
2417 | addAnno(name, text, m_annoWin->getPosn(), m_annoWin->getPosn2()); | 2417 | addAnno(name, text, m_annoWin->getPosn(), m_annoWin->getPosn2()); |
2418 | } | 2418 | } |
2419 | showEditTools(); | 2419 | showEditTools(); |
2420 | } | 2420 | } |
2421 | else | 2421 | else |
2422 | { | 2422 | { |
2423 | if (m_annoWin->edited()) | 2423 | if (m_annoWin->edited()) |
2424 | { | 2424 | { |
2425 | CBuffer buff(text.length()+1); | 2425 | CBuffer buff(text.length()+1); |
2426 | int i; | 2426 | int i; |
2427 | for (i = 0; i < text.length(); i++) | 2427 | for (i = 0; i < text.length(); i++) |
2428 | { | 2428 | { |
2429 | buff[i] = text[i].unicode(); | 2429 | buff[i] = text[i].unicode(); |
2430 | } | 2430 | } |
2431 | buff[i] = 0; | 2431 | buff[i] = 0; |
2432 | m_fBkmksChanged = true; | 2432 | m_fBkmksChanged = true; |
2433 | m_anno->setAnno(buff.data()); | 2433 | m_anno->setAnno(buff.data()); |
2434 | } | 2434 | } |
2435 | QColor c = m_annoWin->getColor(); | 2435 | QColor c = m_annoWin->getColor(); |
2436 | int red,green,blue; | 2436 | int red,green,blue; |
2437 | c.rgb(&red, &green, &blue); | 2437 | c.rgb(&red, &green, &blue); |
2438 | m_anno->red(red); | 2438 | m_anno->red(red); |
2439 | m_anno->green(green); | 2439 | m_anno->green(green); |
2440 | m_anno->blue(blue); | 2440 | m_anno->blue(blue); |
2441 | bool found = findNextBookmark(m_anno->value()+1); | 2441 | bool found = findNextBookmark(m_anno->value()+1); |
2442 | if (found) | 2442 | if (found) |
2443 | { | 2443 | { |
2444 | m_annoWin->setName(toQString(m_anno->name())); | 2444 | m_annoWin->setName(toQString(m_anno->name())); |
2445 | m_annoWin->setAnno(toQString(m_anno->anno())); | 2445 | m_annoWin->setAnno(toQString(m_anno->anno())); |
2446 | m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); | 2446 | m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); |
2447 | } | 2447 | } |
2448 | else | 2448 | else |
2449 | { | 2449 | { |
2450 | showEditTools(); | 2450 | showEditTools(); |
2451 | } | 2451 | } |
2452 | } | 2452 | } |
2453 | } | 2453 | } |
2454 | 2454 | ||
2455 | bool QTReaderApp::findNextBookmark(size_t start) | 2455 | bool QTReaderApp::findNextBookmark(size_t start) |
2456 | { | 2456 | { |
2457 | bool found = false; | 2457 | bool found = false; |
2458 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) | 2458 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) |
2459 | { | 2459 | { |
2460 | if (iter->value() >= start) | 2460 | if (iter->value() >= start) |
2461 | { | 2461 | { |
2462 | if (iter->value() < reader->locate()) | 2462 | if (iter->value() < reader->locate()) |
2463 | { | 2463 | { |
2464 | found = true; | 2464 | found = true; |
2465 | m_anno = iter.pContent(); | 2465 | m_anno = iter.pContent(); |
2466 | } | 2466 | } |
2467 | break; | 2467 | break; |
2468 | } | 2468 | } |
2469 | } | 2469 | } |
2470 | return found; | 2470 | return found; |
2471 | } | 2471 | } |
2472 | 2472 | ||
2473 | void QTReaderApp::addanno() | 2473 | void QTReaderApp::addanno() |
2474 | { | 2474 | { |
2475 | if (reader->empty()) | 2475 | if (reader->empty()) |
2476 | { | 2476 | { |
2477 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 2477 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
2478 | } | 2478 | } |
2479 | else | 2479 | else |
2480 | { | 2480 | { |
2481 | m_annoWin->setName(""); | 2481 | m_annoWin->setName(""); |
2482 | m_annoWin->setAnno(""); | 2482 | m_annoWin->setAnno(""); |
2483 | m_annoWin->setPosn(reader->pagelocate()); | 2483 | m_annoWin->setPosn(reader->pagelocate()); |
2484 | m_annoIsEditing = true; | 2484 | m_annoIsEditing = true; |
2485 | editorStack->raiseWidget( m_annoWin ); | 2485 | editorStack->raiseWidget( m_annoWin ); |
2486 | hidetoolbars(); | 2486 | hidetoolbars(); |
2487 | #ifdef USEQPE | 2487 | #ifdef USEQPE |
2488 | Global::showInputMethod(); | 2488 | Global::showInputMethod(); |
2489 | #endif | 2489 | #endif |
2490 | m_annoWin->setFocus(); | 2490 | m_annoWin->setFocus(); |
2491 | } | 2491 | } |
2492 | } | 2492 | } |
2493 | 2493 | ||
2494 | void QTReaderApp::infoClose() | 2494 | void QTReaderApp::infoClose() |
2495 | { | 2495 | { |
2496 | m_debounce = m_buttonprefs->Debounce(); | 2496 | m_debounce = m_buttonprefs->Debounce(); |
2497 | if (m_kmapchanged) | 2497 | if (m_kmapchanged) |
2498 | { | 2498 | { |
2499 | m_kmapchanged = false; | 2499 | m_kmapchanged = false; |
2500 | #ifndef USEQPE | 2500 | #ifndef USEQPE |
2501 | QDir d = QDir::home(); // "/" | 2501 | QDir d = QDir::home(); // "/" |
2502 | d.cd(APPDIR); | 2502 | d.cd(APPDIR); |
2503 | QFileInfo fi(d, ".keymap"); | 2503 | QFileInfo fi(d, ".keymap"); |
2504 | FILE* f = fopen((const char *)fi.absFilePath(), "w"); | 2504 | FILE* f = fopen((const char *)fi.absFilePath(), "w"); |
2505 | #else /* USEQPE */ | 2505 | #else /* USEQPE */ |
2506 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "w"); | 2506 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "w"); |
2507 | #endif /* USEQPE */ | 2507 | #endif /* USEQPE */ |
2508 | if (f != NULL) | 2508 | if (f != NULL) |
2509 | { | 2509 | { |
2510 | uint cnt = KEYMAPVERSION; | 2510 | uint cnt = KEYMAPVERSION; |
2511 | fwrite(&cnt, sizeof(cnt), 1, f); | 2511 | fwrite(&cnt, sizeof(cnt), 1, f); |
2512 | cnt = kmap.count(); | 2512 | cnt = kmap.count(); |
2513 | fwrite(&cnt, sizeof(cnt), 1, f); | 2513 | fwrite(&cnt, sizeof(cnt), 1, f); |
2514 | for (QMap<orKey,int>::Iterator i = kmap.begin(); i != kmap.end(); i++) | 2514 | for (QMap<orKey,int>::Iterator i = kmap.begin(); i != kmap.end(); i++) |
2515 | { | 2515 | { |
2516 | orKey key = i.key(); | 2516 | orKey key = i.key(); |
2517 | int data = i.data(); | 2517 | int data = i.data(); |
2518 | fwrite(&key, sizeof(key), 1, f); | 2518 | fwrite(&key, sizeof(key), 1, f); |
2519 | fwrite(&data, sizeof(data), 1, f); | 2519 | fwrite(&data, sizeof(data), 1, f); |
2520 | qDebug("Saved %s as %u", (const char*)key.text(), data); | 2520 | qDebug("Saved %s as %u", (const char*)key.text(), data); |
2521 | } | 2521 | } |
2522 | fclose(f); | 2522 | fclose(f); |
2523 | } | 2523 | } |
2524 | } | 2524 | } |
2525 | showEditTools(); | 2525 | showEditTools(); |
2526 | } | 2526 | } |
2527 | 2527 | ||
2528 | /* | 2528 | /* |
2529 | void QTReaderApp::fileRevert() | 2529 | void QTReaderApp::fileRevert() |
2530 | { | 2530 | { |
2531 | clear(); | 2531 | clear(); |
2532 | fileOpen(); | 2532 | fileOpen(); |
2533 | } | 2533 | } |
2534 | 2534 | ||
2535 | void QTReaderApp::editCut() | 2535 | void QTReaderApp::editCut() |
2536 | { | 2536 | { |
2537 | #ifndef QT_NO_CLIPBOARD | 2537 | #ifndef QT_NO_CLIPBOARD |
2538 | editor->cut(); | 2538 | editor->cut(); |
2539 | #endif | 2539 | #endif |
2540 | } | 2540 | } |
2541 | */ | 2541 | */ |
2542 | void QTReaderApp::editMark() | 2542 | void QTReaderApp::editMark() |
2543 | { | 2543 | { |
2544 | m_savedpos = reader->pagelocate(); | 2544 | m_savedpos = reader->pagelocate(); |
2545 | } | 2545 | } |
2546 | 2546 | ||
2547 | void QTReaderApp::editCopy() | 2547 | void QTReaderApp::editCopy() |
2548 | { | 2548 | { |
2549 | QClipboard* cb = QApplication::clipboard(); | 2549 | QClipboard* cb = QApplication::clipboard(); |
2550 | QString text; | 2550 | QString text; |
2551 | int ch; | 2551 | int ch; |
2552 | unsigned long currentpos = reader->pagelocate(); | 2552 | unsigned long currentpos = reader->pagelocate(); |
2553 | unsigned long endpos = reader->locate(); | 2553 | unsigned long endpos = reader->locate(); |
2554 | if (m_savedpos == 0xffffffff) | 2554 | if (m_savedpos == 0xffffffff) |
2555 | { | 2555 | { |
2556 | m_savedpos = currentpos; | 2556 | m_savedpos = currentpos; |
2557 | } | 2557 | } |
2558 | reader->jumpto(m_savedpos); | 2558 | reader->jumpto(m_savedpos); |
2559 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) | 2559 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) |
2560 | { | 2560 | { |
2561 | text += ch; | 2561 | text += QChar(ch); |
2562 | } | 2562 | } |
2563 | cb->setText(text); | 2563 | cb->setText(text); |
2564 | reader->locate(currentpos); | 2564 | reader->locate(currentpos); |
2565 | m_savedpos = 0xffffffff; | 2565 | m_savedpos = 0xffffffff; |
2566 | } | 2566 | } |
2567 | 2567 | ||
2568 | void QTReaderApp::gotoStart() | 2568 | void QTReaderApp::gotoStart() |
2569 | { | 2569 | { |
2570 | reader->locate(reader->buffdoc.startSection()); | 2570 | reader->locate(reader->buffdoc.startSection()); |
2571 | } | 2571 | } |
2572 | 2572 | ||
2573 | void QTReaderApp::gotoEnd() | 2573 | void QTReaderApp::gotoEnd() |
2574 | { | 2574 | { |
2575 | reader->dopageup(reader->buffdoc.endSection()); | 2575 | reader->dopageup(reader->buffdoc.endSection()); |
2576 | } | 2576 | } |
2577 | 2577 | ||
2578 | void QTReaderApp::pageup() | 2578 | void QTReaderApp::pageup() |
2579 | { | 2579 | { |
2580 | reader->NavUp(); | 2580 | reader->NavUp(); |
2581 | } | 2581 | } |
2582 | 2582 | ||
2583 | void QTReaderApp::pagedn() | 2583 | void QTReaderApp::pagedn() |
2584 | { | 2584 | { |
2585 | reader->NavDown(); | 2585 | reader->NavDown(); |
2586 | } | 2586 | } |
2587 | 2587 | ||
2588 | void QTReaderApp::pagemode(bool _b) | 2588 | void QTReaderApp::pagemode(bool _b) |
2589 | { | 2589 | { |
2590 | reader->setpagemode(_b); | 2590 | reader->setpagemode(_b); |
2591 | } | 2591 | } |
2592 | 2592 | ||
2593 | /* | 2593 | /* |
2594 | void QTReaderApp::setspacing() | 2594 | void QTReaderApp::setspacing() |
2595 | { | 2595 | { |
2596 | m_nRegAction = cMonoSpace; | 2596 | m_nRegAction = cMonoSpace; |
2597 | char lcn[20]; | 2597 | char lcn[20]; |
2598 | sprintf(lcn, "%lu", reader->m_charpc); | 2598 | sprintf(lcn, "%lu", reader->m_charpc); |
2599 | regEdit->setText(lcn); | 2599 | regEdit->setText(lcn); |
2600 | do_regedit(); | 2600 | do_regedit(); |
2601 | } | 2601 | } |
2602 | */ | 2602 | */ |
2603 | void QTReaderApp::settarget() | 2603 | void QTReaderApp::settarget() |
2604 | { | 2604 | { |
2605 | m_nRegAction = cSetTarget; | 2605 | m_nRegAction = cSetTarget; |
2606 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) | 2606 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) |
2607 | + "/" | 2607 | + "/" |
2608 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); | 2608 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); |
2609 | regEdit->setText(text); | 2609 | regEdit->setText(text); |
2610 | do_regedit(); | 2610 | do_regedit(); |
2611 | } | 2611 | } |
2612 | 2612 | ||
2613 | /* | 2613 | /* |
2614 | void QTReaderApp::do_mono(const QString& lcn) | 2614 | void QTReaderApp::do_mono(const QString& lcn) |
2615 | { | 2615 | { |
2616 | bool ok; | 2616 | bool ok; |
2617 | unsigned long ulcn = lcn.toULong(&ok); | 2617 | unsigned long ulcn = lcn.toULong(&ok); |
2618 | if (ok) | 2618 | if (ok) |
2619 | { | 2619 | { |
2620 | reader->m_charpc = ulcn; | 2620 | reader->m_charpc = ulcn; |
2621 | reader->setfont(); | 2621 | reader->setfont(); |
2622 | reader->refresh(); | 2622 | reader->refresh(); |
2623 | //reader->setmono(true); | 2623 | //reader->setmono(true); |
2624 | } | 2624 | } |
2625 | else | 2625 | else |
2626 | QMessageBox::information(this, PROGNAME, "Must be a number"); | 2626 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
2627 | } | 2627 | } |
2628 | */ | 2628 | */ |
2629 | /* | 2629 | /* |
2630 | void QTReaderApp::editPaste() | 2630 | void QTReaderApp::editPaste() |
2631 | { | 2631 | { |
2632 | #ifndef QT_NO_CLIPBOARD | 2632 | #ifndef QT_NO_CLIPBOARD |
2633 | editor->paste(); | 2633 | editor->paste(); |
2634 | #endif | 2634 | #endif |
2635 | } | 2635 | } |
2636 | */ | 2636 | */ |
2637 | 2637 | ||
2638 | void QTReaderApp::editFind() | 2638 | void QTReaderApp::editFind() |
2639 | { | 2639 | { |
2640 | searchStart = reader->pagelocate(); | 2640 | searchStart = reader->pagelocate(); |
2641 | #ifdef __ISEARCH | 2641 | #ifdef __ISEARCH |
2642 | searchStack = new QStack<searchrecord>; | 2642 | searchStack = new QStack<searchrecord>; |
2643 | #endif | 2643 | #endif |
2644 | #ifdef USEQPE | 2644 | #ifdef USEQPE |
2645 | Global::showInputMethod(); | 2645 | Global::showInputMethod(); |
2646 | #endif | 2646 | #endif |
2647 | searchBar->show(); | 2647 | searchBar->show(); |
2648 | searchVisible = TRUE; | 2648 | searchVisible = TRUE; |
2649 | searchEdit->setFocus(); | 2649 | searchEdit->setFocus(); |
2650 | #ifdef __ISEARCH | 2650 | #ifdef __ISEARCH |
2651 | searchStack->push(new searchrecord("",reader->pagelocate())); | 2651 | searchStack->push(new searchrecord("",reader->pagelocate())); |
2652 | #endif | 2652 | #endif |
2653 | } | 2653 | } |
2654 | 2654 | ||
2655 | void QTReaderApp::findNext() | 2655 | void QTReaderApp::findNext() |
2656 | { | 2656 | { |
2657 | // // qDebug("findNext called\n"); | 2657 | // // qDebug("findNext called\n"); |
2658 | #ifdef __ISEARCH | 2658 | #ifdef __ISEARCH |
2659 | QString arg = searchEdit->text(); | 2659 | QString arg = searchEdit->text(); |
2660 | #else | 2660 | #else |
2661 | QRegExp arg = searchEdit->text(); | 2661 | QRegExp arg = searchEdit->text(); |
2662 | #endif | 2662 | #endif |
2663 | CDrawBuffer test(&(reader->m_fontControl)); | 2663 | CDrawBuffer test(&(reader->m_fontControl)); |
2664 | size_t start = reader->pagelocate(); | 2664 | size_t start = reader->pagelocate(); |
2665 | reader->jumpto(start); | 2665 | reader->jumpto(start); |
2666 | reader->getline(&test); | 2666 | reader->getline(&test); |
2667 | dosearch(start, test, arg); | 2667 | dosearch(start, test, arg); |
2668 | } | 2668 | } |
2669 | 2669 | ||
2670 | void QTReaderApp::findClose() | 2670 | void QTReaderApp::findClose() |
2671 | { | 2671 | { |
2672 | searchVisible = FALSE; | 2672 | searchVisible = FALSE; |
2673 | searchEdit->setText(""); | 2673 | searchEdit->setText(""); |
2674 | #ifdef USEQPE | 2674 | #ifdef USEQPE |
2675 | Global::hideInputMethod(); | 2675 | Global::hideInputMethod(); |
2676 | #endif | 2676 | #endif |
2677 | searchBar->hide(); | 2677 | searchBar->hide(); |
2678 | #ifdef __ISEARCH | 2678 | #ifdef __ISEARCH |
2679 | // searchStack = new QStack<searchrecord>; | 2679 | // searchStack = new QStack<searchrecord>; |
2680 | while (!searchStack->isEmpty()) | 2680 | while (!searchStack->isEmpty()) |
2681 | { | 2681 | { |
2682 | delete searchStack->pop(); | 2682 | delete searchStack->pop(); |
2683 | } | 2683 | } |
2684 | delete searchStack; | 2684 | delete searchStack; |
2685 | #endif | 2685 | #endif |
2686 | reader->setFocus(); | 2686 | reader->setFocus(); |
2687 | } | 2687 | } |
2688 | 2688 | ||
2689 | void QTReaderApp::regClose() | 2689 | void QTReaderApp::regClose() |
2690 | { | 2690 | { |
2691 | regVisible = FALSE; | 2691 | regVisible = FALSE; |
2692 | regEdit->setText(""); | 2692 | regEdit->setText(""); |
2693 | regBar->hide(); | 2693 | regBar->hide(); |
2694 | #ifdef USEQPE | 2694 | #ifdef USEQPE |
2695 | Global::hideInputMethod(); | 2695 | Global::hideInputMethod(); |
2696 | #endif | 2696 | #endif |
2697 | reader->setFocus(); | 2697 | reader->setFocus(); |
2698 | } | 2698 | } |
2699 | 2699 | ||
2700 | #ifdef __ISEARCH | 2700 | #ifdef __ISEARCH |
2701 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) | 2701 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) |
2702 | #else | 2702 | #else |
2703 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | 2703 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) |
2704 | #endif | 2704 | #endif |
2705 | { | 2705 | { |
2706 | bool ret = true; | 2706 | bool ret = true; |
2707 | unsigned long fs, ts; | 2707 | unsigned long fs, ts; |
2708 | reader->sizes(fs,ts); | 2708 | reader->sizes(fs,ts); |
2709 | size_t pos = reader->locate(); | 2709 | size_t pos = reader->locate(); |
2710 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); | 2710 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); |
2711 | pbar->show(); | 2711 | pbar->show(); |
2712 | pbar->raise(); | 2712 | pbar->raise(); |
2713 | pbar->reset(); | 2713 | pbar->reset(); |
2714 | int offset; | 2714 | int offset; |
2715 | int lastpc = (100*pos)/ts; | 2715 | int lastpc = (100*pos)/ts; |
2716 | pbar->setProgress(lastpc); | 2716 | pbar->setProgress(lastpc); |
2717 | // qApp->processEvents(); | 2717 | // qApp->processEvents(); |
2718 | if (reader->buffdoc.getpara(test) >= 0) | 2718 | if (reader->buffdoc.getpara(test) >= 0) |
2719 | { | 2719 | { |
2720 | reader->setFocus(); | 2720 | reader->setFocus(); |
2721 | #ifdef __ISEARCH | 2721 | #ifdef __ISEARCH |
2722 | while (strstr(test.data(),(const tchar*)arg) == NULL) | 2722 | while (strstr(test.data(),(const tchar*)arg) == NULL) |
2723 | #else | 2723 | #else |
2724 | #ifdef _UNICODE | 2724 | #ifdef _UNICODE |
2725 | while ((offset = arg.match(toQString(test.data()))) == -1) | 2725 | while ((offset = arg.match(toQString(test.data()))) == -1) |
2726 | #else | 2726 | #else |
2727 | while (arg.match(test.data()) == -1) | 2727 | while (arg.match(test.data()) == -1) |
2728 | #endif | 2728 | #endif |
2729 | #endif | 2729 | #endif |
2730 | { | 2730 | { |
2731 | pos = reader->locate(); | 2731 | pos = reader->locate(); |
2732 | int pc = (100*pos)/ts; | 2732 | int pc = (100*pos)/ts; |
2733 | if (pc != lastpc) | 2733 | if (pc != lastpc) |
2734 | { | 2734 | { |
2735 | pbar->setProgress(pc); | 2735 | pbar->setProgress(pc); |
2736 | qApp->processEvents(); | 2736 | qApp->processEvents(); |
2737 | reader->setFocus(); | 2737 | reader->setFocus(); |
2738 | lastpc = pc; | 2738 | lastpc = pc; |
2739 | } | 2739 | } |
2740 | 2740 | ||
2741 | if (reader->buffdoc.getpara(test) < 0) | 2741 | if (reader->buffdoc.getpara(test) < 0) |
2742 | { | 2742 | { |
2743 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2743 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2744 | pos = searchStart; | 2744 | pos = searchStart; |
2745 | else | 2745 | else |
2746 | pos = start; | 2746 | pos = start; |
2747 | findClose(); | 2747 | findClose(); |
2748 | pbar->hide(); | 2748 | pbar->hide(); |
2749 | reader->locate(pos); | 2749 | reader->locate(pos); |
2750 | return false; | 2750 | return false; |
2751 | } | 2751 | } |
2752 | } | 2752 | } |
2753 | // qDebug("Found it at %u:%u", pos, offset); | 2753 | // qDebug("Found it at %u:%u", pos, offset); |
2754 | pbar->hide(); | 2754 | pbar->hide(); |
2755 | // qDebug("Hid"); | 2755 | // qDebug("Hid"); |
2756 | reader->locate(pos+offset); | 2756 | reader->locate(pos+offset); |
2757 | // qDebug("Loacted"); | 2757 | // qDebug("Loacted"); |
2758 | // qDebug("page up"); | 2758 | // qDebug("page up"); |
2759 | ret = true; | 2759 | ret = true; |
2760 | } | 2760 | } |
2761 | else | 2761 | else |
2762 | { | 2762 | { |
2763 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2763 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2764 | pos = searchStart; | 2764 | pos = searchStart; |
2765 | else | 2765 | else |
2766 | pos = start; | 2766 | pos = start; |
2767 | ret = false; | 2767 | ret = false; |
2768 | findClose(); | 2768 | findClose(); |
2769 | } | 2769 | } |
2770 | return ret; | 2770 | return ret; |
2771 | } | 2771 | } |
2772 | 2772 | ||
2773 | #ifdef __ISEARCH | 2773 | #ifdef __ISEARCH |
2774 | void QTReaderApp::search(const QString & arg) | 2774 | void QTReaderApp::search(const QString & arg) |
2775 | { | 2775 | { |
2776 | searchrecord* ss = searchStack->top(); | 2776 | searchrecord* ss = searchStack->top(); |
2777 | CBuffer test; | 2777 | CBuffer test; |
2778 | size_t start = reader->pagelocate(); | 2778 | size_t start = reader->pagelocate(); |
2779 | bool haspopped = false; | 2779 | bool haspopped = false; |
2780 | while (arg.left(ss->s.length()) != ss->s) | 2780 | while (arg.left(ss->s.length()) != ss->s) |
2781 | { | 2781 | { |
2782 | haspopped = true; | 2782 | haspopped = true; |
2783 | start = ss->pos; | 2783 | start = ss->pos; |
2784 | // reader->locate(start); | 2784 | // reader->locate(start); |
2785 | searchStack->pop(); | 2785 | searchStack->pop(); |
2786 | delete ss; | 2786 | delete ss; |
2787 | } | 2787 | } |
2788 | if (haspopped) reader->locate(start); | 2788 | if (haspopped) reader->locate(start); |
2789 | /* | 2789 | /* |
2790 | if (arg.length() < ss->len) | 2790 | if (arg.length() < ss->len) |
2791 | { | 2791 | { |
2792 | start = ss->pos; | 2792 | start = ss->pos; |
2793 | reader->locate(start); | 2793 | reader->locate(start); |
2794 | searchStack->pop(); | 2794 | searchStack->pop(); |
2795 | delete ss; | 2795 | delete ss; |
2796 | } | 2796 | } |
2797 | */ | 2797 | */ |
2798 | else | 2798 | else |
2799 | { | 2799 | { |
2800 | start = reader->pagelocate(); | 2800 | start = reader->pagelocate(); |
2801 | reader->jumpto(start); | 2801 | reader->jumpto(start); |
2802 | searchStack->push(new searchrecord(arg,start)); | 2802 | searchStack->push(new searchrecord(arg,start)); |
2803 | } | 2803 | } |
2804 | dosearch(start, test, arg); | 2804 | dosearch(start, test, arg); |
2805 | } | 2805 | } |
2806 | #else | 2806 | #else |
2807 | void QTReaderApp::search() | 2807 | void QTReaderApp::search() |
2808 | { | 2808 | { |
2809 | findNext(); | 2809 | findNext(); |
2810 | } | 2810 | } |
2811 | #endif | 2811 | #endif |
2812 | 2812 | ||
2813 | void QTReaderApp::openFile( const QString &f, unsigned int loc ) | 2813 | void QTReaderApp::openFile( const QString &f, unsigned int loc ) |
2814 | { | 2814 | { |
2815 | // qDebug("File:%s", (const char*)f); | 2815 | // qDebug("File:%s", (const char*)f); |
2816 | // openFile(DocLnk(f)); | 2816 | // openFile(DocLnk(f)); |
2817 | //} | 2817 | //} |