editxlinkdialog.cpp
author insilmaril
Tue, 04 Sep 2007 13:53:33 +0000
changeset 596 97b9507f5e2b
parent 382 8b0ab4c0f767
child 599 e1d06cd563da
permissions -rw-r--r--
Fixed broken xLink handling
insilmaril@382
     1
#include "editxlinkdialog.h"
insilmaril@382
     2
insilmaril@382
     3
#include <QColorDialog>
insilmaril@382
     4
insilmaril@382
     5
EditXLinkDialog::EditXLinkDialog (QWidget *parent):QDialog (parent)
insilmaril@382
     6
{
insilmaril@382
     7
	ui.setupUi (this);
insilmaril@382
     8
insilmaril@382
     9
	delink=false;
insilmaril@382
    10
	xlo=false;
insilmaril@382
    11
	selection=NULL;
insilmaril@382
    12
insilmaril@382
    13
	connect ( ui.widthBox, SIGNAL (valueChanged( int)), this, SLOT (widthChanged (int)));
insilmaril@382
    14
	connect ( ui.colorButton, SIGNAL (clicked( )), this, SLOT (colorButtonPressed()));
insilmaril@382
    15
	connect ( ui.setColorHeadingButton, SIGNAL (clicked( )), this, SLOT (setColorHeadingButtonPressed()));
insilmaril@382
    16
	connect ( ui.deleteButton, SIGNAL (clicked( )), this, SLOT (deleteButtonPressed()));
insilmaril@382
    17
}
insilmaril@382
    18
insilmaril@382
    19
void EditXLinkDialog::deleteButtonPressed()
insilmaril@382
    20
{
insilmaril@382
    21
	delink=true;
insilmaril@382
    22
	accept();
insilmaril@382
    23
}
insilmaril@382
    24
insilmaril@382
    25
bool EditXLinkDialog::deleteXLink()
insilmaril@382
    26
{
insilmaril@382
    27
	return delink;
insilmaril@382
    28
}	
insilmaril@382
    29
insilmaril@382
    30
insilmaril@382
    31
void EditXLinkDialog::widthChanged( int  w)
insilmaril@382
    32
{
insilmaril@382
    33
	xlo->setWidth(w);
insilmaril@382
    34
}
insilmaril@382
    35
insilmaril@382
    36
void EditXLinkDialog::setXLink( XLinkObj * xo)
insilmaril@382
    37
{
insilmaril@382
    38
	xlo=xo;
insilmaril@382
    39
	ui.colorButton->setPaletteBackgroundColor (xlo->getColor() );
insilmaril@382
    40
	ui.widthBox->setValue(xlo->getWidth());
insilmaril@382
    41
}
insilmaril@382
    42
insilmaril@382
    43
void EditXLinkDialog::setSelection(LinkableMapObj *s)
insilmaril@382
    44
{
insilmaril@382
    45
	selection=s;
insilmaril@382
    46
}
insilmaril@382
    47
insilmaril@382
    48
void EditXLinkDialog::colorButtonPressed()
insilmaril@382
    49
{
insilmaril@382
    50
	if (xlo)
insilmaril@382
    51
	{	
insilmaril@382
    52
		QColor col = QColorDialog::getColor(xlo->getColor(), this );
insilmaril@382
    53
		if ( !col.isValid() ) return;
insilmaril@382
    54
		xlo->setColor( col );
insilmaril@382
    55
		ui.colorButton->setPaletteBackgroundColor (col);
insilmaril@382
    56
	}
insilmaril@382
    57
}
insilmaril@382
    58
insilmaril@382
    59
void EditXLinkDialog::setColorHeadingButtonPressed()
insilmaril@382
    60
{
insilmaril@382
    61
	if (xlo)
insilmaril@382
    62
	{	
insilmaril@382
    63
		if (selection && 
insilmaril@382
    64
			(typeid(*selection) == typeid(BranchObj)) || 
insilmaril@382
    65
			(typeid(*selection) == typeid(MapCenterObj))  )
insilmaril@382
    66
		{
insilmaril@382
    67
			QColor col=((BranchObj*)(selection))->getColor();
insilmaril@382
    68
			xlo->setColor(col);
insilmaril@382
    69
			ui.colorButton->setPaletteBackgroundColor (col);
insilmaril@382
    70
		}
insilmaril@382
    71
	}
insilmaril@382
    72
}
insilmaril@382
    73
insilmaril@382
    74
bool EditXLinkDialog::useSettingsGlobal ()
insilmaril@382
    75
{
insilmaril@382
    76
	return ui.useSettings->isChecked();
insilmaril@382
    77
}