Changeset View
Changeset View
Standalone View
Standalone View
src/kjotswidget.cpp
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
47 | // Akonadi | 47 | // Akonadi | ||
48 | #include <Akonadi/Notes/NoteUtils> | 48 | #include <Akonadi/Notes/NoteUtils> | ||
49 | #include <AkonadiCore/CollectionCreateJob> | 49 | #include <AkonadiCore/CollectionCreateJob> | ||
50 | #include <AkonadiCore/CollectionDeleteJob> | 50 | #include <AkonadiCore/CollectionDeleteJob> | ||
51 | #include <AkonadiCore/ChangeRecorder> | 51 | #include <AkonadiCore/ChangeRecorder> | ||
52 | #include <AkonadiCore/EntityDisplayAttribute> | 52 | #include <AkonadiCore/EntityDisplayAttribute> | ||
53 | #include <AkonadiCore/Item> | 53 | #include <AkonadiCore/Item> | ||
54 | #include <AkonadiCore/ItemCreateJob> | 54 | #include <AkonadiCore/ItemCreateJob> | ||
55 | #include <AkonadiCore/ItemModifyJob> | ||||
55 | #include <AkonadiCore/ItemDeleteJob> | 56 | #include <AkonadiCore/ItemDeleteJob> | ||
56 | #include <AkonadiCore/ItemFetchScope> | 57 | #include <AkonadiCore/ItemFetchScope> | ||
57 | #include <AkonadiCore/EntityOrderProxyModel> | 58 | #include <AkonadiCore/EntityOrderProxyModel> | ||
58 | #include <AkonadiWidgets/ETMViewStateSaver> | 59 | #include <AkonadiWidgets/ETMViewStateSaver> | ||
59 | #include <AkonadiWidgets/ControlGui> | 60 | #include <AkonadiWidgets/ControlGui> | ||
60 | 61 | | |||
61 | // Grantlee | 62 | // Grantlee | ||
62 | #include <grantlee/template.h> | 63 | #include <grantlee/template.h> | ||
▲ Show 20 Lines • Show All 1158 Lines • ▼ Show 20 Line(s) | 1214 | { | |||
1221 | } else if (selection.size() > 1) { | 1222 | } else if (selection.size() > 1) { | ||
1222 | caption = i18nc("@title:window", "Multiple selection"); | 1223 | caption = i18nc("@title:window", "Multiple selection"); | ||
1223 | } | 1224 | } | ||
1224 | Q_EMIT captionChanged(caption); | 1225 | Q_EMIT captionChanged(caption); | ||
1225 | } | 1226 | } | ||
1226 | 1227 | | |||
1227 | bool KJotsWidget::queryClose() | 1228 | bool KJotsWidget::queryClose() | ||
1228 | { | 1229 | { | ||
1230 | // Saving the current note | ||||
1231 | // We cannot use async interface (i.e. ETM) here | ||||
1232 | // because we need to abort the close if something went wrong | ||||
1233 | if ((selProxy->rowCount() == 1) && (editor->document()->isModified())) { | ||||
1234 | QModelIndex idx = selProxy->mapToSource(selProxy->index(0, 0, QModelIndex())); | ||||
1235 | auto job = new ItemModifyJob(KJotsModel::updateItem(idx, editor->document())); | ||||
1236 | if (!job->exec()) { | ||||
1237 | int res = KMessageBox::warningContinueCancelDetailed(this, | ||||
1238 | i18n("Unable to save the note.\n" | ||||
dvratil: I would drop the "Akonadi" from the sentence. Akonadi is an implementation detail, it should… | |||||
1239 | "You can save your note to a local file using the \"File - Export\" menu,\n" | ||||
1240 | "otherwise you will lose your changes!\n" | ||||
1241 | "Do you want to close anyways?"), | ||||
1242 | i18n("Close Document"), | ||||
1243 | KStandardGuiItem::quit(), | ||||
1244 | KStandardGuiItem::cancel(), | ||||
1245 | QString(), | ||||
1246 | KMessageBox::Notify, | ||||
1247 | i18n("Error message:\n" | ||||
dvratil: Same here, remove "Akonadi" from the string. | |||||
1248 | "%1", job->errorString())); | ||||
1249 | if (res == KMessageBox::Cancel) { | ||||
1250 | return false; | ||||
1251 | } | ||||
1252 | } else { | ||||
1253 | // Saved successfully. | ||||
1254 | // However, KJotsEdit will still catch focusOutEvent and try saving using async interface | ||||
1255 | // (application will quit soon, so it doesn't really make much sense doing it) | ||||
1256 | // Marking the document as saved explicitly it order to avoid it | ||||
1257 | editor->document()->setModified(false); | ||||
1258 | } | ||||
1259 | | ||||
1260 | } | ||||
1261 | | ||||
1229 | KJotsSettings::setSplitterSizes(m_splitter->sizes()); | 1262 | KJotsSettings::setSplitterSizes(m_splitter->sizes()); | ||
1230 | KJotsSettings::self()->save(); | 1263 | KJotsSettings::self()->save(); | ||
1231 | m_orderProxy->saveOrder(); | 1264 | m_orderProxy->saveOrder(); | ||
1232 | // TODO: we better wait for a result here! | 1265 | | ||
1233 | editor->savePage(); | | |||
1234 | return true; | 1266 | return true; | ||
1235 | } | 1267 | } | ||
1236 | 1268 | | |||
1237 | void KJotsWidget::actionSortChildrenAlpha() | 1269 | void KJotsWidget::actionSortChildrenAlpha() | ||
1238 | { | 1270 | { | ||
1239 | const QModelIndexList selection = treeview->selectionModel()->selectedRows(); | 1271 | const QModelIndexList selection = treeview->selectionModel()->selectedRows(); | ||
1240 | 1272 | | |||
1241 | for (const QModelIndex &index : selection) { | 1273 | for (const QModelIndex &index : selection) { | ||
Show All 25 Lines |
I would drop the "Akonadi" from the sentence. Akonadi is an implementation detail, it should not be visible anywhere in the UI.