18 setWindowTitle(
"Database Configuration" );
19 setAttribute( Qt::WA_DeleteOnClose );
23 if ( currentHash.isEmpty() )
25 QMessageBox::information(
this,
26 tr(
"No master password" ),
27 tr(
"The Master Password has not been set." ) );
31 QBoxLayout* topbox =
new QVBoxLayout(
this );
32 topbox->setSpacing( 2 );
35 QLabel* banner =
us_banner( tr(
"Database List" ) );
36 topbox->addWidget( banner );
39 tr(
"(Doubleclick for details and set the default)" ), -1 );
40 topbox->addWidget( banner2 );
55 connect(
lw_entries, SIGNAL( itemDoubleClicked( QListWidgetItem* ) ),
56 SLOT (
select_db ( QListWidgetItem* ) ) );
58 QLabel* info =
us_banner( tr(
"Database Detailed Information" ) );
59 topbox->addWidget( info );
62 QGridLayout* details =
new QGridLayout();
65 QLabel* desc =
us_label(
"Database Description:" );
66 details->addWidget( desc, row, 0 );
72 QLabel* user =
us_label(
"DB Connection Name:" );
73 details->addWidget( user, row, 0 );
79 QLabel* password =
us_label(
"DB Password:" );
80 details->addWidget( password, row, 0 );
87 QLabel* DBname =
us_label(
"Database Name:" );
88 details->addWidget( DBname, row, 0 );
91 details->addWidget(
le_dbname, row++, 1 );
94 QLabel* host =
us_label(
"Host Address:" );
95 details->addWidget( host, row, 0 );
98 details->addWidget(
le_host, row++, 1 );
101 QLabel* investigator =
us_label(
"Investigator Email:" );
102 details->addWidget( investigator, row, 0 );
113 QLabel* investigator_pw =
us_label(
"Investigator Password:" );
114 details->addWidget( investigator_pw, row, 0 );
120 topbox->addLayout( details );
124 QGridLayout* buttons =
new QGridLayout();
129 buttons->addWidget(
pb_save, row, 0 );
134 buttons->addWidget(
pb_delete, row++, 1 );
140 QHBoxLayout* std_buttons =
new QHBoxLayout;
143 connect(
pb_reset, SIGNAL( clicked() ),
this, SLOT(
reset() ) );
147 connect( pb_help, SIGNAL( clicked() ),
this, SLOT(
help() ) );
148 std_buttons->addWidget( pb_help );
151 connect( pb_cancel, SIGNAL( clicked() ),
this, SLOT( close() ) );
152 std_buttons->addWidget( pb_cancel );
154 topbox->addLayout( buttons );
155 topbox->addLayout( std_buttons );
163 QString item = entry->text().remove(
" (default)" );
169 for (
int i = 0; i <
dblist.size(); i++ )
171 if ( item ==
dblist.at( i ).at( 0 ) )
180 QString cipher =
dblist.at( i ).at( 4 );
181 QString iv =
dblist.at( i ).at( 5 );
186 cipher =
dblist.at( i ).at( 7 );
187 iv =
dblist.at( i ).at( 8 );
199 QMessageBox::information(
this,
200 tr(
"Database Selected" ),
201 tr(
"The default database has been updated." ) );
217 QMessageBox::information(
this,
219 tr(
"Error making the DB connection.\n" ) );
224 QStringList q(
"get_user_info" );
228 int ID = db.value( 0 ).toInt();
229 QString fname = db.value( 1 ).toString();
230 QString lname = db.value( 2 ).toString();
231 int level = db.value( 5 ).toInt();
243 QMessageBox::information(
this,
245 tr(
"Please enter a Description before saving..." ) );
251 QMessageBox::information(
this,
253 tr(
"Please enter a User Name before saving..." ) );
259 QMessageBox::information(
this,
261 tr(
"Please enter a Password before saving..." ) );
267 QMessageBox::information(
this,
269 tr(
"Please enter a Database Name before saving..."));
273 if (
le_host->text().isEmpty() )
275 QMessageBox::information(
this,
277 tr(
"Please enter a Host Address (possibly 'localhost') "
278 "before saving..." ) );
284 QMessageBox::information(
this,
286 tr(
"Please enter an investigator email address "
287 "before saving..." ) );
293 QMessageBox::information(
this,
295 tr(
"Please enter an investigator password "
296 "before saving..." ) );
300 if (
uuid.isEmpty() )
318 bool updated =
false;
320 for (
int i = 0; i <
dblist.size(); i++ )
322 QStringList db =
dblist.at( i );
327 db.replace( 3,
le_host ->text() );
328 db.replace( 4, pw_list.at( 0 ) );
329 db.replace( 5, pw_list.at( 1 ) );
331 db.replace( 7, inv_pw.at( 0 ) );
332 db.replace( 8, inv_pw.at( 1 ) );
333 db.replace( 9,
uuid );
374 QString defaultDBname;
376 if ( defaultDB.size() > 0 ) defaultDBname = defaultDB.at( 0 );
378 for (
int i = 0; i <
dblist.size(); i++ )
380 QString desc =
dblist.at( i ).at( 0 );
381 QString display = desc;
383 if ( desc == defaultDBname ) display.append(
" (default)" );
385 QListWidgetItem* widget =
new QListWidgetItem( display );
388 if ( desc == current )
389 lw_entries->setCurrentItem( widget, QItemSelectionModel::Select );
416 showhelp->
show_help(
"database_config.html" );
421 for (
int i = 0; i <
dblist.size(); i++ )
423 QString desc =
dblist.at( i ).at( 0 );
428 if (
dblist.at( i ).at( 9 ) ==
"" )
430 QMessageBox::information(
this,
431 tr(
"Default Database Problem" ),
432 tr(
"The current database information has not been tested "
433 "for connectivity.\n"
434 "The default database has not been updated.") );
444 QMessageBox::information(
this,
445 tr(
"Default Database" ),
446 tr(
"The default database has been updated." ) );
451 QMessageBox::warning(
this,
452 tr(
"Default Database Problem" ),
453 tr(
"The description does not match any in the database list.\n"
454 "The default database has not been updated." ) );
462 for (
int i = 0; i <
dblist.size(); i++ )
464 QString desc =
dblist.at( i ).at( 0 );
475 if ( defaultDB.at( 0 ) == item )
480 QMessageBox::information(
this,
481 tr(
"Database Removed" ),
482 tr(
"The database has been removed." ) );
487 QMessageBox::warning(
this,
488 tr(
"Database Problem" ),
489 tr(
"The description does not match any in the database list.\n"
490 "The database has not been removed." ) );
495 if (
le_host ->text().isEmpty() ||
502 QMessageBox::warning(
this,
503 tr(
"Missing Data" ),
504 tr(
"Please fill in all fields before testing the connection." ) );
522 for (
int i = 0; i <
dblist.size(); i++ )
524 QString desc =
dblist.at( i ).at( 0 );
529 QStringList list =
dblist.at( i );
530 list.replace( 9,
uuid );
531 dblist.replace( i, list );
537 QMessageBox::information(
this,
538 tr(
"Database Connection" ),
539 tr(
"The connection was successful." ) );
544 QMessageBox::warning(
this,
545 tr(
"Database Connection" ),
546 tr(
"The connection failed.\n" ) + error );