玉兔远程控制 0.1.0-bate6
载入中...
搜索中...
未找到
ParameterFilter.cpp
1#include "ParameterFilter.h"
2
3CParameterFilter::CParameterFilter(QObject *parent, const QString &szPrefix)
4 : CParameter{parent, szPrefix}
5{}
6
7bool CParameterFilter::contains(const QString &szKey)
8{
9 if(m_Key.contains(szKey))
10 return true;
11 return false;
12}
13
14int CParameterFilter::AddKey(const QString& szKey)
15{
16 if(contains(szKey))
17 return 0;
18 m_Key.insert(szKey);
19 SetModified(true);
20 return 0;
21}
22
23int CParameterFilter::RemoveKey(const QString& szKey)
24{
25 m_Key.remove(szKey);
26 return 0;
27}
28
29int CParameterFilter::Clear()
30{
31 m_Key.clear();
32 return 0;
33}
34
35bool CParameterFilter::isEmpty()
36{
37 return m_Key.isEmpty();
38}
39
40int CParameterFilter::OnProcess(std::function<int (const QString &)> cb, bool bErrExit)
41{
42 if(!cb) return -1;
43 foreach(auto k, m_Key) {
44 int nRet = cb(k);
45 if(bErrExit && nRet)
46 return nRet;
47 }
48 return 0;
49}
50
51int CParameterFilter::OnLoad(QSettings &set)
52{
53 QStringList s = set.value("Key").toStringList();
54 foreach(auto k, s) {
55 AddKey(k);
56 }
57 return 0;
58}
59
60int CParameterFilter::OnSave(QSettings &set)
61{
62 QStringList s;
63 foreach (auto k, m_Key) {
64 s << k;
65 }
66 set.setValue("Key", s);
67 return 0;
68}
参数接口
Definition Parameter.h:209
int SetModified(bool bModified=true)
在设置参数时,如果有修改,则调用。