示例#1
0
void GraphPropertiesWidget::on__graphDelete_clicked()
{
    bool createNewGraph = false;
    bool isActive = false;

    if( _graph == _mainWindow->graph() )
    {
        isActive = true;
    }

    GraphDocument* gd = qobject_cast<GraphDocument*>( _graph->parent() );

    if( gd->size() == 1 )
    {
        createNewGraph = true;
    }


    if( isActive ) emit updateNeeded();
    radio()->group()->removeButton( radio() );


    /*! remove this graph from the document. */
    emit removeGraph();

    if( createNewGraph )
    {
        emit addGraph( i18n( "Untitled0" ) );
    }

    deleteLater();
}
示例#2
0
GraphPropertiesWidget::GraphPropertiesWidget( Graph* g, QWidget* parent )
    : KButtonGroup( parent )
{
    setupUi( this );
    _mainWindow = ( NodeEditor* ) parent;
    //! do not lock here, it will create a racing condition.

    _graph = g;
    _graphName->setText( _graph->name() );
    _graphEdgeColor->setColor( _graph->edgeDefaultColor() );
    _graphNodeColor->setColor( _graph->nodeDefaultColor() );
    _graphAutomate->setChecked( _graph->automate() );
    _graphOriented->setChecked( _graph->directed() );
    _graphVisible->setChecked( ! _graph->readOnly() );
    _activateGraph->setChecked( true );
    _showEdgeNames->setChecked( _graph->edgeNameVisibility() );
    _showEdgeValues->setChecked( _graph->edgeValueVisibility() );
    _showNodeNames->setChecked( _graph->nodeNameVisibility() );
    _showNodeValues->setChecked( _graph->nodeValueVisibility() );

    _editWidget->setVisible( _activateGraph->isChecked() );

    GraphDocument* gDocument = qobject_cast<GraphDocument*>( g->parent() );
    connect( this, SIGNAL(addGraph(QString)), gDocument, SLOT(addGraph(QString)) );
    connect( this, SIGNAL(removeGraph()), g, SLOT(remove()) );

    connect( _graphEdgeColor, SIGNAL(activated(QColor)), this, SLOT(setEdgeDefaultColor(QColor)) );
    connect( _graphNodeColor, SIGNAL(activated(QColor)), this, SLOT(setNodeDefaultColor(QColor)) );

    connect( this, SIGNAL(edgeColorsChanged(QString)),      g, SLOT(setEdgesColor(QString)) );
    connect( this, SIGNAL(nodeColorsChanged(QString)),      g, SLOT(setNodesColor(QString)) );
    connect( this, SIGNAL(edgeDefaultColorSetted(QString)), g, SLOT(setEdgeDefaultColor(QString)) );
    connect( this, SIGNAL(nodeDefaultColorSetted(QString)), g, SLOT(setNodeDefaultColor(QString)) );


    connect( _showEdgeNames,  SIGNAL(toggled(bool)), g, SLOT(setEdgeNameVisibility(bool)) );
    connect( _showEdgeValues, SIGNAL(toggled(bool)), g, SLOT(setEdgeValueVisibility(bool)) );
    connect( _showNodeNames,  SIGNAL(toggled(bool)), g, SLOT(setNodeNameVisibility(bool)) );
    connect( _showNodeValues, SIGNAL(toggled(bool)), g, SLOT(setNodeValueVisibility(bool)) );

    connect( _graphName,      SIGNAL(textChanged(QString)), g, SLOT(setName(QString)) );

    connect( _graphOriented, SIGNAL(toggled(bool)), g, SLOT(setDirected(bool)) );
    connect( _graphAutomate, SIGNAL(toggled(bool)), g, SLOT(setAutomate(bool)) );

}
示例#3
0
LoadGraphWindow::LoadGraphWindow( QWidget* parent )
{
	setModal( true );
	resize( 600,250 );
	setWindowTitle( tr( "Load graph from database" ) );

	loadButton = createButton( tr( "Load" ), SLOT( loadGraph() ) );
	removeButton = createButton( tr( "Remove" ), SLOT( removeGraph() ) );
	renameButton = createButton( tr( "Rename" ), SLOT( renameGraph() ) );

	QPushButton* cancelButton = new QPushButton( tr( "Cancel" ) );
	cancelButton->setFocusPolicy( Qt::NoFocus );
	connect( cancelButton, SIGNAL( clicked() ), this, SLOT( close() ) );

	numberOfGraphs = new QLabel;

	graphList << tr( "ID" ) << tr( "Name" ) << tr( "No. of layouts" ) << tr( "No. of nodes" ) << tr( "No. of edges" );
	graphsTable = new QTableWidget( this );
	graphsTable->setSelectionBehavior( QAbstractItemView::SelectRows );
	graphsTable->setRowCount( 0 );
	graphsTable->setColumnCount( 5 );
	graphsTable->setHorizontalHeaderLabels( graphList );
	graphsTable->horizontalHeader()->setResizeMode( 0, QHeaderView::Interactive );
	graphsTable->horizontalHeader()->setResizeMode( 1, QHeaderView::Stretch );
	graphsTable->horizontalHeader()->setResizeMode( 2, QHeaderView::ResizeToContents );
	graphsTable->horizontalHeader()->setResizeMode( 3, QHeaderView::ResizeToContents );
	graphsTable->horizontalHeader()->setResizeMode( 4, QHeaderView::ResizeToContents );
	graphsTable->verticalHeader()->hide();
	graphsTable->setShowGrid( true );

	createGraphTable();

	QHBoxLayout* buttonsLayout = new QHBoxLayout;
	buttonsLayout->addStretch();
	buttonsLayout->addWidget( loadButton );
	buttonsLayout->addWidget( renameButton );
	buttonsLayout->addWidget( removeButton );
	buttonsLayout->addWidget( cancelButton );

	QGridLayout* mainLayout = new QGridLayout;
	mainLayout->addWidget( graphsTable, 3, 0, 1, 3 );
	mainLayout->addWidget( numberOfGraphs, 4, 0, 1, 3 );
	mainLayout->addLayout( buttonsLayout, 5, 0, 1, 3 );
	setLayout( mainLayout );
}