格式整理
This commit is contained in:
parent
6def2aa88e
commit
fc7a6ba2e0
|
@ -7,10 +7,10 @@
|
|||
|
||||
namespace Tools {
|
||||
|
||||
class Run
|
||||
{
|
||||
class Run {
|
||||
public:
|
||||
Run(bool manual_flag, std::function<bool()> judge, std::function<void(bool)> execution);
|
||||
Run(bool manual_flag, std::function<bool()> judge,
|
||||
std::function<void(bool)> execution);
|
||||
|
||||
void exec();
|
||||
|
||||
|
@ -20,17 +20,17 @@ namespace Tools {
|
|||
std::function<void(bool)> execution;
|
||||
};
|
||||
|
||||
class StatusSyncCore : public QObject
|
||||
{
|
||||
class StatusSyncCore : public QObject {
|
||||
public:
|
||||
explicit StatusSyncCore(QObject *p = nullptr);
|
||||
virtual ~StatusSyncCore() = default;
|
||||
|
||||
|
||||
void widgetSync(QWidget *tar, std::function<bool()> proc);
|
||||
void actionSync(QAction *tar, std::function<bool()> proc);
|
||||
void registerAutoRun(std::function<bool()> judge, std::function<void(bool)> exec);
|
||||
Run* registerManualRun(std::function<bool()> judge, std::function<void (bool)> exec);
|
||||
void registerAutoRun(std::function<bool()> judge,
|
||||
std::function<void(bool)> exec);
|
||||
Run *registerManualRun(std::function<bool()> judge,
|
||||
std::function<void(bool)> exec);
|
||||
void sync();
|
||||
|
||||
private:
|
||||
|
@ -39,28 +39,35 @@ namespace Tools {
|
|||
QList<Run *> alltriggers;
|
||||
};
|
||||
|
||||
template<class BaseType>
|
||||
class ModelSyncs
|
||||
{
|
||||
template <class BaseType> class TreeSyncs {
|
||||
public:
|
||||
ModelSyncs(QStandardItemModel *model_base, std::function<bool(const BaseType &n, QStandardItem *p)> _equal,
|
||||
TreeSyncs(
|
||||
QStandardItemModel *model_base,
|
||||
std::function<bool(const BaseType &n, QStandardItem *p)> _equal,
|
||||
std::function<void(const BaseType &n, QStandardItem *p)> sync_proc)
|
||||
: model_present(model_base), sync_process(sync_proc), compare_process(_equal){}
|
||||
: model_present(model_base), sync_process(sync_proc),
|
||||
compare_process(_equal) {}
|
||||
|
||||
void presentSync(std::function<QList<BaseType>(const BaseType &pnode)> items_peak)
|
||||
{
|
||||
void presentSync(
|
||||
std::function<QList<BaseType>(const BaseType &pnode)> items_peak) {
|
||||
auto default_pdata = BaseType();
|
||||
auto datas = items_peak(default_pdata);
|
||||
|
||||
Operate::OpStream<QStandardItem*>([this](int &cnt, int idx)->QStandardItem*{
|
||||
Operate::OpStream<QStandardItem *>(
|
||||
[this](int &cnt, int idx) -> QStandardItem * {
|
||||
cnt = model_present->rowCount();
|
||||
if (cnt <= 0)
|
||||
return nullptr;
|
||||
|
||||
return model_present->item(idx);
|
||||
}).filter([&datas, this](QStandardItem *const &it)->bool{
|
||||
})
|
||||
.filter([&datas, this](QStandardItem *const &it) -> bool {
|
||||
for (auto &d : datas)
|
||||
if (compare_process(d, it))
|
||||
return false;
|
||||
return true;
|
||||
}).forEach([this](QStandardItem *const &it){
|
||||
})
|
||||
.forEach([this](QStandardItem *const &it) {
|
||||
model_present->removeRow(it->row());
|
||||
});
|
||||
|
||||
|
@ -79,26 +86,29 @@ namespace Tools {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
QStandardItemModel *model_present;
|
||||
std::function<void(const BaseType &n, QStandardItem *p)> sync_process;
|
||||
std::function<bool(const BaseType &n, QStandardItem *p)> compare_process;
|
||||
std::function<bool(const BaseType &n, QStandardItem *p)>
|
||||
compare_process;
|
||||
|
||||
void layer_items_sync(const BaseType &data, QStandardItem *pnode,
|
||||
void layer_items_sync(
|
||||
const BaseType &data, QStandardItem *pnode,
|
||||
std::function<QList<BaseType>(const BaseType &pnode)> items_peak) {
|
||||
auto datas = items_peak(data);
|
||||
|
||||
Operate::OpStream<QStandardItem*>([pnode](int &cnt, int idx)->QStandardItem*{
|
||||
Operate::OpStream<QStandardItem *>(
|
||||
[pnode](int &cnt, int idx) -> QStandardItem * {
|
||||
cnt = pnode->rowCount();
|
||||
return pnode->child(idx);
|
||||
}).filter([&datas, this](QStandardItem *const &it)->bool{
|
||||
})
|
||||
.filter([&datas, this](QStandardItem *const &it) -> bool {
|
||||
for (auto &d : datas)
|
||||
if (compare_process(d, it))
|
||||
return false;
|
||||
return true;
|
||||
}).forEach([pnode](QStandardItem *const &it){
|
||||
})
|
||||
.forEach([pnode](QStandardItem *const &it) {
|
||||
pnode->removeRow(it->row());
|
||||
});
|
||||
|
||||
|
@ -117,7 +127,6 @@ namespace Tools {
|
|||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace Tools
|
||||
|
||||
#endif // COMNTOOLS_H
|
||||
|
|
Loading…
Reference in New Issue