Changeset View
Changeset View
Standalone View
Standalone View
src/imagefoldermodel.cpp
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | 80 | { | |||
---|---|---|---|---|---|
87 | 87 | | |||
88 | QString directoryUrl; | 88 | QString directoryUrl; | ||
89 | 89 | | |||
90 | if( QDir(url).exists()) { | 90 | if( QDir(url).exists()) { | ||
91 | directoryUrl = QUrl::fromLocalFile(url).toString(); | 91 | directoryUrl = QUrl::fromLocalFile(url).toString(); | ||
92 | } else { | 92 | } else { | ||
93 | m_imagePath = url; | 93 | m_imagePath = url; | ||
94 | directoryUrl = QUrl::fromLocalFile(url.left(url.lastIndexOf('/'))).toString(); | 94 | directoryUrl = QUrl::fromLocalFile(url.left(url.lastIndexOf('/'))).toString(); | ||
95 | emit showImageViewer( indexForUrl(m_imagePath)); | | |||
96 | } | 95 | } | ||
97 | 96 | | |||
98 | if (dirLister()->url().path() == directoryUrl) { | 97 | if (dirLister()->url().path() == directoryUrl) { | ||
99 | dirLister()->updateDirectory(QUrl(directoryUrl)); | 98 | dirLister()->updateDirectory(QUrl(directoryUrl)); | ||
100 | return; | 99 | return; | ||
101 | } | 100 | } | ||
102 | 101 | | |||
103 | beginResetModel(); | 102 | beginResetModel(); | ||
104 | dirLister()->openUrl(QUrl(directoryUrl)); | 103 | dirLister()->openUrl(QUrl(directoryUrl)); | ||
105 | endResetModel(); | 104 | endResetModel(); | ||
106 | emit urlChanged(); | 105 | emit urlChanged(); | ||
107 | } | 106 | } | ||
108 | 107 | | |||
109 | int ImageFolderModel::indexForUrl(const QString &url) const | 108 | int ImageFolderModel::indexForUrl(const QString &url) const | ||
110 | { | 109 | { | ||
111 | QModelIndex index = KDirModel::indexForUrl(QUrl(url)); | 110 | QModelIndex index = KDirModel::indexForUrl(QUrl(url)); | ||
112 | return index.row(); | 111 | return index.row(); | ||
113 | } | 112 | } | ||
114 | 113 | | |||
115 | QVariantMap ImageFolderModel::get(int i) const | 114 | QVariantMap ImageFolderModel::get(int i) const | ||
mart: couldn't the qml part just call indexForUrl? i don't like this back and forth of signals, makes… | |||||
116 | { | 115 | { | ||
117 | QModelIndex modelIndex = index(i, 0); | 116 | QModelIndex modelIndex = index(i, 0); | ||
118 | 117 | | |||
119 | KFileItem item = itemForIndex(modelIndex); | 118 | KFileItem item = itemForIndex(modelIndex); | ||
120 | QString url = item.url().toString(); | 119 | QString url = item.url().toString(); | ||
121 | QString mimeType = item.mimetype(); | 120 | QString mimeType = item.mimetype(); | ||
122 | 121 | | |||
123 | QVariantMap ret; | 122 | QVariantMap ret; | ||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |
couldn't the qml part just call indexForUrl? i don't like this back and forth of signals, makes it hard to follow