Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/plugins/sql/sqlstorage.cpp
Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Line(s) | 120 | { | |||
---|---|---|---|---|---|
121 | return saveDatabase(url); | 121 | return saveDatabase(url); | ||
122 | } | 122 | } | ||
123 | 123 | | |||
124 | QString SQLStorage::formatName() const | 124 | QString SQLStorage::formatName() const | ||
125 | { | 125 | { | ||
126 | return QStringLiteral("SQL"); | 126 | return QStringLiteral("SQL"); | ||
127 | } | 127 | } | ||
128 | 128 | | |||
129 | QString SQLStorage::fileExtension() const | ||||
130 | { | ||||
131 | return QString(); | ||||
132 | } | ||||
133 | | ||||
129 | void SQLStorage::createActions() | 134 | void SQLStorage::createActions() | ||
130 | { | 135 | { | ||
131 | m_openDBaction = actionCollection()->addAction("open_database"); | 136 | m_openDBaction = actionCollection()->addAction("open_database"); | ||
132 | m_openDBaction->setText(i18n("Open database...")); | 137 | m_openDBaction->setText(i18n("Open database...")); | ||
133 | m_openDBaction->setIcon(Icons::get(Icon::SVNUpdate)); | 138 | m_openDBaction->setIcon(Icons::get(Icon::SVNUpdate)); | ||
134 | connect(m_openDBaction, &QAction::triggered, this, &SQLStorage::slotOpenDatabase); | 139 | connect(m_openDBaction, &QAction::triggered, this, &SQLStorage::slotOpenDatabase); | ||
135 | 140 | | |||
136 | m_saveAsDBaction = actionCollection()->addAction("saveas_database"); | 141 | m_saveAsDBaction = actionCollection()->addAction("saveas_database"); | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 152 | { | |||
196 | delete dialog; | 201 | delete dialog; | ||
197 | } | 202 | } | ||
198 | 203 | | |||
199 | void SQLStorage::slotSaveAsDatabase() | 204 | void SQLStorage::slotSaveAsDatabase() | ||
200 | { | 205 | { | ||
201 | bool rc = false; | 206 | bool rc = false; | ||
202 | QUrl oldUrl; | 207 | QUrl oldUrl; | ||
203 | // in event of it being a database, ensure that all data is read into storage for saveas | 208 | // in event of it being a database, ensure that all data is read into storage for saveas | ||
204 | if (viewInterface()->isDatabase()) | 209 | if (appInterface()->isDatabase()) | ||
205 | oldUrl = appInterface()->filenameURL().isEmpty() ? appInterface()->lastOpenedURL() : appInterface()->filenameURL(); | 210 | oldUrl = appInterface()->filenameURL().isEmpty() ? appInterface()->lastOpenedURL() : appInterface()->filenameURL(); | ||
206 | 211 | | |||
207 | QPointer<KSelectDatabaseDlg> dialog = new KSelectDatabaseDlg(QIODevice::WriteOnly); | 212 | QPointer<KSelectDatabaseDlg> dialog = new KSelectDatabaseDlg(QIODevice::WriteOnly); | ||
208 | QUrl url = oldUrl; | 213 | QUrl url = oldUrl; | ||
209 | if (!dialog->checkDrivers()) { | 214 | if (!dialog->checkDrivers()) { | ||
210 | delete dialog; | 215 | delete dialog; | ||
211 | return; | 216 | return; | ||
212 | } | 217 | } | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 283 | i18n("Cannot open or create database %1.\n" | |||
280 | " for further info.", url.toDisplayString()), writer->lastError()); | 285 | " for further info.", url.toDisplayString()), writer->lastError()); | ||
281 | return false; | 286 | return false; | ||
282 | } | 287 | } | ||
283 | } | 288 | } | ||
284 | 289 | | |||
285 | bool SQLStorage::saveDatabase(const QUrl &url) | 290 | bool SQLStorage::saveDatabase(const QUrl &url) | ||
286 | { | 291 | { | ||
287 | auto rc = false; | 292 | auto rc = false; | ||
288 | if (!viewInterface()->fileOpen()) { | 293 | if (!appInterface()->fileOpen()) { | ||
289 | KMessageBox::error(nullptr, i18n("Tried to access a file when it has not been opened")); | 294 | KMessageBox::error(nullptr, i18n("Tried to access a file when it has not been opened")); | ||
290 | return (rc); | 295 | return (rc); | ||
291 | } | 296 | } | ||
292 | auto writer = new MyMoneyStorageSql(MyMoneyFile::instance()->storage(), url); | 297 | auto writer = new MyMoneyStorageSql(MyMoneyFile::instance()->storage(), url); | ||
293 | writer->open(url, QIODevice::WriteOnly); | 298 | writer->open(url, QIODevice::WriteOnly); | ||
294 | // writer->setProgressCallback(&KMyMoneyView::progressCallback); | 299 | // writer->setProgressCallback(&KMyMoneyView::progressCallback); | ||
295 | if (!writer->writeFile()) { | 300 | if (!writer->writeFile()) { | ||
296 | KMessageBox::detailedError(nullptr, | 301 | KMessageBox::detailedError(nullptr, | ||
Show All 16 Lines |