Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
KDevelop
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
28
Merge Requests
28
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
KDevelop
KDevelop
Commits
12b7e57e
Commit
12b7e57e
authored
Jan 21, 2020
by
Friedrich W. H. Kossebau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clazy: add configurable predefined checkset selections
parent
2271921d
Pipeline
#13579
failed with stage
in 60 minutes
Changes
28
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
2224 additions
and
56 deletions
+2224
-56
plugins/clazy/CMakeLists.txt
plugins/clazy/CMakeLists.txt
+7
-0
plugins/clazy/analyzer.cpp
plugins/clazy/analyzer.cpp
+8
-2
plugins/clazy/analyzer.h
plugins/clazy/analyzer.h
+3
-1
plugins/clazy/checksetselection.cpp
plugins/clazy/checksetselection.cpp
+80
-0
plugins/clazy/checksetselection.h
plugins/clazy/checksetselection.h
+64
-0
plugins/clazy/checksetselectionlock.cpp
plugins/clazy/checksetselectionlock.cpp
+92
-0
plugins/clazy/checksetselectionlock.h
plugins/clazy/checksetselectionlock.h
+61
-0
plugins/clazy/checksetselectionmanager.cpp
plugins/clazy/checksetselectionmanager.cpp
+468
-0
plugins/clazy/checksetselectionmanager.h
plugins/clazy/checksetselectionmanager.h
+116
-0
plugins/clazy/config/checksetmanagewidget.cpp
plugins/clazy/config/checksetmanagewidget.cpp
+320
-0
plugins/clazy/config/checksetmanagewidget.h
plugins/clazy/config/checksetmanagewidget.h
+73
-0
plugins/clazy/config/checksetmanagewidget.ui
plugins/clazy/config/checksetmanagewidget.ui
+126
-0
plugins/clazy/config/checksetselectioncombobox.cpp
plugins/clazy/config/checksetselectioncombobox.cpp
+72
-0
plugins/clazy/config/checksetselectioncombobox.h
plugins/clazy/config/checksetselectioncombobox.h
+60
-0
plugins/clazy/config/checksetselectionlistmodel.cpp
plugins/clazy/config/checksetselectionlistmodel.cpp
+341
-0
plugins/clazy/config/checksetselectionlistmodel.h
plugins/clazy/config/checksetselectionlistmodel.h
+93
-0
plugins/clazy/config/checkswidget.cpp
plugins/clazy/config/checkswidget.cpp
+20
-1
plugins/clazy/config/checkswidget.h
plugins/clazy/config/checkswidget.h
+6
-1
plugins/clazy/config/globalconfigpage.cpp
plugins/clazy/config/globalconfigpage.cpp
+49
-24
plugins/clazy/config/globalconfigpage.h
plugins/clazy/config/globalconfigpage.h
+19
-1
plugins/clazy/config/globalconfigpage.ui
plugins/clazy/config/globalconfigpage.ui
+6
-11
plugins/clazy/config/projectconfigpage.cpp
plugins/clazy/config/projectconfigpage.cpp
+75
-9
plugins/clazy/config/projectconfigpage.h
plugins/clazy/config/projectconfigpage.h
+22
-3
plugins/clazy/config/projectconfigpage.ui
plugins/clazy/config/projectconfigpage.ui
+25
-0
plugins/clazy/config/projectsettings.kcfg
plugins/clazy/config/projectsettings.kcfg
+4
-0
plugins/clazy/config/projectsettings.kcfgc
plugins/clazy/config/projectsettings.kcfgc
+1
-0
plugins/clazy/plugin.cpp
plugins/clazy/plugin.cpp
+11
-3
plugins/clazy/plugin.h
plugins/clazy/plugin.h
+2
-0
No files found.
plugins/clazy/CMakeLists.txt
View file @
12b7e57e
...
...
@@ -13,6 +13,9 @@ set(kdevclazy_core_SRCS
job.cpp
jobparameters.cpp
utils.cpp
checksetselection.cpp
checksetselectionlock.cpp
checksetselectionmanager.cpp
)
declare_qt_logging_category
(
kdevclazy_core_SRCS
TYPE PLUGIN
...
...
@@ -38,12 +41,16 @@ set(kdevclazy_SRCS
analyzer.cpp
plugin.cpp
config/checksetselectioncombobox.cpp
config/checksetselectionlistmodel.cpp
config/checksetmanagewidget.cpp
config/checkswidget.cpp
config/commandlinewidget.cpp
config/globalconfigpage.cpp
config/projectconfigpage.cpp
)
ki18n_wrap_ui
(
kdevclazy_SRCS
config/checksetmanagewidget.ui
config/checkswidget.ui
config/commandlinewidget.ui
config/globalconfigpage.ui
...
...
plugins/clazy/analyzer.cpp
View file @
12b7e57e
...
...
@@ -25,6 +25,7 @@
// plugin
#include "plugin.h"
#include "job.h"
#include "checksetselectionmanager.h"
#include "globalsettings.h"
#include "projectsettings.h"
#include "checksdb.h"
...
...
@@ -39,7 +40,7 @@
namespace
Clazy
{
Analyzer
::
Analyzer
(
Plugin
*
plugin
,
QObject
*
parent
)
Analyzer
::
Analyzer
(
Plugin
*
plugin
,
CheckSetSelectionManager
*
checkSetSelectionManager
,
QObject
*
parent
)
:
KDevelop
::
CompileAnalyzer
(
plugin
,
i18n
(
"Clazy"
),
QStringLiteral
(
"clazy"
),
QStringLiteral
(
"clazy_file"
),
QStringLiteral
(
"clazy_project"
),
...
...
@@ -52,6 +53,7 @@ Analyzer::Analyzer(Plugin* plugin, QObject* parent)
KDevelop
::
ProblemModel
::
ShowSource
,
parent
)
,
m_plugin
(
plugin
)
,
m_checkSetSelectionManager
(
checkSetSelectionManager
)
{
}
...
...
@@ -77,7 +79,11 @@ KDevelop::CompileAnalyzeJob * Analyzer::createJob(KDevelop::IProject* project,
params
.
url
=
url
;
params
.
filePaths
=
filePaths
;
params
.
buildDir
=
buildDirectory
.
toLocalFile
();
const
auto
checks
=
projectSettings
.
checks
();
QString
checkSetSelectionId
=
projectSettings
.
checkSetSelection
();
if
(
checkSetSelectionId
==
QLatin1String
(
"Default"
))
{
checkSetSelectionId
=
m_checkSetSelectionManager
->
defaultCheckSetSelectionId
();
}
const
auto
checks
=
checkSetSelectionId
.
isEmpty
()
?
projectSettings
.
checks
()
:
m_checkSetSelectionManager
->
checkSetSelection
(
checkSetSelectionId
).
selectionAsString
();
if
(
!
checks
.
isEmpty
())
{
params
.
checks
=
checks
;
}
else
{
...
...
plugins/clazy/analyzer.h
View file @
12b7e57e
...
...
@@ -29,13 +29,14 @@ namespace Clazy
{
class
Plugin
;
class
CheckSetSelectionManager
;
class
Analyzer
:
public
KDevelop
::
CompileAnalyzer
{
Q_OBJECT
public:
Analyzer
(
Plugin
*
plugin
,
QObject
*
parent
);
Analyzer
(
Plugin
*
plugin
,
CheckSetSelectionManager
*
checkSetSelectionManager
,
QObject
*
parent
);
~
Analyzer
();
protected:
...
...
@@ -45,6 +46,7 @@ protected:
private:
Plugin
*
const
m_plugin
;
CheckSetSelectionManager
*
const
m_checkSetSelectionManager
;
};
}
...
...
plugins/clazy/checksetselection.cpp
0 → 100644
View file @
12b7e57e
/*
* This file is part of KDevelop
*
* Copyright 2020 Friedrich W. H. Kossebau <kossebau@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#include "checksetselection.h"
// Qt
#include <QString>
namespace
Clazy
{
class
CheckSetSelectionPrivate
:
public
QSharedData
{
public:
QString
id
;
QString
name
;
QString
selection
;
};
CheckSetSelection
::
CheckSetSelection
()
:
d
(
new
CheckSetSelectionPrivate
)
{
}
CheckSetSelection
::
CheckSetSelection
(
const
CheckSetSelection
&
other
)
=
default
;
CheckSetSelection
::~
CheckSetSelection
()
=
default
;
CheckSetSelection
&
CheckSetSelection
::
operator
=
(
const
CheckSetSelection
&
other
)
=
default
;
QString
CheckSetSelection
::
selectionAsString
()
const
{
return
d
->
selection
;
}
QString
CheckSetSelection
::
id
()
const
{
return
d
->
id
;
}
QString
CheckSetSelection
::
name
()
const
{
return
d
->
name
;
}
void
CheckSetSelection
::
setId
(
const
QString
&
id
)
{
d
->
id
=
id
;
}
void
CheckSetSelection
::
setSelection
(
const
QString
&
selection
)
{
d
->
selection
=
selection
;
}
void
CheckSetSelection
::
setName
(
const
QString
&
name
)
{
d
->
name
=
name
;
}
}
plugins/clazy/checksetselection.h
0 → 100644
View file @
12b7e57e
/*
* This file is part of KDevelop
*
* Copyright 2020 Friedrich W. H. Kossebau <kossebau@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef KDEVCLAZY_CHECKSETSELECTION_H
#define KDEVCLAZY_CHECKSETSELECTION_H
// Qt
#include <QSharedDataPointer>
class
QString
;
namespace
Clazy
{
class
CheckSetSelectionPrivate
;
class
CheckSetSelection
{
public:
CheckSetSelection
();
CheckSetSelection
(
const
CheckSetSelection
&
other
);
~
CheckSetSelection
();
public:
CheckSetSelection
&
operator
=
(
const
CheckSetSelection
&
other
);
public:
void
setId
(
const
QString
&
id
);
QString
id
()
const
;
public:
void
setName
(
const
QString
&
name
);
QString
name
()
const
;
public:
QString
selectionAsString
()
const
;
void
setSelection
(
const
QString
&
selection
);
private:
QSharedDataPointer
<
CheckSetSelectionPrivate
>
d
;
};
}
#endif
plugins/clazy/checksetselectionlock.cpp
0 → 100644
View file @
12b7e57e
/*
* This file is part of KDevelop
*
* Copyright 2010-2012,2020 Friedrich W. H. Kossebau <kossebau@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#include "checksetselectionlock.h"
// plugin
#include <debug.h>
// Qt
#include <QLockFile>
#include <QSharedPointer>
#include <QString>
namespace
Clazy
{
class
CheckSetSelectionLockPrivate
:
public
QSharedData
{
public:
CheckSetSelectionLockPrivate
(
const
QString
&
fileName
,
const
QString
&
checkSetSelectionId
);
public:
QSharedPointer
<
QLockFile
>
lockFile
;
QString
checkSetSelectionId
;
};
static
QString
checkSetSelectionFileLockPath
(
const
QString
&
checkSetSelectionFilePath
)
{
// TODO: just ".lock" conflicts with KConfig(?) using the same
return
checkSetSelectionFilePath
+
QLatin1String
(
".kdevlock"
);
}
CheckSetSelectionLockPrivate
::
CheckSetSelectionLockPrivate
(
const
QString
&
fileName
,
const
QString
&
id
)
:
lockFile
(
new
QLockFile
(
fileName
.
isEmpty
()
?
fileName
:
checkSetSelectionFileLockPath
(
fileName
)))
,
checkSetSelectionId
(
id
)
{
if
(
!
fileName
.
isEmpty
())
{
if
(
!
lockFile
->
tryLock
(
1000
))
{
qCWarning
(
KDEV_CLAZY
)
<<
"Failed to acquire lock file"
<<
fileName
<<
"error ="
<<
lockFile
->
error
();
}
}
}
CheckSetSelectionLock
::
CheckSetSelectionLock
(
const
QString
&
fileName
,
const
QString
&
checkSetSelectionId
)
:
d
(
new
CheckSetSelectionLockPrivate
(
fileName
,
checkSetSelectionId
))
{
}
CheckSetSelectionLock
::
CheckSetSelectionLock
(
const
CheckSetSelectionLock
&
other
)
=
default
;
CheckSetSelectionLock
::~
CheckSetSelectionLock
()
=
default
;
CheckSetSelectionLock
&
CheckSetSelectionLock
::
operator
=
(
const
CheckSetSelectionLock
&
other
)
=
default
;
void
CheckSetSelectionLock
::
unlock
()
{
d
->
lockFile
->
unlock
();
}
bool
CheckSetSelectionLock
::
isLocked
()
const
{
return
d
->
lockFile
->
isLocked
();
}
QString
CheckSetSelectionLock
::
checkSetSelectionId
()
const
{
return
d
->
checkSetSelectionId
;
}
}
plugins/clazy/checksetselectionlock.h
0 → 100644
View file @
12b7e57e
/*
* This file is part of KDevelop
*
* Copyright 2010-2012,2020 Friedrich W. H. Kossebau <kossebau@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef KDEVCLAZY_CHECKSETSELECTIONLOCK_H
#define KDEVCLAZY_CHECKSETSELECTIONLOCK_H
// Qt
#include <QSharedDataPointer>
class
QString
;
namespace
Clazy
{
class
CheckSetSelectionLockPrivate
;
class
CheckSetSelectionLock
{
friend
class
CheckSetSelectionManager
;
protected:
CheckSetSelectionLock
(
const
QString
&
fileName
,
const
QString
&
checkSetSelectionId
);
public:
CheckSetSelectionLock
(
const
CheckSetSelectionLock
&
other
);
~
CheckSetSelectionLock
();
public:
CheckSetSelectionLock
&
operator
=
(
const
CheckSetSelectionLock
&
other
);
public:
void
unlock
();
bool
isLocked
()
const
;
QString
checkSetSelectionId
()
const
;
private:
QSharedDataPointer
<
CheckSetSelectionLockPrivate
>
d
;
};
}
#endif
plugins/clazy/checksetselectionmanager.cpp
0 → 100644
View file @
12b7e57e
/*
* This file is part of KDevelop
*
* Copyright 2010-2012,2020 Friedrich W. H. Kossebau <kossebau@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#include "checksetselectionmanager.h"
// plugin
#include "checksetselectionlock.h"
#include "debug.h"
// KF
#include <KConfigGroup>
#include <KConfig>
#include <KDirWatch>
// Qt
#include <QFileInfo>
#include <QDir>
#include <QUuid>
namespace
Clazy
{
QStringList
checkSetSelectionFileNameFilter
()
{
return
QStringList
{
QStringLiteral
(
"*.kdevczcs"
),
QStringLiteral
(
"*.kdevlock"
)
};
}
inline
QLatin1String
checkSetSelectionFileSuffix
()
{
return
QLatin1String
(
".kdevczcs"
);
}
inline
QLatin1String
checkSetSelectionDirSubPath
()
{
return
QLatin1String
(
"/kdevclazy/checksetselections"
);
}
inline
QLatin1String
defaultCheckSetSelectionFileSubPath
()
{
return
QLatin1String
(
"/kdevclazy/defaultchecksetselection"
);
}
QVector
<
QString
>
lockedCheckSetSelectionIds
(
const
CheckSetSelectionFileInfoLookup
&
checkSetSelectionFileInfoLookup
)
{
QVector
<
QString
>
result
;
for
(
auto
it
=
checkSetSelectionFileInfoLookup
.
constBegin
(),
end
=
checkSetSelectionFileInfoLookup
.
constEnd
();
it
!=
end
;
++
it
)
{
if
(
it
.
value
().
isLocked
())
{
result
.
append
(
it
.
key
());
}
}
return
result
;
}
void
updateLockStatus
(
CheckSetSelectionFileInfoLookup
&
checkSetSelectionFileInfoLookup
,
const
QVector
<
QString
>&
lockedCheckSetSelectionIds
,
const
QVector
<
QString
>&
unlockedCheckSetSelectionIds
)
{
if
(
lockedCheckSetSelectionIds
.
isEmpty
()
&&
unlockedCheckSetSelectionIds
.
isEmpty
())
{
return
;
}
for
(
auto
it
=
checkSetSelectionFileInfoLookup
.
begin
(),
end
=
checkSetSelectionFileInfoLookup
.
end
();
it
!=
end
;
++
it
)
{
bool
isLocked
;
if
(
lockedCheckSetSelectionIds
.
contains
(
it
.
key
()))
{
isLocked
=
true
;
}
else
if
(
unlockedCheckSetSelectionIds
.
contains
(
it
.
key
()))
{
isLocked
=
false
;
}
else
{
continue
;
}
it
.
value
().
setLocked
(
isLocked
);
}
}
QString
defaultCheckSetSelectionFilePath
()
{
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
GenericDataLocation
)
+
defaultCheckSetSelectionFileSubPath
();
}
QString
checkSetSelectionFilePath
(
const
QString
&
checkSetSelectionId
)
{
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
GenericDataLocation
)
+
checkSetSelectionDirSubPath
()
+
QLatin1Char
(
'/'
)
+
checkSetSelectionId
+
checkSetSelectionFileSuffix
();
}
QString
checkSetSelectionFileName
(
const
QString
&
checkSetSelectionId
)
{
return
checkSetSelectionId
+
checkSetSelectionFileSuffix
();
}
// TODO: add global lock
// TODO: make calls async
// TODO: only load checkset setlections on demand
CheckSetSelectionManager
::
CheckSetSelectionManager
()
:
m_checkSetSelectionFileWatcher
(
new
KDirWatch
(
this
))
{
connect
(
m_checkSetSelectionFileWatcher
,
&
KDirWatch
::
dirty
,
this
,
&
CheckSetSelectionManager
::
onCheckSetSelectionsFolderChanged
);
// get all folder where checkSetSelections could be stored
const
QStringList
dataFolderPaths
=
QStandardPaths
::
standardLocations
(
QStandardPaths
::
GenericDataLocation
);
for
(
const
QString
&
dataFolderPath
:
dataFolderPaths
)
{
const
QString
checkSetSelectionFolderPath
=
dataFolderPath
+
checkSetSelectionDirSubPath
();
// watch folder for changes
m_checkSetSelectionFileWatcher
->
addDir
(
checkSetSelectionFolderPath
,
KDirWatch
::
WatchDirOnly
);
// read current files
onCheckSetSelectionsFolderChanged
(
checkSetSelectionFolderPath
);
}
// default checkset selection
// While there is no proper config syncing offer in the used frameworks, use a
// single file with the id as content as workaround and watch for it changing
auto
*
defaultCheckSetSelectionWatcher
=
new
KDirWatch
(
this
);
connect
(
defaultCheckSetSelectionWatcher
,
&
KDirWatch
::
created
,
this
,
&
CheckSetSelectionManager
::
onDefaultCheckSetSelectionChanged
);
connect
(
defaultCheckSetSelectionWatcher
,
&
KDirWatch
::
dirty
,
this
,
&
CheckSetSelectionManager
::
onDefaultCheckSetSelectionChanged
);
const
QString
_defaultCheckSetSelectionFilePath
=
defaultCheckSetSelectionFilePath
();
defaultCheckSetSelectionWatcher
->
addFile
(
_defaultCheckSetSelectionFilePath
);
onDefaultCheckSetSelectionChanged
(
_defaultCheckSetSelectionFilePath
);
// report any problems with existing checkset selections?
}
CheckSetSelectionManager
::~
CheckSetSelectionManager
()
=
default
;
int
CheckSetSelectionManager
::
checkSetSelectionsCount
()
const
{
return
m_checkSetSelections
.
count
();
}
QVector
<
CheckSetSelection
>
CheckSetSelectionManager
::
checkSetSelections
()
const
{
return
m_checkSetSelections
;
}
CheckSetSelection
CheckSetSelectionManager
::
checkSetSelection
(
const
QString
&
checkSetSelectionId
)
const
{
CheckSetSelection
result
;
for
(
const
CheckSetSelection
&
checkSetSelection
:
m_checkSetSelections
)
{
if
(
checkSetSelection
.
id
()
==
checkSetSelectionId
)
{
result
=
checkSetSelection
;
break
;
}
}
return
result
;
}
QString
CheckSetSelectionManager
::
defaultCheckSetSelectionId
()
const
{
return
m_defaultCheckSetSelectionId
;
}
CheckSetSelection
CheckSetSelectionManager
::
defaultCheckSetSelection
()
const
{
return
checkSetSelection
(
m_defaultCheckSetSelectionId
);
}
bool
CheckSetSelectionManager
::
isCheckSetSelectionLocked
(
const
QString
&
checkSetSelectionId
)
const
{
bool
result
=
false
;
// search in all folders for the info
for
(
const
CheckSetSelectionFileInfoLookup
&
checkSetSelectionFileInfoLookup
:
m_checkSetSelectionFileInfoLookupPerFolder
)
{
CheckSetSelectionFileInfoLookup
::
ConstIterator
it
=
checkSetSelectionFileInfoLookup
.
find
(
checkSetSelectionId
);
if
(
it
!=
checkSetSelectionFileInfoLookup
.
constEnd
())
{
result
=
it
->
isLocked
();
break
;
}
}
return
result
;
}
void
CheckSetSelectionManager
::
saveCheckSetSelections
(
QVector
<
CheckSetSelection
>&
checkSetSelections
)
{
// TODO: do not save if locked by someone else -> needs passing of our lock? or just registering our own and check?
// create and set unique id
std
::
for_each
(
checkSetSelections
.
begin
(),
checkSetSelections
.
end
(),
[
this
](
CheckSetSelection
&
checkSetSelection
)
{
const
QString
checkSetSelectionId
=
checkSetSelection
.
id
();
bool
needsId
=
true
;
if
(
!
checkSetSelectionId
.
isEmpty
())
{
// already existing?
auto
hasCheckSetSelectionId
=
[
&
checkSetSelectionId
]
(
const
CheckSetSelection
&
existingProfile
)
{
return
(
checkSetSelectionId
==
existingProfile
.
id
());
};
if
(
std
::
any_of
(
m_checkSetSelections
.
constBegin
(),
m_checkSetSelections
.
constEnd
(),
hasCheckSetSelectionId
))
{
needsId
=
false
;
}
}
// set new uuid for non-existing
if
(
needsId
)
{
checkSetSelection
.
setId
(
QUuid
::
createUuid
().
toString
());
}
saveCheckSetSelection
(
checkSetSelection
);
});
}
void
CheckSetSelectionManager
::
removeCheckSetSelections
(
const
QVector
<
QString
>&
checkSetSelectionIds
)
{
for
(
const
QString
&
checkSetSelectionId
:
checkSetSelectionIds
)
{
removeCheckSetSelection
(
checkSetSelectionId
);
}
}