Changeset View
Changeset View
Standalone View
Standalone View
src/widget/KexiStartupFileHandler.cpp
Show All 37 Lines | |||||
38 | #include <KLocalizedString> | 38 | #include <KLocalizedString> | ||
39 | 39 | | |||
40 | #include <QDebug> | 40 | #include <QDebug> | ||
41 | #include <QEvent> | 41 | #include <QEvent> | ||
42 | #include <QAction> | 42 | #include <QAction> | ||
43 | #include <QEventLoop> | 43 | #include <QEventLoop> | ||
44 | #include <QMimeDatabase> | 44 | #include <QMimeDatabase> | ||
45 | #include <QMimeType> | 45 | #include <QMimeType> | ||
46 | #include <QStandardPaths> | ||||
46 | #include <QUrl> | 47 | #include <QUrl> | ||
47 | 48 | | |||
48 | //! @internal | 49 | //! @internal | ||
49 | class Q_DECL_HIDDEN KexiStartupFileHandler::Private | 50 | class Q_DECL_HIDDEN KexiStartupFileHandler::Private | ||
50 | { | 51 | { | ||
51 | public: | 52 | public: | ||
52 | Private() | 53 | Private() | ||
53 | : confirmOverwrites(true) | 54 | : confirmOverwrites(true) | ||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | |||||
116 | //removed in KEXI3 connect(d->dialog, SIGNAL(accepted()), this, SLOT(slotAccepted())); | 117 | //removed in KEXI3 connect(d->dialog, SIGNAL(accepted()), this, SLOT(slotAccepted())); | ||
117 | QUrl url; | 118 | QUrl url; | ||
118 | if (startDirOrVariable.scheme() == "kfiledialog") { | 119 | if (startDirOrVariable.scheme() == "kfiledialog") { | ||
119 | url = KFileWidget::getStartUrl(startDirOrVariable, d->recentDirClass); | 120 | url = KFileWidget::getStartUrl(startDirOrVariable, d->recentDirClass); | ||
120 | } | 121 | } | ||
121 | else { | 122 | else { | ||
122 | url = startDirOrVariable; | 123 | url = startDirOrVariable; | ||
123 | } | 124 | } | ||
125 | if (url.toLocalFile().isEmpty() || !QDir(url.toLocalFile()).exists()) { | ||||
126 | url = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); | ||||
127 | QDir docDir(url.toLocalFile()); | ||||
128 | if (!docDir.exists()) { // create if missing | ||||
129 | (void)docDir.mkpath(QString()); | ||||
130 | } | ||||
131 | } | ||||
124 | d->setUrl(url); | 132 | d->setUrl(url); | ||
125 | setMode(mode); | 133 | setMode(mode); | ||
126 | /*removed in KEXI3 | 134 | /*removed in KEXI3 | ||
127 | QAction *previewAction = d->dialog->actionCollection()->action("preview"); | 135 | QAction *previewAction = d->dialog->actionCollection()->action("preview"); | ||
128 | if (previewAction) | 136 | if (previewAction) | ||
129 | previewAction->setChecked(false);*/ | 137 | previewAction->setChecked(false);*/ | ||
130 | } | 138 | } | ||
131 | 139 | | |||
▲ Show 20 Lines • Show All 316 Lines • ▼ Show 20 Line(s) | |||||
448 | void KexiStartupFileHandler::messageWidgetActionNoTriggered() | 456 | void KexiStartupFileHandler::messageWidgetActionNoTriggered() | ||
449 | { | 457 | { | ||
450 | d->messageWidgetLoop->exit(0); | 458 | d->messageWidgetLoop->exit(0); | ||
451 | } | 459 | } | ||
452 | 460 | | |||
453 | void KexiStartupFileHandler::updateUrl(const QString &name) | 461 | void KexiStartupFileHandler::updateUrl(const QString &name) | ||
454 | { | 462 | { | ||
455 | QUrl url = d->requester->url(); | 463 | QUrl url = d->requester->url(); | ||
464 | QString path = url.toLocalFile(); | ||||
465 | if (!QFileInfo(path).isDir() && !path.endsWith('/')) { | ||||
466 | url = url.adjusted(QUrl::RemoveFilename); | ||||
467 | path = url.toLocalFile(); | ||||
468 | } | ||||
456 | QString fn = KDbUtils::stringToFileName(name); | 469 | QString fn = KDbUtils::stringToFileName(name); | ||
457 | if (!fn.isEmpty() && !fn.endsWith(".kexi")) | 470 | if (!fn.isEmpty() && !fn.endsWith(".kexi")) | ||
458 | fn += ".kexi"; | 471 | fn += ".kexi"; | ||
459 | url = url.adjusted(QUrl::RemoveFilename); | 472 | url.setPath(QDir(path).absoluteFilePath(fn)); | ||
460 | qDebug() << url.toLocalFile(); | | |||
461 | url.setPath(url.toLocalFile() + fn); | | |||
462 | d->requester->setUrl(url); | 473 | d->requester->setUrl(url); | ||
463 | } | 474 | } | ||
464 | 475 | | |||
465 | bool KexiStartupFileHandler::askForOverwriting(const QString& filePath) | 476 | bool KexiStartupFileHandler::askForOverwriting(const QString& filePath) | ||
466 | { | 477 | { | ||
467 | QFileInfo fi(filePath); | 478 | QFileInfo fi(filePath); | ||
468 | if (d->recentFilePathConfirmed == filePath) { | 479 | if (d->recentFilePathConfirmed == filePath) { | ||
469 | return true; | 480 | return true; | ||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |