row removals
This commit is contained in:
parent
b64f04443c
commit
7229657f4d
|
@ -29,8 +29,12 @@ MultiverseModel::MultiverseModel(QObject *parent, QSacnNode *node)
|
|||
this, &MultiverseModel::doDiscovery);
|
||||
connect(node, &QSacnNode::subscribing,
|
||||
this, &MultiverseModel::doSubscription);
|
||||
connect(node, &QSacnNode::unsubscribing,
|
||||
this, &MultiverseModel::doUnsubscribe);
|
||||
connect(node, &QSacnNode::creating,
|
||||
this, &MultiverseModel::doCreation);
|
||||
connect(node, &QSacnNode::terminating,
|
||||
this, &MultiverseModel::doTerminate);
|
||||
}
|
||||
|
||||
|
||||
|
@ -224,6 +228,26 @@ void MultiverseModel::insert(const QModelIndex &parent,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief MultiverseModel::remove
|
||||
* @param parent
|
||||
* @param data
|
||||
*/
|
||||
void MultiverseModel::remove(const QModelIndex &parent, const QVariant &data)
|
||||
{
|
||||
auto item = static_cast<MultiverseItem*>(parent.internalPointer());
|
||||
auto row = item->childRow(Column::Universe, data);
|
||||
if (row < 0)
|
||||
return;
|
||||
auto child = item->child(row);
|
||||
if (!child)
|
||||
return;
|
||||
beginRemoveRows(parent, row, row);
|
||||
item->removeChild(child);
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
|
||||
void MultiverseModel::doDiscovery()
|
||||
{
|
||||
auto parentIndex = categoryIndexes.value(MultiverseModel::Discovery);
|
||||
|
@ -250,6 +274,18 @@ void MultiverseModel::doSubscription(QSacnUniverse* universe)
|
|||
insert(parentIndex, universe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief MultiverseModel::doUnsubscribe
|
||||
* @param universe
|
||||
*/
|
||||
void MultiverseModel::doUnsubscribe(QSacnUniverse* universe)
|
||||
{
|
||||
auto parentIndex = categoryIndexes.value(MultiverseModel::Receiver);
|
||||
remove(parentIndex, QVariant::fromValue(universe));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief MultiverseModel::doCreation
|
||||
* @param universe
|
||||
|
@ -259,3 +295,14 @@ void MultiverseModel::doCreation(QSacnUniverse* universe)
|
|||
auto parentIndex = categoryIndexes.value(MultiverseModel::Source);
|
||||
insert(parentIndex, universe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief MultiverseModel::doTerminate
|
||||
* @param universe
|
||||
*/
|
||||
void MultiverseModel::doTerminate(QSacnUniverse* universe)
|
||||
{
|
||||
auto parentIndex = categoryIndexes.value(MultiverseModel::Source);
|
||||
remove(parentIndex, QVariant::fromValue(universe));
|
||||
}
|
||||
|
|
|
@ -53,13 +53,17 @@ public:
|
|||
void insert(const QModelIndex &parent,
|
||||
QSacnUniverse *universe = nullptr,
|
||||
discoveredUniverse *discovery = nullptr);
|
||||
void remove(const QModelIndex &parent,
|
||||
const QVariant &data);
|
||||
|
||||
QMap<MultiverseModel::Catagory, QModelIndex> categoryIndexes;
|
||||
|
||||
public slots:
|
||||
void doDiscovery();
|
||||
void doSubscription(QSacnUniverse*);
|
||||
void doUnsubscribe(QSacnUniverse*);
|
||||
void doCreation(QSacnUniverse*);
|
||||
void doTerminate(QSacnUniverse*);
|
||||
|
||||
private:
|
||||
MultiverseItem * getItem(const QModelIndex &index) const;
|
||||
|
|
Loading…
Reference in New Issue