Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "FormSessionManager.h"
00037 #include "ui_FormSessionManager.h"
00038 #include <framework/gui/GuiFactory.h>
00039 #include <core/MethodsCommon.h>
00040 #include <QtGui/QInputDialog>
00041 #include <QtGui/QMessageBox>
00042
00043
00044 using namespace std;
00045 namespace wosh {
00046 namespace gui {
00047
00048 WOSH_REGISTER(wosh::gui::FormSessionManager, wosh::gui::WoshRemoteWidgetTW, 0.8677, gui_FormSessionManager)
00049 WOSH_GUI_BIND(wosh::gui::FormSessionManager, wosh::SessionManager, 0.0, gui_FormSessionManager1)
00050 WOSH_GUI_OVERRIDE(wosh::gui::FormSessionManager, wosh::SessionManager, "wosh::gui::wCore_Object", gui_FormSessionManager2)
00051
00052
00053
00054 FormSessionManager::FormSessionManager( QWidget* parent )
00055 : WoshRemoteWidgetTW(parent) {
00056 this->m_ui = new Ui::FormSessionManager();
00057 this->m_ui->setupUi(this);
00058 WoshRemoteWidgetTW::setTargetURI(URI(_SessionManager_URI));
00059
00060 buildMenus();
00061
00062
00063 this->m_ui->tableView->setResizeStretch("URI");
00064 this->m_ui->tableView->getTableView()->setContextMenuPolicy(Qt::CustomContextMenu);
00065 QObject::connect(this->m_ui->tableView, SIGNAL(postMessage(Message*)),this, SLOT(postMessage(Message*)) );
00066 QObject::connect(this->m_ui->tableView, SIGNAL(tableContextMenuRequested(const QPoint&, const QModelIndex&)),this, SLOT(tableView_ContextMenu(const QPoint&, const QModelIndex&)) );
00067 QObject::connect(this->m_ui->btnMonitorSession, SIGNAL(clicked()), this, SLOT(btnMonitorSession_clicked()));
00068 QObject::connect(this->m_ui->btnCloseSession, SIGNAL(clicked()), this, SLOT(btnCloseSession_clicked()));
00069 QObject::connect(this->m_ui->btnSendMessage, SIGNAL(clicked()), this, SLOT(btnSendMessage_clicked()));
00070 }
00071
00072 FormSessionManager::~FormSessionManager() {
00073 delete this->m_ui;
00074 }
00075
00076 void FormSessionManager::changeEvent(QEvent *e) {
00077 WoshRemoteWidgetTW::changeEvent(e);
00078 if ( e->type() == QEvent::LanguageChange )
00079 this->m_ui->retranslateUi(this);
00080 }
00081
00082
00083
00084
00085 WRESULT FormSessionManager::refresh( long options ) {
00086 WRESULT ret = WoshRemoteWidgetTW::refresh(options);
00087 setWindowTitle( tr("Session Manager [%1]").arg(this->getTargetURI().getKernelName().c_str()) );
00088 this->m_ui->tableView->refreshData();
00089 return ret;
00090 }
00091
00092
00093
00094
00095 void FormSessionManager::btnMonitorSession_clicked() {
00096 QMessageBox::critical(this, tr("NOT Implemented!"), tr("FormSessionManager::btnMonitorSession_clicked()") );
00097 }
00098
00099 void FormSessionManager::btnCloseSession_clicked() {
00100 Variant sessionId = this->m_ui->tableView->getCurrentItemAsVariantAtCol(0);
00101 executeRemoteMethod( _SessionManager_METHOD_close_session, sessionId.clone() );
00102 }
00103
00104 void FormSessionManager::btnSendMessage_clicked() {
00105 bool ok;
00106 Variant sessionId = this->m_ui->tableView->getCurrentItemAsVariantAtCol(0);
00107 QString text_msg = QInputDialog::getText(this, tr("Enter Message.."), tr("Send direct message:"), QLineEdit::Normal, "", &ok);
00108 if ( !ok || text_msg.isEmpty() ) return;
00109 List* args = List::createFrom<Variant>(sessionId, text_msg.toLatin1().constData());
00110 executeRemoteMethod( _SessionManager_METHOD_send_message, args );
00111 }
00112
00113
00114
00115
00116 void FormSessionManager::buildMenus() {
00117 this->menuTitle = new QAction(this);
00118 this->menuTitle->setEnabled(false);
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 this->menuSendMessage = new QAction(this);
00130 this->menuSendMessage->setText(tr("&Send Message.."));
00131
00132 this->menuTable = new QMenu(this);
00133 this->menuTable->addAction(this->menuTitle);
00134 this->menuTable->addSeparator();
00135
00136
00137
00138
00139
00140 this->menuTable->addAction(this->menuSendMessage);
00141
00142 }
00143
00144 void FormSessionManager::tableView_ContextMenu( const QPoint& pos, const QModelIndex& index ) {
00145 QPoint globalPos = this->mapToGlobal(pos);
00146 if ( !index.isValid() || index.row() == 0 ) return;
00147 Variant busName = this->m_ui->tableView->getCurrentItemAsVariantAtCol(1);
00148 Variant busType = this->m_ui->tableView->getCurrentItemAsVariantAtCol(2);
00149 Variant locshared = this->m_ui->tableView->getCurrentItemAsVariantAtCol(4);
00150 Variant netshared = this->m_ui->tableView->getCurrentItemAsVariantAtCol(5);
00151
00152 this->menuTitle->setText( busName.toString().c_str() );
00153 this->menuTitle->setIcon( GuiUtilities::createIconFor(busType.toString()) );
00154 this->menuSharedLocal->setChecked( locshared.toBoolean(false) );
00155 this->menuSharedNetwork->setChecked( netshared.toBoolean(false) );
00156
00157 QAction* selected = this->menuTable->exec( globalPos );
00158 if ( selected == this->menuSharedLocal ) {
00159 }
00160 else if ( selected == this->menuSharedNetwork ) {
00161 }
00162 else if ( selected == this->menuSendMessage ) {
00163 btnSendMessage_clicked();
00164 }
00165 }
00166
00167
00168
00169
00170 void FormSessionManager::busMessage( const Message& message, const Bus* source ) {
00171 WoshRemoteWidgetTW::busMessage( message, source );
00172 if ( message.isEmpty() || !message.getContent()->isResponse() ) return;
00173 if ( !isMessageForMeOrFromTarget(message) ) return;
00174 const wosh::Response* response = message.getContent()->asResponse();
00175 this->m_ui->tableView->evalResponse(response);
00176 }
00177
00178
00179
00180 };
00181 };