Merge tag 'refs/tags/upstream/4.10.2.3' into packaging/openkylin/nile
4.10.2.3-release
This commit is contained in:
commit
42436efd75
|
@ -76,7 +76,13 @@ ListView {
|
|||
|
||||
model: DelegateModel {
|
||||
model: appGroupModel
|
||||
rootIndex: modelIndex(index)
|
||||
|
||||
Component.onCompleted: {
|
||||
// Warning: rootIndex只需要设置一次,多次设置会导致对应关系错误,
|
||||
// delegateModel使用persistedIndex保存rootIndex,会自动进行修正
|
||||
rootIndex = modelIndex(index);
|
||||
}
|
||||
|
||||
delegate: Item {
|
||||
width: GridView.view.cellWidth
|
||||
height: GridView.view.cellHeight
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -104,6 +104,7 @@ public:
|
|||
|
||||
Q_SIGNALS:
|
||||
void titleChanged();
|
||||
void labelChanged();
|
||||
};
|
||||
|
||||
} // UkuiMenu
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue