Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/plugin/appsmodel.cpp
Show All 27 Lines | |||||
28 | #include <QTimer> | 28 | #include <QTimer> | ||
29 | 29 | | |||
30 | #include <KLocalizedString> | 30 | #include <KLocalizedString> | ||
31 | #include <KSycoca> | 31 | #include <KSycoca> | ||
32 | 32 | | |||
33 | AppsModel::AppsModel(const QString &entryPath, bool paginate, int pageSize, bool flat, | 33 | AppsModel::AppsModel(const QString &entryPath, bool paginate, int pageSize, bool flat, | ||
34 | bool sorted, bool separators, QObject *parent) | 34 | bool sorted, bool separators, QObject *parent) | ||
35 | : AbstractModel(parent) | 35 | : AbstractModel(parent) | ||
36 | , m_complete(false) | ||||
36 | , m_paginate(paginate) | 37 | , m_paginate(paginate) | ||
37 | , m_pageSize(pageSize) | 38 | , m_pageSize(pageSize) | ||
38 | , m_deleteEntriesOnDestruction(true) | 39 | , m_deleteEntriesOnDestruction(true) | ||
39 | , m_separatorCount(0) | 40 | , m_separatorCount(0) | ||
40 | , m_showSeparators(separators) | 41 | , m_showSeparators(separators) | ||
41 | , m_showTopLevelItems(false) | 42 | , m_showTopLevelItems(false) | ||
42 | , m_appletInterface(nullptr) | 43 | , m_appletInterface(nullptr) | ||
44 | , m_autoPopulate(true) | ||||
43 | , m_description(i18n("Applications")) | 45 | , m_description(i18n("Applications")) | ||
44 | , m_entryPath(entryPath) | 46 | , m_entryPath(entryPath) | ||
45 | , m_staticEntryList(false) | 47 | , m_staticEntryList(false) | ||
46 | , m_changeTimer(0) | 48 | , m_changeTimer(0) | ||
47 | , m_flat(flat) | 49 | , m_flat(flat) | ||
48 | , m_sorted(sorted) | 50 | , m_sorted(sorted) | ||
49 | , m_appNameFormat(AppEntry::NameOnly) | 51 | , m_appNameFormat(AppEntry::NameOnly) | ||
50 | { | 52 | { | ||
51 | if (!m_entryPath.isEmpty()) { | 53 | if (!m_entryPath.isEmpty()) { | ||
52 | refresh(); | 54 | refresh(); | ||
53 | } | 55 | } | ||
54 | } | 56 | } | ||
55 | 57 | | |||
56 | AppsModel::AppsModel(const QList<AbstractEntry *> entryList, bool deleteEntriesOnDestruction, QObject *parent) | 58 | AppsModel::AppsModel(const QList<AbstractEntry *> entryList, bool deleteEntriesOnDestruction, QObject *parent) | ||
57 | : AbstractModel(parent) | 59 | : AbstractModel(parent) | ||
60 | , m_complete(false) | ||||
58 | , m_paginate(false) | 61 | , m_paginate(false) | ||
59 | , m_pageSize(24) | 62 | , m_pageSize(24) | ||
60 | , m_deleteEntriesOnDestruction(deleteEntriesOnDestruction) | 63 | , m_deleteEntriesOnDestruction(deleteEntriesOnDestruction) | ||
61 | , m_separatorCount(0) | 64 | , m_separatorCount(0) | ||
62 | , m_showSeparators(false) | 65 | , m_showSeparators(false) | ||
63 | , m_showTopLevelItems(false) | 66 | , m_showTopLevelItems(false) | ||
64 | , m_appletInterface(nullptr) | 67 | , m_appletInterface(nullptr) | ||
68 | , m_autoPopulate(true) | ||||
65 | , m_description(i18n("Applications")) | 69 | , m_description(i18n("Applications")) | ||
66 | , m_entryPath(QString()) | 70 | , m_entryPath(QString()) | ||
67 | , m_staticEntryList(true) | 71 | , m_staticEntryList(true) | ||
68 | , m_changeTimer(0) | 72 | , m_changeTimer(0) | ||
69 | , m_flat(true) | 73 | , m_flat(true) | ||
70 | , m_sorted(true) | 74 | , m_sorted(true) | ||
71 | , m_appNameFormat(AppEntry::NameOnly) | 75 | , m_appNameFormat(AppEntry::NameOnly) | ||
72 | { | 76 | { | ||
Show All 19 Lines | |||||
92 | 96 | | |||
93 | AppsModel::~AppsModel() | 97 | AppsModel::~AppsModel() | ||
94 | { | 98 | { | ||
95 | if (m_deleteEntriesOnDestruction) { | 99 | if (m_deleteEntriesOnDestruction) { | ||
96 | qDeleteAll(m_entryList); | 100 | qDeleteAll(m_entryList); | ||
97 | } | 101 | } | ||
98 | } | 102 | } | ||
99 | 103 | | |||
104 | bool AppsModel::autoPopulate() const | ||||
105 | { | ||||
106 | return m_autoPopulate; | ||||
107 | } | ||||
108 | | ||||
109 | void AppsModel::setAutoPopulate(bool populate) | ||||
110 | { | ||||
111 | if (m_autoPopulate != populate) { | ||||
112 | m_autoPopulate = populate; | ||||
113 | | ||||
114 | emit autoPopulateChanged(); | ||||
115 | } | ||||
116 | } | ||||
117 | | ||||
100 | QString AppsModel::description() const | 118 | QString AppsModel::description() const | ||
101 | { | 119 | { | ||
102 | return m_description; | 120 | return m_description; | ||
103 | } | 121 | } | ||
104 | 122 | | |||
105 | void AppsModel::setDescription(const QString &text) | 123 | void AppsModel::setDescription(const QString &text) | ||
106 | { | 124 | { | ||
107 | if (m_description != text) { | 125 | if (m_description != text) { | ||
▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Line(s) | |||||
414 | 432 | | |||
415 | QStringList AppsModel::hiddenEntries() const | 433 | QStringList AppsModel::hiddenEntries() const | ||
416 | { | 434 | { | ||
417 | return m_hiddenEntries; | 435 | return m_hiddenEntries; | ||
418 | } | 436 | } | ||
419 | 437 | | |||
420 | void AppsModel::refresh() | 438 | void AppsModel::refresh() | ||
421 | { | 439 | { | ||
440 | if (m_complete) { | ||||
441 | return; | ||||
442 | } | ||||
443 | | ||||
422 | if (m_staticEntryList) { | 444 | if (m_staticEntryList) { | ||
423 | return; | 445 | return; | ||
424 | } | 446 | } | ||
425 | 447 | | |||
426 | if (rootModel() == this && !m_appletInterface) { | 448 | if (rootModel() == this && !m_appletInterface) { | ||
427 | return; | 449 | return; | ||
428 | } | 450 | } | ||
429 | 451 | | |||
▲ Show 20 Lines • Show All 256 Lines • ▼ Show 20 Line(s) | |||||
686 | { | 708 | { | ||
687 | int i = m_entryList.indexOf(entry); | 709 | int i = m_entryList.indexOf(entry); | ||
688 | 710 | | |||
689 | if (i != -1) { | 711 | if (i != -1) { | ||
690 | QModelIndex idx = index(i, 0); | 712 | QModelIndex idx = index(i, 0); | ||
691 | emit dataChanged(idx, idx); | 713 | emit dataChanged(idx, idx); | ||
692 | } | 714 | } | ||
693 | } | 715 | } | ||
716 | | ||||
717 | void AppsModel::classBegin() | ||||
718 | { | ||||
719 | | ||||
720 | } | ||||
721 | | ||||
722 | void AppsModel::componentComplete() | ||||
723 | { | ||||
724 | m_complete = true; | ||||
725 | | ||||
726 | if (m_autoPopulate) { | ||||
727 | refresh(); | ||||
728 | } | ||||
729 | } |