branchpropwindow.cpp
author insilmaril
Wed Apr 11 09:21:14 2007 +0000 (2007-04-11)
changeset 451 a76dcf52f15e
parent 421 5522d1da7e37
child 462 494a5b8c131e
permissions -rw-r--r--
Updated documentation about macros
insilmaril@421
     1
#include "branchpropwindow.h"
insilmaril@421
     2
insilmaril@440
     3
#include <QColorDialog>
insilmaril@440
     4
insilmaril@421
     5
#include "frameobj.h"
insilmaril@421
     6
insilmaril@421
     7
insilmaril@421
     8
BranchPropertyWindow::BranchPropertyWindow (QWidget *parent):QDialog(parent)
insilmaril@421
     9
{
insilmaril@421
    10
	ui.setupUi (this);
insilmaril@421
    11
insilmaril@421
    12
	branch=NULL;
insilmaril@421
    13
	mapEditor=NULL;
insilmaril@421
    14
insilmaril@440
    15
	ui.tabWidget->setEnabled(false);
insilmaril@440
    16
insilmaril@440
    17
	penColor=QColor (Qt::black);
insilmaril@440
    18
	brushColor=QColor (Qt::black);
insilmaril@440
    19
    QPixmap pix( 16,16);
insilmaril@440
    20
    pix.fill (penColor);
insilmaril@440
    21
	ui.framePenColorButton->setPixmap (pix);
insilmaril@440
    22
	ui.frameBrushColorButton->setPixmap (pix);
insilmaril@440
    23
insilmaril@440
    24
	connect ( 
insilmaril@440
    25
		ui.framePenColorButton, SIGNAL (clicked()), 
insilmaril@440
    26
		this, SLOT (framePenColorClicked()));
insilmaril@440
    27
	connect ( 
insilmaril@440
    28
		ui.frameBrushColorButton, SIGNAL (clicked()), 
insilmaril@440
    29
		this, SLOT (frameBrushColorClicked()));
insilmaril@440
    30
	connect ( 
insilmaril@440
    31
		ui.frameTypeCombo, SIGNAL (currentIndexChanged( int)), 
insilmaril@440
    32
		this, SLOT (frameTypeChanged (int)));
insilmaril@440
    33
	connect ( 
insilmaril@440
    34
		ui.hideLinkIfUnselected, SIGNAL (stateChanged( int)), 
insilmaril@440
    35
		this, SLOT (linkHideUnselectedChanged (int)));
insilmaril@421
    36
}
insilmaril@421
    37
insilmaril@421
    38
void BranchPropertyWindow::setBranch (BranchObj *bo)
insilmaril@421
    39
{
insilmaril@421
    40
	branch=bo;
insilmaril@440
    41
	if (bo) 
insilmaril@440
    42
	{
insilmaril@440
    43
		ui.tabWidget->setEnabled (true);
insilmaril@421
    44
insilmaril@440
    45
		// Frame
insilmaril@440
    46
		FrameType t=branch->getFrameType();
insilmaril@440
    47
		if (t==NoFrame)
insilmaril@440
    48
		{
insilmaril@440
    49
			ui.frameTypeCombo->setCurrentIndex (0);
insilmaril@440
    50
			penColor=Qt::white;
insilmaril@440
    51
			brushColor=Qt::white;
insilmaril@440
    52
			ui.colorGroupBox->setEnabled (false);
insilmaril@440
    53
		} else	
insilmaril@440
    54
		{
insilmaril@440
    55
			penColor=bo->getFramePenColor();
insilmaril@440
    56
			brushColor=bo->getFrameBrushColor();
insilmaril@440
    57
			QPixmap pix( 16,16);
insilmaril@440
    58
			pix.fill (penColor);
insilmaril@440
    59
			ui.frameBrushColorButton->setPixmap (pix);
insilmaril@440
    60
			pix.fill (brushColor);
insilmaril@440
    61
			ui.frameBrushColorButton->setPixmap (pix);
insilmaril@440
    62
			ui.colorGroupBox->setEnabled (true);
insilmaril@440
    63
insilmaril@440
    64
			switch (t)
insilmaril@440
    65
			{
insilmaril@440
    66
				case Rectangle: 
insilmaril@440
    67
					ui.frameTypeCombo->setCurrentIndex (1);
insilmaril@440
    68
					break;
insilmaril@440
    69
				case Ellipse: 
insilmaril@440
    70
					ui.frameTypeCombo->setCurrentIndex (2);
insilmaril@440
    71
					break;
insilmaril@440
    72
				default: 
insilmaril@440
    73
					break;
insilmaril@440
    74
			}
insilmaril@440
    75
		}	
insilmaril@440
    76
		
insilmaril@440
    77
		// Link
insilmaril@440
    78
		if (branch->getHideLinkUnselected())
insilmaril@440
    79
			ui.hideLinkIfUnselected->setCheckState (Qt::Checked);
insilmaril@440
    80
		else	
insilmaril@440
    81
			ui.hideLinkIfUnselected->setCheckState (Qt::Unchecked);
insilmaril@440
    82
	} else
insilmaril@421
    83
	{
insilmaril@440
    84
		ui.tabWidget->setEnabled (false);
insilmaril@421
    85
	}
insilmaril@421
    86
}
insilmaril@421
    87
insilmaril@421
    88
void BranchPropertyWindow::setMapEditor (MapEditor *me)
insilmaril@421
    89
{
insilmaril@440
    90
	mapEditor=me;
insilmaril@440
    91
	if (mapEditor) 
insilmaril@440
    92
		setBranch (mapEditor->getSelectedBranch() );
insilmaril@440
    93
	else
insilmaril@440
    94
		ui.tabWidget->setEnabled (false);
insilmaril@440
    95
		
insilmaril@421
    96
}
insilmaril@421
    97
insilmaril@421
    98
void BranchPropertyWindow::frameTypeChanged (int i)
insilmaril@421
    99
{
insilmaril@421
   100
	if (mapEditor)
insilmaril@421
   101
		switch (i)
insilmaril@421
   102
		{
insilmaril@440
   103
			case 0: mapEditor->setFrameType (NoFrame); break;
insilmaril@440
   104
			case 1: mapEditor->setFrameType (Rectangle); break;
insilmaril@440
   105
			case 2: mapEditor->setFrameType (Ellipse); break;
insilmaril@421
   106
		}
insilmaril@421
   107
}
insilmaril@421
   108
insilmaril@440
   109
void BranchPropertyWindow::framePenColorClicked()
insilmaril@440
   110
{
insilmaril@440
   111
	if (mapEditor) 
insilmaril@440
   112
	{	
insilmaril@440
   113
		QColor col = QColorDialog::getColor( penColor, this );
insilmaril@440
   114
		if ( col.isValid() ) 
insilmaril@440
   115
		{
insilmaril@440
   116
			penColor=col;
insilmaril@440
   117
			mapEditor->setFramePenColor (penColor);
insilmaril@440
   118
		}	
insilmaril@440
   119
	}
insilmaril@440
   120
}
insilmaril@440
   121
insilmaril@440
   122
void BranchPropertyWindow::frameBrushColorClicked()
insilmaril@440
   123
{
insilmaril@440
   124
	if (mapEditor) 
insilmaril@440
   125
	{
insilmaril@440
   126
		QColor col = QColorDialog::getColor( brushColor, this );
insilmaril@440
   127
		if ( col.isValid() ) 
insilmaril@440
   128
		{
insilmaril@440
   129
			brushColor=col;
insilmaril@440
   130
			mapEditor->setFrameBrushColor (brushColor);
insilmaril@440
   131
		}	
insilmaril@440
   132
	}	
insilmaril@440
   133
}
insilmaril@440
   134
insilmaril@421
   135
void BranchPropertyWindow::linkHideUnselectedChanged (int i)
insilmaril@421
   136
{
insilmaril@421
   137
	if (!branch) return;
insilmaril@421
   138
	branch->setHideLinkUnselected(i);
insilmaril@421
   139
}
insilmaril@421
   140