Skip to content

Commit

Permalink
fix: fullscreen frame scrolling bounce effect
Browse files Browse the repository at this point in the history
Change the swipeview control to listview

Issue: linuxdeepin/developer-center#10365
  • Loading branch information
xionglinlin committed Aug 22, 2024
1 parent 7c4b96a commit cfa311d
Show file tree
Hide file tree
Showing 7 changed files with 322 additions and 225 deletions.
439 changes: 214 additions & 225 deletions qml/FullscreenFrame.qml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/models/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ FILES
countlimitproxymodel.h
freesortproxymodel.h
frequentlyusedproxymodel.h
itemspagemodel.h
)

target_sources(launcher-models
Expand All @@ -43,6 +44,7 @@ PRIVATE
countlimitproxymodel.cpp
freesortproxymodel.cpp
frequentlyusedproxymodel.cpp
itemspagemodel.cpp
)

target_link_libraries(launcher-models PRIVATE
Expand Down
2 changes: 2 additions & 0 deletions src/models/itemarrangementproxymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class ItemArrangementProxyModel : public QConcatenateTablesProxyModel
Q_INVOKABLE int creatEmptyPage() const;
Q_INVOKABLE void removeEmptyPage() const;

ItemsPage *itemsPage() { return m_topLevel; }

// QAbstractItemModel interface
public:
QVariant data(const QModelIndex &index, int role) const override;
Expand Down
7 changes: 7 additions & 0 deletions src/models/itemspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "itemspage.h"

#include <QSet>
#include <QDebug>

ItemsPage::ItemsPage(const QString &name, int maxItemCountPerPage, QObject *parent)
: QObject(parent)
Expand Down Expand Up @@ -72,6 +73,7 @@ void ItemsPage::appendEmptyPage()
m_pages.append(QStringList());

emit pageCountChanged();
emit sigPageAdded(m_pages.count() - 1, m_pages.count() - 1);
}

// if length of items larger than max item count per page, there will be another page get appended
Expand All @@ -82,6 +84,8 @@ void ItemsPage::appendPage(const QStringList items)

if (len == 0) return;

int first = m_pages.count();

QList<QString>::const_iterator begin = items.constBegin();

for (int i = 1; i <= pages; i++) {
Expand All @@ -99,6 +103,7 @@ void ItemsPage::appendPage(const QStringList items)
}

emit pageCountChanged();
emit sigPageAdded(first, m_pages.count() - 1);
}

// find a page with empty place and append the item to that page.
Expand Down Expand Up @@ -182,6 +187,7 @@ bool ItemsPage::removeItem(const QString id, bool removePageIfPageIsEmpty)
if (removePageIfPageIsEmpty && m_pages.at(page).isEmpty()) {
m_pages.removeAt(page);
emit pageCountChanged();
emit sigPageRemoved(m_pages.count() - 1, m_pages.count() - 1);
}

return true;
Expand Down Expand Up @@ -209,6 +215,7 @@ void ItemsPage::removeEmptyPages()
m_pages.removeAll({});
if (count != m_pages.size()) {
emit pageCountChanged();
emit sigPageRemoved(m_pages.count() - 1, m_pages.count() - 1);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/models/itemspage.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class ItemsPage : public QObject
signals:
void nameChanged();
void pageCountChanged();
void sigPageAdded(int first, int last);
void sigPageRemoved(int first, int last);

private:
int m_maxItemCountPerPage;
Expand Down
58 changes: 58 additions & 0 deletions src/models/itemspagemodel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "itemspagemodel.h"
#include "itemarrangementproxymodel.h"

ItemsPageModel::ItemsPageModel(QObject *parent)
: QAbstractListModel{parent}
, m_topLevel(nullptr)
, m_sourceModel(nullptr)
{

}

int ItemsPageModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)

if (!m_topLevel) {
return 0;
}

return m_topLevel->pageCount();
}

QVariant ItemsPageModel::data(const QModelIndex &index, int role) const
{
Q_UNUSED(index)
return QVariant();
}

void ItemsPageModel::setModel(QAbstractItemModel *model)
{
if (!model || model == m_sourceModel) {
return;
}

m_sourceModel = model;
emit sourceModelChanged(model);

m_topLevel = qobject_cast<ItemArrangementProxyModel*>(m_sourceModel)->itemsPage();
if (m_topLevel) {

m_topLevel->disconnect(SIGNAL(sigPageAdded(int, int)), this);
m_topLevel->disconnect(SIGNAL(sigPageRemoved(int, int)), this);

connect(m_topLevel, &ItemsPage::sigPageAdded, this, [ = ] (int first, int last) {
beginInsertRows(QModelIndex(), first, last);
endInsertRows();
});

connect(m_topLevel, &ItemsPage::sigPageRemoved, this, [ = ] (int first, int last) {
beginRemoveRows(QModelIndex(), first, last);
endRemoveRows();
});
}
}
37 changes: 37 additions & 0 deletions src/models/itemspagemodel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef ITEMSPAGEMODEL_H
#define ITEMSPAGEMODEL_H

#include <QtQml/qqml.h>
#include <QAbstractListModel>

#include "itemspage.h"

class ItemsPageModel : public QAbstractListModel
{
Q_OBJECT

Q_PROPERTY(QAbstractItemModel *sourceModel READ sourceModel WRITE setModel NOTIFY sourceModelChanged)
QML_NAMED_ELEMENT(ItemsPageModel)

public:
explicit ItemsPageModel(QObject *parent = nullptr);

Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

QAbstractItemModel *sourceModel() { return m_sourceModel; }
void setModel(QAbstractItemModel *model);

signals:
void sourceModelChanged(QObject *);

private:
ItemsPage *m_topLevel;
QAbstractItemModel *m_sourceModel;
};

#endif // ITEMSPAGEMODEL_H

0 comments on commit cfa311d

Please sign in to comment.