Changeset View
Changeset View
Standalone View
Standalone View
kate/katesavemodifieddialog.cpp
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 73 | KateSaveModifiedDocumentCheckListItem(KTextEditor::Document *document) | |||
---|---|---|---|---|---|
75 | m_document = document; | 75 | m_document = document; | ||
76 | } | 76 | } | ||
77 | ~KateSaveModifiedDocumentCheckListItem() override | 77 | ~KateSaveModifiedDocumentCheckListItem() override | ||
78 | {} | 78 | {} | ||
79 | bool synchronousSave(QWidget *dialogParent) override { | 79 | bool synchronousSave(QWidget *dialogParent) override { | ||
80 | if (m_document->url().isEmpty()) { | 80 | if (m_document->url().isEmpty()) { | ||
81 | const QUrl url = QFileDialog::getSaveFileUrl(dialogParent, i18n("Save As (%1)", m_document->documentName())); | 81 | const QUrl url = QFileDialog::getSaveFileUrl(dialogParent, i18n("Save As (%1)", m_document->documentName())); | ||
82 | if (!url.isEmpty()) { | 82 | if (!url.isEmpty()) { | ||
83 | // check for overwriting a file | | |||
84 | if (url.isLocalFile()) { | | |||
85 | QFileInfo info(url.path()); | | |||
86 | if (info.exists()) { | | |||
87 | if (KMessageBox::Cancel == KMessageBox::warningContinueCancel(dialogParent, | | |||
88 | i18n("A file named \"%1\" already exists. " | | |||
89 | "Are you sure you want to overwrite it?" , info.fileName()), | | |||
90 | i18n("Overwrite File?"), KStandardGuiItem::overwrite(), | | |||
91 | KStandardGuiItem::cancel(), QString(), KMessageBox::Notify | KMessageBox::Dangerous)) { | | |||
92 | setState(SaveFailedState); | | |||
93 | return false; | | |||
94 | } | | |||
95 | } | | |||
96 | } | | |||
97 | | ||||
98 | if (!m_document->saveAs(url)) { | 83 | if (!m_document->saveAs(url)) { | ||
99 | setState(SaveFailedState); | 84 | setState(SaveFailedState); | ||
100 | setText(1, m_document->url().toString()); | 85 | setText(1, m_document->url().toString()); | ||
101 | return false; | 86 | return false; | ||
102 | } else { | 87 | } else { | ||
103 | bool sc = m_document->waitSaveComplete(); | 88 | bool sc = m_document->waitSaveComplete(); | ||
104 | setText(1, m_document->url().toString()); | 89 | setText(1, m_document->url().toString()); | ||
105 | if (!sc) { | 90 | if (!sc) { | ||
▲ Show 20 Lines • Show All 156 Lines • Show Last 20 Lines |