MCPcopy Create free account
hub / github.com/cxasm/notepad-- / slot_timerAutoSave

Method slot_timerAutoSave

src/cceditor/ccnotepad.cpp:5964–6021  ·  view source on GitHub ↗

定时器周期触发的自动保存

Source from the content-addressed store, hash-verified

5962
5963//定时器周期触发的自动保存
5964void CCNotePad::slot_timerAutoSave()
5965{
5966 int curTabIndex = ui.editTabWidget->currentIndex();
5967
5968 for (int i = ui.editTabWidget->count() - 1; i >= 0; --i)
5969 {
5970 QWidget* pw = ui.editTabWidget->widget(i);
5971
5972 //如果是未修改,不执行保存
5973 if (!getTextChangeProperty(pw))
5974 {
5975 continue;
5976 }
5977
5978 //16进制文件不执行保存
5979 if (HEX_TYPE == getDocTypeProperty(pw))
5980 {
5981 continue;
5982 }
5983
5984 //新建文件不需要保存
5985 if (getFileNewIndexProperty(pw) >= 0)
5986 {
5987 continue;
5988 }
5989
5990 ScintillaEditView* pEdit = dynamic_cast<ScintillaEditView*>(pw);
5991 if (pEdit != nullptr)
5992 {
5993 //如果是打开的文件了,则保存
5994 QString fileName = getFilePathProperty(pw);
5995 if (!fileName.isEmpty())
5996 {
5997 //保存前取消文件的修改检测,避免自己修改触发自己
5998 removeWatchFilePath(fileName);
5999
6000 if (!saveFile(fileName, pEdit))
6001 {
6002 continue;
6003 }
6004
6005 addWatchFilePath(fileName);
6006 }
6007 }
6008
6009 //如果是未设置脏状态,则设置脏为false
6010 setTextChangeProperty(pw, false);
6011
6012 if (curTabIndex == i)
6013 {
6014 m_saveFile->setEnabled(false);
6015 ui.statusBar->showMessage(tr("The current document has been automatically saved"), 5000);
6016 }
6017
6018 //只有保存后再打开文本变化监控
6019 enableEditTextChangeSign(pEdit);
6020 }
6021}

Callers

nothing calls this directly

Calls 6

getTextChangePropertyFunction · 0.85
getDocTypePropertyFunction · 0.85
getFileNewIndexPropertyFunction · 0.85
getFilePathPropertyFunction · 0.85
setTextChangePropertyFunction · 0.85
isEmptyMethod · 0.80

Tested by

no test coverage detected