diff options
Diffstat (limited to 'src/plugins/marketplace/qtmarketplacewelcomepage.cpp')
-rw-r--r-- | src/plugins/marketplace/qtmarketplacewelcomepage.cpp | 51 |
1 files changed, 16 insertions, 35 deletions
diff --git a/src/plugins/marketplace/qtmarketplacewelcomepage.cpp b/src/plugins/marketplace/qtmarketplacewelcomepage.cpp index 9e54b7b62f..e8bbc25d6e 100644 --- a/src/plugins/marketplace/qtmarketplacewelcomepage.cpp +++ b/src/plugins/marketplace/qtmarketplacewelcomepage.cpp @@ -55,32 +55,17 @@ int QtMarketplaceWelcomePage::priority() const return 60; } -Core::Id QtMarketplaceWelcomePage::id() const +Utils::Id QtMarketplaceWelcomePage::id() const { return "Marketplace"; } -class ProductItemDelegate : public Core::ListItemDelegate -{ -public: - void clickAction(const Core::ListItem *item) const override - { - QTC_ASSERT(item, return); - auto productItem = static_cast<const ProductItem *>(item); - const QUrl url(QString("https://marketplace.qt.io/products/").append(productItem->handle)); - QDesktopServices::openUrl(url); - } -}; - class QtMarketplacePageWidget : public QWidget { public: QtMarketplacePageWidget() - : m_productModel(new ProductListModel(this)) { const int sideMargin = 27; - auto filteredModel = new Core::ListModelFilter(m_productModel, this); - auto searchBox = new Core::SearchBox(this); m_searcher = searchBox->m_lineEdit; m_searcher->setPlaceholderText(QtMarketplaceWelcomePage::tr("Search in Marketplace...")); @@ -96,21 +81,18 @@ public: m_errorLabel->setVisible(false); vbox->addWidget(m_errorLabel); - m_gridModel.setSourceModel(filteredModel); - - auto gridView = new Core::GridView(this); - gridView->setModel(&m_gridModel); - gridView->setItemDelegate(&m_productDelegate); - vbox->addWidget(gridView); - + m_sectionedProducts = new SectionedProducts(this); auto progressIndicator = new Utils::ProgressIndicator(ProgressIndicatorSize::Large, this); - progressIndicator->attachToWidget(gridView); + progressIndicator->attachToWidget(m_sectionedProducts); progressIndicator->hide(); + vbox->addWidget(m_sectionedProducts); - connect(m_productModel, &ProductListModel::toggleProgressIndicator, + connect(m_sectionedProducts, &SectionedProducts::toggleProgressIndicator, progressIndicator, &Utils::ProgressIndicator::setVisible); - connect(m_productModel, &ProductListModel::errorOccurred, - [this, searchBox](int, const QString &message) { + connect(m_sectionedProducts, &SectionedProducts::errorOccurred, + [this, progressIndicator, searchBox](int, const QString &message) { + progressIndicator->hide(); + progressIndicator->deleteLater(); m_errorLabel->setAlignment(Qt::AlignHCenter); QFont f(m_errorLabel->font()); f.setPixelSize(20); @@ -126,17 +108,18 @@ public: connect(m_errorLabel, &QLabel::linkActivated, this, []() { QDesktopServices::openUrl(QUrl("https://marketplace.qt.io")); }); }); - connect(&m_productDelegate, &ProductItemDelegate::tagClicked, - this, &QtMarketplacePageWidget::onTagClicked); + connect(m_searcher, &QLineEdit::textChanged, - filteredModel, &Core::ListModelFilter::setSearchString); + m_sectionedProducts, &SectionedProducts::setSearchString); + connect(m_sectionedProducts, &SectionedProducts::tagClicked, + this, &QtMarketplacePageWidget::onTagClicked); } void showEvent(QShowEvent *event) override { if (!m_initialized) { m_initialized = true; - m_productModel->updateCollections(); + m_sectionedProducts->updateCollections(); } QWidget::showEvent(event); } @@ -144,7 +127,7 @@ public: void resizeEvent(QResizeEvent *ev) final { QWidget::resizeEvent(ev); - m_gridModel.setColumnCount(bestColumnCount()); + m_sectionedProducts->setColumnCount(bestColumnCount()); } int bestColumnCount() const @@ -160,11 +143,9 @@ public: } private: - ProductItemDelegate m_productDelegate; - ProductListModel *m_productModel = nullptr; + SectionedProducts *m_sectionedProducts = nullptr; QLabel *m_errorLabel = nullptr; QLineEdit *m_searcher = nullptr; - Core::GridProxyModel m_gridModel; bool m_initialized = false; }; |