diff --git a/resources/icons/chevron-down_48px.svg b/resources/actions/chevron-down_48px.svg similarity index 100% rename from resources/icons/chevron-down_48px.svg rename to resources/actions/chevron-down_48px.svg diff --git a/resources/icons/chevron-up_48px.svg b/resources/actions/chevron-up_48px.svg similarity index 100% rename from resources/icons/chevron-up_48px.svg rename to resources/actions/chevron-up_48px.svg diff --git a/resources/actions/filter_48px.svg b/resources/actions/filter_48px.svg new file mode 100644 index 0000000000000000000000000000000000000000..667d9adead0a56945f49fe01af7eeb593ad504d2 --- /dev/null +++ b/resources/actions/filter_48px.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/icons/rotate_48px.svg b/resources/actions/rotate_48px.svg similarity index 100% rename from resources/icons/rotate_48px.svg rename to resources/actions/rotate_48px.svg diff --git a/resources/actions/sorter_48px.svg b/resources/actions/sorter_48px.svg new file mode 100644 index 0000000000000000000000000000000000000000..544ae38934a307818d35cf5870b65a73a9c19cf9 --- /dev/null +++ b/resources/actions/sorter_48px.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/dark/icons/am_filter_64px.svg b/resources/dark/icons/am_filter_64px.svg deleted file mode 100644 index 4c7f9f157b2fa187bb92d5b96b98b92e58755da5..0000000000000000000000000000000000000000 --- a/resources/dark/icons/am_filter_64px.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons.qrc b/resources/icons.qrc index 49309d8d3c936c0e827c4e9c055922db1477c788..49fdd844fa3fa010ed03b985f053c2ae6dd66271 100644 --- a/resources/icons.qrc +++ b/resources/icons.qrc @@ -1,13 +1,13 @@ - light/icons/am_filter_64px.svg - dark/icons/am_filter_64px.svg icons/ccc-app-manager_56px.svg icons/app-manager_bak_64px.svg - icons/rotate_48px.svg - icons/chevron-down_48px.svg - icons/chevron-up_48px.svg icons/distributor-logo-deepin_64px.svg icons/spark-store_64px.svg + actions/rotate_48px.svg + actions/chevron-down_48px.svg + actions/chevron-up_48px.svg + actions/filter_48px.svg + actions/sorter_48px.svg diff --git a/resources/light/icons/am_filter_64px.svg b/resources/light/icons/am_filter_64px.svg deleted file mode 100644 index 4c7f9f157b2fa187bb92d5b96b98b92e58755da5..0000000000000000000000000000000000000000 --- a/resources/light/icons/am_filter_64px.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/appmanagerwidget.cpp b/src/appmanagerwidget.cpp index cac4612360882abe9dcb6a2632cbd6db2d145200..fa7c5ce03f4e49f0aa5085dff267054c10832ef9 100644 --- a/src/appmanagerwidget.cpp +++ b/src/appmanagerwidget.cpp @@ -51,6 +51,11 @@ AppManagerWidget::AppManagerWidget(AppManagerModel *model, QWidget *parent) , m_showSearchedAppAction(nullptr) , m_showVerHeldAppAction(nullptr) , m_displayRangeType(DisplayRangeType::All) + , m_sorterMenu(nullptr) + , m_descendingSortByNameAction(nullptr) + , m_descendingSortByInstalledSizeAction(nullptr) + , m_descendingSortByUpdatedTimeAction(nullptr) + , m_currentSortingAction(nullptr) , m_appListModel(nullptr) , m_appListView(nullptr) , m_appCountLabel(nullptr) @@ -114,26 +119,44 @@ AppManagerWidget::AppManagerWidget(AppManagerModel *model, QWidget *parent) QPushButton *filterBtn = new QPushButton(this); filterBtn->setToolTip("展示类别"); + filterBtn->setIcon(QIcon::fromTheme("filter")); filterBtn->setFixedWidth(30); guideOperatingLayout->addWidget(filterBtn); m_filterMenu = new QMenu(this); - m_showAllAppAction = new QAction("全部应用"); + m_showAllAppAction = new QAction("全部应用", this); m_showAllAppAction->setCheckable(true); m_filterMenu->addAction(m_showAllAppAction); - m_showInstalledAppAction = new QAction("已安装应用"); + m_showInstalledAppAction = new QAction("已安装应用", this); m_showInstalledAppAction->setCheckable(true); m_filterMenu->addAction(m_showInstalledAppAction); - m_showGuiAppAction = new QAction("界面应用"); + m_showGuiAppAction = new QAction("界面应用", this); m_showGuiAppAction->setCheckable(true); m_filterMenu->addAction(m_showGuiAppAction); - m_showSearchedAppAction = new QAction("搜索结果"); + m_showSearchedAppAction = new QAction("搜索结果", this); m_showSearchedAppAction->setCheckable(true); m_filterMenu->addAction(m_showSearchedAppAction); - m_showVerHeldAppAction = new QAction("已保持版本"); + m_showVerHeldAppAction = new QAction("已保持版本", this); m_showVerHeldAppAction->setCheckable(true); m_filterMenu->addAction(m_showVerHeldAppAction); - filterBtn->setMenu(m_filterMenu); + + QPushButton *sorterBtn = new QPushButton(this); + sorterBtn->setToolTip("排序"); + sorterBtn->setIcon(QIcon::fromTheme("sorter")); + sorterBtn->setFixedWidth(30); + guideOperatingLayout->addWidget(sorterBtn); + + m_sorterMenu = new QMenu(this); + m_descendingSortByNameAction = new QAction("名称", this); + m_descendingSortByNameAction->setCheckable(true); + m_sorterMenu->addAction(m_descendingSortByNameAction); + m_descendingSortByInstalledSizeAction = new QAction("大小", this); + m_descendingSortByInstalledSizeAction->setCheckable(true); + m_sorterMenu->addAction(m_descendingSortByInstalledSizeAction); + m_descendingSortByUpdatedTimeAction = new QAction("时间", this); + m_descendingSortByUpdatedTimeAction->setCheckable(true); + m_sorterMenu->addAction(m_descendingSortByUpdatedTimeAction); + m_currentSortingAction = m_descendingSortByNameAction; // 应用列表 m_appListModel = new QStandardItemModel(this); @@ -336,6 +359,11 @@ AppManagerWidget::AppManagerWidget(AppManagerModel *model, QWidget *parent) connect(m_searchLineEdit, &QLineEdit::editingFinished, this, &AppManagerWidget::onSearchEditingFinished); // 过滤菜单 + connect(filterBtn, &QPushButton::pressed, this, [=] { + filterBtn->setDown(true); + m_filterMenu->exec(QCursor::pos()); + filterBtn->setDown(false); + }); connect(m_filterMenu, &QMenu::triggered, this, [=](QAction *action) { m_showAllAppAction->setChecked(false); m_showInstalledAppAction->setChecked(false); @@ -360,6 +388,14 @@ AppManagerWidget::AppManagerWidget(AppManagerModel *model, QWidget *parent) } }); + // 排序菜单 + connect(sorterBtn, &QPushButton::pressed, this, [=] { + sorterBtn->setDown(true); + m_sorterMenu->exec(QCursor::pos()); + sorterBtn->setDown(false); + }); + connect(m_sorterMenu, &QMenu::triggered, this, &AppManagerWidget::onSorterMenuTriggered); + connect(reloadBtn, &QPushButton::clicked, this, [this] { this->setLoading(true); Q_EMIT m_model->notifyThreadreloadAppInfos(); @@ -372,7 +408,8 @@ AppManagerWidget::AppManagerWidget(AppManagerModel *model, QWidget *parent) return; } - showAppInfo(m_showingInfoList[row]); + AppInfo info = getAppInfoFromModelIndex(index); + showAppInfo(info); }); connect(openBtn, &QPushButton::clicked, this, [this](bool) { @@ -615,14 +652,6 @@ void AppManagerWidget::onAppInstalled(const AM::AppInfo &appInfo) switch (m_displayRangeType) { case All: case Searched: { - for (QList::iterator iter = m_showingInfoList.begin(); - iter != m_showingInfoList.end(); ++iter) { - if (appInfo.pkgName == iter->pkgName) { - *iter = appInfo; - break; - } - } - // 更新界面数据 for (int i = 0; i < m_appListModel->rowCount(); ++i) { QStandardItem *item = m_appListModel->item(i, 0); @@ -634,21 +663,18 @@ void AppManagerWidget::onAppInstalled(const AM::AppInfo &appInfo) break; } case Installed: { - m_showingInfoList.insert(0, appInfo); m_appListModel->insertRow(0, createViewItemList(appInfo)); break; } case Gui: { // 有desktop文件 if (!appInfo.desktopInfo.desktopPath.isEmpty()) { - m_showingInfoList.insert(0, appInfo); m_appListModel->insertRow(0, createViewItemList(appInfo)); } break; } case VerHeld: if (appInfo.installedPkgInfo.isHoldVersion) { - m_showingInfoList.insert(0, appInfo); m_appListModel->insertRow(0, createViewItemList(appInfo)); } break; @@ -657,11 +683,7 @@ void AppManagerWidget::onAppInstalled(const AM::AppInfo &appInfo) // 刷新右侧显示内容 if (appInfo.pkgName == m_showingAppInfo.pkgName) { // 更改后,显示列表当前选中应用 - AppInfo currentAppInfo; - if (0 <= m_appListView->currentIndex().row() && - m_appListView->currentIndex().row() < m_showingInfoList.size()) { - currentAppInfo = m_showingInfoList.at(m_appListView->currentIndex().row()); - } + AppInfo currentAppInfo = getAppInfoFromListViewModelByPkgName(m_showingAppInfo.pkgName); showAppInfo(currentAppInfo); } // 更新应用个数标签 @@ -682,14 +704,6 @@ void AppManagerWidget::onAppUpdated(const AM::AppInfo &appInfo) case All: case Searched: case Installed: { - for (QList::iterator iter = m_showingInfoList.begin(); - iter != m_showingInfoList.end(); ++iter) { - if (appInfo.pkgName == iter->pkgName) { - *iter = appInfo; - break; - } - } - // 更新界面数据 for (int i = 0; i < m_appListModel->rowCount(); ++i) { QStandardItem *item = m_appListModel->item(i, 0); @@ -701,85 +715,101 @@ void AppManagerWidget::onAppUpdated(const AM::AppInfo &appInfo) break; } case Gui: { - int operateType = 0; // 0 - add, 1 - remove, 2 - update - for (QList::iterator iter = m_showingInfoList.end() - 1; - iter != m_showingInfoList.begin() - 1; --iter) { - if (appInfo.pkgName != iter->pkgName) { + int operateType = 0; // 0 - none, 1 - add, 2 - remove, 3 - update + bool isInList = false; + for (int i = m_appListModel->rowCount() - 1; i >= 0 ; --i) { + QStandardItem *item = m_appListModel->item(i, 0); + AppInfo inListAppInfo = getAppInfoFromModelIndex(item->index()); + if (appInfo.pkgName != inListAppInfo.pkgName) { continue; } + isInList = true; if (appInfo.desktopInfo.desktopPath.isEmpty()) { - operateType = 1; - m_showingInfoList.removeOne(*iter); - } else { operateType = 2; - *iter = appInfo; + } else { + operateType = 3; } break; } + // 不在gui列表中,并存在desktop信息,则为添加操作 + if (!isInList && !appInfo.desktopInfo.desktopPath.isEmpty()) { + operateType = 1; + } + // 如果不需要操作 + if (0 == operateType) { + break; + } // 根据操作类型,更新界面和缓存列表 - if (0 == operateType) { - m_showingInfoList.insert(0, appInfo); + if (1 == operateType) { m_appListModel->insertRow(0, createViewItemList(appInfo)); - } else if (1 == operateType) { + } else { for (int i = m_appListModel->rowCount() - 1; i >= 0 ; --i) { QStandardItem *item = m_appListModel->item(i, 0); - if (appInfo.pkgName == item->data(AM_LIST_VIEW_ITEM_DATA_ROLE_PKG_NAME).toString()) { - m_appListModel->removeRow(i); - break; + AppInfo inListAppInfo = getAppInfoFromModelIndex(item->index()); + if (appInfo.pkgName != inListAppInfo.pkgName) { + continue; } - } - } else if (2 == operateType) { - for (int i = m_appListModel->rowCount() - 1; i >= 0 ; --i) { - QStandardItem *item = m_appListModel->item(i, 0); - if (appInfo.pkgName == item->data(AM_LIST_VIEW_ITEM_DATA_ROLE_PKG_NAME).toString()) { + + if (2 == operateType) { + m_appListModel->removeRow(i); + } else if (3 == operateType) { updateItemFromAppInfo(item, appInfo); - break; } + break; } } + break; } case VerHeld: { - int operateType = 0; // 0 - add, 1 - remove, 2 - update - for (QList::iterator iter = m_showingInfoList.end() - 1; - iter != m_showingInfoList.begin() - 1; --iter) { - if (appInfo.pkgName != iter->pkgName) { + int operateType = 0; // 0 - none, 1 - add, 2 - remove, 3 - update + bool isInList = false; + for (int i = m_appListModel->rowCount() - 1; i >= 0 ; --i) { + QStandardItem *item = m_appListModel->item(i, 0); + AppInfo inListAppInfo = getAppInfoFromModelIndex(item->index()); + if (appInfo.pkgName != inListAppInfo.pkgName) { continue; } + isInList = true; if (!appInfo.installedPkgInfo.isHoldVersion) { - operateType = 1; - m_showingInfoList.removeOne(*iter); - } else { operateType = 2; - *iter = appInfo; + } else { + operateType = 3; } break; } + // 不在held列表中,并为保持版本,则为添加操作 + if (!isInList && appInfo.installedPkgInfo.isHoldVersion) { + operateType = 1; + } + // 如果不需要操作 + if (0 == operateType) { + break; + } // 根据操作类型,更新界面和缓存列表 - if (0 == operateType) { - m_showingInfoList.insert(0, appInfo); + if (1 == operateType) { m_appListModel->insertRow(0, createViewItemList(appInfo)); - } else if (1 == operateType) { + } else { for (int i = m_appListModel->rowCount() - 1; i >= 0 ; --i) { QStandardItem *item = m_appListModel->item(i, 0); - if (appInfo.pkgName == item->data(AM_LIST_VIEW_ITEM_DATA_ROLE_PKG_NAME).toString()) { - m_appListModel->removeRow(i); - break; + AppInfo inListAppInfo = getAppInfoFromModelIndex(item->index()); + if (appInfo.pkgName != inListAppInfo.pkgName) { + continue; } - } - } else if (2 == operateType) { - for (int i = m_appListModel->rowCount() - 1; i >= 0 ; --i) { - QStandardItem *item = m_appListModel->item(i, 0); - if (appInfo.pkgName == item->data(AM_LIST_VIEW_ITEM_DATA_ROLE_PKG_NAME).toString()) { + + if (2 == operateType) { + m_appListModel->removeRow(i); + } else if (3 == operateType) { updateItemFromAppInfo(item, appInfo); - break; } + break; } } + break; } } @@ -787,11 +817,7 @@ void AppManagerWidget::onAppUpdated(const AM::AppInfo &appInfo) // 刷新右侧显示内容 if (appInfo.pkgName == m_showingAppInfo.pkgName) { // 更改后,显示列表当前选中应用 - AppInfo currentAppInfo; - if (0 <= m_appListView->currentIndex().row() && - m_appListView->currentIndex().row() < m_showingInfoList.size()) { - currentAppInfo = m_showingInfoList.at(m_appListView->currentIndex().row()); - } + AppInfo currentAppInfo = getAppInfoFromListViewModelByPkgName(m_showingAppInfo.pkgName); showAppInfo(currentAppInfo); } // 更新应用个数标签 @@ -811,14 +837,6 @@ void AppManagerWidget::onAppUninstalled(const AM::AppInfo &appInfo) switch (m_displayRangeType) { case All: case Searched: { - for (QList::iterator iter = m_showingInfoList.begin(); - iter != m_showingInfoList.end(); ++iter) { - if (appInfo.pkgName == iter->pkgName) { - *iter = appInfo; - break; - } - } - // 更新界面数据 for (int i = 0; i < m_appListModel->rowCount(); ++i) { QStandardItem *item = m_appListModel->item(i, 0); @@ -832,13 +850,6 @@ void AppManagerWidget::onAppUninstalled(const AM::AppInfo &appInfo) case Installed: case Gui: case VerHeld: { - for (QList::iterator iter = m_showingInfoList.end() - 1; - iter != m_showingInfoList.begin() - 1; --iter) { - if (appInfo.pkgName == iter->pkgName) { - m_showingInfoList.removeOne(*iter); - break; - } - } // 更新界面数据 for (int i = m_appListModel->rowCount() - 1; i >= 0 ; --i) { QStandardItem *item = m_appListModel->item(i, 0); @@ -854,17 +865,33 @@ void AppManagerWidget::onAppUninstalled(const AM::AppInfo &appInfo) // 刷新右侧显示内容 if (appInfo.pkgName == m_showingAppInfo.pkgName) { // 删除后,显示列表当前选中应用 - AppInfo currentAppInfo; - if (0 <= m_appListView->currentIndex().row() && - m_appListView->currentIndex().row() < m_showingInfoList.size()) { - currentAppInfo = m_showingInfoList.at(m_appListView->currentIndex().row()); - } + AppInfo currentAppInfo = getAppInfoFromListViewModelByPkgName(m_showingAppInfo.pkgName); showAppInfo(currentAppInfo); } // 更新应用个数标签 updateAppCountLabel(); } +void AppManagerWidget::onSorterMenuTriggered(QAction *action) +{ + m_descendingSortByNameAction->setChecked(false); + m_descendingSortByInstalledSizeAction->setChecked(false); + m_descendingSortByUpdatedTimeAction->setChecked(false); + + action->setChecked(true); + m_currentSortingAction = action; + if (m_descendingSortByNameAction == action) { + m_appListModel->setSortRole(AM_LIST_VIEW_ITEM_DATA_ROLE_APP_NAME); + m_appListModel->sort(0, Qt::SortOrder::AscendingOrder); + } else if (m_descendingSortByInstalledSizeAction == action) { + m_appListModel->setSortRole(AM_LIST_VIEW_ITEM_DATA_ROLE_INSTALLED_SIZE); + m_appListModel->sort(0, Qt::SortOrder::DescendingOrder); + } else if (m_descendingSortByUpdatedTimeAction == action) { + m_appListModel->setSortRole(AM_LIST_VIEW_ITEM_DATA_ROLE_UPDATED_TIME); + m_appListModel->sort(0, Qt::SortOrder::DescendingOrder); + } +} + QString AppManagerWidget::formateAppInfo(const AppInfo &info) { QString text; @@ -906,39 +933,29 @@ QString AppManagerWidget::formateAppInfo(const AppInfo &info) void AppManagerWidget::setItemModelFromAppInfoList(const QList &appInfoList) { - // 更新正在显示的应用列表 - m_showingInfoList = appInfoList; - - // 更新应用个数标签 - updateAppCountLabel(); - // 先清空数据 m_appListModel->removeRows(0, m_appListModel->rowCount()); for (const AppInfo &info : appInfoList) { - QString appName = info.desktopInfo.appName; - if (appName.isEmpty()) { - appName = info.pkgName; - } - QStandardItem *item = new QStandardItem(appName); - item->setData(ListViewItemMarginVar, Dtk::ItemDataRole::MarginsRole); - if (!info.desktopInfo.themeIconName.isEmpty()) { - item->setIcon(QIcon::fromTheme(info.desktopInfo.themeIconName)); - } else { - item->setIcon(QIcon::fromTheme(APP_THEME_ICON_DEFAULT)); - } - - item->setData(info.pkgName, AM_LIST_VIEW_ITEM_DATA_ROLE_PKG_NAME); - m_appListModel->appendRow(QList {item}); + QList items = createViewItemList(info); + m_appListModel->appendRow(items); } - if (!m_showingInfoList.isEmpty()) { - m_appListView->setCurrentIndex(m_appListModel->index(0, 0)); - showAppInfo(m_showingInfoList[0]); + // 排序 + onSorterMenuTriggered(m_currentSortingAction); + + if (m_appListModel->rowCount()) { + QModelIndex modelIndex = m_appListModel->index(0, 0); + m_appListView->setCurrentIndex(modelIndex); + AppInfo info = getAppInfoFromModelIndex(modelIndex); + showAppInfo(info); } else { // 此类别无应用,则显示空信息 showAppInfo(AppInfo()); } + + // 更新应用个数标签 + updateAppCountLabel(); } void AppManagerWidget::showAllAppInfoList() @@ -1034,7 +1051,37 @@ void AppManagerWidget::updateItemFromAppInfo(QStandardItem *item, const AppInfo item->setIcon(QIcon::fromTheme(APP_THEME_ICON_DEFAULT)); } + item->setData(ListViewItemMarginVar, Dtk::ItemDataRole::MarginsRole); + + item->setData(QVariant::fromValue(appInfo), AM_LIST_VIEW_ITEM_DATA_ROLE_ALL_DATA); item->setData(appInfo.pkgName, AM_LIST_VIEW_ITEM_DATA_ROLE_PKG_NAME); + // 为统一排序,将名称全部转换成小写 + QString appNameSortStr = getPinYinInfoFromStr(appName).normalPinYin; + appNameSortStr = appNameSortStr.toLower(); + item->setData(appNameSortStr, AM_LIST_VIEW_ITEM_DATA_ROLE_APP_NAME); + item->setData(appInfo.installedPkgInfo.pkgSize, AM_LIST_VIEW_ITEM_DATA_ROLE_PKG_SIZE); + item->setData(appInfo.installedPkgInfo.installedSize, AM_LIST_VIEW_ITEM_DATA_ROLE_INSTALLED_SIZE); + item->setData(appInfo.installedPkgInfo.updatedTime, AM_LIST_VIEW_ITEM_DATA_ROLE_UPDATED_TIME); +} + +AppInfo AppManagerWidget::getAppInfoFromModelIndex(const QModelIndex &index) +{ + AppInfo info = index.data(AM_LIST_VIEW_ITEM_DATA_ROLE_ALL_DATA).value(); + return info; +} + +AppInfo AppManagerWidget::getAppInfoFromListViewModelByPkgName(const QString &pkgName) +{ + for (int i = m_appListModel->rowCount() - 1; i >= 0; --i) { + QStandardItem *item = m_appListModel->item(i, 0); + const AppInfo &appInfo = getAppInfoFromModelIndex(item->index()); + + if (appInfo.pkgName == pkgName) { + return appInfo; + } + } + + return AppInfo(); } // 更新应用个数标签 @@ -1047,7 +1094,7 @@ void AppManagerWidget::updateAppCountLabel() break; } } - m_appCountLabel->setText(QString("%1:共%2个").arg(showingTypeStr).arg(m_showingInfoList.size())); + m_appCountLabel->setText(QString("%1:共%2个").arg(showingTypeStr).arg(m_appListModel->rowCount())); } void AppManagerWidget::updateHighlightText() diff --git a/src/appmanagerwidget.h b/src/appmanagerwidget.h index ef0f9d3eaaf20a777ea71a5c1d4c413fa66cd709..ad76d8b78807787679d9db8030cf91adb51debdb 100644 --- a/src/appmanagerwidget.h +++ b/src/appmanagerwidget.h @@ -52,6 +52,8 @@ public Q_SLOTS: void onAppInstalled(const AM::AppInfo &appInfo); void onAppUpdated(const AM::AppInfo &appInfo); void onAppUninstalled(const AM::AppInfo &appInfo); + // 当排序器出发后 + void onSorterMenuTriggered(QAction *action); private: QString formateAppInfo(const AM::AppInfo &info); @@ -67,6 +69,9 @@ private: void setLoading(bool loading); QList createViewItemList(const AM::AppInfo &appInfo); void updateItemFromAppInfo(QStandardItem *item, const AM::AppInfo &appInfo); + AppInfo getAppInfoFromModelIndex(const QModelIndex &index); + AppInfo getAppInfoFromListViewModelByPkgName(const QString &pkgName); + // 更新应用个数标签 void updateAppCountLabel(); // 更新高亮显示文字 @@ -76,7 +81,6 @@ private: private: QList m_appInfoList; - QList m_showingInfoList; AM::AppInfo m_showingAppInfo; AppManagerModel *m_model; @@ -93,6 +97,12 @@ private: QAction *m_showVerHeldAppAction; // 保持版本的app过滤按钮 DisplayRangeType m_displayRangeType; // 显示范围类型 + QMenu *m_sorterMenu; + QAction *m_descendingSortByNameAction; + QAction *m_descendingSortByInstalledSizeAction; + QAction *m_descendingSortByUpdatedTimeAction; + QAction *m_currentSortingAction; + QStandardItemModel *m_appListModel; DListView *m_appListView; QLabel *m_appCountLabel; // 应用个数标签 diff --git a/src/common/appmanagercommon.h b/src/common/appmanagercommon.h index 9f257876a62254656778205fa3b1b44eb4171386..eb6b49531bbba8e1ef7411ceabb911c5eb8b20da 100644 --- a/src/common/appmanagercommon.h +++ b/src/common/appmanagercommon.h @@ -11,7 +11,12 @@ #define MY_PKG_NAME "com.github.ccc-app-manager" // 列表数据角色定义 -#define AM_LIST_VIEW_ITEM_DATA_ROLE_PKG_NAME Dtk::ItemDataRole::UserRole + 1 +#define AM_LIST_VIEW_ITEM_DATA_ROLE_ALL_DATA Dtk::ItemDataRole::UserRole + 1 +#define AM_LIST_VIEW_ITEM_DATA_ROLE_PKG_NAME Dtk::ItemDataRole::UserRole + 2 +#define AM_LIST_VIEW_ITEM_DATA_ROLE_APP_NAME Dtk::ItemDataRole::UserRole + 3 +#define AM_LIST_VIEW_ITEM_DATA_ROLE_PKG_SIZE Dtk::ItemDataRole::UserRole + 4 +#define AM_LIST_VIEW_ITEM_DATA_ROLE_INSTALLED_SIZE Dtk::ItemDataRole::UserRole + 5 +#define AM_LIST_VIEW_ITEM_DATA_ROLE_UPDATED_TIME Dtk::ItemDataRole::UserRole + 6 // 文件大小单位,以b为基本单位 #define KB_COUNT (1 << 10) @@ -58,6 +63,7 @@ struct PkgInfo { pkgSize = 0; } }; + struct DesktopInfo { QString appName; QString desktopPath; @@ -107,3 +113,8 @@ bool judgePkgIsInstalledFromStr(const QString &str); // 判断GSettings中是否包含指定键 bool isQGSettingsContainsKey(const QGSettings &settings, const QString &key); } // namespace AM + +// 申明元类型,供QVariant使用 +Q_DECLARE_METATYPE(AM::PkgInfo) +Q_DECLARE_METATYPE(AM::DesktopInfo) +Q_DECLARE_METATYPE(AM::AppInfo)