调整界面listwidget为tablewidget

This commit is contained in:
yangjiaxuan 2022-12-23 10:42:46 +08:00
parent a20dcac343
commit 887ba4b208
10 changed files with 439 additions and 265 deletions

View File

@ -99,8 +99,7 @@ RESOURCES += \
ProductionTool_resource.qrc
TRANSLATIONS += \
ProductionTool_zh_CN.ts \
ProductionTool_zh_CN.ts
DISTFILES += \
ProductionTool_zh_CN.qm \ \
ProductionTool_zh_CN.ts
ProductionTool_zh_CN.qm

View File

@ -14,37 +14,37 @@
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="75"/>
<location filename="dialog_inputserialnum.ui" line="82"/>
<source>Select devType:</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="89"/>
<location filename="dialog_inputserialnum.ui" line="96"/>
<source>G100</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="94"/>
<location filename="dialog_inputserialnum.ui" line="101"/>
<source>G200</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="99"/>
<location filename="dialog_inputserialnum.ui" line="106"/>
<source>G300</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="104"/>
<location filename="dialog_inputserialnum.ui" line="111"/>
<source>G400</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="142"/>
<location filename="dialog_inputserialnum.ui" line="149"/>
<source>OK</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="149"/>
<location filename="dialog_inputserialnum.ui" line="156"/>
<source>Cancel</source>
<translation></translation>
</message>
@ -149,27 +149,31 @@
<translation></translation>
</message>
<message>
<location filename="dialog_changepwd.ui" line="35"/>
<location filename="dialog_changepwd.ui" line="58"/>
<source>old password:</source>
<translation></translation>
</message>
<message>
<location filename="dialog_changepwd.ui" line="75"/>
<location filename="dialog_changepwd.ui" line="96"/>
<source>new password:</source>
<translation></translation>
</message>
<message>
<location filename="dialog_changepwd.ui" line="115"/>
<source>confirm new password:</source>
<translation></translation>
<location filename="dialog_changepwd.ui" line="134"/>
<source>cfm password:</source>
<translation></translation>
</message>
<message>
<location filename="dialog_changepwd.ui" line="155"/>
<source>confirm new password:</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="dialog_changepwd.ui" line="39"/>
<source>OK</source>
<translation></translation>
</message>
<message>
<location filename="dialog_changepwd.ui" line="162"/>
<location filename="dialog_changepwd.ui" line="26"/>
<source>Cancel</source>
<translation></translation>
</message>
@ -404,35 +408,70 @@
<translation></translation>
</message>
<message>
<location filename="form_maininterface.ui" line="80"/>
<location filename="form_maininterface.ui" line="87"/>
<source>PASS</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.ui" line="87"/>
<source>FAIL</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.ui" line="94"/>
<source>STOP</source>
<translation></translation>
<source>FAIL</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.ui" line="101"/>
<source>STOP</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.ui" line="80"/>
<source>Next Step</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="27"/>
<location filename="form_maininterface.cpp" line="71"/>
<source>Device type:</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="27"/>
<location filename="form_maininterface.cpp" line="71"/>
<source> SerialNum:</source>
<translation> </translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="185"/>
<source>ID</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="185"/>
<source>Test items</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="185"/>
<source>status</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="272"/>
<source>not test</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="272"/>
<source>not pass</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="272"/>
<source>not support</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="272"/>
<source>pass</source>
<translation></translation>
</message>
</context>
<context>
<name>Form_textTips</name>
@ -495,7 +534,7 @@
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="285"/>
<location filename="mainwindow.cpp" line="284"/>
<source>Account login elsewhere</source>
<translation></translation>
</message>
@ -504,76 +543,76 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="288"/>
<location filename="mainwindow.cpp" line="287"/>
<source>You have been forced offline by the administrator account</source>
<translation>线</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="291"/>
<location filename="mainwindow.cpp" line="290"/>
<source>Data base error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="240"/>
<location filename="mainwindow.cpp" line="260"/>
<location filename="mainwindow.cpp" line="299"/>
<location filename="mainwindow.cpp" line="317"/>
<location filename="mainwindow.cpp" line="239"/>
<location filename="mainwindow.cpp" line="259"/>
<location filename="mainwindow.cpp" line="298"/>
<location filename="mainwindow.cpp" line="316"/>
<source>tips</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="241"/>
<location filename="mainwindow.cpp" line="240"/>
<source>Are you sure to connect the new device</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="243"/>
<location filename="mainwindow.cpp" line="242"/>
<source>yes</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="244"/>
<location filename="mainwindow.cpp" line="243"/>
<source>no</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="260"/>
<location filename="mainwindow.cpp" line="317"/>
<location filename="mainwindow.cpp" line="259"/>
<location filename="mainwindow.cpp" line="316"/>
<source>cannot create more table</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="337"/>
<location filename="mainwindow.cpp" line="336"/>
<source>save</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="337"/>
<location filename="mainwindow.cpp" line="336"/>
<source>xls(*.xls)</source>
<translation>xls表格(*.xls)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="361"/>
<location filename="mainwindow.cpp" line="360"/>
<source>Illegal user</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="365"/>
<location filename="mainwindow.cpp" line="364"/>
<source>Wrong password</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="369"/>
<location filename="mainwindow.cpp" line="368"/>
<source>Database error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="373"/>
<location filename="mainwindow.cpp" line="372"/>
<source>connect error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="377"/>
<location filename="mainwindow.cpp" line="376"/>
<source>Failed</source>
<translation></translation>
</message>

View File

@ -6,166 +6,153 @@
<rect>
<x>0</x>
<y>0</y>
<width>389</width>
<height>150</height>
<width>440</width>
<height>213</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>old password:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_oldPwd"/>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>new password:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_newPwd"/>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>confirm new password:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_confirmNewPwd"/>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pbtn_ok">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbtn_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<widget class="QPushButton" name="pbtn_cancel">
<property name="geometry">
<rect>
<x>310</x>
<y>160</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
<widget class="QPushButton" name="pbtn_ok">
<property name="geometry">
<rect>
<x>200</x>
<y>160</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>110</x>
<y>20</y>
<width>219</width>
<height>22</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>old password:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_oldPwd">
<property name="minimumSize">
<size>
<width>133</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>133</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>110</x>
<y>60</y>
<width>219</width>
<height>22</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>new password:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_newPwd">
<property name="minimumSize">
<size>
<width>133</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>133</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>110</x>
<y>100</y>
<width>219</width>
<height>22</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>cfm password:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_confirmNewPwd">
<property name="minimumSize">
<size>
<width>133</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>133</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>

View File

@ -11,6 +11,50 @@
#include "hgscanner.h"
#include "mainwindow.h"
typedef struct
{
const wchar_t *title;
HGUInt entryName;
}RELA;
static const RELA Rela[] = {
{HGPDTTOOLDB_TITLE_DIAL_SWITCH, HGPDTTOOLDB_ENTRYNAME_DIAL_SWITCH},
{HGPDTTOOLDB_TITLE_ROCKER_SWITCH, HGPDTTOOLDB_ENTRYNAME_ROCKER_SWITCH},
{HGPDTTOOLDB_TITLE_BOOT_STATUS, HGPDTTOOLDB_ENTRYNAME_BOOT_STATUS},
{HGPDTTOOLDB_TITLE_LCD_DISPLAY, HGPDTTOOLDB_ENTRYNAME_LCD_DISPLAY},
{HGPDTTOOLDB_TITLE_CLEAR_PAPER_PATH, HGPDTTOOLDB_ENTRYNAME_CLEAR_PAPER_PATH},
{HGPDTTOOLDB_TITLE_KEY_FUNCTION, HGPDTTOOLDB_ENTRYNAME_KEY_FUNCTION},
{HGPDTTOOLDB_TITLE_COUNTING_MODE, HGPDTTOOLDB_ENTRYNAME_COUNTING_MODE},
{HGPDTTOOLDB_TITLE_SKEW_DETECTION, HGPDTTOOLDB_ENTRYNAME_SKEW_DETECTION},
{HGPDTTOOLDB_TITLE_SEPARATER_MOTOR, HGPDTTOOLDB_ENTRYNAME_SEPARATER_MOTOR},
{HGPDTTOOLDB_TITLE_CIS_ORIGINAL_IMAGE, HGPDTTOOLDB_ENTRYNAME_CIS_ORIGINAL_IMAGE},
{HGPDTTOOLDB_TITLE_HOST_FAN, HGPDTTOOLDB_ENTRYNAME_HOST_FAN},
{HGPDTTOOLDB_TITLE_ULTRASONIC_MODULE, HGPDTTOOLDB_ENTRYNAME_ULTRASONIC_MODULE},
{HGPDTTOOLDB_TITLE_LED_LIGHT, HGPDTTOOLDB_ENTRYNAME_LED_LIGHT},
{HGPDTTOOLDB_TITLE_RESET, HGPDTTOOLDB_ENTRYNAME_RESET},
{HGPDTTOOLDB_TITLE_PAPER_FEED, HGPDTTOOLDB_ENTRYNAME_PAPER_FEED},
{HGPDTTOOLDB_TITLE_COVER_SENSOR, HGPDTTOOLDB_ENTRYNAME_COVER_SENSOR},
{HGPDTTOOLDB_TITLE_SCANNING_SENSOR, HGPDTTOOLDB_ENTRYNAME_SCANNING_SENSOR},
{HGPDTTOOLDB_TITLE_CONFIGURE_SPEED_MODE, HGPDTTOOLDB_ENTRYNAME_CONFIGURE_SPEED_MODE},
{HGPDTTOOLDB_TITLE_PLACE_CORRECTION_PAPER, HGPDTTOOLDB_ENTRYNAME_PLACE_CORRECTION_PAPER},
{HGPDTTOOLDB_TITLE_AUTO_FLAT_FIELD, HGPDTTOOLDB_ENTRYNAME_AUTO_FLAT_FIELD},
{HGPDTTOOLDB_TITLE_REBOOT_DEVICE, HGPDTTOOLDB_ENTRYNAME_REBOOT_DEVICE},
{HGPDTTOOLDB_TITLE_IMAGE_QUALITY, HGPDTTOOLDB_ENTRYNAME_IMAGE_QUALITY},
{HGPDTTOOLDB_TITLE_COLORCARD_IMAGEING_QUALITY, HGPDTTOOLDB_ENTRYNAME_COLORCARD_IMAGEING_QUALITY},
{HGPDTTOOLDB_TITLE_COLORCARD_BIAS_IMAGEING_QUALITY, HGPDTTOOLDB_ENTRYNAME_COLORCARD_BIAS_IMAGEING_QUALITY},
{HGPDTTOOLDB_TITLE_CLARITY_QUALITY, HGPDTTOOLDB_ENTRYNAME_CLARITY_QUALITY},
{HGPDTTOOLDB_TITLE_DISTORTION, HGPDTTOOLDB_ENTRYNAME_DISTORTION},
{HGPDTTOOLDB_TITLE_DORMANCY, HGPDTTOOLDB_ENTRYNAME_DORMANCY},
{HGPDTTOOLDB_TITLE_SKEW_GEAR, HGPDTTOOLDB_ENTRYNAME_SKEW_GEAR},
{HGPDTTOOLDB_TITLE_PAPER_SEPARATION_STRENGTH, HGPDTTOOLDB_ENTRYNAME_PAPER_SEPARATION_STRENGTH},
{HGPDTTOOLDB_TITLE_MECH_PAPER_FEEDING_INCLINATION, HGPDTTOOLDB_ENTRYNAME_MECH_PAPER_FEEDING_INCLINATION},
{HGPDTTOOLDB_TITLE_SINGLE_PAGE_TEST_1, HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_1},
{HGPDTTOOLDB_TITLE_SINGLE_PAGE_TEST_2, HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_2},
{HGPDTTOOLDB_TITLE_SINGLE_PAGE_TEST_3, HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_3},
{HGPDTTOOLDB_TITLE_PRESSUER_TEST, HGPDTTOOLDB_ENTRYNAME_PRESSUER_TEST},
{HGPDTTOOLDB_TITLE_CLEAR_ROLLER_COUNT, HGPDTTOOLDB_ENTRYNAME_CLEAR_ROLLER_COUNT}
};
Form_mainInterface::Form_mainInterface(class MainWindow *mainwnd, SANE_Handle handle, HGPdtToolDbUserMgr pdtToolDbuserMgr, HGPdtToolDbDevice pdtToolDbDevice,
const QString &serialNum, const QString &devType)
: QWidget(mainwnd)
@ -31,11 +75,7 @@ Form_mainInterface::Form_mainInterface(class MainWindow *mainwnd, SANE_Handle ha
ui->stackedWidget->addWidget(m_textTips);
ui->stackedWidget->addWidget(m_view);
ui->listWidget->setMinimumWidth(200);
ui->listWidget->setCurrentRow(0);
ui->pbtn_preStep->setEnabled(false);
downloadCfgFile();
initTableWidgetUi();
}
Form_mainInterface::~Form_mainInterface()
@ -59,56 +99,85 @@ void Form_mainInterface::paintEvent(QPaintEvent *event)
p.drawRect(0, 0, width() -1, height() -1);
}
void Form_mainInterface::on_listWidget_currentTextChanged(const QString &currentText)
{
ui->pbtn_preStep->setEnabled(ui->listWidget->currentRow() != 0);
ui->pbtn_nextStep->setEnabled(ui->listWidget->currentRow() != ui->listWidget->count() - 1);
QString testName;
if (currentText == HGPDTTOOLDB_TITLE_DIAL_SWITCH)
{
m_textTips->setViewContent(m_map_title_name.value(currentText).desc);
testName = m_map_title_name.value(currentText).name;
ui->stackedWidget->setCurrentWidget(m_textTips);
}
else if (currentText == HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST_1)
{
//addImg
testName = m_map_title_name.value(currentText).name;
ui->stackedWidget->setCurrentWidget(m_view);
}
ui_helper* helper;
hgscanner* hg = new hgscanner(m_handle);
helper = dynamic_cast<hgscanner*>(hg);
QString s("test-31");
// func_test_go(s.toStdWString().c_str(), L"null", helper);
}
void Form_mainInterface::on_pbtn_preStep_clicked()
{
ui->listWidget->setCurrentRow(ui->listWidget->currentRow() - 1);
int row = ui->tableWidget->currentRow();
if (row > 0)
{
ui->tableWidget->selectRow(row - 1);
}
}
void Form_mainInterface::on_pbtn_nextStep_clicked()
{
ui->listWidget->setCurrentRow(ui->listWidget->currentRow() + 1);
int row = ui->tableWidget->currentRow();
if (row < ui->tableWidget->rowCount() - 1)
{
ui->tableWidget->selectRow(row + 1);
}
}
void Form_mainInterface::on_pbtn_fail_clicked()
{
ui->listWidget->item(ui->listWidget->currentRow())->setBackgroundColor("red");
int row = ui->tableWidget->currentRow();
QTableWidgetItem *item = ui->tableWidget->item(row, 1);
QString title = item->text();
setTestItemStatus(title, HGPDTTOOLDB_ENTRYSTATUS_NOTPASS);
ui->tableWidget->setItem(row, 2, new QTableWidgetItem(getItemStatusStr(HGPDTTOOLDB_ENTRYSTATUS_NOTPASS)));
ui->tableWidget->item(row, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(row, 2)->setBackgroundColor(QColor(255,0,0));
}
void Form_mainInterface::on_pbtn_pass_clicked()
{
ui->listWidget->item(ui->listWidget->currentRow())->setBackgroundColor("yellow");
int row = ui->tableWidget->currentRow();
QTableWidgetItem *item = ui->tableWidget->item(row, 1);
QString title = item->text();
setTestItemStatus(title, HGPDTTOOLDB_ENTRYSTATUS_PASS);
ui->tableWidget->setItem(row, 2, new QTableWidgetItem(getItemStatusStr(HGPDTTOOLDB_ENTRYSTATUS_PASS)));
ui->tableWidget->item(row, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(row, 2)->setBackgroundColor(QColor(0,255,0));
on_pbtn_nextStep_clicked();
}
void Form_mainInterface::downloadCfgFile()
void Form_mainInterface::on_pbtn_stop_clicked()
{
m_mainwnd->RemoveInterface(this);
}
void Form_mainInterface::initTableWidgetUi()
{
ui->tableWidget->resizeRowsToContents();
ui->tableWidget->setColumnCount(3);
ui->tableWidget->horizontalHeader()->setDefaultSectionSize(200);
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
QStringList header;
header<< tr("ID") << tr("Test items") << tr("status");
ui->tableWidget->setHorizontalHeaderLabels(header);
QFont font = ui->tableWidget->horizontalHeader()->font();
font.setBold(true);
ui->tableWidget->horizontalHeader()->setFont(font);
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
ui->tableWidget->verticalHeader()->setDefaultSectionSize(10);
ui->tableWidget->setFrameShape(QFrame::NoFrame);
ui->tableWidget->setShowGrid(true);
ui->tableWidget->verticalHeader()->setVisible(false);
ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->tableWidget->horizontalHeader()->setFixedHeight(30);
ui->tableWidget->clearContents();
ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableWidget->setStyleSheet("selection-background-color:rgb(193,210,240)");
HGChar cfgPath[512] = {0};
HGBase_GetConfigPath(cfgPath, 512);
HGBase_CreateDir(cfgPath);
@ -121,26 +190,106 @@ void Form_mainInterface::downloadCfgFile()
AnalysisJson analysisJson(QString::fromStdString(cfgPath));
std::vector<AnalysisJson::json_node> list_jsonNode = analysisJson.GetNode();
for(int i = 0; i < (int)list_jsonNode.size(); ++i)
int count = list_jsonNode.size();
ui->tableWidget->setRowCount(count);
for(int i = 0; i < count; ++i)
{
AnalysisJson::json_node node = list_jsonNode[i];
ui->listWidget->addItem(node.title);
m_map_title_name.insert(node.title, node);
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(QString::number(i+1)));
ui->tableWidget->item(i, 0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(node.title));
ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
HGUInt status = getTestItemStatus(node.title);
QString statusStr = getItemStatusStr(status);
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(statusStr));
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
if (HGPDTTOOLDB_ENTRYSTATUS_NOTPASS == status)
{
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,0,0));
}
else if (HGPDTTOOLDB_ENTRYSTATUS_NOTSUPP == status)
{
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,255,0));
}
else if (HGPDTTOOLDB_ENTRYSTATUS_PASS == status)
{
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(0,255,0));
}
}
ui->tableWidget->selectRow(0);
}
}
void Form_mainInterface::on_pbtn_stop_clicked()
HGUInt Form_mainInterface::getTestItemStatus(const QString &title)
{
m_mainwnd->RemoveInterface(this);
HGUInt status = 0;
for (int i = 0; i < sizeof(Rela) / sizeof(RELA); ++i)
{
if (0 == wcscmp(title.toStdWString().c_str(), Rela[i].title))
{
HGPdtToolDb_GetDeviceEntryStatus(m_pdtToolDbDevice, Rela[i].entryName, &status);
break;
}
}
return status;
}
bool Form_mainInterface::setTestItemStatus(const QString &title, HGUInt status)
{
bool ret = false;
for (int i = 0; i < sizeof(Rela) / sizeof(RELA); ++i)
{
if (0 == wcscmp(title.toStdWString().c_str(), Rela[i].title))
{
if (HGBASE_ERR_OK == HGPdtToolDb_SetDeviceEntryStatus(m_pdtToolDbDevice, Rela[i].entryName, status))
ret = true;
break;
}
}
return ret;
}
QString Form_mainInterface::getItemStatusStr(HGUInt status)
{
static const QString statusStr[] = {tr("not test"), tr("not pass"), tr("not support"), tr("pass") };
return statusStr[status];
}
void Form_mainInterface::on_tableWidget_currentItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous)
{
int row = current->row();
int count = ui->tableWidget->rowCount();
ui->pbtn_preStep->setEnabled(row != 0);
ui->pbtn_nextStep->setEnabled(row != count- 1);
QTableWidgetItem *item2 = ui->tableWidget->item(row, 1);
QString title = item2->text();
QString testName;
if (title == HGPDTTOOLDB_TITLE_DIAL_SWITCH)
{
m_textTips->setViewContent(m_map_title_name.value(title).desc);
testName = m_map_title_name.value(title).name;
ui->stackedWidget->setCurrentWidget(m_textTips);
}
else if (title == HGPDTTOOLDB_TITLE_SINGLE_PAGE_TEST_1)
{
//addImg
testName = m_map_title_name.value(title).name;
ui->stackedWidget->setCurrentWidget(m_view);
}
ui_helper* helper;
hgscanner* hg = new hgscanner(m_handle);
helper = dynamic_cast<hgscanner*>(hg);
QString s("test-31");
// func_test_go(s.toStdWString().c_str(), L"null", helper);
}

View File

@ -3,6 +3,7 @@
#include <QWidget>
#include <QMap>
#include <QTableWidgetItem>
#include "HGImgView.h"
#include "form_texttips.h"
#include "analysisjson.h"
@ -28,8 +29,6 @@ protected:
void paintEvent(QPaintEvent *event) override;
private slots:
void on_listWidget_currentTextChanged(const QString &currentText);
void on_pbtn_preStep_clicked();
void on_pbtn_nextStep_clicked();
@ -40,8 +39,13 @@ private slots:
void on_pbtn_stop_clicked();
void on_tableWidget_currentItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous);
private:
void downloadCfgFile();
void initTableWidgetUi();
HGUInt getTestItemStatus(const QString &title);
bool setTestItemStatus(const QString &title, HGUInt status);
QString getItemStatusStr(HGUInt status);
private:
Ui::Form_mainInterface *ui;

View File

@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
@ -41,7 +41,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,3">
<item>
<widget class="QListWidget" name="listWidget"/>
<widget class="QTableWidget" name="tableWidget"/>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
@ -74,6 +74,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbtn_nextStep">
<property name="text">
<string>Next Step</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbtn_pass">
<property name="text">
@ -95,13 +102,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbtn_nextStep">
<property name="text">
<string>Next Step</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">

View File

@ -19,8 +19,6 @@ int main(int argc, char *argv[])
if (login.exec())
{
MainWindow w(login.GetUserMgr());
w.showMaximized();
w.Init();
a.exec();
if (w.isExitApp())
{

View File

@ -51,6 +51,11 @@ MainWindow::MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, QWidget *parent)
HGChar userName[128];
HGPdtToolDb_GetUserName(m_pdtToolDbuserMgr, userName, 128);
setWindowTitle(userName);
showMaximized();
SANE_Int v = 0;
sane_init_ex(&v, sane_ex_callback, this);
}
MainWindow::~MainWindow()
@ -75,12 +80,6 @@ MainWindow::~MainWindow()
delete ui;
}
void MainWindow::Init()
{
SANE_Int v = 0;
sane_init_ex(&v, sane_ex_callback, this);
}
bool MainWindow::isExitApp()
{
return !m_isLogOut;

View File

@ -20,7 +20,6 @@ class MainWindow : public QMainWindow
public:
MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, QWidget *parent = nullptr);
~MainWindow();
void Init();
static QString getLogInfo(HGResult ret);
bool isExitApp();