forked from MrBesen/soundboard
114 lines
2.5 KiB
C++
114 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include "config.h"
|
|
#include <QTreeWidgetItem>
|
|
|
|
// interface
|
|
class ButtonManagerItem : public QTreeWidgetItem {
|
|
protected:
|
|
ButtonManagerItem(QTreeWidgetItem* parent, int type, uint8_t pos);
|
|
public:
|
|
virtual ~ButtonManagerItem();
|
|
|
|
virtual bool hasEdit() const;
|
|
virtual bool hasRemove() const;
|
|
virtual bool hasMoveUp() const;
|
|
virtual bool hasMoveDown() const;
|
|
|
|
virtual void edit();
|
|
virtual void remove();
|
|
virtual void moveUp();
|
|
virtual void moveDown();
|
|
|
|
template<typename T>
|
|
T* getParent() const;
|
|
|
|
template<typename T>
|
|
T* getChild(int index) const;
|
|
|
|
template<typename T>
|
|
T* getSibling(int index) const;
|
|
|
|
void reenumerateAllSiblings();
|
|
protected:
|
|
QTreeWidgetItem* mparent = nullptr;
|
|
uint8_t pos = 0;
|
|
|
|
void updateAllPosBellow(int8_t diff, uint8_t size);
|
|
virtual void updatePosition();
|
|
};
|
|
|
|
class RowItem : public ButtonManagerItem {
|
|
public:
|
|
RowItem(QTreeWidgetItem* parent, uint8_t rownr, Config::RootConfig& conf);
|
|
|
|
const static int TYPE = 1000;
|
|
|
|
virtual bool hasRemove() const override;
|
|
virtual bool hasMoveUp() const override;
|
|
virtual bool hasMoveDown() const override;
|
|
|
|
virtual void remove() override;
|
|
virtual void moveUp() override;
|
|
virtual void moveDown() override;
|
|
|
|
uint8_t getRow() const; // returns the number of this row
|
|
std::vector<Config::ButtonConfig>& getConfig();
|
|
|
|
RowItem* getRowAbove() const;
|
|
RowItem* getRowBelow() const;
|
|
|
|
private:
|
|
Config::RootConfig& conf;
|
|
|
|
//called when the row was moved
|
|
void updatePosition() override;
|
|
};
|
|
|
|
class ButtonItem : public ButtonManagerItem {
|
|
public:
|
|
ButtonItem(RowItem* parent, uint8_t buttonnr, Config::RootConfig& conf);
|
|
|
|
const static int TYPE = 1001;
|
|
|
|
virtual bool hasRemove() const override;
|
|
virtual bool hasMoveUp() const override;
|
|
virtual bool hasMoveDown() const override;
|
|
|
|
virtual void remove() override;
|
|
virtual void moveUp() override;
|
|
virtual void moveDown() override;
|
|
|
|
|
|
// triggered from the view when the name was changed
|
|
void nameWasChanged();
|
|
|
|
Config::ButtonConfig& getConfig();
|
|
private:
|
|
Config::RootConfig& conf;
|
|
RowItem* row = nullptr;
|
|
|
|
void moveToRowAbove();
|
|
void moveToRowBelow();
|
|
};
|
|
|
|
class SampleItem : public ButtonManagerItem {
|
|
public:
|
|
SampleItem(ButtonItem* parent, uint8_t samplenr, Config::RootConfig& conf);
|
|
|
|
const static int TYPE = 1002;
|
|
|
|
virtual bool hasEdit() const override;
|
|
virtual bool hasRemove() const override;
|
|
|
|
virtual void edit() override;
|
|
virtual void remove() override;
|
|
|
|
Config::SampleConfig& getConfig();
|
|
private:
|
|
Config::RootConfig& conf;
|
|
ButtonItem* button = nullptr;
|
|
|
|
//called when a sample was moved
|
|
void updatePosition() override;
|
|
}; |