Commit dcb4c158 authored by Oleg Solovyov's avatar Oleg Solovyov Committed by Eike Hein

foldermodel: store information about screen used

Summary:
BUG: 401464

According to FolderModel::filterAcceptsRow code, it is possible that folderview is used by containment but not associated with a screen.
In case of m_screen == -1 there was no information about which items we should filter out.

Instead, we do not change m_screen to -1 and we can filter out items that does not belong to our screen.
m_screenUsed shows whether folderview is associated with a screen or not

Reviewers: broulik, hein, #plasma

Reviewed By: hein, #plasma

Subscribers: cfeck, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D18979
parent 408f03ca
......@@ -122,7 +122,8 @@ FolderModel::FolderModel(QObject *parent) : QSortFilterProxyModel(parent),
m_filterMode(NoFilter),
m_filterPatternMatchAll(true),
m_screenMapper(ScreenMapper::instance()),
m_complete(false)
m_complete(false),
m_screenUsed(false)
{
//needed to pass the job around with qml
qmlRegisterType<KIO::DropJob>();
......@@ -638,7 +639,9 @@ void FolderModel::setFilterMimeTypes(const QStringList &mimeList)
void FolderModel::setScreen(int screen)
{
if (m_screen == screen)
m_screenUsed = (screen != -1);
if (!m_screenUsed || m_screen == screen)
return;
m_screen = screen;
......@@ -1556,20 +1559,18 @@ bool FolderModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParen
const QUrl url = item.url();
const int screen = m_screenMapper->screenForItem(url);
// don't do anything if the folderview is not associated with a screen
if (m_screen != -1) {
if (screen == -1) {
// The item is not associated with a screen, probably because this is the first
// time we see it or the folderview was previously used as a regular applet.
// Associated with this folderview if the view is on the first available screen
if (m_screen == m_screenMapper->firstAvailableScreen(resolvedUrl())) {
m_screenMapper->addMapping(url, m_screen, ScreenMapper::DelayedSignal);
} else {
return false;
}
} else if (m_screen != screen) {
// the item belongs to a different screen, filter it out
if (m_screenUsed && screen == -1) {
// The item is not associated with a screen, probably because this is the first
// time we see it or the folderview was previously used as a regular applet.
// Associated with this folderview if the view is on the first available screen
if (m_screen == m_screenMapper->firstAvailableScreen(resolvedUrl())) {
m_screenMapper->addMapping(url, m_screen, ScreenMapper::DelayedSignal);
} else {
return false;
}
} else if (m_screen != screen) {
// the item belongs to a different screen, filter it out
return false;
}
}
......
......@@ -356,6 +356,7 @@ class FOLDERPLUGIN_TESTS_EXPORT FolderModel : public QSortFilterProxyModel, publ
QSet<QString> m_mimeSet;
QList<QRegExp> m_regExps;
int m_screen = -1;
bool m_screenUsed;
ScreenMapper *m_screenMapper = nullptr;
QObject *m_appletInterface = nullptr;
bool m_complete;
......
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