19 #include <QStringList> 33 for (QList<UrlItem*>::iterator it =
schemeItems_.begin();
43 if (index.isValid()) {
64 if (index.isValid()) {
81 QStringList urlParts = url.split(
"://");
83 if (urlParts.count() > 1) {
84 QString prefix = urlParts[0];
86 for (QList<UrlScheme*>::const_iterator it =
schemes_.begin();
91 QStringList hostPathParts = urlParts[1].split(
"/");
94 if (hostPathParts.count() > 1) {
95 host = hostPathParts[0];
96 hostPathParts.removeFirst();
97 path = hostPathParts.join(
"/");
111 if (index.isValid()) {
131 connect(scheme, SIGNAL(pathLoaded(
const QString&,
const QString&)),
136 if (parent.column() <= 0) {
137 if (parent.isValid()) {
138 UrlItem* parentItem =
static_cast<UrlItem*
>(parent.internalPointer());
167 if (index.isValid()) {
172 if ((role == Qt::DisplayRole) || (role == Qt::EditRole))
186 if (hasIndex(row, column, parent)) {
187 if (parent.isValid()) {
188 UrlItem* parentItem =
static_cast<UrlItem*
>(parent.internalPointer());
211 return createIndex(row, column, childItem);
217 return QModelIndex();
221 if (index.isValid()) {
222 UrlItem* childItem =
static_cast<UrlItem*
>(index.internalPointer());
228 return createIndex(parentItem->
getRow(), 0, parentItem);
232 return QModelIndex();
259 QString url = scheme->
getPrefix()+
"://"+host;
void urlLoaded(const QString &url)
void schemeResetFinished()
QModelIndex index(int row, int column, const QModelIndex &parent) const
UrlItem * getParent() const
QList< UrlItem * > schemeItems_
virtual size_t getNumHosts() const =0
UrlItemModel(QObject *parent=0)
UrlScheme * getScheme() const
virtual QVariant getPathData(const QModelIndex &index, int role) const =0
const QString & getPrefix() const
virtual QModelIndex getHostIndex(size_t row) const =0
QString getFilePath(const QModelIndex &index) const
const QModelIndex & getIndex() const
QString getUrl(const QModelIndex &index) const
UrlScheme * getScheme(const QModelIndex &index) const
QList< UrlScheme * > schemes_
int rowCount(const QModelIndex &parent) const
UrlItem * addChild(size_t row, Type type, const QModelIndex &index)
virtual QString getPath(const QModelIndex &hostIndex, const QModelIndex &pathIndex) const =0
void schemePathLoaded(const QString &host, const QString &path)
virtual size_t getNumPaths(const QModelIndex &hostIndex, const QModelIndex &parent=QModelIndex()) const =0
virtual QVariant getHostData(const QModelIndex &index, int role) const =0
int columnCount(const QModelIndex &parent) const
virtual QModelIndex getPathIndex(const QModelIndex &hostIndex, size_t row, const QModelIndex &parent=QModelIndex()) const =0
virtual QString getFilePath(const QModelIndex &hostIndex, const QModelIndex &pathIndex) const =0
void addScheme(UrlScheme *scheme)
QVariant data(const QModelIndex &index, int role) const
virtual QString getHost(const QModelIndex &hostIndex) const =0
QModelIndex parent(const QModelIndex &index) const
void schemeResetStarted()