KIO
kfileplacesmodel.cpp
103 timelineUrl = QUrl(timelinePrefix + timelineDateString(year, month) + QLatin1Char('/') + timelineDateString(year, month, day));
123 const QStringList validSearchPaths = {QStringLiteral("/documents"), QStringLiteral("/images"), QStringLiteral("/audio"), QStringLiteral("/videos")};
144 QObject::connect(tagsLister, &KCoreDirLister::itemsAdded, q, [this](const QUrl &, const KFileItemList &items) {
174 QObject::connect(tagsLister, &KCoreDirLister::itemsDeleted, q, [this](const KFileItemList &items) {
192 return QStringLiteral("application/x-kfileplacesmodel-") + QString::number(reinterpret_cast<qptrdiff>(model));
217 const QString file = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/user-places.xbel");
227 // Increase this version number and use the following logic to handle the update process for existing installations.
245 return KFilePlacesItem::createSystemBookmark(d->bookmarkManager, untranslatedLabel, url, iconName, after);
261 const QString desktopFolder = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
268 const QString documentsFolder = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
275 const QString downloadFolder = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
298 const bool isSystemItem = bItem.metaDataItem(QStringLiteral("isSystemItem")) == QLatin1String("true");
301 // Because of b8a4c2223453932202397d812a0c6b30c6186c70 we need to find the system bookmark named Audio Files
306 // Because of 19feef732085b444515da3f6c66f3352bbcb1824 we need to find the system bookmark named Today
310 // Because of 19feef732085b444515da3f6c66f3352bbcb1824 we need to find the system bookmark named Yesterday
314 // Because of 7e1d2fb84546506c91684dd222c2485f0783848f we need to find the system bookmark named This Month
318 // Because of 7e1d2fb84546506c91684dd222c2485f0783848f we need to find the system bookmark named Last Month
332 const bool isSystemItem = bItem.metaDataItem(QStringLiteral("isSystemItem")) == QLatin1String("true");
340 // This variable is used to insert the new bookmarks at the correct place starting after the "Downloads"
341 // bookmark. When the user already has some of the bookmarks set up manually, the createSystemBookmark()
342 // function returns an empty KBookmark so the following entries will be added at the end of the bookmark
353 const QString pictureFolder = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
361 // is called normally on Linux: https://cgit.freedesktop.org/xdg/xdg-user-dirs/tree/user-dirs.defaults
379 // Force bookmarks to be saved. If on open/save dialog and the bookmarks are not saved, QFile::exists
380 // will always return false, which opening/closing all the time the open/save dialog would cause the
386 if (qEnvironmentVariableIsSet("KDE_FULL_SESSION") && KProtocolInfo::isKnownProtocol(QStringLiteral("recentlyused"))
402 // Move The recently used bookmarks below the trash, making it the first element in the Recent group
413 if (d->fileIndexingEnabled && root.metaDataItem(QStringLiteral("withBaloo")) != QLatin1String("true")) {
416 // don't add by default "Modified Today" and "Modified Yesterday" when recentlyused:/ is present
435 QString::fromLatin1("[[[[ StorageVolume.ignored == false AND [ StorageVolume.usage == 'FileSystem' OR StorageVolume.usage == 'Encrypted' ]]"
444 predicate = QLatin1Char('[') + predicate + QLatin1String(" OR PortableMediaPlayer.supportedProtocols == 'mtp']");
447 predicate = QLatin1Char('[') + predicate + QLatin1String(" OR PortableMediaPlayer.supportedProtocols == 'afc']");
549KFilePlacesModel::DeviceAccessibility KFilePlacesModel::deviceAccessibility(const QModelIndex &index) const
719 QObject::connect(notifier, &Solid::DeviceNotifier::deviceAdded, q, [this](const QString &device) {
722 QObject::connect(notifier, &Solid::DeviceNotifier::deviceRemoved, q, [this](const QString &device) {
743 auto it = std::find_if(availableDevices.begin(), availableDevices.end(), [udi](const Solid::Device &device) {
809 if (it_i + 1 != end_i && (*(it_i + 1))->id() == (*it_c)->id()) { // if the next one matches, it's a remove
856 auto it = std::find_if(devices.begin(), devices.end(), [udi, uuid](const Solid::Device &device) {
882 bool allowedHere = appName.isEmpty() || appName == QCoreApplication::instance()->applicationName();
893 QObject::connect(item, &KFilePlacesItem::itemChanged, q, [this](const QString &id, const QList<int> &roles) {
906 KFilePlacesItem *item = new KFilePlacesItem(bookmarkManager, bookmark.address(), device.udi(), q);
907 QObject::connect(item, &KFilePlacesItem::itemChanged, q, [this](const QString &id, const QList<int> &roles) {
919 QObject::connect(item, &KFilePlacesItem::itemChanged, q, [this](const QString &id, const QList<int> &roles) {
927 std::stable_sort(items.begin(), items.end(), [](KFilePlacesItem *itemA, KFilePlacesItem *itemB) {
1029bool KFilePlacesModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
1091 Q_EMIT errorMessage(i18nc("Placeholder is error message", "Could not add to the Places panel: %1", job->errorString()));
1102 KBookmark bookmark = KFilePlacesItem::createBookmark(d->bookmarkManager, item.text(), url, KIO::iconNameForUrl(url));
1141void KFilePlacesModel::addPlace(const QString &text, const QUrl &url, const QString &iconName, const QString &appName, const QModelIndex &after)
1157void KFilePlacesModel::editPlace(const QModelIndex &index, const QString &text, const QUrl &url, const QString &iconName, const QString &appName)
1347 const bool teardownInProgress = deviceAccessibility(index) == KFilePlacesModel::TeardownInProgress;
1418 connect(access, &Solid::StorageAccess::teardownDone, this, [this, access, filePath](Solid::ErrorType error, QVariant errorData) {
1441 connect(drive, &Solid::OpticalDrive::ejectDone, this, [this, filePath, drive](Solid::ErrorType error, QVariant errorData) {
1447 QString label = data(index, Qt::DisplayRole).toString().replace(QLatin1Char('&'), QLatin1String("&&"));
1457 if (device.is<Solid::StorageAccess>() && !d->setupInProgress.contains(device.as<Solid::StorageAccess>())
1463 connect(access, &Solid::StorageAccess::setupDone, this, [this, access](Solid::ErrorType error, QVariant errorData) {
1471void KFilePlacesModelPrivate::storageSetupDone(Solid::ErrorType error, const QVariant &errorData, Solid::StorageAccess *sender)
1483 Q_EMIT q->errorMessage(i18n("An error occurred while accessing '%1', the system responded: %2", q->text(index), errorData.toString()));
1491void KFilePlacesModelPrivate::storageTeardownDone(const QString &filePath, Solid::ErrorType error, const QVariant &errorData, QObject *sender)
1500 QObject::connect(listOpenFilesJob, &KIO::Job::result, q, [this, index, error, errorData, listOpenFilesJob]() {
1511 Q_EMIT q->errorMessage(i18n("One or more files on this device are open within an application."));
1514 Q_EMIT q->errorMessage(xi18np("One or more files on this device are opened in application <application>\"%2\"</application>.",
1515 "One or more files on this device are opened in following applications: <application>%2</application>.",
1546 static const QString path = QStandardPaths::findExecutable(QStringLiteral("partitionmanager"));
1558 // Not using kservice to find partitionmanager because we need to manually invoke it so we can pass the --device argument.
1564 new QAction(QIcon::fromTheme(QStringLiteral("partitionmanager")), i18nc("@action:inmenu", "Reformat or Edit with Partition Manager"), nullptr);
1567 auto job = new KIO::CommandLauncherJob(partitionManagerPath(), {QStringLiteral("--device"), block->device()});
KBookmark next(const KBookmark ¤t) const
KBookmark first() const
void deleteBookmark(const KBookmark &bk)
bool moveBookmark(const KBookmark &bookmark, const KBookmark &after)
QList< QUrl > groupUrlList() const
void changed(const QString &groupAddress)
QString icon() const
void setMetaDataItem(const QString &key, const QString &value, MetaDataOverwriteMode mode=OverwriteMetaData)
bool isNull() const
QString fullText() const
void setUrl(const QUrl &url)
void setFullText(const QString &fullText)
QString address() const
void setIcon(const QString &icon)
QUrl url() const
QString metaDataItem(const QString &key) const
KConfigGroup group(const QString &group)
QString readEntry(const char *key, const char *aDefault=nullptr) const
Helper class for the kiojob used to list and update a directory.
Definition kcoredirlister.h:54
void itemsDeleted(const KFileItemList &items)
Signal that items have been deleted.
@ Reload
Indicates whether to use the cache or to reread the directory from the disk.
Definition kcoredirlister.h:80
void itemsAdded(const QUrl &directoryUrl, const KFileItemList &items)
Signal that new items were found during directory listing.
List of KFileItems, which adds a few helper methods to QList<KFileItem>.
Definition kfileitem.h:632
Q_INVOKABLE bool isDevice(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:508
Q_INVOKABLE QAction * ejectActionForIndex(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:1396
Q_INVOKABLE bool isHidden(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:486
Q_INVOKABLE void requestSetup(const QModelIndex &index)
Mounts the place at index index by triggering the setup functionality of its Solid device.
Definition kfileplacesmodel.cpp:1453
Q_INVOKABLE bool setupNeeded(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:471
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Get the children model index for the given row and column.
Definition kfileplacesmodel.cpp:626
Q_INVOKABLE void removePlace(const QModelIndex &index) const
Deletes the place with index index from the model.
Definition kfileplacesmodel.cpp:1208
Q_INVOKABLE QAction * teardownActionForIndex(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:1334
Q_INVOKABLE QUrl url(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:466
Solid::Device deviceForIndex(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:559
void setSupportedSchemes(const QStringList &schemes)
Set the URL schemes that the file widget should allow navigating to.
Definition kfileplacesmodel.cpp:1530
static QUrl convertedUrl(const QUrl &url)
Converts the URL, which contains "virtual" URLs for system-items like "timeline:/lastmonth" into a Qu...
Definition kfileplacesmodel.cpp:1124
Q_INVOKABLE GroupType groupType(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:584
Q_INVOKABLE bool isGroupHidden(const GroupType type) const
Definition kfileplacesmodel.cpp:492
QVariant data(const QModelIndex &index, int role) const override
Get a visible data based on Qt role for the given index.
Definition kfileplacesmodel.cpp:612
KBookmark bookmarkForUrl(const QUrl &searchUrl) const
Definition kfileplacesmodel.cpp:195
Q_INVOKABLE bool isTeardownOverlayRecommended(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:539
Q_INVOKABLE QIcon icon(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:476
Q_INVOKABLE bool isEjectAllowed(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:529
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Get the number of rows for a model index.
Definition kfileplacesmodel.cpp:665
KBookmark bookmarkForIndex(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:574
Q_INVOKABLE void requestTeardown(const QModelIndex &index)
Unmounts the place at index index by triggering the teardown functionality of its Solid device.
Definition kfileplacesmodel.cpp:1409
Q_INVOKABLE int hiddenCount() const
Definition kfileplacesmodel.cpp:1320
@ GroupRole
The name of the group, for example "Remote" or "Devices".
Definition kfileplacesmodel.h:73
@ TeardownOverlayRecommendedRole
roleName is "isTeardownOverlayRecommended".
Definition kfileplacesmodel.h:104
@ CapacityBarRecommendedRole
Whether the place should have its free space displayed in a capacity bar.
Definition kfileplacesmodel.h:67
@ FixedDeviceRole
Whether the place is a fixed device (neither hotpluggable nor removable).
Definition kfileplacesmodel.h:61
QHash< int, QByteArray > roleNames() const override
Reimplemented from QAbstractItemModel.
Definition kfileplacesmodel.cpp:645
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.
Definition kfileplacesmodel.cpp:1136
void supportedSchemesChanged()
Emitted whenever the list of supported schemes has been changed.
Q_INVOKABLE bool isTeardownAllowed(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:519
Q_INVOKABLE void setGroupHidden(const GroupType type, bool hidden)
Changes the visibility of the group with type type.
Definition kfileplacesmodel.cpp:1254
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Get the number of columns for a model index.
Definition kfileplacesmodel.cpp:674
QModelIndex closestItem(const QUrl &url) const
Returns the closest item for the URL url.
Definition kfileplacesmodel.cpp:681
Q_INVOKABLE QString text(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:481
void groupHiddenChanged(KFilePlacesModel::GroupType group, bool hidden)
Emitted whenever the visibility of the group group changes.
Q_INVOKABLE bool movePlace(int itemRow, int row)
Move place at itemRow to a position before row.
Definition kfileplacesmodel.cpp:1265
Q_INVOKABLE KFilePlacesModel::DeviceAccessibility deviceAccessibility(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:549
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.
Definition kfileplacesmodel.cpp:1157
Q_INVOKABLE void requestEject(const QModelIndex &index)
Ejects the place at index index by triggering the eject functionality of its Solid device.
Definition kfileplacesmodel.cpp:1426
Q_INVOKABLE QModelIndexList groupIndexes(const GroupType type) const
Definition kfileplacesmodel.cpp:594
void errorMessage(const QString &message)
message An error message explaining what went wrong.
Q_INVOKABLE QAction * partitionActionForIndex(const QModelIndex &index) const
Definition kfileplacesmodel.cpp:1551
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...
Definition kfileplacesmodel.cpp:1230
CommandLauncherJob runs a command and watches it while running.
Definition commandlauncherjob.h:45
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:26
A KIO job that retrieves information about a file or directory.
bool exec()
void result(KJob *job)
static bool isKnownProtocol(const QUrl &url)
Returns whether a protocol is installed that is able to handle url.
Definition kprotocolinfo.cpp:321
void deviceRemoved(const QString &udi)
void deviceAdded(const QString &udi)
QString udi() const
Device parent() const
bool is() const
static QList< Device > listFromQuery(const Predicate &predicate, const QString &parentUdi=QString())
DevIface * as()
bool eject()
void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi)
static Predicate fromString(const QString &predicate)
QString filePath() const
bool isAccessible() const
bool teardown()
void teardownDone(Solid::ErrorType error, QVariant errorData, const QString &udi)
bool setup()
void setupDone(Solid::ErrorType error, QVariant errorData, const QString &udi)
bool isHotpluggable() const
bool isRemovable() const
QString xi18np(const char *singular, const char *plural, const TYPE &arg...)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
KIOCORE_EXPORT QString iconNameForUrl(const QUrl &url)
Return the icon name for a URL.
Definition global.cpp:188
KIOCORE_EXPORT StatJob * stat(const QUrl &url, JobFlags flags=DefaultFlags)
Find all details for one file or directory.
Definition statjob.cpp:203
QString path(const QString &relativePath)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
QString name(StandardAction id)
KCOREADDONS_EXPORT QList< QUrl > urlsFromMimeData(const QMimeData *mimeData, DecodeOptions decodeOptions=PreferKdeUrls, MetaDataMap *metaData=nullptr)
QCA_EXPORT QString appName()
bool beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild)
QModelIndex createIndex(int row, int column, const void *ptr) const const
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles)
void endMoveRows()
virtual QMap< int, QVariant > itemData(const QModelIndex &index) const const
virtual QHash< int, QByteArray > roleNames() const const
void setEnabled(bool)
void triggered(bool checked)
applicationName
QCoreApplication * instance()
QDate addDays(qint64 ndays) const const
QDate addMonths(int nmonths) const const
QDate currentDate()
int day() const const
int month() const const
int year() const const
QString homePath()
bool exists() const const
QIcon fromTheme(const QString &name)
WriteOnly
Iterator
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
iterator begin()
void clear()
bool contains(const AT &value) const const
qsizetype count() const const
iterator end()
iterator erase(const_iterator begin, const_iterator end)
iterator insert(const_iterator before, parameter_type value)
bool isEmpty() const const
void reserve(qsizetype size)
void setData(const QString &mimeType, const QByteArray &data)
void setUrls(const QList< QUrl > &urls)
void * internalPointer() const const
bool isValid() const const
int row() const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
bool isValid() const const
GenericDataLocation
QString findExecutable(const QString &executableName, const QStringList &paths)
QString writableLocation(StandardLocation type)
QString arg(Args &&... args) const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
QString fromLatin1(QByteArrayView str)
bool isEmpty() const const
qsizetype length() const const
QString number(double n, char format, int precision)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
int toInt(bool *ok, int base) const const
QString join(QChar separator) const const
qsizetype removeDuplicates()
typedef DropActions
DecorationRole
typedef ItemFlags
singleShot
PreferLocalFile
QString fragment(ComponentFormattingOptions options) const const
QUrl fromLocalFile(const QString &localFile)
bool isParentOf(const QUrl &childUrl) const const
bool isValid() const const
bool matches(const QUrl &url, FormattingOptions options) const const
QString query(ComponentFormattingOptions options) const const
QString scheme() const const
void setScheme(const QString &scheme)
QString toDisplayString(FormattingOptions options) const const
QString toString(FormattingOptions options) const const
void * data()
bool isValid() const const
bool toBool() const const
QString toString() const const
QUrl toUrl() const const
T value() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.