Merge tag 'refs/tags/upstream/4.10.2.3' into packaging/openkylin/nile

4.10.2.3-release
This commit is contained in:
hewenfei 2024-06-19 15:30:14 +08:00
commit 42436efd75
6 changed files with 47 additions and 15 deletions

View File

@ -76,7 +76,13 @@ ListView {
model: DelegateModel {
model: appGroupModel
rootIndex: modelIndex(index)
Component.onCompleted: {
// Warning: rootIndex
// delegateModel使persistedIndexrootIndex
rootIndex = modelIndex(index);
}
delegate: Item {
width: GridView.view.cellWidth
height: GridView.view.cellHeight

View File

@ -68,6 +68,19 @@ AppCategoryPlugin::AppCategoryPlugin(QObject *parent) : AppListPluginInterface(p
EventTrack::instance()->sendClickEvent("switch_app_view", "AppView", map);
});
connect(m_categoryModel, &AppCategoryModel::rowsInserted, this, [=] {
Q_EMIT labelChanged();
});
connect(m_categoryModel, &AppCategoryModel::rowsRemoved, this, [=] {
Q_EMIT labelChanged();
});
connect(m_recentlyModel, &RecentlyInstalledModel::rowsInserted, this, [=] {
Q_EMIT labelChanged();
});
connect(m_recentlyModel, &RecentlyInstalledModel::rowsRemoved, this, [=] {
Q_EMIT labelChanged();
});
m_actions.append(categoryAction);
m_actions.append(firstLatterAction);

View File

@ -241,25 +241,34 @@ int AppGroupModel::findGroupIndex(const QModelIndex &sourceIndex) const
void AppGroupModel::insertApp(int groupIndex, const QModelIndex &sourceIndex)
{
int newIndex = sourceIndex.row();
if (groupIndex < 0 || groupIndex >= m_groups.size()) {
beginInsertRows(QModelIndex(), m_groups.size(), m_groups.size());
m_groups.append(new QVector<int>(1, sourceIndex.row()));
if (newIndex > 0) {
// 查找前一个item的index
newIndex = findGroupIndex(sourceModel()->index(--newIndex, 0));
if (newIndex < 0) {
newIndex = m_groups.size();
} else {
++newIndex;
}
}
beginInsertRows(QModelIndex(), newIndex, newIndex);
m_groups.insert(newIndex, new QVector<int>(1, sourceIndex.row()));
endInsertRows();
return;
}
int index = 0;
int newItem = sourceIndex.row();
QVector<int> *subItems = m_groups[groupIndex];
for (; index < subItems->size(); ++index) {
if (newItem < subItems->at(index)) {
if (newIndex < subItems->at(index)) {
break;
}
}
beginInsertRows(AppGroupModel::index(groupIndex, 0, QModelIndex()), index, index);
subItems->insert(index, newItem);
subItems->insert(index, newIndex);
endInsertRows();
}
@ -331,13 +340,13 @@ void AppGroupModel::onRowsAboutToBeRemoved(const QModelIndex &parent, int first,
break;
}
// 删除组里的元素
beginRemoveRows(index(groupIndex, 0, QModelIndex()), itemIndex, itemIndex);
subItems->removeAt(itemIndex);
endRemoveRows();
// 删除组
if (subItems->isEmpty()) {
if (subItems->size() > 1) {
// 删除组里的元素
beginRemoveRows(index(groupIndex, 0, QModelIndex()), itemIndex, itemIndex);
subItems->removeAt(itemIndex);
endRemoveRows();
} else {
// 删除组
beginRemoveRows(QModelIndex(), groupIndex, groupIndex);
delete m_groups.takeAt(groupIndex);
endRemoveRows();

View File

@ -128,6 +128,9 @@ void AppListModel::installPlugin(AppListPluginInterface *plugin)
connect(m_plugin, &AppListPluginInterface::titleChanged, this, [this, plugin] {
m_header->setTitle(plugin->title());
});
connect(m_plugin, &AppListPluginInterface::labelChanged, this, [this, plugin] {
Q_EMIT labelBottleChanged();
});
Q_EMIT labelBottleChanged();
}

View File

@ -104,6 +104,7 @@ public:
Q_SIGNALS:
void titleChanged();
void labelChanged();
};
} // UkuiMenu

View File

@ -25,7 +25,7 @@
#define KYLIN_ACCOUNT_INFORMATION_NAME "org.freedesktop.Accounts"
#define KYLIN_ACCOUNT_INFORMATION_PATH "/org/freedesktop/Accounts"
#define KYLIN_ACCOUNT_INFORMATION_INTERFACE "org.freedesktop.Accounts"
#define DEFAULT_USER_ICON_FILE ":/icon/default-community-image.png"
#define DEFAULT_USER_ICON_FILE ":/res/icon/default-community-image.png"
using namespace UkuiMenu;