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