mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-06-21 12:03:43 -05:00
Insert duplicated macro after original macro
This commit is contained in:
parent
25b5590d2c
commit
d45d4ded99
|
|
@ -612,9 +612,10 @@ void AdvSceneSwitcher::CopyMacro()
|
|||
newMacro->Load(data);
|
||||
newMacro->PostLoad();
|
||||
newMacro->SetName(name);
|
||||
Macro::PrepareMoveToGroup(macro->Parent(), newMacro);
|
||||
obs_data_release(data);
|
||||
|
||||
ui->macros->Add(newMacro);
|
||||
ui->macros->Add(newMacro, macro);
|
||||
ui->macroAdd->disconnect(addPulse);
|
||||
emit MacroAdded(QString::fromStdString(name));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,7 +260,8 @@ MacroIndexToModelIndex(int realIdx,
|
|||
void MacroTreeModel::MoveItemBefore(const std::shared_ptr<Macro> &item,
|
||||
const std::shared_ptr<Macro> &before)
|
||||
{
|
||||
if (!item || !before || item == before) {
|
||||
if (!item || !before || item == before ||
|
||||
Neighbor(item, false) == before) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -313,7 +314,7 @@ void MacroTreeModel::MoveItemBefore(const std::shared_ptr<Macro> &item,
|
|||
void MacroTreeModel::MoveItemAfter(const std::shared_ptr<Macro> &item,
|
||||
const std::shared_ptr<Macro> &after)
|
||||
{
|
||||
if (!item || !after || item == after) {
|
||||
if (!item || !after || item == after || Neighbor(item, true) == after) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -706,9 +707,13 @@ void MacroTree::Reset(std::deque<std::shared_ptr<Macro>> ¯os,
|
|||
GetModel()->Reset(macros);
|
||||
}
|
||||
|
||||
void MacroTree::Add(std::shared_ptr<Macro> item) const
|
||||
void MacroTree::Add(std::shared_ptr<Macro> item,
|
||||
std::shared_ptr<Macro> after) const
|
||||
{
|
||||
GetModel()->Add(item);
|
||||
if (after) {
|
||||
MoveItemAfter(item, after);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Macro> MacroTree::GetCurrentMacro() const
|
||||
|
|
@ -834,7 +839,7 @@ void MacroTree::dropEvent(QDropEvent *event)
|
|||
Macro *dropItem = items[ModelIndexToMacroIndex(row, items)]
|
||||
.get(); // Item being dropped on
|
||||
bool itemIsGroup = dropItem->IsGroup();
|
||||
Macro *dropGroup = itemIsGroup ? dropItem : dropItem->Parent();
|
||||
Macro *dropGroup = itemIsGroup ? dropItem : dropItem->Parent().get();
|
||||
|
||||
// Not a group if moving above the group
|
||||
if (indicator == QAbstractItemView::AboveItem && itemIsGroup) {
|
||||
|
|
@ -880,7 +885,7 @@ void MacroTree::dropEvent(QDropEvent *event)
|
|||
}
|
||||
|
||||
if (hasGroups) {
|
||||
if (!itemBelow || itemBelow->Parent() != dropGroup) {
|
||||
if (!itemBelow || itemBelow->Parent().get() != dropGroup) {
|
||||
dropGroup = nullptr;
|
||||
dropOnCollapsed = false;
|
||||
}
|
||||
|
|
@ -923,7 +928,7 @@ void MacroTree::dropEvent(QDropEvent *event)
|
|||
bool collapsed = item->IsCollapsed();
|
||||
for (int j = items.size() - 1; j >= 0; j--) {
|
||||
std::shared_ptr<Macro> subitem = items[j];
|
||||
auto subitemGroup = subitem->Parent();
|
||||
auto subitemGroup = subitem->Parent().get();
|
||||
|
||||
if (subitemGroup == item.get()) {
|
||||
if (!collapsed) {
|
||||
|
|
|
|||
|
|
@ -120,7 +120,8 @@ class MacroTree : public QListView {
|
|||
public:
|
||||
explicit MacroTree(QWidget *parent = nullptr);
|
||||
void Reset(std::deque<std::shared_ptr<Macro>> &, bool highlight);
|
||||
void Add(std::shared_ptr<Macro> item) const;
|
||||
void Add(std::shared_ptr<Macro> item,
|
||||
std::shared_ptr<Macro> after = {}) const;
|
||||
void Remove(std::shared_ptr<Macro> item) const;
|
||||
void Up(std::shared_ptr<Macro> item) const;
|
||||
void Down(std::shared_ptr<Macro> item) const;
|
||||
|
|
|
|||
|
|
@ -325,10 +325,9 @@ void Macro::UpdateConditionIndices()
|
|||
}
|
||||
}
|
||||
|
||||
Macro *Macro::Parent()
|
||||
std::shared_ptr<Macro> Macro::Parent()
|
||||
{
|
||||
auto p = _parent.lock();
|
||||
return p.get();
|
||||
return _parent.lock();
|
||||
}
|
||||
|
||||
bool Macro::Save(obs_data_t *obj) const
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public:
|
|||
void SetCollapsed(bool val) { _isCollapsed = val; }
|
||||
bool IsCollapsed() { return _isCollapsed; }
|
||||
void SetParent(std::shared_ptr<Macro> m) { _parent = m; }
|
||||
Macro *Parent();
|
||||
std::shared_ptr<Macro> Parent();
|
||||
|
||||
bool Save(obs_data_t *obj) const;
|
||||
bool Load(obs_data_t *obj);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user