obs-studio/frontend/components/SourceTree.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
2 KiB
C++
Raw Normal View History

2018-06-02 09:45:01 -07:00
#pragma once
#include "SourceTreeItem.hpp"
#include "SourceTreeModel.hpp"
2018-06-02 09:45:01 -07:00
#include <QListView>
#include <QStaticText>
#include <QSvgRenderer>
2018-06-02 09:45:01 -07:00
class SourceTree : public QListView {
Q_OBJECT
bool ignoreReorder = false;
friend class SourceTreeModel;
friend class SourceTreeItem;
bool textPrepared = false;
QStaticText textNoSources;
QSvgRenderer iconNoSources;
OBSData undoSceneData;
bool iconsVisible = true;
void UpdateNoSourcesMessage();
2018-06-02 09:45:01 -07:00
void ResetWidgets();
void UpdateWidget(const QModelIndex &idx, obs_sceneitem_t *item);
void UpdateWidgets(bool force = false);
inline SourceTreeModel *GetStm() const { return reinterpret_cast<SourceTreeModel *>(model()); }
public:
2018-06-02 09:45:01 -07:00
inline SourceTreeItem *GetItemWidget(int idx)
{
QWidget *widget = indexWidget(GetStm()->createIndex(idx, 0));
return reinterpret_cast<SourceTreeItem *>(widget);
}
explicit SourceTree(QWidget *parent = nullptr);
inline bool IgnoreReorder() const { return ignoreReorder; }
inline void Clear() { GetStm()->Clear(); }
inline void Add(obs_sceneitem_t *item) { GetStm()->Add(item); }
inline OBSSceneItem Get(int idx) { return GetStm()->Get(idx); }
inline QString GetNewGroupName() { return GetStm()->GetNewGroupName(); }
void SelectItem(obs_sceneitem_t *sceneitem, bool select);
bool MultipleBaseSelected() const;
bool GroupsSelected() const;
bool GroupedItemsSelected() const;
2019-07-27 23:59:16 -05:00
void UpdateIcons();
void SetIconsVisible(bool visible);
2019-07-27 23:59:16 -05:00
2018-06-02 09:45:01 -07:00
public slots:
inline void ReorderItems() { GetStm()->ReorderItems(); }
inline void RefreshItems() { GetStm()->SceneChanged(); }
2024-02-06 13:13:49 +01:00
void Remove(OBSSceneItem item, OBSScene scene);
2018-06-02 09:45:01 -07:00
void GroupSelectedItems();
void UngroupSelectedGroups();
void AddGroup();
bool Edit(int idx);
void NewGroupEdit(int idx);
2018-06-02 09:45:01 -07:00
protected:
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
virtual void dropEvent(QDropEvent *event) override;
virtual void paintEvent(QPaintEvent *event) override;
2018-06-02 09:45:01 -07:00
virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override;
};