umbrello API Documentation

activitydialog.cpp

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2002-2006                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 // own header
00013 #include "activitydialog.h"
00014 
00015 //qt includes
00016 #include <qlayout.h>
00017 
00018 //kde includes
00019 #include <kiconloader.h>
00020 #include <klocale.h>
00021 
00022 //local includes
00023 #include "../umlview.h"
00024 #include "../activitywidget.h"
00025 #include "../dialog_utils.h"
00026 
00027 ActivityDialog::ActivityDialog( UMLView * pView, ActivityWidget * pWidget )
00028         : KDialogBase(IconList, i18n("Properties"), Ok | Apply | Cancel | Help, Ok, pView, "_STATEDIALOG_", true, true) {
00029     m_pView = pView;
00030     m_pActivityWidget = pWidget;
00031     m_bChangesMade = false;
00032     setupPages();
00033 }
00034 
00035 void ActivityDialog::slotOk() {
00036     applyPage( GeneralPage );
00037     applyPage( ColorPage );
00038     applyPage( FontPage );
00039     accept();
00040 }
00041 
00042 void ActivityDialog::slotApply() {
00043     applyPage( (Page) activePageIndex() );
00044 }
00045 
00046 void ActivityDialog::setupPages() {
00047     setupGeneralPage();
00048     setupColorPage();
00049     setupFontPage();
00050 }
00051 
00052 void ActivityDialog::applyPage( Page page ) {
00053     m_bChangesMade = true;
00054     switch( page ) {
00055     case GeneralPage:
00056         m_pActivityWidget -> setName( m_GenPageWidgets.nameLE -> text() );
00057         m_pActivityWidget -> setDoc( m_GenPageWidgets.docMLE -> text() );
00058         break;
00059 
00060     case ColorPage:
00061         m_pColorPage -> updateUMLWidget();
00062 
00063     case FontPage:
00064         m_pActivityWidget -> setFont( m_pChooser -> font() );
00065         break;
00066     }//end switch
00067 }
00068 
00069 void ActivityDialog::setupGeneralPage() {
00070     QString types[ ] = { i18n("Initial activity"), i18n("Activity"), i18n("End activity"), i18n( "Branch/Merge"), i18n( "Fork/Join" ) };
00071     ActivityWidget::ActivityType type = m_pActivityWidget -> getActivityType();
00072 
00073     QVBox * page = addVBoxPage( i18n("General"), i18n("General Properties"), DesktopIcon( "misc") );
00074     m_GenPageWidgets.generalGB = new QGroupBox( i18n( "Properties"), (QWidget *)page );
00075 
00076     QGridLayout * generalLayout = new QGridLayout( m_GenPageWidgets.generalGB, 2, 2 );
00077     generalLayout -> setSpacing( spacingHint() );
00078     generalLayout -> setMargin(  fontMetrics().height()  );
00079 
00080     QString actType ( types[ (int)type ] );
00081     Dialog_Utils::makeLabeledEditField( m_GenPageWidgets.generalGB, generalLayout, 0,
00082                                     m_GenPageWidgets.typeL, i18n("Activity type:"),
00083                                     m_GenPageWidgets.typeLE, actType );
00084     m_GenPageWidgets.typeLE -> setEnabled( false );
00085 
00086     Dialog_Utils::makeLabeledEditField( m_GenPageWidgets.generalGB, generalLayout, 1,
00087                                     m_GenPageWidgets.nameL, i18n("Activity name:"),
00088                                     m_GenPageWidgets.nameLE );
00089 
00090     m_GenPageWidgets.docGB = new QGroupBox( i18n( "Documentation"), (QWidget *)page );
00091 
00092     QHBoxLayout * docLayout = new QHBoxLayout( m_GenPageWidgets.docGB );
00093     docLayout -> setSpacing( spacingHint() );
00094     docLayout -> setMargin(  fontMetrics().height()  );
00095 
00096     m_GenPageWidgets.docMLE = new QMultiLineEdit( m_GenPageWidgets.docGB );
00097     m_GenPageWidgets.docMLE -> setText( m_pActivityWidget -> getDoc() );
00098     docLayout -> addWidget( m_GenPageWidgets.docMLE );
00099 
00100     if( type != ActivityWidget::Normal ) {
00101         m_GenPageWidgets.nameLE -> setEnabled( false );
00102         m_GenPageWidgets.nameLE -> setText( "" );
00103     } else
00104         m_GenPageWidgets.nameLE -> setText( m_pActivityWidget -> getName() );
00105 }
00106 
00107 void ActivityDialog::setupFontPage() {
00108     QVBox * page = addVBoxPage( i18n("Font"), i18n("Font Settings"), DesktopIcon( "fonts")  );
00109     m_pChooser = new KFontChooser( (QWidget*)page, "font", false, QStringList(), false);
00110     m_pChooser -> setFont( m_pActivityWidget -> getFont() );
00111 }
00112 
00113 void ActivityDialog::setupColorPage() {
00114     QFrame * colorPage = addPage( i18n("Color"), i18n("Widget Colors"), DesktopIcon( "colors") );
00115     QHBoxLayout * m_pColorLayout = new QHBoxLayout(colorPage);
00116     m_pColorPage = new UMLWidgetColorPage( colorPage, m_pActivityWidget );
00117     m_pColorLayout -> addWidget(m_pColorPage);
00118 }
00119 
00120 
00121 
00122 
00123 
00124 
00125 #include "activitydialog.moc"
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:07:53 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003