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
af6dc9c6
Commit
af6dc9c6
authored
Mar 04, 2014
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge
parent
d3661633
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
695 additions
and
526 deletions
+695
-526
OpenBoard.css
resources/etc/OpenBoard.css
+383
-377
UBDocumentController.cpp
src/document/UBDocumentController.cpp
+174
-122
UBDocumentController.h
src/document/UBDocumentController.h
+10
-0
UBDocumentProxy.cpp
src/document/UBDocumentProxy.cpp
+1
-1
UBDocumentTreeWidget.cpp
src/gui/UBDocumentTreeWidget.cpp
+116
-25
UBDocumentTreeWidget.h
src/gui/UBDocumentTreeWidget.h
+11
-1
No files found.
resources/etc/OpenBoard.css
View file @
af6dc9c6
...
@@ -380,3 +380,9 @@ QLineEdit#ubWebBrowserLineEdit
...
@@ -380,3 +380,9 @@ QLineEdit#ubWebBrowserLineEdit
padding
:
2
2px
;
padding
:
2
2px
;
background
:
white
;
background
:
white
;
}
}
QSplitter
{
background-color
:
#b3b3b3
;
width
:
15px
;
src/document/UBDocumentController.cpp
View file @
af6dc9c6
...
@@ -103,7 +103,9 @@ void UBDocumentController::createNewDocument()
...
@@ -103,7 +103,9 @@ void UBDocumentController::createNewDocument()
if
(
group
)
if
(
group
)
{
{
UBDocumentProxy
*
document
=
UBPersistenceManager
::
persistenceManager
()
->
createDocument
(
group
->
groupName
());
QString
path
=
group
->
buildEntirePath
();
UBDocumentProxy
*
document
=
UBPersistenceManager
::
persistenceManager
()
->
createDocument
(
path
);
selectDocument
(
document
);
selectDocument
(
document
);
}
}
...
@@ -201,7 +203,19 @@ void UBDocumentController::createNewDocumentGroup()
...
@@ -201,7 +203,19 @@ void UBDocumentController::createNewDocumentGroup()
int
trashIndex
=
mDocumentUI
->
documentTreeWidget
->
indexOfTopLevelItem
(
mTrashTi
);
int
trashIndex
=
mDocumentUI
->
documentTreeWidget
->
indexOfTopLevelItem
(
mTrashTi
);
UBDocumentGroupTreeItem
*
selected
=
selectedDocumentGroupTreeItem
();
QString
parentGroupName
(
""
);
if
(
selected
->
groupName
().
contains
(
mDefaultDocumentGroupName
))
mDocumentUI
->
documentTreeWidget
->
insertTopLevelItem
(
trashIndex
,
docGroupItem
);
mDocumentUI
->
documentTreeWidget
->
insertTopLevelItem
(
trashIndex
,
docGroupItem
);
else
selected
->
addChild
(
docGroupItem
);
parentGroupName
=
docGroupItem
->
buildEntirePath
();
mMapOfPaths
.
insert
(
parentGroupName
,
docGroupItem
);
mDocumentUI
->
documentTreeWidget
->
setCurrentItem
(
docGroupItem
);
mDocumentUI
->
documentTreeWidget
->
setCurrentItem
(
docGroupItem
);
mDocumentUI
->
documentTreeWidget
->
expandItem
(
docGroupItem
);
mDocumentUI
->
documentTreeWidget
->
expandItem
(
docGroupItem
);
}
}
...
@@ -293,8 +307,7 @@ void UBDocumentController::setupViews()
...
@@ -293,8 +307,7 @@ void UBDocumentController::setupViews()
mDocumentUI
->
documentZoomSlider
->
setValue
(
thumbWidth
);
mDocumentUI
->
documentZoomSlider
->
setValue
(
thumbWidth
);
mDocumentUI
->
thumbnailWidget
->
setThumbnailWidth
(
thumbWidth
);
mDocumentUI
->
thumbnailWidget
->
setThumbnailWidth
(
thumbWidth
);
connect
(
mDocumentUI
->
documentZoomSlider
,
SIGNAL
(
valueChanged
(
int
)),
this
,
connect
(
mDocumentUI
->
documentZoomSlider
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
documentZoomSliderValueChanged
(
int
)));
SLOT
(
documentZoomSliderValueChanged
(
int
)));
connect
(
mMainWindow
->
actionOpen
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
openSelectedItem
()));
connect
(
mMainWindow
->
actionOpen
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
openSelectedItem
()));
connect
(
mMainWindow
->
actionNewFolder
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
createNewDocumentGroup
()));
connect
(
mMainWindow
->
actionNewFolder
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
createNewDocumentGroup
()));
...
@@ -612,6 +625,38 @@ void UBDocumentController::moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi,
...
@@ -612,6 +625,38 @@ void UBDocumentController::moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi,
proxyTi
->
setFlags
(
proxyTi
->
flags
()
^
Qt
::
ItemIsEditable
);
proxyTi
->
setFlags
(
proxyTi
->
flags
()
^
Qt
::
ItemIsEditable
);
}
}
QList
<
UBDocumentProxyTreeItem
*>
UBDocumentController
::
getProxies
(
QTreeWidgetItem
*
groupItem
)
{
QList
<
UBDocumentProxyTreeItem
*>
result
;
for
(
int
i
=
0
;
i
<
groupItem
->
childCount
();
i
+=
1
){
UBDocumentProxyTreeItem
*
docProxy
=
dynamic_cast
<
UBDocumentProxyTreeItem
*>
(
groupItem
->
child
(
i
));
if
(
docProxy
)
result
.
append
(
docProxy
);
else
result
<<
getProxies
(
groupItem
->
child
(
i
));
}
return
result
;
}
QList
<
UBDocumentGroupTreeItem
*>
UBDocumentController
::
getGroupTreeItem
(
QTreeWidgetItem
*
groupItem
)
{
QList
<
UBDocumentGroupTreeItem
*>
result
;
for
(
int
i
=
0
;
i
<
groupItem
->
childCount
();
i
+=
1
){
UBDocumentGroupTreeItem
*
group
=
dynamic_cast
<
UBDocumentGroupTreeItem
*>
(
groupItem
->
child
(
i
));
if
(
group
)
result
.
append
(
group
);
else
result
<<
getGroupTreeItem
(
groupItem
->
child
(
i
));
}
return
result
;
}
void
UBDocumentController
::
moveFolderToTrash
(
UBDocumentGroupTreeItem
*
groupTi
)
void
UBDocumentController
::
moveFolderToTrash
(
UBDocumentGroupTreeItem
*
groupTi
)
{
{
bool
changeCurrentDocument
=
false
;
bool
changeCurrentDocument
=
false
;
...
@@ -625,14 +670,9 @@ void UBDocumentController::moveFolderToTrash(UBDocumentGroupTreeItem* groupTi)
...
@@ -625,14 +670,9 @@ void UBDocumentController::moveFolderToTrash(UBDocumentGroupTreeItem* groupTi)
}
}
}
}
QList
<
UBDocumentProxyTreeItem
*>
toBeDeleted
;
for
(
int
i
=
0
;
i
<
groupTi
->
childCount
();
i
++
)
{
QList
<
UBDocumentProxyTreeItem
*>
toBeDeleted
=
getProxies
(
groupTi
);
UBDocumentProxyTreeItem
*
proxyTi
=
dynamic_cast
<
UBDocumentProxyTreeItem
*>
(
groupTi
->
child
(
i
));
if
(
proxyTi
&&
proxyTi
->
proxy
())
toBeDeleted
<<
proxyTi
;
}
for
(
int
i
=
0
;
i
<
toBeDeleted
.
count
();
i
++
)
for
(
int
i
=
0
;
i
<
toBeDeleted
.
count
();
i
++
)
{
{
...
@@ -644,21 +684,38 @@ void UBDocumentController::moveFolderToTrash(UBDocumentGroupTreeItem* groupTi)
...
@@ -644,21 +684,38 @@ void UBDocumentController::moveFolderToTrash(UBDocumentGroupTreeItem* groupTi)
proxyTi
->
proxy
()
->
setMetaData
(
UBSettings
::
documentGroupName
,
UBSettings
::
trashedDocumentGroupNamePrefix
+
oldGroupName
);
proxyTi
->
proxy
()
->
setMetaData
(
UBSettings
::
documentGroupName
,
UBSettings
::
trashedDocumentGroupNamePrefix
+
oldGroupName
);
UBPersistenceManager
::
persistenceManager
()
->
persistDocumentMetadata
(
proxyTi
->
proxy
());
UBPersistenceManager
::
persistenceManager
()
->
persistDocumentMetadata
(
proxyTi
->
proxy
());
groupTi
->
removeChild
(
proxyTi
);
UBDocumentGroupTreeItem
*
parentDirectory
=
dynamic_cast
<
UBDocumentGroupTreeItem
*>
(
mMapOfPaths
.
value
(
oldGroupName
));
parentDirectory
->
removeChild
(
proxyTi
);
mTrashTi
->
addChild
(
proxyTi
);
mTrashTi
->
addChild
(
proxyTi
);
proxyTi
->
setFlags
(
proxyTi
->
flags
()
^
Qt
::
ItemIsEditable
);
proxyTi
->
setFlags
(
proxyTi
->
flags
()
^
Qt
::
ItemIsEditable
);
showMessage
(
QString
(
"%1 deleted"
).
arg
(
groupTi
->
groupName
()));
showMessage
(
QString
(
"%1 deleted"
).
arg
(
groupTi
->
groupName
()));
}
}
QList
<
UBDocumentGroupTreeItem
*>
dirToDelete
=
getGroupTreeItem
(
groupTi
);
for
(
int
i
=
dirToDelete
.
count
()
-
1
;
i
>=
0
;
i
-=
1
){
UBDocumentGroupTreeItem
*
parent
=
dynamic_cast
<
UBDocumentGroupTreeItem
*>
(
dirToDelete
.
at
(
i
)
->
parent
());
if
(
parent
){
mMapOfPaths
.
remove
(
dirToDelete
.
at
(
i
)
->
buildEntirePath
());
parent
->
removeChild
(
dirToDelete
.
at
(
i
));
}
}
// dont remove default group
// dont remove default group
if
(
!
groupTi
->
isDefaultFolder
())
if
(
!
groupTi
->
isDefaultFolder
())
{
{
int
index
=
mDocumentUI
->
documentTreeWidget
->
indexOfTopLevelItem
(
groupTi
);
int
index
=
mDocumentUI
->
documentTreeWidget
->
indexOfTopLevelItem
(
groupTi
);
if
(
index
>=
0
)
if
(
index
>=
0
)
{
mDocumentUI
->
documentTreeWidget
->
takeTopLevelItem
(
index
);
mDocumentUI
->
documentTreeWidget
->
takeTopLevelItem
(
index
);
else
{
UBDocumentGroupTreeItem
*
parent
=
dynamic_cast
<
UBDocumentGroupTreeItem
*>
(
groupTi
->
parent
());
if
(
parent
){
mMapOfPaths
.
remove
(
groupTi
->
buildEntirePath
());
parent
->
removeChild
(
groupTi
);
}
}
}
}
}
...
@@ -809,96 +866,56 @@ void UBDocumentController::documentZoomSliderValueChanged (int value)
...
@@ -809,96 +866,56 @@ void UBDocumentController::documentZoomSliderValueChanged (int value)
}
}
UBDocumentGroupTreeItem
*
UBDocumentController
::
getCommonGroupItem
(
QString
&
path
)
{
QList
<
QString
>
paths
=
mMapOfPaths
.
keys
();
if
(
paths
.
count
()
==
0
)
return
NULL
;
QString
commonPath
=
path
;
do
{
if
(
paths
.
contains
(
commonPath
))
return
mMapOfPaths
.
value
(
commonPath
);
else
{
int
lastSeparatorIndex
=
commonPath
.
lastIndexOf
(
"/"
);
if
(
lastSeparatorIndex
>
0
)
commonPath
=
commonPath
.
left
(
lastSeparatorIndex
);
else
commonPath
=
""
;
}
}
while
(
commonPath
.
length
()
>
0
);
return
NULL
;
}
void
UBDocumentController
::
loadDocumentProxies
()
void
UBDocumentController
::
loadDocumentProxies
()
{
{
QList
<
QPointer
<
UBDocumentProxy
>
>
proxies
=
UBPersistenceManager
::
persistenceManager
()
->
documentProxies
;
QList
<
QPointer
<
UBDocumentProxy
>
>
proxies
=
UBPersistenceManager
::
persistenceManager
()
->
documentProxies
;
QStringList
emptyGroupNames
=
UBSettings
::
settings
()
->
value
(
"Document/EmptyGroupNames"
,
QStringList
()).
toStringList
();
mDocumentUI
->
documentTreeWidget
->
clear
();
mDocumentUI
->
documentTreeWidget
->
clear
();
QMap
<
QString
,
UBDocumentGroupTreeItem
*>
groupNamesMap
;
UBDocumentGroupTreeItem
*
emptyGroupNameTi
=
new
UBDocumentGroupTreeItem
(
0
,
false
);
emptyGroupNameTi
->
setGroupName
(
mDefaultDocumentGroupName
);
UBDocumentGroupTreeItem
*
emptyGroupNameTi
=
0
;
emptyGroupNameTi
->
setIcon
(
0
,
QIcon
(
":/images/toolbar/documents.png"
));
mMapOfPaths
.
insert
(
mDefaultDocumentGroupName
,
emptyGroupNameTi
);
mTrashTi
=
new
UBDocumentGroupTreeItem
(
0
,
false
);
// deleted by the tree widget
mTrashTi
=
new
UBDocumentGroupTreeItem
(
0
,
false
);
// deleted by the tree widget
mTrashTi
->
setGroupName
(
mDocumentTrashGroupName
);
mTrashTi
->
setGroupName
(
mDocumentTrashGroupName
);
mTrashTi
->
setIcon
(
0
,
QIcon
(
":/images/trash.png"
));
mTrashTi
->
setIcon
(
0
,
QIcon
(
":/images/trash.png"
));
mMapOfPaths
.
insert
(
mDocumentTrashGroupName
,
mTrashTi
);
foreach
(
QPointer
<
UBDocumentProxy
>
proxy
,
proxies
)
mDocumentUI
->
documentTreeWidget
->
addTopLevelItem
(
emptyGroupNameTi
);
{
mDocumentUI
->
documentTreeWidget
->
addTopLevelItem
(
mTrashTi
);
if
(
proxy
)
{
QString
docGroup
=
proxy
->
metaData
(
UBSettings
::
documentGroupName
).
toString
();
bool
isEmptyGroupName
=
false
;
bool
isInTrash
=
false
;
if
(
docGroup
.
isEmpty
())
// #see https://trac.assembla.com/uniboard/ticket/426
{
docGroup
=
mDefaultDocumentGroupName
;
isEmptyGroupName
=
true
;
}
else
if
(
docGroup
.
startsWith
(
UBSettings
::
trashedDocumentGroupNamePrefix
))
{
isInTrash
=
true
;
}
QString
docName
=
proxy
->
metaData
(
UBSettings
::
documentName
).
toString
();
if
(
emptyGroupNames
.
contains
(
docGroup
))
emptyGroupNames
.
removeAll
(
docGroup
);
if
(
!
groupNamesMap
.
contains
(
docGroup
)
&&
!
isInTrash
)
{
UBDocumentGroupTreeItem
*
docGroupItem
=
new
UBDocumentGroupTreeItem
(
0
,
!
isEmptyGroupName
);
// deleted by the tree widget
groupNamesMap
.
insert
(
docGroup
,
docGroupItem
);
docGroupItem
->
setGroupName
(
docGroup
);
if
(
isEmptyGroupName
)
emptyGroupNameTi
=
docGroupItem
;
}
UBDocumentGroupTreeItem
*
docGroupItem
;
if
(
isInTrash
)
docGroupItem
=
mTrashTi
;
else
docGroupItem
=
groupNamesMap
.
value
(
docGroup
);
QTreeWidgetItem
*
docItem
=
new
UBDocumentProxyTreeItem
(
docGroupItem
,
proxy
,
!
isInTrash
);
docItem
->
setText
(
0
,
docName
);
if
(
mBoardController
->
selectedDocument
()
==
proxy
)
foreach
(
QPointer
<
UBDocumentProxy
>
proxy
,
proxies
)
{
{
mDocumentUI
->
documentTreeWidget
->
expandItem
(
docGroupItem
);
if
(
proxy
)
mDocumentUI
->
documentTreeWidget
->
setCurrentItem
(
docGroupItem
);
}
}
}
foreach
(
const
QString
emptyGroupName
,
emptyGroupNames
)
{
{
UBDocumentGroupTreeItem
*
docGroupItem
=
new
UBDocumentGroupTreeItem
(
0
);
// deleted by the tree widget
addDocumentInTree
(
proxy
);
groupNamesMap
.
insert
(
emptyGroupName
,
docGroupItem
);
docGroupItem
->
setGroupName
(
emptyGroupName
);
}
}
QList
<
QString
>
groupNamesList
=
groupNamesMap
.
keys
();
qSort
(
groupNamesList
);
foreach
(
const
QString
groupName
,
groupNamesList
)
{
UBDocumentGroupTreeItem
*
ti
=
groupNamesMap
.
value
(
groupName
);
if
(
ti
!=
emptyGroupNameTi
)
mDocumentUI
->
documentTreeWidget
->
addTopLevelItem
(
ti
);
}
}
if
(
emptyGroupNameTi
)
mDocumentUI
->
documentTreeWidget
->
addTopLevelItem
(
emptyGroupNameTi
);
mDocumentUI
->
documentTreeWidget
->
addTopLevelItem
(
mTrashTi
);
}
}
...
@@ -912,12 +929,27 @@ void UBDocumentController::itemClicked(QTreeWidgetItem * item, int column )
...
@@ -912,12 +929,27 @@ void UBDocumentController::itemClicked(QTreeWidgetItem * item, int column )
}
}
void
UBDocumentController
::
treeGroupItemRenamed
(
QString
&
oldPath
,
QString
&
newPath
)
{
if
(
oldPath
.
isEmpty
()
||
newPath
.
isEmpty
())
return
;
QList
<
QString
>
keys
=
mMapOfPaths
.
keys
();
for
(
int
i
=
0
;
i
<
keys
.
count
();
i
+=
1
){
QString
key
=
keys
.
at
(
i
);
if
(
key
.
startsWith
(
oldPath
)){
UBDocumentGroupTreeItem
*
value
=
mMapOfPaths
.
take
(
key
);
key
=
key
.
remove
(
0
,
oldPath
.
size
());
mMapOfPaths
.
insert
(
key
.
prepend
(
newPath
),
value
);
}
}
}
void
UBDocumentController
::
itemChanged
(
QTreeWidgetItem
*
item
,
int
column
)
void
UBDocumentController
::
itemChanged
(
QTreeWidgetItem
*
item
,
int
column
)
{
{
UBDocumentProxyTreeItem
*
proxyItem
=
dynamic_cast
<
UBDocumentProxyTreeItem
*>
(
item
);
UBDocumentProxyTreeItem
*
proxyItem
=
dynamic_cast
<
UBDocumentProxyTreeItem
*>
(
item
);
disconnect
(
UBPersistenceManager
::
persistenceManager
(),
SIGNAL
(
documentMetadataChanged
(
UBDocumentProxy
*
))
disconnect
(
UBPersistenceManager
::
persistenceManager
(),
SIGNAL
(
documentMetadataChanged
(
UBDocumentProxy
*
))
,
this
,
SLOT
(
updateDocumentInTree
(
UBDocumentProxy
*
)));
,
this
,
SLOT
(
updateDocumentInTree
(
UBDocumentProxy
*
)));
if
(
proxyItem
)
if
(
proxyItem
)
{
{
...
@@ -939,7 +971,6 @@ void UBDocumentController::itemChanged(QTreeWidgetItem * item, int column)
...
@@ -939,7 +971,6 @@ void UBDocumentController::itemChanged(QTreeWidgetItem * item, int column)
if
(
childItem
)
if
(
childItem
)
{
{
QString
groupName
;
if
(
0
!=
(
item
->
flags
()
&
Qt
::
ItemIsEditable
))
if
(
0
!=
(
item
->
flags
()
&
Qt
::
ItemIsEditable
))
{
{
childItem
->
proxy
()
->
setMetaData
(
UBSettings
::
documentGroupName
,
item
->
text
(
column
));
childItem
->
proxy
()
->
setMetaData
(
UBSettings
::
documentGroupName
,
item
->
text
(
column
));
...
@@ -950,8 +981,7 @@ void UBDocumentController::itemChanged(QTreeWidgetItem * item, int column)
...
@@ -950,8 +981,7 @@ void UBDocumentController::itemChanged(QTreeWidgetItem * item, int column)
}
}
}
}
connect
(
UBPersistenceManager
::
persistenceManager
(),
SIGNAL
(
documentMetadataChanged
(
UBDocumentProxy
*
)),
connect
(
UBPersistenceManager
::
persistenceManager
(),
SIGNAL
(
documentMetadataChanged
(
UBDocumentProxy
*
)),
this
,
SLOT
(
updateDocumentInTree
(
UBDocumentProxy
*
)));
this
,
SLOT
(
updateDocumentInTree
(
UBDocumentProxy
*
)));
}
}
...
@@ -1341,42 +1371,51 @@ void UBDocumentController::addToDocument()
...
@@ -1341,42 +1371,51 @@ void UBDocumentController::addToDocument()
}
}
UBDocumentGroupTreeItem
*
UBDocumentController
::
getParentTreeItem
(
QString
&
documentGroup
)
{
QString
pathNotYetCreated
=
documentGroup
;
UBDocumentGroupTreeItem
*
result
=
getCommonGroupItem
(
documentGroup
);
if
(
result
)
pathNotYetCreated
=
pathNotYetCreated
.
remove
(
0
,
result
->
buildEntirePath
().
size
());
if
(
pathNotYetCreated
.
startsWith
(
"/"
))
pathNotYetCreated
=
pathNotYetCreated
.
remove
(
0
,
1
);
QString
completePath
=
result
?
result
->
groupName
()
+
"/"
:
""
;
QStringList
folders
=
pathNotYetCreated
.
split
(
"/"
);
for
(
int
i
=
0
;
i
<
folders
.
count
();
i
+=
1
){
if
(
!
folders
.
at
(
i
).
isEmpty
()){
completePath
=
completePath
+
folders
.
at
(
i
);
UBDocumentGroupTreeItem
*
newTreeItem
=
new
UBDocumentGroupTreeItem
(
result
,
true
);
newTreeItem
->
setGroupName
(
folders
.
at
(
i
));
if
(
completePath
.
indexOf
(
"/"
)
==
-
1
)
mDocumentUI
->
documentTreeWidget
->
insertTopLevelItem
(
0
,
newTreeItem
);
mMapOfPaths
.
insert
(
completePath
,
newTreeItem
);
result
=
newTreeItem
;
completePath
+=
"/"
;
}
}
return
result
;
}
void
UBDocumentController
::
addDocumentInTree
(
UBDocumentProxy
*
pDocument
)
void
UBDocumentController
::
addDocumentInTree
(
UBDocumentProxy
*
pDocument
)
{
{
QString
documentName
=
pDocument
->
name
();
QString
documentName
=
pDocument
->
name
();
QString
documentGroup
=
pDocument
->
groupName
();
QString
documentGroup
=
pDocument
->
groupName
();
if
(
documentGroup
.
isEmpty
())
if
(
documentGroup
.
isEmpty
())
{
documentGroup
=
mDefaultDocumentGroupName
;
documentGroup
=
mDefaultDocumentGroupName
;
}
UBDocumentGroupTreeItem
*
group
=
0
;
UBDocumentGroupTreeItem
*
group
=
NULL
;
if
(
documentGroup
.
startsWith
(
UBSettings
::
trashedDocumentGroupNamePrefix
))
if
(
documentGroup
.
startsWith
(
UBSettings
::
trashedDocumentGroupNamePrefix
))
{
group
=
mTrashTi
;
group
=
mTrashTi
;
}
else
else
{
group
=
getParentTreeItem
(
documentGroup
);
for
(
int
i
=
0
;
i
<
mDocumentUI
->
documentTreeWidget
->
topLevelItemCount
();
i
++
)
{
QTreeWidgetItem
*
item
=
mDocumentUI
->
documentTreeWidget
->
topLevelItem
(
i
);
UBDocumentGroupTreeItem
*
groupItem
=
dynamic_cast
<
UBDocumentGroupTreeItem
*>
(
item
);
if
(
groupItem
->
groupName
()
==
documentGroup
)
{
group
=
groupItem
;
break
;
}
}
}
if
(
group
==
0
)
{
group
=
new
UBDocumentGroupTreeItem
(
0
);
// deleted by the tree widget
group
->
setGroupName
(
documentGroup
);
mDocumentUI
->
documentTreeWidget
->
addTopLevelItem
(
group
);
}
UBDocumentProxyTreeItem
*
ti
=
new
UBDocumentProxyTreeItem
(
group
,
pDocument
,
!
group
->
isTrashFolder
());
UBDocumentProxyTreeItem
*
ti
=
new
UBDocumentProxyTreeItem
(
group
,
pDocument
,
!
group
->
isTrashFolder
());
ti
->
setText
(
0
,
documentName
);
ti
->
setText
(
0
,
documentName
);
mDocumentUI
->
documentTreeWidget
->
editItem
(
ti
,
0
);
}
}
...
@@ -1401,12 +1440,25 @@ QStringList UBDocumentController::allGroupNames()
...
@@ -1401,12 +1440,25 @@ QStringList UBDocumentController::allGroupNames()
{
{
QStringList
result
;
QStringList
result
;
UBDocumentGroupTreeItem
*
selectedGroup
=
selectedDocumentGroupTreeItem
();
if
(
selectedGroup
->
isDefaultFolder
()){
for
(
int
i
=
0
;
i
<
mDocumentUI
->
documentTreeWidget
->
topLevelItemCount
();
i
++
)
for
(
int
i
=
0
;
i
<
mDocumentUI
->
documentTreeWidget
->
topLevelItemCount
();
i
++
)
{
{
QTreeWidgetItem
*
item
=
mDocumentUI
->
documentTreeWidget
->
topLevelItem
(
i
);
QTreeWidgetItem
*
item
=
mDocumentUI
->
documentTreeWidget
->
topLevelItem
(
i
);
UBDocumentGroupTreeItem
*
groupItem
=
dynamic_cast
<
UBDocumentGroupTreeItem
*>
(
item
);
UBDocumentGroupTreeItem
*
groupItem
=
dynamic_cast
<
UBDocumentGroupTreeItem
*>
(
item
);
result
<<
groupItem
->
groupName
();
result
<<
groupItem
->
groupName
();
}
}
}
else
{
for
(
int
i
=
0
;
i
<
selectedGroup
->
childCount
();
i
++
)
{
QTreeWidgetItem
*
item
=
selectedGroup
->
child
(
i
);
UBDocumentGroupTreeItem
*
groupItem
=
dynamic_cast
<
UBDocumentGroupTreeItem
*>
(
item
);
if
(
groupItem
)
result
<<
groupItem
->
groupName
();
}
}
return
result
;
return
result
;
}
}
...
...
src/document/UBDocumentController.h
View file @
af6dc9c6
...
@@ -66,6 +66,8 @@ class UBDocumentController : public UBDocumentContainer
...
@@ -66,6 +66,8 @@ class UBDocumentController : public UBDocumentContainer
QString
documentTrashGroupName
(){
return
mDocumentTrashGroupName
;}
QString
documentTrashGroupName
(){
return
mDocumentTrashGroupName
;}
QString
defaultDocumentGroupName
(){
return
mDefaultDocumentGroupName
;}
QString
defaultDocumentGroupName
(){
return
mDefaultDocumentGroupName
;}
void
treeGroupItemRenamed
(
QString
&
oldPath
,
QString
&
newPath
);
signals
:
signals
:
void
exportDone
();
void
exportDone
();
...
@@ -128,6 +130,14 @@ class UBDocumentController : public UBDocumentContainer
...
@@ -128,6 +130,14 @@ class UBDocumentController : public UBDocumentContainer
QString
mDocumentTrashGroupName
;
QString
mDocumentTrashGroupName
;
QString
mDefaultDocumentGroupName
;
QString
mDefaultDocumentGroupName
;
UBDocumentGroupTreeItem
*
getCommonGroupItem
(
QString
&
path
);
QMap
<
QString
,
UBDocumentGroupTreeItem
*>
mMapOfPaths
;
UBDocumentGroupTreeItem
*
getParentTreeItem
(
QString
&
documentGroup
);
QList
<
UBDocumentProxyTreeItem
*>
getProxies
(
QTreeWidgetItem
*
groupItem
);
QList
<
UBDocumentGroupTreeItem
*>
getGroupTreeItem
(
QTreeWidgetItem
*
groupItem
);
private
slots
:
private
slots
:
void
documentZoomSliderValueChanged
(
int
value
);
void
documentZoomSliderValueChanged
(
int
value
);
void
loadDocumentProxies
();
void
loadDocumentProxies
();
...
...
src/document/UBDocumentProxy.cpp
View file @
af6dc9c6
...
@@ -56,7 +56,7 @@ void UBDocumentProxy::init()
...
@@ -56,7 +56,7 @@ void UBDocumentProxy::init()
setMetaData
(
UBSettings
::
documentGroupName
,
""
);
setMetaData
(
UBSettings
::
documentGroupName
,
""
);
QDateTime
now
=
QDateTime
::
currentDateTime
();
QDateTime
now
=
QDateTime
::
currentDateTime
();
setMetaData
(
UBSettings
::
documentName
,
now
.
toString
(
Qt
::
SystemLocaleShort
Date
));
setMetaData
(
UBSettings
::
documentName
,
now
.
toString
(
Qt
::
ISO
Date
));
setUuid
(
QUuid
::
createUuid
());
setUuid
(
QUuid
::
createUuid
());
...
...
src/gui/UBDocumentTreeWidget.cpp
View file @
af6dc9c6
...
@@ -22,10 +22,10 @@
...
@@ -22,10 +22,10 @@
* along with OpenBoard. If not, see <http://www.gnu.org/licenses/>.
* along with OpenBoard. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "UBDocumentTreeWidget.h"
#include "UBDocumentTreeWidget.h"
#include "document/UBDocumentProxy.h"
#include "document/UBDocumentProxy.h"
//#include "document/UBDocumentContainer.h"
#include "core/UBSettings.h"
#include "core/UBSettings.h"
#include "core/UBApplication.h"
#include "core/UBApplication.h"
...
@@ -33,6 +33,9 @@
...
@@ -33,6 +33,9 @@
#include "core/UBMimeData.h"
#include "core/UBMimeData.h"
#include "core/UBApplicationController.h"
#include "core/UBApplicationController.h"
#include "core/UBDocumentManager.h"
#include "core/UBDocumentManager.h"
#include "gui/UBMainWindow.h"
#include "document/UBDocumentController.h"
#include "document/UBDocumentController.h"
#include "adaptors/UBThumbnailAdaptor.h"
#include "adaptors/UBThumbnailAdaptor.h"
...
@@ -41,22 +44,23 @@
...
@@ -41,22 +44,23 @@
#include "core/memcheck.h"
#include "core/memcheck.h"
#include <QTimer>
UBDocumentTreeWidget
::
UBDocumentTreeWidget
(
QWidget
*
parent
)
UBDocumentTreeWidget
::
UBDocumentTreeWidget
(
QWidget
*
parent
)
:
QTreeWidget
(
parent
)
:
QTreeWidget
(
parent
)
,
mSelectedProxyTi
(
0
)
,
mSelectedProxyTi
(
0
)
,
mDropTargetProxyTi
(
0
)
,
mDropTargetProxyTi
(
0
)
,
mLastItemCompletePath
(
""
)
{
{
setDragDropMode
(
QAbstractItemView
::
InternalMove
);
setDragDropMode
(
QAbstractItemView
::
InternalMove
);
setAutoScroll
(
true
);
setAutoScroll
(
true
);
mScrollTimer
=
new
QTimer
(
this
);
mScrollTimer
=
new
QTimer
(
this
);
connect
(
UBDocumentManager
::
documentManager
(),
SIGNAL
(
documentUpdated
(
UBDocumentProxy
*
))
connect
(
UBDocumentManager
::
documentManager
(),
SIGNAL
(
documentUpdated
(
UBDocumentProxy
*
)),
this
,
SLOT
(
documentUpdated
(
UBDocumentProxy
*
)));
,
this
,
SLOT
(
documentUpdated
(
UBDocumentProxy
*
)));
connect
(
this
,
SIGNAL
(
itemChanged
(
QTreeWidgetItem
*
,
int
))
connect
(
this
,
SIGNAL
(
itemChanged
(
QTreeWidgetItem
*
,
int
))
,
this
,
SLOT
(
itemChangedValidation
(
QTreeWidgetItem
*
,
int
)));
,
this
,
SLOT
(
itemChangedValidation
(
QTreeWidgetItem
*
,
int
)));
connect
(
mScrollTimer
,
SIGNAL
(
timeout
())
,
this
,
SLOT
(
autoScroll
()));
connect
(
mScrollTimer
,
SIGNAL
(
timeout
())
connect
(
this
,
SIGNAL
(
itemPressed
(
QTreeWidgetItem
*
,
int
)),
this
,
SLOT
(
onItemPressed
(
QTreeWidgetItem
*
,
int
)));
,
this
,
SLOT
(
autoScroll
()));
}
}
...
@@ -66,30 +70,95 @@ UBDocumentTreeWidget::~UBDocumentTreeWidget()
...
@@ -66,30 +70,95 @@ UBDocumentTreeWidget::~UBDocumentTreeWidget()
}
}
void
UBDocumentTreeWidget
::
onItemPressed
(
QTreeWidgetItem
*
item
,
int
column
)
{
Q_UNUSED
(
column
)
UBDocumentGroupTreeItem
*
group
=
dynamic_cast
<
UBDocumentGroupTreeItem
*>
(
item
);
if
(
group
){
mLastItemCompletePath
=
group
->
buildEntirePath
();
mLastItemName
=
group
->
groupName
();
}
}
void
UBDocumentTreeWidget
::
itemChangedValidation
(
QTreeWidgetItem
*
item
,
int
column
)
void
UBDocumentTreeWidget
::
itemChangedValidation
(
QTreeWidgetItem
*
item
,
int
column
)
{
{
if
(
column
==
0
)
// QString emptyNameWarningTitle = tr("Empty name");
// QString emptyNameWarningText = tr("The name should not be empty. Please enter a valid name.");
QString
alreadyExistsNameWarningTitle
=
tr
(
"Name already used"
);
QString
alreadyExistsNameWarningText
=
tr
(
"The actual name is in conflict with and existing. Please choose another one."
);
UBDocumentProxyTreeItem
*
treeItem
=
dynamic_cast
<
UBDocumentProxyTreeItem
*>
(
item
);
if
(
treeItem
)
{
{
UBDocumentGroupTreeItem
*
group
=
dynamic_cast
<
UBDocumentGroupTreeItem
*>
(
item
);
QString
name
=
treeItem
->
text
(
column
);
// if(name.isEmpty())
// UBApplication::mainWindow->warning(emptyNameWarningTitle,emptyNameWarningText);
if
(
group
)
for
(
int
i
=
0
;
i
<
treeItem
->
parent
()
->
childCount
();
i
++
)
{
{
QString
name
=
group
->
text
(
0
);
QTreeWidgetItem
*
childAtPosition
=
treeItem
->
parent
()
->
child
(
i
);
if
(
childAtPosition
!=
item
&&
childAtPosition
->
text
(
column
)
==
name
){
UBApplication
::
mainWindow
->
warning
(
alreadyExistsNameWarningTitle
,
alreadyExistsNameWarningText
);
// This is not really a good way but at this time we are not yet out of the editing time
// this is not what is told by the name of the function itemChanged...
mFailedValidationForTreeItem
=
item
;
mFailedValidationItemColumn
=
column
;
QTimer
::
singleShot
(
100
,
this
,
SLOT
(
validationFailed
()));
return
;
}
}
}
for
(
int
i
=
0
;
i
<
topLevelItemCount
();
i
++
)
UBDocumentGroupTreeItem
*
group
=
dynamic_cast
<
UBDocumentGroupTreeItem
*>
(
item
);
if
(
group
)
{
{
QTreeWidgetItem
*
someTopLevelItem
=
topLevelItem
(
i
);
QString
name
=
group
->
text
(
column
);
// if(name.isEmpty())
// UBApplication::mainWindow->warning(emptyNameWarningTitle,emptyNameWarningText);
if
(
someTopLevelItem
!=
group
&&
if
(
group
->
parent
()){
someTopLevelItem
->
text
(
0
)
==
name
)
for
(
int
i
=
0
;
i
<
group
->
parent
()
->
childCount
();
i
++
)
{
{
group
->
setText
(
0
,
tr
(
"%1 (copy)"
).
arg
(
name
));
QTreeWidgetItem
*
childAtPosition
=
group
->
parent
()
->
child
(
i
);
if
(
childAtPosition
!=
item
&&
childAtPosition
->
text
(
column
)
==
name
){
UBApplication
::
mainWindow
->
warning
(
alreadyExistsNameWarningTitle
,
alreadyExistsNameWarningText
);
mFailedValidationForTreeItem
=
item
;
mFailedValidationItemColumn
=
column
;
QTimer
::
singleShot
(
100
,
this
,
SLOT
(
validationFailed
()));
return
;
}
}
}
}
}
}
else
{
// We are looking at the top level items;
for
(
int
i
=
0
;
i
<
topLevelItemCount
();
i
+=
1
){
if
(
topLevelItem
(
i
)
!=
item
&&
dynamic_cast
<
UBDocumentGroupTreeItem
*>
(
topLevelItem
(
i
))
->
groupName
()
==
group
->
groupName
()){
UBApplication
::
mainWindow
->
warning
(
tr
(
"Name already in use"
),
tr
(
"Please choose another name for the directory. The chosed name is already used."
));
mFailedValidationForTreeItem
=
item
;
mFailedValidationItemColumn
=
column
;
QTimer
::
singleShot
(
100
,
this
,
SLOT
(
validationFailed
()));
return
;
}
}
}
QString
newPath
=
group
->
buildEntirePath
();
group
->
updateChildrenPath
(
column
,
mLastItemCompletePath
,
newPath
);
UBApplication
::
documentController
->
treeGroupItemRenamed
(
mLastItemCompletePath
,
newPath
);
}
}
}
}
void
UBDocumentTreeWidget
::
validationFailed
()
{
editItem
(
mFailedValidationForTreeItem
,
mFailedValidationItemColumn
);
}
Qt
::
DropActions
UBDocumentTreeWidget
::
supportedDropActions
()
const
Qt
::
DropActions
UBDocumentTreeWidget
::
supportedDropActions
()
const
{
{
...
@@ -208,11 +277,6 @@ void UBDocumentTreeWidget::dragMoveEvent(QDragMoveEvent *event)
...
@@ -208,11 +277,6 @@ void UBDocumentTreeWidget::dragMoveEvent(QDragMoveEvent *event)
void
UBDocumentTreeWidget
::
focusInEvent
(
QFocusEvent
*
event
)
void
UBDocumentTreeWidget
::
focusInEvent
(
QFocusEvent
*
event
)
{
{
Q_UNUSED
(
event
);
// Tolik
//itemSelectionChanged();
QTreeWidget
::
focusInEvent
(
event
);
QTreeWidget
::
focusInEvent
(
event
);
}
}
...
@@ -275,7 +339,6 @@ void UBDocumentTreeWidget::dropEvent(QDropEvent *event)
...
@@ -275,7 +339,6 @@ void UBDocumentTreeWidget::dropEvent(QDropEvent *event)
if
(
groupItem
->
isTrashFolder
())
if
(
groupItem
->
isTrashFolder
())
mSelectedProxyTi
->
setFlags
(
mSelectedProxyTi
->
flags
()
^
Qt
::
ItemIsEditable
);
mSelectedProxyTi
->
setFlags
(
mSelectedProxyTi
->
flags
()
^
Qt
::
ItemIsEditable
);
//clearSelection();
expandItem
(
groupItem
);
expandItem
(
groupItem
);
scrollToItem
(
mSelectedProxyTi
);
scrollToItem
(
mSelectedProxyTi
);
...
@@ -320,7 +383,6 @@ void UBDocumentTreeWidget::dropEvent(QDropEvent *event)
...
@@ -320,7 +383,6 @@ void UBDocumentTreeWidget::dropEvent(QDropEvent *event)
if
(
scene
)
if
(
scene
)
{
{
UBGraphicsScene
*
sceneClone
=
scene
->
sceneDeepCopy
();
UBGraphicsScene
*
sceneClone
=
scene
->
sceneDeepCopy
();
// UBGraphicsScene* sceneClone = scene;
UBDocumentProxy
*
targetDocProxy
=
targetProxyTreeItem
->
proxy
();
UBDocumentProxy
*
targetDocProxy
=
targetProxyTreeItem
->
proxy
();
...
@@ -453,6 +515,35 @@ QString UBDocumentGroupTreeItem::groupName() const
...
@@ -453,6 +515,35 @@ QString UBDocumentGroupTreeItem::groupName() const
return
text
(
0
);
return
text
(
0
);
}
}
QString
UBDocumentGroupTreeItem
::
buildEntirePath
()
{
QString
result
(
groupName
());
UBDocumentGroupTreeItem
*
item
=
this
;
while
(
item
->
parent
()){
item
=
dynamic_cast
<
UBDocumentGroupTreeItem
*>
(
item
->
parent
());
result
=
item
->
groupName
()
+
"/"
+
result
;
}
return
result
;
}
void
UBDocumentGroupTreeItem
::
updateChildrenPath
(
int
column
,
QString
&
previousText
,
const
QString
&
text
)
{
for
(
int
i
=
0
;
i
<
childCount
();
i
+=
1
){
UBDocumentGroupTreeItem
*
groupTreeItem
=
dynamic_cast
<
UBDocumentGroupTreeItem
*>
(
child
(
i
));
if
(
groupTreeItem
)
groupTreeItem
->
updateChildrenPath
(
column
,
previousText
,
text
);
else
{
UBDocumentProxyTreeItem
*
docProxyItem
=
dynamic_cast
<
UBDocumentProxyTreeItem
*>
(
child
(
i
));
QString
groupName
=
docProxyItem
->
proxy
()
->
metaData
(
UBSettings
::
documentGroupName
).
toString
();
groupName
=
groupName
.
remove
(
0
,
previousText
.
length
());
groupName
=
text
+
groupName
;
docProxyItem
->
proxy
()
->
setMetaData
(
UBSettings
::
documentGroupName
,
groupName
);
UBPersistenceManager
::
persistenceManager
()
->
persistDocumentMetadata
(
docProxyItem
->
proxy
());
}
}
}
bool
UBDocumentGroupTreeItem
::
isTrashFolder
()
const
bool
UBDocumentGroupTreeItem
::
isTrashFolder
()
const
{
{
...
...
src/gui/UBDocumentTreeWidget.h
View file @
af6dc9c6
...
@@ -54,8 +54,9 @@ class UBDocumentTreeWidget : public QTreeWidget
...
@@ -54,8 +54,9 @@ class UBDocumentTreeWidget : public QTreeWidget
void
documentUpdated
(
UBDocumentProxy
*
pDocument
);
void
documentUpdated
(
UBDocumentProxy
*
pDocument
);
void
itemChangedValidation
(
QTreeWidgetItem
*
item
,
int
column
);
void
itemChangedValidation
(
QTreeWidgetItem
*
item
,
int
column
);
void
onItemPressed
(
QTreeWidgetItem
*
item
,
int
column
);
void
autoScroll
();
void
autoScroll
();
void
validationFailed
();
private
:
private
:
UBDocumentProxyTreeItem
*
mSelectedProxyTi
;
UBDocumentProxyTreeItem
*
mSelectedProxyTi
;
...
@@ -63,6 +64,10 @@ class UBDocumentTreeWidget : public QTreeWidget
...
@@ -63,6 +64,10 @@ class UBDocumentTreeWidget : public QTreeWidget
QBrush
mBackground
;
QBrush
mBackground
;
QTimer
*
mScrollTimer
;
QTimer
*
mScrollTimer
;
int
mScrollMagnitude
;
int
mScrollMagnitude
;
QTreeWidgetItem
*
mFailedValidationForTreeItem
;
int
mFailedValidationItemColumn
;
QString
mLastItemCompletePath
;
QString
mLastItemName
;
};
};
...
@@ -93,6 +98,11 @@ class UBDocumentGroupTreeItem : public QTreeWidgetItem
...
@@ -93,6 +98,11 @@ class UBDocumentGroupTreeItem : public QTreeWidgetItem
bool
isTrashFolder
()
const
;
bool
isTrashFolder
()
const
;
bool
isDefaultFolder
()
const
;
bool
isDefaultFolder
()
const
;
QString
buildEntirePath
();
void
updateChildrenPath
(
int
column
,
QString
&
previousText
,
const
QString
&
text
);
};
};
#endif
/* UBDOCUMENTTREEWIDGET_H_ */
#endif
/* UBDOCUMENTTREEWIDGET_H_ */
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