telsale-management/代码/cpp/telsale_aux_kit/source/QConfigurationWidget.cpp

85 lines
1.9 KiB
C++
Raw Normal View History

#include <Qtwidgets/QtWidgets>
#include "QConfigurationWidget.h"
#include "SystemDataQuery.h"
#include "SystemData.h"
QConfigurationWidget::QConfigurationWidget(QWidget *parent)
: QWidget(parent)
{
setupUi(this);
init();
initWidget();
initSignal();
initData();
}
QConfigurationWidget::~QConfigurationWidget()
{
}
void QConfigurationWidget::init()
{
}
void QConfigurationWidget::initWidget()
{
setLayout( pLayoutMain );
setMaximumWidth( 800 );
}
void QConfigurationWidget::initSignal()
{
connect( pEditAutoTraderCode, SIGNAL(editingFinished()), this, SLOT(onAutoTraderCodeEdited()));
connect( pEditAutoTraderCode, SIGNAL(textChanged(const QString &)), this, SLOT(onAutoTraderCodeChanged()) );
connect( pButtonSave, SIGNAL(clicked()), this, SLOT(onSave()) );
connect( pButtonReset, SIGNAL(clicked()), this, SLOT(onReset()) );
}
void QConfigurationWidget::initData()
{
pEditAutoTraderCode->setText( QString::fromLocal8Bit( pParameters->getParameter("默认车商代码").c_str() ));
emit pEditAutoTraderCode->editingFinished();
}
void QConfigurationWidget::onAutoTraderCodeEdited()
{
string strAutoTraderCode = pEditAutoTraderCode->text().trimmed().toUpper().toLocal8Bit().data();
string strAutoTraderName;
2018-06-15 07:32:41 +00:00
query_auto_trader_info( strAutoTraderCode, strAutoTraderName );
pEditAutoTraderName->setText( QString::fromLocal8Bit( strAutoTraderName.c_str() ));
}
void QConfigurationWidget::onAutoTraderCodeChanged()
{
pEditAutoTraderName->clear();
}
void QConfigurationWidget::onSave()
{
if ( pEditAutoTraderName->text().isEmpty() )
{
emit pEditAutoTraderCode->editingFinished();
}
if ( pEditAutoTraderName->text().isEmpty() )
{
2018-06-01 10:21:26 +00:00
QMessageBox::critical( this, QString::fromLocal8Bit("错误!"), QString::fromLocal8Bit("车商代码错误!") );
return;
}
pParameters->setParameter( "默认车商代码", pEditAutoTraderCode->text().toLocal8Bit().data() );
}
void QConfigurationWidget::onReset()
{
initData();
}