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
5956b988
Commit
5956b988
authored
Jul 25, 2011
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added thread that imports olds Uniboard/Sankore documents
parent
3f7d47e2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
200 additions
and
31 deletions
+200
-31
UBUpdateDlg.cpp
src/gui/UBUpdateDlg.cpp
+133
-22
UBUpdateDlg.h
src/gui/UBUpdateDlg.h
+17
-6
UniboardSankoreTransition.cpp
src/transition/UniboardSankoreTransition.cpp
+35
-3
UniboardSankoreTransition.h
src/transition/UniboardSankoreTransition.h
+15
-0
No files found.
src/gui/UBUpdateDlg.cpp
View file @
5956b988
...
@@ -4,56 +4,161 @@
...
@@ -4,56 +4,161 @@
#include "UBUpdateDlg.h"
#include "UBUpdateDlg.h"
#include "core/memcheck.h"
#include "core/memcheck.h"
#include <../Trolltech/Qt-4.7.0/include/QtWebKit/qwebpage.h>
UBUpdateDlg
::
UBUpdateDlg
(
QWidget
*
parent
,
int
nbFiles
,
const
QString
&
bkpPath
)
UBUpdateDlg
::
UBUpdateDlg
(
QWidget
*
parent
,
int
nbFiles
,
const
QString
&
bkpPath
)
:
QDialog
(
parent
)
:
QDialog
(
parent
)
,
mMainLayout
(
NULL
)
,
mNbFilesLabel
(
NULL
)
,
mBkpLabel
(
NULL
)
,
mBkpPath
(
NULL
)
,
mBrowseBttn
(
NULL
)
,
mpDlgBttn
(
NULL
)
,
mpDlgBttn
(
NULL
)
,
mLayout
(
NULL
)
,
mHLayout
(
NULL
)
,
mStackedWidget
(
NULL
)
,
mDialogWidget
(
NULL
)
,
mProgressWidget
(
NULL
)
,
mProgressLayout
(
NULL
)
,
mProgressLabel
(
NULL
)
{
{
setFixedSize
(
400
,
110
);
mDialogWidget
=
new
QWidget
(
this
);
mProgressWidget
=
new
QWidget
(
this
);
mStackedWidget
=
new
QStackedWidget
(
this
);
mStackedWidget
->
addWidget
(
mDialogWidget
);
mStackedWidget
->
addWidget
(
mProgressWidget
);
setFixedSize
(
450
,
110
);
setModal
(
true
);
setModal
(
true
);
setWindowTitle
(
tr
(
"Document updater"
));
setWindowTitle
(
tr
(
"Document updater"
));
setLayout
(
&
mLayout
);
mLayout
=
new
QVBoxLayout
();
setLayout
(
mLayout
);
QString
str
=
QString
::
number
(
nbFiles
);
QString
str
=
QString
::
number
(
nbFiles
);
str
.
append
(
tr
(
" files require an update."
));
str
.
append
(
tr
(
" files require an update."
));
mNbFilesLabel
.
setText
(
str
);
mNbFilesLabel
=
new
QLabel
(
mDialogWidget
);
mLayout
.
addWidget
(
&
mNbFilesLabel
);
mNbFilesLabel
->
setText
(
str
);
mBkpLabel
.
setText
(
tr
(
"Backup path: "
));
mBkpPath
.
setText
(
bkpPath
);
mLayout
->
addWidget
(
mNbFilesLabel
);
mBrowseBttn
.
setText
(
tr
(
"Browse"
));
mHLayout
.
addWidget
(
&
mBkpLabel
);
mBkpLabel
=
new
QLabel
(
mDialogWidget
);
mHLayout
.
addWidget
(
&
mBkpPath
,
1
);
mBkpLabel
->
setText
(
tr
(
"Backup path: "
));
mHLayout
.
addWidget
(
&
mBrowseBttn
);
mLayout
.
addLayout
(
&
mHLayout
);
mBkpPath
=
new
QLineEdit
(
mDialogWidget
);
mBkpPath
->
setText
(
bkpPath
);
mpDlgBttn
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
,
Qt
::
Horizontal
,
this
);
mLayout
.
addWidget
(
mpDlgBttn
);
mBrowseBttn
=
new
QPushButton
(
mDialogWidget
);
mBrowseBttn
->
setText
(
tr
(
"Browse"
));
mHLayout
=
new
QHBoxLayout
();
mHLayout
->
addWidget
(
mBkpLabel
);
mHLayout
->
addWidget
(
mBkpPath
,
1
);
mHLayout
->
addWidget
(
mBrowseBttn
);
mLayout
->
addLayout
(
mHLayout
);
mpDlgBttn
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
,
Qt
::
Horizontal
,
mDialogWidget
);
mLayout
->
addWidget
(
mpDlgBttn
);
mpDlgBttn
->
button
(
QDialogButtonBox
::
Ok
)
->
setText
(
tr
(
"Update"
));
mpDlgBttn
->
button
(
QDialogButtonBox
::
Ok
)
->
setText
(
tr
(
"Update"
));
mpDlgBttn
->
button
(
QDialogButtonBox
::
Cancel
)
->
setText
(
"Remind me later"
);
mpDlgBttn
->
button
(
QDialogButtonBox
::
Cancel
)
->
setText
(
"Remind me later"
);
QObject
::
connect
(
&
mBrowseBttn
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onBrowse
()));
QObject
::
connect
(
mBrowseBttn
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onBrowse
()));
QObject
::
connect
(
mpDlgBttn
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
onUpdate
()));
QObject
::
connect
(
mpDlgBttn
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
onUpdate
()));
QObject
::
connect
(
mpDlgBttn
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
QObject
::
connect
(
mpDlgBttn
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
mDialogWidget
->
setLayout
(
mLayout
);
mStackedWidget
->
setCurrentWidget
(
mDialogWidget
);
mMainLayout
=
new
QVBoxLayout
();
this
->
setLayout
(
mMainLayout
);
mMainLayout
->
addWidget
(
mStackedWidget
);
}
}
UBUpdateDlg
::~
UBUpdateDlg
()
UBUpdateDlg
::~
UBUpdateDlg
()
{
{
if
(
NULL
!=
mpDlgBttn
)
if
(
NULL
!=
mpDlgBttn
)
{
{
delete
mpDlgBttn
;
delete
mpDlgBttn
;
mpDlgBttn
=
NULL
;
mpDlgBttn
=
NULL
;
}
}
if
(
mNbFilesLabel
)
{
delete
mNbFilesLabel
;
mNbFilesLabel
=
NULL
;
}
if
(
mBkpLabel
)
{
delete
mBkpLabel
;
mBkpLabel
=
NULL
;
}
if
(
mBkpPath
)
{
delete
mBkpPath
;
mBkpPath
=
NULL
;
}
if
(
mBrowseBttn
)
{
delete
mBrowseBttn
;
mBrowseBttn
=
NULL
;
}
if
(
mProgressLabel
)
{
delete
mProgressLabel
;
mProgressLabel
=
NULL
;
}
if
(
mHLayout
)
{
delete
mHLayout
;
mHLayout
=
NULL
;
}
if
(
mLayout
)
{
delete
mLayout
;
mLayout
=
NULL
;
}
if
(
mProgressLayout
)
{
delete
mProgressLayout
;
mProgressLayout
=
NULL
;
}
if
(
mDialogWidget
)
{
delete
mDialogWidget
;
mDialogWidget
=
NULL
;
}
if
(
mProgressWidget
)
{
delete
mProgressWidget
;
mProgressWidget
=
NULL
;
}
if
(
mStackedWidget
)
{
delete
mStackedWidget
;
mStackedWidget
=
NULL
;
}
if
(
mMainLayout
)
{
delete
mMainLayout
;
mMainLayout
=
NULL
;
}
}
}
void
UBUpdateDlg
::
onBrowse
()
void
UBUpdateDlg
::
onBrowse
()
{
{
QString
qsSelectedDir
;
QString
qsSelectedDir
;
qsSelectedDir
=
QFileDialog
::
getExistingDirectory
(
this
,
tr
(
"Select a backup folder"
),
mBkpPath
.
text
());
qsSelectedDir
=
QFileDialog
::
getExistingDirectory
(
this
,
tr
(
"Select a backup folder"
),
mBkpPath
->
text
());
mBkpPath
.
setText
(
qsSelectedDir
);
mBkpPath
->
setText
(
qsSelectedDir
);
}
}
void
UBUpdateDlg
::
onUpdate
()
void
UBUpdateDlg
::
onUpdate
()
{
{
mProgressLabel
=
new
QLabel
(
mProgressWidget
);
mProgressLayout
=
new
QHBoxLayout
();
mProgressLayout
->
addWidget
(
mProgressLabel
);
mProgressWidget
->
setLayout
(
mProgressLayout
);
mStackedWidget
->
setCurrentWidget
(
mProgressWidget
);
emit
updateFiles
();
emit
updateFiles
();
}
}
...
@@ -61,7 +166,7 @@ void UBUpdateDlg::onFilesUpdated(bool bResult)
...
@@ -61,7 +166,7 @@ void UBUpdateDlg::onFilesUpdated(bool bResult)
{
{
QString
qsMsg
;
QString
qsMsg
;
if
(
bResult
)
if
(
bResult
)
{
{
qsMsg
=
tr
(
"Files update successful!
\n
Please reboot the application to access the updated documents."
);
qsMsg
=
tr
(
"Files update successful!
\n
Please reboot the application to access the updated documents."
);
}
}
...
@@ -74,5 +179,11 @@ void UBUpdateDlg::onFilesUpdated(bool bResult)
...
@@ -74,5 +179,11 @@ void UBUpdateDlg::onFilesUpdated(bool bResult)
QString
UBUpdateDlg
::
backupPath
()
QString
UBUpdateDlg
::
backupPath
()
{
{
return
mBkpPath
.
text
();
return
mBkpPath
->
text
();
}
}
void
UBUpdateDlg
::
transitioningFile
(
QString
fileName
)
{
mProgressLabel
->
setText
(
tr
(
"Updating file "
)
+
fileName
);
}
src/gui/UBUpdateDlg.h
View file @
5956b988
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include <QDialogButtonBox>
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QHBoxLayout>
#include <QStackedWidget>
class
UBUpdateDlg
:
public
QDialog
class
UBUpdateDlg
:
public
QDialog
{
{
...
@@ -27,15 +28,25 @@ signals:
...
@@ -27,15 +28,25 @@ signals:
private
slots
:
private
slots
:
void
onBrowse
();
void
onBrowse
();
void
onUpdate
();
void
onUpdate
();
void
transitioningFile
(
QString
fileName
);
private
:
private
:
QLabel
mNbFilesLabel
;
QVBoxLayout
*
mMainLayout
;
QLabel
mBkpLabel
;
QLineEdit
mBkpPath
;
QLabel
*
mNbFilesLabel
;
QPushButton
mBrowseBttn
;
QLabel
*
mBkpLabel
;
QLineEdit
*
mBkpPath
;
QPushButton
*
mBrowseBttn
;
QDialogButtonBox
*
mpDlgBttn
;
QDialogButtonBox
*
mpDlgBttn
;
QVBoxLayout
mLayout
;
QVBoxLayout
*
mLayout
;
QHBoxLayout
mHLayout
;
QHBoxLayout
*
mHLayout
;
QStackedWidget
*
mStackedWidget
;
QWidget
*
mDialogWidget
;
QWidget
*
mProgressWidget
;
QHBoxLayout
*
mProgressLayout
;
QLabel
*
mProgressLabel
;
};
};
#endif // UBUPDATEDLG_H
#endif // UBUPDATEDLG_H
src/transition/UniboardSankoreTransition.cpp
View file @
5956b988
...
@@ -8,9 +8,9 @@
...
@@ -8,9 +8,9 @@
UniboardSankoreTransition
::
UniboardSankoreTransition
(
QObject
*
parent
)
:
UniboardSankoreTransition
::
UniboardSankoreTransition
(
QObject
*
parent
)
:
QObject
(
parent
)
QObject
(
parent
)
,
mTransitionDlg
(
NULL
)
,
mTransitionDlg
(
NULL
)
,
mThread
(
NULL
)
{
{
mOldSankoreDirectory
=
UBFileSystemUtils
::
normalizeFilePath
(
UBDesktopServices
::
storageLocation
(
QDesktopServices
::
DataLocation
));
mOldSankoreDirectory
=
UBFileSystemUtils
::
normalizeFilePath
(
UBDesktopServices
::
storageLocation
(
QDesktopServices
::
DataLocation
));
qDebug
()
<<
mOldSankoreDirectory
;
mUniboardSourceDirectory
=
UBFileSystemUtils
::
normalizeFilePath
(
UBDesktopServices
::
storageLocation
(
QDesktopServices
::
DataLocation
));
mUniboardSourceDirectory
=
UBFileSystemUtils
::
normalizeFilePath
(
UBDesktopServices
::
storageLocation
(
QDesktopServices
::
DataLocation
));
#if defined(Q_WS_MACX)
#if defined(Q_WS_MACX)
...
@@ -28,6 +28,11 @@ UniboardSankoreTransition::~UniboardSankoreTransition()
...
@@ -28,6 +28,11 @@ UniboardSankoreTransition::~UniboardSankoreTransition()
delete
mTransitionDlg
;
delete
mTransitionDlg
;
mTransitionDlg
=
NULL
;
mTransitionDlg
=
NULL
;
}
}
if
(
mThread
){
delete
mThread
;
mThread
=
NULL
;
}
}
}
void
UniboardSankoreTransition
::
rollbackDocumentsTransition
(
QFileInfoList
&
fileInfoList
)
void
UniboardSankoreTransition
::
rollbackDocumentsTransition
(
QFileInfoList
&
fileInfoList
)
...
@@ -56,7 +61,7 @@ void UniboardSankoreTransition::documentTransition()
...
@@ -56,7 +61,7 @@ void UniboardSankoreTransition::documentTransition()
QString
backupDirectoryPath
=
UBFileSystemUtils
::
normalizeFilePath
(
UBDesktopServices
::
storageLocation
(
QDesktopServices
::
DesktopLocation
));
QString
backupDirectoryPath
=
UBFileSystemUtils
::
normalizeFilePath
(
UBDesktopServices
::
storageLocation
(
QDesktopServices
::
DesktopLocation
));
if
(
fileInfoList
.
count
()
!=
0
){
if
(
fileInfoList
.
count
()
!=
0
){
mTransitionDlg
=
new
UBUpdateDlg
(
0
,
fileInfoList
.
count
(),
backupDirectoryPath
);
mTransitionDlg
=
new
UBUpdateDlg
(
NULL
,
fileInfoList
.
count
(),
backupDirectoryPath
);
connect
(
mTransitionDlg
,
SIGNAL
(
updateFiles
()),
this
,
SLOT
(
startDocumentTransition
()));
connect
(
mTransitionDlg
,
SIGNAL
(
updateFiles
()),
this
,
SLOT
(
startDocumentTransition
()));
connect
(
this
,
SIGNAL
(
transitionFinished
(
bool
)),
mTransitionDlg
,
SLOT
(
onFilesUpdated
(
bool
)));
connect
(
this
,
SIGNAL
(
transitionFinished
(
bool
)),
mTransitionDlg
,
SLOT
(
onFilesUpdated
(
bool
)));
mTransitionDlg
->
show
();
mTransitionDlg
->
show
();
...
@@ -65,6 +70,13 @@ void UniboardSankoreTransition::documentTransition()
...
@@ -65,6 +70,13 @@ void UniboardSankoreTransition::documentTransition()
}
}
void
UniboardSankoreTransition
::
startDocumentTransition
()
void
UniboardSankoreTransition
::
startDocumentTransition
()
{
mThread
=
new
UniboardSankoreThread
(
this
);
mThread
->
start
();
connect
(
this
,
SIGNAL
(
transitioningFile
(
QString
)),
mTransitionDlg
,
SLOT
(
transitioningFile
(
QString
)));
}
void
UniboardSankoreTransition
::
executeTransition
()
{
{
bool
result
=
false
;
bool
result
=
false
;
QString
backupDestinationPath
=
mTransitionDlg
->
backupPath
()
+
"/OldSankoreAndUniboardVersionsBackup"
;
QString
backupDestinationPath
=
mTransitionDlg
->
backupPath
()
+
"/OldSankoreAndUniboardVersionsBackup"
;
...
@@ -83,6 +95,7 @@ void UniboardSankoreTransition::startDocumentTransition()
...
@@ -83,6 +95,7 @@ void UniboardSankoreTransition::startDocumentTransition()
for
(
fileInfo
=
fileInfoList
.
begin
();
fileInfo
!=
fileInfoList
.
end
()
&&
result
;
fileInfo
+=
1
)
{
for
(
fileInfo
=
fileInfoList
.
begin
();
fileInfo
!=
fileInfoList
.
end
()
&&
result
;
fileInfo
+=
1
)
{
if
(
fileInfo
->
isDir
()
&&
(
fileInfo
->
fileName
().
startsWith
(
"Uniboard Document "
)
||
fileInfo
->
fileName
().
startsWith
(
"Sankore Document "
))){
if
(
fileInfo
->
isDir
()
&&
(
fileInfo
->
fileName
().
startsWith
(
"Uniboard Document "
)
||
fileInfo
->
fileName
().
startsWith
(
"Sankore Document "
))){
QString
sankoreDocumentName
=
fileInfo
->
fileName
();
QString
sankoreDocumentName
=
fileInfo
->
fileName
();
emit
transitioningFile
(
sankoreDocumentName
);
sankoreDocumentName
.
replace
(
"Uniboard"
,
"Sankore"
);
sankoreDocumentName
.
replace
(
"Uniboard"
,
"Sankore"
);
result
=
UBFileSystemUtils
::
copyDir
(
fileInfo
->
filePath
(),
sankoreDocumentDirectory
+
"/"
+
sankoreDocumentName
);
result
=
UBFileSystemUtils
::
copyDir
(
fileInfo
->
filePath
(),
sankoreDocumentDirectory
+
"/"
+
sankoreDocumentName
);
qslNewDocs
<<
sankoreDocumentName
;
qslNewDocs
<<
sankoreDocumentName
;
...
@@ -103,3 +116,22 @@ void UniboardSankoreTransition::startDocumentTransition()
...
@@ -103,3 +116,22 @@ void UniboardSankoreTransition::startDocumentTransition()
mTransitionDlg
->
hide
();
mTransitionDlg
->
hide
();
}
}
UniboardSankoreThread
::
UniboardSankoreThread
(
QObject
*
parent
)
:
QThread
(
parent
)
{
}
UniboardSankoreThread
::~
UniboardSankoreThread
()
{
}
void
UniboardSankoreThread
::
run
()
{
UniboardSankoreTransition
*
pTransition
=
dynamic_cast
<
UniboardSankoreTransition
*>
(
parent
());
pTransition
->
executeTransition
();
}
src/transition/UniboardSankoreTransition.h
View file @
5956b988
...
@@ -3,9 +3,21 @@
...
@@ -3,9 +3,21 @@
#include <QObject>
#include <QObject>
#include <QFileInfo>
#include <QFileInfo>
#include <QThread>
#include "gui/UBUpdateDlg.h"
#include "gui/UBUpdateDlg.h"
#include "document/UBDocumentProxy.h"
#include "document/UBDocumentProxy.h"
class
UniboardSankoreThread
:
public
QThread
{
Q_OBJECT
public
:
UniboardSankoreThread
(
QObject
*
parent
=
0
);
~
UniboardSankoreThread
();
void
run
();
};
class
UniboardSankoreTransition
:
public
QObject
class
UniboardSankoreTransition
:
public
QObject
{
{
Q_OBJECT
Q_OBJECT
...
@@ -13,6 +25,7 @@ public:
...
@@ -13,6 +25,7 @@ public:
explicit
UniboardSankoreTransition
(
QObject
*
parent
=
0
);
explicit
UniboardSankoreTransition
(
QObject
*
parent
=
0
);
~
UniboardSankoreTransition
();
~
UniboardSankoreTransition
();
void
documentTransition
();
void
documentTransition
();
void
executeTransition
();
private
:
private
:
...
@@ -22,10 +35,12 @@ private:
...
@@ -22,10 +35,12 @@ private:
protected
:
protected
:
QString
mUniboardSourceDirectory
;
QString
mUniboardSourceDirectory
;
QString
mOldSankoreDirectory
;
QString
mOldSankoreDirectory
;
UniboardSankoreThread
*
mThread
;
signals
:
signals
:
void
transitionFinished
(
bool
result
);
void
transitionFinished
(
bool
result
);
void
docAdded
(
UBDocumentProxy
*
doc
);
void
docAdded
(
UBDocumentProxy
*
doc
);
void
transitioningFile
(
QString
documentName
);
private
slots
:
private
slots
:
void
startDocumentTransition
();
void
startDocumentTransition
();
...
...
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