void LoadGraphWindow::renameGraph() { qlonglong graphID; Manager::GraphManager* manager = Manager::GraphManager::getInstance(); Model::DB* db = manager->getDB(); bool ok; if ( graphsTable->rowCount() > 0 ) { graphID = graphsTable->item( graphsTable->currentRow(), 0 )->text().toLongLong(); qDebug() << "[QOSG::LoadGraphWindow::renameGraph] Selected graph ID: " << graphID; QString newGraphName = QInputDialog::getText( this, tr( "New graph name" ), tr( "Enter new graph name:" ), QLineEdit::Normal, "", &ok ); if ( ok && !newGraphName.isEmpty() ) { Model::GraphDAO::setGraphName( graphID, newGraphName, db->tmpGetConn() ); createGraphTable(); this->repaint(); this->update(); } else { qDebug() << "[QOSG::LoadGraphWindow::renameGraph] Input dialog canceled"; } } else { qDebug() << "[QOSG::LoadGraphWindow::removeGraph] There are no graphs saved in DB."; } }
void LoadGraphWindow::removeGraph() { qlonglong graphID; Manager::GraphManager* manager = Manager::GraphManager::getInstance(); Model::DB* db = manager->getDB(); if ( graphsTable->rowCount() > 0 ) { graphID = graphsTable->item( graphsTable->currentRow(), 0 )->text().toLongLong(); qDebug() << "[QOSG::LoadGraphWindow::removeGraph] Selected graph ID: " << graphID; QMessageBox msgBox; msgBox.setText( "Do you want to remove selected graph and all its parts from database?" ); msgBox.setStandardButtons( QMessageBox::Ok | QMessageBox::Cancel ); msgBox.setDefaultButton( QMessageBox::Ok ); int ret = msgBox.exec(); if ( ret == QMessageBox::Ok ) { Model::GraphDAO::removeGraph( graphID, db->tmpGetConn() ); createGraphTable(); this->repaint(); this->update(); } } else { qDebug() << "[QOSG::LoadGraphWindow::lremoveGraph] There are no graphs saved in DB."; } }
void OptionsWindow::saveNodeTypes( TreeItem* index ) { //nacitanie typov grafu Manager::GraphManager* manager = Manager::GraphManager::getInstance(); QMap<qlonglong, Data::Type*>* types = manager->getActiveGraph()->getTypes(); for ( int i=0; i < index->childCount(); i++ ) { TreeItem* root = index->child( i ); //ak je root typov grafu if ( root->data( 0 ) == "Node Types" ) { //pre kazdy uloz data for ( int j=0; j< root->childCount(); j++ ) { TreeItem* item = root->child( j ); Data::Type* type = types->value( item->data( 2 ).toLongLong() ); QMap<QString, QString>* settings = type->getSettings(); QList<QString> atributes = item->data( 1 ).toString().split( ";" ); for ( int k=0; k<atributes.length(); k++ ) { QList<QString> atribute = atributes[k].split( "," ); settings->insert( atribute[0],atribute[1] ); } } } } }
void SelectLayoutWindow::createLayoutTable() { Manager::GraphManager * manager = Manager::GraphManager::getInstance(); Model::DB * db = manager->getDB(); bool error = false; qlonglong layoutsCount, row; QString name; QMap<qlonglong, QString>::iterator iterLayout; qlonglong layoutID; QMap<qlonglong, QString> layouts = Model::GraphLayoutDAO::getLayoutsNames(graphID, db->tmpGetConn(), &error); layoutsCount = layouts.count(); numberOfLayouts->setText(tr("%1 layout(s) found").arg(layoutsCount)); layoutsTable->setRowCount(layoutsCount); for(iterLayout = layouts.begin(), row=0; iterLayout != layouts.end(); ++iterLayout, row++) { layoutID = iterLayout.key(); name = layouts.value(layoutID); QTableWidgetItem *itemID = new QTableWidgetItem(tr("%1").arg(layoutID)); QTableWidgetItem *itemName = new QTableWidgetItem(name); layoutsTable->setItem(row, 0, itemID); layoutsTable->setItem(row, 1, itemName); } if(layoutsTable->rowCount() > 0) layoutsTable->selectRow(0); }
void SelectLayoutWindow::removeLayout() { qlonglong layoutID; Manager::GraphManager * manager = Manager::GraphManager::getInstance(); Model::DB * db = manager->getDB(); if(layoutsTable->rowCount() > 0) { layoutID = layoutsTable->item(layoutsTable->currentRow(), 0)->text().toLongLong(); qDebug() << "[QOSG::SelectLayoutWindow::removeLayout] Selected layout ID: " << layoutID; QMessageBox msgBox; msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Ok); if(layoutsTable->rowCount() == 1) { msgBox.setText("There is only one layout in this graph!"); msgBox.setInformativeText("Do you really want to remove this layout? (It will also remove the graph)"); int ret = msgBox.exec(); if(ret == QMessageBox::Ok) { Model::GraphDAO::removeGraph(graphID, db->tmpGetConn()); createLayoutTable(); this->repaint(); this->update(); qDebug() << "[QOSG::SelectLayoutWindow::removeLayout] Graph no. " << graphID << " was removed from database"; } } else { msgBox.setText("Do you want to remove selected layout from database?"); int ret = msgBox.exec(); if(ret == QMessageBox::Ok) { Model::GraphLayoutDAO::removeLayout(graphID, layoutID, db->tmpGetConn()); createLayoutTable(); this->repaint(); this->update(); qDebug() << "[QOSG::SelectLayoutWindow::removeLayout] Layout no. " << layoutID << " was removed from database"; } } } else { qDebug() << "[QOSG::SelectLayoutWindow::removeLayout] There are no layouts for graph saved in DB."; } }
void LoadGraphWindow::createGraphTable() { Manager::GraphManager* manager = Manager::GraphManager::getInstance(); Model::DB* db = manager->getDB(); bool error = false; qlonglong id; int graphsCount,row; QList<qlonglong> nodes; QList<qlonglong> edges; QList<qlonglong> layouts; QString name; QMap<qlonglong, Data::Graph*>::iterator iterGraph; QMap<qlonglong, Data::Graph*> graphs = Model::GraphDAO::getGraphs( db->tmpGetConn(), &error ); graphsCount = graphs.count(); numberOfGraphs->setText( tr( "%1 graph(s) found" ).arg( graphsCount ) ); graphsTable->setRowCount( graphsCount ); nodes = Model::NodeDAO::getListOfNodes( db->tmpGetConn(), &error ); edges = Model::EdgeDAO::getListOfEdges( db->tmpGetConn(), &error ); layouts = Model::GraphLayoutDAO::getListOfLayouts( db->tmpGetConn(), &error ); qDebug() << "[QOSG::LoadGraphWindow::createGraphTable] total number of nodes in DB: " << nodes.count(); qDebug() << "[QOSG::LoadGraphWindow::createGraphTable] total number of edges in DB: " << edges.count(); qDebug() << "[QOSG::LoadGraphWindow::createGraphTable] total number of layouts in DB: " << layouts.count(); for ( iterGraph = graphs.begin(), row=0; iterGraph != graphs.end(); ++iterGraph, row++ ) { id = iterGraph.key(); name = graphs.value( id )->getName(); QTableWidgetItem* itemID = new QTableWidgetItem( tr( "%1" ).arg( id ) ); QTableWidgetItem* itemName = new QTableWidgetItem( name ); QTableWidgetItem* itemNumberOfLayouts = new QTableWidgetItem( tr( "%1" ).arg( layouts.count( id ) ) ); QTableWidgetItem* itemNumberOfNodes = new QTableWidgetItem( tr( "%1" ).arg( nodes.count( id ) ) ); QTableWidgetItem* itemNumberOfEdges = new QTableWidgetItem( tr( "%1" ).arg( edges.count( id ) ) ); graphsTable->setItem( row, 0, itemID ); graphsTable->setItem( row, 1, itemName ); graphsTable->setItem( row, 2, itemNumberOfLayouts ); graphsTable->setItem( row, 3, itemNumberOfNodes ); graphsTable->setItem( row, 4, itemNumberOfEdges ); } if ( graphsTable->rowCount() > 0 ) { graphsTable->selectRow( 0 ); } }
void TreeModel::addNodesToList(QList<TreeItem*> * parents) { //vytvori sa nova korenova polozka pre typy uzlov QList<QVariant> * columnData = new QList<QVariant>(); columnData->append("Node Types"); TreeItem * nodeRoot = new TreeItem(*columnData,parents->last()); parents->last()->appendChild(nodeRoot); //nacita sa zoznam typov uzlov Manager::GraphManager * manager = Manager::GraphManager::getInstance(); QMap<qlonglong, Data::Type*> * nodes = manager->getActiveGraph()->getTypes(); QMap<qlonglong, Data::Type*>::iterator iterator; //typy uzlyovsa postupne prechadzaju for (iterator = nodes->begin(); iterator != nodes->end(); ++iterator) { //vytvori sa nova polozka a vlozi sa nazov polozky QString name = iterator.value()->getName(); columnData = new QList<QVariant>(); columnData->append(name); //nacitaju sa data typu uzla Data::Type * node = static_cast<Data::Type*>(iterator.value()); QMap<QString, QString> * settings = node->getSettings(); QMap<QString, QString>::iterator settingsIterator; QString data; //postupne sa data zlozia for (settingsIterator = settings->begin(); settingsIterator != settings->end(); settingsIterator++) { if (settingsIterator != settings->begin()) data.append(";"); data.append(QString("%1,%2").arg(settingsIterator.key()).arg(settingsIterator.value())); } //nakoniec sa data prilozia danemu typu uzla columnData->append(data); columnData->append(iterator.key()); nodeRoot->appendChild(new TreeItem(*columnData,nodeRoot)); } }
void SelectLayoutWindow::loadLayout() { qlonglong layoutID; if(layoutsTable->rowCount() > 0) { layoutID = layoutsTable->item(layoutsTable->currentRow(), 0)->text().toLongLong(); Manager::GraphManager * manager = Manager::GraphManager::getInstance(); Model::DB * db = manager->getDB(); bool error = false; qDebug() << "[QOSG::SelectLayoutWindow::loadLayout] Selected layout ID: " << layoutID; manager->loadGraphFromDB(graphID, layoutID); this->close(); } else { qDebug() << "[QOSG::SelectLayoutWindow::loadLayout] There are no layouts for graph saved in DB."; } }