Changeset View
Changeset View
Standalone View
Standalone View
part.cpp
Show First 20 Lines • Show All 369 Lines • ▼ Show 20 Line(s) | 312 | { | |||
---|---|---|---|---|---|
370 | 370 | | |||
371 | // connect the started signal to tell the job the mimetypes we like, | 371 | // connect the started signal to tell the job the mimetypes we like, | ||
372 | // and get some more information from it | 372 | // and get some more information from it | ||
373 | connect(this, &KParts::ReadOnlyPart::started, this, &Part::slotJobStarted); | 373 | connect(this, &KParts::ReadOnlyPart::started, this, &Part::slotJobStarted); | ||
374 | 374 | | |||
375 | // connect the completed signal so we can put the window caption when loading remote files | 375 | // connect the completed signal so we can put the window caption when loading remote files | ||
376 | connect(this, SIGNAL(completed()), this, SLOT(setWindowTitleFromDocument())); | 376 | connect(this, SIGNAL(completed()), this, SLOT(setWindowTitleFromDocument())); | ||
377 | connect(this, &KParts::ReadOnlyPart::canceled, this, &Part::loadCancelled); | 377 | connect(this, &KParts::ReadOnlyPart::canceled, this, &Part::loadCancelled); | ||
378 | 378 | | |||
aacid: You don't need this, just do it after open. | |||||
379 | // create browser extension (for printing when embedded into browser) | 379 | // create browser extension (for printing when embedded into browser) | ||
380 | m_bExtension = new BrowserExtension(this); | 380 | m_bExtension = new BrowserExtension(this); | ||
381 | // create live connect extension (for integrating with browser scripting) | 381 | // create live connect extension (for integrating with browser scripting) | ||
382 | new OkularLiveConnectExtension( this ); | 382 | new OkularLiveConnectExtension( this ); | ||
383 | 383 | | |||
384 | GuiUtils::addIconLoader( iconLoader() ); | 384 | GuiUtils::addIconLoader( iconLoader() ); | ||
385 | 385 | | |||
386 | m_sidebar = new Sidebar( parentWidget ); | 386 | m_sidebar = new Sidebar( parentWidget ); | ||
▲ Show 20 Lines • Show All 1205 Lines • ▼ Show 20 Line(s) | 1591 | #endif | |||
1592 | if ( isCompressedFile ) | 1592 | if ( isCompressedFile ) | ||
1593 | { | 1593 | { | ||
1594 | m_realUrl = url(); | 1594 | m_realUrl = url(); | ||
1595 | } | 1595 | } | ||
1596 | #ifdef OKULAR_KEEP_FILE_OPEN | 1596 | #ifdef OKULAR_KEEP_FILE_OPEN | ||
1597 | if ( keepFileOpen() ) | 1597 | if ( keepFileOpen() ) | ||
1598 | m_keeper->open( fileNameToOpen ); | 1598 | m_keeper->open( fileNameToOpen ); | ||
1599 | #endif | 1599 | #endif | ||
1600 | | ||||
1601 | // Tries to find the text passed from terminal after the file is open | ||||
1602 | if(!m_textToFindOnOpen.isEmpty()) | ||||
just move the code of the function here, it's three lines and makes it clearer it's something we only do here. aacid: just move the code of the function here, it's three lines and makes it clearer it's something… | |||||
1603 | { | ||||
1604 | m_findBar->startSearch(m_textToFindOnOpen); | ||||
1605 | m_textToFindOnOpen = QString(); | ||||
1606 | } | ||||
1607 | | ||||
1600 | } | 1608 | } | ||
1601 | if ( m_exportAsText ) m_exportAsText->setEnabled( ok && m_document->canExportToText() ); | 1609 | if ( m_exportAsText ) m_exportAsText->setEnabled( ok && m_document->canExportToText() ); | ||
1602 | if ( m_exportAs ) m_exportAs->setEnabled( ok ); | 1610 | if ( m_exportAs ) m_exportAs->setEnabled( ok ); | ||
1603 | #if PURPOSE_FOUND | 1611 | #if PURPOSE_FOUND | ||
1604 | if ( m_share ) m_share->setEnabled( ok ); | 1612 | if ( m_share ) m_share->setEnabled( ok ); | ||
1605 | #endif | 1613 | #endif | ||
1606 | 1614 | | |||
1607 | // update viewing actions | 1615 | // update viewing actions | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 1697 | { | |||
1706 | url.setFragment( QString() ); | 1714 | url.setFragment( QString() ); | ||
1707 | } | 1715 | } | ||
1708 | 1716 | | |||
1709 | // this calls in sequence the 'closeUrl' and 'openFile' methods | 1717 | // this calls in sequence the 'closeUrl' and 'openFile' methods | ||
1710 | bool openOk = KParts::ReadWritePart::openUrl( url ); | 1718 | bool openOk = KParts::ReadWritePart::openUrl( url ); | ||
1711 | 1719 | | |||
1712 | if ( openOk ) | 1720 | if ( openOk ) | ||
1713 | { | 1721 | { | ||
1714 | m_viewportDirty.pageNumber = -1; | 1722 | m_viewportDirty.pageNumber = -1; | ||
That is, move the code from findTextOnStartUp here, also clean up the textToFind variable. aacid: That is, move the code from findTextOnStartUp here, also clean up the textToFind variable. | |||||
joaonetto: Tried this, didn't work for network files | |||||
aacid: Right, you actually want it in openFile() not in openUrl, sorry :) | |||||
1715 | 1723 | | |||
1716 | setWindowTitleFromDocument(); | 1724 | setWindowTitleFromDocument(); | ||
1717 | } | 1725 | } | ||
1718 | else | 1726 | else | ||
1719 | { | 1727 | { | ||
1720 | resetStartArguments(); | 1728 | resetStartArguments(); | ||
1721 | KMessageBox::error( widget(), i18n("Could not open %1", url.toDisplayString() ) ); | 1729 | KMessageBox::error( widget(), i18n("Could not open %1", url.toDisplayString() ) ); | ||
1722 | } | 1730 | } | ||
1723 | 1731 | | |||
Is this some bad practices? I'm sending as ID for search 1, since it's the first search, fromStart is set as false, since the document could be in another page. Change viewport is set as 1, since it has to change. Everything else I set default values, one problem is that I can't continue the search, I just find the first ocurrence. joaonetto: Is this some bad practices? I'm sending as ID for search 1, since it's the first search… | |||||
1724 | return openOk; | 1732 | return openOk; | ||
1725 | } | 1733 | } | ||
1726 | 1734 | | |||
1727 | bool Part::queryClose() | 1735 | bool Part::queryClose() | ||
1728 | { | 1736 | { | ||
1729 | if ( !isReadWrite() || !isModified() ) | 1737 | if ( !isReadWrite() || !isModified() ) | ||
yurchor: Trailing spaces | |||||
1730 | return true; | 1738 | return true; | ||
1731 | 1739 | | |||
1732 | // TODO When we get different saving backends we need to query the backend | 1740 | // TODO When we get different saving backends we need to query the backend | ||
1733 | // as to if it can save changes even if the open file has been modified, | 1741 | // as to if it can save changes even if the open file has been modified, | ||
1734 | // since we only have poppler as saving backend for now we're skipping that check | 1742 | // since we only have poppler as saving backend for now we're skipping that check | ||
1735 | if ( m_fileLastModified != QFileInfo( localFilePath() ).lastModified() ) | 1743 | if ( m_fileLastModified != QFileInfo( localFilePath() ).lastModified() ) | ||
1736 | { | 1744 | { | ||
1737 | int res; | 1745 | int res; | ||
▲ Show 20 Lines • Show All 1869 Lines • ▼ Show 20 Line(s) | |||||
3607 | #endif | 3615 | #endif | ||
3608 | 3616 | | |||
3609 | void Part::setReadWrite(bool readwrite) | 3617 | void Part::setReadWrite(bool readwrite) | ||
3610 | { | 3618 | { | ||
3611 | m_document->setAnnotationEditingEnabled( readwrite ); | 3619 | m_document->setAnnotationEditingEnabled( readwrite ); | ||
3612 | ReadWritePart::setReadWrite( readwrite ); | 3620 | ReadWritePart::setReadWrite( readwrite ); | ||
3613 | } | 3621 | } | ||
3614 | 3622 | | |||
3623 | void Part::enableStartWithFind(const QString &text) | ||||
3624 | { | ||||
3625 | m_textToFindOnOpen = QString(text); | ||||
3626 | } | ||||
3627 | | ||||
3615 | } // namespace Okular | 3628 | } // namespace Okular | ||
3616 | 3629 | | |||
3617 | #include "part.moc" | 3630 | #include "part.moc" | ||
3618 | 3631 | | |||
3619 | /* kate: replace-tabs on; indent-width 4; */ | 3632 | /* kate: replace-tabs on; indent-width 4; */ | ||
This won't matter since i asked you to move m_textToFindOnOpen to be just a QString, but ehre you had a bug, you needed to reset m_textToFindOnOpen to nullptr after delete; aacid: This won't matter since i asked you to move m_textToFindOnOpen to be just a QString, but ehre… |
You don't need this, just do it after open.