Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
2fd15cc0
Commit
2fd15cc0
authored
Feb 14, 2012
by
Anatoly Mihalchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved document navigation for the ticket 382.
parent
18925ab0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
50 deletions
+88
-50
UBThumbnailAdaptor.cpp
src/adaptors/UBThumbnailAdaptor.cpp
+61
-18
UBThumbnailAdaptor.h
src/adaptors/UBThumbnailAdaptor.h
+5
-10
UBBoardController.cpp
src/board/UBBoardController.cpp
+2
-3
UBDocumentNavigator.cpp
src/gui/UBDocumentNavigator.cpp
+19
-18
UBDocumentNavigator.h
src/gui/UBDocumentNavigator.h
+1
-1
No files found.
src/adaptors/UBThumbnailAdaptor.cpp
View file @
2fd15cc0
...
@@ -31,22 +31,8 @@
...
@@ -31,22 +31,8 @@
#include "core/memcheck.h"
#include "core/memcheck.h"
UBThumbnailAdaptor
::
UBThumbnailAdaptor
(
QObject
*
parent
)
:
QObject
(
parent
)
{
// NOOP
}
UBThumbnailAdaptor
::~
UBThumbnailAdaptor
()
{
// NOOP
}
QList
<
QPixmap
>
UBThumbnailAdaptor
::
load
(
UBDocumentProxy
*
proxy
)
QList
<
QPixmap
>
UBThumbnailAdaptor
::
load
(
UBDocumentProxy
*
proxy
)
{
{
QList
<
QPixmap
>
thumbnails
;
QList
<
QPixmap
>
thumbnails
;
if
(
!
proxy
||
proxy
->
persistencePath
().
size
()
==
0
)
if
(
!
proxy
||
proxy
->
persistencePath
().
size
()
==
0
)
...
@@ -76,14 +62,14 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
...
@@ -76,14 +62,14 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
thumbCount
++
;
thumbCount
++
;
if
(
displayMessage
&&
thumbCount
==
1
)
if
(
displayMessage
&&
thumbCount
==
1
)
UBApplication
::
showMessage
(
tr
(
"Generating preview thumbnails ..."
));
UBApplication
::
showMessage
(
QObject
::
tr
(
"Generating preview thumbnails ..."
));
persistScene
(
proxy
->
persistencePath
(),
scene
,
i
);
persistScene
(
proxy
->
persistencePath
(),
scene
,
i
);
}
}
}
}
if
(
displayMessage
&&
thumbCount
>
0
)
if
(
displayMessage
&&
thumbCount
>
0
)
UBApplication
::
showMessage
(
tr
(
"%1 thumbnails generated ..."
).
arg
(
thumbCount
));
UBApplication
::
showMessage
(
QObject
::
tr
(
"%1 thumbnails generated ..."
).
arg
(
thumbCount
));
}
}
...
@@ -114,8 +100,65 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
...
@@ -114,8 +100,65 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
return
thumbnails
;
return
thumbnails
;
}
}
QPixmap
UBThumbnailAdaptor
::
load
(
UBDocumentProxy
*
proxy
,
int
index
)
{
int
existingPageCount
=
proxy
->
pageCount
();
if
(
!
proxy
||
proxy
->
persistencePath
().
size
()
==
0
||
index
<
0
||
index
>=
existingPageCount
)
return
QPixmap
();
//compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails
QString
thumbFileName
=
proxy
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
existingPageCount
);
QFile
thumbFile
(
thumbFileName
);
if
(
!
thumbFile
.
exists
())
{
bool
displayMessage
=
(
existingPageCount
>
5
);
int
thumbCount
=
0
;
for
(
int
i
=
0
;
i
<
existingPageCount
;
i
++
)
{
UBGraphicsScene
*
scene
=
UBSvgSubsetAdaptor
::
loadScene
(
proxy
,
i
);
if
(
scene
)
{
thumbCount
++
;
if
(
displayMessage
&&
thumbCount
==
1
)
UBApplication
::
showMessage
(
QObject
::
tr
(
"Generating preview thumbnails ..."
));
persistScene
(
proxy
->
persistencePath
(),
scene
,
i
);
}
}
if
(
displayMessage
&&
thumbCount
>
0
)
UBApplication
::
showMessage
(
QObject
::
tr
(
"%1 thumbnails generated ..."
).
arg
(
thumbCount
));
}
//end compatibility with older format
QString
fileName
=
proxy
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
index
+
1
);
QFile
file
(
fileName
);
if
(
file
.
exists
())
{
QPixmap
pix
;
//Warning. Works only with modified Qt
#ifdef Q_WS_X11
pix
.
load
(
fileName
,
0
,
Qt
::
AutoColor
);
#else
pix
.
load
(
fileName
,
0
,
Qt
::
AutoColor
,
false
);
#endif
return
pix
;
}
return
QPixmap
();
}
void
UBThumbnailAdaptor
::
persistScene
(
const
QString
&
pDocPath
,
UBGraphicsScene
*
pScene
,
const
int
pageIndex
,
const
bool
overrideModified
)
void
UBThumbnailAdaptor
::
persistScene
(
const
QString
&
pDocPath
,
UBGraphicsScene
*
pScene
,
int
pageIndex
,
bool
overrideModified
)
{
{
QString
fileName
=
pDocPath
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
pageIndex
+
1
);
QString
fileName
=
pDocPath
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
pageIndex
+
1
);
...
@@ -161,7 +204,7 @@ void UBThumbnailAdaptor::persistScene(const QString& pDocPath, UBGraphicsScene*
...
@@ -161,7 +204,7 @@ void UBThumbnailAdaptor::persistScene(const QString& pDocPath, UBGraphicsScene*
}
}
QUrl
UBThumbnailAdaptor
::
thumbnailUrl
(
UBDocumentProxy
*
proxy
,
const
int
pageIndex
)
QUrl
UBThumbnailAdaptor
::
thumbnailUrl
(
UBDocumentProxy
*
proxy
,
int
pageIndex
)
{
{
QString
fileName
=
proxy
->
persistencePath
()
+
QString
fileName
=
proxy
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
pageIndex
+
1
);
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
pageIndex
+
1
);
...
...
src/adaptors/UBThumbnailAdaptor.h
View file @
2fd15cc0
...
@@ -21,21 +21,16 @@ class UBDocument;
...
@@ -21,21 +21,16 @@ class UBDocument;
class
UBDocumentProxy
;
class
UBDocumentProxy
;
class
UBGraphicsScene
;
class
UBGraphicsScene
;
class
UBThumbnailAdaptor
:
public
QObject
class
UBThumbnailAdaptor
//static class
{
{
Q_OBJECT
;
private
:
UBThumbnailAdaptor
()
{}
public
:
public
:
static
void
persistScene
(
const
QString
&
pDocPath
,
UBGraphicsScene
*
pScene
,
int
pageIndex
,
bool
overrideModified
=
false
);
UBThumbnailAdaptor
(
QObject
*
parent
=
0
);
~
UBThumbnailAdaptor
();
static
void
persistScene
(
const
QString
&
pDocPath
,
UBGraphicsScene
*
pScene
,
const
int
pageIndex
,
const
bool
overrideModified
=
false
);
static
QList
<
QPixmap
>
load
(
UBDocumentProxy
*
proxy
);
static
QList
<
QPixmap
>
load
(
UBDocumentProxy
*
proxy
);
static
QPixmap
load
(
UBDocumentProxy
*
proxy
,
int
index
);
static
QUrl
thumbnailUrl
(
UBDocumentProxy
*
proxy
,
const
int
pageIndex
);
static
QUrl
thumbnailUrl
(
UBDocumentProxy
*
proxy
,
int
pageIndex
);
};
};
#endif // UBTHUMBNAILADAPTOR_H
#endif // UBTHUMBNAILADAPTOR_H
src/board/UBBoardController.cpp
View file @
2fd15cc0
...
@@ -1166,11 +1166,10 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
...
@@ -1166,11 +1166,10 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
{
{
emit
activeDocumentChanged
();
emit
activeDocumentChanged
();
UBGraphicsTextItem
::
lastUsedTextColor
=
QColor
();
UBGraphicsTextItem
::
lastUsedTextColor
=
QColor
();
// Notify the navigator palette that the document has changed
emit
setDocOnPageNavigator
(
pDocumentProxy
);
}
}
// Notify the navigator palette that the document has changed
emit
setDocOnPageNavigator
(
pDocumentProxy
);
if
(
sceneChange
)
if
(
sceneChange
)
{
{
emit
activeSceneChanged
();
emit
activeSceneChanged
();
...
...
src/gui/UBDocumentNavigator.cpp
View file @
2fd15cc0
...
@@ -99,7 +99,7 @@ void UBDocumentNavigator::setDocument(UBDocumentProxy *document)
...
@@ -99,7 +99,7 @@ void UBDocumentNavigator::setDocument(UBDocumentProxy *document)
*/
*/
void
UBDocumentNavigator
::
generateThumbnails
()
void
UBDocumentNavigator
::
generateThumbnails
()
{
{
// Get the thumbnails
// Get the thumbnails
QList
<
QPixmap
>
thumbs
=
UBThumbnailAdaptor
::
load
(
mCrntDoc
);
QList
<
QPixmap
>
thumbs
=
UBThumbnailAdaptor
::
load
(
mCrntDoc
);
mThumbsWithLabels
.
clear
();
mThumbsWithLabels
.
clear
();
...
@@ -155,9 +155,8 @@ void UBDocumentNavigator::updateSpecificThumbnail(int iPage)
...
@@ -155,9 +155,8 @@ void UBDocumentNavigator::updateSpecificThumbnail(int iPage)
UBThumbnailAdaptor
::
persistScene
(
mCrntDoc
->
persistencePath
(),
pScene
,
iPage
);
UBThumbnailAdaptor
::
persistScene
(
mCrntDoc
->
persistencePath
(),
pScene
,
iPage
);
// Load it
// Load it
QList
<
QPixmap
>
thumbs
=
UBThumbnailAdaptor
::
load
(
mCrntDoc
);
QPixmap
pix
=
UBThumbnailAdaptor
::
load
(
mCrntDoc
,
iPage
);
QPixmap
pix
=
thumbs
.
at
(
iPage
);
UBSceneThumbnailNavigPixmap
*
pixmapItem
=
new
UBSceneThumbnailNavigPixmap
(
pix
,
mCrntDoc
,
iPage
);
QGraphicsPixmapItem
*
pixmapItem
=
new
UBSceneThumbnailNavigPixmap
(
pix
,
mCrntDoc
,
iPage
);
if
(
pixmapItem
)
if
(
pixmapItem
)
{
{
// Get the old thumbnail
// Get the old thumbnail
...
@@ -307,27 +306,29 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event)
...
@@ -307,27 +306,29 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event)
}
}
}
}
}
}
else
else
{
{
if
(
NULL
!=
mCrntItem
&&
mCrntItem
!=
pCrntItem
)
if
(
NULL
!=
mCrntItem
&&
mCrntItem
!=
pCrntItem
)
{
{
// Unselect the previous item
// Unselect the previous item
int
iOldPage
=
-
1
;
mCrntItem
->
setSelected
(
false
);
int
iOldPage
=
-
1
;
for
(
int
i
=
0
;
i
<
mThumbsWithLabels
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
mThumbsWithLabels
.
size
();
i
++
)
if
(
mThumbsWithLabels
.
at
(
i
).
getThumbnail
()
==
mCrntItem
)
if
(
mThumbsWithLabels
.
at
(
i
).
getThumbnail
()
==
mCrntItem
)
{
{
iOldPage
=
i
;
iOldPage
=
i
;
break
;
break
;
}
}
updateSpecificThumbnail
(
iOldPage
);
updateSpecificThumbnail
(
iOldPage
);
mCrntItem
=
pCrntItem
;
mCrntItem
=
pCrntItem
;
}
}
// Then display the related page
// Then display the related page
emit
changeCurrentPage
();
emit
changeCurrentPage
();
refreshScene
();
refreshScene
();
}
}
bNavig
=
false
;
bNavig
=
false
;
}
}
QGraphicsView
::
mousePressEvent
(
event
);
QGraphicsView
::
mousePressEvent
(
event
);
}
}
...
...
src/gui/UBDocumentNavigator.h
View file @
2fd15cc0
...
@@ -58,7 +58,7 @@ private slots:
...
@@ -58,7 +58,7 @@ private slots:
private
:
private
:
void
refreshScene
();
void
refreshScene
();
void
updateSpecificThumbnail
(
int
iPage
);
void
updateSpecificThumbnail
(
int
iPage
);
int
border
();
int
border
();
...
...
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