GemListView.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #include <GemCatalog/GemListView.h>
  9. #include <GemCatalog/GemItemDelegate.h>
  10. #include <AdjustableHeaderWidget.h>
  11. #include <QMovie>
  12. #include <QHeaderView>
  13. namespace O3DE::ProjectManager
  14. {
  15. GemListView::GemListView(
  16. QAbstractItemModel* model, QItemSelectionModel* selectionModel, AdjustableHeaderWidget* header, bool readOnly, QWidget* parent)
  17. : QListView(parent)
  18. {
  19. setObjectName("GemCatalogListView");
  20. setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
  21. setModel(model);
  22. setSelectionModel(selectionModel);
  23. GemItemDelegate* itemDelegate = new GemItemDelegate(model, header, readOnly, this);
  24. connect(itemDelegate, &GemItemDelegate::MovieStartedPlaying, [=](const QMovie* playingMovie)
  25. {
  26. // Force redraw when movie is playing so animation is smooth
  27. connect(playingMovie, &QMovie::frameChanged, this, [=]
  28. {
  29. this->viewport()->repaint();
  30. });
  31. });
  32. connect(header, &AdjustableHeaderWidget::sectionsResized, [=] { update(); });
  33. setItemDelegate(itemDelegate);
  34. }
  35. } // namespace O3DE::ProjectManager