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