isInQuit::是否在主程序退出状态
| 3908 | |
| 3909 | //isInQuit::是否在主程序退出状态 |
| 3910 | void CCNotePad::tabClose(int index, bool isInQuit) |
| 3911 | { |
| 3912 | QWidget* pw = ui.editTabWidget->widget(index); |
| 3913 | QString filePath = pw->property(Edit_View_FilePath).toString(); |
| 3914 | |
| 3915 | //16进制的处理逻辑 |
| 3916 | int type = getDocTypeProperty(pw); |
| 3917 | |
| 3918 | if (HEX_TYPE == type) |
| 3919 | { |
| 3920 | ui.editTabWidget->removeTab(index); |
| 3921 | pw->deleteLater(); |
| 3922 | |
| 3923 | FileManager::getInstance().closeHexFileHand(filePath); |
| 3924 | |
| 3925 | //关闭文件后,打开一个新的页面 |
| 3926 | if (!isInQuit) |
| 3927 | { |
| 3928 | initTabNewOne(); |
| 3929 | } |
| 3930 | delFileListView(filePath); |
| 3931 | return; |
| 3932 | } |
| 3933 | else if (BIG_TEXT_RO_TYPE == type) |
| 3934 | { |
| 3935 | ui.editTabWidget->removeTab(index); |
| 3936 | pw->deleteLater(); |
| 3937 | |
| 3938 | FileManager::getInstance().closeBigTextRoFileHand(filePath); |
| 3939 | if (!isInQuit) |
| 3940 | { |
| 3941 | initTabNewOne(); |
| 3942 | } |
| 3943 | delFileListView(filePath); |
| 3944 | return; |
| 3945 | } |
| 3946 | else if (SUPER_BIG_TEXT_RO_TYPE == type) |
| 3947 | { |
| 3948 | ui.editTabWidget->removeTab(index); |
| 3949 | pw->deleteLater(); |
| 3950 | |
| 3951 | FileManager::getInstance().closeSuperBigTextFileHand(filePath); |
| 3952 | if (!isInQuit) |
| 3953 | { |
| 3954 | initTabNewOne(); |
| 3955 | } |
| 3956 | delFileListView(filePath); |
| 3957 | return; |
| 3958 | } |
| 3959 | |
| 3960 | //关闭之前,检查是否要保存。如果文档为脏,则询问是否要保存 |
| 3961 | ScintillaEditView* pEdit = dynamic_cast<ScintillaEditView*>(pw); |
| 3962 | |
| 3963 | //关闭之前先检测是否在tailf模式,否则要回收tailf线程,不然可能崩溃 |
| 3964 | #ifdef Q_OS_WIN |
| 3965 | if (pEdit != nullptr) |
| 3966 | { |
| 3967 | pEdit->deleteTailFileThread(); |
nothing calls this directly
no test coverage detected