1 // copyright (c) 2019-2021 hors<horsicq@gmail.com>
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 
10 // The above copyright notice and this permission notice shall be included in all
11 // copies or substantial portions of the Software.
12 
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 //
21 #ifndef NEWIDGET_H
22 #define NEWIDGET_H
23 
24 #include "../formatwidget.h"
25 #include "ne_defs.h"
26 #include "neprocessdata.h"
27 #include "nesectionheaderwidget.h"
28 
29 namespace Ui
30 {
31 class NEWidget;
32 }
33 
34 class NEWidget : public FormatWidget
35 {
36     Q_OBJECT
37 
38 public:
39     NEWidget(QWidget *pParent=nullptr);
40     NEWidget(QIODevice *pDevice,FW_DEF::OPTIONS options,QWidget *pParent=nullptr);
41     ~NEWidget();
42     void setShortcuts(XShortcuts *pShortcuts);
43 
44     virtual void clear();
45     virtual void cleanup();
46     virtual void reload();
47 
48 protected:
49     virtual SV _setValue(QVariant vValue,int nStype,int nNdata,int nVtype,int nPosition,qint64 nOffset);
50     virtual void setReadonly(bool bState);
51     virtual void blockSignals(bool bState);
52     virtual void adjustHeaderTable(int nType,QTableWidget *pTableWidget);
53 
54 private slots:
55     virtual void reloadData();
56     void widgetValueChanged(quint64 nValue);
57     void on_treeWidgetNavi_currentItemChanged(QTreeWidgetItem *pCurrent,QTreeWidgetItem *pPrevious);
58     void on_checkBoxReadonly_toggled(bool bChecked);
59     void on_pushButtonReload_clicked();
60     void enableButton();
61     void on_tableWidget_DOS_HEADER_currentCellChanged(int nCurrentRow,int nCurrentColumn,int nPreviousRow,int nPreviousColumn);
62     void on_tableWidget_OS2_HEADER_currentCellChanged(int nCurrentRow,int nCurrentColumn,int nPreviousRow,int nPreviousColumn);
63     void on_toolButtonPrev_clicked();
64     void on_toolButtonNext_clicked();
65 
66 private:
67     enum CB
68     {
69         CB_DOS_HEADER_e_magic=0,
70         CB_OS2_HEADER_ne_magic,
71         CB_OS2_HEADER_ne_flags,
72         CB_OS2_HEADER_ne_exetype,
73         CB_OS2_HEADER_ne_flagsothers,
74         __CB_size
75     };
76 
77     enum INV
78     {
79         INV_IMAGE_DOS_HEADER_e_lfanew,
80         CB_OS2_HEADER_ne_enttab,
81         CB_OS2_HEADER_ne_segtab,
82         CB_OS2_HEADER_ne_rsrctab,
83         CB_OS2_HEADER_ne_restab,
84         CB_OS2_HEADER_ne_modtab,
85         CB_OS2_HEADER_ne_imptab,
86         CB_OS2_HEADER_ne_nrestab,
87         __INV_size
88     };
89 
90     Ui::NEWidget *ui;
91 
92     XLineEditHEX *g_lineEdit_DOS_HEADER[N_NE_DOS_HEADER::__data_size];
93     XLineEditHEX *g_lineEdit_OS2_HEADER[N_OS2_HEADER::__data_size];
94     XComboBoxEx *g_comboBox[__CB_size];
95 
96     InvWidget *g_invWidget[__INV_size];
97     SubDevice *g_subDevice[SNE::__TYPE_size];
98 };
99 
100 #endif // NEWIDGET_H
101