GoToButtonDelegate.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #if !defined(Q_MOC_RUN)
  10. #include <QStyledItemDelegate>
  11. #include <QMetaType>
  12. #include <QSvgRenderer>
  13. #include <AzCore/std/string/string.h>
  14. #endif
  15. namespace AssetProcessor
  16. {
  17. struct GoToButtonData
  18. {
  19. GoToButtonData() = default;
  20. GoToButtonData(AZStd::string destination)
  21. : m_destination(AZStd::move(destination))
  22. {
  23. }
  24. AZStd::string m_destination;
  25. };
  26. class GoToButtonDelegate
  27. : public QStyledItemDelegate
  28. {
  29. Q_OBJECT
  30. public:
  31. GoToButtonDelegate(QObject* parent = nullptr);
  32. void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
  33. bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) override;
  34. Q_SIGNALS:
  35. void Clicked(const GoToButtonData& data);
  36. protected:
  37. QIcon m_icon;
  38. QIcon m_hoverIcon;
  39. };
  40. } // namespace AssetProcessor
  41. Q_DECLARE_METATYPE(AssetProcessor::GoToButtonData);