Esempio n. 1
0
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.";
	}
}
Esempio n. 2
0
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.";
	}
}
Esempio n. 3
0
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);
}
Esempio n. 4
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.";
	}
}
Esempio n. 5
0
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 );
	}
}
Esempio n. 6
0
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.";
	}
}