#include <ConnectWindow.h>
Public Slots | |
void | makeConnection (void) |
Make Connection: Rio Connection, Local Connection or Monitor Connection. | |
void | changeConnectionType (int index=0) |
Changes between Local and Rio/Monitor Connection. | |
void | changeLogin (int index=0) |
Changes between logins. | |
void | changeLogin (const QString &string) |
Public Member Functions | |
ConnectWindow (QWidget *parent=0, QWorkspace *workspace=0) | |
void | changeUpdateInterval (const int UpdateInterval) |
Private Member Functions | |
void | updateConnectionSettings (void) |
Private Attributes | |
QComboBox * | host |
QComboBox * | login |
QLineEdit * | password |
QComboBox * | type |
QWorkspace * | workspace |
RioQt * | rioQt |
int | UpIntMonConnection |
Definition at line 29 of file ConnectWindow.h.
ConnectWindow::ConnectWindow | ( | QWidget * | parent = 0 , |
|
QWorkspace * | workspace = 0 | |||
) |
Definition at line 32 of file ConnectWindow.cpp.
00033 : QDialog( parent, "Connect", true, 0 ) 00034 { 00035 this->workspace = workspace; 00036 00037 rioQt = (RioQt *)parent; 00038 00039 QWidget *widget = new QWidget( this ); 00040 setCaption( tr( "Open new connection" ) ); 00041 00042 QVBoxLayout *mainLayout = new QVBoxLayout( widget ); 00043 mainLayout->setMargin( 10 ); 00044 00045 QGridLayout *fieldLayout = new QGridLayout( 4, 2 ); 00046 fieldLayout->setSpacing( 10 ); 00047 fieldLayout->setMargin( 10 ); 00048 00049 type = new QComboBox( this ); 00050 type->insertItem( "Rio Connection" ); 00051 type->insertItem( "Local Connection" ); 00052 type->insertItem( "Monitor Connection" ); 00053 00054 host = new QComboBox( this ); 00055 host->setEditable( true ); 00056 host->setInsertionPolicy( QComboBox::AtTop ); 00057 host->setAutoCompletion( true ); 00058 host->setDuplicatesEnabled( false ); 00059 00060 login = new QComboBox( this ); 00061 login->setEditable( true ); 00062 login->setInsertionPolicy( QComboBox::AtTop ); 00063 login->setAutoCompletion( true ); 00064 login->setDuplicatesEnabled( false ); 00065 00066 password = new QLineEdit( this ); 00067 password->setEchoMode( QLineEdit::Password ); 00068 password->setFocus(); 00069 password->setMaxLength( MAXPASSWORDSIZE ); 00070 00071 fieldLayout->addWidget( new QLabel( tr( "Type:" ), this ), 0, 0 ); 00072 fieldLayout->addWidget( type, 0, 1 ); 00073 fieldLayout->addWidget( new QLabel( tr( "Server:" ), this ), 1, 0 ); 00074 fieldLayout->addWidget( host, 1, 1 ); 00075 fieldLayout->addWidget( new QLabel( tr( "Login:" ), this ), 2, 0 ); 00076 fieldLayout->addWidget( login, 2, 1 ); 00077 fieldLayout->addWidget( new QLabel( tr( "Password:" ), this ), 3, 0 ); 00078 fieldLayout->addWidget( password, 3, 1 ); 00079 00080 host->insertStringList( rioQt->getConfig()->getHostsList() ); 00081 login->insertStringList( rioQt->getConfig()->getUsersList() ); 00082 00083 QPushButton *connectButton = new QPushButton( tr( "Connect" ), this ); 00084 QPushButton *cancelButton = new QPushButton( tr( "Cancel" ), this ); 00085 00086 connectButton->setDefault( true ); 00087 00088 connect( connectButton, SIGNAL( clicked() ), 00089 this, SLOT( makeConnection() ) ); 00090 connect( cancelButton, SIGNAL( clicked() ), 00091 this, SLOT( close() ) ); 00092 connect( type, SIGNAL( activated( int ) ), 00093 this, SLOT( changeConnectionType( int ) ) ); 00094 connect( login, SIGNAL( activated( int ) ), 00095 this, SLOT( changeLogin( int ) ) ); 00096 connect( login, SIGNAL( textChanged( const QString & ) ), 00097 this, SLOT( changeLogin( const QString & ) ) ); 00098 00099 QHBoxLayout *buttonLayout = new QHBoxLayout(); 00100 buttonLayout->addWidget( connectButton, 0 ); 00101 buttonLayout->addWidget( cancelButton, 0 ); 00102 00103 mainLayout->addLayout( fieldLayout ); 00104 mainLayout->addLayout( buttonLayout ); 00105 00106 changeConnectionType(); 00107 changeLogin( 0 ); 00108 00109 widget->setMinimumSize( widget->minimumSizeHint() ); 00110 }
void ConnectWindow::changeConnectionType | ( | int | index = 0 |
) | [slot] |
Changes between Local and Rio/Monitor Connection.
Definition at line 210 of file ConnectWindow.cpp.
00211 { 00212 bool enabled = true; 00213 if( type->currentText() == "Local Connection" ) 00214 enabled = false; 00215 00216 host->setEnabled( enabled ); 00217 login->setEnabled( enabled ); 00218 password->setEnabled( enabled ); 00219 if( type->currentText() == "Monitor Connection" ) 00220 { 00221 login->setCurrentText( "root" ); 00222 login->setEnabled( false ); 00223 } 00224 00225 if( password->isEnabled() ) 00226 changeLogin( 0 ); 00227 }
void ConnectWindow::changeLogin | ( | const QString & | string | ) | [slot] |
Definition at line 241 of file ConnectWindow.cpp.
00242 { 00243 changeLogin( 0 ); 00244 }
void ConnectWindow::changeLogin | ( | int | index = 0 |
) | [slot] |
Changes between logins.
Definition at line 232 of file ConnectWindow.cpp.
void ConnectWindow::changeUpdateInterval | ( | const int | UpdateInterval | ) |
Definition at line 246 of file ConnectWindow.cpp.
00247 { 00248 UpIntMonConnection = UpdateInterval; 00249 }
void ConnectWindow::makeConnection | ( | void | ) | [slot] |
Make Connection: Rio Connection, Local Connection or Monitor Connection.
Definition at line 115 of file ConnectWindow.cpp.
00116 { 00117 if( ( type->currentText() == "Rio Connection" ) || 00118 ( type->currentText() == "Monitor Connection" ) ) 00119 { 00120 QString errorMessage; 00121 bool status; 00122 00123 status = true; 00124 // Default error message 00125 errorMessage = tr( "You have entered invalid value for:\n" ); 00126 if( host->isEnabled() && host->currentText().isEmpty() ) 00127 { 00128 errorMessage += tr( "Server Host\n" ); 00129 status = false; 00130 } 00131 if( login->isEnabled() && login->currentText().isEmpty() ) 00132 { 00133 errorMessage += tr( "Login\n" ); 00134 status = false; 00135 } 00136 if( password->isEnabled() && password->text().isEmpty() ) 00137 { 00138 errorMessage += tr( "Password\n" ); 00139 status = false; 00140 } 00141 00142 if( !status ) 00143 { 00144 ShowMessageEvent * event = new ShowMessageEvent( ShowMessageEvent::ERROR, 00145 errorMessage ); 00146 QApplication::postEvent( (RioQt *)parent(), event ); 00147 } 00148 else 00149 { 00150 char * hostName = (char *)host->currentText().latin1(); 00151 char * user = (char *)login->currentText().latin1(); 00152 char * qspass = encryptPassword( 00153 (char *)password->text().latin1() ); 00154 00155 if( type->currentText() == "Rio Connection") 00156 { 00157 FileWindow *rioWindow; 00158 rioWindow = new FileWindow( workspace, rioQt, FileWindow::RIO ); 00159 00160 if( rioWindow->connectRioServer( hostName, user, qspass ) ) 00161 { 00162 // Criando janela do rio e criando uma nova sessao 00163 rioWindow->show(); 00164 00165 updateConnectionSettings(); 00166 00167 accept(); 00168 } 00169 else 00170 { 00171 delete rioWindow; 00172 reject(); 00173 } 00174 } 00175 else // type->currentText() == "Monitor Connection" 00176 { 00177 MonitorWindow *monitorWindow; 00178 monitorWindow = new MonitorWindow( workspace, rioQt, 00179 UpIntMonConnection ); 00180 00181 if( monitorWindow->connectRioServer( hostName, user, qspass ) ) 00182 { 00183 // Criando janela do rio e criando uma nova sessao 00184 monitorWindow->show(); 00185 00186 updateConnectionSettings(); 00187 00188 accept(); 00189 } 00190 else 00191 { 00192 delete monitorWindow; 00193 reject(); 00194 } 00195 } 00196 } 00197 } 00198 else // type->currentText() == "Local Connection" 00199 { 00200 FileWindow *localWindow = new FileWindow( workspace, rioQt, FileWindow::LOCAL ); 00201 00202 localWindow->show(); 00203 accept(); 00204 } 00205 }
void ConnectWindow::updateConnectionSettings | ( | void | ) | [private] |
Definition at line 255 of file ConnectWindow.cpp.
00256 { 00257 QStringList values; 00258 bool add_item; 00259 00260 // Hosts list 00261 values = rioQt->getConfig()->getHostsList(); 00262 add_item = true; 00263 00264 for( QStringList::Iterator it = values.begin(); it != values.end(); ++it ) 00265 { 00266 if( host->currentText() == *it ) 00267 { 00268 // Move this entry to the beginning of the list 00269 values.remove( *it ); 00270 values.prepend( *it ); 00271 00272 add_item = false; 00273 break; 00274 } 00275 } 00276 if( add_item ) 00277 { 00278 values.prepend( host->currentText() ); 00279 host->insertItem( host->currentText() ); 00280 } 00281 rioQt->getConfig()->setHostsList( values ); 00282 00283 values.clear(); 00284 00285 // Users list 00286 values = rioQt->getConfig()->getUsersList(); 00287 add_item = true; 00288 00289 for( QStringList::Iterator it = values.begin(); it != values.end(); ++it ) 00290 { 00291 if( login->currentText() == *it ) 00292 { 00293 // Move this entry to the beginning of the list 00294 values.remove( *it ); 00295 values.prepend( *it ); 00296 00297 add_item = false; 00298 break; 00299 } 00300 } 00301 if( add_item ) 00302 { 00303 values.prepend( login->currentText() ); 00304 login->insertItem( login->currentText() ); 00305 } 00306 rioQt->getConfig()->setUsersList( values ); 00307 rioQt->getConfig()->writeSettings(); 00308 }
QComboBox* ConnectWindow::host [private] |
Definition at line 32 of file ConnectWindow.h.
QComboBox* ConnectWindow::login [private] |
Definition at line 33 of file ConnectWindow.h.
QLineEdit* ConnectWindow::password [private] |
Definition at line 34 of file ConnectWindow.h.
RioQt* ConnectWindow::rioQt [private] |
Definition at line 38 of file ConnectWindow.h.
QComboBox* ConnectWindow::type [private] |
Definition at line 35 of file ConnectWindow.h.
int ConnectWindow::UpIntMonConnection [private] |
Definition at line 42 of file ConnectWindow.h.
QWorkspace* ConnectWindow::workspace [private] |
Definition at line 37 of file ConnectWindow.h.