chore(cpn): implement ui bindings to auto widgets and apply to timers (#7331)
This commit is contained in:
@@ -4,6 +4,7 @@ project(datamodels)
|
||||
set(${PROJECT_NAME}_NAMES
|
||||
compounditemmodels
|
||||
filtereditemmodels
|
||||
itemmodeleventhandler
|
||||
)
|
||||
|
||||
AddHeadersSources()
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef FILTEREDITEMMODELS_H
|
||||
#define FILTEREDITEMMODELS_H
|
||||
#pragma once
|
||||
|
||||
#include "compounditemmodels.h"
|
||||
|
||||
@@ -112,5 +111,3 @@ class CurveRefFilteredFactory : public FilteredItemModelFactory
|
||||
|
||||
static QString fidToString(const int value);
|
||||
};
|
||||
|
||||
#endif // FILTEREDITEMMODELS_H
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "itemmodeleventhandler.h"
|
||||
|
||||
ItemModelEventHandler::ItemModelEventHandler(FilteredItemModel * itemModel,
|
||||
bool & lock,
|
||||
std::function<void()> updateCallback) :
|
||||
QObject(nullptr),
|
||||
m_lock(lock),
|
||||
m_updateCallback(std::move(updateCallback)),
|
||||
m_cnt(0)
|
||||
{
|
||||
connect(itemModel, &FilteredItemModel::aboutToBeUpdated, this, [this] ()
|
||||
{
|
||||
m_lock = true;
|
||||
m_cnt++;
|
||||
}
|
||||
);
|
||||
|
||||
connect(itemModel, &FilteredItemModel::updateComplete, this, [this] ()
|
||||
{
|
||||
m_cnt--;
|
||||
|
||||
if (m_cnt < 1) {
|
||||
if (m_updateCallback)
|
||||
m_updateCallback();
|
||||
m_lock = false;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "filtereditemmodels.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <functional>
|
||||
|
||||
class ItemModelEventHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ItemModelEventHandler(FilteredItemModel * filteredModel,
|
||||
bool & lock, std::function<void()> callback);
|
||||
virtual ~ItemModelEventHandler() = default;
|
||||
|
||||
private:
|
||||
bool &m_lock;
|
||||
std::function<void()> m_updateCallback;
|
||||
int m_cnt;
|
||||
};
|
||||
Reference in New Issue
Block a user