Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit cd21808d authored by Marco Martin's avatar Marco Martin

fix flicker on the second column loading a new category

don't remove/readd the page when we are just changing the model
of the page, make sure a signle model reset signal arrives to the view
to populate it all in one go
parent c87a1cd6
......@@ -52,6 +52,39 @@
K_PLUGIN_FACTORY( SidebarModeFactory, registerPlugin<SidebarMode>(); )
class SubcategoryModel : public QStandardItemModel
{
public:
SubcategoryModel(QAbstractItemModel *parentModel, QObject *parent = 0)
: QStandardItemModel(parent),
m_parentModel(parentModel)
{}
void setParentIndex(const QModelIndex &activeModule)
{
blockSignals(true);
//make the view receive a single signal when the new subcategory is loaded,
//never make the view believe there are zero items if this is not the final count
//this avoids the brief flash it had
clear();
const int subRows = m_parentModel->rowCount(activeModule);
if ( subRows > 1) {
for (int i = 0; i < subRows; ++i) {
const QModelIndex& index = m_parentModel->index(i, 0, activeModule);
QStandardItem *item = new QStandardItem(m_parentModel->data(index, Qt::DecorationRole).value<QIcon>(), m_parentModel->data(index, Qt::DisplayRole).toString());
item->setData(index.data(Qt::UserRole), Qt::UserRole);
appendRow(item);
}
}
blockSignals(false);
beginResetModel();
endResetModel();
}
private:
QAbstractItemModel *m_parentModel;
};
class SidebarMode::Private {
public:
Private()
......@@ -69,7 +102,7 @@ public:
ToolTipManager *toolTipManager;
QQuickWidget * quickWidget;
KPackage::Package package;
QStandardItemModel * subCategoryModel;
SubcategoryModel * subCategoryModel;
QWidget * mainWidget;
QWidget * placeHolderWidget;
QHBoxLayout * mainLayout;
......@@ -149,7 +182,7 @@ void SidebarMode::initEvent()
d->proxyModel->setFilterHighlightsEntries( false );
connect( d->proxyModel, &MenuProxyModel::filterRegExpChanged, this, &SidebarMode::activeCategoryChanged );
d->subCategoryModel = new QStandardItemModel( this );
d->subCategoryModel = new SubcategoryModel( d->proxyModel, this );
d->mainWidget = new QWidget();
d->mainWidget->installEventFilter(this);
d->mainLayout = new QHBoxLayout(d->mainWidget);
......@@ -189,19 +222,14 @@ void SidebarMode::changeModule( const QModelIndex& activeModule )
{
d->moduleView->closeModules();
d->subCategoryModel->clear();
const int subRows = d->proxyModel->rowCount(activeModule);
if ( subRows < 2) {
d->moduleView->loadModule( activeModule );
} else {
for (int i = 0; i < subRows; ++i) {
const QModelIndex& index = d->proxyModel->index(i, 0, activeModule);
QStandardItem *item = new QStandardItem(d->proxyModel->data(index, Qt::DecorationRole).value<QIcon>(), d->proxyModel->data(index, Qt::DisplayRole).toString());
item->setData(index.data(Qt::UserRole), Qt::UserRole);
d->subCategoryModel->appendRow(item);
}
d->moduleView->loadModule( d->proxyModel->index(0, 0, activeModule) );
}
d->subCategoryModel->setParentIndex( activeModule );
}
void SidebarMode::moduleLoaded()
......
......@@ -68,7 +68,9 @@ Kirigami.ScrollablePage {
currentIndex: systemsettings.activeSubCategory
onCountChanged: {
if (count > 1) {
root.pageStack.push(subCategoryColumn);
if (root.pageStack.depth < 2) {
root.pageStack.push(subCategoryColumn);
}
root.pageStack.currentIndex = 1;
subCategoryView.forceActiveFocus();
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment