Merge lp:~srazi/qpdfview/small-patches into lp:qpdfview

Proposed by Razi Alavizadeh
Status: Merged
Approved by: Adam Reichold
Approved revision: 1694
Merged at revision: 1691
Proposed branch: lp:~srazi/qpdfview/small-patches
Merge into: lp:qpdfview
Diff against target: 118 lines (+23/-33)
3 files modified
sources/djvumodel.cpp (+10/-18)
sources/mainwindow.cpp (+1/-1)
sources/pageitem.cpp (+12/-14)
To merge this branch: bzr merge lp:~srazi/qpdfview/small-patches
Reviewer Review Type Date Requested Status
Adam Reichold Approve
Review via email: mp+234985@code.launchpad.net

Description of the change

Hi Adam,

Some explanations:
Commit Message: "Show text related context-menu's actions only when selected rectangle contains text."
- I think showing "Copy text" when just image is available is confusing.

Commit Message: "Correctly determines word when searching through DjVu document."
- For example searching (book: "Megginson R. An introduction to Banach space theory") for "Banach" now can find "Hahn-Banach", "Banach's". (1229 results improved to 1382 results!)
Indeed, I found this issue when I implemented an extended search dock. It's completed but I didn't push it here because you said there are enough features for new release. (but if you want to review it then I'll push it tonight)

Best Regards,
Razi.

To post a comment you must log in.
Revision history for this message
Adam Reichold (adamreichold) wrote :

Hello Razi,

I don't have time to review and merge right now, but the changes look correct and I will merge as soon as I can and definitely before the next release (since functional analysis without the Hahn-Banach theorem won't get you very far). Just a small thing, could you revert the usage of "QUrl::fromLocalFile" since that is not available on Qt 4.6 which we are currently still targeting. Thanks!

Best regards, Adam.

review: Approve
Revision history for this message
Adam Reichold (adamreichold) wrote :

Hello again,

sorry I was wrong, it was "QUrl::isLocalFile" that was introduced only in Qt 4.8. So I'll take that fix in as well.

Best regards, Adam.

Revision history for this message
Razi Alavizadeh (srazi) wrote :

Hello Adam,
> I don't have time to review and merge right now, but the changes look correct and I will merge as soon as I can and definitely before the next release (since functional analysis without the Hahn-Banach theorem won't get you very far). Just a small thing, could you revert the usage of "QUrl::fromLocalFile" since that is not available on Qt 4.6 which we are currently still targeting. Thanks!
It feels good to see a man of computer's world knows about mathematics's world.

Sorry again unrelated discussions:
1- I suggest that the HelpDialog should be non-modal, then user can read it and test application without closing it.
2- I want to save firstPage state to database (indeed I wrote the patch) but I don't understand the following part of preparePerFileSettings_v2()?

    if(Settings::instance()->mainWindow().restorePerFileSettings())
    {
        query.exec("DELETE FROM perfilesettings_v2 WHERE filePath IN (SELECT filePath FROM perfilesettings_v2 ORDER BY lastUsed DESC LIMIT -1 OFFSET 1000)");
    }
    else
    {
        query.exec("DELETE FROM perfilesettings_v2");
    }

Best Regards,
Razi.

Revision history for this message
Adam Reichold (adamreichold) wrote :

Hello Razi,

Am 19.09.2014 um 22:31 schrieb S. Razi Alavizadeh:
> Hello Adam,
>> I don't have time to review and merge right now, but the changes look correct and I will merge as soon as I can and definitely before the next release (since functional analysis without the Hahn-Banach theorem won't get you very far). Just a small thing, could you revert the usage of "QUrl::fromLocalFile" since that is not available on Qt 4.6 which we are currently still targeting. Thanks!
> It feels good to see a man of computer's world knows about mathematics's world.
>
> Sorry again unrelated discussions:

Again, the mailing list would be best. :-)

> 1- I suggest that the HelpDialog should be non-modal, then user can read it and test application without closing it.

I agree, the change sounds sensible. Can you write up the patch as I
will be travelling until Sunday evening (CEST).

> 2- I want to save firstPage state to database (indeed I wrote the patch) but I don't understand the following part of preparePerFileSettings_v2()?
>
> if(Settings::instance()->mainWindow().restorePerFileSettings())
> {
> query.exec("DELETE FROM perfilesettings_v2 WHERE filePath IN (SELECT filePath FROM perfilesettings_v2 ORDER BY lastUsed DESC LIMIT -1 OFFSET 1000)");
> }
> else
> {
> query.exec("DELETE FROM perfilesettings_v2");
> }

It is our probably not very elegant way to keep only the 1000 least
recently used entries of the per-file settings table (or completely
clear it if the user disabled the option). The number 1000 is pretty
arbitrary and was chosen conservatively and could propbably be improved.
More elegant SQL to keep only the last N entries would of course also be
welcome.

> Best Regards,
> Razi.

Best regards, Adam.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'sources/djvumodel.cpp'
--- sources/djvumodel.cpp 2014-03-30 09:43:56 +0000
+++ sources/djvumodel.cpp 2014-09-17 14:08:17 +0000
@@ -519,6 +519,8 @@
519 QRectF rect;519 QRectF rect;
520 int index = 0;520 int index = 0;
521521
522 const QTransform transform = QTransform::fromScale(72.0 / m_resolution, 72.0 / m_resolution);
523
522 while(!words.isEmpty())524 while(!words.isEmpty())
523 {525 {
524 miniexp_t textExp = words.takeFirst();526 miniexp_t textExp = words.takeFirst();
@@ -531,7 +533,9 @@
531 {533 {
532 const QString word = QString::fromUtf8(miniexp_to_str(miniexp_nth(5, textExp)));534 const QString word = QString::fromUtf8(miniexp_to_str(miniexp_nth(5, textExp)));
533535
534 if(text.indexOf(word, index, matchCase ? Qt::CaseSensitive : Qt::CaseInsensitive) == index)536 index = word.indexOf(text, index, (matchCase ? Qt::CaseSensitive : Qt::CaseInsensitive));
537
538 if (index != -1)
535 {539 {
536 const int xmin = miniexp_to_int(miniexp_nth(1, textExp));540 const int xmin = miniexp_to_int(miniexp_nth(1, textExp));
537 const int ymin = miniexp_to_int(miniexp_nth(2, textExp));541 const int ymin = miniexp_to_int(miniexp_nth(2, textExp));
@@ -540,16 +544,11 @@
540544
541 rect = rect.united(QRectF(xmin, m_size.height() - ymax, xmax - xmin, ymax - ymin));545 rect = rect.united(QRectF(xmin, m_size.height() - ymax, xmax - xmin, ymax - ymin));
542546
543 index += word.length();547 index += text.length();
544548
545 while(text.length() > index && text.at(index).isSpace())549 if (!word.at(index).isLetter())
546 {550 {
547 ++index;551 results.append(transform.mapRect(rect));
548 }
549
550 if(text.length() == index)
551 {
552 results.append(rect);
553552
554 rect = QRectF();553 rect = QRectF();
555 index = 0;554 index = 0;
@@ -573,13 +572,6 @@
573572
574 ddjvu_miniexp_release(m_parent->m_document, pageTextExp);573 ddjvu_miniexp_release(m_parent->m_document, pageTextExp);
575574
576 const QTransform transform = QTransform::fromScale(72.0 / m_resolution, 72.0 / m_resolution);
577
578 for(int index = 0; index < results.size(); ++index)
579 {
580 results[index] = transform.mapRect(results[index]);
581 }
582
583 return results;575 return results;
584}576}
585577
586578
=== modified file 'sources/mainwindow.cpp'
--- sources/mainwindow.cpp 2014-09-10 18:57:50 +0000
+++ sources/mainwindow.cpp 2014-09-17 14:08:17 +0000
@@ -910,7 +910,7 @@
910910
911void MainWindow::on_openContainingFolder_triggered()911void MainWindow::on_openContainingFolder_triggered()
912{912{
913 QDesktopServices::openUrl(currentTab()->fileInfo().absolutePath());913 QDesktopServices::openUrl(QUrl::fromLocalFile(currentTab()->fileInfo().absolutePath()));
914}914}
915915
916void MainWindow::on_refresh_triggered()916void MainWindow::on_refresh_triggered()
917917
=== modified file 'sources/pageitem.cpp'
--- sources/pageitem.cpp 2014-09-16 21:07:02 +0000
+++ sources/pageitem.cpp 2014-09-17 14:08:17 +0000
@@ -756,29 +756,27 @@
756{756{
757 QMenu menu;757 QMenu menu;
758758
759 const QAction* copyTextAction = menu.addAction(tr("Copy &text"));759 QAction* copyTextAction = menu.addAction(tr("Copy &text"));
760 QAction* selectTextAction = menu.addAction(tr("&Select text"));760 QAction* selectTextAction = menu.addAction(tr("&Select text"));
761 const QAction* copyImageAction = menu.addAction(tr("Copy &image"));761 const QAction* copyImageAction = menu.addAction(tr("Copy &image"));
762 const QAction* saveImageToFileAction = menu.addAction(tr("Save image to &file..."));762 const QAction* saveImageToFileAction = menu.addAction(tr("Save image to &file..."));
763763
764 selectTextAction->setVisible(QApplication::clipboard()->supportsSelection());764 const QString text = m_page->text(m_transform.inverted().mapRect(m_rubberBand));
765
766 selectTextAction->setVisible(QApplication::clipboard()->supportsSelection() && !text.isEmpty());
767 copyTextAction->setVisible(!text.isEmpty());
765768
766 const QAction* action = menu.exec(screenPos);769 const QAction* action = menu.exec(screenPos);
767770
768 if(action == copyTextAction || action == selectTextAction)771 if(action == copyTextAction || action == selectTextAction)
769 {772 {
770 const QString text = m_page->text(m_transform.inverted().mapRect(m_rubberBand));773 if(action == copyTextAction)
771774 {
772 if(!text.isEmpty())775 QApplication::clipboard()->setText(text);
773 {776 }
774 if(action == copyTextAction)777 else
775 {778 {
776 QApplication::clipboard()->setText(text);779 QApplication::clipboard()->setText(text, QClipboard::Selection);
777 }
778 else
779 {
780 QApplication::clipboard()->setText(text, QClipboard::Selection);
781 }
782 }780 }
783 }781 }
784 else if(action == copyImageAction || action == saveImageToFileAction)782 else if(action == copyImageAction || action == saveImageToFileAction)

Subscribers

People subscribed via source and target branches