Ejemplo n.º 1
0
void SQLToolWidget::browseDatabase(void)
{
  try
  {    
    //If the selected database is already being browse do not create another explorer instance
    if(database_cmb->currentIndex() > 0 /* && !databases_tbw->findChild<DatabaseExplorerWidget *>(database_cmb->currentText())*/)
    {
      Connection conn=(*reinterpret_cast<Connection *>(connections_cmb->itemData(connections_cmb->currentIndex()).value<void *>()));
      DatabaseExplorerWidget *db_explorer_wgt=new DatabaseExplorerWidget;

      db_explorer_wgt->setObjectName(database_cmb->currentText());
      conn.setConnectionParam(Connection::PARAM_DB_NAME, database_cmb->currentText());
      db_explorer_wgt->setConnection(conn);
      db_explorer_wgt->listObjects();

      databases_tbw->addTab(db_explorer_wgt, database_cmb->currentText());
      databases_tbw->setCurrentWidget(db_explorer_wgt);

      connect(db_explorer_wgt, SIGNAL(s_dataGridOpenRequested(QString,QString,QString,bool)), this, SLOT(openDataGrid(QString,QString,QString,bool)));
      connect(db_explorer_wgt, SIGNAL(s_databaseDropRequested(QString)), this, SLOT(dropDatabase(QString)));
      connect(db_explorer_wgt, SIGNAL(s_sqlExecutionRequested()), this, SLOT(addSQLExecutionTab()));
      connect(db_explorer_wgt, SIGNAL(s_snippetShowRequested(QString)), this, SLOT(showSnippet(QString)));

      /* Forcing the signal s_sqlExecutionRequested to be emitted to properly register the
       new tab on the map of sql panes related to the database explorer */
      db_explorer_wgt->runsql_tb->click();
    }
  }
  catch(Exception &e)
  {
    throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__,&e);
  }
}
Ejemplo n.º 2
0
void SQLToolWidget::showSnippet(const QString &snip)
{
  SQLExecutionWidget *sql_exec_wgt=nullptr;

  if(sql_exec_tbw->count()==0)
    addSQLExecutionTab();

  sql_exec_wgt=dynamic_cast<SQLExecutionWidget *>(sql_exec_tbw->currentWidget());
  sql_exec_wgt->sql_cmd_txt->setPlainText(snip);
}
Ejemplo n.º 3
0
void SQLToolWidget::showSnippet(const QString &snip)
{
	SQLExecutionWidget *sql_exec_wgt=nullptr;

	if(sql_exec_tbw->count()==0)
		addSQLExecutionTab();

	sql_exec_wgt=dynamic_cast<SQLExecutionWidget *>(sql_exec_tbw->currentWidget());

	QTextCursor cursor=sql_exec_wgt->sql_cmd_txt->textCursor();
	cursor.movePosition(QTextCursor::End);

	sql_exec_wgt->sql_cmd_txt->appendPlainText(snip);
	sql_exec_wgt->sql_cmd_txt->setTextCursor(cursor);
}
Ejemplo n.º 4
0
void SQLToolWidget::browseDatabase(void)
{
  try
  {
    Connection conn=(*reinterpret_cast<Connection *>(connections_cmb->itemData(connections_cmb->currentIndex()).value<void *>()));
    DatabaseExplorerWidget *db_explorer_wgt=new DatabaseExplorerWidget;

    conn.setConnectionParam(Connection::PARAM_DB_NAME, database_cmb->currentText());
    db_explorer_wgt->setConnection(conn);
    db_explorer_wgt->listObjects();

    databases_tbw->addTab(db_explorer_wgt, database_cmb->currentText());
    databases_tbw->setCurrentWidget(db_explorer_wgt);

    connect(db_explorer_wgt, SIGNAL(s_dataGridOpenRequested(QString,QString,bool)), this, SLOT(openDataGrid(QString,QString,bool)));
    connect(db_explorer_wgt, SIGNAL(s_sqlExecutionRequested()), this, SLOT(addSQLExecutionTab()));
    connect(db_explorer_wgt, SIGNAL(s_snippetShowRequested(QString)), this, SLOT(showSnippet(QString)));
  }
  catch(Exception &e)
  {
    throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__,&e);
  }
}
Ejemplo n.º 5
0
void SQLToolWidget::browseDatabase(void)
{
	try
	{
		//If the selected database is already being browse do not create another explorer instance
		if(database_cmb->currentIndex() > 0)
		{
			Connection conn=(*reinterpret_cast<Connection *>(connections_cmb->itemData(connections_cmb->currentIndex()).value<void *>()));
			QString maintainance_db=conn.getConnectionParam(Connection::PARAM_DB_NAME);
			DatabaseExplorerWidget *db_explorer_wgt=new DatabaseExplorerWidget;

			db_explorer_wgt->setObjectName(database_cmb->currentText());
			conn.setConnectionParam(Connection::PARAM_DB_NAME, database_cmb->currentText());
			db_explorer_wgt->setConnection(conn, maintainance_db);
			db_explorer_wgt->listObjects();

			databases_tbw->addTab(db_explorer_wgt, database_cmb->currentText());
			databases_tbw->setCurrentWidget(db_explorer_wgt);

			connect(db_explorer_wgt, SIGNAL(s_databaseDropped(QString)), this, SLOT(handleDatabaseDropped(QString)));
			connect(db_explorer_wgt, SIGNAL(s_sqlExecutionRequested()), this, SLOT(addSQLExecutionTab()));
			connect(db_explorer_wgt, SIGNAL(s_snippetShowRequested(QString)), this, SLOT(showSnippet(QString)));
			connect(db_explorer_wgt, SIGNAL(s_sourceCodeShowRequested(QString)), sourcecode_txt, SLOT(setPlainText(QString)));

			connect(attributes_tb, SIGNAL(toggled(bool)), db_explorer_wgt->attributes_wgt, SLOT(setVisible(bool)));
			db_explorer_wgt->attributes_wgt->setVisible(attributes_tb->isChecked());

			/* Forcing the signal s_sqlExecutionRequested to be emitted to properly register the
			new tab on the map of sql panes related to the database explorer */
			db_explorer_wgt->runsql_tb->click();
		}
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__,&e);
	}
}