porymap/include/ui/customattributestable.h

50 lines
1.5 KiB
C
Raw Normal View History

#ifndef CUSTOMATTRIBUTESTABLE_H
#define CUSTOMATTRIBUTESTABLE_H
#include <QObject>
2024-01-11 21:42:54 +00:00
#include <QJsonValue>
#include <QTableWidget>
2024-01-11 21:42:54 +00:00
class CustomAttributesTable : public QTableWidget
{
Q_OBJECT
public:
explicit CustomAttributesTable(QWidget *parent = nullptr);
2024-01-11 21:42:54 +00:00
~CustomAttributesTable() {};
QMap<QString, QJsonValue> getAttributes() const;
void setAttributes(const QMap<QString, QJsonValue> attributes);
2024-01-11 21:42:54 +00:00
void addNewAttribute(const QString &key, QJsonValue value, bool setAsDefault);
2024-01-11 21:42:54 +00:00
bool deleteSelectedAttributes();
2024-01-09 22:03:07 +00:00
2024-01-10 18:10:28 +00:00
QSet<QString> keys() const;
QSet<QString> defaultKeys() const;
2024-01-10 18:10:28 +00:00
QSet<QString> restrictedKeys() const;
void setDefaultKeys(const QSet<QString> keys);
2024-01-10 18:10:28 +00:00
void setRestrictedKeys(const QSet<QString> keys);
2024-01-09 22:03:07 +00:00
signals:
void edited();
void defaultSet(QString key, QJsonValue value);
void defaultRemoved(QString key);
2024-01-11 21:42:54 +00:00
protected:
void resizeEvent(QResizeEvent *event);
2024-01-10 18:10:28 +00:00
2024-01-11 21:42:54 +00:00
private:
QSet<QString> m_keys; // All keys currently in the table
QSet<QString> m_defaultKeys; // All keys that are in this table by default (whether or not they're present)
QSet<QString> m_restrictedKeys; // All keys not allowed in the table
2024-01-10 18:10:28 +00:00
2024-01-11 20:56:01 +00:00
QPair<QString, QJsonValue> getAttribute(int row) const;
2024-01-10 18:10:28 +00:00
int addAttribute(const QString &key, QJsonValue value);
void removeAttribute(const QString &key);
void setDefaultAttribute(const QString &key, QJsonValue value);
void unsetDefaultAttribute(const QString &key);
void resizeVertically();
};
#endif // CUSTOMATTRIBUTESTABLE_H