Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLMC
Manage
Activity
Members
Labels
Plan
Issues
26
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
VideoLAN
VLMC
Commits
cf3c3c3d
Commit
cf3c3c3d
authored
8 years ago
by
luyikei
Committed by
Hugo Beauzée-Luyssen
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
RecentProjects: Use QVariantList to store m_recentsProjects
parent
7c5b378a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Gui/wizard/WelcomePage.cpp
+5
-5
5 additions, 5 deletions
src/Gui/wizard/WelcomePage.cpp
src/Project/RecentProjects.cpp
+22
-81
22 additions, 81 deletions
src/Project/RecentProjects.cpp
src/Project/RecentProjects.h
+3
-18
3 additions, 18 deletions
src/Project/RecentProjects.h
with
30 additions
and
104 deletions
src/Gui/wizard/WelcomePage.cpp
+
5
−
5
View file @
cf3c3c3d
...
...
@@ -118,13 +118,13 @@ void
WelcomePage
::
loadRecentsProjects
()
{
m_ui
.
projectsListWidget
->
clear
();
const
RecentProjects
::
List
&
recents
=
Core
::
instance
()
->
recentProjects
()
->
list
();
for
(
int
i
=
0
;
i
<
recents
.
count
();
++
i
)
for
(
const
auto
&
var
:
Core
::
instance
()
->
recentProjects
()
->
toVariant
().
toList
()
)
{
RecentProjects
::
RecentProject
project
=
recents
.
at
(
i
);
QListWidgetItem
*
item
=
new
QListWidgetItem
(
project
.
name
);
item
->
setData
(
FilePath
,
project
.
filePath
);
const
auto
&
name
=
var
.
toMap
()[
"name"
].
toString
();
const
auto
&
filePath
=
var
.
toMap
()[
"file"
].
toString
();
QListWidgetItem
*
item
=
new
QListWidgetItem
(
name
);
item
->
setData
(
FilePath
,
filePath
);
m_ui
.
projectsListWidget
->
addItem
(
item
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/Project/RecentProjects.cpp
+
22
−
81
View file @
cf3c3c3d
...
...
@@ -20,105 +20,46 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include
<QStringList>
#include
"RecentProjects.h"
#include
"Project/Project.h"
#include
"Settings/Settings.h"
#include
"Tools/VlmcDebug.h"
RecentProjects
::
RecentProjects
(
Settings
*
vlmcSettings
,
QObject
*
parent
)
:
QObject
(
parent
)
,
m_settings
(
vlmcSettings
)
{
SettingValue
*
recentProjects
=
vlmcSettings
->
createVar
(
SettingValue
::
String
,
"private/RecentsProjects"
,
""
,
m_
recent
s
Projects
=
vlmcSettings
->
createVar
(
SettingValue
::
List
,
"private/RecentsProjects"
,
QVariantList
()
,
""
,
""
,
SettingValue
::
Private
);
connect
(
recentProjects
,
SIGNAL
(
changed
(
QVariant
)
),
this
,
SLOT
(
loadRecentProjects
(
QVariant
)
)
);
}
void
RecentProjects
::
projectLoaded
(
const
QString
&
projectName
,
const
QString
&
projectFile
)
{
removeFromRecentProjects
(
projectName
);
RecentProject
project
;
project
.
name
=
projectName
;
project
.
filePath
=
projectFile
;
m_recentsProjects
.
prepend
(
project
);
while
(
m_recentsProjects
.
count
()
>
15
)
m_recentsProjects
.
removeLast
();
Core
::
instance
()
->
settings
()
->
setValue
(
"private/RecentsProjects"
,
flattenProjectList
()
);
}
const
RecentProjects
::
List
&
RecentProjects
::
lis
t
()
const
QVariant
RecentProjects
::
toVarian
t
()
const
{
return
m_recentsProjects
;
}
QString
RecentProjects
::
flattenProjectList
()
const
{
if
(
m_recentsProjects
.
count
()
==
0
)
return
QString
();
QString
res
;
foreach
(
RecentProject
p
,
m_recentsProjects
)
{
res
+=
p
.
name
+
'#'
+
p
.
filePath
+
'#'
;
}
res
.
chop
(
1
);
return
res
;
return
QVariant
(
m_recentsProjects
->
get
().
toList
()
);
}
void
RecentProjects
::
remove
FromRecentProjects
(
const
QString
&
project
Path
)
RecentProjects
::
remove
(
const
QString
&
project
File
)
{
List
::
iterator
it
=
m_recentsProjects
.
begin
();
List
::
iterator
ite
=
m_recentsProjects
.
end
();
while
(
it
!=
ite
)
QVariantList
l
=
m_recentsProjects
->
get
().
toList
();
for
(
int
i
=
0
;
i
<
l
.
count
();
++
i
)
{
if
(
(
*
it
).
filePath
==
projectPath
)
it
=
m_recentsProjects
.
erase
(
it
);
else
++
it
;
if
(
l
[
i
].
toMap
()[
"file"
].
toString
()
==
projectFile
)
{
l
.
removeAt
(
i
);
--
i
;
}
}
m_recentsProjects
->
set
(
l
);
}
void
RecentProjects
::
remove
(
const
QString
&
project
Path
)
RecentProjects
::
projectLoaded
(
const
QString
&
project
Name
,
const
QString
&
projectFile
)
{
removeFromRecentProjects
(
projectPath
);
Core
::
instance
()
->
settings
()
->
setValue
(
"private/RecentsProjects"
,
flattenProjectList
()
);
}
void
RecentProjects
::
loadRecentProjects
(
const
QVariant
&
recentProjects
)
{
// Only watch initial loading, we are now taking ownership of "private/RecentsProjects settings"
disconnect
(
this
,
SLOT
(
loadRecentProjects
(
QVariant
)
)
);
const
QStringList
recentProjectsList
=
recentProjects
.
toString
().
split
(
'#'
);
if
(
recentProjectsList
.
count
()
==
0
)
return
;
QStringList
::
const_iterator
it
=
recentProjectsList
.
begin
();
QStringList
::
const_iterator
ite
=
recentProjectsList
.
end
();
while
(
it
!=
ite
)
{
RecentProject
project
;
project
.
name
=
*
it
;
++
it
;
if
(
it
==
ite
)
{
vlmcWarning
()
<<
"Invalid flattened recent projects list."
;
return
;
}
project
.
filePath
=
*
it
;
++
it
;
m_recentsProjects
.
append
(
project
);
}
QVariantList
l
=
m_recentsProjects
->
get
().
toList
();
QVariantMap
var
{
{
"name"
,
projectName
},
{
"file"
,
projectFile
}
};
l
.
removeAll
(
var
);
l
.
insert
(
0
,
var
);
m_recentsProjects
->
set
(
l
);
}
This diff is collapsed.
Click to expand it.
src/Project/RecentProjects.h
+
3
−
18
View file @
cf3c3c3d
...
...
@@ -26,6 +26,7 @@
#include
<QObject>
class
Project
;
class
SettingValue
;
class
Settings
;
class
RecentProjects
:
public
QObject
...
...
@@ -33,32 +34,16 @@ class RecentProjects : public QObject
Q_OBJECT
public:
struct
RecentProject
{
QString
name
;
QString
filePath
;
};
typedef
QList
<
RecentProject
>
List
;
explicit
RecentProjects
(
Settings
*
vlmcSettings
,
QObject
*
parent
=
0
);
QVariant
toVariant
()
const
;
void
remove
(
const
QString
&
projectFile
);
const
List
&
list
()
const
;
private
:
void
removeFromRecentProjects
(
const
QString
&
projectPath
);
QString
flattenProjectList
()
const
;
public
slots
:
void
projectLoaded
(
const
QString
&
projectName
,
const
QString
&
projectFile
);
private
slots
:
void
loadRecentProjects
(
const
QVariant
&
recentProjects
);
private:
Settings
*
m_settings
;
List
m_recentsProjects
;
SettingValue
*
m_recentsProjects
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment