Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Qt Design Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Design Studio
QML Viewer Projects
Qt Design Viewer
Merge requests
!30
Remove zip support
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Remove zip support
remove-zip-support
into
master
Overview
0
Commits
1
Pipelines
2
Changes
3
Merged
Burak Hançerli
requested to merge
remove-zip-support
into
master
8 months ago
Overview
0
Commits
1
Pipelines
2
Changes
3
Expand
This MR brings the following changes;
chore: remove the zip archive support
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
d06891a0
1 commit,
8 months ago
3 files
+
24
−
48
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
src/designviewer.cpp
+
21
−
45
Options
@@ -33,7 +33,6 @@
#include
<QRandomGenerator>
#include
<QRegularExpression>
#include
<QResource>
#include
<QtCore/private/qzipreader_p.h>
DesignViewer
::
DesignViewer
()
{
@@ -62,58 +61,35 @@ void DesignViewer::fetchProject(QByteArray *data, QString *fileName)
*
fileName
=
QString
::
fromStdString
(
jsFileName
.
as
<
std
::
string
>
());
}
QString
DesignViewer
::
unpackProject
(
const
QByteArray
&
project
,
bool
extractZip
)
QString
DesignViewer
::
unpackProject
(
const
QByteArray
&
project
)
{
QString
projectLocation
=
"/home/web_user/"
;
if
(
extractZip
)
{
QDir
().
mkpath
(
projectLocation
);
QBuffer
buffer
;
buffer
.
setData
(
project
);
buffer
.
open
(
QIODevice
::
ReadOnly
);
QZipReader
reader
(
&
buffer
);
reader
.
extractAll
(
projectLocation
);
}
qDebug
()
<<
"Initial project location: "
+
projectLocation
;
QDir
projectLocationDir
(
projectLocation
);
// maybe it was not a zip file so try it as resource binary
if
(
projectLocationDir
.
isEmpty
())
{
if
(
extractZip
)
qDebug
()
<<
"File could not be extracted. Trying to open it as a resource file."
;
const
uchar
*
data
;
if
(
m_projectData
.
size
())
{
qDebug
()
<<
"Unregistering the previous data from QRC system. Path: "
+
m_projectPath
+
" Size: "
+
QString
::
number
(
m_projectData
.
size
())
+
" bytes."
;
data
=
reinterpret_cast
<
const
uchar
*>
(
m_projectData
.
data
());
if
(
!
QResource
::
unregisterResource
(
data
,
m_projectPath
))
{
qCritical
()
<<
"Cannot unregister the previous resource data."
;
}
}
m_projectData
=
project
;
const
uchar
*
data
;
if
(
m_projectData
.
size
())
{
qDebug
()
<<
"Unregistering the previous data from QRC system. Path: "
+
m_projectPath
+
" Size: "
+
QString
::
number
(
m_projectData
.
size
())
+
" bytes."
;
data
=
reinterpret_cast
<
const
uchar
*>
(
m_projectData
.
data
());
qDebug
()
<<
"Registering resource data. Size: "
+
QString
::
number
(
m_projectData
.
size
());
if
(
!
QResource
::
unregisterResource
(
data
,
m_projectPath
))
{
qCritical
()
<<
"Cannot unregister the previous resource data."
;
}
}
const
QString
resourcePath
{
"/"
+
QString
::
number
(
QRandomGenerator
::
global
()
->
generate
())};
m_projectPath
=
resourcePath
;
m_projectData
=
project
;
data
=
reinterpret_cast
<
const
uchar
*>
(
m_projectData
.
data
());
qDebug
()
<<
"Registering resource data. Size: "
+
QString
::
number
(
m_projectData
.
size
());
if
(
!
QDir
(
resourcePath
).
removeRecursively
())
{
qDebug
()
<<
"Could not remove resource path: "
+
resourcePath
;
}
const
QString
resourcePath
{
"/"
+
QString
::
number
(
QRandomGenerator
::
global
()
->
generate
())};
m_projectPath
=
resourcePath
;
if
(
!
QResource
::
registerResource
(
data
,
resourcePath
))
{
qCritical
()
<<
"Can not load the resource data."
;
return
""
;
}
if
(
!
QDir
(
resourcePath
).
removeRecursively
())
{
qDebug
()
<<
"Could not remove resource path: "
+
resourcePath
;
}
projectLocation
=
":"
+
resourcePath
;
if
(
!
QResource
::
registerResource
(
data
,
resourcePath
))
{
qCritical
()
<<
"Can not load the resource data."
;
return
""
;
}
return
projectLocation
;
return
QString
(
resourcePath
).
prepend
(
":"
)
;
}
QString
DesignViewer
::
findFile
(
const
QString
&
dir
,
const
QString
&
filter
)
Loading