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
75b7fd56
Commit
75b7fd56
authored
May 09, 2012
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handling the documents without zero page when using a program set to handle zero pages
parent
c601a639
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
148 additions
and
116 deletions
+148
-116
UBThumbnailAdaptor.cpp
src/adaptors/UBThumbnailAdaptor.cpp
+10
-1
UBFeaturesController.h
src/board/UBFeaturesController.h
+117
-105
UBPersistenceManager.cpp
src/core/UBPersistenceManager.cpp
+16
-1
UBDocumentController.cpp
src/document/UBDocumentController.cpp
+5
-9
No files found.
src/adaptors/UBThumbnailAdaptor.cpp
View file @
75b7fd56
...
...
@@ -45,7 +45,6 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
int
existingPageCount
=
proxy
->
pageCount
();
QString
thumbFileName
=
proxy
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
existingPageCount
);
QFile
thumbFile
(
thumbFileName
);
if
(
!
thumbFile
.
exists
())
...
...
@@ -67,6 +66,16 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
persistScene
(
proxy
->
persistencePath
(),
scene
,
i
);
}
else
{
if
(
i
==
0
){
// we are working a document without zero page but on a system that enable it
// we have to create an empty zero scene
scene
=
new
UBGraphicsScene
(
proxy
);
UBSvgSubsetAdaptor
::
persistScene
(
proxy
,
scene
,
0
);
persistScene
(
proxy
->
persistencePath
(),
scene
,
i
);
thumbCount
++
;
}
}
}
if
(
displayMessage
&&
thumbCount
>
0
)
...
...
src/board/UBFeaturesController.h
View file @
75b7fd56
...
...
@@ -12,128 +12,140 @@
#include <QUrl>
#include <QByteArray>
//#include "UBDockPaletteWidget.h"
enum
UBFeatureElementType
{
FEATURE_CATEGORY
,
FEATURE_VIRTUALFOLDER
,
FEATURE_FOLDER
,
FEATURE_INTERACTIVE
,
FEATURE_INTERNAL
,
FEATURE_INTERNAL
,
FEATURE_ITEM
,
FEATURE_TRASH
,
FEATURE_FAVORITE
,
FEATURE_SEARCH
FEATURE_TRASH
,
FEATURE_FAVORITE
,
FEATURE_SEARCH
};
class
UBFeature
{
public
:
UBFeature
()
{;}
//UBFeature(const UBFeature &f);
UBFeature
(
const
QString
&
url
,
const
QPixmap
&
icon
,
const
QString
&
name
,
const
QString
&
realPath
,
UBFeatureElementType
type
=
FEATURE_CATEGORY
);
virtual
~
UBFeature
()
{;}
QString
getName
()
const
{
return
mName
;
}
QPixmap
getThumbnail
()
const
{
return
mThumbnail
;}
QString
getUrl
()
const
{
return
virtualPath
;
}
//QString getPath() const { return mPath; };
QString
getFullPath
()
const
{
return
mPath
;
}
QString
getVirtualPath
()
const
{
return
virtualPath
+
"/"
+
mName
;
}
UBFeatureElementType
getType
()
const
{
return
elementType
;
}
bool
isFolder
()
const
;
bool
isDeletable
()
const
;
bool
operator
==
(
const
UBFeature
&
f
)
const
;
bool
operator
!=
(
const
UBFeature
&
f
)
const
;
private
:
QString
virtualPath
;
QPixmap
mThumbnail
;
QString
mName
;
QString
mPath
;
UBFeatureElementType
elementType
;
public
:
UBFeature
()
{;}
//UBFeature(const UBFeature &f);
UBFeature
(
const
QString
&
url
,
const
QPixmap
&
icon
,
const
QString
&
name
,
const
QUrl
&
realPath
,
UBFeatureElementType
type
=
FEATURE_CATEGORY
);
virtual
~
UBFeature
()
{;}
QString
getName
()
const
{
return
mName
;
}
QPixmap
getThumbnail
()
const
{
return
mThumbnail
;}
QString
getVirtualPath
()
const
{
return
virtualPath
;
}
//QString getPath() const { return mPath; };
QUrl
getFullPath
()
const
{
return
mPath
;
}
QString
getFullVirtualPath
()
const
{
return
virtualPath
+
"/"
+
mName
;
}
QString
getUrl
()
const
;
UBFeatureElementType
getType
()
const
{
return
elementType
;
}
bool
isFolder
()
const
;
bool
isDeletable
()
const
;
bool
operator
==
(
const
UBFeature
&
f
)
const
;
bool
operator
!=
(
const
UBFeature
&
f
)
const
;
const
QMap
<
QString
,
QString
>
&
getMetadata
()
const
{
return
metadata
;
}
void
setMetadata
(
const
QMap
<
QString
,
QString
>
&
data
)
{
metadata
=
data
;
}
private
:
QString
virtualPath
;
QPixmap
mThumbnail
;
QString
mName
;
QUrl
mPath
;
UBFeatureElementType
elementType
;
QMap
<
QString
,
QString
>
metadata
;
};
Q_DECLARE_METATYPE
(
UBFeature
)
class
UBFeaturesController
:
public
QObject
{
Q_OBJECT
public
:
UBFeaturesController
(
QWidget
*
parentWidget
);
virtual
~
UBFeaturesController
();
QList
<
UBFeature
>*
getFeatures
()
const
{
return
featuresList
;
}
const
QString
&
getRootPath
()
const
{
return
rootPath
;
}
void
addItemToPage
(
const
UBFeature
&
item
);
const
UBFeature
&
getCurrentElement
()
const
{
return
currentElement
;
}
void
setCurrentElement
(
const
UBFeature
&
elem
)
{
currentElement
=
elem
;
}
const
UBFeature
&
getTrashElement
()
const
{
return
trashElement
;
}
UBFeature
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
UBFeature
copyItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
void
deleteItem
(
const
QUrl
&
url
);
bool
isTrash
(
const
QUrl
&
url
);
UBFeature
newFolder
(
const
QString
&
name
);
UBFeature
addToFavorite
(
const
QUrl
&
path
);
void
removeFromFavorite
(
const
QUrl
&
path
);
static
QString
fileNameFromUrl
(
const
QUrl
&
url
);
static
QPixmap
thumbnailForFile
(
const
QString
&
path
);
static
bool
isDeletable
(
const
QUrl
&
url
);
private
:
void
initDirectoryTree
();
void
fileSystemScan
(
const
QString
&
currPath
,
const
QString
&
currVirtualPath
);
static
QPixmap
createThumbnail
(
const
QString
&
path
);
//void addImageToCurrentPage( const QString &path );
void
loadFavoriteList
();
void
saveFavoriteList
();
UBFeature
getDestinationForItem
(
const
QUrl
&
url
);
static
UBFeatureElementType
fileTypeFromUrl
(
const
QString
&
path
);
QList
<
UBFeature
>
*
featuresList
;
UBFeature
*
rootElement
;
QString
mUserAudioDirectoryPath
;
QString
mUserVideoDirectoryPath
;
QString
mUserPicturesDirectoryPath
;
QString
mUserInteractiveDirectoryPath
;
QString
mUserAnimationDirectoryPath
;
QString
libraryPath
;
QString
mLibAudioDirectoryPath
;
QString
mLibVideoDirectoryPath
;
QString
mLibPicturesDirectoryPath
;
QString
mLibInteractiveDirectoryPath
;
QString
mLibAnimationDirectoryPath
;
QString
mLibApplicationsDirectoryPath
;
QString
mLibShapesDirectoryPath
;
QString
trashDirectoryPath
;
QString
mLibSearchDirectoryPath
;
QString
rootPath
;
QString
audiosPath
;
QString
moviesPath
;
QString
picturesPath
;
QString
appPath
;
QString
flashPath
;
QString
shapesPath
;
QString
interactPath
;
QString
trashPath
;
QString
favoritePath
;
int
mLastItemOffsetIndex
;
UBFeature
currentElement
;
UBFeature
trashElement
;
UBFeature
favoriteElement
;
UBFeature
audiosElement
;
UBFeature
moviesElement
;
UBFeature
picturesElement
;
UBFeature
interactElement
;
UBFeature
flashElement
;
UBFeature
shapesElement
;
UBFeature
searchElement
;
QSet
<
QString
>
*
favoriteSet
;
Q_OBJECT
public
:
UBFeaturesController
(
QWidget
*
parentWidget
);
virtual
~
UBFeaturesController
();
QList
<
UBFeature
>*
getFeatures
()
const
{
return
featuresList
;
}
const
QString
&
getRootPath
()
const
{
return
rootPath
;
}
void
addItemToPage
(
const
UBFeature
&
item
);
void
addItemAsBackground
(
const
UBFeature
&
item
);
const
UBFeature
&
getCurrentElement
()
const
{
return
currentElement
;
}
void
setCurrentElement
(
const
UBFeature
&
elem
)
{
currentElement
=
elem
;
}
const
UBFeature
&
getTrashElement
()
const
{
return
trashElement
;
}
UBFeature
addDownloadedFile
(
const
QUrl
&
sourceUrl
,
const
QByteArray
&
pData
);
UBFeature
moveItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
UBFeature
copyItemToFolder
(
const
QUrl
&
url
,
const
UBFeature
&
destination
);
void
deleteItem
(
const
QUrl
&
url
);
bool
isTrash
(
const
QUrl
&
url
);
UBFeature
newFolder
(
const
QString
&
name
);
UBFeature
addToFavorite
(
const
QUrl
&
path
);
void
removeFromFavorite
(
const
QUrl
&
path
);
UBFeature
importImage
(
const
QImage
&
image
,
const
UBFeature
&
destination
);
static
QString
fileNameFromUrl
(
const
QUrl
&
url
);
static
QPixmap
thumbnailForFile
(
const
QString
&
path
);
static
bool
isDeletable
(
const
QUrl
&
url
);
private
:
void
initDirectoryTree
();
void
fileSystemScan
(
const
QUrl
&
currPath
,
const
QString
&
currVirtualPath
);
static
QPixmap
createThumbnail
(
const
QString
&
path
);
//void addImageToCurrentPage( const QString &path );
void
loadFavoriteList
();
void
saveFavoriteList
();
UBFeature
getDestinationForItem
(
const
QUrl
&
url
);
static
UBFeatureElementType
fileTypeFromUrl
(
const
QString
&
path
);
QList
<
UBFeature
>
*
featuresList
;
UBFeature
*
rootElement
;
QUrl
mUserAudioDirectoryPath
;
QUrl
mUserVideoDirectoryPath
;
QUrl
mUserPicturesDirectoryPath
;
QUrl
mUserInteractiveDirectoryPath
;
QUrl
mUserAnimationDirectoryPath
;
QString
libraryPath
;
QUrl
mLibAudioDirectoryPath
;
QUrl
mLibVideoDirectoryPath
;
QUrl
mLibPicturesDirectoryPath
;
QUrl
mLibInteractiveDirectoryPath
;
QUrl
mLibAnimationDirectoryPath
;
QUrl
mLibApplicationsDirectoryPath
;
QUrl
mLibShapesDirectoryPath
;
QUrl
trashDirectoryPath
;
QUrl
mLibSearchDirectoryPath
;
QString
rootPath
;
QString
audiosPath
;
QString
moviesPath
;
QString
picturesPath
;
QString
appPath
;
QString
flashPath
;
QString
shapesPath
;
QString
interactPath
;
QString
trashPath
;
QString
favoritePath
;
int
mLastItemOffsetIndex
;
UBFeature
currentElement
;
UBFeature
trashElement
;
UBFeature
favoriteElement
;
UBFeature
audiosElement
;
UBFeature
moviesElement
;
UBFeature
picturesElement
;
UBFeature
interactElement
;
UBFeature
flashElement
;
UBFeature
shapesElement
;
UBFeature
webSearchElement
;
QSet
<
QUrl
>
*
favoriteSet
;
};
...
...
src/core/UBPersistenceManager.cpp
View file @
75b7fd56
...
...
@@ -670,6 +670,7 @@ int UBPersistenceManager::sceneCountInDir(const QString& pPath)
{
int
pageIndex
=
0
;
bool
moreToProcess
=
true
;
bool
addedMissingZeroPage
=
false
;
while
(
moreToProcess
)
{
...
...
@@ -683,10 +684,24 @@ int UBPersistenceManager::sceneCountInDir(const QString& pPath)
}
else
{
moreToProcess
=
false
;
if
(
UBSettings
::
settings
()
->
teacherGuidePageZeroActivated
&&
pageIndex
==
0
){
// the document has no zero file but doesn't means that it hasn't any file
// at all. Just importing a document without the first page using a configuartion
// that enables zero page.
pageIndex
++
;
addedMissingZeroPage
=
true
;
}
else
moreToProcess
=
false
;
}
}
if
(
pageIndex
==
1
&&
addedMissingZeroPage
){
// increment is done only to check if there are other pages than the missing zero page
// This situation means -> no pages on the document
return
0
;
}
return
pageIndex
;
}
...
...
src/document/UBDocumentController.cpp
View file @
75b7fd56
...
...
@@ -168,7 +168,6 @@ void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurr
mDocumentUI
->
documentTreeWidget
->
scrollToItem
(
selected
);
mDocumentThumbs
=
UBThumbnailAdaptor
::
load
(
selectedDocumentProxy
());
qDebug
()
<<
mDocumentThumbs
.
size
();
refreshDocumentThumbnailsView
();
mSelectionType
=
Document
;
...
...
@@ -291,9 +290,9 @@ void UBDocumentController::refreshDocumentThumbnailsView()
}
items
<<
pixmapItem
;
labels
<<
tr
(
"Page %1"
).
arg
(
i
+
1
);
labels
<<
tr
(
"Page %1"
).
arg
(
UBApplication
::
boardController
->
pageFromSceneIndex
(
i
)
);
itemsPath
.
append
(
QUrl
::
fromLocalFile
(
proxy
->
persistencePath
()
+
QString
(
"/pages/%1"
).
arg
(
i
+
1
)));
itemsPath
.
append
(
QUrl
::
fromLocalFile
(
proxy
->
persistencePath
()
+
QString
(
"/pages/%1"
).
arg
(
UBApplication
::
boardController
->
pageFromSceneIndex
(
i
)
)));
}
}
...
...
@@ -307,15 +306,12 @@ void UBDocumentController::refreshDocumentThumbnailsView()
mDocumentUI
->
thumbnailWidget
->
ensureVisible
(
0
,
0
,
10
,
10
);
if
(
selection
)
{
disconnect
(
mDocumentUI
->
thumbnailWidget
->
scene
(),
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
pageSelectionChanged
()));
if
(
selection
)
{
disconnect
(
mDocumentUI
->
thumbnailWidget
->
scene
(),
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
pageSelectionChanged
()));
UBSceneThumbnailPixmap
*
currentScene
=
dynamic_cast
<
UBSceneThumbnailPixmap
*>
(
selection
);
if
(
currentScene
)
mDocumentUI
->
thumbnailWidget
->
hightlightItem
(
currentScene
->
sceneIndex
());
connect
(
mDocumentUI
->
thumbnailWidget
->
scene
(),
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
pageSelectionChanged
()));
connect
(
mDocumentUI
->
thumbnailWidget
->
scene
(),
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
pageSelectionChanged
()));
}
emit
refreshThumbnails
();
...
...
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