Changeset View
Changeset View
Standalone View
Standalone View
src/panels/places/placesitemmodel.cpp
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | |||||
64 | } | 64 | } | ||
65 | 65 | | |||
66 | PlacesItemModel::~PlacesItemModel() | 66 | PlacesItemModel::~PlacesItemModel() | ||
67 | { | 67 | { | ||
68 | } | 68 | } | ||
69 | 69 | | |||
70 | void PlacesItemModel::createPlacesItem(const QString &text, const QUrl &url, const QString &iconName, const QString &appName) | 70 | void PlacesItemModel::createPlacesItem(const QString &text, const QUrl &url, const QString &iconName, const QString &appName) | ||
71 | { | 71 | { | ||
72 | createPlacesItem(text, url, iconName, appName, -1); | 72 | m_sourceModel->addPlace(text, url, iconName, appName); | ||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | void PlacesItemModel::createPlacesItem(const QString &text, const QUrl &url, const QString &iconName, const QString &appName, int after) | 75 | void PlacesItemModel::createPlacesItem(const QString &text, const QUrl &url, const QString &iconName, const QString &appName, int after) | ||
76 | { | 76 | { | ||
77 | m_sourceModel->addPlace(text, url, iconName, appName, mapToSource(after)); | 77 | m_sourceModel->addPlace(text, url, iconName, appName, mapToSource(after)); | ||
78 | } | 78 | } | ||
79 | 79 | | |||
80 | PlacesItem* PlacesItemModel::placesItem(int index) const | 80 | PlacesItem* PlacesItemModel::placesItem(int index) const | ||
▲ Show 20 Lines • Show All 276 Lines • ▼ Show 20 Line(s) | 356 | if (text.isEmpty()) { | |||
357 | text = url.host(); | 357 | text = url.host(); | ||
358 | } | 358 | } | ||
359 | 359 | | |||
360 | if ((url.isLocalFile() && !QFileInfo(url.toLocalFile()).isDir()) | 360 | if ((url.isLocalFile() && !QFileInfo(url.toLocalFile()).isDir()) | ||
361 | || url.scheme() == QLatin1String("trash")) { | 361 | || url.scheme() == QLatin1String("trash")) { | ||
362 | // Only directories outside the trash are allowed | 362 | // Only directories outside the trash are allowed | ||
363 | continue; | 363 | continue; | ||
364 | } | 364 | } | ||
365 | 365 | if (index < 0) { | |||
366 | createPlacesItem(text, url, KIO::iconNameForUrl(url), {}, qMax(0, index - 1)); | 366 | createPlacesItem(text, url, KIO::iconNameForUrl(url), {}); | ||
367 | } else { | ||||
368 | createPlacesItem(text, url, KIO::iconNameForUrl(url), {}, qMax(-1, index - 1)); | ||||
369 | } | ||||
367 | } | 370 | } | ||
368 | } | 371 | } | ||
369 | // will save bookmark alteration and fix sort if that is broken by the drag/drop operation | 372 | // will save bookmark alteration and fix sort if that is broken by the drag/drop operation | ||
370 | refresh(); | 373 | refresh(); | ||
371 | } | 374 | } | ||
372 | 375 | | |||
373 | void PlacesItemModel::addItemFromSourceModel(const QModelIndex &index) | 376 | void PlacesItemModel::addItemFromSourceModel(const QModelIndex &index) | ||
374 | { | 377 | { | ||
▲ Show 20 Lines • Show All 420 Lines • Show Last 20 Lines |