From c8e515fd74f246875f6ffd5c2e0353fae5d6ef9d Mon Sep 17 00:00:00 2001 From: hewenfei Date: Tue, 18 Apr 2023 16:43:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=98=BE=E7=A4=BA=E5=8F=B3?= =?UTF-8?q?=E9=94=AE=E8=8F=9C=E5=8D=95=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=B4=A9=E6=BA=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/menu/menu-manager.cpp | 2 +- src/menu/menu-manager.h | 2 +- src/model/app-model.cpp | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/menu/menu-manager.cpp b/src/menu/menu-manager.cpp index 9b758d5..c0b398b 100644 --- a/src/menu/menu-manager.cpp +++ b/src/menu/menu-manager.cpp @@ -226,7 +226,7 @@ void MenuManager::showMenu(const DataEntity &entity, const QPoint &point) showMenu(MenuProvider::DataType, QVariant::fromValue(entity), point); } -void MenuManager::showMenu(const MenuProvider::RequestType &type, const QVariant &data, const QPoint &point) +void MenuManager::showMenu(const MenuProvider::RequestType &type, QVariant data, const QPoint &point) { QMenu menu; diff --git a/src/menu/menu-manager.h b/src/menu/menu-manager.h index 935e26e..e15f455 100644 --- a/src/menu/menu-manager.h +++ b/src/menu/menu-manager.h @@ -38,7 +38,7 @@ public: void registerMenuProvider(MenuProvider *provider); Q_INVOKABLE void showMenu(const QString &appid, const QPoint &point = QPoint()); void showMenu(const DataEntity &entity, const QPoint &point = QPoint()); - void showMenu(const MenuProvider::RequestType &type, const QVariant &data, const QPoint &point = QPoint()); + void showMenu(const MenuProvider::RequestType &type, QVariant data, const QPoint &point = QPoint()); private: MenuManager(); diff --git a/src/model/app-model.cpp b/src/model/app-model.cpp index 2e56065..4e3ae88 100644 --- a/src/model/app-model.cpp +++ b/src/model/app-model.cpp @@ -189,11 +189,10 @@ void AppModel::insertData(QVector &data, int index) void AppModel::openMenu(const int &index) { - if (index < 0 || index >= m_apps.size()) { - return; + QModelIndex modelIndex = createIndex(index, 0, nullptr); + if (modelIndex.isValid()) { + MenuManager::instance()->showMenu(modelIndex.data(DataEntity::Id).toString()); } - - MenuManager::instance()->showMenu(m_apps.at(index)); } void AppModel::renameFolder(const QString &index, const QString &folderName)