statedialog.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "statedialog.h"
00014
00015
00016 #include <qlayout.h>
00017 #include <qlabel.h>
00018 #include <qlineedit.h>
00019 #include <qmultilineedit.h>
00020 #include <qgroupbox.h>
00021
00022
00023 #include <kiconloader.h>
00024 #include <klocale.h>
00025 #include <kfontdialog.h>
00026
00027
00028 #include "../umlview.h"
00029 #include "../statewidget.h"
00030 #include "../dialog_utils.h"
00031
00032 StateDialog::StateDialog( UMLView * pView, StateWidget * pWidget )
00033 : KDialogBase(IconList, i18n("Properties"), Ok | Apply | Cancel | Help, Ok, pView, "_STATEDIALOG_", true, true) {
00034 m_pActivityPage = 0;
00035 m_pView = pView;
00036 m_pStateWidget = pWidget;
00037 m_bChangesMade = false;
00038 setupPages();
00039 }
00040
00041 void StateDialog::slotOk() {
00042 applyPage( GeneralPage );
00043 applyPage( Activity_Page );
00044 applyPage( ColorPage );
00045 applyPage( FontPage );
00046 accept();
00047 }
00048
00049 void StateDialog::slotApply() {
00050 applyPage( (Page) activePageIndex() );
00051 }
00052
00053 void StateDialog::setupPages() {
00054 setupGeneralPage();
00055 if( m_pStateWidget -> getStateType() == StateWidget::Normal )
00056 setupActivityPage();
00057 setupColorPage();
00058 setupFontPage();
00059 }
00060
00061 void StateDialog::applyPage( Page page ) {
00062 m_bChangesMade = true;
00063 switch( page ) {
00064 case GeneralPage:
00065 m_pStateWidget -> setName( m_GenPageWidgets.nameLE -> text() );
00066 m_pStateWidget -> setDoc( m_GenPageWidgets.docMLE -> text() );
00067 break;
00068
00069 case Activity_Page:
00070 if( m_pActivityPage )
00071 m_pActivityPage -> updateActivities();
00072 break;
00073
00074 case ColorPage:
00075 m_pColorPage -> updateUMLWidget();
00076 break;
00077
00078 case FontPage:
00079 m_pStateWidget -> setFont( m_pChooser -> font() );
00080 break;
00081 }
00082 }
00083
00084 void StateDialog::setupGeneralPage() {
00085 QString types[ ] = { i18n("Initial state"), i18n("State"), i18n("End state") };
00086 StateWidget::StateType type = m_pStateWidget -> getStateType();
00087
00088 QVBox * page = addVBoxPage( i18n("General"), i18n("General Properties"), DesktopIcon( "misc") );
00089 m_GenPageWidgets.generalGB = new QGroupBox( i18n( "Properties"), (QWidget *)page );
00090
00091 QGridLayout * generalLayout = new QGridLayout( m_GenPageWidgets.generalGB, 2, 2 );
00092 generalLayout -> setSpacing( spacingHint() );
00093 generalLayout -> setMargin( fontMetrics().height() );
00094
00095 Dialog_Utils::makeLabeledEditField( m_GenPageWidgets.generalGB, generalLayout, 0,
00096 m_GenPageWidgets.typeL, i18n("State type:"),
00097 m_GenPageWidgets.typeLE, types[ (int)type ] );
00098 m_GenPageWidgets.typeLE -> setEnabled( false );
00099
00100 Dialog_Utils::makeLabeledEditField( m_GenPageWidgets.generalGB, generalLayout, 1,
00101 m_GenPageWidgets.nameL, i18n("State name:"),
00102 m_GenPageWidgets.nameLE );
00103
00104 m_GenPageWidgets.docGB = new QGroupBox( i18n( "Documentation"), (QWidget *)page );
00105
00106 QHBoxLayout * docLayout = new QHBoxLayout( m_GenPageWidgets.docGB );
00107 docLayout -> setSpacing( spacingHint() );
00108 docLayout -> setMargin( fontMetrics().height() );
00109
00110 m_GenPageWidgets.docMLE = new QMultiLineEdit( m_GenPageWidgets.docGB );
00111 m_GenPageWidgets.docMLE -> setText( m_pStateWidget -> getDoc() );
00112 docLayout -> addWidget( m_GenPageWidgets.docMLE );
00113
00114 if( type != StateWidget::Normal ) {
00115 m_GenPageWidgets.nameLE -> setEnabled( false );
00116 m_GenPageWidgets.nameLE -> setText( "" );
00117 } else
00118 m_GenPageWidgets.nameLE -> setText( m_pStateWidget -> getName() );
00119 }
00120
00121 void StateDialog::setupFontPage() {
00122 if ( !m_pStateWidget )
00123 return;
00124 QVBox * page = addVBoxPage( i18n("Font"), i18n("Font Settings"), DesktopIcon( "fonts") );
00125 m_pChooser = new KFontChooser( (QWidget*)page, "font", false, QStringList(), false);
00126 m_pChooser -> setFont( m_pStateWidget -> getFont() );
00127 }
00128
00129 void StateDialog::setupColorPage() {
00130 QFrame * colorPage = addPage( i18n("Color"), i18n("Widget Color"), DesktopIcon( "colors") );
00131 QHBoxLayout * m_pColorLayout = new QHBoxLayout(colorPage);
00132 m_pColorPage = new UMLWidgetColorPage( colorPage, m_pStateWidget );
00133 m_pColorLayout -> addWidget(m_pColorPage);
00134 }
00135
00136 void StateDialog::setupActivityPage() {
00137 QFrame * activityPage = addPage( i18n("Activities"), i18n("Activities"), DesktopIcon( "misc") );
00138 QHBoxLayout * activityLayout = new QHBoxLayout( activityPage );
00139 m_pActivityPage = new ActivityPage( activityPage, m_pStateWidget );
00140 activityLayout -> addWidget( m_pActivityPage );
00141 }
00142
00143
00144
00145
00146
00147 #include "statedialog.moc"
This file is part of the documentation for umbrello Version 3.1.0.