Example #1
0
void Schema::resetViewsVertically2()
{
    populateSchemaViews();
    QList<View*> view_list = getViewList();
    foreach(View *view, view_list) {
        if(mainwin->getSearchBox()->isVisible())
            view->getSearchTerm(mainwin->getSearchBox()->text());
        view->verticalPosition2();
    }
    scene()->setSceneRect(QRectF());
}
Example #2
0
void Schema::populateSchemaViews()
{
    foreach (View *view, getViewList())
        delete view;
    this->view_list.clear();

    QList<View*> view_list;
    QSqlQuery *view_query = new QSqlQuery(parent_database->getDatabaseConnection());
    QString view_query_string = "SELECT 1, viewname FROM pg_views WHERE schemaname='"+this->getName()+"' ORDER BY 1,2";
    view_query->exec(view_query_string);
    setViewCount(view_query->size());
    if(view_query->lastError().isValid())
    {
        QMessageBox *error_message = new QMessageBox(QMessageBox::Critical,
                                    tr("Database error"),
                                    tr("Unable to retrieve schema views.\n"
                                    "Check your database connection or permissions.\n"), QMessageBox::Cancel,0,Qt::Dialog);
        error_message->setWindowModality(Qt::NonModal);
        error_message->show();
        return;
    }
    while (view_query->next())
    {
        QString view_name = view_query->value(1).toString();
        View *view;
        if(view_query->value(0).toInt() == 1) {
            view = new View(parent_database, this, view_name, view_list.size(), QColor(100,50,50));
        }
        else
        {
            return;
        }

        view->setSearched(true);
        if(mainwin->isColumnView())
            view->verticalPosition2();
        else
            view->defaultPosition();

        QObject::connect(mainwin->getSearchBox(), SIGNAL(textChanged(QString)), view, SLOT(getSearchTerm(QString)));
        QObject::connect(mainwin, SIGNAL(showColumnView()), view, SLOT(verticalPosition2()));
        QObject::connect(view, SIGNAL(expandView(Database *, Schema *, View*)), mainwin, SLOT(showViewView(Database *, Schema *, View*)));
        QObject::connect(view, SIGNAL(dropView(Database *, Schema *, View*)), mainwin, SLOT(dropView(Database *, Schema *, View*)));

        view_list.append(view);
        if(!mainwin->view_completer_list.contains(view_name))
            mainwin->view_completer_list.append(view_name);
    }
    setViewList(view_list);
}