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