Changeset View
Changeset View
Standalone View
Standalone View
src/kexiutils/utils.cpp
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | |||||
58 | #include <QDebug> | 58 | #include <QDebug> | ||
59 | #include <QFileDialog> | 59 | #include <QFileDialog> | ||
60 | #include <QDesktopServices> | 60 | #include <QDesktopServices> | ||
61 | #include <QStyleHints> | 61 | #include <QStyleHints> | ||
62 | #include <QLineEdit> | 62 | #include <QLineEdit> | ||
63 | #include <QProcess> | 63 | #include <QProcess> | ||
64 | 64 | | |||
65 | #ifndef KEXI_MOBILE | 65 | #ifndef KEXI_MOBILE | ||
66 | #include <kio_version.h> | 66 | #include <KFileWidget> | ||
67 | #include <KRecentDirs> | ||||
67 | #include <KRun> | 68 | #include <KRun> | ||
68 | #include <KToolInvocation> | 69 | #include <KToolInvocation> | ||
70 | #include <kio_version.h> | ||||
69 | #endif | 71 | #endif | ||
70 | #include <KAboutData> | 72 | #include <KAboutData> | ||
71 | #include <KColorScheme> | 73 | #include <KColorScheme> | ||
72 | #include <KConfigGroup> | 74 | #include <KConfigGroup> | ||
73 | #include <KFileWidget> | | |||
74 | #include <KIconEffect> | 75 | #include <KIconEffect> | ||
75 | #include <KLocalizedString> | 76 | #include <KLocalizedString> | ||
76 | #include <KRecentDirs> | | |||
77 | 77 | | |||
78 | #if HAVE_LANGINFO_H | 78 | #if HAVE_LANGINFO_H | ||
79 | #include <langinfo.h> | 79 | #include <langinfo.h> | ||
80 | #endif | 80 | #endif | ||
81 | 81 | | |||
82 | #ifdef Q_OS_WIN | 82 | #ifdef Q_OS_WIN | ||
83 | #include <windows.h> | 83 | #include <windows.h> | ||
84 | 84 | | |||
▲ Show 20 Lines • Show All 236 Lines • ▼ Show 20 Line(s) | 317 | { | |||
321 | dialog->setAcceptMode(QFileDialog::AcceptSave); | 321 | dialog->setAcceptMode(QFileDialog::AcceptSave); | ||
322 | if (QDialog::Accepted == dialog->exec()) { | 322 | if (QDialog::Accepted == dialog->exec()) { | ||
323 | return dialog->selectedUrls().value(0); | 323 | return dialog->selectedUrls().value(0); | ||
324 | } else { | 324 | } else { | ||
325 | return QUrl(); | 325 | return QUrl(); | ||
326 | } | 326 | } | ||
327 | } | 327 | } | ||
328 | 328 | | |||
329 | #ifndef KEXI_MOBILE | ||||
329 | QUrl KexiUtils::getStartUrl(const QUrl &startDirOrVariable, QString *recentDirClass) | 330 | QUrl KexiUtils::getStartUrl(const QUrl &startDirOrVariable, QString *recentDirClass) | ||
330 | { | 331 | { | ||
331 | QUrl result; | 332 | QUrl result; | ||
332 | if (recentDirClass) { | 333 | if (recentDirClass) { | ||
333 | result = KFileWidget::getStartUrl(startDirOrVariable, *recentDirClass); | 334 | result = KFileWidget::getStartUrl(startDirOrVariable, *recentDirClass); | ||
334 | // Fix bug introduced by Kexi 3.0.x in KexiFileWidget: remove file protocol from path | 335 | // Fix bug introduced by Kexi 3.0.x in KexiFileWidget: remove file protocol from path | ||
335 | // (the KRecentDirs::add(.., dir.url()) call was invalid because of prepended protocol) | 336 | // (the KRecentDirs::add(.., dir.url()) call was invalid because of prepended protocol) | ||
336 | const QString protocol("file:/"); | 337 | const QString protocol("file:/"); | ||
337 | if (result.path().startsWith(protocol) && !result.path().startsWith(protocol + '/')) { | 338 | if (result.path().startsWith(protocol) && !result.path().startsWith(protocol + '/')) { | ||
338 | result.setPath(result.path().mid(protocol.length() - 1)); | 339 | result.setPath(result.path().mid(protocol.length() - 1)); | ||
339 | } | 340 | } | ||
340 | } else { | 341 | } else { | ||
341 | qWarning() << "Missing recentDirClass"; | 342 | qWarning() << "Missing recentDirClass"; | ||
342 | } | 343 | } | ||
343 | return result; | 344 | return result; | ||
344 | } | 345 | } | ||
345 | 346 | | |||
346 | void KexiUtils::addRecentDir(const QString &fileClass, const QString &directory) | 347 | void KexiUtils::addRecentDir(const QString &fileClass, const QString &directory) | ||
347 | { | 348 | { | ||
348 | KRecentDirs::add(fileClass, directory); | 349 | KRecentDirs::add(fileClass, directory); | ||
349 | } | 350 | } | ||
351 | #endif | ||||
350 | 352 | | |||
351 | bool KexiUtils::askForFileOverwriting(const QString& filePath, QWidget *parent) | 353 | bool KexiUtils::askForFileOverwriting(const QString& filePath, QWidget *parent) | ||
352 | { | 354 | { | ||
353 | QFileInfo fi(filePath); | 355 | QFileInfo fi(filePath); | ||
354 | if (!fi.exists()) { | 356 | if (!fi.exists()) { | ||
355 | return true; | 357 | return true; | ||
356 | } | 358 | } | ||
357 | const KMessageBox::ButtonCode res = KMessageBox::warningYesNo(parent, | 359 | const KMessageBox::ButtonCode res = KMessageBox::warningYesNo(parent, | ||
▲ Show 20 Lines • Show All 379 Lines • ▼ Show 20 Line(s) | 738 | { | |||
737 | if (m_enabled && watched == parent() && event->type() == QEvent::Paint) { | 739 | if (m_enabled && watched == parent() && event->type() == QEvent::Paint) { | ||
738 | return true; | 740 | return true; | ||
739 | } | 741 | } | ||
740 | return false; | 742 | return false; | ||
741 | } | 743 | } | ||
742 | 744 | | |||
743 | tristate KexiUtils::openHyperLink(const QUrl &url, QWidget *parent, const OpenHyperlinkOptions &options) | 745 | tristate KexiUtils::openHyperLink(const QUrl &url, QWidget *parent, const OpenHyperlinkOptions &options) | ||
744 | { | 746 | { | ||
745 | #ifndef KEXI_MOBILE | 747 | #ifdef KEXI_MOBILE | ||
748 | //! @todo | ||||
749 | Q_UNUSED(url) | ||||
750 | Q_UNUSED(parent) | ||||
751 | Q_UNUSED(options) | ||||
752 | #else | ||||
746 | if (url.isLocalFile()) { | 753 | if (url.isLocalFile()) { | ||
747 | QFileInfo fileInfo(url.toLocalFile()); | 754 | QFileInfo fileInfo(url.toLocalFile()); | ||
748 | if (!fileInfo.exists()) { | 755 | if (!fileInfo.exists()) { | ||
749 | KMessageBox::sorry(parent, xi18nc("@info", "The file or directory <filename>%1</filename> does not exist.", fileInfo.absoluteFilePath())); | 756 | KMessageBox::sorry(parent, xi18nc("@info", "The file or directory <filename>%1</filename> does not exist.", fileInfo.absoluteFilePath())); | ||
750 | return false; | 757 | return false; | ||
751 | } | 758 | } | ||
752 | } | 759 | } | ||
753 | 760 | | |||
▲ Show 20 Lines • Show All 446 Lines • Show Last 20 Lines |