void SQLToolWidget::disconnectFromDatabases(void) { try { Messagebox msg_box; msg_box.show(trUtf8("Warning"), trUtf8("<strong>ATTENTION:</strong> Disconnect from all databases will close any opened tab in this view! Do you really want to proceed?"), Messagebox::ALERT_ICON, Messagebox::YES_NO_BUTTONS); if(msg_box.result()==QDialog::Accepted) { database_cmb->clear(); connections_cmb->setEnabled(true); refresh_tb->setEnabled(false); while(databases_tbw->count() > 0) { databases_tbw->blockSignals(true); closeDatabaseExplorer(0); databases_tbw->blockSignals(false); } connections_cmb->setCurrentIndex(0); disconnect_tb->setEnabled(false); } } catch(Exception &e) { throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
SQLToolWidget::~SQLToolWidget(void) { databases_tbw->blockSignals(true); while(databases_tbw->count() > 0) closeDatabaseExplorer(0); }
void SQLToolWidget::handleDatabaseDropped(const QString &dbname) { try { //Closing tabs related to the database to be dropped for(int i=0; i < databases_tbw->count(); i++) { if(databases_tbw->tabText(i).remove('&') == dbname) { closeDatabaseExplorer(i); i=-1; } } connectToServer(); } catch(Exception &e) { throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void SQLToolWidget::disconnectFromServer(void) { try { database_cmb->clear(); connections_cmb->setEnabled(true); connect_tb->setEnabled(true); disconnect_tb->setEnabled(false); refresh_tb->setEnabled(false); while(databases_tbw->count() > 0) { databases_tbw->blockSignals(true); closeDatabaseExplorer(0); databases_tbw->blockSignals(false); } } catch(Exception &e) { throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void SQLToolWidget::dropDatabase(const QString &dbname) { Messagebox msg_box; msg_box.show(trUtf8("Warning"), trUtf8("<strong>CAUTION:</strong> You are about to drop the entire database <strong>%1</strong>! All data will be completely wiped out. Do you really want to proceed?").arg(dbname), Messagebox::ALERT_ICON, Messagebox::YES_NO_BUTTONS); if(msg_box.result()==QDialog::Accepted) { Connection *conn=reinterpret_cast<Connection *>(connections_cmb->itemData(connections_cmb->currentIndex()).value<void *>()); Connection aux_conn=(*conn); try { //Closing tabs related to the database to be dropped for(int i=0; i < databases_tbw->count(); i++) { if(databases_tbw->tabText(i)==dbname) { closeDatabaseExplorer(i); i=-1; } } aux_conn.connect(); aux_conn.executeDDLCommand(QString("DROP DATABASE \"%1\";").arg(dbname)); aux_conn.close(); connectToServer(); } catch(Exception &e) { throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } } }
SQLToolWidget::~SQLToolWidget(void) { while(databases_tbw->count() > 0) closeDatabaseExplorer(0); }