Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/plugin/recentusagemodel.cpp
Show First 20 Lines • Show All 237 Lines • ▼ Show 20 Line(s) | |||||
238 | QVariant RecentUsageModel::docData(const QString &resource, int role) const | 238 | QVariant RecentUsageModel::docData(const QString &resource, int role) const | ||
239 | { | 239 | { | ||
240 | QUrl url(resource); | 240 | QUrl url(resource); | ||
241 | 241 | | |||
242 | if (url.scheme().isEmpty()) { | 242 | if (url.scheme().isEmpty()) { | ||
243 | url.setScheme(QStringLiteral("file")); | 243 | url.setScheme(QStringLiteral("file")); | ||
244 | } | 244 | } | ||
245 | 245 | | |||
246 | const KFileItem fileItem(url); | 246 | // Do not call QT_LSTAT in KFileItemPrivate::init(). | ||
247 | // The QT_LSTAT doesn't return any useful information | ||||
248 | // for our purposes here. | ||||
249 | const KFileItem fileItem(url, KFileItem::SkipMimeTypeDetermination); | ||||
247 | 250 | | |||
248 | if (!url.isValid() || !(fileItem.isFile() || fileItem.isDir())) { | 251 | if (!url.isValid()) { | ||
dfaure: How do you expect isFile() and isDir() to work without a QT_LSTAT call? | |||||
hoffmannrobert: A document should always be a file, so not needed. | |||||
249 | return QVariant(); | 252 | return QVariant(); | ||
250 | } | 253 | } | ||
251 | 254 | | |||
This looks very much like a workaround. How about adding an argument to the KFileItem to skip the stat if it's a desirable behaviour? apol: This looks very much like a workaround. How about adding an argument to the KFileItem to skip… | |||||
252 | if (role == Qt::DisplayRole) { | 255 | if (role == Qt::DisplayRole) { | ||
253 | return fileItem.text(); | 256 | return fileItem.text(); | ||
254 | } else if (role == Qt::DecorationRole) { | 257 | } else if (role == Qt::DecorationRole) { | ||
255 | return QIcon::fromTheme(fileItem.iconName(), QIcon::fromTheme(QStringLiteral("unknown"))); | 258 | return QIcon::fromTheme(fileItem.iconName(), QIcon::fromTheme(QStringLiteral("unknown"))); | ||
256 | } else if (role == Kicker::GroupRole) { | 259 | } else if (role == Kicker::GroupRole) { | ||
257 | return i18n("Documents"); | 260 | return i18n("Documents"); | ||
258 | } else if (role == Kicker::FavoriteIdRole || role == Kicker::UrlRole) { | 261 | } else if (role == Kicker::FavoriteIdRole || role == Kicker::UrlRole) { | ||
259 | return url.toString(); | 262 | return url.toString(); | ||
260 | } else if (role == Kicker::UrlRole) { | 263 | } else if (role == Kicker::UrlRole) { | ||
261 | return url; | 264 | return url; | ||
262 | } else if (role == Kicker::HasActionListRole) { | 265 | } else if (role == Kicker::HasActionListRole) { | ||
263 | return true; | 266 | return true; | ||
264 | } else if (role == Kicker::ActionListRole) { | 267 | } else if (role == Kicker::ActionListRole) { | ||
apol: url.isLocalFile() | |||||
265 | QVariantList actionList = Kicker::createActionListForFileItem(fileItem); | 268 | QVariantList actionList = Kicker::createActionListForFileItem(fileItem); | ||
266 | 269 | | |||
267 | actionList << Kicker::createSeparatorActionItem(); | 270 | actionList << Kicker::createSeparatorActionItem(); | ||
268 | 271 | | |||
269 | const QVariantMap &forgetAction = Kicker::createActionItem(i18n("Forget Document"), QStringLiteral("forget")); | 272 | const QVariantMap &forgetAction = Kicker::createActionItem(i18n("Forget Document"), QStringLiteral("forget")); | ||
270 | actionList << forgetAction; | 273 | actionList << forgetAction; | ||
271 | 274 | | |||
272 | const QVariantMap &forgetAllAction = Kicker::createActionItem(forgetAllActionName(), QStringLiteral("forgetAll")); | 275 | const QVariantMap &forgetAllAction = Kicker::createActionItem(forgetAllActionName(), QStringLiteral("forgetAll")); | ||
▲ Show 20 Lines • Show All 213 Lines • Show Last 20 Lines |
How do you expect isFile() and isDir() to work without a QT_LSTAT call?