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

Method openHexFile

src/cceditor/ccnotepad.cpp:5003–5057  ·  view source on GitHub ↗

打开并显示二进制文件

Source from the content-addressed store, hash-verified

5001
5002//打开并显示二进制文件
5003bool CCNotePad::openHexFile(QString filePath)
5004{
5005 getRegularFilePath(filePath);
5006
5007 QFileInfo fi(filePath);
5008 QString fileLabel(fi.fileName());
5009
5010 HexFileMgr* hexFile = nullptr;
5011
5012 if (!FileManager::getInstance().loadFileData(filePath, hexFile))
5013 {
5014 return false;
5015 }
5016
5017 ScintillaHexEditView* pEdit = FileManager::getInstance().newEmptyHexDocument();
5018 pEdit->setReadOnly(true);
5019 pEdit->setNoteWidget(this);
5020 pEdit->execute(SCI_SETSCROLLWIDTH, 80 * 10);
5021
5022
5023 setDocTypeProperty(pEdit, HEX_TYPE);
5024
5025 showHexFile(pEdit,hexFile);
5026
5027 disconnect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged);
5028 int curIndex = ui.editTabWidget->addTab(pEdit, QIcon((StyleSet::getCurrentSytleId() != DEEP_BLACK) ? TabNoNeedSave : TabNoNeedSaveDark32), getShortName(fileLabel));
5029
5030 ui.editTabWidget->setCurrentIndex(curIndex);
5031 connect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged, Qt::UniqueConnection);
5032
5033 QVariant editViewFilePath(filePath);
5034 pEdit->setProperty(Edit_View_FilePath, editViewFilePath);
5035
5036 //setWindowTitle(filePath);
5037 ui.editTabWidget->setTabToolTip(curIndex, filePath);
5038
5039 QVariant editViewNewFile(-1);
5040 pEdit->setProperty(Edit_File_New, editViewNewFile);
5041
5042 QVariant editTextChange(false);
5043 pEdit->setProperty(Edit_Text_Change, editTextChange);
5044
5045 syncCurDocEncodeToMenu(pEdit);
5046
5047 syncCurDocTailfToMenu(pEdit);
5048
5049 setFileOpenAttrProperty(pEdit, OpenAttr::HexReadOnly);
5050 setWindowTitleMode(filePath, OpenAttr::HexReadOnly);
5051
5052 ui.statusBar->showMessage(tr("File %1 Open Finished [Hex ReayOnly Mode]").arg(filePath),MSG_EXIST_TIME);
5053
5054 addFileListView(filePath, pEdit);
5055
5056 return true;
5057}
5058
5059void CCNotePad::slot_fileListView(bool check)
5060{

Callers

nothing calls this directly

Calls 8

getRegularFilePathFunction · 0.85
setDocTypePropertyFunction · 0.85
setFileOpenAttrPropertyFunction · 0.85
loadFileDataMethod · 0.80
newEmptyHexDocumentMethod · 0.80
setReadOnlyMethod · 0.80
setNoteWidgetMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected