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

Method checkRoladFile

src/cceditor/ccnotepad.cpp:3641–3716  ·  view source on GitHub ↗

startReadSize == -1 则从头开始读取。否则从startReadSize开始

Source from the content-addressed store, hash-verified

3639
3640//startReadSize == -1 则从头开始读取。否则从startReadSize开始
3641bool CCNotePad::checkRoladFile(ScintillaEditView* pEdit, qint64 startReadSize)
3642{
3643 if (pEdit != nullptr && pEdit->property(Modify_Outside).toBool())
3644 {
3645 //防止该函数重入,导致时序错误
3646 if (m_isInReloadFile)
3647 {
3648 return false;
3649 }
3650
3651 m_isInReloadFile = true;
3652
3653 int tailStatus = getFileTailProperty(pEdit);
3654
3655 if (tailStatus != 1)
3656 {
3657 QApplication::beep();
3658 }
3659
3660 //如果是开启了taif,则不提示,直接重新加载文件
3661 if (tailStatus == 1)
3662 {
3663 //如果是进入tailf模式,但是startReadSize == -1.则什么也不干。
3664 //等监控超时后,后续走tailf差异读取模式。
3665 if (startReadSize == -1)
3666 {
3667 //这里什么也不做。坐等超时后,走下面的逻辑
3668 }
3669 else
3670 {
3671 //如果文件大于3000行,则删除内容,只保留当前100行,继续tailf
3672 if (pEdit->lines() < 3000)
3673 {
3674 doReloadTxtFile(pEdit, true, startReadSize);
3675 }
3676 else
3677 {
3678 firstTimeIntoTail(pEdit,100);
3679 }
3680
3681 }
3682
3683 }
3684 else
3685 {
3686 QString filePath = pEdit->property(Edit_View_FilePath).toString();
3687
3688 int ret = QMessageBox::question(this, tr("Reload"), tr("\"%1\" This file has been modified by another program. Do you want to reload it?").arg(filePath), tr("Yes[Reload]"), tr("No[Drop]"), tr("On Tailf"));
3689 if(ret == 0)
3690 {
3691 doReloadTxtFile(pEdit, false, startReadSize);
3692 }
3693 else if (ret == 1)
3694 {
3695 //放弃
3696 pEdit->setProperty(Modify_Outside, QVariant(false));
3697 }
3698 else if (ret == 2)

Callers

nothing calls this directly

Calls 2

getFileTailPropertyFunction · 0.85
linesMethod · 0.80

Tested by

no test coverage detected