|
15 | 15 |
|
16 | 16 | #define ROW_DATA_SIZE 16
|
17 | 17 | #define HEADER_ROW_NUM 1
|
| 18 | + |
| 19 | +#define HEADER_ROW 0 |
| 20 | +#define HEADER_ADDRESS_COL 0 |
18 | 21 | #define HEADER_HEX_COL 1
|
| 22 | +#define HEADER_ANCII_COL 2 |
| 23 | + |
| 24 | +#define HEADER_ADDRESS_WIDTH 80 |
| 25 | +#define HEADER_HEX_WIDTH 340 |
19 | 26 |
|
20 | 27 | static void initBufferTable(QTableWidget *bufTable)
|
21 | 28 | {
|
22 | 29 | QTableWidgetItem *addressHeaderItem, *hexHeaderItem, *anciiHeaderItem;
|
23 | 30 |
|
24 | 31 | addressHeaderItem = new QTableWidgetItem(QObject::tr("ADDRESS"));
|
25 |
| - bufTable->setColumnWidth(0, 80); |
26 |
| - bufTable->setItem(0, 0, addressHeaderItem); |
| 32 | + bufTable->setColumnWidth(HEADER_ADDRESS_COL, HEADER_ADDRESS_WIDTH); |
| 33 | + bufTable->setItem(HEADER_ROW, HEADER_ADDRESS_COL, addressHeaderItem); |
27 | 34 | addressHeaderItem->setTextAlignment(Qt::AlignCenter);
|
28 | 35 |
|
29 | 36 | hexHeaderItem = new QTableWidgetItem(QObject::tr("HEX"));
|
30 |
| - bufTable->setColumnWidth(1, 340); |
31 |
| - bufTable->setItem(0, 1, hexHeaderItem); |
| 37 | + bufTable->setColumnWidth(HEADER_HEX_COL, HEADER_HEX_WIDTH); |
| 38 | + bufTable->setItem(HEADER_ROW, HEADER_HEX_COL, hexHeaderItem); |
32 | 39 | hexHeaderItem->setTextAlignment(Qt::AlignCenter);
|
33 | 40 |
|
34 | 41 | anciiHeaderItem = new QTableWidgetItem(QObject::tr("ANCII"));
|
35 | 42 | bufTable->horizontalHeader()->setStretchLastSection(true);
|
36 |
| - bufTable->setItem(0, 2, anciiHeaderItem); |
| 43 | + bufTable->setItem(HEADER_ROW, HEADER_ANCII_COL, anciiHeaderItem); |
37 | 44 | anciiHeaderItem->setTextAlignment(Qt::AlignCenter);
|
38 | 45 | }
|
39 | 46 |
|
@@ -114,11 +121,11 @@ void MainWindow::slotFileOpen()
|
114 | 121 | addressString.sprintf("0x%08X", address);
|
115 | 122 | address += ret;
|
116 | 123 |
|
117 |
| - ui->bufferTableWidget->setItem(rowNum, 0, |
| 124 | + ui->bufferTableWidget->setItem(rowNum, HEADER_ADDRESS_COL, |
118 | 125 | new QTableWidgetItem(addressString));
|
119 |
| - ui->bufferTableWidget->setItem(rowNum, 1, |
| 126 | + ui->bufferTableWidget->setItem(rowNum, HEADER_HEX_COL, |
120 | 127 | new QTableWidgetItem(hexString));
|
121 |
| - ui->bufferTableWidget->setItem(rowNum, 2, |
| 128 | + ui->bufferTableWidget->setItem(rowNum, HEADER_ANCII_COL, |
122 | 129 | new QTableWidgetItem("................"));
|
123 | 130 | rowNum++;
|
124 | 131 | }
|
|
0 commit comments