Magellan Linux

Contents of /trunk/kdebase4-workspace/patches/kdebase4-workspace-4.4.0-kickoff.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 981 - (show annotations) (download)
Sat Feb 13 11:52:08 2010 UTC (14 years, 2 months ago) by niro
File size: 9291 byte(s)
-patches for 4.4.0

1 Index: plasma/desktop/applets/kickoff/core/systemmodel.cpp
2 ===================================================================
3 --- plasma/desktop/applets/kickoff/core/systemmodel.cpp (Revision 1087229)
4 +++ plasma/desktop/applets/kickoff/core/systemmodel.cpp (Revision 1087230)
5 @@ -52,21 +52,22 @@
6
7 struct UsageInfo {
8 UsageInfo()
9 - : used(0),
10 - available(0),
11 - dirty(true) {}
12 + : used(0),
13 + available(0)
14 + {}
15
16 quint64 used;
17 quint64 available;
18 - bool dirty;
19 };
20
21 class SystemModel::Private
22 {
23 public:
24 Private(SystemModel *parent)
25 - : q(parent)
26 - , placesModel(new KFilePlacesModel(parent)) {
27 + : q(parent),
28 + placesModel(new KFilePlacesModel(parent)),
29 + currentPlacesModelUsageIndex(0)
30 + {
31 q->setSourceModel(placesModel);
32
33 connect(placesModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
34 @@ -84,44 +85,15 @@
35 << i18n("Places")
36 << i18n("Removable Storage")
37 << i18n("Storage");
38 - loadApplications();
39 - connect(&refreshTimer, SIGNAL(timeout()),
40 - q, SLOT(startRefreshingUsageInfo()));
41 - refreshTimer.start(10000);
42 - QTimer::singleShot(0, q, SLOT(startRefreshingUsageInfo()));
43 connect(KSycoca::self(), SIGNAL(databaseChanged(const QStringList&)), q, SLOT(reloadApplications()));
44 }
45
46 - void queryFreeSpace(const QString& mountPoint) {
47 - KDiskFreeSpaceInfo freeSpace = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
48 - if (freeSpace.isValid())
49 - q->freeSpaceInfoAvailable(freeSpace.mountPoint(), freeSpace.size() / 1024,
50 - freeSpace.used() / 1024, freeSpace.available() / 1024);
51 - }
52 -
53 - void loadApplications() {
54 - const QStringList apps = Kickoff::systemApplicationList();
55 - appsList.clear();
56 -
57 - foreach(const QString &app, apps) {
58 - KService::Ptr service = KService::serviceByStorageId(app);
59 -
60 - if (!service) {
61 - continue;
62 - }
63 -
64 - appsList << service;
65 - }
66 - //kDebug() << "*************" << appsList;
67 - }
68 -
69 SystemModel * const q;
70 KFilePlacesModel *placesModel;
71 QStringList topLevelSections;
72 KService::List appsList;
73 - QList<QString> mountPointsQueue;
74 QMap<QString, UsageInfo> usageByMountpoint;
75 - QTimer refreshTimer;
76 + int currentPlacesModelUsageIndex;
77 };
78
79 SystemModel::SystemModel(QObject *parent)
80 @@ -137,7 +109,9 @@
81
82 QModelIndex SystemModel::mapFromSource(const QModelIndex &sourceIndex) const
83 {
84 - if (!sourceIndex.isValid()) return QModelIndex();
85 + if (!sourceIndex.isValid()) {
86 + return QModelIndex();
87 + }
88
89 QModelIndex parent;
90
91 @@ -356,75 +330,60 @@
92 }
93 }
94
95 -void SystemModel::startRefreshingUsageInfo()
96 +void SystemModel::refreshUsageInfo()
97 {
98 - if (!d->mountPointsQueue.isEmpty()) {
99 - return;
100 - }
101 -
102 - int rowCount = d->placesModel->rowCount();
103 - for (int i = 0; i < rowCount; ++i) {
104 - QModelIndex index = d->placesModel->index(i, 0);
105 - if (d->placesModel->isDevice(index)) {
106 - Solid::Device dev = d->placesModel->deviceForIndex(index);
107 - Solid::StorageAccess *access = dev.as<Solid::StorageAccess>();
108 -
109 - if (access && !access->filePath().isEmpty()) {
110 - d->mountPointsQueue << access->filePath();
111 - }
112 - }
113 - }
114 -
115 - if (!d->mountPointsQueue.isEmpty()) {
116 - d->queryFreeSpace(d->mountPointsQueue.takeFirst());
117 - }
118 + d->currentPlacesModelUsageIndex = 0;
119 + QTimer::singleShot(100, this, SLOT(refreshNextUsageInfo()));
120 }
121
122 -void SystemModel::reloadApplications()
123 +void SystemModel::stopRefreshingUsageInfo()
124 {
125 - d->loadApplications();
126 + d->currentPlacesModelUsageIndex = d->placesModel->rowCount();
127 }
128
129 -void SystemModel::freeSpaceInfoAvailable(const QString& mountPoint, quint64,
130 - quint64 kbUsed, quint64 kbAvailable)
131 +void SystemModel::refreshNextUsageInfo()
132 {
133 - UsageInfo info;
134 - info.used = kbUsed;
135 - info.available = kbAvailable;
136 -
137 - d->usageByMountpoint[mountPoint] = info;
138 -
139 - // More to process
140 - if (!d->mountPointsQueue.isEmpty()) {
141 - d->queryFreeSpace(d->mountPointsQueue.takeFirst());
142 + if (d->currentPlacesModelUsageIndex >= d->placesModel->rowCount()) {
143 return;
144 }
145
146 - // We're done, let's emit the changes
147 - int rowCount = d->placesModel->rowCount();
148 - for (int i = 0; i < rowCount; ++i) {
149 - QModelIndex sourceIndex = d->placesModel->index(i, 0);
150 - if (d->placesModel->isDevice(sourceIndex)) {
151 - Solid::Device dev = d->placesModel->deviceForIndex(sourceIndex);
152 - Solid::StorageAccess *access = dev.as<Solid::StorageAccess>();
153 + QModelIndex sourceIndex = d->placesModel->index(d->currentPlacesModelUsageIndex, 0);
154 + if (d->placesModel->isDevice(sourceIndex)) {
155 + Solid::Device dev = d->placesModel->deviceForIndex(sourceIndex);
156 + Solid::StorageAccess *access = dev.as<Solid::StorageAccess>();
157
158 - if (access && d->usageByMountpoint.contains(access->filePath())) {
159 - info = d->usageByMountpoint[access->filePath()];
160 + if (access && !access->filePath().isEmpty()) {
161 + KDiskFreeSpaceInfo freeSpace = KDiskFreeSpaceInfo::freeSpaceInfo(access->filePath());
162 + if (freeSpace.isValid()) {
163 + UsageInfo info;
164 + info.used = freeSpace.used() / 1024;
165 + info.available = freeSpace.available() / 1024;
166
167 - if (info.dirty) {
168 - info.dirty = false;
169 - d->usageByMountpoint[access->filePath()] = info;
170 - } else {
171 - d->usageByMountpoint.remove(access->filePath());
172 - }
173 -
174 + d->usageByMountpoint[freeSpace.mountPoint()] = info;
175 QModelIndex index = mapFromSource(sourceIndex);
176 emit dataChanged(index, index);
177 }
178 }
179 }
180 +
181 + ++d->currentPlacesModelUsageIndex;
182 + QTimer::singleShot(0, this, SLOT(refreshNextUsageInfo()));
183 }
184
185 +void SystemModel::reloadApplications()
186 +{
187 + const QStringList apps = Kickoff::systemApplicationList();
188 + d->appsList.clear();
189 +
190 + foreach (const QString &app, apps) {
191 + KService::Ptr service = KService::serviceByStorageId(app);
192 +
193 + if (service) {
194 + d->appsList << service;
195 + }
196 + }
197 +}
198 +
199 void Kickoff::SystemModel::sourceDataChanged(const QModelIndex &start, const QModelIndex &end)
200 {
201 if (start.parent().isValid()) return;
202 Index: plasma/desktop/applets/kickoff/core/systemmodel.h
203 ===================================================================
204 --- plasma/desktop/applets/kickoff/core/systemmodel.h (Revision 1087229)
205 +++ plasma/desktop/applets/kickoff/core/systemmodel.h (Revision 1087230)
206 @@ -48,13 +48,12 @@
207 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
208 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
209 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
210 + void refreshUsageInfo();
211 + void stopRefreshingUsageInfo();
212
213 private Q_SLOTS:
214 - void startRefreshingUsageInfo();
215 + void refreshNextUsageInfo();
216 void reloadApplications();
217 - void freeSpaceInfoAvailable(const QString& mountPoint, quint64 kbSize,
218 - quint64 kbUsed, quint64 kbAvailable);
219 -
220 void sourceDataChanged(const QModelIndex &start, const QModelIndex &end);
221 void sourceRowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
222 void sourceRowsInserted(const QModelIndex &parent, int start, int end);
223 Index: plasma/desktop/applets/kickoff/ui/launcher.cpp
224 ===================================================================
225 --- plasma/desktop/applets/kickoff/ui/launcher.cpp (Revision 1087229)
226 +++ plasma/desktop/applets/kickoff/ui/launcher.cpp (Revision 1087230)
227 @@ -228,7 +228,7 @@
228
229 void setupSystemView()
230 {
231 - SystemModel *model = new SystemModel(q);
232 + systemModel = new SystemModel(q);
233 UrlItemView *view = new UrlItemView();
234 ItemDelegate *delegate = new ItemDelegate(q);
235 delegate->setRoleMapping(Plasma::Delegate::SubTitleRole, SubTitleRole);
236 @@ -236,7 +236,7 @@
237 view->setItemDelegate(delegate);
238 view->setItemStateProvider(delegate);
239
240 - addView(i18n("Computer"), systemIcon(), model, view);
241 + addView(i18n("Computer"), systemIcon(), systemModel, view);
242 }
243
244 void setupSearchView()
245 @@ -448,6 +448,7 @@
246 ApplicationModel *applicationModel;
247 RecentlyUsedModel *recentlyUsedModel;
248 KRunnerModel *searchModel;
249 + SystemModel *systemModel;
250 LeaveModel *leaveModel;
251 SearchBar *searchBar;
252 QWidget *footer;
253 @@ -807,6 +808,7 @@
254 {
255 Q_UNUSED(event)
256 reset();
257 + d->systemModel->stopRefreshingUsageInfo();
258 }
259
260 void Launcher::keyPressEvent(QKeyEvent *event)
261 @@ -828,6 +830,7 @@
262 void Launcher::showEvent(QShowEvent *e)
263 {
264 d->searchBar->setFocus();
265 + d->systemModel->refreshUsageInfo();
266
267 QWidget::showEvent(e);
268 }