ColumnGroupProxyModel.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #ifndef COLUMNGROUPPROXYMODEL_H
  9. #define COLUMNGROUPPROXYMODEL_H
  10. #if !defined(Q_MOC_RUN)
  11. #include "AbstractGroupProxyModel.h"
  12. #include <QVector>
  13. #endif
  14. class ColumnSortProxyModel;
  15. class ColumnGroupProxyModel
  16. : public AbstractGroupProxyModel
  17. {
  18. Q_OBJECT
  19. public:
  20. ColumnGroupProxyModel(QObject* parent = nullptr);
  21. void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
  22. void setSourceModel(QAbstractItemModel* sourceModel) override;
  23. void AddGroup(int column);
  24. void RemoveGroup(int column);
  25. void SetGroups(const QVector<int>& columns);
  26. void ClearGroups();
  27. QVector<int> Groups() const;
  28. bool IsColumnSorted(int col) const;
  29. Qt::SortOrder SortOrder(int col) const;
  30. protected:
  31. QStringList GroupForSourceIndex(const QModelIndex& sourceIndex) const override;
  32. signals:
  33. void GroupsChanged();
  34. void SortChanged();
  35. private:
  36. ColumnSortProxyModel* m_sortModel;
  37. QVector<int> m_groups;
  38. int m_freeSortColumn;
  39. };
  40. #endif // COLUMNGROUPPROXYMODEL_H