|
@@ -1,12 +1,30 @@
|
|
|
#include "mainwindow.h"
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
|
+#include <QMessageBox>
|
|
|
+#include <iostream>
|
|
|
+
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
: QMainWindow(parent)
|
|
|
, ui(new Ui::MainWindow)
|
|
|
{
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
+ mmsg = QDBusMessage::createSignal("/catarc/adc", "adciv.interface", "modulemsgquery");
|
|
|
+ mmsg<<1;
|
|
|
+ bool bconnect = QDBusConnection::sessionBus().connect(QString(),"/catarc/adc", "adciv.interface", "modulemsgres",this,SLOT(onQuery(QByteArray)));
|
|
|
+
|
|
|
+ if(bconnect == false)
|
|
|
+ {
|
|
|
+ qDebug("connect dbus fail.");
|
|
|
+ }
|
|
|
+ QTimer * timer = new QTimer();
|
|
|
+ connect(timer,SIGNAL(timeout()),this,SLOT(onTimer()));
|
|
|
+ // timer->start(5000);
|
|
|
+
|
|
|
+ mpTimer = timer;
|
|
|
+
|
|
|
+
|
|
|
setWindowTitle("Message View");
|
|
|
}
|
|
|
|
|
@@ -18,15 +36,79 @@ MainWindow::~MainWindow()
|
|
|
|
|
|
void MainWindow::on_pushButton_refresh_clicked()
|
|
|
{
|
|
|
+ mSendQueryTime = QDateTime::currentMSecsSinceEpoch();
|
|
|
+ mvectormsgname_temp.clear();
|
|
|
+
|
|
|
+ QDBusConnection::sessionBus().send(mmsg);
|
|
|
+
|
|
|
+ mpTimer->start(1000);
|
|
|
+ ui->pushButton_refresh->setEnabled(false);
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
void MainWindow::on_pushButton_view_clicked()
|
|
|
{
|
|
|
+ if(ui->comboBox_message->count()<1)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","Please Refresh or Manual Add Message.",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string strmsgname = ui->comboBox_message->currentText().toStdString();
|
|
|
|
|
|
+ DialogViewMessage * pdlgviewmsg = new DialogViewMessage(strmsgname);
|
|
|
+ connect(pdlgviewmsg,SIGNAL(ViewMsgClose(void*)),this,SLOT(onViewWindowClose(void*)));
|
|
|
+ pdlgviewmsg->show();
|
|
|
}
|
|
|
|
|
|
void MainWindow::on_pushButton_manualadd_clicked()
|
|
|
{
|
|
|
+ DialogAddMsg dialogadd(this);
|
|
|
+ if(dialogadd.exec() == QDialog::Accepted)
|
|
|
+ {
|
|
|
+ std::string strnewmsg = dialogadd.GetMessageName();
|
|
|
+ ui->comboBox_message->addItem(strnewmsg.data());
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onQuery(QByteArray ba)
|
|
|
+{
|
|
|
+ if(ba.size() < sizeof(iv::modulemsg_type))
|
|
|
+ {
|
|
|
+ std::cout<<" querymsg::onQuery size error."<<std::endl;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ iv::modulemsg_type xmodulemsg;
|
|
|
+ memcpy((char *)&xmodulemsg,ba.data(),sizeof(iv::modulemsg_type));
|
|
|
+
|
|
|
+ std::string strmsgname = xmodulemsg.mstrmsgidname;
|
|
|
+ mvectormsgname_temp.push_back(strmsgname);
|
|
|
+ qDebug("id name: %s share name: %s bufsize:%d bufcount:%d",
|
|
|
+ xmodulemsg.mstrmsgidname,xmodulemsg.mstrmsgname,
|
|
|
+ xmodulemsg.mnBufSize,xmodulemsg.mnMsgBufCount);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onTimer()
|
|
|
+{
|
|
|
+ mpTimer->stop();
|
|
|
+ ui->comboBox_message->clear();
|
|
|
+ ui->pushButton_refresh->setEnabled(true);
|
|
|
+ mvectormsg = mvectormsgname_temp;
|
|
|
|
|
|
+
|
|
|
+ unsigned int i;
|
|
|
+ for(i=0;i<mvectormsg.size();i++)
|
|
|
+ {
|
|
|
+ ui->comboBox_message->addItem(mvectormsg[i].data());
|
|
|
+ }
|
|
|
+
|
|
|
+ QMessageBox::information(this,"Info","Refresh succefully.",QMessageBox::YesAll);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onViewWindowClose(void *phandle)
|
|
|
+{
|
|
|
+// DialogViewMessage * pdlg = (DialogViewMessage * )phandle;
|
|
|
+// delete pdlg;
|
|
|
}
|