2018-10-25 00:19:38 +00:00
|
|
|
#ifndef DUST3D_MATERIAL_LIST_WIDGET_H
|
|
|
|
#define DUST3D_MATERIAL_LIST_WIDGET_H
|
2018-10-09 02:19:12 +00:00
|
|
|
#include <QTreeWidget>
|
|
|
|
#include <map>
|
2018-10-24 08:54:18 +00:00
|
|
|
#include <QMouseEvent>
|
2018-10-25 00:19:38 +00:00
|
|
|
#include "document.h"
|
2018-10-09 02:19:12 +00:00
|
|
|
#include "materialwidget.h"
|
|
|
|
|
2018-10-24 08:54:18 +00:00
|
|
|
class MaterialListWidget : public QTreeWidget
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
signals:
|
|
|
|
void removeMaterial(QUuid materialId);
|
|
|
|
void modifyMaterial(QUuid materialId);
|
|
|
|
void cornerButtonClicked(QUuid materialId);
|
|
|
|
void currentSelectedMaterialChanged(QUuid materialId);
|
|
|
|
public:
|
2018-10-25 00:19:38 +00:00
|
|
|
MaterialListWidget(const Document *document, QWidget *parent=nullptr);
|
2018-10-09 02:19:12 +00:00
|
|
|
bool isMaterialSelected(QUuid materialId);
|
|
|
|
void enableMultipleSelection(bool enabled);
|
|
|
|
public slots:
|
|
|
|
void reload();
|
|
|
|
void removeAllContent();
|
|
|
|
void materialRemoved(QUuid materialId);
|
|
|
|
void showContextMenu(const QPoint &pos);
|
|
|
|
void selectMaterial(QUuid materialId, bool multiple=false);
|
|
|
|
void copy();
|
|
|
|
void setCornerButtonVisible(bool visible);
|
|
|
|
void setHasContextMenu(bool hasContextMenu);
|
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
|
|
private:
|
|
|
|
int calculateColumnCount();
|
|
|
|
void updateMaterialSelectState(QUuid materialId, bool selected);
|
2018-10-25 00:19:38 +00:00
|
|
|
const Document *m_document = nullptr;
|
2018-10-09 02:19:12 +00:00
|
|
|
std::map<QUuid, std::pair<QTreeWidgetItem *, int>> m_itemMap;
|
|
|
|
std::set<QUuid> m_selectedMaterialIds;
|
|
|
|
QUuid m_currentSelectedMaterialId;
|
|
|
|
QUuid m_shiftStartMaterialId;
|
|
|
|
bool m_cornerButtonVisible = false;
|
|
|
|
bool m_hasContextMenu = true;
|
|
|
|
bool m_multipleSelectionEnabled = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|