Changeset View
Changeset View
Standalone View
Standalone View
src/document/katedocument.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 214 | { | |||
---|---|---|---|---|---|
258 | 258 | | |||
259 | /** | 259 | /** | ||
260 | * singleshot timer to handle updates of mod on hd state delayed | 260 | * singleshot timer to handle updates of mod on hd state delayed | ||
261 | */ | 261 | */ | ||
262 | m_modOnHdTimer.setSingleShot(true); | 262 | m_modOnHdTimer.setSingleShot(true); | ||
263 | m_modOnHdTimer.setInterval(200); | 263 | m_modOnHdTimer.setInterval(200); | ||
264 | connect(&m_modOnHdTimer, SIGNAL(timeout()), this, SLOT(slotDelayedHandleModOnHd())); | 264 | connect(&m_modOnHdTimer, SIGNAL(timeout()), this, SLOT(slotDelayedHandleModOnHd())); | ||
265 | 265 | | |||
266 | // Prepare some reload amok protector, no connect | ||||
267 | m_autoReloadThrottle.setSingleShot(true); | ||||
268 | m_autoReloadThrottle.setInterval(1000); | ||||
269 | | ||||
266 | /** | 270 | /** | ||
267 | * load handling | 271 | * load handling | ||
268 | * this is needed to ensure we signal the user if a file ist still loading | 272 | * this is needed to ensure we signal the user if a file ist still loading | ||
269 | * and to disallow him to edit in that time | 273 | * and to disallow him to edit in that time | ||
270 | */ | 274 | */ | ||
271 | connect(this, SIGNAL(started(KIO::Job*)), this, SLOT(slotStarted(KIO::Job*))); | 275 | connect(this, SIGNAL(started(KIO::Job*)), this, SLOT(slotStarted(KIO::Job*))); | ||
272 | connect(this, SIGNAL(completed()), this, SLOT(slotCompleted())); | 276 | connect(this, SIGNAL(completed()), this, SLOT(slotCompleted())); | ||
273 | connect(this, SIGNAL(canceled(QString)), this, SLOT(slotCanceled())); | 277 | connect(this, SIGNAL(canceled(QString)), this, SLOT(slotCanceled())); | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | |||||
4160 | } | 4164 | } | ||
4161 | 4165 | | |||
4162 | void KTextEditor::DocumentPrivate::slotModifiedOnDisk(KTextEditor::View * /*v*/) | 4166 | void KTextEditor::DocumentPrivate::slotModifiedOnDisk(KTextEditor::View * /*v*/) | ||
4163 | { | 4167 | { | ||
4164 | if (url().isEmpty() || !m_modOnHd) { | 4168 | if (url().isEmpty() || !m_modOnHd) { | ||
4165 | return; | 4169 | return; | ||
4166 | } | 4170 | } | ||
4167 | 4171 | | |||
4172 | if (!isModified() && m_autoReloadMode) { | ||||
4173 | onModOnHdAutoReload(); | ||||
4174 | return; | ||||
4175 | } | ||||
4176 | | ||||
4168 | if (!m_fileChangedDialogsActivated || m_modOnHdHandler) { | 4177 | if (!m_fileChangedDialogsActivated || m_modOnHdHandler) { | ||
4169 | return; | 4178 | return; | ||
4170 | } | 4179 | } | ||
4171 | 4180 | | |||
4172 | // don't ask the user again and again the same thing | 4181 | // don't ask the user again and again the same thing | ||
4173 | if (m_modOnHdReason == m_prevModOnHdReason) { | 4182 | if (m_modOnHdReason == m_prevModOnHdReason) { | ||
4174 | return; | 4183 | return; | ||
4175 | } | 4184 | } | ||
4176 | m_prevModOnHdReason = m_modOnHdReason; | 4185 | m_prevModOnHdReason = m_modOnHdReason; | ||
4177 | 4186 | | |||
4178 | m_modOnHdHandler = new KateModOnHdPrompt(this, m_modOnHdReason, reasonedMOHString()); | 4187 | m_modOnHdHandler = new KateModOnHdPrompt(this, m_modOnHdReason, reasonedMOHString()); | ||
4179 | connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::saveAsTriggered, this, &DocumentPrivate::onModOnHdSaveAs); | 4188 | connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::saveAsTriggered, this, &DocumentPrivate::onModOnHdSaveAs); | ||
4180 | connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::reloadTriggered, this, &DocumentPrivate::onModOnHdReload); | 4189 | connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::reloadTriggered, this, &DocumentPrivate::onModOnHdReload); | ||
4190 | connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::autoReloadTriggered, this, &DocumentPrivate::onModOnHdAutoReload); | ||||
4181 | connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::ignoreTriggered, this, &DocumentPrivate::onModOnHdIgnore); | 4191 | connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::ignoreTriggered, this, &DocumentPrivate::onModOnHdIgnore); | ||
4182 | } | 4192 | } | ||
4183 | 4193 | | |||
4184 | void KTextEditor::DocumentPrivate::onModOnHdSaveAs() | 4194 | void KTextEditor::DocumentPrivate::onModOnHdSaveAs() | ||
4185 | { | 4195 | { | ||
4186 | m_modOnHd = false; | 4196 | m_modOnHd = false; | ||
4187 | QWidget *parentWidget(dialogParent()); | 4197 | QWidget *parentWidget(dialogParent()); | ||
4188 | const QUrl res = QFileDialog::getSaveFileUrl(parentWidget, i18n("Save File"), url(), {}, nullptr, | 4198 | const QUrl res = QFileDialog::getSaveFileUrl(parentWidget, i18n("Save File"), url(), {}, nullptr, | ||
Show All 16 Lines | |||||
4205 | { | 4215 | { | ||
4206 | m_modOnHd = false; | 4216 | m_modOnHd = false; | ||
4207 | m_prevModOnHdReason = OnDiskUnmodified; | 4217 | m_prevModOnHdReason = OnDiskUnmodified; | ||
4208 | emit modifiedOnDisk(this, false, OnDiskUnmodified); | 4218 | emit modifiedOnDisk(this, false, OnDiskUnmodified); | ||
4209 | documentReload(); | 4219 | documentReload(); | ||
4210 | delete m_modOnHdHandler; | 4220 | delete m_modOnHdHandler; | ||
4211 | } | 4221 | } | ||
4212 | 4222 | | |||
4223 | void KTextEditor::DocumentPrivate::onModOnHdAutoReload() | ||||
4224 | { | ||||
4225 | if (m_modOnHdHandler) { | ||||
4226 | delete m_modOnHdHandler; | ||||
4227 | m_autoReloadMode = true; | ||||
4228 | } | ||||
4229 | | ||||
4230 | if (!m_reloading && !m_autoReloadThrottle.isActive()) { | ||||
4231 | m_modOnHd = false; | ||||
4232 | m_prevModOnHdReason = OnDiskUnmodified; | ||||
4233 | emit modifiedOnDisk(this, false, OnDiskUnmodified); | ||||
4234 | documentReload(); | ||||
4235 | m_autoReloadThrottle.start(); | ||||
4236 | } else { | ||||
4237 | // Don't drop some triggered hint completely | ||||
4238 | QTimer::singleShot(m_autoReloadThrottle.remainingTime(), this, &DocumentPrivate::onModOnHdAutoReload); | ||||
4239 | } | ||||
4240 | } | ||||
4241 | | ||||
4213 | void KTextEditor::DocumentPrivate::onModOnHdIgnore() | 4242 | void KTextEditor::DocumentPrivate::onModOnHdIgnore() | ||
4214 | { | 4243 | { | ||
4215 | // ignore as long as m_prevModOnHdReason == m_modOnHdReason | 4244 | // ignore as long as m_prevModOnHdReason == m_modOnHdReason | ||
4216 | delete m_modOnHdHandler; | 4245 | delete m_modOnHdHandler; | ||
4217 | } | 4246 | } | ||
4218 | 4247 | | |||
4219 | void KTextEditor::DocumentPrivate::setModifiedOnDisk(ModifiedOnDiskReason reason) | 4248 | void KTextEditor::DocumentPrivate::setModifiedOnDisk(ModifiedOnDiskReason reason) | ||
4220 | { | 4249 | { | ||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |