/usr/include/KF5/KIOFileWidgets/kfileplacesmodel.h is in libkf5kio-dev 5.44.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | /* This file is part of the KDE project
Copyright (C) 2007 Kevin Ottens <ervin@kde.org>
Copyright (C) 2007 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KFILEPLACESMODEL_H
#define KFILEPLACESMODEL_H
#include "kiofilewidgets_export.h"
#include <QtCore/QAbstractItemModel>
#include <QUrl>
#include <kbookmark.h>
#include <solid/device.h>
class QMimeData;
class QAction;
/**
* @class KFilePlacesModel kfileplacesmodel.h <KFilePlacesModel>
*
* This class is a list view model. Each entry represents a "place"
* where user can access files. Only revelant when
* used with QListView or QTableView.
*/
class KIOFILEWIDGETS_EXPORT KFilePlacesModel : public QAbstractItemModel
{
Q_OBJECT
public:
enum AdditionalRoles {
UrlRole = 0x069CD12B,
HiddenRole = 0x0741CAAC,
SetupNeededRole = 0x059A935D,
FixedDeviceRole = 0x332896C1,
CapacityBarRecommendedRole = 0x1548C5C4,
GroupRole = 0x0a5b64ee,
/// @since 5.41
IconNameRole = 0x00a45c00,
GroupHiddenRole = 0x21a4b936
};
/// @since 5.42
enum GroupType {
PlacesType,
RemoteType,
RecentlySavedType,
SearchForType,
DevicesType,
RemovableDevicesType,
UnknownType
};
KFilePlacesModel(QObject *parent = nullptr);
/**
* @brief Construct a new KFilePlacesModel with an alternativeApplicationName
* @param alternativeApplicationName This value will be used to filter bookmarks in addition to the actual application name
* @param parent Parent object
* @since 5.43
* @todo kf6: merge contstructors
*/
KFilePlacesModel(const QString &alternativeApplicationName, QObject *parent = nullptr);
~KFilePlacesModel();
QUrl url(const QModelIndex &index) const;
bool setupNeeded(const QModelIndex &index) const;
QIcon icon(const QModelIndex &index) const;
QString text(const QModelIndex &index) const;
bool isHidden(const QModelIndex &index) const;
/// @since 5.42
bool isGroupHidden(const GroupType type) const;
/// @since 5.42
bool isGroupHidden(const QModelIndex &index) const;
bool isDevice(const QModelIndex &index) const;
Solid::Device deviceForIndex(const QModelIndex &index) const;
KBookmark bookmarkForIndex(const QModelIndex &index) const;
/// @since 5.42
GroupType groupType(const QModelIndex &index) const;
QModelIndexList groupIndexes(const GroupType type) const;
QAction *teardownActionForIndex(const QModelIndex &index) const;
QAction *ejectActionForIndex(const QModelIndex &index) const;
void requestTeardown(const QModelIndex &index);
void requestEject(const QModelIndex &index);
void requestSetup(const QModelIndex &index);
void addPlace(const QString &text, const QUrl &url, const QString &iconName = QString(), const QString &appName = QString());
void addPlace(const QString &text, const QUrl &url, const QString &iconName, const QString &appName, const QModelIndex &after);
void editPlace(const QModelIndex &index, const QString &text, const QUrl &url, const QString &iconName = QString(), const QString &appName = QString());
void removePlace(const QModelIndex &index) const;
void setPlaceHidden(const QModelIndex &index, bool hidden);
/// @since 5.42
void setGroupHidden(const GroupType type, bool hidden);
/**
* @brief Move place at @p itemRow to a position before @p row
* @since 5.41
*/
bool movePlace(int itemRow, int row);
int hiddenCount() const;
/**
* @brief Get a visible data based on Qt role for the given index.
* Return the device information for the give index.
*
* @param index The QModelIndex which contains the row, column to fetch the data.
* @param role The Interview data role(ex: Qt::DisplayRole).
*
* @return the data for the given index and role.
*/
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
/**
* @brief Get the children model index for the given row and column.
*/
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
/**
* @brief Get the parent QModelIndex for the given model child.
*/
QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE;
/**
* @brief Get the number of rows for a model index.
*/
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
/**
* @brief Get the number of columns for a model index.
*/
int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
/**
* Returns the closest item for the URL \a url.
* The closest item is defined as item which is equal to
* the URL or at least is a parent URL. If there are more than
* one possible parent URL candidates, the item which covers
* the bigger range of the URL is returned.
*
* Example: the url is '/home/peter/Documents/Music'.
* Available items are:
* - /home/peter
* - /home/peter/Documents
*
* The returned item will the one for '/home/peter/Documents'.
*/
QModelIndex closestItem(const QUrl &url) const;
Qt::DropActions supportedDropActions() const Q_DECL_OVERRIDE;
Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
QStringList mimeTypes() const Q_DECL_OVERRIDE;
QMimeData *mimeData(const QModelIndexList &indexes) const Q_DECL_OVERRIDE;
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE;
/**
* @brief Reload bookmark information
* @since 5.41
*/
void refresh() const;
/**
* @brief Converts the URL, which contains "virtual" URLs for system-items like
* "timeline:/lastmonth" into a Query-URL "timeline:/2017-10"
* that will be handled by the corresponding IO-slave.
* Virtual URLs for bookmarks are used to be independent from
* internal format changes.
* @param an url
* @return the converted URL, which can be handled by an ioslave
* @since 5.41
*/
static QUrl convertedUrl(const QUrl &url);
/**
* Set the URL schemes that the file widget should allow navigating to.
*
* If the returned list is empty, all schemes are supported. Examples for
* schemes are @c "file" or @c "ftp".
*
* @sa QFileDialog::setSupportedSchemes
* @since 5.43
*/
void setSupportedSchemes(const QStringList &schemes);
/**
* Returns the URL schemes that the file widget should allow navigating to.
*
* If the returned list is empty, all schemes are supported.
*
* @sa QFileDialog::supportedSchemes
* @since 5.43
*/
QStringList supportedSchemes() const;
Q_SIGNALS:
void errorMessage(const QString &message);
void setupDone(const QModelIndex &index, bool success);
void groupHiddenChanged(KFilePlacesModel::GroupType group, bool hidden);
private:
Q_PRIVATE_SLOT(d, void _k_initDeviceList())
Q_PRIVATE_SLOT(d, void _k_deviceAdded(const QString &))
Q_PRIVATE_SLOT(d, void _k_deviceRemoved(const QString &))
Q_PRIVATE_SLOT(d, void _k_itemChanged(const QString &))
Q_PRIVATE_SLOT(d, void _k_reloadBookmarks())
Q_PRIVATE_SLOT(d, void _k_storageSetupDone(Solid::ErrorType, QVariant))
Q_PRIVATE_SLOT(d, void _k_storageTeardownDone(Solid::ErrorType, QVariant))
class Private;
Private *const d;
friend class Private;
};
#endif
|