Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Okular
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
John Zhang
Okular
Commits
bf673495
Commit
bf673495
authored
May 27, 2015
by
Saheb Preet Singh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added layers on the left sidebar
parent
146c6d85
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
173 additions
and
0 deletions
+173
-0
CMakeLists.txt
CMakeLists.txt
+1
-0
core/document.cpp
core/document.cpp
+13
-0
core/document.h
core/document.h
+11
-0
core/generator.h
core/generator.h
+6
-0
generators/poppler/generator_pdf.cpp
generators/poppler/generator_pdf.cpp
+5
-0
generators/poppler/generator_pdf.h
generators/poppler/generator_pdf.h
+1
-0
part.cpp
part.cpp
+13
-0
part.h
part.h
+3
-0
ui/layers.cpp
ui/layers.cpp
+77
-0
ui/layers.h
ui/layers.h
+43
-0
No files found.
CMakeLists.txt
View file @
bf673495
...
...
@@ -204,6 +204,7 @@ set(okularpart_SRCS
ui/toolaction.cpp
ui/tts.cpp
ui/videowidget.cpp
ui/layers.cpp
)
kde4_add_ui_files
(
okularpart_SRCS
...
...
core/document.cpp
View file @
bf673495
...
...
@@ -36,6 +36,7 @@
#include <QtGui/QPrintDialog>
#include <QStack>
#include <QUndoCommand>
#include <QAbstractItemModel>
#include <kaboutdata.h>
#include <kauthorized.h>
...
...
@@ -3737,6 +3738,13 @@ void Document::editFormButtons( int pageNumber, const QList< FormFieldButton* >&
d
->
m_undoStack
->
push
(
uc
);
}
void
Document
::
reloadDocument
()
const
{
const
int
numOfPages
=
pages
();
for
(
int
i
=
0
;
i
<
numOfPages
;
i
++
)
d
->
refreshPixmaps
(
i
);
}
BookmarkManager
*
Document
::
bookmarkManager
()
const
{
return
d
->
m_bookmarkManager
;
...
...
@@ -4563,6 +4571,11 @@ void Document::walletDataForFile( const QString &fileName, QString *walletName,
}
}
QAbstractItemModel
*
Document
::
layersModel
()
const
{
return
d
->
m_generator
?
d
->
m_generator
->
layersModel
()
:
NULL
;
}
void
DocumentPrivate
::
requestDone
(
PixmapRequest
*
req
)
{
if
(
!
req
)
...
...
core/document.h
View file @
bf673495
...
...
@@ -31,6 +31,7 @@ class KConfigDialog;
class
KXMLGUIClient
;
class
KUrl
;
class
DocumentItem
;
class
QAbstractItemModel
;
namespace
Okular
{
...
...
@@ -842,6 +843,11 @@ class OKULAR_EXPORT Document : public QObject
*/
void
walletDataForFile
(
const
QString
&
fileName
,
QString
*
walletName
,
QString
*
walletFolder
,
QString
*
walletKey
)
const
;
/**
* Returns the model for rendering layer or NULL if no layer is present
*/
QAbstractItemModel
*
layersModel
()
const
;
public
Q_SLOTS
:
/**
* This slot is called whenever the user changes the @p rotation of
...
...
@@ -918,6 +924,11 @@ class OKULAR_EXPORT Document : public QObject
const
QList
<
Okular
::
FormFieldButton
*
>
&
formButtons
,
const
QList
<
bool
>
&
newButtonStates
);
/**
* This slot is called to reload the pixmaps for whole document
*/
void
reloadDocument
()
const
;
Q_SIGNALS:
/**
* This signal is emitted whenever an action requests a
...
...
core/generator.h
View file @
bf673495
...
...
@@ -432,6 +432,12 @@ class OKULAR_EXPORT Generator : public QObject
*/
void
setDPI
(
const
QSizeF
&
dpi
);
/**
* Returns the 'layers model' object of the document or NULL if
* layers model is not available.
*/
virtual
QAbstractItemModel
*
layersModel
()
const
;
Q_SIGNALS:
/**
* This signal should be emitted whenever an error occurred in the generator.
...
...
generators/poppler/generator_pdf.cpp
View file @
bf673495
...
...
@@ -776,6 +776,11 @@ const QList<Okular::EmbeddedFile*> *PDFGenerator::embeddedFiles() const
return
&
docEmbeddedFiles
;
}
QAbstractItemModel
*
PDFGenerator
::
layersModel
()
const
{
return
pdfdoc
->
hasOptionalContent
()
?
pdfdoc
->
optionalContentModel
()
:
NULL
;
}
bool
PDFGenerator
::
isAllowed
(
Okular
::
Permission
permission
)
const
{
bool
b
=
true
;
...
...
generators/poppler/generator_pdf.h
View file @
bf673495
...
...
@@ -67,6 +67,7 @@ class PDFGenerator : public Okular::Generator, public Okular::ConfigInterface, p
Okular
::
FontInfo
::
List
fontsForPage
(
int
page
);
const
QList
<
Okular
::
EmbeddedFile
*>
*
embeddedFiles
()
const
;
PageSizeMetric
pagesSizeMetric
()
const
{
return
Pixels
;
}
QAbstractItemModel
*
layersModel
()
const
;
// [INHERITED] document information
bool
isAllowed
(
Okular
::
Permission
permission
)
const
;
...
...
part.cpp
View file @
bf673495
...
...
@@ -85,6 +85,7 @@
#include "ui/sidebar.h"
#include "ui/fileprinterpreview.h"
#include "ui/guiutils.h"
#include "ui/layers.h"
#include "conf/preferencesdialog.h"
#include "settings.h"
#include "core/action.h"
...
...
@@ -379,6 +380,12 @@ m_cliPresentation(false), m_cliPrint(false), m_embedMode(detectEmbedMode(parentW
tbIndex
=
m_sidebar
->
addItem
(
m_toc
,
KIcon
(
QApplication
::
isLeftToRight
()
?
"format-justify-left"
:
"format-justify-right"
),
i18n
(
"Contents"
)
);
enableTOC
(
false
);
// [left toolbox: Layers] | []
m_layers
=
new
Layers
(
0
,
m_document
);
connect
(
m_layers
,
SIGNAL
(
hasLayers
(
bool
)),
this
,
SLOT
(
enableLayers
(
bool
))
);
tbIndex
=
m_sidebar
->
addItem
(
m_layers
,
KIcon
(
"draw-freehand"
),
i18n
(
"Layers"
)
);
enableLayers
(
false
);
// [left toolbox: Thumbnails and Bookmarks] | []
KVBox
*
thumbsBox
=
new
ThumbnailsBox
(
0
);
thumbsBox
->
setSpacing
(
6
);
...
...
@@ -854,6 +861,7 @@ Part::~Part()
Part
::
closeUrl
(
false
);
delete
m_toc
;
delete
m_layers
;
delete
m_pageView
;
delete
m_thumbnailList
;
delete
m_miniBar
;
...
...
@@ -1935,6 +1943,11 @@ void Part::slotRebuildBookmarkMenu()
rebuildBookmarkMenu
();
}
void
Part
::
enableLayers
(
bool
enable
)
{
m_sidebar
->
setItemEnabled
(
1
,
enable
);
}
void
Part
::
slotShowFindBar
()
{
m_findBar
->
show
();
...
...
part.h
View file @
bf673495
...
...
@@ -64,6 +64,7 @@ class MiniBarLogic;
class
FileKeeper
;
class
Reviews
;
class
BookmarkList
;
class
Layers
;
namespace
Okular
{
...
...
@@ -219,6 +220,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
void
updateBookmarksActions
();
void
enableTOC
(
bool
enable
);
void
slotRebuildBookmarkMenu
();
void
enableLayers
(
bool
enable
);
public
slots
:
// connected to Shell action (and browserExtension), not local one
...
...
@@ -278,6 +280,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
QPointer
<
PageSizeLabel
>
m_pageSizeLabel
;
QPointer
<
Reviews
>
m_reviewsWidget
;
QPointer
<
BookmarkList
>
m_bookmarkList
;
QPointer
<
Layers
>
m_layers
;
// document watcher (and reloader) variables
KDirWatch
*
m_watcher
;
...
...
ui/layers.cpp
0 → 100644
View file @
bf673495
#include "layers.h"
#include "settings.h"
// qt/kde includes
#include <QVBoxLayout>
#include <QTreeView>
#include <qheaderview.h>
// local includes
#include "core/document.h"
#include "ktreeviewsearchline.h"
Layers
::
Layers
(
QWidget
*
parent
,
Okular
::
Document
*
document
)
:
QWidget
(
parent
),
m_document
(
document
)
{
QVBoxLayout
*
const
mainlay
=
new
QVBoxLayout
(
this
);
mainlay
->
setMargin
(
0
);
mainlay
->
setSpacing
(
6
);
m_document
->
addObserver
(
this
);
m_searchLine
=
new
KTreeViewSearchLine
(
this
);
mainlay
->
addWidget
(
m_searchLine
);
m_searchLine
->
setCaseSensitivity
(
Okular
::
Settings
::
self
()
->
contentsSearchCaseSensitive
()
?
Qt
::
CaseSensitive
:
Qt
::
CaseInsensitive
);
m_searchLine
->
setRegularExpression
(
Okular
::
Settings
::
self
()
->
contentsSearchRegularExpression
()
);
connect
(
m_searchLine
,
SIGNAL
(
searchOptionsChanged
()),
this
,
SLOT
(
saveSearchOptions
())
);
m_treeView
=
new
QTreeView
(
this
);
mainlay
->
addWidget
(
m_treeView
);
QAbstractItemModel
*
layersModel
=
m_document
->
layersModel
();
if
(
layersModel
)
{
m_treeView
->
setModel
(
layersModel
);
m_searchLine
->
addTreeView
(
m_treeView
);
emit
hasLayers
(
true
);
connect
(
layersModel
,
SIGNAL
(
dataChanged
(
QModelIndex
,
QModelIndex
)),
m_document
,
SLOT
(
reloadDocument
())
);
}
else
{
emit
hasLayers
(
false
);
}
m_treeView
->
setSortingEnabled
(
false
);
m_treeView
->
setRootIsDecorated
(
true
);
m_treeView
->
setAlternatingRowColors
(
true
);
m_treeView
->
header
()
->
hide
();
}
Layers
::~
Layers
()
{
m_document
->
removeObserver
(
this
);
}
void
Layers
::
notifySetup
(
const
QVector
<
Okular
::
Page
*
>
&
/*pages*/
,
int
/*setupFlags*/
)
{
QAbstractItemModel
*
layersModel
=
m_document
->
layersModel
();
if
(
layersModel
)
{
m_treeView
->
setModel
(
layersModel
);
m_searchLine
->
addTreeView
(
m_treeView
);
emit
hasLayers
(
true
);
connect
(
layersModel
,
SIGNAL
(
dataChanged
(
QModelIndex
,
QModelIndex
)),
m_document
,
SLOT
(
reloadDocument
())
);
}
else
{
emit
hasLayers
(
false
);
}
}
void
Layers
::
saveSearchOptions
()
{
Okular
::
Settings
::
setContentsSearchRegularExpression
(
m_searchLine
->
regularExpression
()
);
Okular
::
Settings
::
setContentsSearchCaseSensitive
(
m_searchLine
->
caseSensitivity
()
==
Qt
::
CaseSensitive
?
true
:
false
);
Okular
::
Settings
::
self
()
->
writeConfig
();
}
#include "layers.moc"
ui/layers.h
0 → 100644
View file @
bf673495
#ifndef _OKULAR_LAYERS_H_
#define _OKULAR_LAYERS_H_
#include <qwidget.h>
#include "core/observer.h"
#include "okular_part_export.h"
class
QModelIndex
;
class
QTreeView
;
class
KTreeViewSearchLine
;
namespace
Okular
{
class
Document
;
class
PartTest
;
}
class
OKULAR_PART_EXPORT
Layers
:
public
QWidget
,
public
Okular
::
DocumentObserver
{
Q_OBJECT
friend
class
Okular
::
PartTest
;
public:
Layers
(
QWidget
*
parent
,
Okular
::
Document
*
document
);
~
Layers
();
// inherited from DocumentObserver
void
notifySetup
(
const
QVector
<
Okular
::
Page
*
>
&
pages
,
int
setupFlags
);
signals:
void
hasLayers
(
bool
has
);
private
slots
:
void
saveSearchOptions
();
private:
Okular
::
Document
*
m_document
;
QTreeView
*
m_treeView
;
KTreeViewSearchLine
*
m_searchLine
;
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment