KIO
kfileplacesmodel.cpp
104 timelineUrl = QUrl(timelinePrefix + timelineDateString(year, month) + QLatin1Char('/') + timelineDateString(year, month, day));
125 const QStringList validSearchPaths = {QStringLiteral("/documents"), QStringLiteral("/images"), QStringLiteral("/audio"), QStringLiteral("/videos")};
151 QObject::connect(tagsLister, &KCoreDirLister::itemsAdded, q, [this](const QUrl &, const KFileItemList &items) {
181 QObject::connect(tagsLister, &KCoreDirLister::itemsDeleted, q, [this](const KFileItemList &items) {
220 void storageSetupDone(Solid::ErrorType error, const QVariant &errorData, Solid::StorageAccess *sender);
221 void storageTeardownDone(const QString &filePath, Solid::ErrorType error, const QVariant &errorData, QObject *sender);
249 const QString file = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/user-places.xbel");
260 // Increase this version number and use the following logic to handle the update process for existing installations.
278 return KFilePlacesItem::createSystemBookmark(d->bookmarkManager, untranslatedLabel, url, iconName, after);
294 const QString desktopFolder = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
301 const QString documentsFolder = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
308 const QString downloadFolder = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
331 const bool isSystemItem = bItem.metaDataItem(QStringLiteral("isSystemItem")) == QLatin1String("true");
334 // Because of b8a4c2223453932202397d812a0c6b30c6186c70 we need to find the system bookmark named Audio Files
339 // Because of 19feef732085b444515da3f6c66f3352bbcb1824 we need to find the system bookmark named Today
343 // Because of 19feef732085b444515da3f6c66f3352bbcb1824 we need to find the system bookmark named Yesterday
347 // Because of 7e1d2fb84546506c91684dd222c2485f0783848f we need to find the system bookmark named This Month
351 // Because of 7e1d2fb84546506c91684dd222c2485f0783848f we need to find the system bookmark named Last Month
365 const bool isSystemItem = bItem.metaDataItem(QStringLiteral("isSystemItem")) == QLatin1String("true");
373 // This variable is used to insert the new bookmarks at the correct place starting after the "Downloads"
374 // bookmark. When the user already has some of the bookmarks set up manually, the createSystemBookmark()
375 // function returns an empty KBookmark so the following entries will be added at the end of the bookmark
386 const QString pictureFolder = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
394 // is called normally on Linux: https://cgit.freedesktop.org/xdg/xdg-user-dirs/tree/user-dirs.defaults
412 // Force bookmarks to be saved. If on open/save dialog and the bookmarks are not saved, QFile::exists
413 // will always return false, which opening/closing all the time the open/save dialog would cause the
419 if (qEnvironmentVariableIsSet("KDE_FULL_SESSION") && KProtocolInfo::isKnownProtocol(QStringLiteral("recentlyused"))
435 // Move The recently used bookmarks below the trash, making it the first element in the Recent group
446 if (d->fileIndexingEnabled && root.metaDataItem(QStringLiteral("withBaloo")) != QLatin1String("true")) {
449 // don't add by default "Modified Today" and "Modified Yesterday" when recentlyused:/ is present
468 QString::fromLatin1("[[[[ StorageVolume.ignored == false AND [ StorageVolume.usage == 'FileSystem' OR StorageVolume.usage == 'Encrypted' ]]"
477 predicate = QLatin1Char('[') + predicate + QLatin1String(" OR PortableMediaPlayer.supportedProtocols == 'mtp']");
480 predicate = QLatin1Char('[') + predicate + QLatin1String(" OR PortableMediaPlayer.supportedProtocols == 'afc']");
590 KFilePlacesModel::DeviceAccessibility KFilePlacesModel::deviceAccessibility(const QModelIndex &index) const
740 || (itemUrl.isParentOf(url) && itemUrl.query() == url.query() && itemUrl.fragment() == url.fragment())) {
760 QObject::connect(notifier, &Solid::DeviceNotifier::deviceAdded, q, [this](const QString &device) {
763 QObject::connect(notifier, &Solid::DeviceNotifier::deviceRemoved, q, [this](const QString &device) {
853 if (it_i + 1 != end_i && (*(it_i + 1))->id() == (*it_c)->id()) { // if the next one matches, it's a remove
911 appName.isEmpty() || ((appName == QCoreApplication::instance()->applicationName()) || (appName == alternativeApplicationName));
928 QObject::connect(item, &KFilePlacesItem::itemChanged, q, [this](const QString &id, const QVector<int> &roles) {
940 QObject::connect(item, &KFilePlacesItem::itemChanged, q, [this](const QString &id, const QVector<int> &roles) {
955 QObject::connect(item, &KFilePlacesItem::itemChanged, q, [this](const QString &id, const QVector<int> &roles) {
967 QObject::connect(item, &KFilePlacesItem::itemChanged, q, [this](const QString &id, const QVector<int> &roles) {
975 std::stable_sort(items.begin(), items.end(), [](KFilePlacesItem *itemA, KFilePlacesItem *itemB) {
1044 return QStringLiteral("application/x-kfileplacesmodel-") + QString::number(reinterpret_cast<qptrdiff>(self));
1082 bool KFilePlacesModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
1144 Q_EMIT errorMessage(i18nc("Placeholder is error message", "Could not add to the Places panel: %1", job->errorString()));
1155 KBookmark bookmark = KFilePlacesItem::createBookmark(d->bookmarkManager, item.text(), url, KIO::iconNameForUrl(url));
1189 void KFilePlacesModel::addPlace(const QString &text, const QUrl &url, const QString &iconName, const QString &appName)
1194 void KFilePlacesModel::addPlace(const QString &text, const QUrl &url, const QString &iconName, const QString &appName, const QModelIndex &after)
1210 void KFilePlacesModel::editPlace(const QModelIndex &index, const QString &text, const QUrl &url, const QString &iconName, const QString &appName)
1313 d->bookmarkManager->root().setMetaDataItem(stateNameForGroupType(type), (hidden ? QStringLiteral("true") : QStringLiteral("false")));
1400 const bool teardownInProgress = deviceAccessibility(index) == KFilePlacesModel::TeardownInProgress;
1471 connect(access, &Solid::StorageAccess::teardownDone, this, [this, access, filePath](Solid::ErrorType error, QVariant errorData) {
1494 connect(drive, &Solid::OpticalDrive::ejectDone, this, [this, filePath, drive](Solid::ErrorType error, QVariant errorData) {
1500 QString label = data(index, Qt::DisplayRole).toString().replace(QLatin1Char('&'), QLatin1String("&&"));
1510 if (device.is<Solid::StorageAccess>() && !d->setupInProgress.contains(device.as<Solid::StorageAccess>())
1516 connect(access, &Solid::StorageAccess::setupDone, this, [this, access](Solid::ErrorType error, QVariant errorData) {
1524 void KFilePlacesModelPrivate::storageSetupDone(Solid::ErrorType error, const QVariant &errorData, Solid::StorageAccess *sender)
1536 Q_EMIT q->errorMessage(i18n("An error occurred while accessing '%1', the system responded: %2", q->text(index), errorData.toString()));
1544 void KFilePlacesModelPrivate::storageTeardownDone(const QString &filePath, Solid::ErrorType error, const QVariant &errorData, QObject *sender)
1553 QObject::connect(listOpenFilesJob, &KIO::Job::result, q, [this, index, error, errorData, listOpenFilesJob]() {
1564 Q_EMIT q->errorMessage(i18n("One or more files on this device are open within an application."));
1567 Q_EMIT q->errorMessage(xi18np("One or more files on this device are opened in application <application>\"%2\"</application>.",
void setIcon(const QString &icon)
Q_INVOKABLE int hiddenCount() const
void deviceRemoved(const QString &udi)
QString readEntry(const char *key, const char *aDefault=nullptr) const
QString icon() const
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const const
bool isParentOf(const QUrl &childUrl) const const
int month() const const
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Get the number of rows for a model index.
@ FixedDeviceRole
Whether the place is a fixed device (neither hotpluggable nor removable).
Definition: kfileplacesmodel.h:58
bool isValid() const const
bool is() const
DecorationRole
Q_INVOKABLE bool isDevice(const QModelIndex &index) const
KBookmark bookmarkForUrl(const QUrl &searchUrl) const
Definition: kfileplacesmodel.cpp:227
static KBookmarkManager * managerForExternalFile(const QString &bookmarksFile)
@ CapacityBarRecommendedRole
Whether the place should have its free space displayed in a capacity bar.
Definition: kfileplacesmodel.h:64
QString number(int n, int base)
void deviceAdded(const QString &udi)
QUrl toUrl() const const
WriteOnly
void setData(const QString &mimeType, const QByteArray &data)
void * internalPointer() const const
void setUrls(const QList< QUrl > &urls)
Q_INVOKABLE QAction * ejectActionForIndex(const QModelIndex &index) const
Q_EMITQ_EMIT
QVariant data(const QModelIndex &index, int role) const override
Get a visible data based on Qt role for the given index.
void result(KJob *job)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Get the children model index for the given row and column.
QString scheme() const const
QVector::iterator begin()
Q_INVOKABLE QIcon icon(const QModelIndex &index) const
singleShot
Q_INVOKABLE QString text(const QModelIndex &index) const
int count(const T &value) const const
T value() const const
void errorMessage(const QString &message)
message An error message explaining what went wrong.
int year() const const
bool isRemovable() const
Definition: kfileitem.h:657
void changed(const QString &groupAddress, const QString &caller)
QIcon fromTheme(const QString &name)
QString metaDataItem(const QString &key) const
QString query(QUrl::ComponentFormattingOptions options) const const
void itemsAdded(const QUrl &directoryUrl, const KFileItemList &items)
Signal that new items were found during directory listing.
QString writableLocation(QStandardPaths::StandardLocation type)
KBookmark first() const
PHONON_EXPORT Notifier * notifier()
QString homePath()
void setUrl(const QUrl &url)
KBookmark bookmarkForIndex(const QModelIndex &index) const
void setupDone(Solid::ErrorType error, QVariant errorData, const QString &udi)
Q_INVOKABLE bool isHidden(const QModelIndex &index) const
bool isValid() const const
bool contains(const T &value) const const
void setSupportedSchemes(const QStringList &schemes)
Set the URL schemes that the file widget should allow navigating to.
bool exists() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Q_INVOKABLE GroupType groupType(const QModelIndex &index) const
bool matches(const QUrl &url, QUrl::FormattingOptions options) const const
QString address() const
void setFullText(const QString &fullText)
void setScheme(const QString &scheme)
@ TeardownOverlayRecommendedRole
roleName is "isTeardownOverlayRecommended".
Definition: kfileplacesmodel.h:101
QStringList types(Mode mode=Writing)
static bool isKnownProtocol(const QUrl &url)
Returns whether a protocol is installed that is able to handle url.
Definition: kprotocolinfo.cpp:445
void reserve(int alloc)
void deleteBookmark(const KBookmark &bk)
bool isValid() const const
bool beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild)
bool eject()
KIOCORE_EXPORT QString iconNameForUrl(const QUrl &url)
Return the icon name for a URL.
Definition: global.cpp:212
QDate addMonths(int nmonths) const const
int size() const const
virtual QHash< int, QByteArray > roleNames() const const
QModelIndex createIndex(int row, int column, void *ptr) const const
QString toString(QUrl::FormattingOptions options) const const
KBookmark next(const KBookmark ¤t) const
typedef ItemFlags
QString i18n(const char *text, const TYPE &arg...)
void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi)
PreferLocalFile
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
Helper class for the kiojob used to list and update a directory.
Definition: kcoredirlister.h:54
void endMoveRows()
int indexOf(const T &value, int from) const const
virtual QMap< int, QVariant > itemData(const QModelIndex &index) const const
bool isEmpty() const const
Q_INVOKABLE void removePlace(const QModelIndex &index) const
Deletes the place with index index from the model.
QModelIndex closestItem(const QUrl &url) const
Returns the closest item for the URL url.
QUrl fromLocalFile(const QString &localFile)
DevIface * as()
Q_INVOKABLE QModelIndexList groupIndexes(const GroupType type) const
QCA_EXPORT QString appName()
int length() const const
QString toDisplayString(QUrl::FormattingOptions options) const const
QCoreApplication * instance()
const T & at(int i) const const
bool isNull() const
int toInt(bool *ok, int base) const const
void groupHiddenChanged(KFilePlacesModel::GroupType group, bool hidden)
Emitted whenever the visibility of the group group changes.
bool isEmpty() const const
@ GroupRole
The name of the group, for example "Remote" or "Devices".
Definition: kfileplacesmodel.h:70
Q_INVOKABLE QUrl url(const QModelIndex &index) const
Q_INVOKABLE void addPlace(const QString &text, const QUrl &url, const QString &iconName=QString(), const QString &appName=QString())
Adds a new place to the model.
Q_INVOKABLE void requestTeardown(const QModelIndex &index)
Unmounts the place at index index by triggering the teardown functionality of its Solid device.
QUrl url() const
Solid::Device deviceForIndex(const QModelIndex &index) const
Q_INVOKABLE bool isTeardownOverlayRecommended(const QModelIndex &index) const
QDate currentDate()
Q_INVOKABLE bool isGroupHidden(const GroupType type) const
static QUrl convertedUrl(const QUrl &url)
Converts the URL, which contains "virtual" URLs for system-items like "timeline:/lastmonth" into a Qu...
QDate addDays(qint64 ndays) const const
static QList< Device > listFromQuery(const Predicate &predicate, const QString &parentUdi=QString())
KSharedConfigPtr config()
applicationName
bool isValid() const const
Q_INVOKABLE void editPlace(const QModelIndex &index, const QString &text, const QUrl &url, const QString &iconName=QString(), const QString &appName=QString())
Edits the place with index index.
Q_INVOKABLE void requestEject(const QModelIndex &index)
Ejects the place at index index by triggering the eject functionality of its Solid device.
void insert(int i, const T &value)
bool toBool() const const
Q_INVOKABLE bool isTeardownAllowed(const QModelIndex &index) const
QString & replace(int position, int n, QChar after)
Q_INVOKABLE void setPlaceHidden(const QModelIndex &index, bool hidden)
Changes the visibility of the place with index index, but only if the place is not inside an hidden g...
int row() const const
int removeAll(const T &t)
static Predicate fromString(const QString &predicate)
QList< QUrl > groupUrlList() const
QString label(StandardShortcut id)
QVector::iterator end()
typedef DropActions
Q_INVOKABLE QAction * teardownActionForIndex(const QModelIndex &index) const
bool moveBookmark(const KBookmark &bookmark, const KBookmark &after)
Device parent() const
Q_INVOKABLE bool isEjectAllowed(const QModelIndex &index) const
GenericDataLocation
QString errorString() const override
Converts an error code and a non-i18n error message into an error message in the current language.
Definition: job_error.cpp:22
QString fragment(QUrl::ComponentFormattingOptions options) const const
Q_INVOKABLE void setGroupHidden(const GroupType type, bool hidden)
Changes the visibility of the group with type type.
QString fullText() const
QList::iterator erase(QList::iterator pos)
void setEnabled(bool)
Q_INVOKABLE bool movePlace(int itemRow, int row)
Move place at itemRow to a position before row.
Q_INVOKABLE void requestSetup(const QModelIndex &index)
Mounts the place at index index by triggering the setup functionality of its Solid device.
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
bool isAccessible() const
Q_INVOKABLE bool setupNeeded(const QModelIndex &index) const
Q_INVOKABLE KFilePlacesModel::DeviceAccessibility deviceAccessibility(const QModelIndex &index) const
QString fromLatin1(const char *str, int size)
QString name(StandardShortcut id)
KIOCORE_EXPORT StatJob * statDetails(const QUrl &url, KIO::StatJob::StatSide side, KIO::StatDetails details=KIO::StatDefaultDetails, JobFlags flags=DefaultFlags)
Find all details for one file or directory.
Definition: statjob.cpp:263
bool isHotpluggable() const
void clear()
QVector::iterator erase(QVector::iterator begin, QVector::iterator end)
Definition: statjob.h:25
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QList::iterator begin()
void teardownDone(Solid::ErrorType error, QVariant errorData, const QString &udi)
KCOREADDONS_EXPORT QList< QUrl > urlsFromMimeData(const QMimeData *mimeData, DecodeOptions decodeOptions=PreferKdeUrls, MetaDataMap *metaData=nullptr)
QHash< int, QByteArray > roleNames() const override
Reimplemented from QAbstractItemModel.
void supportedSchemesChanged()
Emitted whenever the list of supported schemes has been changed.
void setMetaDataItem(const QString &key, const QString &value, MetaDataOverwriteMode mode=OverwriteMetaData)
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Get the number of columns for a model index.
QList::iterator end()
void itemsDeleted(const KFileItemList &items)
Signal that items have been deleted.
Definition: kfileitem.h:35
Definition: kfileplacesmodel.h:35
QObject * parent() const const
void bookmarksChanged(QString groupAddress)
QString message
bool exec()
QString & append(QChar ch)
int access(const QString &path, int mode)
QString toString() const const
int day() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Feb 5 2023 04:00:51 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Feb 5 2023 04:00:51 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.