Skip to content

Commit 2f5f2df

Browse files
committed
qt: use defines for header col, row and width
1 parent 6ea62a2 commit 2f5f2df

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

qt/main_window.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,32 @@
1515

1616
#define ROW_DATA_SIZE 16
1717
#define HEADER_ROW_NUM 1
18+
19+
#define HEADER_ROW 0
20+
#define HEADER_ADDRESS_COL 0
1821
#define HEADER_HEX_COL 1
22+
#define HEADER_ANCII_COL 2
23+
24+
#define HEADER_ADDRESS_WIDTH 80
25+
#define HEADER_HEX_WIDTH 340
1926

2027
static void initBufferTable(QTableWidget *bufTable)
2128
{
2229
QTableWidgetItem *addressHeaderItem, *hexHeaderItem, *anciiHeaderItem;
2330

2431
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);
2734
addressHeaderItem->setTextAlignment(Qt::AlignCenter);
2835

2936
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);
3239
hexHeaderItem->setTextAlignment(Qt::AlignCenter);
3340

3441
anciiHeaderItem = new QTableWidgetItem(QObject::tr("ANCII"));
3542
bufTable->horizontalHeader()->setStretchLastSection(true);
36-
bufTable->setItem(0, 2, anciiHeaderItem);
43+
bufTable->setItem(HEADER_ROW, HEADER_ANCII_COL, anciiHeaderItem);
3744
anciiHeaderItem->setTextAlignment(Qt::AlignCenter);
3845
}
3946

@@ -114,11 +121,11 @@ void MainWindow::slotFileOpen()
114121
addressString.sprintf("0x%08X", address);
115122
address += ret;
116123

117-
ui->bufferTableWidget->setItem(rowNum, 0,
124+
ui->bufferTableWidget->setItem(rowNum, HEADER_ADDRESS_COL,
118125
new QTableWidgetItem(addressString));
119-
ui->bufferTableWidget->setItem(rowNum, 1,
126+
ui->bufferTableWidget->setItem(rowNum, HEADER_HEX_COL,
120127
new QTableWidgetItem(hexString));
121-
ui->bufferTableWidget->setItem(rowNum, 2,
128+
ui->bufferTableWidget->setItem(rowNum, HEADER_ANCII_COL,
122129
new QTableWidgetItem("................"));
123130
rowNum++;
124131
}

0 commit comments

Comments
 (0)