AdjustableHeaderWidget.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 <QTableWidget>
  11. #include <QHeaderView>
  12. #include <QStringList>
  13. #include <QVector>
  14. #include <QPair>
  15. #endif
  16. namespace O3DE::ProjectManager
  17. {
  18. // Using a QTableWidget for its header
  19. // Using a seperate model allows the setup of a header exactly as needed
  20. class AdjustableHeaderWidget
  21. : public QTableWidget
  22. {
  23. Q_OBJECT
  24. public:
  25. explicit AdjustableHeaderWidget(const QStringList& headerLabels,
  26. const QVector<int>& defaultHeaderWidths, int minHeaderWidth,
  27. const QVector<QHeaderView::ResizeMode>& resizeModes,
  28. QWidget* parent = nullptr);
  29. ~AdjustableHeaderWidget() = default;
  30. QPair<int, int> CalcColumnXBounds(int headerIndex) const;
  31. inline constexpr static int s_headerTextIndent = 7;
  32. inline constexpr static int s_headerWidgetHeight = 24;
  33. QHeaderView* m_header;
  34. signals:
  35. void sectionsResized();
  36. protected slots:
  37. void OnSectionResized(int logicalIndex, int oldSize, int newSize);
  38. private:
  39. inline constexpr static int s_headerIndentSection = 11;
  40. };
  41. } // namespace O3DE::ProjectManager