117 lines
3.1 KiB
C++
117 lines
3.1 KiB
C++
#include "dialog_accountmanage.h"
|
|
#include "ui_dialog_accountmanage.h"
|
|
#include "dialog_rootfuntion.h"
|
|
#include "mainwindow.h"
|
|
#include <QMessageBox>
|
|
|
|
|
|
Dialog_accountManage::Dialog_accountManage(QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::Dialog_accountManage)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
|
|
QFont ft;
|
|
ft.setPointSize(15);
|
|
this->setFont(ft);
|
|
|
|
HGChar* userNameList[100];
|
|
HGUInt count = 0;
|
|
//HGPdtToolDb_GetUserList(pdtToolDbuserMgr, userNameList, 100, &count);
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
{
|
|
ui->listWidget->addItem(QString(userNameList[i]));
|
|
}
|
|
|
|
ui->listWidget->setCurrentRow(0);
|
|
|
|
//HGPdtToolDb_ReleaseUserList(userNameList, count);
|
|
}
|
|
|
|
Dialog_accountManage::~Dialog_accountManage()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void Dialog_accountManage::on_pbtn_newAccount_clicked()
|
|
{
|
|
Dialog_rootFuntion dlg(false, this);
|
|
if (dlg.exec())
|
|
{
|
|
// HGResult ret = HGPdtToolDb_CreateUser(m_pdtToolDbuserMgr, dlg.getAccount().toStdString().c_str(), dlg.getPassword().toStdString().c_str());
|
|
// if (ret == HGBASE_ERR_OK)
|
|
// {
|
|
// ui->listWidget->addItem(dlg.getAccount());
|
|
// }
|
|
// else
|
|
// {
|
|
// QMessageBox::information(this, tr("tips"), tr("create user failed: ") + MainWindow::getLogInfo(ret));
|
|
// }
|
|
}
|
|
}
|
|
|
|
void Dialog_accountManage::on_pbtn_destroyAccount_clicked()
|
|
{
|
|
QString userName = ui->listWidget->currentItem()->text();
|
|
|
|
QMessageBox msg(QMessageBox::Question, tr("Question"),
|
|
tr("Are you sure to destroy: ") + userName,
|
|
QMessageBox::Yes | QMessageBox::No, this);
|
|
msg.setButtonText(QMessageBox::Yes, tr("yes"));
|
|
msg.setButtonText(QMessageBox::No, tr("no"));
|
|
msg.exec();
|
|
if (msg.clickedButton() == msg.button(QMessageBox::Yes))
|
|
{
|
|
// HGResult ret = HGPdtToolDb_DestroyUser(m_pdtToolDbuserMgr, userName.toStdString().c_str());
|
|
// if(ret == HGBASE_ERR_OK)
|
|
// {
|
|
// ui->listWidget->takeItem(ui->listWidget->currentRow());
|
|
// }
|
|
// else
|
|
// {
|
|
// QMessageBox::information(this, tr("tips"), tr("destroy user failed: ") + MainWindow::getLogInfo(ret));
|
|
// }
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
void Dialog_accountManage::on_pbtn_changePwd_clicked()
|
|
{
|
|
Dialog_rootFuntion dlg(true, this);
|
|
if (dlg.exec())
|
|
{
|
|
QString userName = ui->listWidget->currentItem()->text();
|
|
// HGResult ret = HGPdtToolDb_SetPassword(m_pdtToolDbuserMgr, userName.toStdString().c_str(), dlg.getPassword().toStdString().c_str());
|
|
// if(ret == HGBASE_ERR_OK)
|
|
// {
|
|
// QMessageBox::information(this, tr("tips"), tr("change password succeed"));
|
|
// }
|
|
// else
|
|
// {
|
|
// QMessageBox::information(this, tr("tips"), tr("change password failed: ") + MainWindow::getLogInfo(ret));
|
|
// }
|
|
}
|
|
}
|
|
|
|
void Dialog_accountManage::on_pbtn_exit_clicked()
|
|
{
|
|
close();
|
|
}
|
|
|
|
void Dialog_accountManage::on_listWidget_itemDoubleClicked(QListWidgetItem *item)
|
|
{
|
|
(void)item;
|
|
on_pbtn_changePwd_clicked();
|
|
}
|
|
|
|
|
|
|
|
|
|
|