Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/kfilewidget.cpp
Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Line(s) | 82 | public: | |||
---|---|---|---|---|---|
156 | * Returns the absolute version of the URL specified in locationEdit. | 156 | * Returns the absolute version of the URL specified in locationEdit. | ||
157 | */ | 157 | */ | ||
158 | QUrl getCompleteUrl(const QString &) const; | 158 | QUrl getCompleteUrl(const QString &) const; | ||
159 | 159 | | |||
160 | /** | 160 | /** | ||
161 | * Sets the dummy entry on the history combo box. If the dummy entry | 161 | * Sets the dummy entry on the history combo box. If the dummy entry | ||
162 | * already exists, it is overwritten with this information. | 162 | * already exists, it is overwritten with this information. | ||
163 | */ | 163 | */ | ||
164 | void setDummyHistoryEntry(const QString &text, const QPixmap &icon = QPixmap(), | 164 | void setDummyHistoryEntry(const QString &text, const QIcon &icon = QIcon(), | ||
165 | bool usePreviousPixmapIfNull = true); | 165 | bool usePreviousPixmapIfNull = true); | ||
166 | 166 | | |||
167 | /** | 167 | /** | ||
168 | * Removes the dummy entry of the history combo box. | 168 | * Removes the dummy entry of the history combo box. | ||
169 | */ | 169 | */ | ||
170 | void removeDummyHistoryEntry(); | 170 | void removeDummyHistoryEntry(); | ||
171 | 171 | | |||
172 | /** | 172 | /** | ||
▲ Show 20 Lines • Show All 1028 Lines • ▼ Show 20 Line(s) | 1194 | { | |||
1201 | if (list.isEmpty()) { | 1201 | if (list.isEmpty()) { | ||
1202 | setLocationText(QUrl()); | 1202 | setLocationText(QUrl()); | ||
1203 | return; | 1203 | return; | ||
1204 | } | 1204 | } | ||
1205 | 1205 | | |||
1206 | setLocationText(list.urlList()); | 1206 | setLocationText(list.urlList()); | ||
1207 | } | 1207 | } | ||
1208 | 1208 | | |||
1209 | void KFileWidgetPrivate::setDummyHistoryEntry(const QString &text, const QPixmap &icon, | 1209 | void KFileWidgetPrivate::setDummyHistoryEntry(const QString &text, const QIcon &icon, | ||
1210 | bool usePreviousPixmapIfNull) | 1210 | bool usePreviousPixmapIfNull) | ||
1211 | { | 1211 | { | ||
1212 | // setCurrentItem() will cause textChanged() being emitted, | 1212 | // setCurrentItem() will cause textChanged() being emitted, | ||
1213 | // so slotLocationChanged() will be called. Make sure we don't clear | 1213 | // so slotLocationChanged() will be called. Make sure we don't clear | ||
1214 | // the KDirOperator's view-selection in there | 1214 | // the KDirOperator's view-selection in there | ||
1215 | QObject::disconnect(locationEdit, SIGNAL(editTextChanged(QString)), | 1215 | QObject::disconnect(locationEdit, SIGNAL(editTextChanged(QString)), | ||
1216 | q, SLOT(_k_slotLocationChanged(QString))); | 1216 | q, SLOT(_k_slotLocationChanged(QString))); | ||
1217 | 1217 | | |||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 1259 | { | |||
1275 | 1275 | | |||
1276 | QObject::connect(locationEdit, SIGNAL(editTextChanged(QString)), | 1276 | QObject::connect(locationEdit, SIGNAL(editTextChanged(QString)), | ||
1277 | q, SLOT(_k_slotLocationChanged(QString))); | 1277 | q, SLOT(_k_slotLocationChanged(QString))); | ||
1278 | } | 1278 | } | ||
1279 | 1279 | | |||
1280 | void KFileWidgetPrivate::setLocationText(const QUrl &url) | 1280 | void KFileWidgetPrivate::setLocationText(const QUrl &url) | ||
1281 | { | 1281 | { | ||
1282 | if (!url.isEmpty()) { | 1282 | if (!url.isEmpty()) { | ||
1283 | QPixmap mimeTypeIcon = KIconLoader::global()->loadMimeTypeIcon(KIO::iconNameForUrl(url), KIconLoader::Small); | | |||
1284 | if (!url.isRelative()) { | 1283 | if (!url.isRelative()) { | ||
1285 | const QUrl directory = url.adjusted(QUrl::RemoveFilename); | 1284 | const QUrl directory = url.adjusted(QUrl::RemoveFilename); | ||
1286 | if (!directory.path().isEmpty()) { | 1285 | if (!directory.path().isEmpty()) { | ||
1287 | q->setUrl(directory, false); | 1286 | q->setUrl(directory, false); | ||
1288 | } else { | 1287 | } else { | ||
1289 | q->setUrl(url, false); | 1288 | q->setUrl(url, false); | ||
1290 | } | 1289 | } | ||
1291 | } | 1290 | } | ||
1292 | setDummyHistoryEntry(url.fileName(), mimeTypeIcon); | 1291 | setDummyHistoryEntry(url.fileName(), QIcon::fromTheme(KIO::iconNameForUrl(url))); | ||
1293 | } else { | 1292 | } else { | ||
1294 | removeDummyHistoryEntry(); | 1293 | removeDummyHistoryEntry(); | ||
1295 | } | 1294 | } | ||
1296 | 1295 | | |||
1297 | if (operationMode == KFileWidget::Saving) { | 1296 | if (operationMode == KFileWidget::Saving) { | ||
1298 | setNonExtSelection(); | 1297 | setNonExtSelection(); | ||
1299 | } | 1298 | } | ||
1300 | } | 1299 | } | ||
Show All 19 Lines | 1317 | { | |||
1320 | 1319 | | |||
1321 | if (urlList.count() > 1) { | 1320 | if (urlList.count() > 1) { | ||
1322 | QString urls; | 1321 | QString urls; | ||
1323 | foreach (const QUrl &url, urlList) { | 1322 | foreach (const QUrl &url, urlList) { | ||
1324 | urls += QStringLiteral("\"%1\"").arg(relativePathOrUrl(currUrl, url)) + ' '; | 1323 | urls += QStringLiteral("\"%1\"").arg(relativePathOrUrl(currUrl, url)) + ' '; | ||
1325 | } | 1324 | } | ||
1326 | urls = urls.left(urls.size() - 1); | 1325 | urls = urls.left(urls.size() - 1); | ||
1327 | 1326 | | |||
1328 | setDummyHistoryEntry(urls, QPixmap(), false); | 1327 | setDummyHistoryEntry(urls, QIcon(), false); | ||
1329 | } else if (urlList.count() == 1) { | 1328 | } else if (urlList.count() == 1) { | ||
1330 | const QPixmap mimeTypeIcon = KIconLoader::global()->loadMimeTypeIcon(KIO::iconNameForUrl(urlList[0]), KIconLoader::Small); | 1329 | setDummyHistoryEntry(relativePathOrUrl(currUrl, urlList[0]), QIcon::fromTheme(KIO::iconNameForUrl(urlList[0]))); | ||
1331 | setDummyHistoryEntry(relativePathOrUrl(currUrl, urlList[0]), mimeTypeIcon); | | |||
1332 | } else { | 1330 | } else { | ||
1333 | removeDummyHistoryEntry(); | 1331 | removeDummyHistoryEntry(); | ||
1334 | } | 1332 | } | ||
1335 | 1333 | | |||
1336 | if (operationMode == KFileWidget::Saving) { | 1334 | if (operationMode == KFileWidget::Saving) { | ||
1337 | setNonExtSelection(); | 1335 | setNonExtSelection(); | ||
1338 | } | 1336 | } | ||
1339 | } | 1337 | } | ||
▲ Show 20 Lines • Show All 294 Lines • ▼ Show 20 Line(s) | |||||
1634 | { | 1632 | { | ||
1635 | // qDebug(); | 1633 | // qDebug(); | ||
1636 | 1634 | | |||
1637 | if (match.isEmpty() || locationEdit->currentText().contains('"')) { | 1635 | if (match.isEmpty() || locationEdit->currentText().contains('"')) { | ||
1638 | return; | 1636 | return; | ||
1639 | } | 1637 | } | ||
1640 | 1638 | | |||
1641 | const QUrl url = urlFromString(match); | 1639 | const QUrl url = urlFromString(match); | ||
1642 | const QPixmap pix = KIconLoader::global()->loadMimeTypeIcon(KIO::iconNameForUrl(url), KIconLoader::Small); | 1640 | setDummyHistoryEntry(locationEdit->currentText(), QIcon::fromTheme(KIO::iconNameForUrl(url)), !locationEdit->currentText().isEmpty()); | ||
1643 | setDummyHistoryEntry(locationEdit->currentText(), pix, !locationEdit->currentText().isEmpty()); | | |||
1644 | } | 1641 | } | ||
1645 | 1642 | | |||
1646 | void KFileWidgetPrivate::_k_slotLocationChanged(const QString &text) | 1643 | void KFileWidgetPrivate::_k_slotLocationChanged(const QString &text) | ||
1647 | { | 1644 | { | ||
1648 | // qDebug(); | 1645 | // qDebug(); | ||
1649 | 1646 | | |||
1650 | locationEdit->lineEdit()->setModified(true); | 1647 | locationEdit->lineEdit()->setModified(true); | ||
1651 | 1648 | | |||
▲ Show 20 Lines • Show All 991 Lines • Show Last 20 Lines |