summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'umbrello/umbrello/dialogs')
-rw-r--r--umbrello/umbrello/dialogs/Makefile.am54
-rw-r--r--umbrello/umbrello/dialogs/activitydialog.cpp125
-rw-r--r--umbrello/umbrello/dialogs/activitydialog.h136
-rw-r--r--umbrello/umbrello/dialogs/activitypage.cpp325
-rw-r--r--umbrello/umbrello/dialogs/activitypage.h94
-rw-r--r--umbrello/umbrello/dialogs/assocgenpage.cpp131
-rw-r--r--umbrello/umbrello/dialogs/assocgenpage.h93
-rw-r--r--umbrello/umbrello/dialogs/assocpage.cpp127
-rw-r--r--umbrello/umbrello/dialogs/assocpage.h76
-rw-r--r--umbrello/umbrello/dialogs/assocpropdlg.cpp115
-rw-r--r--umbrello/umbrello/dialogs/assocpropdlg.h72
-rw-r--r--umbrello/umbrello/dialogs/assocrolepage.cpp293
-rw-r--r--umbrello/umbrello/dialogs/assocrolepage.h85
-rw-r--r--umbrello/umbrello/dialogs/classgenpage.cpp472
-rw-r--r--umbrello/umbrello/dialogs/classgenpage.h109
-rw-r--r--umbrello/umbrello/dialogs/classifierlistpage.cpp607
-rw-r--r--umbrello/umbrello/dialogs/classifierlistpage.h191
-rw-r--r--umbrello/umbrello/dialogs/classoptionspage.cpp195
-rw-r--r--umbrello/umbrello/dialogs/classoptionspage.h106
-rw-r--r--umbrello/umbrello/dialogs/classpropdlg.cpp250
-rw-r--r--umbrello/umbrello/dialogs/classpropdlg.h129
-rw-r--r--umbrello/umbrello/dialogs/classwizard.cpp107
-rw-r--r--umbrello/umbrello/dialogs/classwizard.h104
-rw-r--r--umbrello/umbrello/dialogs/codeeditor.cpp1231
-rw-r--r--umbrello/umbrello/dialogs/codeeditor.h191
-rw-r--r--umbrello/umbrello/dialogs/codegenerationoptionsbase.ui533
-rw-r--r--umbrello/umbrello/dialogs/codegenerationoptionspage.cpp188
-rw-r--r--umbrello/umbrello/dialogs/codegenerationoptionspage.h74
-rw-r--r--umbrello/umbrello/dialogs/codegenerationpolicybase.ui39
-rw-r--r--umbrello/umbrello/dialogs/codegenerationpolicypage.cpp50
-rw-r--r--umbrello/umbrello/dialogs/codegenerationpolicypage.h55
-rw-r--r--umbrello/umbrello/dialogs/codegenerationwizard.cpp258
-rw-r--r--umbrello/umbrello/dialogs/codegenerationwizard.h88
-rw-r--r--umbrello/umbrello/dialogs/codegenerationwizardbase.ui309
-rw-r--r--umbrello/umbrello/dialogs/codeviewerdialog.cpp122
-rw-r--r--umbrello/umbrello/dialogs/codeviewerdialog.h80
-rw-r--r--umbrello/umbrello/dialogs/codeviewerdialogbase.ui113
-rw-r--r--umbrello/umbrello/dialogs/codevieweroptionsbase.ui369
-rw-r--r--umbrello/umbrello/dialogs/codevieweroptionspage.cpp70
-rw-r--r--umbrello/umbrello/dialogs/codevieweroptionspage.h52
-rw-r--r--umbrello/umbrello/dialogs/defaultcodegenpolicypage.cpp41
-rw-r--r--umbrello/umbrello/dialogs/defaultcodegenpolicypage.h42
-rw-r--r--umbrello/umbrello/dialogs/diagramprintpage.cpp225
-rw-r--r--umbrello/umbrello/dialogs/diagramprintpage.h101
-rw-r--r--umbrello/umbrello/dialogs/diagrampropertiespage.ui410
-rw-r--r--umbrello/umbrello/dialogs/exportallviewsdialog.cpp55
-rw-r--r--umbrello/umbrello/dialogs/exportallviewsdialog.h72
-rw-r--r--umbrello/umbrello/dialogs/exportallviewsdialogbase.ui216
-rw-r--r--umbrello/umbrello/dialogs/notedialog.cpp53
-rw-r--r--umbrello/umbrello/dialogs/notedialog.h55
-rw-r--r--umbrello/umbrello/dialogs/overwritedialogue.cpp62
-rw-r--r--umbrello/umbrello/dialogs/overwritedialogue.h72
-rw-r--r--umbrello/umbrello/dialogs/parmpropdlg.cpp257
-rw-r--r--umbrello/umbrello/dialogs/parmpropdlg.h125
-rw-r--r--umbrello/umbrello/dialogs/pkgcontentspage.cpp127
-rw-r--r--umbrello/umbrello/dialogs/pkgcontentspage.h62
-rw-r--r--umbrello/umbrello/dialogs/selectopdlg.cpp141
-rw-r--r--umbrello/umbrello/dialogs/selectopdlg.h120
-rw-r--r--umbrello/umbrello/dialogs/settingsdlg.cpp443
-rw-r--r--umbrello/umbrello/dialogs/settingsdlg.h177
-rw-r--r--umbrello/umbrello/dialogs/statedialog.cpp147
-rw-r--r--umbrello/umbrello/dialogs/statedialog.h144
-rw-r--r--umbrello/umbrello/dialogs/umlattributedialog.cpp235
-rw-r--r--umbrello/umbrello/dialogs/umlattributedialog.h81
-rw-r--r--umbrello/umbrello/dialogs/umlentityattributedialog.cpp262
-rw-r--r--umbrello/umbrello/dialogs/umlentityattributedialog.h87
-rw-r--r--umbrello/umbrello/dialogs/umloperationdialog.cpp530
-rw-r--r--umbrello/umbrello/dialogs/umloperationdialog.h135
-rw-r--r--umbrello/umbrello/dialogs/umlroledialog.cpp63
-rw-r--r--umbrello/umbrello/dialogs/umlroledialog.h75
-rw-r--r--umbrello/umbrello/dialogs/umlroleproperties.cpp114
-rw-r--r--umbrello/umbrello/dialogs/umlroleproperties.h59
-rw-r--r--umbrello/umbrello/dialogs/umlrolepropertiesbase.ui203
-rw-r--r--umbrello/umbrello/dialogs/umltemplatedialog.cpp161
-rw-r--r--umbrello/umbrello/dialogs/umltemplatedialog.h81
-rw-r--r--umbrello/umbrello/dialogs/umlviewdialog.cpp184
-rw-r--r--umbrello/umbrello/dialogs/umlviewdialog.h119
-rw-r--r--umbrello/umbrello/dialogs/umlwidgetcolorpage.cpp114
-rw-r--r--umbrello/umbrello/dialogs/umlwidgetcolorpage.h86
79 files changed, 13554 insertions, 0 deletions
diff --git a/umbrello/umbrello/dialogs/Makefile.am b/umbrello/umbrello/dialogs/Makefile.am
new file mode 100644
index 00000000..0def48d4
--- /dev/null
+++ b/umbrello/umbrello/dialogs/Makefile.am
@@ -0,0 +1,54 @@
+noinst_LTLIBRARIES = libdialogs.la
+
+INCLUDES = -I$(top_srcdir) $(all_includes)
+
+libdialogs_la_METASOURCES = AUTO
+
+libdialogs_la_SOURCES = \
+ codegenerationoptionsbase.ui \
+ codegenerationpolicybase.ui \
+ codegenerationwizardbase.ui \
+ codeviewerdialogbase.ui \
+ codevieweroptionsbase.ui \
+ diagrampropertiespage.ui \
+ exportallviewsdialogbase.ui \
+ umlrolepropertiesbase.ui \
+activitydialog.cpp \
+activitypage.cpp \
+assocgenpage.cpp \
+assocpage.cpp \
+assocpropdlg.cpp \
+assocrolepage.cpp \
+classgenpage.cpp \
+classifierlistpage.cpp\
+classoptionspage.cpp \
+classpropdlg.cpp \
+classwizard.cpp \
+codeeditor.cpp \
+codegenerationoptionspage.cpp \
+codegenerationpolicypage.cpp \
+codegenerationwizard.cpp \
+codeviewerdialog.cpp \
+codevieweroptionspage.cpp \
+defaultcodegenpolicypage.cpp \
+diagramprintpage.cpp \
+exportallviewsdialog.cpp \
+notedialog.cpp \
+overwritedialogue.cpp \
+pkgcontentspage.cpp \
+parmpropdlg.cpp \
+selectopdlg.cpp \
+settingsdlg.cpp \
+statedialog.cpp \
+umlattributedialog.cpp \
+umlentityattributedialog.cpp \
+umloperationdialog.cpp \
+umltemplatedialog.cpp \
+umlroledialog.cpp \
+umlroleproperties.cpp \
+umlviewdialog.cpp \
+umlwidgetcolorpage.cpp
+
+libdialogs_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -export-dynamic
+
+
diff --git a/umbrello/umbrello/dialogs/activitydialog.cpp b/umbrello/umbrello/dialogs/activitydialog.cpp
new file mode 100644
index 00000000..d34782a5
--- /dev/null
+++ b/umbrello/umbrello/dialogs/activitydialog.cpp
@@ -0,0 +1,125 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "activitydialog.h"
+
+//qt includes
+#include <qlayout.h>
+
+//kde includes
+#include <kiconloader.h>
+#include <klocale.h>
+
+//local includes
+#include "../umlview.h"
+#include "../activitywidget.h"
+#include "../dialog_utils.h"
+
+ActivityDialog::ActivityDialog( UMLView * pView, ActivityWidget * pWidget )
+ : KDialogBase(IconList, i18n("Properties"), Ok | Apply | Cancel | Help, Ok, pView, "_STATEDIALOG_", true, true) {
+ m_pView = pView;
+ m_pActivityWidget = pWidget;
+ m_bChangesMade = false;
+ setupPages();
+}
+
+void ActivityDialog::slotOk() {
+ applyPage( GeneralPage );
+ applyPage( ColorPage );
+ applyPage( FontPage );
+ accept();
+}
+
+void ActivityDialog::slotApply() {
+ applyPage( (Page) activePageIndex() );
+}
+
+void ActivityDialog::setupPages() {
+ setupGeneralPage();
+ setupColorPage();
+ setupFontPage();
+}
+
+void ActivityDialog::applyPage( Page page ) {
+ m_bChangesMade = true;
+ switch( page ) {
+ case GeneralPage:
+ m_pActivityWidget -> setName( m_GenPageWidgets.nameLE -> text() );
+ m_pActivityWidget -> setDoc( m_GenPageWidgets.docMLE -> text() );
+ break;
+
+ case ColorPage:
+ m_pColorPage -> updateUMLWidget();
+
+ case FontPage:
+ m_pActivityWidget -> setFont( m_pChooser -> font() );
+ break;
+ }//end switch
+}
+
+void ActivityDialog::setupGeneralPage() {
+ QString types[ ] = { i18n("Initial activity"), i18n("Activity"), i18n("End activity"), i18n( "Branch/Merge"), i18n( "Fork/Join" ) };
+ ActivityWidget::ActivityType type = m_pActivityWidget -> getActivityType();
+
+ QVBox * page = addVBoxPage( i18n("General"), i18n("General Properties"), DesktopIcon( "misc") );
+ m_GenPageWidgets.generalGB = new QGroupBox( i18n( "Properties"), (QWidget *)page );
+
+ QGridLayout * generalLayout = new QGridLayout( m_GenPageWidgets.generalGB, 2, 2 );
+ generalLayout -> setSpacing( spacingHint() );
+ generalLayout -> setMargin( fontMetrics().height() );
+
+ QString actType ( types[ (int)type ] );
+ Dialog_Utils::makeLabeledEditField( m_GenPageWidgets.generalGB, generalLayout, 0,
+ m_GenPageWidgets.typeL, i18n("Activity type:"),
+ m_GenPageWidgets.typeLE, actType );
+ m_GenPageWidgets.typeLE -> setEnabled( false );
+
+ Dialog_Utils::makeLabeledEditField( m_GenPageWidgets.generalGB, generalLayout, 1,
+ m_GenPageWidgets.nameL, i18n("Activity name:"),
+ m_GenPageWidgets.nameLE );
+
+ m_GenPageWidgets.docGB = new QGroupBox( i18n( "Documentation"), (QWidget *)page );
+
+ QHBoxLayout * docLayout = new QHBoxLayout( m_GenPageWidgets.docGB );
+ docLayout -> setSpacing( spacingHint() );
+ docLayout -> setMargin( fontMetrics().height() );
+
+ m_GenPageWidgets.docMLE = new QMultiLineEdit( m_GenPageWidgets.docGB );
+ m_GenPageWidgets.docMLE -> setText( m_pActivityWidget -> getDoc() );
+ docLayout -> addWidget( m_GenPageWidgets.docMLE );
+
+ if( type != ActivityWidget::Normal ) {
+ m_GenPageWidgets.nameLE -> setEnabled( false );
+ m_GenPageWidgets.nameLE -> setText( "" );
+ } else
+ m_GenPageWidgets.nameLE -> setText( m_pActivityWidget -> getName() );
+}
+
+void ActivityDialog::setupFontPage() {
+ QVBox * page = addVBoxPage( i18n("Font"), i18n("Font Settings"), DesktopIcon( "fonts") );
+ m_pChooser = new KFontChooser( (QWidget*)page, "font", false, QStringList(), false);
+ m_pChooser -> setFont( m_pActivityWidget -> getFont() );
+}
+
+void ActivityDialog::setupColorPage() {
+ QFrame * colorPage = addPage( i18n("Color"), i18n("Widget Colors"), DesktopIcon( "colors") );
+ QHBoxLayout * m_pColorLayout = new QHBoxLayout(colorPage);
+ m_pColorPage = new UMLWidgetColorPage( colorPage, m_pActivityWidget );
+ m_pColorLayout -> addWidget(m_pColorPage);
+}
+
+
+
+
+
+
+#include "activitydialog.moc"
diff --git a/umbrello/umbrello/dialogs/activitydialog.h b/umbrello/umbrello/dialogs/activitydialog.h
new file mode 100644
index 00000000..4dc5980b
--- /dev/null
+++ b/umbrello/umbrello/dialogs/activitydialog.h
@@ -0,0 +1,136 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef ACTIVITYDIALOG_H
+#define ACTIVITYDIALOG_H
+
+//qt class includes
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qmultilineedit.h>
+#include <qgroupbox.h>
+
+//kde class includes
+#include <kdialogbase.h>
+#include <kfontdialog.h>
+
+//local class includes
+#include "umlwidgetcolorpage.h"
+
+//forward declarations
+class UMLView;
+class ActivityWidget;
+
+/**
+ * Displays the properties for a @ref ActivityWidget
+ *
+ * @author Paul Hensgen
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+
+class ActivityDialog : public KDialogBase {
+ Q_OBJECT
+
+public:
+ /**
+ * Constructor
+ */
+ ActivityDialog( UMLView * pView, ActivityWidget * pWidget );
+
+ /**
+ * Returns whether changes were made.
+ */
+ bool getChangesMade() {
+ return m_bChangesMade;
+ }
+
+protected slots:
+
+ /**
+ * Entered when OK button pressed.
+ */
+ void slotOk();
+
+ /**
+ * Entered when Apply button pressed.
+ */
+ void slotApply();
+
+protected:
+
+ enum Page
+ {
+ GeneralPage = 0,
+ ColorPage,
+ FontPage
+ };
+
+ /**
+ * Sets up the pages of the dialog.
+ */
+ void setupPages();
+
+ /**
+ * Sets up the general page of the dialog.
+ */
+ void setupGeneralPage();
+
+ /**
+ * Sets up the color page.
+ */
+ void setupColorPage();
+
+ /**
+ * Sets up the font selection page.
+ */
+ void setupFontPage();
+
+ /**
+ * Applys changes to the given page.
+ */
+ void applyPage( Page page );
+
+ /**
+ * Font chooser widget for font page.
+ */
+ KFontChooser * m_pChooser;
+
+ /**
+ * Color page
+ */
+ UMLWidgetColorPage * m_pColorPage;
+
+ /**
+ * The widget to represent.
+ */
+ ActivityWidget * m_pActivityWidget;
+
+ /**
+ * The diagram the widget is on.
+ */
+ UMLView * m_pView;
+
+ /**
+ * Holds whether changes in the dialog have been made.
+ */
+ bool m_bChangesMade;
+
+ struct GeneralPageWidgets {
+ QLabel * nameL, * typeL;
+ QLineEdit * nameLE, * typeLE;
+ QMultiLineEdit * docMLE;
+
+ QGroupBox * docGB, * generalGB;
+ }
+ m_GenPageWidgets;
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/activitypage.cpp b/umbrello/umbrello/dialogs/activitypage.cpp
new file mode 100644
index 00000000..8d3f5931
--- /dev/null
+++ b/umbrello/umbrello/dialogs/activitypage.cpp
@@ -0,0 +1,325 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#include "activitypage.h"
+#include "../statewidget.h"
+#include "../listpopupmenu.h"
+#include "../uml.h"
+
+#include <kinputdialog.h>
+#include <klocale.h>
+#include <kbuttonbox.h>
+#include <kdebug.h>
+#include <qlayout.h>
+#include <qstringlist.h>
+
+ActivityPage::ActivityPage( QWidget * pParent, StateWidget * pWidget ) : QWidget( pParent ) {
+ m_pStateWidget = pWidget;
+ m_pMenu = 0;
+ setupPage();
+}
+
+ActivityPage::~ActivityPage() {}
+
+void ActivityPage::setupPage() {
+ int margin = fontMetrics().height();
+
+ QVBoxLayout * mainLayout = new QVBoxLayout( this );
+ mainLayout -> setSpacing(10);
+
+ m_pActivityGB = new QGroupBox(i18n("Activities"), this );
+
+ // vertical box layout for the activity lists, arrow buttons and the button box
+ QVBoxLayout* listVBoxLayout = new QVBoxLayout( m_pActivityGB );
+ listVBoxLayout -> setMargin(margin);
+ listVBoxLayout -> setSpacing ( 10 );
+
+ //horizontal box contains the list box and the move up/down buttons
+ QHBoxLayout* listHBoxLayout = new QHBoxLayout( listVBoxLayout );
+
+ m_pActivityLB = new QListBox(m_pActivityGB );
+
+ listHBoxLayout -> addWidget(m_pActivityLB);
+
+ QVBoxLayout * buttonLayout = new QVBoxLayout( listHBoxLayout );
+
+ m_pTopArrowB = new KArrowButton( m_pActivityGB );
+ m_pTopArrowB -> setEnabled( false );
+ buttonLayout -> addWidget( m_pTopArrowB );
+
+ m_pUpArrowB = new KArrowButton( m_pActivityGB );
+ m_pUpArrowB -> setEnabled( false );
+ buttonLayout -> addWidget( m_pUpArrowB );
+
+ m_pDownArrowB = new KArrowButton( m_pActivityGB, Qt::DownArrow );
+ m_pDownArrowB -> setEnabled( false );
+ buttonLayout -> addWidget( m_pDownArrowB );
+
+ m_pBottomArrowB = new KArrowButton( m_pActivityGB, Qt::DownArrow );
+ m_pBottomArrowB -> setEnabled( false );
+ buttonLayout -> addWidget( m_pBottomArrowB );
+
+
+ KButtonBox* buttonBox = new KButtonBox(m_pActivityGB);
+ buttonBox->addButton( i18n("New Activity..."), this, SLOT(slotNewActivity()) );
+ m_pDeleteActivityButton = buttonBox->addButton( i18n("Delete"),
+ this, SLOT(slotDelete()) );
+ m_pRenameButton = buttonBox->addButton( i18n("Rename"), this, SLOT(slotRename()) );
+ listVBoxLayout->addWidget(buttonBox);
+
+ mainLayout -> addWidget( m_pActivityGB );
+
+ //now fill activity list box
+ QStringList list = m_pStateWidget -> getActivityList();
+ QStringList::Iterator end(list.end());
+
+ for( QStringList::Iterator it(list.begin()); it != end; ++it ) {
+ m_pActivityLB -> insertItem( *it );
+ }
+
+ //now setup the signals
+ connect(m_pActivityLB, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotClicked(QListBoxItem *)));
+ connect(m_pActivityLB, SIGNAL(rightButtonPressed(QListBoxItem *, const QPoint &)),
+ this, SLOT(slotRightButtonPressed(QListBoxItem *, const QPoint &)));
+
+ connect(m_pActivityLB, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)),
+ this, SLOT(slotRightButtonClicked(QListBoxItem *, const QPoint &)));
+
+ connect( m_pTopArrowB, SIGNAL( clicked() ), this, SLOT( slotTopClicked() ) );
+ connect( m_pUpArrowB, SIGNAL( clicked() ), this, SLOT( slotUpClicked() ) );
+ connect( m_pDownArrowB, SIGNAL( clicked() ), this, SLOT( slotDownClicked() ) );
+ connect( m_pBottomArrowB, SIGNAL( clicked() ), this, SLOT( slotBottomClicked() ) );
+
+ connect( m_pActivityLB, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( slotDoubleClicked( QListBoxItem* ) ) );
+
+ enableWidgets(false);
+}
+
+void ActivityPage::updateActivities() {
+ QStringList list;
+ int count = m_pActivityLB -> count();
+ for( int i = 0; i < count; i++ ) {
+ list.append( m_pActivityLB -> text( i ) );
+ }
+ m_pStateWidget -> setActivities( list );
+}
+
+void ActivityPage::slotMenuSelection( int sel ) {
+ switch( sel ) {
+ case ListPopupMenu::mt_New_Activity:
+ slotNewActivity();
+ break;
+
+ case ListPopupMenu::mt_Delete:
+ slotDelete();
+ break;
+
+ case ListPopupMenu::mt_Rename:
+ slotRename();
+ break;
+ }
+}
+
+void ActivityPage::slotNewActivity() {
+ bool ok = false;
+ QString name = m_pActivityLB->currentText();
+ name = KInputDialog::getText( i18n("New Activity"), i18n("Enter the name of the new activity:"),
+ i18n("new activity"), &ok, UMLApp::app() );
+ if( ok && name.length() > 0 ) {
+ m_pActivityLB->insertItem( name );
+ m_pStateWidget->addActivity( name );
+ }
+}
+
+void ActivityPage::slotDelete() {
+ QString name = m_pActivityLB->currentText();
+ m_pStateWidget->removeActivity(name);
+ m_pActivityLB->removeItem( m_pActivityLB->currentItem() );
+ slotClicked(0);
+}
+
+void ActivityPage::slotRename() {
+ bool ok = false;
+ QString name = m_pActivityLB -> currentText();
+ QString oldName = name;
+ name = KInputDialog::getText( i18n("Rename Activity"), i18n("Enter the new name of the activity:"), name, &ok, UMLApp::app() );
+ if( ok && name.length() > 0 ) {
+ m_pActivityLB -> changeItem( name, m_pActivityLB -> currentItem());
+ m_pStateWidget -> renameActivity( oldName, name );
+ }
+}
+
+void ActivityPage::slotRightButtonClicked(QListBoxItem * /*item*/, const QPoint &/* p*/) {
+ if(m_pMenu) {
+ m_pMenu->hide();
+ disconnect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotMenuSelection(int)));
+ delete m_pMenu;
+ m_pMenu = 0;
+ }
+}
+
+void ActivityPage::slotRightButtonPressed(QListBoxItem * item, const QPoint & p)
+{
+ ListPopupMenu::Menu_Type type = ListPopupMenu::mt_Undefined;
+ if( item ) { //pressed on an item
+ type = ListPopupMenu::mt_Activity_Selected;
+ } else { //pressed into fresh air
+ type = ListPopupMenu::mt_New_Activity;
+ }
+
+ if(m_pMenu) {
+ m_pMenu -> hide();
+ disconnect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotMenuSelection(int)));
+ delete m_pMenu;
+ m_pMenu = 0;
+ }
+ m_pMenu = new ListPopupMenu(this, type);
+ m_pMenu->popup(p);
+ connect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotMenuSelection(int)));
+}
+
+
+void ActivityPage::slotTopClicked() {
+ int count = m_pActivityLB->count();
+ int index = m_pActivityLB->currentItem();
+ //shouldn't occur, but just in case
+ if( count <= 1 || index <= 0 )
+ return;
+
+ //swap the text around in the ListBox
+ QString currentString = m_pActivityLB->text( index );
+ m_pActivityLB->removeItem( index );
+ m_pActivityLB->insertItem( currentString, 0 );
+ //set the moved item selected
+ QListBoxItem* item = m_pActivityLB->item( 0 );
+ m_pActivityLB->setSelected( item, true );
+
+ slotClicked(item);
+}
+
+void ActivityPage::slotUpClicked() {
+ int count = m_pActivityLB -> count();
+ int index = m_pActivityLB -> currentItem();
+ //shouldn't occur, but just in case
+ if( count <= 1 || index <= 0 ) {
+ return;
+ }
+
+ //swap the text around ( meaning attributes )
+ QString aboveString = m_pActivityLB -> text( index - 1 );
+ QString currentString = m_pActivityLB -> text( index );
+ m_pActivityLB -> changeItem( currentString, index -1 );
+ m_pActivityLB -> changeItem( aboveString, index );
+ //set the moved atttribute selected
+ QListBoxItem * item = m_pActivityLB -> item( index - 1 );
+ m_pActivityLB -> setSelected( item, true );
+ slotClicked(item);
+}
+
+void ActivityPage::slotDownClicked() {
+ int count = m_pActivityLB -> count();
+ int index = m_pActivityLB -> currentItem();
+ //shouldn't occur, but just in case
+ if( count <= 1 || index >= count - 1 ) {
+ return;
+ }
+
+ //swap the text around ( meaning attributes )
+ QString belowString = m_pActivityLB -> text( index + 1 );
+ QString currentString = m_pActivityLB -> text( index );
+ m_pActivityLB -> changeItem( currentString, index + 1 );
+ m_pActivityLB -> changeItem( belowString, index );
+ //set the moved atttribute selected
+ QListBoxItem * item = m_pActivityLB -> item( index + 1 );
+ m_pActivityLB -> setSelected( item, true );
+ slotClicked(item);
+}
+
+
+void ActivityPage::slotBottomClicked() {
+ int count = m_pActivityLB->count();
+ int index = m_pActivityLB->currentItem();
+ //shouldn't occur, but just in case
+ if( count <= 1 || index >= count - 1 )
+ return;
+
+ //swap the text around in the ListBox
+ QString currentString = m_pActivityLB->text( index );
+ m_pActivityLB->removeItem( index );
+ m_pActivityLB->insertItem( currentString, m_pActivityLB->count() );
+ //set the moved item selected
+ QListBoxItem* item = m_pActivityLB->item( m_pActivityLB->count() - 1 );
+ m_pActivityLB->setSelected( item, true );
+
+ slotClicked( item );
+}
+
+
+void ActivityPage::slotClicked(QListBoxItem *item) {
+ //make sure clicked on an item
+ if(!item) {
+ enableWidgets(false);
+ m_pActivityLB -> clearSelection();
+ } else {
+ enableWidgets(true);
+ }
+}
+
+void ActivityPage::slotDoubleClicked(QListBoxItem* item) {
+ if (item) {
+ slotRename();
+ }
+}
+
+void ActivityPage::enableWidgets(bool state) {
+ if( !state ) {
+ m_pTopArrowB->setEnabled( false );
+ m_pUpArrowB->setEnabled( false );
+ m_pDownArrowB->setEnabled( false );
+ m_pBottomArrowB->setEnabled( false );
+ m_pDeleteActivityButton->setEnabled(false);
+ m_pRenameButton->setEnabled(false);
+ return;
+ }
+ /*now check the order buttons.
+ Double check an item is selected
+ If only one att. in list make sure there disabled.
+ If at top item,only allow down arrow to be enabled.
+ If at bottom item. only allow up arrow to be enabled.
+ */
+ int index = m_pActivityLB->currentItem();
+ if( m_pActivityLB->count() == 1 || index == -1 ) {
+ m_pTopArrowB->setEnabled(false);
+ m_pUpArrowB->setEnabled(false);
+ m_pDownArrowB->setEnabled(false);
+ m_pBottomArrowB->setEnabled( false );
+ } else if( index == 0 ) {
+ m_pTopArrowB->setEnabled( false );
+ m_pUpArrowB->setEnabled(false);
+ m_pDownArrowB->setEnabled(true);
+ m_pBottomArrowB->setEnabled(true);
+ } else if( index == (int)m_pActivityLB->count() - 1 ) {
+ m_pTopArrowB->setEnabled(true);
+ m_pUpArrowB->setEnabled(true);
+ m_pDownArrowB->setEnabled(false);
+ m_pBottomArrowB->setEnabled(false);
+ } else {
+ m_pTopArrowB->setEnabled(true);
+ m_pUpArrowB->setEnabled(true);
+ m_pDownArrowB->setEnabled(true);
+ m_pBottomArrowB->setEnabled(true);
+ }
+ m_pDeleteActivityButton->setEnabled(true);
+ m_pRenameButton->setEnabled(true);
+}
+
+
+#include "activitypage.moc"
diff --git a/umbrello/umbrello/dialogs/activitypage.h b/umbrello/umbrello/dialogs/activitypage.h
new file mode 100644
index 00000000..7d391b96
--- /dev/null
+++ b/umbrello/umbrello/dialogs/activitypage.h
@@ -0,0 +1,94 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef ACTIVITYPAGE_H
+#define ACTIVITYPAGE_H
+//qt includes
+#include <qwidget.h>
+#include <qgroupbox.h>
+#include <qlistbox.h>
+//kde includes
+#include <karrowbutton.h>
+//app includes
+
+class StateWidget;
+class ListPopupMenu;
+
+/**
+ * @author Paul Hensgen
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class ActivityPage : public QWidget {
+ Q_OBJECT
+public:
+ /**
+ * Constructor
+ */
+ ActivityPage( QWidget * pParent, StateWidget * pWidget );
+
+ /**
+ * Deconstructor
+ */
+ ~ActivityPage();
+
+ /**
+ * Sets up the page.
+ */
+ void setupPage();
+
+ /**
+ * Sets the activities of the widget.
+ */
+ void updateActivities();
+
+protected:
+ /**
+ * Set the state of the widgets on the page with the given value.
+ *
+ * @param state The state to set the widgets as.
+ */
+ void enableWidgets(bool state);
+
+ /**
+ * The widget to get the activities from.
+ */
+ StateWidget * m_pStateWidget;
+
+ /**
+ * Popup menu used.
+ */
+ ListPopupMenu * m_pMenu;
+ //GUI widgets
+ QListBox * m_pActivityLB;
+ QGroupBox * m_pActivityGB;
+ KArrowButton * m_pUpArrowB, * m_pDownArrowB, * m_pTopArrowB, *m_pBottomArrowB;
+ QPushButton* m_pDeleteActivityButton;
+ QPushButton* m_pRenameButton;
+
+public slots:
+ /**
+ * Popup menu item selected
+ */
+ void slotMenuSelection( int sel );
+ void slotClicked( QListBoxItem* item );
+ void slotDoubleClicked( QListBoxItem* item );
+ void slotRightButtonClicked(QListBoxItem* item, const QPoint& p);
+ void slotRightButtonPressed(QListBoxItem* item, const QPoint& p);
+ void slotTopClicked();
+ void slotUpClicked();
+ void slotDownClicked();
+ void slotBottomClicked();
+ void slotNewActivity();
+ void slotDelete();
+ void slotRename();
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/assocgenpage.cpp b/umbrello/umbrello/dialogs/assocgenpage.cpp
new file mode 100644
index 00000000..9be13ee0
--- /dev/null
+++ b/umbrello/umbrello/dialogs/assocgenpage.cpp
@@ -0,0 +1,131 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "assocgenpage.h"
+
+// qt includes
+#include <qlayout.h>
+#include <kcombobox.h>
+
+// kde includes
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+
+// local includes
+#include "../association.h"
+#include "../dialog_utils.h"
+
+AssocGenPage::AssocGenPage (UMLDoc *d, QWidget *parent, AssociationWidget *assoc)
+ : QWidget(parent)
+{
+
+ m_pAssociationWidget = assoc;
+ m_pWidget = 0;
+ m_pTypeCB = 0;
+ m_pAssocNameLE = 0;
+ m_pUmldoc = d;
+
+ constructWidget();
+
+}
+
+AssocGenPage::~AssocGenPage() {}
+
+void AssocGenPage::constructWidget() {
+
+ // general configuration of the GUI
+ int margin = fontMetrics().height();
+ setMinimumSize(310,330);
+ QVBoxLayout * topLayout = new QVBoxLayout(this);
+ topLayout -> setSpacing(6);
+
+ // group boxes for name, documentation properties
+ QGroupBox *nameGB = new QGroupBox(this);
+ QGroupBox *docGB = new QGroupBox(this);
+ nameGB -> setTitle(i18n("Properties"));
+ docGB -> setTitle(i18n("Documentation"));
+ topLayout -> addWidget(nameGB);
+ topLayout -> addWidget(docGB);
+
+ QGridLayout * nameLayout = new QGridLayout(nameGB, 2, 2);
+ nameLayout -> setSpacing(6);
+ nameLayout -> setMargin(margin);
+
+ //Association name
+ QLabel *pAssocNameL = NULL;
+ QLineEdit* nameField = Dialog_Utils::makeLabeledEditField( nameGB, nameLayout, 0,
+ pAssocNameL, i18n("Name:"),
+ m_pAssocNameLE, m_pAssociationWidget->getName() );
+ nameField->setFocus();
+
+ // document
+ QHBoxLayout * docLayout = new QHBoxLayout(docGB);
+ docLayout -> setMargin(margin);
+
+ m_pDoc = new QMultiLineEdit(docGB);
+ docLayout -> addWidget(m_pDoc);
+ m_pDoc-> setText(m_pAssociationWidget-> getDoc());
+ Uml::Association_Type currentType = m_pAssociationWidget->getAssocType();
+ QString currentTypeAsString = UMLAssociation::typeAsString(currentType);
+ QLabel *pTypeL = new QLabel(i18n("Type:"), nameGB);
+ nameLayout->addWidget(pTypeL, 1, 0);
+
+ /* Here is a list of all the supported choices for changing
+ association types */
+ m_AssocTypes.clear();
+ m_AssocTypes << Uml::at_Aggregation
+ << Uml::at_Composition << Uml::at_Containment;
+
+ bool found=false;
+ m_AssocTypeStrings.clear();
+ for (uint i=0; i<m_AssocTypes.size(); ++i) {
+ if (m_AssocTypes[i] == currentType) found=true;
+ QString typeStr = UMLAssociation::typeAsString(m_AssocTypes[i]);
+ m_AssocTypeStrings << typeStr;
+ }
+
+ if (!found) {
+ m_AssocTypes.clear();
+ m_AssocTypes << currentType;
+ m_AssocTypeStrings.clear();
+ m_AssocTypeStrings << currentTypeAsString;
+ }
+
+ m_pTypeCB = new KComboBox(nameGB);
+ pTypeL->setBuddy(m_pTypeCB);
+ m_pTypeCB->insertStringList(m_AssocTypeStrings);
+ m_pTypeCB->setCompletedItems(m_AssocTypeStrings);
+ m_pTypeCB->setCurrentText(currentTypeAsString);
+ m_pTypeCB->setDuplicatesEnabled(false);//only allow one of each type in box
+ m_pTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
+ m_pDoc->setWordWrap(QMultiLineEdit::WidgetWidth);
+ nameLayout->addWidget(m_pTypeCB, 1, 1);
+
+
+}
+
+
+void AssocGenPage::updateObject() {
+
+ if (m_pAssociationWidget) {
+ int comboBoxItem = m_pTypeCB->currentItem();
+ Uml::Association_Type newType = m_AssocTypes[comboBoxItem];
+ m_pAssociationWidget->setAssocType(newType);
+ m_pAssociationWidget->setName(m_pAssocNameLE->text());
+ m_pAssociationWidget->setDoc(m_pDoc->text());
+
+ } //end if m_pAssociationWidget
+}
+
+
+#include "assocgenpage.moc"
diff --git a/umbrello/umbrello/dialogs/assocgenpage.h b/umbrello/umbrello/dialogs/assocgenpage.h
new file mode 100644
index 00000000..3eff137f
--- /dev/null
+++ b/umbrello/umbrello/dialogs/assocgenpage.h
@@ -0,0 +1,93 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef ASSOCGENPAGE_H
+#define ASSOCGENPAGE_H
+
+//quicktime class includes
+#include <qwidget.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qbuttongroup.h>
+#include <qmultilineedit.h>
+#include <qradiobutton.h>
+#include <qcheckbox.h>
+#include <qvaluelist.h>
+
+//my class includes
+#include "../umlobject.h"
+#include "../objectwidget.h"
+#include "../umldoc.h"
+#include "../associationwidget.h"
+
+class KComboBox;
+
+
+/**
+ * Displays properties of a UMLObject in a dialog box. This is not usually directly
+ * called. The class @ref AssocPropDlg will set this up for you.
+ *
+ * @short Display properties on a UMLObject.
+ * @author Paul Hensgen <phensgen@techie.com>
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class AssocGenPage : public QWidget {
+ Q_OBJECT
+public:
+
+ /**
+ * Sets up the AssocGenPage.
+ *
+ * @param d The UMLDoc which controls controls object creation.
+ * @param parent The parent to the AssocGenPage.
+ * @param a The AssociationWidget to display the properties of.
+ */
+ AssocGenPage(UMLDoc *d, QWidget *parent, AssociationWidget *a);
+
+ /**
+ * Standard deconstructor.
+ */
+ ~AssocGenPage();
+
+ /**
+ * Will move information from the dialog into the object.
+ * Call when the ok or apply button is pressed.
+ */
+ void updateObject();
+
+private:
+ QLineEdit * m_pAssocNameLE;
+ KComboBox *m_pTypeCB;
+
+ /* Choices for the QComboBox, and we store ints and strings
+ so we can translate both ways */
+ QValueList<Uml::Association_Type> m_AssocTypes;
+ QStringList m_AssocTypeStrings;
+
+ QMultiLineEdit * m_pDoc;
+
+ AssociationWidget *m_pAssociationWidget;
+ UMLDoc * m_pUmldoc;
+ ObjectWidget * m_pWidget;
+
+ void constructWidget();
+
+public slots:
+ /**
+ * When the draw as actor check box is toggled, the draw
+ * as multi instance need to be enabled/disabled. They
+ * both can't be available at the same time.
+ */
+ // void slotActorToggled( bool state );
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/assocpage.cpp b/umbrello/umbrello/dialogs/assocpage.cpp
new file mode 100644
index 00000000..1b3cf5ad
--- /dev/null
+++ b/umbrello/umbrello/dialogs/assocpage.cpp
@@ -0,0 +1,127 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#include "assocpage.h"
+#include <qlayout.h>
+#include <klocale.h>
+#include "assocpropdlg.h"
+
+AssocPage::AssocPage(QWidget *parent, UMLView * v, UMLObject * o) : QWidget(parent) {
+ m_pObject = o;
+ m_pView = v;
+ int margin = fontMetrics().height();
+
+ QHBoxLayout * mainLayout = new QHBoxLayout(this);
+ mainLayout -> setSpacing(10);
+
+ m_pAssocGB = new QGroupBox(i18n("Associations"), this);
+ mainLayout -> addWidget(m_pAssocGB);
+
+ QHBoxLayout * layout = new QHBoxLayout(m_pAssocGB);
+ layout -> setSpacing(10);
+ layout -> setMargin(margin);
+
+ m_pAssocLB = new QListBox(m_pAssocGB);
+ layout -> addWidget(m_pAssocLB);
+ setMinimumSize(310, 330);
+ fillListBox();
+ m_pMenu = 0;
+
+ connect(m_pAssocLB, SIGNAL(doubleClicked(QListBoxItem *)),
+ this, SLOT(slotDoubleClick(QListBoxItem *)));
+
+ connect(m_pAssocLB, SIGNAL(rightButtonPressed(QListBoxItem *, const QPoint &)),
+ this, SLOT(slotRightButtonPressed(QListBoxItem *, const QPoint &)));
+
+ connect(m_pAssocLB, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)),
+ this, SLOT(slotRightButtonClicked(QListBoxItem *, const QPoint &)));
+}
+
+AssocPage::~AssocPage() {
+ disconnect(m_pAssocLB, SIGNAL(doubleClicked(QListBoxItem *)),
+ this, SLOT(slotDoubleClick(QListBoxItem *)));
+
+ disconnect(m_pAssocLB, SIGNAL(rightButtonPressed(QListBoxItem *, const QPoint &)),
+ this, SLOT(slotRightButtonPressed(QListBoxItem *, const QPoint &)));
+
+ disconnect(m_pAssocLB, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)),
+ this, SLOT(slotRightButtonClicked(QListBoxItem *, const QPoint &)));
+}
+
+void AssocPage::slotDoubleClick(QListBoxItem * i) {
+
+ if(!i)
+ return;
+
+ int item = m_pAssocLB -> currentItem();
+
+ AssociationWidget * a = m_List.at(item);
+
+ if (a->showDialog())
+ fillListBox();
+}
+
+void AssocPage::fillListBox() {
+ m_List.clear();
+ m_pAssocLB->clear();
+ m_pView->getWidgetAssocs(m_pObject, m_List);
+ AssociationWidgetListIt assoc_it(m_List);
+ AssociationWidget* assocwidget = 0;
+ int i = 0;
+ while((assocwidget = assoc_it.current())) {
+ if( assocwidget->getAssocType() != Uml::at_Anchor) {
+ m_pAssocLB -> insertItem(assocwidget->toString(), i++);
+ }
+ ++assoc_it;
+ }
+}
+
+void AssocPage::slotRightButtonClicked(QListBoxItem */* item*/, const QPoint &/* p*/) {
+ if(m_pMenu) {
+ m_pMenu -> hide();
+ disconnect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotPopupMenuSel(int)));
+ delete m_pMenu;
+ m_pMenu = 0;
+ }
+}
+
+void AssocPage::slotRightButtonPressed(QListBoxItem * item, const QPoint & p) {
+ if(!item)
+ return;
+ if(m_pMenu) {
+ m_pMenu -> hide();
+ disconnect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotPopupMenuSel(int)));
+ delete m_pMenu;
+ m_pMenu = 0;
+ }
+ m_pMenu = new ListPopupMenu(this, ListPopupMenu::mt_Association_Selected);
+ m_pMenu->popup(p);
+ connect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotPopupMenuSel(int)));
+}
+
+void AssocPage::slotPopupMenuSel(int id) {
+ AssociationWidget * a = m_List.at(m_pAssocLB -> currentItem());
+ switch(id) {
+ case ListPopupMenu::mt_Delete:
+ m_pView->removeAssocInViewAndDoc(a);
+ fillListBox();
+ break;
+
+ case ListPopupMenu::mt_Properties:
+ slotDoubleClick(m_pAssocLB -> item(m_pAssocLB -> currentItem()));
+ break;
+ }
+}
+
+
+
+
+#include "assocpage.moc"
diff --git a/umbrello/umbrello/dialogs/assocpage.h b/umbrello/umbrello/dialogs/assocpage.h
new file mode 100644
index 00000000..60e1e339
--- /dev/null
+++ b/umbrello/umbrello/dialogs/assocpage.h
@@ -0,0 +1,76 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+
+#ifndef ASSOCPAGE_H
+#define ASSOCPAGE_H
+
+#include <qwidget.h>
+#include <qgroupbox.h>
+#include <qlistbox.h>
+#include <qptrlist.h>
+
+#include "../umlobject.h"
+#include "../umlview.h"
+#include "../associationwidgetlist.h"
+#include "../associationwidget.h"
+#include "../listpopupmenu.h"
+
+
+/**
+ * Displays a page on the tabbed dialog window of @ref ClassPropDlg.
+ * The page shows all the Associations that belong to a UMLClassifier.
+ *
+ *
+ * @see ClassPropDlg
+
+ * @see UMLClassifier
+ *
+ * @short The page shows all the Associations that belong to a UMLClassifier.
+ * @author Paul Hensgen <phensgen@techie.com>
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class AssocPage : public QWidget {
+ Q_OBJECT
+public:
+ /**
+ * Constructs an instance of AssocPage.
+ *
+ * @param parent The parent of the page
+ * @param v The view the UMLObject being represented.
+ * @param o The UMLObject being represented
+ */
+ AssocPage(QWidget *parent, UMLView * v, UMLObject * o);
+
+ /**
+ * Standard deconstructor.
+ */
+ ~AssocPage();
+private:
+ UMLObject * m_pObject;
+ UMLView * m_pView;
+ QListBox * m_pAssocLB;
+ QGroupBox * m_pAssocGB;
+ AssociationWidgetList m_List;
+ ListPopupMenu * m_pMenu;
+
+ /**
+ * Fills the list box with the objects associations.
+ */
+ void fillListBox();
+public slots:
+ void slotDoubleClick(QListBoxItem * i);
+ void slotRightButtonClicked(QListBoxItem */* item*/, const QPoint &/* p*/);
+ void slotRightButtonPressed(QListBoxItem * item, const QPoint & p);
+ void slotPopupMenuSel(int id);
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/assocpropdlg.cpp b/umbrello/umbrello/dialogs/assocpropdlg.cpp
new file mode 100644
index 00000000..2458da13
--- /dev/null
+++ b/umbrello/umbrello/dialogs/assocpropdlg.cpp
@@ -0,0 +1,115 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "assocpropdlg.h"
+
+// qt/kde includes
+#include <qlayout.h>
+#include <qlabel.h>
+
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kiconloader.h>
+#include <kdebug.h>
+
+// local includes
+#include "assocgenpage.h"
+#include "assocrolepage.h"
+#include "classpropdlg.h"
+#include "classgenpage.h"
+#include "umlwidgetcolorpage.h"
+
+#include "../umlobject.h"
+#include "../umldoc.h"
+#include "../objectwidget.h"
+#include "../uml.h"
+#include "../umlview.h"
+
+
+AssocPropDlg::AssocPropDlg (QWidget *parent, AssociationWidget * assocWidget, int pageNum)
+ : KDialogBase(IconList, i18n("Association Properties"), Ok | Apply | Cancel | Help,
+ Ok, parent, "_ASSOCPROPDLG_", true, true)
+{
+ init();
+ m_pAssoc = assocWidget;
+
+ m_pDoc = ((UMLApp *)parent) -> getDocument(); // needed?
+
+ setupPages(assocWidget);
+ showPage(pageNum);
+}
+
+AssocPropDlg::~AssocPropDlg() { }
+
+void AssocPropDlg::init ( )
+{
+ m_pAssoc = 0;
+ m_pGenPage = 0;
+ m_pRolePage = 0;
+}
+
+void AssocPropDlg::slotOk() {
+ slotApply();
+ KDialogBase::accept();
+}
+
+void AssocPropDlg::slotApply() {
+
+ if (m_pGenPage) {
+ m_pGenPage->updateObject();
+ }
+
+ if (m_pRolePage) {
+ m_pRolePage->updateObject();
+ }
+
+ if (m_pAssoc) {
+ m_pAssoc->lwSetFont( m_pChooser->font() );
+ }
+
+
+}
+
+// void AssocPropDlg::setupPages (UMLObject * c)
+void AssocPropDlg::setupPages (AssociationWidget *assocWidget)
+{
+
+ // general page
+ QFrame *page = addPage( i18n("General"), i18n("General Settings"), DesktopIcon( "misc") );
+ QHBoxLayout *genLayout = new QHBoxLayout(page);
+ page -> setMinimumSize(310, 330);
+ m_pGenPage = new AssocGenPage (m_pDoc, page, assocWidget);
+ genLayout -> addWidget(m_pGenPage);
+
+ // role page
+ QFrame * newPage = addPage( i18n("Roles"), i18n("Role Settings"), DesktopIcon( "misc") );
+ QHBoxLayout * roleLayout = new QHBoxLayout(newPage);
+ // newPage -> setMinimumSize(310, 330);
+ m_pRolePage = new AssocRolePage(m_pDoc, newPage, assocWidget);
+ roleLayout -> addWidget(m_pRolePage);
+
+ setupFontPage();
+
+}
+
+void AssocPropDlg::setupFontPage()
+{
+ if( !m_pAssoc)
+ return;
+
+ QVBox *page = addVBoxPage( i18n("Font"), i18n("Font Settings"), DesktopIcon( "fonts"));
+ m_pChooser = new KFontChooser( (QWidget*)page, "font", false, QStringList(), false);
+ m_pChooser->setFont( m_pAssoc->getFont());
+ m_pChooser->setSampleText(i18n("Association font"));
+}
+
+#include "assocpropdlg.moc"
diff --git a/umbrello/umbrello/dialogs/assocpropdlg.h b/umbrello/umbrello/dialogs/assocpropdlg.h
new file mode 100644
index 00000000..a5bdad6e
--- /dev/null
+++ b/umbrello/umbrello/dialogs/assocpropdlg.h
@@ -0,0 +1,72 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef ASSOCPROPDLG_H
+#define ASSOCPROPDLG_H
+
+//kde class includes
+#include <kdialogbase.h>
+#include <kfontdialog.h>
+#include "../associationwidget.h"
+
+class AssocRolePage;
+class AssocGenPage;
+class UMLDoc;
+// class ObjectWidget;
+// class UMLObject;
+// class UMLWidget;
+
+/**
+ * Based off of AssocPropDlg class
+ * @author Brian Thomas <Brian.A.Thomas@gsfc.nasa.gov>
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class AssocPropDlg : public KDialogBase {
+ Q_OBJECT
+public:
+
+ /**
+ * Sets up a Association Properties Dialog.
+ * @param parent The parent of the AssocPropDlg
+ * @param a The Association Widget to display properties of.
+ * @param pageNum The page to show first.
+ */
+
+ AssocPropDlg(QWidget *parent, AssociationWidget *a, int pageNum = 0);
+
+ /**
+ * Standard deconstructor
+ */
+ ~AssocPropDlg();
+
+ enum Page { page_gen = 0, page_role, page_font };
+
+protected:
+ void setupPages(AssociationWidget * assocWidget);
+ void setupFontPage();
+ void init();
+
+protected slots:
+ void slotOk();
+ void slotApply();
+
+private:
+ AssocGenPage *m_pGenPage;
+ AssocRolePage *m_pRolePage;
+ KFontChooser * m_pChooser;
+ AssociationWidget *m_pAssoc;
+
+ UMLDoc *m_pDoc; // is this needed??
+
+};
+
+#endif /* ASSOCPROPDLG_H */
+
diff --git a/umbrello/umbrello/dialogs/assocrolepage.cpp b/umbrello/umbrello/dialogs/assocrolepage.cpp
new file mode 100644
index 00000000..807a7e1e
--- /dev/null
+++ b/umbrello/umbrello/dialogs/assocrolepage.cpp
@@ -0,0 +1,293 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "assocrolepage.h"
+
+// qt includes
+#include <qlayout.h>
+
+// kde includes
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+
+// local includes
+#include "../dialog_utils.h"
+
+AssocRolePage::AssocRolePage (UMLDoc *d, QWidget *parent, AssociationWidget *assoc)
+ : QWidget(parent)
+{
+
+ m_pAssociationWidget = assoc;
+ m_pWidget = 0;
+ m_pUmldoc = d;
+
+ m_pRoleALE = 0;
+ m_pRoleBLE = 0;
+ m_pMultiALE = 0;
+ m_pMultiBLE = 0;
+
+ constructWidget();
+
+}
+
+AssocRolePage::~AssocRolePage() {}
+
+void AssocRolePage::constructWidget() {
+
+ // underlying roles and objects
+ QString nameA = m_pAssociationWidget->getRoleName(Uml::A);
+ QString nameB = m_pAssociationWidget->getRoleName(Uml::B);
+ QString titleA = i18n("Role A Properties");
+ QString titleB = i18n("Role B Properties");
+ QString widgetNameA = m_pAssociationWidget->getWidget(Uml::A)->getName();
+ QString widgetNameB = m_pAssociationWidget->getWidget(Uml::B)->getName();
+ if(!widgetNameA.isEmpty())
+ titleA.append(" (" + widgetNameA + ')');
+ if(!widgetNameB.isEmpty())
+ titleB.append(" (" + widgetNameB + ')');
+
+ // general configuration of the GUI
+ int margin = fontMetrics().height();
+
+ QGridLayout * mainLayout = new QGridLayout(this, 4, 2);
+ mainLayout -> setSpacing(6);
+
+ // group boxes for role, documentation properties
+ QGroupBox *propsAGB = new QGroupBox(this);
+ QGroupBox *propsBGB = new QGroupBox(this);
+ QButtonGroup * scopeABG = new QButtonGroup(i18n("Role A Visibility"), this );
+ QButtonGroup * scopeBBG = new QButtonGroup(i18n("Role B Visibility"), this );
+ QButtonGroup * changeABG = new QButtonGroup(i18n("Role A Changeability"), this );
+ QButtonGroup * changeBBG = new QButtonGroup(i18n("Role B Changeability"), this );
+ QGroupBox *docAGB = new QGroupBox(this);
+ QGroupBox *docBGB = new QGroupBox(this);
+ propsAGB -> setTitle(titleA);
+ propsBGB -> setTitle(titleB);
+ docAGB -> setTitle(i18n("Documentation"));
+ docBGB -> setTitle(i18n("Documentation"));
+
+ QGridLayout * propsALayout = new QGridLayout(propsAGB, 2, 2);
+ propsALayout -> setSpacing(6);
+ propsALayout -> setMargin(margin);
+
+ QGridLayout * propsBLayout = new QGridLayout(propsBGB, 3, 2);
+ propsBLayout -> setSpacing(6);
+ propsBLayout -> setMargin(margin);
+
+ // Properties
+ //
+
+ // Rolename A
+ QLabel *pRoleAL = NULL;
+ Dialog_Utils::makeLabeledEditField( propsAGB, propsALayout, 0,
+ pRoleAL, i18n("Rolename:"),
+ m_pRoleALE, nameA );
+
+ // Multi A
+ QLabel *pMultiAL = NULL;
+ Dialog_Utils::makeLabeledEditField( propsAGB, propsALayout, 1,
+ pMultiAL, i18n("Multiplicity:"),
+ m_pMultiALE, m_pAssociationWidget->getMulti(Uml::A) );
+
+ // Visibility A
+ QHBoxLayout * scopeALayout = new QHBoxLayout(scopeABG);
+ scopeALayout -> setMargin(margin);
+
+ m_PublicARB = new QRadioButton(i18n("Public"), scopeABG);
+ scopeALayout -> addWidget(m_PublicARB);
+
+ m_PrivateARB = new QRadioButton(i18n("Private"), scopeABG);
+ scopeALayout -> addWidget(m_PrivateARB);
+
+ m_ProtectedARB = new QRadioButton(i18n("Protected"), scopeABG);
+ scopeALayout -> addWidget(m_ProtectedARB);
+
+ m_ImplementationARB = new QRadioButton(i18n("Implementation"), scopeABG);
+ scopeALayout -> addWidget(m_ImplementationARB);
+
+ Uml::Visibility scope = m_pAssociationWidget->getVisibility(Uml::A);
+ if( scope == Uml::Visibility::Public )
+ m_PublicARB -> setChecked( true );
+ else if( scope == Uml::Visibility::Private )
+ m_PrivateARB -> setChecked( true );
+ else if( scope == Uml::Visibility::Implementation )
+ m_PrivateARB -> setChecked( true );
+ else
+ m_ProtectedARB -> setChecked( true );
+
+ // Changeability A
+ QHBoxLayout * changeALayout = new QHBoxLayout(changeABG);
+ changeALayout -> setMargin(margin);
+
+ m_ChangeableARB = new QRadioButton(i18n("Changeable"), changeABG);
+ changeALayout -> addWidget(m_ChangeableARB);
+
+ m_FrozenARB = new QRadioButton(i18n("Frozen"), changeABG);
+ changeALayout -> addWidget(m_FrozenARB);
+
+ m_AddOnlyARB = new QRadioButton(i18n("Add only"), changeABG);
+ changeALayout -> addWidget(m_AddOnlyARB);
+
+ Uml::Changeability_Type changeability = m_pAssociationWidget->getChangeability(Uml::A);
+ if( changeability == Uml::chg_Changeable )
+ m_ChangeableARB -> setChecked( true );
+ else if( changeability == Uml::chg_Frozen )
+ m_FrozenARB -> setChecked( true );
+ else
+ m_AddOnlyARB -> setChecked( true );
+
+ // Rolename B
+ QLabel * pRoleBL = NULL;
+ Dialog_Utils::makeLabeledEditField( propsBGB, propsBLayout, 0,
+ pRoleBL, i18n("Rolename:"),
+ m_pRoleBLE, nameB );
+
+ // Multi B
+ QLabel * pMultiBL = NULL;
+ Dialog_Utils::makeLabeledEditField( propsBGB, propsBLayout, 1,
+ pMultiBL, i18n("Multiplicity:"),
+ m_pMultiBLE, m_pAssociationWidget->getMulti(Uml::B) );
+
+ // Visibility B
+
+ QHBoxLayout * scopeBLayout = new QHBoxLayout(scopeBBG);
+ scopeBLayout -> setMargin(margin);
+
+ m_PublicBRB = new QRadioButton(i18n("Public"), scopeBBG);
+ scopeBLayout -> addWidget(m_PublicBRB);
+
+ m_PrivateBRB = new QRadioButton(i18n("Private"), scopeBBG);
+ scopeBLayout -> addWidget(m_PrivateBRB);
+
+ m_ProtectedBRB = new QRadioButton(i18n("Protected"), scopeBBG);
+ scopeBLayout -> addWidget(m_ProtectedBRB);
+
+ m_ImplementationBRB = new QRadioButton(i18n("Implementation"), scopeBBG);
+ scopeBLayout -> addWidget(m_ImplementationBRB);
+
+ scope = m_pAssociationWidget->getVisibility(Uml::B);
+ if( scope == Uml::Visibility::Public )
+ m_PublicBRB -> setChecked( true );
+ else if( scope == Uml::Visibility::Private )
+ m_PrivateBRB -> setChecked( true );
+ else if( scope == Uml::Visibility::Protected )
+ m_ProtectedBRB -> setChecked( true );
+ else
+ m_ImplementationBRB -> setChecked( true );
+
+ // Changeability B
+ QHBoxLayout * changeBLayout = new QHBoxLayout(changeBBG);
+ changeBLayout -> setMargin(margin);
+
+ m_ChangeableBRB = new QRadioButton(i18n("Changeable"), changeBBG);
+ changeBLayout -> addWidget(m_ChangeableBRB);
+
+ m_FrozenBRB = new QRadioButton(i18n("Frozen"), changeBBG);
+ changeBLayout -> addWidget(m_FrozenBRB);
+
+ m_AddOnlyBRB = new QRadioButton(i18n("Add only"), changeBBG);
+ changeBLayout -> addWidget(m_AddOnlyBRB);
+
+ changeability = m_pAssociationWidget->getChangeability(Uml::B);
+ if( changeability == Uml::chg_Changeable )
+ m_ChangeableBRB -> setChecked( true );
+ else if( changeability == Uml::chg_Frozen )
+ m_FrozenBRB -> setChecked( true );
+ else
+ m_AddOnlyBRB -> setChecked( true );
+
+ // Documentation
+ //
+
+ // Document A
+ QHBoxLayout * docALayout = new QHBoxLayout(docAGB);
+ docALayout -> setMargin(margin);
+ m_pDocA = new QMultiLineEdit(docAGB);
+ docALayout -> addWidget(m_pDocA);
+ m_pDocA-> setText(m_pAssociationWidget-> getRoleDoc(Uml::A));
+ // m_pDocA-> setText("<<not implemented yet>>");
+ // m_pDocA-> setEnabled(false);
+ m_pDocA->setWordWrap(QMultiLineEdit::WidgetWidth);
+
+ // Document B
+ QHBoxLayout * docBLayout = new QHBoxLayout(docBGB);
+ docBLayout -> setMargin(margin);
+ m_pDocB = new QMultiLineEdit(docBGB);
+ docBLayout -> addWidget(m_pDocB);
+ m_pDocB-> setText(m_pAssociationWidget-> getRoleDoc(Uml::B));
+ // m_pDocB-> setEnabled(false);
+ m_pDocB->setWordWrap(QMultiLineEdit::WidgetWidth);
+
+ // add group boxes to main layout
+ mainLayout -> addWidget( propsAGB, 0, 0);
+ mainLayout -> addWidget( scopeABG, 1, 0);
+ mainLayout -> addWidget(changeABG, 2, 0);
+ mainLayout -> addWidget( docAGB, 3, 0);
+ mainLayout -> addWidget( propsBGB, 0, 1);
+ mainLayout -> addWidget( scopeBBG, 1, 1);
+ mainLayout -> addWidget(changeBBG, 2, 1);
+ mainLayout -> addWidget( docBGB, 3, 1);
+
+}
+
+void AssocRolePage::updateObject() {
+
+ if(m_pAssociationWidget) {
+
+ // set props
+ m_pAssociationWidget->setRoleName(m_pRoleALE->text(), Uml::A);
+ m_pAssociationWidget->setRoleName(m_pRoleBLE->text(), Uml::B);
+ m_pAssociationWidget->setMulti(m_pMultiALE->text(), Uml::A);
+ m_pAssociationWidget->setMulti(m_pMultiBLE->text(), Uml::B);
+
+ if(m_PrivateARB->isChecked())
+ m_pAssociationWidget->setVisibility(Uml::Visibility::Private, Uml::A);
+ else if(m_ProtectedARB->isChecked())
+ m_pAssociationWidget->setVisibility(Uml::Visibility::Protected, Uml::A);
+ else if(m_PublicARB->isChecked())
+ m_pAssociationWidget->setVisibility(Uml::Visibility::Public, Uml::A);
+ else if(m_ImplementationARB->isChecked())
+ m_pAssociationWidget->setVisibility(Uml::Visibility::Implementation, Uml::A);
+
+ if(m_PrivateBRB->isChecked())
+ m_pAssociationWidget->setVisibility(Uml::Visibility::Private, Uml::B);
+ else if(m_ProtectedBRB->isChecked())
+ m_pAssociationWidget->setVisibility(Uml::Visibility::Protected, Uml::B);
+ else if(m_PublicBRB->isChecked())
+ m_pAssociationWidget->setVisibility(Uml::Visibility::Public, Uml::B);
+ else if(m_ImplementationBRB->isChecked())
+ m_pAssociationWidget->setVisibility(Uml::Visibility::Implementation, Uml::B);
+
+ if(m_FrozenARB->isChecked())
+ m_pAssociationWidget->setChangeability(Uml::chg_Frozen, Uml::A);
+ else if(m_AddOnlyARB->isChecked())
+ m_pAssociationWidget->setChangeability(Uml::chg_AddOnly, Uml::A);
+ else
+ m_pAssociationWidget->setChangeability(Uml::chg_Changeable, Uml::A);
+
+ if(m_FrozenBRB->isChecked())
+ m_pAssociationWidget->setChangeability(Uml::chg_Frozen, Uml::B);
+ else if(m_AddOnlyBRB->isChecked())
+ m_pAssociationWidget->setChangeability(Uml::chg_AddOnly, Uml::B);
+ else
+ m_pAssociationWidget->setChangeability(Uml::chg_Changeable, Uml::B);
+
+ m_pAssociationWidget->setRoleDoc(m_pDocA->text(), Uml::A);
+ m_pAssociationWidget->setRoleDoc(m_pDocB->text(), Uml::B);
+
+ } //end if m_pAssociationWidget
+
+}
+
+
+#include "assocrolepage.moc"
diff --git a/umbrello/umbrello/dialogs/assocrolepage.h b/umbrello/umbrello/dialogs/assocrolepage.h
new file mode 100644
index 00000000..c1c4d603
--- /dev/null
+++ b/umbrello/umbrello/dialogs/assocrolepage.h
@@ -0,0 +1,85 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef ASSOCROLEPAGE_H
+#define ASSOCROLEPAGE_H
+
+//quicktime class includes
+#include <qwidget.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qbuttongroup.h>
+#include <qmultilineedit.h>
+#include <qradiobutton.h>
+#include <qcheckbox.h>
+
+//my class includes
+#include "../umlobject.h"
+#include "../objectwidget.h"
+#include "../umldoc.h"
+#include "../associationwidget.h"
+
+/**
+ * Displays properties of a UMLObject in a dialog box. This is not usually directly
+ * called. The class @ref AssocPropDlg will set this up for you.
+ *
+ * @short Display properties on a UMLObject.
+ * @author Paul Hensgen <phensgen@techie.com>
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class AssocRolePage : public QWidget {
+ Q_OBJECT
+public:
+
+ /**
+ * Sets up the AssocRolePage.
+ *
+ * @param d The UMLDoc which controls controls object creation.
+ * @param parent The parent to the AssocRolePage.
+ * @param a The AssociationWidget to display the properties of.
+ */
+ AssocRolePage(UMLDoc *d, QWidget *parent, AssociationWidget *a);
+
+ /**
+ * Standard deconstructor.
+ */
+ ~AssocRolePage();
+
+ /**
+ * Will move information from the dialog into the object.
+ * Call when the ok or apply button is pressed.
+ */
+ void updateObject();
+
+private:
+ QLineEdit *m_pRoleALE, *m_pRoleBLE, *m_pMultiALE, *m_pMultiBLE;
+ QMultiLineEdit *m_pDocA, *m_pDocB;
+ AssociationWidget *m_pAssociationWidget;
+ UMLDoc * m_pUmldoc;
+ ObjectWidget *m_pWidget;
+ QRadioButton *m_PublicARB, *m_ProtectedARB, *m_PrivateARB, *m_ImplementationARB;
+ QRadioButton *m_PublicBRB, *m_ProtectedBRB, *m_PrivateBRB, *m_ImplementationBRB;
+ QRadioButton *m_ChangeableARB, *m_AddOnlyARB, *m_FrozenARB;
+ QRadioButton *m_ChangeableBRB, *m_AddOnlyBRB, *m_FrozenBRB;
+
+ void constructWidget();
+
+public slots:
+ /**
+ * When the draw as actor check box is toggled, the draw
+ * as multi instance need to be enabled/disabled. They
+ * both can't be available at the same time.
+ */
+ // void slotActorToggled( bool state );
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/classgenpage.cpp b/umbrello/umbrello/dialogs/classgenpage.cpp
new file mode 100644
index 00000000..01b3d3c7
--- /dev/null
+++ b/umbrello/umbrello/dialogs/classgenpage.cpp
@@ -0,0 +1,472 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// my own header
+#include "classgenpage.h"
+
+// qt includes
+#include <qlayout.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qbuttongroup.h>
+#include <qmultilineedit.h>
+#include <qradiobutton.h>
+#include <qcheckbox.h>
+
+// kde includes
+#include <klocale.h>
+#include <kdebug.h>
+#include <kmessagebox.h>
+#include <kcombobox.h>
+
+// my class includes
+#include "../umlobject.h"
+#include "../objectwidget.h"
+#include "../uml.h"
+#include "../umldoc.h"
+#include "../artifact.h"
+#include "../component.h"
+#include "../umlview.h"
+#include "../stereotype.h"
+
+ClassGenPage::ClassGenPage(UMLDoc* d, QWidget* parent, UMLObject* o) : QWidget(parent) {
+ m_pWidget = 0;
+ m_pObject = 0;
+ m_pInstanceWidget = 0;
+ QString name;
+ int margin = fontMetrics().height();
+ Uml::Object_Type t = o -> getBaseType();
+ m_pUmldoc = d;
+ if (t == Uml::ot_Class) {
+ name = i18n("Class &name:");
+ } else if (t == Uml::ot_Actor) {
+ name = i18n("Actor &name:");
+ } else if (t == Uml::ot_Package) {
+ name = i18n("Package &name:");
+ } else if (t == Uml::ot_UseCase) {
+ name = i18n("Use case &name:");
+ } else if (t == Uml::ot_Interface) {
+ name = i18n("Interface &name:");
+ } else if (t == Uml::ot_Component) {
+ name = i18n("Component &name:");
+ } else if (t == Uml::ot_Artifact) {
+ name = i18n("Artifact &name:");
+ } else if (t == Uml::ot_Enum) {
+ name = i18n("Enum &name:");
+ } else if (t == Uml::ot_Datatype) {
+ name = i18n("Datatype &name:");
+ } else if (t == Uml::ot_Entity) {
+ name = i18n("Entity &name:");
+ } else {
+ kWarning() << "creating class gen page for unknown widget type" << endl;
+ }
+ setMinimumSize(310,330);
+ QVBoxLayout * topLayout = new QVBoxLayout(this);
+ topLayout -> setSpacing(6);
+
+ //setup name
+ QGridLayout * m_pNameLayout = new QGridLayout(topLayout, 4, 2);
+ m_pNameLayout -> setSpacing(6);
+ m_pNameL = new QLabel(this);
+ m_pNameL -> setText(name);
+ m_pNameLayout -> addWidget(m_pNameL, 0, 0);
+
+ m_pClassNameLE = new QLineEdit(this);
+ m_pNameLayout -> addWidget(m_pClassNameLE, 0, 1);
+ m_pClassNameLE->setFocus();
+ m_pNameL->setBuddy(m_pClassNameLE);
+
+ m_pStereoTypeCB = 0;
+ m_pPackageLE = 0;
+ m_pAbstractCB = 0;
+ m_pDeconCB = 0;
+
+ m_pStereoTypeL = new QLabel(i18n("&Stereotype name:"), this);
+ m_pNameLayout -> addWidget(m_pStereoTypeL, 1, 0);
+
+ m_pStereoTypeCB = new KComboBox(true, this);
+ m_pNameLayout -> addWidget(m_pStereoTypeCB, 1, 1);
+
+ m_pStereoTypeCB->setCurrentText( o->getStereotype() );
+ m_pStereoTypeL->setBuddy(m_pStereoTypeCB);
+
+ if (t == Uml::ot_Interface || t == Uml::ot_Datatype || t == Uml::ot_Enum) {
+ m_pStereoTypeCB->setEditable(false);
+ }
+
+ if (t == Uml::ot_Class || t == Uml::ot_Interface) {
+ m_pPackageL = new QLabel(i18n("&Package name:"), this);
+ m_pNameLayout -> addWidget(m_pPackageL, 2, 0);
+
+ m_pPackageLE = new QLineEdit(this);
+ m_pNameLayout -> addWidget(m_pPackageLE, 2, 1);
+
+ m_pPackageLE -> setText(o -> getPackage());
+ m_pPackageLE -> setEnabled(false);
+ m_pPackageL->setBuddy(m_pPackageLE);
+ }
+
+ if (t == Uml::ot_Class || t == Uml::ot_UseCase ) {
+ QString abstractCaption;
+ if ( t == Uml::ot_Class ) {
+ abstractCaption = i18n("A&bstract class");
+ } else {
+ abstractCaption = i18n("A&bstract use case");
+ }
+ m_pAbstractCB = new QCheckBox( abstractCaption, this );
+ m_pAbstractCB -> setChecked( o -> getAbstract() );
+ m_pNameLayout -> addWidget( m_pAbstractCB, 3, 0 );
+ }
+
+ if (t == Uml::ot_Component) {
+ m_pExecutableCB = new QCheckBox(i18n("&Executable"), this);
+ m_pExecutableCB->setChecked( (static_cast<UMLComponent*>(o))->getExecutable() );
+ m_pNameLayout->addWidget( m_pExecutableCB, 3, 0 );
+ }
+
+ if (t == Uml::ot_Artifact) {
+ //setup artifact draw as
+ m_pDrawAsBG = new QButtonGroup(i18n("Draw As"), this);
+ QHBoxLayout* drawAsLayout = new QHBoxLayout(m_pDrawAsBG);
+ drawAsLayout->setMargin(margin);
+ m_pDrawAsBG->setExclusive(true);
+
+ m_pDefaultRB = new QRadioButton(i18n("&Default"), m_pDrawAsBG);
+ drawAsLayout->addWidget(m_pDefaultRB);
+
+ m_pFileRB = new QRadioButton(i18n("&File"), m_pDrawAsBG);
+ drawAsLayout->addWidget(m_pFileRB);
+
+ m_pLibraryRB = new QRadioButton(i18n("&Library"), m_pDrawAsBG);
+ drawAsLayout->addWidget(m_pLibraryRB);
+
+ m_pTableRB = new QRadioButton(i18n("&Table"), m_pDrawAsBG);
+ drawAsLayout->addWidget(m_pTableRB);
+
+ topLayout->addWidget(m_pDrawAsBG);
+
+ UMLArtifact::Draw_Type drawAs = (static_cast<UMLArtifact*>(o))->getDrawAsType();
+
+ if (drawAs == UMLArtifact::file) {
+ m_pFileRB->setChecked(true);
+ } else if (drawAs == UMLArtifact::library) {
+ m_pLibraryRB->setChecked(true);
+ } else if (drawAs == UMLArtifact::table) {
+ m_pTableRB->setChecked(true);
+ } else {
+ m_pDefaultRB->setChecked(true);
+ }
+ }
+
+ //setup scope
+ m_pButtonBG = new QButtonGroup(i18n("Visibility"), this);
+ QHBoxLayout * scopeLayout = new QHBoxLayout(m_pButtonBG);
+ scopeLayout -> setMargin(margin);
+ m_pButtonBG -> setExclusive(true);
+
+ m_pPublicRB = new QRadioButton(i18n("P&ublic"), m_pButtonBG);
+ scopeLayout -> addWidget(m_pPublicRB);
+
+ m_pPrivateRB = new QRadioButton(i18n("P&rivate"), m_pButtonBG);
+ scopeLayout -> addWidget(m_pPrivateRB);
+
+ m_pProtectedRB = new QRadioButton(i18n("Pro&tected"), m_pButtonBG);
+ scopeLayout -> addWidget(m_pProtectedRB);
+ topLayout -> addWidget(m_pButtonBG);
+
+ m_pImplementationRB = new QRadioButton(i18n("Imple&mentation"), m_pButtonBG);
+ scopeLayout -> addWidget(m_pImplementationRB);
+ topLayout -> addWidget(m_pButtonBG);
+ //setup documentation
+ m_pDocGB = new QGroupBox(this);
+ QHBoxLayout * docLayout = new QHBoxLayout(m_pDocGB);
+ docLayout -> setMargin(margin);
+ m_pDocGB -> setTitle(i18n("Documentation"));
+
+ m_pDoc = new QMultiLineEdit(m_pDocGB);
+ docLayout -> addWidget(m_pDoc);
+ topLayout -> addWidget(m_pDocGB);
+
+ m_pObject = o;
+ //setup fields
+ m_pClassNameLE -> setText(o -> getName());
+ m_pDoc-> setText(o -> getDoc());
+ Uml::Visibility s = o -> getVisibility();
+ if(s == Uml::Visibility::Public)
+ m_pPublicRB->setChecked(true);
+ else if(s == Uml::Visibility::Private)
+ m_pPrivateRB->setChecked(true);
+ else if(s == Uml::Visibility::Protected)
+ m_pProtectedRB->setChecked(true);
+ else
+ m_pImplementationRB -> setChecked(true);
+
+ // manage stereotypes
+ m_pStereoTypeCB -> setDuplicatesEnabled(false);//only allow one of each type in box
+ m_pStereoTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
+ insertStereotype (QString("")); // an empty stereotype is the default
+ int defaultStereotype=0;
+ bool foundDefaultStereotype = false;
+ for (UMLStereotypeListIt it(m_pUmldoc->getStereotypes()); it.current(); ++it) {
+ if (!foundDefaultStereotype) {
+ if ( m_pObject->getStereotype() == it.current()->getName()) {
+ foundDefaultStereotype = true;
+ }
+ defaultStereotype++;
+ }
+ insertStereotype (it.current()->getName());
+ }
+ // lookup for a default stereotype, if the operation doesn't have one
+ if (foundDefaultStereotype)
+ m_pStereoTypeCB -> setCurrentItem(defaultStereotype);
+ else
+ m_pStereoTypeCB -> setCurrentItem(-1);
+
+ ///////////
+ m_pDoc->setWordWrap(QMultiLineEdit::WidgetWidth);
+ //////////
+}
+
+ClassGenPage::ClassGenPage(UMLDoc* d, QWidget* parent, ObjectWidget* o) : QWidget(parent) {
+ m_pObject = 0;
+ m_pInstanceWidget = 0;
+ m_pWidget = o;
+ m_pDeconCB = 0;
+ m_pMultiCB = 0;
+ int margin = fontMetrics().height();
+ //int t = o -> getBaseType();
+ m_pUmldoc = d;
+ setMinimumSize(310,330);
+ QGridLayout * topLayout = new QGridLayout(this, 2, 1);
+ topLayout -> setSpacing(6);
+
+ //setup name
+ QGridLayout * m_pNameLayout = new QGridLayout(topLayout, 3, 2);
+ m_pNameLayout -> setSpacing(6);
+ m_pNameL = new QLabel(this);
+ m_pNameL -> setText(i18n("Class name:"));
+ m_pNameLayout -> addWidget(m_pNameL, 0, 0);
+
+ m_pClassNameLE = new QLineEdit(this);
+ m_pClassNameLE -> setText(o -> getName());
+ m_pNameLayout -> addWidget(m_pClassNameLE, 0, 1);
+
+ m_pInstanceL = new QLabel(this);
+ m_pInstanceL -> setText(i18n("Instance name:"));
+ m_pNameLayout -> addWidget(m_pInstanceL, 1, 0);
+
+ m_pInstanceLE = new QLineEdit(this);
+ m_pInstanceLE -> setText(o -> getInstanceName());
+ m_pNameLayout -> addWidget(m_pInstanceLE, 1, 1);
+ UMLView *view = UMLApp::app()->getCurrentView();
+
+ m_pDrawActorCB = new QCheckBox( i18n( "Draw as actor" ) , this );
+ m_pDrawActorCB -> setChecked( o -> getDrawAsActor() );
+ m_pNameLayout -> addWidget( m_pDrawActorCB, 2, 0 );
+
+ if(view -> getType() == Uml::dt_Collaboration) {
+ m_pMultiCB = new QCheckBox(i18n("Multiple instance"), this);
+ m_pMultiCB -> setChecked(o -> getMultipleInstance());
+ m_pNameLayout -> addWidget(m_pMultiCB, 2,1);
+ if( m_pDrawActorCB -> isChecked() )
+ m_pMultiCB -> setEnabled( false );
+ } else//sequence diagram
+ {
+ m_pDeconCB = new QCheckBox(i18n("Show destruction"), this);
+ m_pDeconCB->setChecked(o->getShowDestruction());
+ m_pNameLayout -> addWidget(m_pDeconCB, 2,1);
+ }
+ //setup documentation
+ m_pDocGB = new QGroupBox(this);
+ topLayout -> addWidget(m_pDocGB, 1, 0);
+ QHBoxLayout * docLayout = new QHBoxLayout(m_pDocGB);
+ docLayout -> setMargin(margin);
+ m_pDocGB -> setTitle(i18n("Documentation"));
+
+ m_pDoc = new QMultiLineEdit(m_pDocGB);
+ m_pDoc->setWordWrap(QMultiLineEdit::WidgetWidth);
+ m_pDoc-> setText(o -> getDoc());
+ docLayout -> addWidget(m_pDoc);
+ m_pObject = 0;//needs to be set to zero
+ if( m_pMultiCB )
+ connect( m_pDrawActorCB, SIGNAL( toggled( bool ) ), this, SLOT( slotActorToggled( bool ) ) );
+}
+
+ClassGenPage::ClassGenPage(UMLDoc* d, QWidget* parent, UMLWidget* widget) : QWidget(parent) {
+ m_pWidget = 0;
+ m_pObject = 0;
+ m_pInstanceWidget = widget;
+ m_pDeconCB = 0;
+ m_pMultiCB = 0;
+ int margin = fontMetrics().height();
+ //int t = o -> getBaseType();
+ m_pUmldoc = d;
+ setMinimumSize(310,330);
+ QGridLayout* topLayout = new QGridLayout(this, 2, 1);
+ topLayout->setSpacing(6);
+
+ //setup name
+ QGridLayout* m_pNameLayout = new QGridLayout(topLayout, 3, 2);
+ m_pNameLayout->setSpacing(6);
+ m_pNameL = new QLabel(this);
+ if (widget->getBaseType() == Uml::wt_Component) {
+ m_pNameL->setText(i18n("Component name:"));
+ } else if (widget->getBaseType() == Uml::wt_Node) {
+ m_pNameL->setText(i18n("Node name:"));
+ } else {
+ kWarning() << "ClassGenPage called on unknown widget type" << endl;
+ }
+ m_pNameLayout->addWidget(m_pNameL, 0, 0);
+
+ m_pClassNameLE = new QLineEdit(this);
+ m_pClassNameLE->setText(widget->getName());
+ m_pNameLayout->addWidget(m_pClassNameLE, 0, 1);
+
+ m_pStereoTypeL = new QLabel(i18n("Stereotype name:"), this);
+ m_pNameLayout->addWidget(m_pStereoTypeL, 1, 0);
+
+ m_pStereoTypeCB = new KComboBox(true, this);
+ m_pNameLayout->addWidget(m_pStereoTypeCB, 1, 1);
+
+ m_pStereoTypeCB->setCurrentText( widget->getUMLObject()->getStereotype() );
+ m_pStereoTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
+
+ m_pInstanceL = new QLabel(this);
+ m_pInstanceL->setText(i18n("Instance name:"));
+ m_pNameLayout->addWidget(m_pInstanceL, 2, 0);
+
+ m_pInstanceLE = new QLineEdit(this);
+ m_pInstanceLE->setText(widget->getInstanceName());
+ m_pNameLayout->addWidget(m_pInstanceLE, 2, 1);
+
+ //setup documentation
+ m_pDocGB = new QGroupBox(this);
+ topLayout->addWidget(m_pDocGB, 1, 0);
+ QHBoxLayout* docLayout = new QHBoxLayout(m_pDocGB);
+ docLayout->setMargin(margin);
+ m_pDocGB->setTitle(i18n("Documentation"));
+
+ m_pDoc = new QMultiLineEdit(m_pDocGB);
+ m_pDoc->setWordWrap(QMultiLineEdit::WidgetWidth);
+ m_pDoc->setText(widget->getDoc());
+ docLayout->addWidget(m_pDoc);
+ m_pObject = 0;//needs to be set to zero
+}
+
+ClassGenPage::~ClassGenPage() {}
+
+void ClassGenPage::insertStereotype( const QString& type, int index )
+{
+ m_pStereoTypeCB->insertItem( type, index );
+ m_pStereoTypeCB->completionObject()->addItem( type );
+}
+
+void ClassGenPage::updateObject() {
+ if(m_pObject) {
+ QString name = m_pClassNameLE -> text();
+
+ m_pObject -> setDoc(m_pDoc -> text());
+
+ if(m_pStereoTypeCB)
+ m_pObject -> setStereotype(m_pStereoTypeCB->currentText());
+ /**
+ * @todo enable the package lineedit field amd add logic for changing the package
+ if(m_pPackageLE)
+ m_pObject -> setPackage(m_pPackageLE -> text());
+ */
+
+ if ( m_pObject->getUMLPackage() == NULL ) {
+ kDebug() << k_funcinfo << "Parent package not set, setting it to Logical View folder"<<endl;
+ UMLFolder* folder = m_pUmldoc->getRootFolder( Uml::mt_Logical );
+ m_pObject->setUMLPackage( ( UMLPackage* )folder );
+ }
+
+ if( m_pAbstractCB )
+ m_pObject -> setAbstract( m_pAbstractCB -> isChecked() );
+ //make sure unique name
+ UMLObject *o = m_pUmldoc -> findUMLObject(name);
+ if(o && m_pObject != o) {
+ KMessageBox::sorry(this, i18n("The name you have chosen\nis already being used.\nThe name has been reset."),
+ i18n("Name is Not Unique"), false);
+ m_pClassNameLE -> setText( m_pObject -> getName() );
+ } else
+ m_pObject -> setName(name);
+ Uml::Visibility s;
+ if(m_pPublicRB -> isChecked())
+ s = Uml::Visibility::Public;
+ else if(m_pPrivateRB -> isChecked())
+ s = Uml::Visibility::Private;
+ else if(m_pProtectedRB->isChecked())
+ s = Uml::Visibility::Protected;
+ else
+ s = Uml::Visibility::Implementation;
+ m_pObject -> setVisibility(s);
+
+ if (m_pObject->getBaseType() == Uml::ot_Component) {
+ (static_cast<UMLComponent*>(m_pObject))->setExecutable( m_pExecutableCB->isChecked() );
+ }
+
+ if (m_pObject->getBaseType() == Uml::ot_Artifact) {
+ UMLArtifact::Draw_Type drawAsType;
+ if ( m_pFileRB->isChecked() ) {
+ drawAsType = UMLArtifact::file;
+ } else if ( m_pLibraryRB->isChecked() ) {
+ drawAsType = UMLArtifact::library;
+ } else if (m_pTableRB->isChecked() ) {
+ drawAsType = UMLArtifact::table;
+ } else {
+ drawAsType = UMLArtifact::defaultDraw;
+ }
+ (static_cast<UMLArtifact*>(m_pObject))->setDrawAsType(drawAsType);
+ }
+
+ }//end if m_pObject
+ else if(m_pWidget) {
+ m_pWidget -> setInstanceName(m_pInstanceLE -> text());
+ if(m_pMultiCB)
+ m_pWidget -> setMultipleInstance(m_pMultiCB -> isChecked());
+ m_pWidget -> setDrawAsActor( m_pDrawActorCB -> isChecked() );
+ if( m_pDeconCB )
+ m_pWidget -> setShowDestruction( m_pDeconCB -> isChecked() );
+ QString name = m_pClassNameLE -> text();
+ m_pWidget -> setDoc(m_pDoc -> text());
+ UMLObject * o = m_pWidget -> getUMLObject();
+ UMLObject * old = m_pUmldoc -> findUMLObject(name);
+ if(old && o != old) {
+ KMessageBox::sorry(this, i18n("The name you have chosen\nis already being used.\nThe name has been reset."),
+ i18n("Name is Not Unique"), false);
+ } else
+ o -> setName(name);
+ } else if (m_pInstanceWidget) {
+ m_pInstanceWidget->setInstanceName(m_pInstanceLE->text());
+ QString name = m_pClassNameLE->text();
+ m_pInstanceWidget->setDoc(m_pDoc->text());
+ UMLObject* o = m_pInstanceWidget->getUMLObject();
+ UMLObject* old = m_pUmldoc->findUMLObject(name);
+ if(old && o != old) {
+ KMessageBox::sorry(this, i18n("The name you have chosen\nis already being used.\nThe name has been reset."),
+ i18n("Name is Not Unique"), false);
+ } else {
+ o->setName(name);
+ }
+ o->setStereotype( m_pStereoTypeCB->currentText() );
+ }
+}
+
+void ClassGenPage::slotActorToggled( bool state ) {
+ if( m_pMultiCB )
+ m_pMultiCB -> setEnabled( !state );
+}
+
+
+
+#include "classgenpage.moc"
diff --git a/umbrello/umbrello/dialogs/classgenpage.h b/umbrello/umbrello/dialogs/classgenpage.h
new file mode 100644
index 00000000..6fd0f7d3
--- /dev/null
+++ b/umbrello/umbrello/dialogs/classgenpage.h
@@ -0,0 +1,109 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef CLASSGENPAGE_H
+#define CLASSGENPAGE_H
+
+#include <qwidget.h>
+
+class QGroupBox;
+class QLabel;
+class QLineEdit;
+class QButtonGroup;
+class QMultiLineEdit;
+class QRadioButton;
+class QCheckBox;
+class KComboBox;
+
+class UMLObject;
+class UMLWidget;
+class ObjectWidget;
+class UMLDoc;
+
+/**
+ * Displays properties of a UMLObject in a dialog box. This is not usually directly
+ * called. The class @ref ClassPropDlg will set this up for you.
+ *
+ * @short Display properties on a UMLObject.
+ * @author Paul Hensgen <phensgen@techie.com>
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class ClassGenPage : public QWidget {
+ Q_OBJECT
+public:
+
+ /**
+ * Sets up the ClassGenPage.
+ *
+ * @param d The UMLDoc which controls controls object creation.
+ * @param parent The parent to the ClassGenPage.
+ * @param o The UMLObject to display the properties of.
+ */
+ ClassGenPage(UMLDoc *d, QWidget *parent, UMLObject * o);
+
+ /**
+ * Sets up the ClassGenPage for an ObjectWidget
+ *
+ * @param d The UMLDoc which controls controls object creation.
+ * @param parent The parent to the ClassGenPage.
+ * @param o The ObjectWidget to display the properties of.
+ */
+ ClassGenPage(UMLDoc *d, QWidget *parent, ObjectWidget * o);
+
+ /**
+ * Sets up the ClassGenPage for a UMLWidget instance (used
+ * for component instances on deployment diagrams)
+ *
+ * @param d The UMLDoc which controls controls object creation.
+ * @param parent The parent to the ClassGenPage.
+ * @param widget The UMLWidget to display the properties of.
+ */
+ ClassGenPage(UMLDoc* d, QWidget* parent, UMLWidget* widget);
+
+ /**
+ * Standard deconstructor.
+ */
+ ~ClassGenPage();
+
+ /**
+ * Will move information from the dialog into the object.
+ * Call when the ok or apply button is pressed.
+ */
+ void updateObject();
+private:
+ QGroupBox *m_pDocGB;
+ QButtonGroup * m_pButtonBG;
+ QLabel * m_pNameL, * m_pInstanceL, * m_pStereoTypeL, * m_pPackageL;
+ QLineEdit * m_pClassNameLE, *m_pInstanceLE, * m_pPackageLE;
+ KComboBox * m_pStereoTypeCB;
+ QRadioButton *m_pPublicRB, *m_pPrivateRB, *m_pProtectedRB, *m_pImplementationRB;
+ QCheckBox * m_pMultiCB, * m_pDrawActorCB, * m_pAbstractCB, * m_pDeconCB;
+ QMultiLineEdit * m_pDoc;
+ UMLObject * m_pObject;
+ UMLDoc * m_pUmldoc;
+ ObjectWidget * m_pWidget;
+ UMLWidget* m_pInstanceWidget;
+ QButtonGroup* m_pDrawAsBG;
+ QRadioButton* m_pDefaultRB,* m_pFileRB,* m_pLibraryRB,* m_pTableRB;
+ QCheckBox* m_pExecutableCB;
+
+ void insertStereotype(const QString& type, int index = -1);
+
+public slots:
+ /**
+ * When the draw as actor check box is toggled, the draw
+ * as multi instance need to be enabled/disabled. They
+ * both can't be available at the same time.
+ */
+ void slotActorToggled( bool state );
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/classifierlistpage.cpp b/umbrello/umbrello/dialogs/classifierlistpage.cpp
new file mode 100644
index 00000000..d7148660
--- /dev/null
+++ b/umbrello/umbrello/dialogs/classifierlistpage.cpp
@@ -0,0 +1,607 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#include "classifierlistpage.h"
+#include "../classifierlistitem.h"
+#include "../umldoc.h"
+#include "../classifier.h"
+#include "../enum.h"
+#include "../entity.h"
+#include "../attribute.h"
+#include "../operation.h"
+#include "../template.h"
+#include "../enumliteral.h"
+#include "../entityattribute.h"
+#include "../object_factory.h"
+#include <kapplication.h>
+#include <kbuttonbox.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <qlayout.h>
+
+using namespace Uml;
+
+ClassifierListPage::ClassifierListPage(QWidget* parent, UMLClassifier* classifier,
+ UMLDoc* doc, Uml::Object_Type type) : QWidget(parent) {
+ m_itemType = type;
+ QString typeName("");
+ QString newItemType("");
+ if (type == ot_Attribute) {
+ typeName = i18n("Attributes");
+ newItemType = i18n("N&ew Attribute...");
+ } else if (type == ot_Operation) {
+ typeName = i18n("Operations");
+ newItemType = i18n("N&ew Operation...");
+ } else if (type == ot_Template) {
+ typeName = i18n("Templates");
+ newItemType = i18n("N&ew Template...");
+ } else if (type == ot_EnumLiteral) {
+ typeName = i18n("Enum Literals");
+ newItemType = i18n("N&ew Enum Literal...");
+ } else if (type == ot_EntityAttribute) {
+ typeName = i18n("Entity Attributes");
+ newItemType = i18n("N&ew Entity Attribute...");
+ } else {
+ kWarning() << "unknown listItem type in ClassifierListPage" << endl;
+ }
+
+ m_bSigWaiting = false;
+ m_pDoc = doc;
+ m_pClassifier = classifier;
+ m_pMenu = 0;
+ int margin = fontMetrics().height();
+ setMinimumSize(310,330);
+
+ //main layout contains our two group boxes, the list and the documentation
+ QVBoxLayout* mainLayout = new QVBoxLayout( this );
+ mainLayout->setSpacing(10);
+
+ //top group box, contains a vertical layout with list box above and buttons below
+ m_pItemListGB = new QGroupBox(typeName, this );
+ QVBoxLayout* listVBoxLayout = new QVBoxLayout( m_pItemListGB );
+ listVBoxLayout->setMargin(margin);
+ listVBoxLayout->setSpacing ( 10 );
+
+ //horizontal box contains the list box and the move up/down buttons
+ QHBoxLayout* listHBoxLayout = new QHBoxLayout( listVBoxLayout );
+ m_pItemListLB = new QListBox(m_pItemListGB);
+ listHBoxLayout->addWidget(m_pItemListLB);
+
+ //the move up/down buttons (another vertical box)
+ QVBoxLayout* buttonLayout = new QVBoxLayout( listHBoxLayout );
+ m_pTopArrowB = new KArrowButton( m_pItemListGB );
+ m_pTopArrowB->setEnabled( false );
+ buttonLayout->addWidget( m_pTopArrowB );
+
+ m_pUpArrowB = new KArrowButton( m_pItemListGB );
+ m_pUpArrowB->setEnabled( false );
+ buttonLayout->addWidget( m_pUpArrowB );
+
+ m_pDownArrowB = new KArrowButton( m_pItemListGB, Qt::DownArrow );
+ m_pDownArrowB->setEnabled( false );
+ buttonLayout->addWidget( m_pDownArrowB );
+
+ m_pBottomArrowB = new KArrowButton( m_pItemListGB, Qt::DownArrow );
+ m_pBottomArrowB->setEnabled( false );
+ buttonLayout->addWidget( m_pBottomArrowB );
+
+ //the action buttons
+ KButtonBox* buttonBox = new KButtonBox(m_pItemListGB);
+ buttonBox->addButton( newItemType, this, SLOT(slotNewListItem()) );
+ m_pDeleteListItemButton = buttonBox->addButton( i18n("&Delete"),
+ this, SLOT(slotDelete()) );
+ m_pPropertiesButton = buttonBox->addButton( i18n("&Properties"), this, SLOT(slotProperties()) );
+ listVBoxLayout->addWidget(buttonBox);
+
+ mainLayout->addWidget(m_pItemListGB);
+
+ m_pDocGB = new QGroupBox(i18n("Documentation"), this);
+ QVBoxLayout* docLayout = new QVBoxLayout( m_pDocGB );
+ m_pDocTE = new QTextEdit( m_pDocGB );
+ docLayout->setMargin(margin);
+ docLayout->setSpacing ( 10 );
+ docLayout->addWidget( m_pDocTE );
+ mainLayout->addWidget(m_pDocGB);
+
+ UMLClassifierListItemList itemList(getItemList());
+
+ // add each item in the list to the ListBox and connect each item modified signal
+ // to the ListItemModified slot in this class
+ for (UMLClassifierListItem* listItem = itemList.first(); listItem != 0; listItem = itemList.next() ) {
+ m_pItemListLB->insertItem(listItem->toString(Uml::st_SigNoVis));
+ connect( listItem, SIGNAL(modified()),this,SLOT(slotListItemModified()) );
+ }
+
+ enableWidgets(false);//disable widgets until an att is chosen
+ m_pOldListItem = 0;
+ connect(m_pItemListLB, SIGNAL(clicked(QListBoxItem*)), this, SLOT(slotClicked(QListBoxItem*)));
+ connect(m_pItemListLB, SIGNAL(selectionChanged(QListBoxItem*)), this, SLOT(slotClicked(QListBoxItem*)));
+
+ connect(m_pItemListLB, SIGNAL(rightButtonPressed(QListBoxItem*, const QPoint&)),
+ this, SLOT(slotRightButtonPressed(QListBoxItem*, const QPoint&)));
+
+ connect(m_pItemListLB, SIGNAL(rightButtonClicked(QListBoxItem*, const QPoint&)),
+ this, SLOT(slotRightButtonClicked(QListBoxItem*, const QPoint&)));
+ connect(m_pDoc, SIGNAL(sigObjectCreated(UMLObject*)), this, SLOT(slotListItemCreated(UMLObject*)));
+
+ connect( m_pTopArrowB, SIGNAL( clicked() ), this, SLOT( slotTopClicked() ) );
+ connect( m_pUpArrowB, SIGNAL( clicked() ), this, SLOT( slotUpClicked() ) );
+ connect( m_pDownArrowB, SIGNAL( clicked() ), this, SLOT( slotDownClicked() ) );
+ connect( m_pBottomArrowB, SIGNAL( clicked() ), this, SLOT( slotBottomClicked() ) );
+ connect( m_pItemListLB, SIGNAL( doubleClicked( QListBoxItem* ) ),
+ this, SLOT( slotDoubleClick( QListBoxItem* ) ) );
+}
+
+ClassifierListPage::~ClassifierListPage() {
+
+}
+
+void ClassifierListPage::enableWidgets(bool state) {
+ m_pDocTE->setEnabled( state );
+ //if disabled clear contents
+ if( !state ) {
+ m_pDocTE->setText( "" );
+ m_pTopArrowB->setEnabled( false );
+ m_pUpArrowB->setEnabled( false );
+ m_pDownArrowB->setEnabled( false );
+ m_pBottomArrowB->setEnabled( false );
+ m_pDeleteListItemButton->setEnabled(false);
+ m_pPropertiesButton->setEnabled(false);
+ return;
+ }
+ /*now check the order buttons.
+ Double check an item is selected
+ If only one item in list make sure they are disabled.
+ If at top item, only allow down arrow to be enabled.
+ If at bottom item, only allow up arrow to be enabled.
+ */
+ int index = m_pItemListLB->currentItem();
+ if( m_pItemListLB->count() == 1 || index == -1 ) {
+ m_pTopArrowB->setEnabled( false );
+ m_pUpArrowB->setEnabled( false );
+ m_pDownArrowB->setEnabled( false );
+ m_pBottomArrowB->setEnabled( false );
+ } else if( index == 0 ) {
+ m_pTopArrowB->setEnabled( false );
+ m_pUpArrowB->setEnabled( false );
+ m_pDownArrowB->setEnabled( true );
+ m_pBottomArrowB->setEnabled( true );
+ } else if( index == (int)m_pItemListLB->count() - 1 ) {
+ m_pTopArrowB->setEnabled( true );
+ m_pUpArrowB->setEnabled( true );
+ m_pDownArrowB->setEnabled( false );
+ m_pBottomArrowB->setEnabled( false );
+ } else {
+ m_pTopArrowB->setEnabled( true );
+ m_pUpArrowB->setEnabled( true );
+ m_pDownArrowB->setEnabled( true );
+ m_pBottomArrowB->setEnabled( true );
+ }
+ m_pDeleteListItemButton->setEnabled(true);
+ m_pPropertiesButton->setEnabled(true);
+}
+
+void ClassifierListPage::slotClicked(QListBoxItem*item) {
+ //if not first time an item is highlighted
+ //save old highlighted item first
+ if(m_pOldListItem) {
+ m_pOldListItem->setDoc( m_pDocTE->text() );
+ }
+
+ // make sure clicked on an item
+ // it is impossible to deselect all items, because our list box has keyboard
+ // focus and so at least one item is always selected; this doesn't happen, if
+ // there are no items of course;
+ //
+ // for more information see Qt doc for void QListBox::clearSelection()
+ UMLClassifierListItem* listItem;
+ if (item == NULL) {
+ if (m_pItemListLB->count() == 0) {
+ enableWidgets(false);
+ m_pOldListItem = 0;
+ m_pItemListLB->clearSelection();
+ return;
+ }
+ m_pItemListLB->setSelected(0, true);
+ listItem = getItemList().at(0);
+ } else {
+ listItem = getItemList().at( m_pItemListLB->index(item) );
+ }
+
+ if (listItem) {
+ //now update screen
+ m_pDocTE->setText( listItem->getDoc() );
+ enableWidgets(true);
+ m_pOldListItem = listItem;
+ }
+}
+
+void ClassifierListPage::updateObject() {
+ saveCurrentItemDocumentation();
+ QListBoxItem*i = m_pItemListLB->item(m_pItemListLB->currentItem());
+ slotClicked(i);
+
+ // The rest of this function does nothing?!
+ QStringList stringList;
+ int count = m_pItemListLB->count();
+ for( int j = 0; j < count ; j++ )
+ stringList.append( m_pItemListLB->text( j ) );
+}
+
+void ClassifierListPage::slotListItemCreated(UMLObject* object) {
+ if(!m_bSigWaiting) {
+ return;
+ }
+ UMLClassifierListItem *listItem = dynamic_cast<UMLClassifierListItem*>(object);
+ if (listItem == NULL) {
+ return;
+ }
+ int index = m_pItemListLB->count();
+ m_pItemListLB->insertItem(listItem->toString(Uml::st_SigNoVis), index);
+ m_bSigWaiting = false;
+
+ // now select the new item, so that the user can go on adding doc or calling
+ // the property dialog
+ m_pItemListLB->setSelected(index, true);
+ slotClicked(m_pItemListLB->item(index));
+}
+
+void ClassifierListPage::slotListItemModified() {
+ if(!m_bSigWaiting) {
+ return;
+ }
+ //is this safe???
+ UMLClassifierListItem* object = const_cast<UMLClassifierListItem*>(dynamic_cast<const UMLClassifierListItem*>(sender()));
+ if (object == NULL)
+ return;
+ int index = m_pItemListLB->currentItem();
+ m_pItemListLB->changeItem(object->toString(Uml::st_SigNoVis), index);
+ m_bSigWaiting = false;
+}
+
+void ClassifierListPage::slotRightButtonClicked(QListBoxItem* /*item*/, const QPoint& /* p*/) {
+ if (m_pMenu) {
+ m_pMenu->hide();
+ disconnect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotPopupMenuSel(int)));
+ delete m_pMenu;
+ m_pMenu = 0;
+ }
+}
+
+void ClassifierListPage::slotRightButtonPressed(QListBoxItem* item, const QPoint& p) {
+ ListPopupMenu::Menu_Type type = ListPopupMenu::mt_Undefined;
+ if (item) { //pressed on a list item
+ if (m_itemType == ot_Attribute) {
+ type = ListPopupMenu::mt_Attribute_Selected;
+ } else if (m_itemType == ot_Operation) {
+ type = ListPopupMenu::mt_Operation_Selected;
+ } else if (m_itemType == ot_Template) {
+ type = ListPopupMenu::mt_Template_Selected;
+ } else if (m_itemType == ot_EnumLiteral) {
+ type = ListPopupMenu::mt_EnumLiteral_Selected;
+ } else if (m_itemType == ot_EntityAttribute) {
+ type = ListPopupMenu::mt_EntityAttribute_Selected;
+ } else {
+ kWarning() << "unknown type in ClassifierListPage" << endl;
+ }
+ } else { //pressed into fresh air
+ if (m_itemType == ot_Attribute) {
+ type = ListPopupMenu::mt_New_Attribute;
+ } else if (m_itemType == ot_Operation) {
+ type = ListPopupMenu::mt_New_Operation;
+ } else if (m_itemType == ot_Template) {
+ type = ListPopupMenu::mt_New_Template;
+ } else if (m_itemType == ot_EnumLiteral) {
+ type = ListPopupMenu::mt_New_EnumLiteral;
+ } else if (m_itemType == ot_EntityAttribute) {
+ type = ListPopupMenu::mt_New_EntityAttribute;
+ } else {
+ kWarning() << "unknown type in ClassifierListPage" << endl;
+ }
+ }
+ if(m_pMenu) {
+ m_pMenu->hide();
+ disconnect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotPopupMenuSel(int)));
+ delete m_pMenu;
+ m_pMenu = 0;
+ }
+ m_pMenu = new ListPopupMenu(this, type);
+
+ m_pMenu->popup(p);
+ connect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotPopupMenuSel(int)));
+}
+
+void ClassifierListPage::slotPopupMenuSel(int id) {
+ UMLClassifierListItem* listItem = getItemList().at( m_pItemListLB->currentItem() );
+ if(!listItem && id != ListPopupMenu::mt_New_Attribute) {
+ kDebug() << "can't find att from selection" << endl;
+ return;
+ }
+ switch(id) {
+ case ListPopupMenu::mt_New_Attribute:
+ case ListPopupMenu::mt_New_Operation:
+ case ListPopupMenu::mt_New_Template:
+ case ListPopupMenu::mt_New_EnumLiteral:
+ case ListPopupMenu::mt_New_EntityAttribute:
+ slotNewListItem();
+ break;
+
+ case ListPopupMenu::mt_Delete:
+ slotDelete();
+ break;
+
+ case ListPopupMenu::mt_Rename:
+ m_bSigWaiting = true;
+ m_pDoc->renameChildUMLObject(listItem);
+ break;
+
+ case ListPopupMenu::mt_Properties:
+ slotProperties();
+ break;
+ }
+}
+
+void ClassifierListPage::printItemList(QString prologue) {
+#ifdef VERBOSE_DEBUGGING
+ UMLClassifierListItem* item;
+ QString buf;
+ UMLClassifierListItemList itemList = getItemList();
+ for (UMLClassifierListItemListIt it(itemList); (item = it.current()) != NULL; ++it)
+ buf.append(' ' + item->getName());
+ kDebug() << prologue << buf << endl;
+#endif
+}
+
+void ClassifierListPage::slotTopClicked() {
+ int count = m_pItemListLB->count();
+ int index = m_pItemListLB->currentItem();
+ //shouldn't occur, but just in case
+ if( count <= 1 || index <= 0 )
+ return;
+ m_pOldListItem = NULL;
+
+ //swap the text around in the ListBox
+ QString currentString = m_pItemListLB->text( index );
+ m_pItemListLB->removeItem( index );
+ m_pItemListLB->insertItem( currentString, 0 );
+ //set the moved item selected
+ QListBoxItem* item = m_pItemListLB->item( 0 );
+ m_pItemListLB->setSelected( item, true );
+
+ //now change around in the list
+ printItemList("itemList before change: ");
+ UMLClassifierListItem* currentAtt = getItemList().at(index);
+ // NB: The index in the m_pItemListLB is not necessarily the same
+ // as the index in the UMLClassifier::m_List.
+ // Reason: getItemList() returns only a subset of all entries
+ // in UMLClassifier::m_List.
+ takeItem(currentAtt, true, index); // now we index the UMLClassifier::m_List
+ kDebug() << "ClassifierListPage::slotTopClicked(" << currentAtt->getName()
+ << "): peer index in UMLCanvasItem::m_List is " << index << endl;
+ addClassifier(currentAtt, 0);
+ printItemList("itemList after change: ");
+ slotClicked(item);
+}
+
+void ClassifierListPage::slotUpClicked() {
+ int count = m_pItemListLB->count();
+ int index = m_pItemListLB->currentItem();
+ //shouldn't occur, but just in case
+ if( count <= 1 || index <= 0 )
+ return;
+ m_pOldListItem = NULL;
+
+ //swap the text around in the ListBox
+ QString aboveString = m_pItemListLB->text( index - 1 );
+ QString currentString = m_pItemListLB->text( index );
+ m_pItemListLB->changeItem( currentString, index -1 );
+ m_pItemListLB->changeItem( aboveString, index );
+ //set the moved item selected
+ QListBoxItem* item = m_pItemListLB->item( index - 1 );
+ m_pItemListLB->setSelected( item, true );
+
+ //now change around in the list
+ printItemList("itemList before change: ");
+ UMLClassifierListItem* currentAtt = getItemList().at(index);
+ // NB: The index in the m_pItemListLB is not necessarily the same
+ // as the index in the UMLClassifier::m_List.
+ // Reason: getItemList() returns only a subset of all entries
+ // in UMLClassifier::m_List.
+ takeItem(currentAtt, true, index); // now we index the UMLClassifier::m_List
+ kDebug() << "ClassifierListPage::slotUpClicked(" << currentAtt->getName()
+ << "): peer index in UMLCanvasItem::m_List is " << index << endl;
+ if (index == -1)
+ index = 0;
+ addClassifier(currentAtt, index);
+ printItemList("itemList after change: ");
+ slotClicked( item );
+}
+
+void ClassifierListPage::slotDownClicked() {
+ int count = m_pItemListLB->count();
+ int index = m_pItemListLB->currentItem();
+ //shouldn't occur, but just in case
+ if( count <= 1 || index >= count - 1 )
+ return;
+ m_pOldListItem = NULL;
+
+ //swap the text around in the ListBox
+ QString belowString = m_pItemListLB->text( index + 1 );
+ QString currentString = m_pItemListLB->text( index );
+ m_pItemListLB->changeItem( currentString, index + 1 );
+ m_pItemListLB->changeItem( belowString, index );
+ //set the moved item selected
+ QListBoxItem* item = m_pItemListLB->item( index + 1 );
+ m_pItemListLB->setSelected( item, true );
+ //now change around in the list
+ printItemList("itemList before change: ");
+ UMLClassifierListItem* currentAtt = getItemList().at(index);
+ // NB: The index in the m_pItemListLB is not necessarily the same
+ // as the index in the UMLClassifier::m_List.
+ // Reason: getItemList() returns only a subset of all entries
+ // in UMLClassifier::m_List.
+ takeItem(currentAtt, false, index); // now we index the UMLClassifier::m_List
+ kDebug() << "ClassifierListPage::slotDownClicked(" << currentAtt->getName()
+ << "): peer index in UMLCanvasItem::m_List is " << index << endl;
+ if (index != -1)
+ index++; // because we want to go _after_ the following peer item
+ addClassifier(currentAtt, index);
+ printItemList("itemList after change: ");
+ slotClicked( item );
+}
+
+void ClassifierListPage::slotBottomClicked() {
+ int count = m_pItemListLB->count();
+ int index = m_pItemListLB->currentItem();
+ //shouldn't occur, but just in case
+ if( count <= 1 || index >= count - 1 )
+ return;
+ m_pOldListItem = NULL;
+
+ //swap the text around in the ListBox
+ QString currentString = m_pItemListLB->text( index );
+ m_pItemListLB->removeItem( index );
+ m_pItemListLB->insertItem( currentString, m_pItemListLB->count() );
+ //set the moved item selected
+ QListBoxItem* item = m_pItemListLB->item( m_pItemListLB->count() - 1 );
+ m_pItemListLB->setSelected( item, true );
+
+ //now change around in the list
+ printItemList("itemList before change: ");
+ UMLClassifierListItem* currentAtt = getItemList().at(index);
+ // NB: The index in the m_pItemListLB is not necessarily the same
+ // as the index in the UMLClassifier::m_List.
+ // Reason: getItemList() returns only a subset of all entries
+ // in UMLClassifier::m_List.
+ takeItem(currentAtt, false, index); // now we index the UMLClassifier::m_List
+ kDebug() << "ClassifierListPage::slotDownClicked(" << currentAtt->getName()
+ << "): peer index in UMLCanvasItem::m_List is " << index << endl;
+ addClassifier(currentAtt, getItemList().count());
+ printItemList("itemList after change: ");
+ slotClicked( item );
+}
+
+void ClassifierListPage::slotDoubleClick( QListBoxItem* item ) {
+ if( !item )
+ return;
+
+ UMLClassifierListItem* listItem = getItemList().at( m_pItemListLB->index( item ) );
+ if( !listItem ) {
+ kDebug() << "can't find att from selection" << endl;
+ return;
+ }
+
+ if( listItem->showPropertiesDialog(this) ) {
+ m_pItemListLB->changeItem( listItem->toString(Uml::st_SigNoVis), m_pItemListLB->index(item) );
+ }
+}
+
+void ClassifierListPage::slotDelete() {
+ UMLClassifierListItem* selectedItem = getItemList().at( m_pItemListLB->currentItem() );
+ //should really wait for signal back
+ //but really shouldn't matter
+ m_pDoc->removeUMLObject(selectedItem);
+ m_pItemListLB->removeItem( m_pItemListLB->currentItem());
+ m_pOldListItem = 0;
+ slotClicked(0);
+}
+
+void ClassifierListPage::slotProperties() {
+ saveCurrentItemDocumentation();
+ slotDoubleClick( m_pItemListLB->item( m_pItemListLB->currentItem() ) );
+}
+
+void ClassifierListPage::slotNewListItem() {
+ saveCurrentItemDocumentation();
+ m_bSigWaiting = true;
+ Object_Factory::createChildObject(m_pClassifier, m_itemType);
+}
+
+void ClassifierListPage::saveCurrentItemDocumentation() {
+ UMLClassifierListItem* selectedItem = getItemList().at( m_pItemListLB->currentItem() );
+ if (selectedItem) {
+ selectedItem->setDoc( m_pDocTE->text() );
+ }
+}
+
+UMLClassifierListItemList ClassifierListPage::getItemList() {
+ return m_pClassifier->getFilteredList(m_itemType);
+}
+
+bool ClassifierListPage::addClassifier(UMLClassifierListItem* listitem, int position) {
+ switch (m_itemType) {
+ case ot_Attribute: {
+ UMLAttribute *att = dynamic_cast<UMLAttribute*>(listitem);
+ return m_pClassifier->addAttribute(att, NULL, position);
+ }
+ case ot_Operation: {
+ UMLOperation *op = dynamic_cast<UMLOperation*>(listitem);
+ return m_pClassifier->addOperation(op, position);
+ }
+ case ot_Template: {
+ UMLTemplate* t = dynamic_cast<UMLTemplate*>(listitem);
+ return m_pClassifier->addTemplate(t, position);
+ }
+ case ot_EnumLiteral: {
+ UMLEnum* c = dynamic_cast<UMLEnum*>(m_pClassifier);
+ if (c) {
+ return c->addEnumLiteral(dynamic_cast<UMLEnumLiteral*>(listitem), position);
+ }
+ break;
+ }
+ case ot_EntityAttribute: {
+ UMLEntity* c = dynamic_cast<UMLEntity*>(m_pClassifier);
+ if (c) {
+ return c->addEntityAttribute(dynamic_cast<UMLEntityAttribute*>(listitem), position);
+ }
+ break;
+ }
+ default: {
+ kWarning() << "unknown type in ClassifierListPage" << endl;
+ return false;
+ }
+ }
+ kError() << "ClassifierListPage::addClassifier unable to handle listitem type in current state" << endl;
+ return false;
+}
+
+bool ClassifierListPage::takeItem(UMLClassifierListItem* listItem,
+ bool seekPeerBefore, int &peerIndex) {
+ int wasAtIndex = m_pClassifier->takeItem(listItem);
+ if (wasAtIndex == -1)
+ return false;
+ kapp->processEvents();
+ peerIndex = -1;
+ UMLObject *o;
+ const Uml::Object_Type seekType = listItem->getBaseType();
+ UMLObjectList listItems = m_pClassifier->subordinates();
+ UMLObjectListIt it(listItems);
+ for (int i = 0; (o = it.current()) != NULL; ++i, ++it) {
+ if (seekPeerBefore) {
+ if (i >= wasAtIndex)
+ break;
+ if (o->getBaseType() == seekType)
+ peerIndex = i;
+ } else { // seekPeerAfter
+ if (i < wasAtIndex)
+ continue;
+ if (o->getBaseType() == seekType) {
+ peerIndex = i;
+ break;
+ }
+ }
+ }
+ return true;
+}
+
+
+#include "classifierlistpage.moc"
+
diff --git a/umbrello/umbrello/dialogs/classifierlistpage.h b/umbrello/umbrello/dialogs/classifierlistpage.h
new file mode 100644
index 00000000..ea1c0b9f
--- /dev/null
+++ b/umbrello/umbrello/dialogs/classifierlistpage.h
@@ -0,0 +1,191 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef CLASSIFIERLISTPAGE_H
+#define CLASSIFIERLISTPAGE_H
+
+//qt includes
+#include <qwidget.h>
+#include <qgroupbox.h>
+#include <qlistbox.h>
+#include <qtextedit.h>
+//kde includes
+#include <karrowbutton.h>
+
+//app includes
+#include "../listpopupmenu.h"
+#include "../umlclassifierlistitemlist.h"
+
+class UMLObject;
+class UMLClassifier;
+class UMLDoc;
+
+/**
+ * A dialog page to display classifier list properties. This is not normally setup
+ * by you. It is used by the @ref ClassPropDlg and new class wizard.
+ *
+ * @short A dialog page to display classifier properties.
+ * @author Paul Hensgen, Jonathan Riddell
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class ClassifierListPage : public QWidget {
+ Q_OBJECT
+public:
+ /**
+ * Sets up the ClassifierListPage
+ *
+ * @param parent The parent to the ClassAttPage.
+ * @param classifier The Concept to display the properties of.
+ * @param doc The UMLDoc document
+ * @param type The type of listItem this handles
+ */
+ ClassifierListPage(QWidget* parent, UMLClassifier* classifier, UMLDoc* doc, Uml::Object_Type type);
+
+ /**
+ * Standard deconstructor.
+ */
+ ~ClassifierListPage();
+
+ /**
+ * Will move information from the dialog into the object.
+ * Call when the ok or apply button is pressed.
+ */
+ void updateObject();
+
+private:
+ /**
+ * Set the state of the widgets on the page with the given value.
+ *
+ * @param state The state to set the widgets as.
+ */
+ void enableWidgets(bool state);
+
+ /**
+ * Saves the documentation for the currently selected item
+ */
+ void saveCurrentItemDocumentation();
+
+ /**
+ * Get classifiers
+ */
+ UMLClassifierListItemList getItemList();
+
+ /**
+ * Attempts to add classifier to the appropriate list
+ *
+ * @param classifier Pointer to the classifier to add.
+ * @param position Index at which to insert into the list.
+ * @return true if the classifier could be added
+ *
+ */
+ bool addClassifier(UMLClassifierListItem* classifier, int position = -1);
+
+ /**
+ * Take a classifier's subordinate item.
+ * Ownership of the classifier list item is transferred to the caller.
+ * @param listitem UMLClassifierListItem to take.
+ * @param seekPeerBefore True if a peer index should be sought which
+ * is smaller than the current listitem's index.
+ * @param peerIndex Return value: Index in the UMLClassifier's
+ * item list at which a peer item, i.e. another
+ * UMLClassifierListItem of the same type as
+ * listItem, is found. If no such item exists
+ * then return -1.
+ * @return True for success.
+ */
+ bool takeItem(UMLClassifierListItem* listitem,
+ bool seekPeerBefore, int &peerIndex);
+
+ /**
+ * Utility for debugging, prints the current item list.
+ * Only effective if VERBOSE_DEBUGGING is defined.
+ */
+ void printItemList(QString prologue);
+
+ UMLClassifier* m_pClassifier;
+ QGroupBox* m_pDocGB;
+ QGroupBox* m_pItemListGB;
+ QListBox* m_pItemListLB;
+ QTextEdit* m_pDocTE;
+ Uml::Object_Type m_itemType;
+
+ KArrowButton* m_pTopArrowB;
+ KArrowButton* m_pUpArrowB;
+ KArrowButton* m_pDownArrowB;
+ KArrowButton* m_pBottomArrowB;
+ QPushButton* m_pDeleteListItemButton;
+ QPushButton* m_pPropertiesButton;
+
+ UMLClassifierListItem* m_pOldListItem;
+ UMLDoc* m_pDoc;
+ ListPopupMenu* m_pMenu;
+ bool m_bSigWaiting;
+
+public slots:
+ /**
+ * called when list view is clicked on
+ * calls enableWidgets()
+ */
+ void slotClicked(QListBoxItem* item);
+
+ /**
+ * Called when an item is selected in a right click menu
+ */
+ void slotPopupMenuSel(int id);
+
+ void slotListItemCreated(UMLObject* object);
+ void slotListItemModified();
+ void slotRightButtonClicked(QListBoxItem* item, const QPoint& p);
+ void slotRightButtonPressed(QListBoxItem* item, const QPoint& p);
+
+ /**
+ * shows properties dialog for the attribute clicked on
+ */
+ void slotDoubleClick(QListBoxItem* item);
+
+
+ /**
+ * moves selected attribute to the top of the list
+ */
+ void slotTopClicked();
+
+ /**
+ * moves selected attribute up in list
+ */
+ void slotUpClicked();
+
+ /**
+ * moved selected attribute down in list
+ */
+ void slotDownClicked();
+
+ /**
+ * moved selected attribute to the bottom of the list
+ */
+ void slotBottomClicked();
+
+ /**
+ * shows dialog for new attribute
+ */
+ void slotNewListItem();
+
+ /**
+ * removes currently seleted attribute
+ */
+ void slotDelete();
+
+ /**
+ * shows properties dialog for currently selected attribute
+ */
+ void slotProperties();
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/classoptionspage.cpp b/umbrello/umbrello/dialogs/classoptionspage.cpp
new file mode 100644
index 00000000..7a54f2dc
--- /dev/null
+++ b/umbrello/umbrello/dialogs/classoptionspage.cpp
@@ -0,0 +1,195 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "classoptionspage.h"
+
+// qt/kde includes
+#include <qlayout.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+// local includes
+#include "../umlview.h"
+#include "../classifierwidget.h"
+
+
+ClassOptionsPage::ClassOptionsPage(QWidget* pParent, ClassifierWidget* pWidget)
+ : QWidget( pParent ) {
+ init();
+ //Uml::Widget_Type type = pWidget->getBaseType();
+ m_pWidget = pWidget;
+ setupPage();
+}
+
+ClassOptionsPage::ClassOptionsPage(QWidget* pParent, Settings::OptionState *options) : QWidget( pParent )
+{
+ init();
+ m_options = options;
+ setupClassPageOption();
+}
+
+void ClassOptionsPage::init() {
+ m_options = NULL;
+ m_pWidget = NULL;
+ m_pShowStereotypeCB = NULL;
+ m_pShowAttsCB = NULL;
+ m_pShowAttSigCB = NULL;
+ m_pDrawAsCircleCB = NULL;
+}
+
+ClassOptionsPage::~ClassOptionsPage() {}
+
+void ClassOptionsPage::setupPage() {
+ int margin = fontMetrics().height();
+
+ bool sig = false;
+ Uml::Signature_Type sigtype;
+
+ QVBoxLayout * topLayout = new QVBoxLayout(this);
+ topLayout -> setSpacing(6);
+ m_pVisibilityGB = new QGroupBox(i18n("Show"), this);
+ topLayout -> addWidget(m_pVisibilityGB);
+ QGridLayout * visibilityLayout = new QGridLayout(m_pVisibilityGB);
+ visibilityLayout -> setSpacing(10);
+ visibilityLayout -> setMargin(margin);
+ visibilityLayout -> setRowStretch(3, 1);
+
+ m_pShowOpsCB = new QCheckBox(i18n("Operatio&ns"), m_pVisibilityGB);
+ m_pShowOpsCB -> setChecked(m_pWidget -> getShowOps());
+ visibilityLayout -> addWidget(m_pShowOpsCB, 0, 0);
+
+ m_pShowVisibilityCB = new QCheckBox(i18n("&Visibility"), m_pVisibilityGB);
+ m_pShowVisibilityCB -> setChecked(m_pWidget -> getShowVisibility());
+ visibilityLayout -> addWidget(m_pShowVisibilityCB, 0, 1);
+
+ sigtype = m_pWidget -> getShowOpSigs();
+ if(sigtype == Uml::st_NoSig || sigtype == Uml::st_NoSigNoVis)
+ sig = false;
+ else
+ sig = true;
+ m_pShowOpSigCB = new QCheckBox(i18n("O&peration signature"), m_pVisibilityGB);
+ m_pShowOpSigCB -> setChecked(sig);
+ visibilityLayout -> addWidget(m_pShowOpSigCB, 1, 0);
+
+ m_pShowPackageCB = new QCheckBox(i18n("Pac&kage"), m_pVisibilityGB);
+ m_pShowPackageCB -> setChecked(m_pWidget -> getShowPackage());
+ visibilityLayout -> addWidget(m_pShowPackageCB, 1, 1);
+
+ Uml::Widget_Type type = m_pWidget->getBaseType();
+
+ if (type == Uml::wt_Class) {
+ m_pShowAttsCB = new QCheckBox(i18n("Att&ributes"), m_pVisibilityGB);
+ m_pShowAttsCB->setChecked(m_pWidget->getShowAtts());
+ visibilityLayout->addWidget(m_pShowAttsCB, 2, 0);
+
+ m_pShowStereotypeCB = new QCheckBox(i18n("Stereot&ype"), m_pVisibilityGB);
+ m_pShowStereotypeCB->setChecked(m_pWidget->getShowStereotype());
+ visibilityLayout->addWidget(m_pShowStereotypeCB, 2, 1);
+
+ m_pShowAttSigCB = new QCheckBox(i18n("Attr&ibute signature"), m_pVisibilityGB);
+ sigtype = m_pWidget->getShowAttSigs();
+ if(sigtype == Uml::st_NoSig || sigtype == Uml::st_NoSigNoVis)
+ sig = false;
+ else
+ sig = true;
+ m_pShowAttSigCB->setChecked(sig);
+ visibilityLayout->addWidget(m_pShowAttSigCB, 3, 0);
+
+ } else if (type == Uml::wt_Interface) {
+ m_pDrawAsCircleCB = new QCheckBox(i18n("Draw as circle"), m_pVisibilityGB);
+ m_pDrawAsCircleCB->setChecked( m_pWidget->getDrawAsCircle() );
+ visibilityLayout->addWidget(m_pDrawAsCircleCB, 2, 0);
+ }
+}
+
+void ClassOptionsPage::setupClassPageOption() {
+
+ int margin = fontMetrics().height();
+
+ QVBoxLayout * topLayout = new QVBoxLayout(this);
+ topLayout -> setSpacing(6);
+ m_pVisibilityGB = new QGroupBox(i18n("Show"), this);
+ topLayout -> addWidget(m_pVisibilityGB);
+ QGridLayout * visibilityLayout = new QGridLayout(m_pVisibilityGB);
+ visibilityLayout -> setSpacing(10);
+ visibilityLayout -> setMargin(margin);
+
+ m_pShowOpsCB = new QCheckBox(i18n("Operatio&ns"), m_pVisibilityGB);
+ m_pShowOpsCB -> setChecked( m_options->classState.showOps );
+ visibilityLayout -> addWidget(m_pShowOpsCB, 0, 0);
+
+ m_pShowOpSigCB = new QCheckBox(i18n("O&peration signature"), m_pVisibilityGB);
+ m_pShowOpSigCB -> setChecked(m_options->classState.showOpSig);
+ visibilityLayout -> addWidget(m_pShowOpSigCB, 1, 0);
+ visibilityLayout -> setRowStretch(3, 1);
+
+ m_pShowAttsCB = new QCheckBox(i18n("Att&ributes"), m_pVisibilityGB);
+ m_pShowAttsCB -> setChecked(m_options->classState.showAtts );
+ visibilityLayout -> addWidget(m_pShowAttsCB, 2, 0);
+
+ m_pShowAttSigCB = new QCheckBox(i18n("Attr&ibute signature"), m_pVisibilityGB);
+ m_pShowAttSigCB -> setChecked(m_options->classState.showAttSig);
+ visibilityLayout -> addWidget(m_pShowAttSigCB, 3, 0);
+
+ m_pShowVisibilityCB = new QCheckBox(i18n("&Visibility"), m_pVisibilityGB);
+ m_pShowVisibilityCB -> setChecked(m_options->classState.showVisibility);
+ visibilityLayout -> addWidget(m_pShowVisibilityCB, 0, 1);
+
+ m_pShowPackageCB = new QCheckBox(i18n("Pac&kage"), m_pVisibilityGB);
+ m_pShowPackageCB -> setChecked(m_options->classState.showPackage);
+ visibilityLayout -> addWidget(m_pShowPackageCB, 1, 1);
+
+ m_pShowStereotypeCB = new QCheckBox(i18n("Stereot&ype"), m_pVisibilityGB);
+ m_pShowStereotypeCB -> setChecked(m_options->classState.showStereoType);
+ visibilityLayout -> addWidget(m_pShowStereotypeCB, 2, 1);
+
+}
+
+void ClassOptionsPage::updateUMLWidget() {
+ if (m_pWidget) {
+ updateWidget();
+ } else if (m_options) {
+ updateOptionState();
+ }
+}
+
+void ClassOptionsPage::updateWidget() {
+ m_pWidget->setShowPackage( m_pShowPackageCB->isChecked() );
+ m_pWidget->setShowVisibility( m_pShowVisibilityCB->isChecked() );
+ m_pWidget->setShowOps( m_pShowOpsCB->isChecked() );
+ m_pWidget->setShowOpSigs( m_pShowOpSigCB->isChecked() );
+ Uml::Widget_Type type = m_pWidget->getBaseType();
+ if (type == Uml::wt_Class) {
+ m_pWidget->setShowStereotype( m_pShowStereotypeCB->isChecked() );
+ m_pWidget->setShowAtts( m_pShowAttsCB->isChecked() );
+ m_pWidget->setShowAttSigs( m_pShowAttSigCB->isChecked() );
+ } else if (type == Uml::wt_Interface) {
+ if (m_pDrawAsCircleCB)
+ m_pWidget->setDrawAsCircle( m_pDrawAsCircleCB->isChecked() );
+ }
+}
+
+void ClassOptionsPage::updateOptionState() {
+ m_options->classState.showVisibility = m_pShowVisibilityCB->isChecked();
+ if (m_pShowAttsCB)
+ m_options->classState.showAtts = m_pShowAttsCB->isChecked();
+ m_options->classState.showOps = m_pShowOpsCB->isChecked();
+ if (m_pShowStereotypeCB)
+ m_options->classState.showStereoType = m_pShowStereotypeCB->isChecked();
+ m_options->classState.showPackage = m_pShowPackageCB->isChecked();
+ if (m_pShowAttSigCB)
+ m_options->classState.showAttSig = m_pShowAttSigCB->isChecked();
+ m_options->classState.showOpSig = m_pShowOpSigCB->isChecked();
+}
+
+
+//#include "classoptionspage.moc"
diff --git a/umbrello/umbrello/dialogs/classoptionspage.h b/umbrello/umbrello/dialogs/classoptionspage.h
new file mode 100644
index 00000000..50d43f8c
--- /dev/null
+++ b/umbrello/umbrello/dialogs/classoptionspage.h
@@ -0,0 +1,106 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+
+#ifndef CLASSOPTIONSPAGE_H
+#define CLASSOPTIONSPAGE_H
+
+#include <qwidget.h>
+#include <qgroupbox.h>
+#include <qcheckbox.h>
+
+#include "../optionstate.h"
+
+class ClassifierWidget;
+
+/**
+ * A dialog page to display options for a @ref UMLWidget and its
+ * children. This is not normally called by you. It is used by
+ * the @ref ClassPropDlg.
+ *
+ * @short A dialog page to display the options for a UMLWidget.
+ * @author Paul Hensgen <phensgen@techie.com>
+ * @see ClassPropDlg
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class ClassOptionsPage : public QWidget {
+public:
+ /**
+ * Constructor - observe and modify a Widget
+ */
+ ClassOptionsPage(QWidget* pParent, ClassifierWidget* pWidget);
+
+ /**
+ * Constructor - observe and modify an OptionState structure
+ */
+ ClassOptionsPage(QWidget* pParent, Settings::OptionState *options );
+
+ /**
+ * destructor
+ */
+ virtual ~ClassOptionsPage();
+
+ /**
+ * Updates the widget with the dialog page properties.
+ */
+ void updateUMLWidget();
+
+ /**
+ * Sets the widget to be used. Only used by @ref UMLView to set
+ * settings of a widget.
+ */
+ void setWidget( ClassifierWidget * pWidget ) {
+ m_pWidget = pWidget;
+ }
+
+protected:
+ /**
+ * Initialize optional items
+ */
+ void init();
+
+ /**
+ * Creates the page with the correct options for the class/interface
+ */
+ void setupPage();
+
+ /**
+ * Creates the page based on the OptionState
+ */
+ void setupClassPageOption();
+
+ /**
+ * Sets the ClassifierWidget's properties to those selected in this dialog page.
+ */
+ void updateWidget();
+
+ /**
+ * Sets the OptionState to the values selected in this dialog page.
+ */
+ void updateOptionState();
+
+ //GUI widgets
+ QGroupBox * m_pVisibilityGB;
+ QCheckBox * m_pShowVisibilityCB, * m_pShowAttSigCB;
+ QCheckBox * m_pShowOpSigCB, * m_pShowAttsCB, * m_pShowOpsCB;
+ QCheckBox * m_pShowStereotypeCB, * m_pShowPackageCB;
+ QCheckBox* m_pDrawAsCircleCB;
+
+ /**
+ * The classifier widget to represent in the dialog page.
+ */
+ ClassifierWidget* m_pWidget;
+ /**
+ * The OptionState structure to represent in the dialog page.
+ */
+ Settings::OptionState *m_options;
+};
+#endif
diff --git a/umbrello/umbrello/dialogs/classpropdlg.cpp b/umbrello/umbrello/dialogs/classpropdlg.cpp
new file mode 100644
index 00000000..9c4848a1
--- /dev/null
+++ b/umbrello/umbrello/dialogs/classpropdlg.cpp
@@ -0,0 +1,250 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "classpropdlg.h"
+
+// qt/kde includes
+#include <qlayout.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+// app includes
+#include "classgenpage.h"
+#include "classifierlistpage.h"
+#include "pkgcontentspage.h"
+#include "assocpage.h"
+#include "classoptionspage.h"
+#include "umlwidgetcolorpage.h"
+#include "../umlobject.h"
+#include "../umldoc.h"
+#include "../classifierwidget.h"
+#include "../objectwidget.h"
+#include "../componentwidget.h"
+#include "../uml.h"
+#include "../umlview.h"
+
+ClassPropDlg::ClassPropDlg(QWidget *parent, UMLObject * c, int pageNum, bool assoc)
+ : KDialogBase(IconList, i18n("Properties"), Ok | Apply | Cancel | Help,
+ Ok, parent, "_CLASSDLG_", true, true) {
+ m_pWidget = 0;
+ m_pGenPage = 0;
+ m_pAttPage = 0;
+ m_pOpsPage = 0;
+ m_pTemplatePage = 0;
+ m_pEnumLiteralPage = 0;
+ m_pEntityAttributePage = 0;
+ m_pOptionsPage = 0;
+ m_pColorPage = 0;
+ m_Type = pt_Object;
+ m_pDoc = UMLApp::app()->getDocument();
+ m_pObject = c;
+ setupPages(c, assoc);
+ showPage(pageNum);
+}
+
+ClassPropDlg::ClassPropDlg(QWidget *parent, ObjectWidget * o)
+ : KDialogBase(IconList, i18n("Properties"), Ok | Apply | Cancel | Help,
+ Ok, parent, "_CLASSDLG_", true, true) {
+ m_pWidget = o;
+ m_pGenPage = 0;
+ m_pAttPage = 0;
+ m_pOpsPage = 0;
+ m_pTemplatePage = 0;
+ m_pEnumLiteralPage = 0;
+ m_pEntityAttributePage = 0;
+ m_pOptionsPage = 0;
+ m_Type = pt_ObjectWidget;
+ m_pObject = m_pWidget->getUMLObject();
+ m_pDoc = UMLApp::app()->getDocument();
+ QFrame *page = addPage( i18n("General"), i18n("General Settings"), DesktopIcon( "misc") );
+ page -> setMinimumSize(310, 330);
+ QHBoxLayout * topLayout = new QHBoxLayout(page);
+ m_pGenPage = new ClassGenPage(m_pDoc, page, o);
+ topLayout -> addWidget(m_pGenPage);
+
+ QFrame * newPage = addPage( i18n("Color"), i18n("Widget Colors"), DesktopIcon( "colors") );
+ QHBoxLayout * m_pColorLayout = new QHBoxLayout(newPage);
+ m_pColorPage = new UMLWidgetColorPage(newPage, o);
+ m_pColorLayout -> addWidget(m_pColorPage);
+
+ setupFontPage();
+ showPage(0);
+ setMinimumSize(340,420);
+}
+
+ClassPropDlg::ClassPropDlg(QWidget *parent, UMLWidget * w)
+ : KDialogBase(IconList, i18n("Properties"), Ok | Apply | Cancel | Help,
+ Ok, parent, "_CLASSDLG_", true, true) {
+ m_pWidget = w;
+ m_pGenPage = 0;
+ m_pAttPage = 0;
+ m_pOpsPage = 0;
+ m_pTemplatePage = 0;
+ m_pEnumLiteralPage = 0;
+ m_pEntityAttributePage = 0;
+ m_pOptionsPage = 0;
+ m_Type = pt_Widget;
+ m_pObject = w -> getUMLObject();
+ m_pDoc = ((UMLApp *)parent) -> getDocument();
+
+ if (w->getBaseType() == Uml::wt_Class
+ || w->getBaseType() == Uml::wt_Interface
+ || w->getBaseType() == Uml::wt_Package) {
+ setupPages(m_pObject, true);
+ } else if (w->getBaseType() == Uml::wt_Component) {
+ if ( w->getIsInstance() ) {
+ setupInstancePages(w);
+ } else {
+ setupPages(m_pObject);
+ }
+ } else if (w->getBaseType() == Uml::wt_Node) {
+ setupInstancePages(w);
+ } else {
+ setupPages(m_pObject);
+ }
+
+ //now setup the options page for classes
+ if (w->getBaseType() == Uml::wt_Class || w->getBaseType() == Uml::wt_Interface) {
+ QFrame* newPage = addPage( i18n("Display"), i18n("Display Options"), DesktopIcon("info") );
+ QHBoxLayout* m_pOptionsLayout = new QHBoxLayout(newPage);
+ ClassifierWidget *cw = static_cast<ClassifierWidget*>(w);
+ m_pOptionsPage = new ClassOptionsPage( newPage, cw );
+ m_pOptionsLayout -> addWidget(m_pOptionsPage);
+ }
+
+ QFrame* colorPage = addPage( i18n("Color"), i18n("Widget Colors"), DesktopIcon("colors") );
+ QHBoxLayout * m_pColorLayout = new QHBoxLayout(colorPage);
+ m_pColorPage = new UMLWidgetColorPage(colorPage, w);
+ m_pColorLayout -> addWidget(m_pColorPage);
+ setupFontPage();
+}
+
+ClassPropDlg::~ClassPropDlg() {}
+
+void ClassPropDlg::slotOk() {
+ slotApply();
+ KDialogBase::accept();
+}
+
+void ClassPropDlg::slotApply() {
+ if (m_pGenPage) {
+ m_pGenPage->updateObject();
+ }
+ if (m_pAttPage) {
+ m_pAttPage->updateObject();
+ }
+ if (m_pOpsPage) {
+ m_pOpsPage->updateObject();
+ }
+ if (m_pTemplatePage) {
+ m_pTemplatePage->updateObject();
+ }
+ if (m_pEnumLiteralPage) {
+ m_pEnumLiteralPage->updateObject();
+ }
+ if (m_pEntityAttributePage) {
+ m_pEntityAttributePage->updateObject();
+ }
+ if (m_pOptionsPage) {
+ m_pOptionsPage->updateUMLWidget();
+ }
+ if (m_pColorPage) {
+ m_pColorPage->updateUMLWidget();
+ }
+ if (m_pWidget) {
+ m_pWidget->setFont( m_pChooser->font() );
+ }
+}
+
+void ClassPropDlg::setupPages(UMLObject * c, bool assoc) {
+ QFrame *page = addPage(i18n("General"), i18n("General Settings"), DesktopIcon( "misc") );
+ QHBoxLayout * genLayout = new QHBoxLayout(page);
+ page -> setMinimumSize(310, 330);
+ m_pGenPage = new ClassGenPage(m_pDoc, page, c);
+ genLayout -> addWidget(m_pGenPage);
+ Uml::Object_Type ot = c->getBaseType();
+ //add extra pages for class
+ if (ot == Uml::ot_Class ) {
+ //setup attributes page
+ QFrame* newPage = addPage( i18n("Attributes"), i18n("Attribute Settings"), DesktopIcon("misc") );
+ m_pAttPage = new ClassifierListPage(newPage, (UMLClassifier *)c, m_pDoc, Uml::ot_Attribute);
+ QHBoxLayout * attLayout = new QHBoxLayout(newPage);
+ attLayout -> addWidget(m_pAttPage);
+ }
+
+ if (ot == Uml::ot_Class || ot == Uml::ot_Interface) {
+ //setup operations page
+ QFrame* newPage = addPage( i18n("Operations"), i18n("Operation Settings"), DesktopIcon("misc") );
+ m_pOpsPage = new ClassifierListPage(newPage, (UMLClassifier*)c, m_pDoc, Uml::ot_Operation);
+ QHBoxLayout* pOpsLayout = new QHBoxLayout(newPage);
+ pOpsLayout -> addWidget(m_pOpsPage);
+ }
+
+ if (ot == Uml::ot_Class || ot == Uml::ot_Interface) {
+ //setup templates page
+ QFrame* newPage = addPage( i18n("Templates"), i18n("Templates Settings"), DesktopIcon("misc") );
+ m_pTemplatePage = new ClassifierListPage(newPage, (UMLClassifier *)c, m_pDoc, Uml::ot_Template);
+ QHBoxLayout* templatesLayout = new QHBoxLayout(newPage);
+ templatesLayout->addWidget(m_pTemplatePage);
+ }
+ if (ot == Uml::ot_Enum) {
+ //setup enum literals page
+ QFrame* newPage = addPage( i18n("Enum Literals"), i18n("Enum Literals Settings"), DesktopIcon("misc") );
+ m_pEnumLiteralPage = new ClassifierListPage(newPage, (UMLClassifier*)c, m_pDoc, Uml::ot_EnumLiteral);
+ QHBoxLayout* enumLiteralsLayout = new QHBoxLayout(newPage);
+ enumLiteralsLayout->addWidget(m_pEnumLiteralPage);
+ }
+ if (ot == Uml::ot_Entity) {
+ //setup enum literals page
+ QFrame* newPage = addPage( i18n("Entity Attributes"), i18n("Entity Attributes Settings"), DesktopIcon("misc") );
+ m_pEntityAttributePage = new ClassifierListPage(newPage, (UMLClassifier*)c, m_pDoc, Uml::ot_EntityAttribute);
+ QHBoxLayout* entityAttributesLayout = new QHBoxLayout(newPage);
+ entityAttributesLayout->addWidget(m_pEntityAttributePage);
+ }
+ if (ot == Uml::ot_Package ) {
+ // Set up containment page.
+ QFrame* newPage = addPage( i18n("Contents"), i18n("Contents Settings"), DesktopIcon("misc") );
+ m_pPkgContentsPage = new PkgContentsPage(newPage, (UMLPackage*)(c));
+ QHBoxLayout* contentsLayout = new QHBoxLayout(newPage);
+ contentsLayout->addWidget(m_pPkgContentsPage);
+ }
+ if (assoc) {
+ QFrame* newPage = addPage(i18n("Associations"), i18n("Class Associations"), DesktopIcon( "misc") );
+ m_pAssocPage = new AssocPage(newPage, UMLApp::app()->getCurrentView(), m_pObject);
+ QHBoxLayout* assocLayout = new QHBoxLayout(newPage);
+ assocLayout -> addWidget(m_pAssocPage);
+ } else {
+ m_pAssocPage = 0;
+ }
+}
+
+void ClassPropDlg::setupInstancePages(UMLWidget* widget) {
+ QFrame* page = addPage( i18n("General"), i18n("General Settings"), DesktopIcon("misc") );
+ QHBoxLayout* genLayout = new QHBoxLayout(page);
+ page->setMinimumSize(310, 330);
+ m_pGenPage = new ClassGenPage(m_pDoc, page, widget);
+ genLayout->addWidget(m_pGenPage);
+ m_pAssocPage = 0;
+}
+
+void ClassPropDlg::setupFontPage() {
+ if( !m_pWidget )
+ return;
+ QVBox * page = addVBoxPage( i18n("Font"), i18n("Font Settings"), DesktopIcon( "fonts") );
+ m_pChooser = new KFontChooser( (QWidget*)page, "font", false, QStringList(), false);
+ m_pChooser -> setFont( m_pWidget -> getFont() );
+}
+
+
+
+#include "classpropdlg.moc"
diff --git a/umbrello/umbrello/dialogs/classpropdlg.h b/umbrello/umbrello/dialogs/classpropdlg.h
new file mode 100644
index 00000000..90c5b4ec
--- /dev/null
+++ b/umbrello/umbrello/dialogs/classpropdlg.h
@@ -0,0 +1,129 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef CLASSPROPDLG_H
+#define CLASSPROPDLG_H
+
+//kde class includes
+#include <kdialogbase.h>
+#include <kfontdialog.h>
+
+#include "../umlnamespace.h"
+
+class ClassGenPage;
+class ClassifierListPage;
+class ClassOpsPage;
+class ClassTemplatePage;
+class PkgContentsPage;
+class AssocPage;
+class ClassOptionsPage;
+class UMLWidgetColorPage;
+
+class ComponentWidget;
+class ObjectWidget;
+class UMLDoc;
+class UMLObject;
+class UMLWidget;
+
+/**
+ * @author Paul Hensgen <phensgen@techie.com>
+ * @version 1.0
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class ClassPropDlg : public KDialogBase {
+ Q_OBJECT
+public:
+ /**
+ * Sets up a ClassPropDlg.
+ *
+ * @param parent The parent of the ClassPropDlg
+ * @param c The UMLObject to display properties of.
+ * @param pageNum The page to show first.
+ * @param assoc Determines whether to display associations
+ */
+ ClassPropDlg(QWidget *parent, UMLObject *c, int pageNum = 0, bool assoc = false);
+
+ /**
+ * Sets up a ClassPropDlg.
+ *
+ * @param parent The parent of the ClassPropDlg
+ * @param o The ObjectWidget to display properties of.
+ */
+ ClassPropDlg(QWidget *parent, ObjectWidget * o);
+
+ /**
+ * Sets up a ClassPropDlg.
+ *
+ * @param parent The parent of the ClassPropDlg
+ * @param o The UMLWidget to display properties of.
+ */
+ ClassPropDlg(QWidget *parent, UMLWidget * o);
+
+
+ /**
+ * Standard deconstructor
+ */
+ ~ClassPropDlg();
+
+ enum Page{page_gen = 0, page_att, page_op, page_template,
+ page_assoc, page_options, page_color, page_font};
+
+protected slots:
+ /**
+ * Calls slotApply() and accepts (closes) the dialog
+ */
+ void slotOk();
+
+ /**
+ * Applies the settings in the dialog to the widget and object
+ */
+ void slotApply();
+
+protected:
+ /**
+ * Sets up the general, attribute, operations, template and association pages as appropriate
+ */
+ void setupPages(UMLObject * c, bool assoc = false);
+
+ /**
+ * Sets up the general page for the component
+ */
+ void setupInstancePages(UMLWidget* widget);
+
+ /**
+ * Sets up the font page
+ */
+ void setupFontPage();
+private:
+ KFontChooser * m_pChooser;
+ ClassGenPage * m_pGenPage;
+ ClassifierListPage* m_pAttPage;
+ ClassifierListPage* m_pOpsPage;
+ ClassifierListPage* m_pTemplatePage;
+ ClassifierListPage* m_pEnumLiteralPage;
+ ClassifierListPage* m_pEntityAttributePage;
+ PkgContentsPage * m_pPkgContentsPage;
+ AssocPage * m_pAssocPage;
+ ClassOptionsPage * m_pOptionsPage;
+ UMLWidgetColorPage * m_pColorPage;
+ UMLDoc *m_pDoc;
+
+ UMLObject *m_pObject;
+ UMLWidget * m_pWidget;
+
+ enum Page_Type{ pt_Object = 1, //Show General page + Assoc. page if Class i.e. no colours page
+ pt_ObjectWidget, //Shows pages needed for an ObjectWidget
+ pt_Widget //Shows pages needed for any other widget
+ };
+ Page_Type m_Type;
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/classwizard.cpp b/umbrello/umbrello/dialogs/classwizard.cpp
new file mode 100644
index 00000000..7ac1cb27
--- /dev/null
+++ b/umbrello/umbrello/dialogs/classwizard.cpp
@@ -0,0 +1,107 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "classwizard.h"
+
+// system includes
+#include <khelpmenu.h>
+#include <klocale.h>
+
+// local includes
+#include "classifierlistpage.h"
+#include "../uml.h"
+#include "../umldoc.h"
+#include "../classifier.h"
+#include "../attribute.h"
+#include "../operation.h"
+#include "../umlclassifierlistitemlist.h"
+#include "../classifierlistitem.h"
+
+ClassWizard::ClassWizard( UMLDoc * pDoc ) : KWizard( (QWidget*)pDoc -> parent(), "_CLASSWIZARD_", true) {
+ m_pDoc = pDoc;
+ //create a unique class to start with
+ UMLObject * pTemp = 0;
+ QString name = i18n("new_class");
+ QString newName = name;
+ QString num = "";
+ int i = 0;
+ m_pClass = new UMLClassifier( newName );
+ do {
+ m_pClass -> setName( newName );
+ pTemp = m_pDoc -> findUMLObject( newName );
+ num.setNum( ++i);
+ newName = name;
+ newName.append("_").append( num );
+ } while( pTemp );
+ //setup pages
+ setupPages();
+}
+
+ClassWizard::~ClassWizard() {}
+
+void ClassWizard::setupPages() {
+ //Setup General Page
+ m_pGenPage = new ClassGenPage( m_pDoc, this, m_pClass );
+ addPage( m_pGenPage, i18n("New Class") );
+ setHelpEnabled(m_pGenPage, false);
+
+ //Setup Attribute Page
+ m_pAttPage = new ClassifierListPage(this, m_pClass, m_pDoc, Uml::ot_Attribute);
+ addPage( m_pAttPage, i18n("Class Attributes") );
+
+ //Setup Operation Page
+ m_pOpPage = new ClassifierListPage(this, m_pClass, m_pDoc, Uml::ot_Operation);
+ addPage( m_pOpPage, i18n("Class Operations") );
+}
+
+void ClassWizard::showPage( QWidget * pWidget ) {
+ QWizard::showPage( pWidget );
+ if( pWidget == m_pOpPage )
+ finishButton() -> setEnabled( true );
+}
+
+void ClassWizard::next() {
+ QWidget * pWidget = currentPage();
+ if( pWidget == m_pGenPage ) {
+ m_pGenPage -> updateObject();
+ } else if( pWidget == m_pAttPage ) {
+ m_pAttPage -> updateObject();
+ }
+ QWizard::next();
+}
+
+void ClassWizard::back() {
+ QWidget * pWidget = currentPage();
+ if( pWidget == m_pAttPage ) {
+ m_pAttPage -> updateObject();
+ } else if( pWidget == m_pOpPage ) {
+ m_pOpPage -> updateObject();
+ }
+ QWizard::back();
+}
+
+void ClassWizard::accept() {
+ m_pDoc -> addUMLObject( m_pClass );
+ m_pDoc->signalUMLObjectCreated(m_pClass);
+
+ QWizard::accept();
+}
+
+void ClassWizard::reject() {
+ delete m_pClass;
+ QWizard::reject();
+}
+
+void ClassWizard::help() {
+ KHelpMenu helpMenu(this);
+ helpMenu.appHelpActivated();
+}
diff --git a/umbrello/umbrello/dialogs/classwizard.h b/umbrello/umbrello/dialogs/classwizard.h
new file mode 100644
index 00000000..bc2dabf8
--- /dev/null
+++ b/umbrello/umbrello/dialogs/classwizard.h
@@ -0,0 +1,104 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef CLASSWIZARD_H
+#define CLASSWIZARD_H
+//kde includes
+#include <kwizard.h>
+//app includes
+#include "classgenpage.h"
+
+class ClassifierListPage;
+class UMLClassifier;
+class UMLDoc;
+
+/**
+ * @author Paul Hensgen
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class ClassWizard : public KWizard {
+public:
+ /**
+ * Consrtuctor
+ */
+ ClassWizard( UMLDoc * pDoc );
+
+ /**
+ * Deconstructor
+ */
+ ~ClassWizard();
+
+protected:
+
+ /**
+ * Overrides the default method.
+ */
+ void showPage( QWidget * pWidget );
+
+ /**
+ * Overrides the default method.
+ */
+ void next();
+
+ /**
+ * Overrides the default method.
+ */
+ void back();
+
+ /**
+ * Overrides the default method.
+ */
+ void accept();
+
+ /**
+ * Overrides the default method.
+ */
+ void reject();
+
+ /**
+ * Setup the wizard pages.
+ */
+ void setupPages();
+
+ /**
+ * Page 1 - General class info
+ */
+ ClassGenPage * m_pGenPage;
+
+ /**
+ * Page 2 - Class Attributes
+ */
+ ClassifierListPage* m_pAttPage;
+
+ /**
+ * Page 3 - Class Operations
+ */
+ ClassifierListPage* m_pOpPage;
+
+ /**
+ * Document currently opened
+ */
+ UMLDoc * m_pDoc;
+
+ /**
+ * Class to create
+ */
+ UMLClassifier * m_pClass;
+
+protected slots:
+ /**
+ * Opens Umbrello handbook
+ */
+ void help();
+
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/codeeditor.cpp b/umbrello/umbrello/dialogs/codeeditor.cpp
new file mode 100644
index 00000000..c05b80bb
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codeeditor.cpp
@@ -0,0 +1,1231 @@
+
+/***************************************************************************
+ codeviewerdialog.cpp - description
+ -------------------
+ begin : Fri Aug 1 2003
+ copyright : (C) 2003 by Brian Thomas
+ email : brian.thomas@gsfc.nasa.gov
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2004-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "codeeditor.h"
+
+// qt/kde includes
+#include <qkeysequence.h>
+#include <qcursor.h>
+#include <qcolor.h>
+#include <qlabel.h>
+#include <qbrush.h>
+#include <qlayout.h>
+#include <qregexp.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+// local includes
+#include "../attribute.h"
+#include "../classifier.h"
+#include "../umldoc.h"
+#include "../umlrole.h"
+
+#include "../codeaccessormethod.h"
+#include "../codegenerator.h"
+#include "../codeclassfield.h"
+#include "../codeclassfielddeclarationblock.h"
+#include "../codedocument.h"
+#include "../codeoperation.h"
+#include "../codemethodblock.h"
+#include "../classifiercodedocument.h"
+#include "../ownedhierarchicalcodeblock.h"
+#include "../codegenerators/codegenfactory.h"
+
+#include "codeviewerdialog.h"
+#include "classpropdlg.h"
+#include "umlattributedialog.h"
+#include "umlroledialog.h"
+#include "umloperationdialog.h"
+
+CodeEditor::CodeEditor ( const QString & text, const QString & context, CodeViewerDialog * parent, const char * name , CodeDocument * doc)
+ : QTextEdit ( text, context, parent, name)
+{
+ init(parent, doc);
+}
+
+CodeEditor::CodeEditor ( CodeViewerDialog * parent, const char* name, CodeDocument * doc )
+ : QTextEdit ( parent, name )
+{
+ init(parent, doc);
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+CodeEditor::~CodeEditor() { }
+
+// clear the display of all text
+void CodeEditor::clearText () {
+
+ // setCaption( tr2i18n("") );
+ m_selectedTextBlock = 0;
+ m_textBlockList.clear();
+ m_tbInfoMap->clear();
+
+ // now call super-class
+ clear();
+
+}
+
+Settings::CodeViewerState CodeEditor::getState()
+{
+ return m_parentDlg->getState();
+}
+
+QLabel * CodeEditor::getComponentLabel() {
+ return m_parentDlg->componentLabel;
+}
+
+
+// FIX: used only for debugging right now.. eliminate eventually -b.t.
+void CodeEditor::clicked(int para, int pos)
+{
+ getComponentLabel()->setText("para:"+QString::number(para)+" pos:"+QString::number(pos));
+}
+
+
+bool CodeEditor::close ( bool alsoDelete )
+{
+
+ // capture last code block, if it exists
+ if(m_lastTextBlockToBeEdited)
+ {
+ updateTextBlockFromText (m_lastTextBlockToBeEdited);
+ m_lastTextBlockToBeEdited = 0;
+ }
+
+ return QTextEdit::close(alsoDelete);
+
+}
+
+void CodeEditor::doubleClicked(int para, int pos)
+{
+
+ m_lastPara = para;
+ m_lastPos = pos;
+
+ // ugh. more ugliness. We want to be able to call up the
+ // correct editing dialog for the given attribute.
+ TextBlock * tBlock = m_textBlockList.at(para);
+ editTextBlock(tBlock, para);
+
+}
+
+// allow us to edit, as appropriate, the parent UMLObject of the
+// given text block.
+void CodeEditor::editTextBlock(TextBlock * tBlock, int para) {
+
+ if(tBlock)
+ {
+ TextBlockInfo *info = (*m_tbInfoMap)[tBlock];
+ if(info) {
+ UMLObject *obj = info->getParent();
+ if(obj)
+ {
+
+ UMLAttribute * at = 0;
+ UMLRole * role = 0;
+ UMLOperation * op = 0;
+
+ if( (at = dynamic_cast<UMLAttribute*>(obj)) )
+ {
+ UMLAttributeDialog dlg( this, at);
+ if( dlg.exec() ) { rebuildView(para); }
+ }
+ else if( (dynamic_cast<UMLClassifier*>(obj)) )
+ {
+ if (obj->showProperties())
+ rebuildView(para);
+ }
+ else if( (role = dynamic_cast<UMLRole*>(obj)))
+ {
+ UMLRoleDialog dlg(this,role);
+ if( dlg.exec() ) { rebuildView(para); }
+ }
+ else if( (op = dynamic_cast<UMLOperation*>(obj)) )
+ //else if( (cop = dynamic_cast<CodeOperation*>(tBlock)) )
+ {
+ UMLOperationDialog dlg(this,op);
+ if( dlg.exec() ) { rebuildView(para); }
+ }
+ else
+ {
+ kError()<<" CodeViewerDlg ERROR: UNKNOWN parent for textBlock"<<endl;
+ }
+
+ }
+ }
+ }
+}
+
+// return whether is empty or just whitespace
+bool CodeEditor::StringIsBlank(const QString &str)
+{
+ if(str.isEmpty() || str.stripWhiteSpace().isEmpty())
+ return true;
+ return false;
+}
+
+void CodeEditor::keyPressEvent ( QKeyEvent * e ) {
+
+ // kDebug() <<"KEY PRESS EVENT:["<<e->text().latin1()<<"] ascii CODE:"<<e->ascii();
+
+ if((e->ascii() == 8) ) // || (e->ascii() == 127)) // what about delete?
+ m_backspacePressed = true;
+
+ // Q: can the MAC or WIN/DOS sequences occur?
+ if((e->ascii() == 10) || (e->ascii() == 13) || (e->text() == "\r\n"))
+ m_newLinePressed = true;
+
+ QTextEdit::keyPressEvent(e);
+}
+
+void CodeEditor::loadFromDocument ()
+{
+
+ // clear the tool
+ clearText();
+
+ // set caption on tool
+ QString caption = m_parentDoc->getFileName() + m_parentDoc->getFileExtension();
+ setCaption( tr2i18n( caption.latin1() ) );
+
+ // header for document
+ QString header = m_parentDoc->getHeader()->toString();
+ QString componentName = QString("header for file ") +caption;
+ if(!StringIsBlank(header))
+ insert(header,m_parentDoc->getHeader(),false,getState().fontColor,
+ getState().nonEditBlockColor,0,componentName);
+
+ // now all the text blocks in the document
+ TextBlockList * items = m_parentDoc->getTextBlockList();
+ appendText(items);
+
+ setCursorPosition(0,0);
+
+}
+
+void CodeEditor::insert (const QString & text, TextBlock * parent, bool editable, const QColor & fgcolor, const QColor & bgcolor, UMLObject * umlobj, const QString & displayName, int startLine)
+{
+
+ // set some params
+ bool isInsert = false;
+ setColor(fgcolor);
+
+ // its an append op if startLine is -1, otherwise its
+ // an actual insert, which is more complicated
+ if(startLine == -1)
+ {
+ startLine = paragraphs()-1;
+ QTextEdit::append(text); // put actual text in. Use insert instead of append so history is preserved?
+ }
+ else
+ {
+ isInsert = true;
+ QTextEdit::insertAt(text, startLine, 0);
+ }
+
+ // actual put in text
+
+ // now do 'paragraph' background highlighting
+ // int endLine = paragraphs()-2;
+ int endLine = text.contains(QRegExp("\n")) + startLine -1;
+ if(m_isHighlighted)
+ for(int para=startLine;para<=endLine;para++)
+ setParagraphBackgroundColor(para,bgcolor);
+
+ // record paragraph information
+ // Did we already start recording info for this parent object?
+ TextBlockInfo * tbinfo;
+ if(m_tbInfoMap->contains(parent))
+ tbinfo = (*m_tbInfoMap)[parent];
+ else {
+ tbinfo = new TextBlockInfo();
+ tbinfo->displayName = displayName;
+ tbinfo->isCodeAccessorMethod = dynamic_cast<CodeAccessorMethod*>(parent) ? true : false;
+ m_tbInfoMap->insert(parent,tbinfo);
+ }
+
+ // set a parent, if its not already set
+ if(umlobj && !tbinfo->getParent())
+ {
+ tbinfo->displayName = displayName;
+ tbinfo->setParent(umlobj);
+ tbinfo->isClickable = textBlockIsClickable(umlobj);
+ }
+
+ // now mark all lines that we just inserted as belonging to the parent
+ for(int para=startLine;para<=endLine;para++)
+ m_textBlockList.insert(para,parent);
+
+ // lastly, update the para info
+ // start position is relative to the FIRST parent position
+ int start = startLine - m_textBlockList.findRef(parent);
+ int size = endLine-startLine;
+
+ // create the object that records this particular "paragraph"
+ ParaInfo * item = new ParaInfo();
+ item->start = start;
+ item->size= size;
+ item->fgcolor = fgcolor;
+ item->bgcolor = bgcolor;
+ item->isEditable = editable;
+
+ if(isInsert)
+ {
+ // now we have to fix the 'start' value for all the para
+ // info blocks that coorspond to textblocks that we inserted
+ // inside of. This means parent tblock paragraph locations
+ // that are greater than zero in that type of textblock
+
+ int increase = size + 1;
+ QMap<TextBlock*,TextBlockInfo*>::Iterator it;
+ for ( it = m_tbInfoMap->begin(); it != m_tbInfoMap->end(); ++it )
+ {
+ TextBlock * tblock = it.key();
+ TextBlockInfo * thisTbInfo = it.data();
+ int firstLoc = m_textBlockList.findRef(tblock);
+ ParaInfo * lastPi = thisTbInfo->m_paraList.last();
+
+ for(ParaInfo * pi = thisTbInfo->m_paraList.first(); pi; pi = thisTbInfo->m_paraList.next())
+ {
+ int minPara = pi->start+firstLoc;
+
+ // only worth doing if in range of the whole
+ // representation
+ if(!pi->start && (startLine > (lastPi->start+firstLoc+lastPi->size) || endLine < minPara) )
+ break;
+
+ // now, only for those paraInfo blocks which
+ // have exceeded our last line, we increase them
+ if(pi->start && minPara >= endLine )
+ pi->start += increase;
+
+ }
+ }
+
+ }
+
+ tbinfo->m_paraList.append(item);
+
+}
+
+void CodeEditor::appendText(TextBlockList * items)
+{
+
+ for (TextBlock *tb = items->first(); tb; tb = items->next())
+ {
+ // types of things we may cast our text block into
+ // This isnt efficient, and is a vote for recording
+ // code block types in an enumerated list somewhere,
+ // as well as a generic attribute "blockType" we could
+ // quickly access, rather than casting. -b.t.
+ HierarchicalCodeBlock * hb = dynamic_cast<HierarchicalCodeBlock *>(tb);
+ CodeMethodBlock * mb = 0;
+ CodeClassFieldDeclarationBlock * db = 0;
+ CodeBlockWithComments * cb = 0;
+ // CodeComment * cm = 0;
+ if(hb)
+ appendText(hb);
+ else if ( (mb = dynamic_cast<CodeMethodBlock*>(tb)) )
+ appendText(mb);
+ else if ( (db = dynamic_cast<CodeClassFieldDeclarationBlock*>(tb)) )
+ appendText(db);
+ else if ( (cb = dynamic_cast<CodeBlockWithComments*>(tb)) )
+ appendText(cb);
+ /*
+ // no! shouldn't be any 'naked' comments floating about. Always
+ // are assocated with a parent code block
+ else if ( (cm = dynamic_cast<CodeComment*>(tb)) )
+ appendText(cm);
+ */
+ else
+ appendText(tb); // no cast worked. Just do a text block
+ }
+
+}
+
+void CodeEditor::appendText (CodeComment * comment, TextBlock * parent, UMLObject * umlObj , const QString & componentName)
+{
+
+ if(!comment->getWriteOutText() && !m_showHiddenBlocks)
+ return;
+
+ QColor bgcolor = getState().nonEditBlockColor;
+ if(!comment->getWriteOutText() && m_showHiddenBlocks)
+ bgcolor = getState().hiddenColor;
+
+ QString indent = comment->getIndentationString();
+ QString text = comment->toString(); // use comment formatting, NOT formatMultiLineText(comment->toString(), indent, "\n");
+ if(!StringIsBlank(text))
+ insert(text,parent,true,getState().fontColor, bgcolor, umlObj, componentName);
+
+}
+
+void CodeEditor::appendText (CodeBlockWithComments * cb ) {
+
+ if(!cb->getWriteOutText() && !m_showHiddenBlocks)
+ return;
+
+ QString indent = cb->getIndentationString();
+ QString body = cb->formatMultiLineText (cb->getText(), indent, "\n");
+
+ QColor bgcolor = getState().editBlockColor;
+ QString componentName = QString("CodeBlock");
+
+ appendText(cb->getComment(), cb, 0, componentName);
+
+ if(!cb->getWriteOutText() && m_showHiddenBlocks)
+ bgcolor = getState().hiddenColor;
+
+ if(!StringIsBlank(body))
+ insert(body,cb,true,getState().fontColor,bgcolor,0);
+
+}
+
+void CodeEditor::appendText (CodeClassFieldDeclarationBlock * db ) {
+
+ if(!db->getWriteOutText() && !m_showHiddenBlocks)
+ return;
+
+ QString indent = db->getIndentationString();
+ QString body = db->formatMultiLineText (db->getText(), indent, "\n");
+
+ UMLObject * parentObj = db->getParentClassField()->getParentObject();
+
+ QColor bgcolor = getState().editBlockColor;
+ QString componentName = QString("");
+ if(parentObj)
+ {
+ if(db->getParentClassField()->parentIsAttribute()) {
+ componentName = parentDocName + "::attribute_field(" + parentObj->getName() + ')';
+ } else {
+ UMLRole * role = dynamic_cast<UMLRole*>(parentObj);
+ componentName = parentDocName + "::association_field(" + role->getName() + ')';
+ }
+ bgcolor = getState().umlObjectColor;
+ }
+
+ appendText(db->getComment(), db, parentObj,componentName);
+
+ if(!db->getWriteOutText() && m_showHiddenBlocks)
+ bgcolor = getState().hiddenColor;
+
+ if(!StringIsBlank(body))
+ insert(body,db,false,getState().fontColor,bgcolor,parentObj);
+
+
+}
+
+void CodeEditor::appendText (CodeMethodBlock * mb) {
+
+ // Note: IF CodeAccessors are hidden, we DON'T show
+ // it even when requested as the hiddeness of these methods
+ // should be controled by the class fields, not the user in the editor.
+ if(!mb->getWriteOutText() && (!m_showHiddenBlocks || dynamic_cast<CodeAccessorMethod*>(mb)))
+ return;
+
+ QColor bgcolor = getState().umlObjectColor;
+ QString indent = mb->getIndentationString();
+ QString bodyIndent = mb->getIndentationString(mb->getIndentationLevel()+1);
+
+ QString startText = mb->formatMultiLineText ( mb->getStartMethodText(), indent, "\n");
+ QString body = mb->formatMultiLineText (mb->getText(), bodyIndent, "\n");
+ QString endText = mb->formatMultiLineText( mb->getEndMethodText(), indent, "\n");
+
+ if(body.isEmpty())
+ body = " \n";
+
+ if(!mb->getWriteOutText() && m_showHiddenBlocks)
+ {
+ // it gets the 'hidden' color
+ bgcolor = getState().hiddenColor;
+ }
+
+ QString componentName = QString("<b>parentless method\?</b>");
+
+ // ugly, but we need to know if there is a parent object here.
+ CodeOperation * op = dynamic_cast<CodeOperation*>(mb);
+ CodeAccessorMethod * accessor = dynamic_cast<CodeAccessorMethod*>(mb);
+ UMLObject * parentObj = 0;
+ if(op)
+ {
+ parentObj = op->getParentOperation();
+ if(((UMLOperation*)parentObj)->isConstructorOperation())
+ componentName = parentDocName + "::operation("+ parentObj->getName()+") constructor method";
+ else
+ componentName = parentDocName + "::operation("+ parentObj->getName()+") method";
+ }
+ if(accessor)
+ {
+ parentObj = accessor->getParentObject();
+ if(accessor->getParentClassField()->parentIsAttribute()) {
+ componentName = parentDocName + "::attribute_field(" + parentObj->getName() + ") accessor method";
+ } else {
+ UMLRole * role = dynamic_cast<UMLRole*>(parentObj);
+ componentName = parentDocName + "::association_field(" + role->getName() + ") accessor method";
+ }
+
+ }
+
+ //appendText(mb->getComment(), mb, parentObj, componentName);
+ appendText(mb->getComment(), mb->getComment(), parentObj, componentName);
+
+ if(!StringIsBlank(startText))
+ insert(startText,mb,false,getState().fontColor,bgcolor,parentObj);
+ // always insert body for methods..IF we don't, we create a
+ // situation where the user cant edit the body (!)
+ insert(body,mb,true,getState().fontColor,bgcolor,parentObj);
+ if(!StringIsBlank(endText))
+ insert(endText,mb,false,getState().fontColor,bgcolor,parentObj);
+
+}
+
+void CodeEditor::appendText (TextBlock * tb) {
+
+ if(!tb->getWriteOutText() && !m_showHiddenBlocks)
+ return;
+
+ QColor bgcolor = getState().nonEditBlockColor;
+ if(!tb->getWriteOutText() && m_showHiddenBlocks)
+ bgcolor = getState().hiddenColor;
+
+ QString str = tb->toString();
+ insert(str,tb,false,getState().fontColor,bgcolor);
+
+}
+
+void CodeEditor::appendText(HierarchicalCodeBlock * hblock)
+{
+
+ if(!hblock->getWriteOutText() && !m_showHiddenBlocks)
+ return;
+
+ OwnedHierarchicalCodeBlock * test = dynamic_cast<OwnedHierarchicalCodeBlock *>(hblock);
+ UMLObject * parentObj = 0;
+ QString componentName = QString("");
+ QColor paperColor = getState().nonEditBlockColor;
+ if(test)
+ {
+ parentObj = test->getParentObject();
+ UMLClassifier *c = dynamic_cast<UMLClassifier*>(parentObj);
+ if (c) {
+ QString typeStr;
+ if (c->isInterface())
+ typeStr = "Interface";
+ else
+ typeStr = "Class";
+ componentName = parentDocName + "::" + typeStr + '(' + parentObj->getName() + ')';
+ } else {
+ componentName = parentDocName + "::UNKNOWN(" + parentObj->getName() + ')';
+ }
+
+ paperColor = getState().umlObjectColor;
+ }
+
+ if(!hblock->getWriteOutText() && m_showHiddenBlocks)
+ paperColor = getState().hiddenColor;
+
+ TextBlockList * items = hblock->getTextBlockList();
+ QString indent = hblock->getIndentationString();
+ QString startText = hblock->formatMultiLineText ( hblock->getStartText(), indent, "\n");
+ QString endText = hblock->formatMultiLineText( hblock->getEndText(), indent, "\n");
+
+ appendText(hblock->getComment(), hblock, parentObj, componentName);
+
+ if(!StringIsBlank(startText))
+ insert(startText,hblock,false,getState().fontColor,paperColor, parentObj);
+ appendText(items);
+ if(!StringIsBlank(endText))
+ insert(endText,hblock,false,getState().fontColor,paperColor);
+
+}
+
+void CodeEditor::insertParagraph ( const QString & text, int para )
+{
+ QTextEdit::insertParagraph(text,para);
+}
+
+void CodeEditor::removeParagraph ( int para )
+{
+ QTextEdit::removeParagraph(para);
+}
+
+// All umlobjects which may have pop-up boxes should return true here
+// Yes, a CRAPPY way of doing this. Im not proud. =b.t.
+bool CodeEditor::textBlockIsClickable(UMLObject * obj)
+{
+
+ if( dynamic_cast<UMLAttribute*>(obj) )
+ return true;
+ else if( dynamic_cast<UMLClassifier*>(obj) )
+ return true;
+ else if( dynamic_cast<UMLRole*>(obj) )
+ return true;
+ else if( dynamic_cast<UMLOperation*>(obj) )
+ return true;
+
+ return false;
+}
+
+void CodeEditor::slotChangeSelectedBlockView()
+{
+ TextBlock * tb = m_selectedTextBlock;
+ if(tb) {
+ tb->setWriteOutText(tb->getWriteOutText() ? false : true );
+ rebuildView(m_lastPara);
+ }
+
+}
+
+// change the status of the comment writeOutText value to
+// opposite of current value
+void CodeEditor::slotChangeSelectedBlockCommentView()
+{
+
+ TextBlock * tb = m_selectedTextBlock;
+ CodeBlockWithComments * cb = 0;
+ if(tb && (cb = dynamic_cast<CodeBlockWithComments*>(tb)))
+ {
+ cb->getComment()->setWriteOutText(cb->getComment()->getWriteOutText() ? false : true );
+ rebuildView( m_lastPara );
+ }
+
+}
+
+void CodeEditor::slotInsertCodeBlockBeforeSelected()
+{
+
+ TextBlock * tb = m_selectedTextBlock;
+ CodeBlockWithComments * newBlock = m_parentDoc->newCodeBlockWithComments();
+ newBlock->setText("<<INSERT>>");
+ newBlock->getComment()->setWriteOutText(false);
+
+ m_parentDoc->insertTextBlock(newBlock, tb, false);
+
+ int location = m_textBlockList.findRef(m_selectedTextBlock); // find first para of selected block
+
+ QString body = newBlock->formatMultiLineText (newBlock->getText(), newBlock->getIndentationString(), "\n");
+
+ insert(body,newBlock,true,getState().fontColor,
+ getState().editBlockColor,0,QString("CodeBlock"),location);
+
+}
+
+void CodeEditor::slotInsertCodeBlockAfterSelected()
+{
+
+ TextBlock * tb = m_selectedTextBlock;
+ CodeBlockWithComments * newBlock = m_parentDoc->newCodeBlockWithComments();
+ newBlock->setText("<<INSERT>>");
+ newBlock->getComment()->setWriteOutText(false);
+
+ m_parentDoc->insertTextBlock(newBlock, tb, true);
+
+ // find last para of selected block
+ TextBlockInfo *tbinfo = (*m_tbInfoMap)[m_selectedTextBlock];
+ ParaInfo * lastpi = tbinfo->m_paraList.last();
+ int location = m_textBlockList.findRef(m_selectedTextBlock) + lastpi->start + lastpi->size + 1;
+
+ QString body = newBlock->formatMultiLineText (newBlock->getText(), newBlock->getIndentationString(), "\n");
+
+ insert(body,newBlock,true,getState().fontColor,
+ getState().editBlockColor,0,QString("CodeBlock"),location);
+
+}
+
+QPopupMenu * CodeEditor::createPopupMenu ( const QPoint & pos )
+{
+
+ TextBlock * tb = m_selectedTextBlock;
+ m_lastPara = paragraphAt(pos);
+
+ QPopupMenu * menu = new QPopupMenu(this);
+ // ugh. A bug in the Qt interaction between QTextEdit and Menu
+ // can sometimes trigger a clear() call of the text area after
+ // the popup menu is destroyed. The workaround is to disable
+ // the behavior by blocking the destroy signal from the menu.
+ menu->blockSignals(true);
+
+ if (m_selectedTextBlock)
+ {
+ if(tb->getWriteOutText())
+ menu->insertItem("Hide",this,SLOT(slotChangeSelectedBlockView()), Key_H, 0);
+ else
+ menu->insertItem("Show",this,SLOT(slotChangeSelectedBlockView()), Key_S, 0);
+
+ CodeBlockWithComments * cb = dynamic_cast<CodeBlockWithComments*>(tb);
+ if(cb)
+ if(cb->getComment()->getWriteOutText())
+ menu->insertItem("Hide Comment",this,SLOT(slotChangeSelectedBlockCommentView()), CTRL+Key_H, 1);
+ else
+ menu->insertItem("Show Comment",this,SLOT(slotChangeSelectedBlockCommentView()), CTRL+Key_S, 1);
+ menu->insertSeparator();
+
+ menu->insertItem("Insert Code Block Before",this,SLOT(slotInsertCodeBlockBeforeSelected()), CTRL+Key_B, 2);
+ menu->insertItem("Insert Code Block After",this,SLOT(slotInsertCodeBlockAfterSelected()), CTRL+Key_A, 3);
+
+ menu->insertSeparator();
+
+ menu->insertItem("Copy",this,SLOT(slotCopyTextBlock()), CTRL+Key_C, 4);
+ menu->insertItem("Paste",this,SLOT(slotPasteTextBlock()), CTRL+Key_V, 5);
+ menu->insertItem("Cut",this,SLOT(slotCutTextBlock()), CTRL+Key_X, 6);
+
+ // enable/disable based on conditions
+ if(m_selectedTextBlock == m_parentDoc->getHeader())
+ menu->setItemEnabled (2, false);
+
+ if(!m_textBlockToPaste)
+ menu->setItemEnabled (5, false);
+
+ if(!tb->canDelete())
+ menu->setItemEnabled (6, false);
+
+ // manythings cant be copied. RIght now, lets just limit ourselves to
+ // owned things and hierarchicalcodeblocks
+ if(dynamic_cast<OwnedCodeBlock*>(m_selectedTextBlock) ||
+ dynamic_cast<HierarchicalCodeBlock*>(m_selectedTextBlock))
+ menu->setItemEnabled (4, false);
+
+ // TBD
+ // m_selectedTextBlock->insertCodeEditMenuItems(menu, this);
+ }
+
+ return menu;
+}
+
+void CodeEditor::slotCopyTextBlock ( )
+{
+ // make a copy
+ if(dynamic_cast<HierarchicalCodeBlock*>(m_selectedTextBlock))
+ m_textBlockToPaste = m_parentDoc->newHierarchicalCodeBlock();
+ else if(dynamic_cast<CodeBlockWithComments*>(m_selectedTextBlock))
+ m_textBlockToPaste = m_parentDoc->newCodeBlockWithComments();
+ else if(dynamic_cast<CodeBlock*>(m_selectedTextBlock))
+ m_textBlockToPaste = m_parentDoc->newCodeBlock();
+ else if(dynamic_cast<CodeComment*>(m_selectedTextBlock))
+ m_textBlockToPaste = CodeGenFactory::newCodeComment(m_parentDoc);
+ else
+ {
+ kError()<<" ERROR: CodeEditor can't copy selected block:"<<m_selectedTextBlock<<" of unknown type"<<endl;
+ m_textBlockToPaste = 0;
+ return; // error!
+ }
+
+ m_textBlockToPaste->setAttributesFromObject(m_selectedTextBlock);
+
+}
+
+void CodeEditor::slotCutTextBlock ( ) {
+
+ // make a copy first
+ slotCopyTextBlock();
+
+ // This could cause problems, but we are OK as
+ // long as we only try to delete 'canDelete' textblocks
+ if(m_selectedTextBlock->canDelete())
+ {
+ // just in case there are pending edits
+ // we don't want to lose them
+ if (m_lastTextBlockToBeEdited && m_lastTextBlockToBeEdited == (CodeBlock*) m_selectedTextBlock)
+ {
+ updateTextBlockFromText (m_lastTextBlockToBeEdited);
+ m_lastTextBlockToBeEdited = 0;
+ }
+
+ m_parentDoc->removeTextBlock(m_selectedTextBlock);
+ rebuildView(m_lastPara);
+ // removeTextBlock(m_selectedTextBlock);
+ m_selectedTextBlock = 0;
+ }
+
+}
+
+void CodeEditor::slotPasteTextBlock ( ) {
+
+ if(m_textBlockToPaste)
+ {
+ m_parentDoc->insertTextBlock(m_textBlockToPaste, m_selectedTextBlock);
+ m_textBlockToPaste = 0;
+ rebuildView(m_lastPara);
+ }
+
+}
+
+void CodeEditor::slotRedrawText() {
+ rebuildView(m_lastPara);
+}
+
+void CodeEditor::init ( CodeViewerDialog * parentDlg, CodeDocument * parentDoc ) {
+
+ // safety to insure that we are up to date
+ parentDoc->synchronize();
+
+ m_parentDlg = parentDlg;
+ m_parentDoc = parentDoc;
+
+ setUndoRedoEnabled( false );
+ setCursor( QCursor( 0 ) );
+ setMouseTracking( true );
+ setReadOnly (true);
+ m_isHighlighted = getState().blocksAreHighlighted;
+ m_showHiddenBlocks = getState().showHiddenBlocks;
+
+ m_newLinePressed = false;
+ m_backspacePressed = false;
+ m_textBlockToPaste = 0;
+ m_selectedTextBlock = 0;
+ m_lastTextBlockToBeEdited = 0;
+ m_tbInfoMap = new QMap<TextBlock *, TextBlockInfo*>;
+
+ setFont( getState().font );
+
+ // set name of parent doc
+ ClassifierCodeDocument * cdoc = dynamic_cast<ClassifierCodeDocument*>(m_parentDoc);
+ if(cdoc)
+ parentDocName = cdoc->getParentClassifier()->getName();
+ else
+ parentDocName = "";
+
+ // set some viewability parameters
+ //int margin = fontMetrics().height();
+
+ QBrush pbrush = QBrush ( getState().paperColor);
+ setPaper(pbrush);
+
+ // setMargin(margin);
+
+ // connect(this,SIGNAL(newLinePressed()),this,SLOT(newLinePressed()));
+ // connect(this,SIGNAL(backspacePressed()),this,SLOT(backspacePressed()));
+ connect(this,SIGNAL(doubleClicked(int,int)),this,SLOT(doubleClicked(int,int)));
+ connect(this,SIGNAL(cursorPositionChanged(int,int)),this,SLOT(cursorPositionChanged(int,int)));
+
+ // do this last
+ loadFromDocument();
+
+}
+
+void CodeEditor::updateTextBlockFromText (TextBlock * block) {
+
+ if (block) {
+
+ CodeMethodBlock * cmb = dynamic_cast<CodeMethodBlock*>(block);
+ //QString baseIndent = block->getNewEditorLine(block->getIndentationLevel()+(cmb ? 1 : 0));
+ QString baseIndent = block->getIndentationString(block->getIndentationLevel()+(cmb ? 1 : 0));
+
+ TextBlockInfo *info = (*m_tbInfoMap)[block];
+ UMLObject * parentObj = info->getParent();
+ int pstart = m_textBlockList.findRef(block);
+ QString content = "";
+
+ // Assemble content from editiable paras
+ QPtrList<ParaInfo> list = info->m_paraList;
+ for(ParaInfo * item = list.first(); item; item=list.next())
+ {
+ if(item->isEditable)
+ {
+ int lastpara = item->start+pstart+item->size;
+ int endEdit = block->lastEditableLine();
+ int lastLineToAddNewLine = lastpara + endEdit;
+ for(int para=(item->start+pstart);para<=lastpara;para++)
+ {
+ QString line = block->unformatText(text(para), baseIndent);
+ content += line;
+ // \n are implicit in the editor (!) so we should put them
+ // back in, if there is any content from the line
+ if(!line.isEmpty() && para != lastLineToAddNewLine)
+ content += "\n";
+ }
+ }
+ }
+
+ //cerr<<"UPDATE GOT CONTENT:["<<content.latin1()<<"] to block:"<<block<<endl;
+ block->setText(content);
+
+ // if a parent for the block, try to set its documentation
+ // as long as its NOT an accessor codeblock.
+ if(parentObj && !info->isCodeAccessorMethod)
+ parentObj->setDoc(content);
+
+ // make note that its now user generated
+ if(cmb)
+ cmb->setContentType(CodeBlock::UserGenerated);
+
+ }
+}
+
+void CodeEditor::cursorPositionChanged(int para, int pos)
+{
+
+ // safety.. this is endemic of a 'bad' pointer event and can crash us otherwise
+ if(pos < 0)
+ return;
+
+ // bool lastParaIsEditable = isReadOnly() ? false : true;
+ bool lastParaIsEditable = isParaEditable(m_lastPara);
+
+ // IF last para where cursor is coming from was editable
+ // we have a variety of things to look out for.
+ if(lastParaIsEditable)
+ {
+ // If we got here as the result of a newline, then expansion
+ // of a para editablity occurs.
+ if((para-1) == m_lastPara && m_newLinePressed )
+ expandSelectedParagraph ( m_lastPara );
+
+ // conversely, we contract the zone of editablity IF we
+ // got to current position as result of backspace
+ if((para+1) == m_lastPara && m_backspacePressed )
+ contractSelectedParagraph( para );
+
+ }
+
+ // now check if the current paragraph is really editiable, and if so,
+ // so some things
+ bool editPara = isParaEditable(para);
+ if(editPara) {
+
+ TextBlock * tBlock = m_textBlockList.at(para);
+ CodeMethodBlock * cmb = dynamic_cast<CodeMethodBlock*>(tBlock);
+
+ // auto-indent new lines
+ QString currentParaText = text(para);
+ QString baseIndent = tBlock->getNewEditorLine(tBlock->getIndentationLevel()+(cmb ? 1 : 0));
+ // cerr<<"AUTO INDENT:["<<baseIndent.latin1()<<"] isMethod?"<<(cmb?"true":"false")<<endl;
+ int minPos = baseIndent.length();
+
+ // add indent chars to the current line, if missing
+ if(!m_backspacePressed && !currentParaText.contains(QRegExp('^'+baseIndent)))
+ {
+ insertAt(baseIndent,para,0);
+ setCursorPosition(para,pos+minPos);
+ return;
+ }
+
+ if(pos<minPos)
+ {
+
+ bool priorParaIsEditable = isParaEditable(para-1);
+ if(m_backspacePressed && para && priorParaIsEditable)
+ {
+ int endOfPriorLine = paragraphLength(para-1);
+ // IN this case, we remove old (para) line, and tack its
+ // contents on the line we are going to.
+ QString contents = text(para);
+ contents = contents.right(contents.length()-m_lastPos+1);
+
+ // this next thing happens when we arent deleting last line
+ // of editable text, so we want to append whats left of this line
+ // onto the one we are backspacing into
+ if(paraIsNotSingleLine(para))
+ {
+ removeParagraph(para);
+ insertAt(contents,(para-1),endOfPriorLine);
+ setCursorPosition((para-1),endOfPriorLine);
+ }
+
+ } else {
+ // well, if the following is true, then they
+ // are trying to hack away at the last line, which
+ // we cant allow to entirely disappear. Lets preserve
+ // the indentation
+ if(m_backspacePressed && !priorParaIsEditable)
+ {
+ QString contents = text(para);
+ contents = contents.right(contents.length()-m_lastPos+1);
+ contents = baseIndent + contents.left(contents.length()-1); // left is to remove trailing space
+ insertParagraph(contents,para+1);
+ removeParagraph(para);
+
+ // furthermore, IF its nothing but indentation + whitespace
+ // we switch this back to Auto-Generated.
+ if(cmb && contents.contains(QRegExp('^'+baseIndent+"\\s$")))
+ {
+ cmb->setContentType(CodeBlock::AutoGenerated);
+ cmb->syncToParent();
+ }
+
+ }
+
+ // send them to the first spot in the line which is editable
+ setCursorPosition(para,minPos);
+
+ }
+ return;
+ }
+ }
+
+ // look for changes in editability, if they occur, we need to record
+ // the edits which have been made
+ if((editPara && !m_lastTextBlockToBeEdited) || (!editPara && m_lastTextBlockToBeEdited)) {
+
+ setReadOnly(editPara ? false : true);
+
+ // IF this is a different text block, update the body of the method
+ // it belongs to
+ if(m_lastTextBlockToBeEdited && (m_lastTextBlockToBeEdited != m_textBlockList.at(para) || !editPara))
+ {
+ updateTextBlockFromText (m_lastTextBlockToBeEdited);
+ m_lastTextBlockToBeEdited = 0;
+ }
+
+ if(editPara)
+ m_lastTextBlockToBeEdited = m_textBlockList.at(para);
+ else
+ m_lastTextBlockToBeEdited = 0;
+
+ }
+
+ m_lastPara = para;
+ m_lastPos = pos;
+ m_newLinePressed = false;
+ m_backspacePressed = false;
+
+}
+
+bool CodeEditor::paraIsNotSingleLine (int para)
+{
+ TextBlock * tBlock = m_textBlockList.at(para);
+ if(tBlock)
+ {
+ int pstart = m_textBlockList.findRef(tBlock);
+ TextBlockInfo *info = (*m_tbInfoMap)[tBlock];
+ QPtrList<ParaInfo> list = info->m_paraList;
+
+ for(ParaInfo * item = list.first(); item; item=list.next())
+ if((pstart+item->start) <= para && (item->start+pstart+item->size) >= para )
+ if(item->size > 0)
+ return true;
+ }
+ return false;
+}
+
+bool CodeEditor::isParaEditable (int para) {
+
+ if (para <0)
+ return false;
+
+ TextBlock * tBlock = m_textBlockList.at(para);
+ if(tBlock)
+ {
+ int editStart = tBlock->firstEditableLine();
+ int editEnd = tBlock->lastEditableLine();
+ bool hasEditableRange = (editStart > 0 || editEnd < 0) ? true : false;
+ TextBlockInfo *info = (*m_tbInfoMap)[tBlock];
+ int pstart = m_textBlockList.findRef(tBlock);
+ int relativeLine = para - pstart;
+ QPtrList<ParaInfo> list = info->m_paraList;
+ for(ParaInfo * item = list.first(); item; item=list.next())
+ {
+ if((item->start+pstart) <= para && (item->start+pstart+item->size) >= para)
+ if(item->isEditable && hasEditableRange)
+ {
+ if ( relativeLine >= editStart && relativeLine <= (item->size + editEnd) )
+ return true;
+ else
+ return false;
+ } else
+ return item->isEditable;
+ }
+ }
+ return false;
+}
+
+void CodeEditor::changeTextBlockHighlighting(TextBlock * tBlock, bool selected) {
+
+ if(tBlock)
+ {
+ TextBlockInfo *info = (*m_tbInfoMap)[tBlock];
+ QPtrList<ParaInfo> list = info->m_paraList;
+ int pstart = m_textBlockList.findRef(tBlock);
+ for(ParaInfo * item = list.first(); item; item=list.next())
+ for(int p=(item->start+pstart);p<=(item->start+pstart+item->size);p++)
+ if(selected)
+ if(info->isClickable)
+ setParagraphBackgroundColor(p,getState().selectedColor);
+ else
+ setParagraphBackgroundColor(p,getState().nonEditBlockColor);
+ else if(m_isHighlighted)
+ setParagraphBackgroundColor(p,item->bgcolor);
+ else
+ setParagraphBackgroundColor(p,getState().paperColor);
+ }
+
+}
+
+void CodeEditor::changeShowHidden (int signal) {
+
+ if(signal)
+ m_showHiddenBlocks = true;
+ else
+ m_showHiddenBlocks = false;
+
+ rebuildView(m_lastPara);
+
+}
+
+// colorizes/uncolorizes type for ALL paragraphs
+void CodeEditor::changeHighlighting(int signal) {
+
+ int total_para = paragraphs()-1;
+ if(signal) {
+ // we want to highlight
+ m_isHighlighted = true;
+ for(int para=0;para<total_para;para++)
+ {
+ TextBlock * tblock = m_textBlockList.at(para);
+ changeTextBlockHighlighting(tblock,false);
+ }
+
+
+ } else {
+ // we DON'T want to highlight
+ m_isHighlighted = false;
+ for(int para=0;para<total_para;para++)
+ setParagraphBackgroundColor(para,getState().paperColor);
+ }
+
+ // now redo the "selected" para, should it exist
+ if(m_selectedTextBlock)
+ changeTextBlockHighlighting(m_selectedTextBlock,true);
+
+}
+
+void CodeEditor::contractSelectedParagraph( int paraToRemove ) {
+ TextBlock * tBlock = m_textBlockList.at(paraToRemove);
+ if(tBlock)
+ {
+ int pstart = m_textBlockList.findRef(tBlock);
+ TextBlockInfo *info = (*m_tbInfoMap)[tBlock];
+ QPtrList<ParaInfo> list = info->m_paraList;
+
+ bool lowerStartPosition = false;
+ for(ParaInfo * item = list.first(); item; item=list.next())
+ {
+ if(lowerStartPosition)
+ item->start -= 1;
+
+ if((pstart+item->start) <= paraToRemove && (item->start+pstart+item->size) >= paraToRemove)
+ {
+ item->size -= 1;
+ // a little cheat.. we don't want to remove last line as we need
+ // to leave a place that can be 'edited' by the tool IF the user
+ // changes their mind about method body content
+ if(item->size < 0)
+ item->size = 0;
+ lowerStartPosition = true;
+ }
+ }
+
+ m_textBlockList.remove(paraToRemove);
+ }
+}
+
+void CodeEditor::expandSelectedParagraph( int priorPara ) {
+
+
+ TextBlock * tBlock = m_textBlockList.at(priorPara);
+ if(tBlock)
+ {
+ // add this tBlock in
+ m_textBlockList.insert(priorPara,tBlock);
+ TextBlockInfo *info = (*m_tbInfoMap)[tBlock];
+ QPtrList<ParaInfo> list = info->m_paraList;
+ int pstart = m_textBlockList.findRef(tBlock);
+
+ // now update the paragraph information
+ bool upStartPosition = false;
+ for(ParaInfo * item = list.first(); item; item=list.next())
+ {
+ // AFTER we get a match, then following para's need to have start position upped too
+ if(upStartPosition)
+ item->start += 1;
+
+ if((pstart+item->start) <= priorPara && (item->start+pstart+item->size) >= priorPara)
+ {
+ item->size += 1;
+ cursorPositionChanged(m_lastPara, m_lastPos);
+ upStartPosition = true;
+ }
+ }
+ }
+
+}
+
+void CodeEditor::contentsMouseMoveEvent ( QMouseEvent * e )
+{
+
+ int para = paragraphAt(e->pos());
+
+ if (para < 0)
+ return; // shouldn't happen..
+
+ TextBlock * tblock = m_textBlockList.at(para);
+ if (tblock && m_selectedTextBlock != tblock ) {
+ TextBlockInfo * info = (*m_tbInfoMap)[tblock];
+
+ // unhighlight old selected textblock regardless of whether
+ // it was selected or not.
+ changeTextBlockHighlighting(m_selectedTextBlock,false);
+
+ // highlight new block
+ changeTextBlockHighlighting(tblock,true);
+
+ // FIX: update the label that shows what type of component this is
+ getComponentLabel()->setText("<b>"+info->displayName+"</b>");
+
+ m_selectedTextBlock = tblock;
+
+ if(m_lastTextBlockToBeEdited)
+ {
+ updateTextBlockFromText (m_lastTextBlockToBeEdited);
+ m_lastTextBlockToBeEdited = 0;
+ }
+ }
+
+ // record this as the last paragraph
+
+}
+
+
+// Rebuild our view of the document. Happens whenever we change
+// some field/aspect of an underlying UML object used to create
+// the view.
+// If connections are right, then the UMLObject will send out the modified()
+// signal which will trigger a call to re-generate the appropriate code within
+// the code document. Our burden is to appropriately prepare the tool: we clear
+// out ALL the textblocks in the QTextEdit widget and then re-show them
+// after the dialog disappears
+void CodeEditor::rebuildView( int startCursorPos ) {
+
+ loadFromDocument();
+
+ // make a minima attempt to leave the cursor (view of the code) where
+ // we started
+ int new_nrof_para = paragraphs() -1;
+ setCursorPosition((startCursorPos < new_nrof_para ? startCursorPos : 0), 0);
+
+}
+
+
+
+
+#include "codeeditor.moc"
diff --git a/umbrello/umbrello/dialogs/codeeditor.h b/umbrello/umbrello/dialogs/codeeditor.h
new file mode 100644
index 00000000..57f1fb37
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codeeditor.h
@@ -0,0 +1,191 @@
+
+/***************************************************************************
+ codeeditor.h - description
+ -------------------
+ begin : Fri Aug 1 2003
+ copyright : (C) 2003 by Brian Thomas
+ email : brian.thomas@gsfc.nasa.gov
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef CODEEDITOR_H
+#define CODEEDITOR_H
+
+#include <qpopupmenu.h>
+#include <qstring.h>
+#include <qlabel.h>
+#include <qtextedit.h>
+#include "../codeviewerstate.h"
+#include "../textblocklist.h"
+
+class UMLObject;
+
+class CodeViewerDialog;
+class CodeComment;
+class CodeDocument;
+class CodeClassFieldDeclarationBlock;
+class CodeMethodBlock;
+class CodeBlockWithComments;
+class HierarchicalCodeBlock;
+
+class TextBlockInfo;
+class TextBlock;
+class ParaInfo;
+
+class CodeEditor : public QTextEdit
+{
+ Q_OBJECT
+public:
+
+ explicit CodeEditor ( const QString & text, const QString & context = QString(), CodeViewerDialog * parent = 0, const char * name = 0 , CodeDocument * doc = 0);
+ explicit CodeEditor ( CodeViewerDialog * parent, const char* name = 0, CodeDocument * doc = 0);
+ ~CodeEditor ();
+
+ // return code viewer state
+ Settings::CodeViewerState getState( );
+
+protected:
+
+ bool close ( bool alsoDelete );
+
+ // various methods for appending various types of text blocks in the editor.
+ void appendText (TextBlock * tblock);
+ void appendText (HierarchicalCodeBlock * hblock);
+ void appendText (CodeClassFieldDeclarationBlock * db );
+ void appendText (TextBlockList * items);
+ void appendText (CodeMethodBlock * mb);
+ void appendText (CodeComment * comment, TextBlock * parent, UMLObject * umlObj = 0, const QString & compName="");
+ void appendText (CodeBlockWithComments * cb );
+
+ // Rebuild our view of the document. Happens whenever we change
+ // some field/aspect of an underlying UML object used to create
+ // the view.
+ // If connections are right, then the UMLObject will send out the modified()
+ // signal which will trigger a call to re-generate the appropriate code within
+ // the code document. Our burden is to appropriately prepare the tool: we clear
+ // out ALL the textblocks in the QTextEdit widget and then re-show them
+ // after the dialog disappears
+ void rebuildView( int startCursorPos );
+
+ // override the QT event so we can do appropriate things
+ void contentsMouseMoveEvent ( QMouseEvent * e );
+
+ // implemented so we may capture certain key presses, namely backspace
+ // and 'return' events.
+ void keyPressEvent ( QKeyEvent * e );
+
+ // (re) load the parent code document into the editor
+ void loadFromDocument();
+
+ // specialized popup menu for our tool
+ QPopupMenu * createPopupMenu ( const QPoint & pos );
+
+private:
+
+ QString parentDocName;
+ CodeDocument * m_parentDoc;
+ CodeViewerDialog * m_parentDlg;
+
+ int m_lastPara;
+ int m_lastPos;
+
+ bool m_newLinePressed;
+ bool m_backspacePressed;
+ bool m_isHighlighted;
+ bool m_showHiddenBlocks;
+
+ TextBlock * m_textBlockToPaste;
+ TextBlock * m_selectedTextBlock;
+ TextBlock * m_lastTextBlockToBeEdited;
+
+ QMap<TextBlock*, TextBlockInfo*> *m_tbInfoMap;
+ TextBlockList m_textBlockList;
+
+ // main insert routine. Will append if startline is not supplied.
+ void insert (const QString & text, TextBlock * parent, bool isEditable = false,
+ const QColor & fgcolor = QColor("black"), const QColor & bgcolor = QColor("white"),
+ UMLObject * umlobj = 0, const QString & displayName = "", int startLine = -1);
+
+ void editTextBlock(TextBlock * tBlock, int para);
+ void clearText();
+ QLabel * getComponentLabel();
+ bool paraIsNotSingleLine (int para);
+ void expandSelectedParagraph( int where );
+ void contractSelectedParagraph( int where );
+ void updateTextBlockFromText (TextBlock * block);
+
+ void initText ( CodeDocument * doc );
+ void init ( CodeViewerDialog * parentDlg, CodeDocument * parentDoc );
+
+ void changeTextBlockHighlighting(TextBlock * tb, bool selected);
+ bool isParaEditable (int para);
+ bool textBlockIsClickable(UMLObject * obj);
+
+ // return whether or not the passed string is empty or
+ // contains nothing but whitespace
+ static bool StringIsBlank( const QString &str );
+
+public slots:
+
+ void insertParagraph ( const QString & text, int para );
+ void removeParagraph ( int para );
+ void changeHighlighting(int signal);
+ void changeShowHidden (int signal);
+ void slotRedrawText();
+
+protected slots:
+
+ void clicked(int para, int pos );
+ void doubleClicked(int para, int pos );
+ void cursorPositionChanged(int para, int pos );
+ void slotCopyTextBlock ( );
+ void slotCutTextBlock ( );
+ void slotPasteTextBlock ( );
+ void slotChangeSelectedBlockView();
+ void slotChangeSelectedBlockCommentView();
+ void slotInsertCodeBlockAfterSelected();
+ void slotInsertCodeBlockBeforeSelected();
+
+signals:
+
+ /*
+ void sigNewLinePressed ();
+ void sigBackspacePressed ();
+ */
+
+};
+
+class ParaInfo {
+public:
+ int start; // this is a relative offset from the beginning of the tblock
+ int size;
+ QColor fgcolor;
+ QColor bgcolor;
+ bool isEditable;
+
+ ParaInfo () { isEditable = false; }
+};
+
+class TextBlockInfo {
+public:
+ QPtrList<ParaInfo> m_paraList;
+ UMLObject * m_parent;
+ QString displayName;
+ bool isClickable;
+ bool isCodeAccessorMethod;
+
+ TextBlockInfo () { m_parent = 0; isClickable = false; isCodeAccessorMethod = false; }
+ void setParent(UMLObject *p = 0) { m_parent = p; }
+ UMLObject * getParent() { return m_parent; }
+
+};
+
+#endif // CODEEDITOR_H
diff --git a/umbrello/umbrello/dialogs/codegenerationoptionsbase.ui b/umbrello/umbrello/dialogs/codegenerationoptionsbase.ui
new file mode 100644
index 00000000..f0df1e17
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codegenerationoptionsbase.ui
@@ -0,0 +1,533 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>CodeGenerationOptionsBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>CodeGenerationOptionsBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>581</width>
+ <height>525</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>Code Generation Options</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QTabWidget" row="0" column="0">
+ <property name="name">
+ <cstring>tabWidget</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>General</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>m_SelectLanguageGroup</cstring>
+ </property>
+ <property name="title">
+ <string>Language</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>m_SelectLanguageBox</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>GroupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Folders</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Write all generated files to folder:</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="2">
+ <property name="name">
+ <cstring>m_browseOutput</cstring>
+ </property>
+ <property name="text">
+ <string>Bro&amp;wse...</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="3" column="2">
+ <property name="name">
+ <cstring>m_browseHeadings</cstring>
+ </property>
+ <property name="text">
+ <string>B&amp;rowse...</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>m_includeHeadings</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Include heading files from folder:</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>m_outputDir</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Files generated by Code Generator will be written to this folder</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="3" column="1">
+ <property name="name">
+ <cstring>m_headingsDir</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Files in this folder will be used as heading files in the generated code</string>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>Spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>30</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>Spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>30</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>m_overwriteGroup</cstring>
+ </property>
+ <property name="title">
+ <string>Overwrite Policy</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>If a file with the same name as the name code
+generator wants to use as output file already exists:</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>m_overwrite</cstring>
+ </property>
+ <property name="text">
+ <string>O&amp;verwrite</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Overwrite existing files if they exist in the destination folder</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>m_ask</cstring>
+ </property>
+ <property name="text">
+ <string>As&amp;k</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If a file with the same name already exists, ask what to do</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>m_changeName</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Use a different name</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If a file already exists in the destination folder, select a different name to use by adding a suffix to the file name</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </vbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Formatting</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout8</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBox5</cstring>
+ </property>
+ <property name="title">
+ <string>Lines</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="0" column="0">
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>30</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer3_2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>30</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer3_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>30</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="2" column="1">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Line ending style:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Indentation type:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="1" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Indentation amount:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="2" column="2" rowspan="1" colspan="3">
+ <item>
+ <property name="text">
+ <string>*NIX ("\n")</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Windows ("\r\n")</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Mac ("\r")</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>m_SelectEndLineCharsBox</cstring>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="0" column="3" rowspan="1" colspan="2">
+ <item>
+ <property name="text">
+ <string>No Indentation</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Tab</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Space</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>m_SelectIndentationTypeBox</cstring>
+ </property>
+ </widget>
+ <widget class="KIntNumInput" row="1" column="4">
+ <property name="name">
+ <cstring>m_SelectIndentationNumber</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>GroupBox3</cstring>
+ </property>
+ <property name="title">
+ <string>Comment Verbosity</string>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_forceSections</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>60</y>
+ <width>446</width>
+ <height>52</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Write comments &amp;for sections even if section
+is empty</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Writes comments to indicate the different sections (public, private etc) in a class, even if the sections are empty</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_forceDoc</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>11</x>
+ <y>29</y>
+ <width>446</width>
+ <height>28</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>&amp;Write documentation comments even if empty</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Write comments &amp;for class and method documentation even if empty</string>
+ </property>
+ </widget>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Language Options</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QFrame" row="0" column="0">
+ <property name="name">
+ <cstring>languageOptionsFrame</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Raised</enum>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>m_includeHeadings</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_browseHeadings</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>m_includeHeadings</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_headingsDir</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>m_browseOutput</sender>
+ <signal>clicked()</signal>
+ <receiver>CodeGenerationOptionsBase</receiver>
+ <slot>browseClicked()</slot>
+ </connection>
+ <connection>
+ <sender>m_browseHeadings</sender>
+ <signal>clicked()</signal>
+ <receiver>CodeGenerationOptionsBase</receiver>
+ <slot>browseClicked()</slot>
+ </connection>
+ <connection>
+ <sender>m_SelectLanguageBox</sender>
+ <signal>activated(int)</signal>
+ <receiver>CodeGenerationOptionsBase</receiver>
+ <slot>activeLanguageChanged(int)</slot>
+ </connection>
+</connections>
+<slots>
+ <slot access="protected">browseClicked()</slot>
+ <slot access="protected">activeLanguageChanged(int id)</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+</includehints>
+</UI>
diff --git a/umbrello/umbrello/dialogs/codegenerationoptionspage.cpp b/umbrello/umbrello/dialogs/codegenerationoptionspage.cpp
new file mode 100644
index 00000000..f3dc25be
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codegenerationoptionspage.cpp
@@ -0,0 +1,188 @@
+/***************************************************************************
+ begin : Thu Jul 25 2002
+ copyright : (C) 2002 by Luis De la Parra
+ email : luis@delaparra.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+// own header
+#include "codegenerationoptionspage.h"
+// qt/kde includes
+#include <qcheckbox.h>
+#include <kdebug.h>
+// app includes
+#include "../codegenerator.h"
+#include "codegenerationpolicypage.h"
+#include "../codegenerators/codegenpolicyext.h"
+#include "defaultcodegenpolicypage.h"
+#include "../model_utils.h"
+#include "../uml.h"
+
+//kde include
+#include <knuminput.h>
+#include <kfiledialog.h>
+#include <klocale.h>
+
+//qt include
+#include <qlineedit.h>
+#include <qlistview.h>
+#include <qbuttongroup.h>
+
+CodeGenerationOptionsPage::CodeGenerationOptionsPage(QWidget *parent)
+ : CodeGenerationOptionsBase(parent)
+{
+ init();
+}
+
+CodeGenerationOptionsPage::~CodeGenerationOptionsPage() { }
+
+void CodeGenerationOptionsPage::init()
+{
+ m_pCodePolicyPage = 0;
+
+ CodeGenerationPolicy *policy = UMLApp::app()->getCommonPolicy();
+ m_parentPolicy = policy;
+ CodeGenerator *gen = UMLApp::app()->getGenerator();
+
+ m_forceDoc->setChecked(policy->getCodeVerboseDocumentComments());
+ m_forceSections->setChecked(policy->getCodeVerboseSectionComments());
+
+ m_outputDir->setText(policy->getOutputDirectory().absPath());
+ m_includeHeadings->setChecked(policy->getIncludeHeadings());
+ m_headingsDir->setText(policy->getHeadingFileDir());
+ m_overwriteGroup->setButton(overwriteToInteger(policy->getOverwritePolicy()));
+
+ m_SelectEndLineCharsBox->setCurrentItem(newLineToInteger(policy->getLineEndingType()));
+ m_SelectIndentationTypeBox->setCurrentItem(indentTypeToInteger(policy->getIndentationType()));
+ m_SelectIndentationNumber->setValue(policy->getIndentationAmount());
+
+ connect(this,SIGNAL(syncCodeDocumentsToParent()),gen,SLOT(syncCodeToDocument()));
+
+ // now insert the language-dependant page, should there be one
+ updateCodeGenerationPolicyTab();
+
+ setupActiveLanguageBox();
+}
+
+void CodeGenerationOptionsPage::setupActiveLanguageBox()
+{
+ int indexCounter = 0;
+ while (indexCounter < Uml::pl_Reserved) {
+ QString language = Model_Utils::progLangToString((Uml::Programming_Language) indexCounter);
+ m_SelectLanguageBox->insertItem(language, indexCounter);
+ indexCounter++;
+ }
+ m_SelectLanguageBox->setCurrentItem(UMLApp::app()->getActiveLanguage());
+}
+
+int CodeGenerationOptionsPage::indentTypeToInteger(CodeGenerationPolicy::IndentationType value) {
+ switch (value) {
+ case CodeGenerationPolicy::SPACE:
+ return 2;
+ case CodeGenerationPolicy::TAB:
+ return 1;
+ default:
+ case CodeGenerationPolicy::NONE:
+ return 0;
+ }
+}
+
+int CodeGenerationOptionsPage::newLineToInteger(CodeGenerationPolicy::NewLineType value) {
+ switch (value) {
+ case CodeGenerationPolicy::DOS:
+ return 1;
+ case CodeGenerationPolicy::MAC:
+ return 2;
+ default:
+ case CodeGenerationPolicy::UNIX:
+ return 0;
+ }
+}
+
+//0 = overwrite, 1 = ask, 2 = change name
+int CodeGenerationOptionsPage::overwriteToInteger(CodeGenerationPolicy::OverwritePolicy value) {
+ switch (value) {
+ case CodeGenerationPolicy::Ok:
+ return 0;
+ case CodeGenerationPolicy::Never:
+ return 2;
+ default:
+ case CodeGenerationPolicy::Ask:
+ return 1;
+ }
+}
+
+void CodeGenerationOptionsPage::updateCodeGenerationPolicyTab() {
+
+ if(m_pCodePolicyPage)
+ {
+ m_pCodePolicyPage->disconnect();
+ m_pCodePolicyPage = 0;
+ }
+
+ CodeGenPolicyExt *policyExt = UMLApp::app()->getPolicyExt();
+ if (policyExt)
+ m_pCodePolicyPage = policyExt->createPage(languageOptionsFrame, "codelangpolicypage");
+ else
+ m_pCodePolicyPage = new DefaultCodeGenPolicyPage(languageOptionsFrame, "codelangpolicypage");
+
+ connect(this,SIGNAL(applyClicked()),m_pCodePolicyPage,SLOT(apply()));
+
+}
+
+void CodeGenerationOptionsPage::apply() {
+
+ if(m_parentPolicy) {
+
+ m_parentPolicy->setCodeVerboseDocumentComments(m_forceDoc->isChecked());
+ m_parentPolicy->setCodeVerboseSectionComments(m_forceSections->isChecked());
+ m_parentPolicy->setOutputDirectory(QDir(m_outputDir->text()));
+ m_parentPolicy->setIncludeHeadings(m_includeHeadings->isChecked());
+ m_parentPolicy->setHeadingFileDir(m_headingsDir->text());
+ m_parentPolicy->setOverwritePolicy((CodeGenerationPolicy::OverwritePolicy)m_overwriteGroup->id(m_overwriteGroup->selected()));
+ m_parentPolicy->setLineEndingType((CodeGenerationPolicy::NewLineType) m_SelectEndLineCharsBox->currentItem());
+ m_parentPolicy->setIndentationType((CodeGenerationPolicy::IndentationType) m_SelectIndentationTypeBox->currentItem());
+ m_parentPolicy->setIndentationAmount(m_SelectIndentationNumber->value());
+
+ // emit in THIS order.. the first signal triggers any sub-class to do its apply
+ // slot, THEN, once we are all updated, we may sync the parent generator's code
+ // documents
+ emit applyClicked();
+ emit syncCodeDocumentsToParent();
+ }
+}
+
+void CodeGenerationOptionsPage::activeLanguageChanged(int /*id*/)
+{
+ emit languageChanged();
+}
+
+void CodeGenerationOptionsPage::setDefaults() {
+}
+
+void CodeGenerationOptionsPage::browseClicked() {
+
+ QString button = sender()->name();
+ QString dir = KFileDialog::getExistingDirectory();
+ if(dir.isEmpty())
+ return;
+ if(button=="m_browseOutput")
+ m_outputDir->setText(dir);
+ else if(button=="m_browseHeadings")
+ m_headingsDir->setText(dir);
+}
+
+QString CodeGenerationOptionsPage::getCodeGenerationLanguage() {
+ return m_SelectLanguageBox->currentText();
+}
+
+#include "codegenerationoptionspage.moc"
diff --git a/umbrello/umbrello/dialogs/codegenerationoptionspage.h b/umbrello/umbrello/dialogs/codegenerationoptionspage.h
new file mode 100644
index 00000000..ff939d08
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codegenerationoptionspage.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ codegenerationoptionspage.h - description
+ -------------------
+ begin : Thu Jul 25 2002
+ copyright : (C) 2002 by Luis De la Parra
+ email : luis@delaparra.org
+ Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef CODEGENERATIONOPTIONSPAGE_H
+#define CODEGENERATIONOPTIONSPAGE_H
+
+#include <qwidget.h>
+#include "codegenerationoptionsbase.h"
+#include "../codegenerationpolicy.h"
+#include "../umlnamespace.h"
+
+/**
+ * @author Luis De la Parra
+ * @author Brian Thomas
+ */
+
+class CodeGenerationPolicy;
+class CodeGenerationPolicyPage;
+
+// 2003-07-30 : Updated for new code generation system. No longer need Yucky codegenstate
+// structure.
+
+class CodeGenerationOptionsPage : public CodeGenerationOptionsBase {
+ Q_OBJECT
+public:
+ CodeGenerationOptionsPage(QWidget *parent=0);
+ ~CodeGenerationOptionsPage();
+ void setDefaults();
+ QString getCodeGenerationLanguage();
+ void updateCodeGenerationPolicyTab();
+ void apply();
+
+protected:
+ CodeGenerationPolicy * m_parentPolicy;
+
+private:
+
+ CodeGenerationPolicyPage * m_pCodePolicyPage;
+ void init();
+ int overwriteToInteger(CodeGenerationPolicy::OverwritePolicy value);
+ int newLineToInteger(CodeGenerationPolicy::NewLineType value);
+ int indentTypeToInteger(CodeGenerationPolicy::IndentationType value);
+ void setupActiveLanguageBox();
+
+protected slots:
+ void activeLanguageChanged(int id);
+ void browseClicked();
+
+signals:
+ void applyClicked();
+ void languageChanged();
+ void syncCodeDocumentsToParent();
+
+
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/codegenerationpolicybase.ui b/umbrello/umbrello/dialogs/codegenerationpolicybase.ui
new file mode 100644
index 00000000..bbc739a7
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codegenerationpolicybase.ui
@@ -0,0 +1,39 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>CodeGenerationPolicyBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>CodeGenerationPolicyBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>519</width>
+ <height>515</height>
+ </rect>
+ </property>
+ <widget class="QFrame">
+ <property name="name">
+ <cstring>policyFrame</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>30</x>
+ <y>20</y>
+ <width>470</width>
+ <height>470</height>
+ </rect>
+ </property>
+ <property name="frameShape">
+ <enum>StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Raised</enum>
+ </property>
+ </widget>
+</widget>
+<slots>
+ <slot access="protected">apply()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/umbrello/umbrello/dialogs/codegenerationpolicypage.cpp b/umbrello/umbrello/dialogs/codegenerationpolicypage.cpp
new file mode 100644
index 00000000..8deb3387
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codegenerationpolicypage.cpp
@@ -0,0 +1,50 @@
+/***************************************************************************
+ begin : Tue Jul 29 2003
+ copyright : (C) 2003 by Brian Thomas
+ email : brian.thomas@gsfc.nasa.gov
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2004-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "codegenerationpolicypage.h"
+
+// qt/kde includes
+#include <qlabel.h>
+#include <klocale.h>
+
+// local includes
+#include "../codegenerationpolicy.h"
+
+
+/** This is the page which comes up IF there is no special options for the
+ * code generator.
+ */
+CodeGenerationPolicyPage::CodeGenerationPolicyPage( QWidget *parent, const char *name, CodeGenPolicyExt * policy )
+ :CodeGenerationPolicyBase(parent,name)
+{
+ m_parentPolicy = policy;
+}
+
+CodeGenerationPolicyPage::~CodeGenerationPolicyPage()
+{
+ this->disconnect();
+}
+
+void CodeGenerationPolicyPage::apply() {
+ // do nothing in vanilla version
+}
+
+void CodeGenerationPolicyPage::setDefaults() { }
+
+#include "codegenerationpolicypage.moc"
+
diff --git a/umbrello/umbrello/dialogs/codegenerationpolicypage.h b/umbrello/umbrello/dialogs/codegenerationpolicypage.h
new file mode 100644
index 00000000..16590dd3
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codegenerationpolicypage.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+ codegenerationpolicypage.h - description
+ -------------------
+ begin : Tue Jul 29 2003
+ copyright : (C) 2003 by Brian Thomas
+ email : brian.thomas@gsfc.nasa.gov
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2004-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef CODEGENERATIONPOLICYPAGE_H
+#define CODEGENERATIONPOLICYPAGE_H
+
+#include <qwidget.h>
+#include "codegenerationpolicybase.h"
+
+class CodeGenPolicyExt;
+
+/**
+ * @author Brian Thomas
+ */
+
+class CodeGenerationPolicyPage : public CodeGenerationPolicyBase {
+ Q_OBJECT
+public:
+ explicit CodeGenerationPolicyPage (QWidget *parent=0, const char *name=0, CodeGenPolicyExt * policy = 0);
+
+ virtual ~CodeGenerationPolicyPage();
+
+ void setDefaults();
+
+protected:
+
+ CodeGenPolicyExt * m_parentPolicy;
+
+private:
+
+public slots:
+
+ virtual void apply();
+
+
+};
+
+#endif
+
diff --git a/umbrello/umbrello/dialogs/codegenerationwizard.cpp b/umbrello/umbrello/dialogs/codegenerationwizard.cpp
new file mode 100644
index 00000000..ca726398
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codegenerationwizard.cpp
@@ -0,0 +1,258 @@
+/***************************************************************************
+ codegenerationwizard.cpp - description
+ -------------------
+ begin : Wed Jul 24 2002
+ copyright : (C) 2002 by Paul Hensgen
+ email : phensgen@users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "codegenerationwizard.h"
+
+// qt/kde includes
+#include <qdir.h>
+#include <qlistview.h>
+#include <qfileinfo.h>
+#include <qapplication.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+// local includes
+#include "codegenerationoptionspage.h"
+#include "../classifier.h"
+#include "../codegenerator.h"
+#include "../uml.h"
+#include "../umldoc.h"
+
+
+CodeGenerationWizard::CodeGenerationWizard(UMLClassifierList *classList)
+ : CodeGenerationWizardBase((QWidget*)UMLApp::app()) {
+ m_doc = UMLApp::app()->getDocument();
+ m_app = UMLApp::app();
+ m_availableList -> setAllColumnsShowFocus(true);
+ m_availableList -> setResizeMode(QListView::AllColumns);
+ m_selectedList -> setAllColumnsShowFocus(true);
+ m_selectedList -> setResizeMode(QListView::AllColumns);
+ m_statusList -> setAllColumnsShowFocus(true);
+ m_statusList -> setResizeMode(QListView::AllColumns);
+
+ m_CodeGenerationOptionsPage = new CodeGenerationOptionsPage(this);
+ connect( m_CodeGenerationOptionsPage, SIGNAL(languageChanged()), this, SLOT(changeLanguage()) );
+
+ insertPage(m_CodeGenerationOptionsPage, i18n("Code Generation Options"), 1);
+
+ UMLClassifierList cList;
+
+ if (classList == NULL) {
+ cList = m_doc->getClassesAndInterfaces();
+ classList = &cList;
+ }
+ for (UMLClassifier *c = classList->first(); c ; c = classList->next()) {
+ new QListViewItem( m_selectedList, c->getFullyQualifiedName());
+ }
+
+ setNextEnabled(page(0),m_selectedList->childCount() > 0);
+
+ setFinishEnabled(page(2),true);
+ finishButton()->disconnect();
+ finishButton()->setText(i18n("&Generate"));
+ connect(finishButton(),SIGNAL(clicked()),this,SLOT(generateCode()));
+ if ( QApplication::reverseLayout() )
+ {
+ QPixmap tmpPixmap( *m_addButton->pixmap() );
+ m_addButton->setPixmap(*m_removeButton->pixmap());
+ m_removeButton->setPixmap(tmpPixmap);
+ }
+}
+
+CodeGenerationWizard::~CodeGenerationWizard() {}
+
+
+void CodeGenerationWizard::selectClass() {
+ moveSelectedItems(m_availableList, m_selectedList);
+
+ if (m_selectedList->childCount() > 0) {
+ setNextEnabled(currentPage(), true);
+ }
+}
+
+void CodeGenerationWizard::deselectClass() {
+ moveSelectedItems(m_selectedList, m_availableList);
+
+ if (m_selectedList->childCount() == 0) {
+ setNextEnabled(currentPage(), false);
+ }
+}
+
+void CodeGenerationWizard::generateCode() {
+ backButton()->setEnabled(false);
+
+ CodeGenerator* codeGenerator = m_app->getGenerator();
+
+ if (codeGenerator) {
+
+ cancelButton()->setEnabled(false);
+
+ connect( codeGenerator, SIGNAL(codeGenerated(UMLClassifier*, bool)),
+ this, SLOT(classGenerated(UMLClassifier*, bool)) );
+
+ UMLClassifierList cList;
+ cList.setAutoDelete(false);
+
+ for(QListViewItem *item = m_statusList->firstChild(); item;
+ item = item-> nextSibling()) {
+ UMLClassifier *concept = m_doc->findUMLClassifier(item->text(0));
+ cList.append(concept);
+ }
+ codeGenerator->writeCodeToFile(cList);
+ finishButton()->setText(i18n("Finish"));
+ finishButton()->disconnect();
+ connect(finishButton(),SIGNAL(clicked()),this,SLOT(accept()));
+
+ }
+}
+
+void CodeGenerationWizard::classGenerated(UMLClassifier* concept, bool generated) {
+ QListViewItem* item = m_statusList->findItem( concept->getFullyQualifiedName(), 0 );
+ if( !item ) {
+ kError()<<"GenerationStatusPage::Error finding class in list view"<<endl;
+ } else if (generated) {
+ item->setText( 1, i18n("Code Generated") );
+ } else {
+ item->setText( 1, i18n("Not Generated") );
+ }
+}
+
+void CodeGenerationWizard::populateStatusList() {
+ m_statusList->clear();
+ for(QListViewItem* item = m_selectedList->firstChild(); item; item = item->nextSibling()) {
+ new QListViewItem(m_statusList,item->text(0),i18n("Not Yet Generated"));
+ }
+}
+
+void CodeGenerationWizard::showPage(QWidget *page) {
+ if (indexOf(page) == 2)
+ {
+ // first save the settings to the selected generator policy
+ ((CodeGenerationOptionsPage*)QWizard::page(1))->apply();
+
+ // before going on to the final page, check that the output directory exists and is
+ // writable
+
+ // get the policy for the current code generator
+ CodeGenerationPolicy *policy = UMLApp::app()->getCommonPolicy();
+
+ // get the output directory path
+ QFileInfo info(policy->getOutputDirectory().absPath());
+ if(!info.exists())
+ {
+ if (KMessageBox::questionYesNo(this,
+ i18n("The folder %1 does not exist. Do you want to create it now?").arg(info.filePath()),
+ i18n("Output Folder Does Not Exist"), i18n("Create Folder"), i18n("Do Not Create")) == KMessageBox::Yes)
+ {
+ QDir dir;
+ if(!dir.mkdir(info.filePath()))
+ {
+ KMessageBox::sorry(this,i18n("The folder could not be created.\nPlease make sure you have write access to its parent folder or select another, valid, folder."),
+ i18n("Error Creating Folder"));
+ return;
+ }
+ //else, directory created
+ }
+ else // do not create output directory
+ {
+ KMessageBox::information(this,i18n("Please select a valid folder."),
+ i18n("Output Folder Does Not Exist"));
+ return;
+ }
+ } else {
+ //directory exists.. make sure we can write to it
+ if(!info.isWritable())
+ {
+ KMessageBox::sorry(this,i18n("The output folder exists, but it is not writable.\nPlease set the appropriate permissions or choose another folder."),
+ i18n("Error Writing to Output Folder"));
+ return;
+ }
+ // it exits and we can write... make sure it is a directory
+ if(!info.isDir())
+ {
+ KMessageBox::sorry(this,i18n("%1 does not seem to be a folder. Please choose a valid folder.").arg(info.filePath()),
+ i18n("Please Choose Valid Folder"));
+ return;
+ }
+ }
+ }
+ populateStatusList();
+ QWizard::showPage(page);
+}
+
+CodeGenerator* CodeGenerationWizard::generator() {
+ // FIX
+ /*
+ KLibLoader* loader = KLibLoader::self();
+ if(!loader) {
+ kDebug()<<"error getting KLibLoader!"<<endl;
+ return 0;
+ }
+
+ KLibFactory* fact = loader->factory(info->library.latin1());
+ if(!fact) {
+ kDebug()<<"error getting the Factory"<<endl;
+ return 0;
+ }
+
+ QObject* o=fact->create(m_doc, 0, info->object.latin1());
+ if(!o) {
+ kDebug()<<"could not create object"<<endl;
+ return 0;
+ }
+
+ CodeGenerator* g = (CodeGenerator*)o;
+ // g->setDocument(m_doc);
+ return g;
+ */
+ return (CodeGenerator*) NULL;
+}
+
+void CodeGenerationWizard::moveSelectedItems(QListView* fromList, QListView* toList) {
+ QListViewItemIterator it(fromList, QListViewItemIterator::Selected);
+ while (it.current()) {
+ QListViewItem* selectedItem = it.current();
+
+ QString name = selectedItem->text(0);
+ if (!toList->findItem(name, 0)) {
+ new QListViewItem(toList, name);
+ }
+
+ ++it;
+
+ //Removed here because it can't (really, shouldn't) be removed while
+ //iterator is pointing to it
+ fromList->removeItem(selectedItem);
+ }
+}
+
+// when we change language, we need to update the codegenoptions page
+// language-dependent stuff. THe way to do this is to call its "apply" method.
+void CodeGenerationWizard::changeLanguage()
+{
+ m_app->setActiveLanguage( m_CodeGenerationOptionsPage->getCodeGenerationLanguage() );
+ /* @todo is this needed? if yes adapt to new scheme
+ m_CodeGenerationOptionsPage->setCodeGenerator(m_doc->getCurrentCodeGenerator());
+ */
+ m_CodeGenerationOptionsPage->apply();
+}
+
+#include "codegenerationwizard.moc"
diff --git a/umbrello/umbrello/dialogs/codegenerationwizard.h b/umbrello/umbrello/dialogs/codegenerationwizard.h
new file mode 100644
index 00000000..14d5f157
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codegenerationwizard.h
@@ -0,0 +1,88 @@
+/***************************************************************************
+ codegenerationwizard.h - description
+ -------------------
+ begin : Wed Jul 24 2002
+ copyright : (C) 2002 by Luis De la Parra
+ email : luis@delaparra.org
+ Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef CODEGENERATIONWIZARD_H
+#define CODEGENERATIONWIZARD_H
+
+#include <qwidget.h>
+#include <qptrlist.h>
+#include "codegenerationwizardbase.h"
+#include "settingsdlg.h"
+#include "../umlclassifierlist.h"
+
+class UMLApp;
+class UMLDoc;
+class CodeGenerator;
+class CodeGenerationOptionsPage;
+
+/**
+ * @author Luis De la Parra
+ * based on wizard from Paul Hensgen
+ */
+
+class CodeGenerationWizard : public CodeGenerationWizardBase {
+ Q_OBJECT
+public:
+ CodeGenerationWizard(UMLClassifierList *classList);
+ ~CodeGenerationWizard();
+
+ void showPage(QWidget *);
+
+ int exec() {
+ return QWizard::exec();
+ }
+protected slots:
+
+ /**
+ * Adds the classes selected in the available classes list to the
+ * list of classes used to generate the code.
+ */
+ void selectClass();
+
+ /**
+ * Removes the classes selected in the selected classes list from the
+ * list of classes used to generate the code.
+ */
+ void deselectClass();
+ void populateStatusList();
+ void generateCode();
+ void classGenerated(UMLClassifier* concept, bool generated);
+
+private slots:
+ void changeLanguage();
+
+
+private:
+ CodeGenerator* generator();
+
+ /**
+ * Moves the selected items from first list to second list.
+ * The selected items are removed from the first list and added to the
+ * second. An item is added to the second list only if it isn't already
+ * there (no duplicated items are created).
+ */
+ void moveSelectedItems(QListView* fromList, QListView* toList);
+
+ UMLApp* m_app;
+ UMLDoc* m_doc;
+ CodeGenerationOptionsPage* m_CodeGenerationOptionsPage;
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/codegenerationwizardbase.ui b/umbrello/umbrello/dialogs/codegenerationwizardbase.ui
new file mode 100644
index 00000000..732aa0c7
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codegenerationwizardbase.ui
@@ -0,0 +1,309 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>CodeGenerationWizardBase</class>
+<widget class="QWizard">
+ <property name="name">
+ <cstring>CodeGenerationWizardBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>396</width>
+ <height>386</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Code Generation Wizard</string>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>select</cstring>
+ </property>
+ <attribute name="title">
+ <string>Select Classes</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>10</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Place all the classes you want to generate code
+for in the right hand side list</string>
+ </property>
+ </widget>
+ <widget class="QFrame">
+ <property name="name">
+ <cstring>Frame4</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="margin">
+ <number>10</number>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>20</number>
+ </property>
+ <property name="spacing">
+ <number>10</number>
+ </property>
+ <widget class="QPushButton" row="1" column="1">
+ <property name="name">
+ <cstring>m_addButton</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image0</pixmap>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Add class for code generation</string>
+ </property>
+ </widget>
+ <spacer row="0" column="1">
+ <property name="name" stdset="0">
+ <cstring>Spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QListView" row="0" column="2" rowspan="5" colspan="1">
+ <column>
+ <property name="text">
+ <string>Classes Selected</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_selectedList</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="selectionMode">
+ <enum>Extended</enum>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="3" column="1">
+ <property name="name">
+ <cstring>m_removeButton</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image1</pixmap>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Remove class from Code Generation</string>
+ </property>
+ </widget>
+ <spacer row="2" column="1">
+ <property name="name" stdset="0">
+ <cstring>Spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QListView" row="0" column="0" rowspan="5" colspan="1">
+ <column>
+ <property name="text">
+ <string>Classes Available</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_availableList</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="selectionMode">
+ <enum>Extended</enum>
+ </property>
+ </widget>
+ <spacer row="4" column="1">
+ <property name="name" stdset="0">
+ <cstring>Spacer1_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>status</cstring>
+ </property>
+ <attribute name="title">
+ <string>Code Generation Status</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>10</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>m_label</cstring>
+ </property>
+ <property name="text">
+ <string>Press the Generation button to start the code generation</string>
+ </property>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>GroupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>Generation Status</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>20</number>
+ </property>
+ <property name="spacing">
+ <number>10</number>
+ </property>
+ <widget class="QListView">
+ <column>
+ <property name="text">
+ <string>Class</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Generation Status</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_statusList</cstring>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </vbox>
+ </widget>
+</widget>
+<images>
+ <image name="image0">
+ <data format="XPM.GZ" length="915">789c65d1c96ec2301006e03b4f61c10d5580431262553db0158ad4aac74a550f633bec5b21a4d0aaefdecc8c1395605ffc79fe71e2a459176fafcfa2deac1c1348164698391c44dd9e369bcbfbc7c34fa52a432103d18e84acde55aa0d61c4cb6e1be35a67eb5aabe5b7420f592b08c8d8d1670231ca3941ca28b091463e21bd5628958f1c1355a8988f050d72e4689903645b762473e81800f5f689aaa3983d47cbec227d1949a0de8b63c0fc2642a4986764e04556536fca5492f955d022132228c53c395ae611197a109800792042ce9d63ccdc233bed8cd4fb49d43a64ae1d81b9ca69a977838cda39e74ce33117449d917ee814a97c13c721724b3406b8ba44826f3daece88c6424c55eb18330d52fb391b386ad0c847bea7b386f21e98a981726e365fe4c922b75cad372e59e4b6bbfd6ecfc922f7793866939245ee909c70eaffb9244dbfd234bdca9d2fdfd9bc3eafdbed757ba5e7f607c341f9fd1e47e39b7b3c4d6eee7bf55d7eef2b7f4698d01d</data>
+ </image>
+ <image name="image1">
+ <data format="XPM.GZ" length="915">789c65d1c76e83401006e0bb9f62656e56147b316056510eee454a9463a428872db81b775ca2bc7b9899c502c21cd86fe71f6abdc63e3fde58ad5e399ee469a1999ecb03ab99f36673fbfa7efda95479c0b8cf9a21e3d5a74af59969f6be8d235847e9da6934bc46e002e58312a82c3da2830c338e813cf44da88013a0db08b8f08003a4080471f4a0060e2d0db10b6cf21627f62c7d89b37da4680962dbd2103b408f875ce2ecd5d227de903214c43bd07743a37036210a4ebc3c688067a4148278b234c4033070a5af7de01e29336e2d23620c6c3553e2ec11a954405c594ae232a3c1d935306c669c13b54b9c21554afca153a0f0741405c01d526b49dd0d507ac6a5ee02a98d8cb0ab2d23a2012a2fe3b33d1c49e7dc9e4a674a7b8e991aa7b8a7f46cbe28e61cb35cad37859cd2f1368e77f99c63f687b48ef95c743a43ed0bb9e49224c9e55cbcdef596d6bd74df76a7dde9949fafdbebf6ffbdc760382ae5d2e47852cee5becbef4be50f94aacd35</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>m_addButton</sender>
+ <signal>clicked()</signal>
+ <receiver>CodeGenerationWizardBase</receiver>
+ <slot>selectClass()</slot>
+ </connection>
+ <connection>
+ <sender>m_removeButton</sender>
+ <signal>clicked()</signal>
+ <receiver>CodeGenerationWizardBase</receiver>
+ <slot>deselectClass()</slot>
+ </connection>
+</connections>
+<forwards>
+ <forward>class UMLClassifier</forward>
+</forwards>
+<slots>
+ <slot>selectClass()</slot>
+ <slot access="protected">deselectClass()</slot>
+ <slot>classGenerated( UMLClassifier * /* c */ )</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/umbrello/umbrello/dialogs/codeviewerdialog.cpp b/umbrello/umbrello/dialogs/codeviewerdialog.cpp
new file mode 100644
index 00000000..5672e576
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codeviewerdialog.cpp
@@ -0,0 +1,122 @@
+/***************************************************************************
+ begin : Fri Aug 1 2003
+ copyright : (C) 2003 by Brian Thomas
+ email : brian.thomas@gsfc.nasa.gov
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2004-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "codeviewerdialog.h"
+
+// qt/kde includes
+#include <qlayout.h>
+#include <qtabwidget.h>
+#include <qcheckbox.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+// local includes
+#include "../codedocument.h"
+#include "../classifiercodedocument.h"
+#include "codeeditor.h"
+
+CodeViewerDialog::CodeViewerDialog ( QWidget* parent, CodeDocument * doc,
+ Settings::CodeViewerState state,
+ const char* name, bool modal, WFlags fl )
+ : CodeViewerDialogBase ( parent, name, modal, fl )
+
+{
+ m_state = state;
+
+ initGUI(name);
+
+ addCodeDocument(doc);
+
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+CodeViewerDialog::~CodeViewerDialog()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+void CodeViewerDialog::initGUI ( const char * name) {
+
+ if ( !name )
+ setName( "CodeViewerDialog" );
+
+ setFont( getState().font );
+
+ // set some viewability parameters
+ int margin = fontMetrics().height();
+ int width = fontMetrics().maxWidth() * getState().width;
+ int height = fontMetrics().lineSpacing() * getState().height;
+
+ m_highlightCheckBox->setChecked( getState().blocksAreHighlighted );
+ m_showHiddenCodeCB->setChecked ( getState().showHiddenBlocks );
+
+ CodeViewerDialogBaseLayout->setMargin(margin);
+
+ resize( QSize(width, height).expandedTo(minimumSizeHint()) );
+
+}
+
+/*
+ * Adds a code document to the tabbed output
+ */
+void CodeViewerDialog::addCodeDocument( CodeDocument * doc)
+{
+ CodeEditor * page = new CodeEditor ( this, "_codedocumenteditor_", doc );
+ QString fname = doc->getFileName();
+ QString ext = doc->getFileExtension();
+ m_tabWidget->insertTab(page, (fname + (ext.isEmpty()? "" : ext)));
+
+ connect( m_highlightCheckBox, SIGNAL( stateChanged(int) ), page, SLOT( changeHighlighting(int) ) );
+ connect( m_showHiddenCodeCB, SIGNAL( stateChanged(int) ), page, SLOT( changeShowHidden(int) ) );
+
+}
+
+Settings::CodeViewerState CodeViewerDialog::getState() {
+ return m_state;
+}
+
+bool CodeViewerDialog::close ( bool alsoDelete )
+{
+
+ // remember widget size for next time
+ m_state.height = height() / fontMetrics().lineSpacing();
+ m_state.width = width() / fontMetrics().maxWidth();
+
+ // remember block highlighting
+ m_state.blocksAreHighlighted = m_highlightCheckBox->isChecked();
+
+ // remember block show status
+ m_state.showHiddenBlocks = m_showHiddenCodeCB->isChecked();
+
+ // run superclass close now
+ return CodeViewerDialogBase::close(alsoDelete);
+
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void CodeViewerDialog::languageChange()
+{
+ setCaption( tr2i18n( "Code Viewer" ) );
+}
+
+#include "codeviewerdialog.moc"
diff --git a/umbrello/umbrello/dialogs/codeviewerdialog.h b/umbrello/umbrello/dialogs/codeviewerdialog.h
new file mode 100644
index 00000000..7315384f
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codeviewerdialog.h
@@ -0,0 +1,80 @@
+
+/***************************************************************************
+ codeviewerdialog.h - description
+ -------------------
+ begin : Fri Aug 1 2003
+ copyright : (C) 2003 by Brian Thomas
+ email : brian.thomas@gsfc.nasa.gov
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef CODEVIEWERDIALOG_H
+#define CODEVIEWERDIALOG_H
+
+#include <qcolor.h>
+#include <qmap.h>
+#include <qptrlist.h>
+#include <qstring.h>
+#include <qtextedit.h>
+#include "../codeviewerstate.h"
+#include "codeviewerdialogbase.h"
+
+class CodeDocument;
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QFrame;
+
+class UMLObject;
+
+/** This class is sooo ugly I don't know where to begin. For now, its a prototype
+ * that works, and thats all we need. In the future, a re-write is mandated to
+ * bring a bit of beauty to this beast. -b.t.
+ */
+class CodeViewerDialog : public CodeViewerDialogBase
+{
+ Q_OBJECT
+public:
+
+ CodeViewerDialog ( QWidget* parent, CodeDocument * doc, Settings::CodeViewerState state,
+ const char* name = 0, bool modal = false, WFlags fl = 0 );
+ ~CodeViewerDialog ();
+
+ /** return the code viewer state */
+ Settings::CodeViewerState getState( );
+
+ QString parentDocName;
+
+ /**
+ * Adds a code document to the tabbed output
+ */
+ void addCodeDocument( CodeDocument * doc);
+
+protected:
+
+ bool close ( bool alsoDelete );
+
+private:
+
+ Settings::CodeViewerState m_state;
+
+ void initGUI ( const char * name );
+
+public slots:
+
+protected slots:
+
+ virtual void languageChange();
+
+};
+
+
+#endif // CODEVIEWERDIALOG_H
diff --git a/umbrello/umbrello/dialogs/codeviewerdialogbase.ui b/umbrello/umbrello/dialogs/codeviewerdialogbase.ui
new file mode 100644
index 00000000..672aefdb
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codeviewerdialogbase.ui
@@ -0,0 +1,113 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>CodeViewerDialogBase</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>CodeViewerDialogBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>615</width>
+ <height>728</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <family>Courier</family>
+ </font>
+ </property>
+ <property name="caption">
+ <string>Code Viewer</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="0" column="1">
+ <property name="name">
+ <cstring>m_showHiddenCodeCB</cstring>
+ </property>
+ <property name="text">
+ <string>Show hidden blocks</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>componentLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;p align="center"&gt;component name here&lt;/p&gt;</string>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="2">
+ <property name="name">
+ <cstring>m_exitButton</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>m_highlightCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>Show block type</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QTabWidget" row="1" column="0">
+ <property name="name">
+ <cstring>m_tabWidget</cstring>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>m_exitButton</sender>
+ <signal>released()</signal>
+ <receiver>CodeViewerDialogBase</receiver>
+ <slot>close()</slot>
+ </connection>
+</connections>
+<slots>
+ <slot>changeHighlighting(int)</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/umbrello/umbrello/dialogs/codevieweroptionsbase.ui b/umbrello/umbrello/dialogs/codevieweroptionsbase.ui
new file mode 100644
index 00000000..99fd198d
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codevieweroptionsbase.ui
@@ -0,0 +1,369 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>CodeViewerOptionsBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>CodeViewerOptionsBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>486</width>
+ <height>545</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KFontChooser" row="0" column="0">
+ <property name="name">
+ <cstring>fontChooser</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>colorGroupBox</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Colors</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>colorLayout</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="2">
+ <property name="name">
+ <cstring>fontLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Font:</string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="0" column="5">
+ <property name="name">
+ <cstring>selectColorButton</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="color">
+ <color>
+ <red>255</red>
+ <green>255</green>
+ <blue>127</blue>
+ </color>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>paperLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Paper:</string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="0" column="1">
+ <property name="name">
+ <cstring>paperColorButton</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="color">
+ <color>
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="4">
+ <property name="name">
+ <cstring>selectedLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Selected:</string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="0" column="3">
+ <property name="name">
+ <cstring>fontColorButton</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="color">
+ <color>
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KColorButton" row="1" column="3">
+ <property name="name">
+ <cstring>nonEditBlockColorButton</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="color">
+ <color>
+ <red>213</red>
+ <green>213</green>
+ <blue>213</blue>
+ </color>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="0" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KColorButton" row="0" column="3">
+ <property name="name">
+ <cstring>m_hiddenBlockColorButton</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="color">
+ <color>
+ <red>166</red>
+ <green>254</green>
+ <blue>248</blue>
+ </color>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="0" column="1">
+ <property name="name">
+ <cstring>umlObjectColorButton</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="color">
+ <color>
+ <red>255</red>
+ <green>170</green>
+ <blue>255</blue>
+ </color>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;p align="right"&gt;UML object block:&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="2">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;p align="right"&gt;Hidden block:&lt;/p&gt;</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLabel" row="1" column="2">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;p align="right"&gt;Uneditable text:&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="1" column="1">
+ <property name="name">
+ <cstring>editBlockColorButton</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="color">
+ <color>
+ <red>255</red>
+ <green>170</green>
+ <blue>255</blue>
+ </color>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;p align="right"&gt;Editable text:&lt;/p&gt;</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>KFontChooser</class>
+ <header location="global">kfontdialog.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="XPM.GZ" length="4462">789c9d97c76e24490e86effd1442f3d65870d2451a0ce6206f5adeb4cc620f8c34f2553225b5a4c1befb46927fe6a1d4c0ccac4287fa8a0c26834193f5dbb785b3fd9d856fbf7d799ec9ecba5ea8afe469e15bf3727ffffeeffffcf1e797af49b2d0ffc7d142f2f55f5fbe1ecc16ea85dde9a4ed81290045faa77ca49cf4ab67ba1e3953969173651ab9d4fdf1c8a27c3872ad7c3c72d3b32c2a67c3f3444636fbef23eb7e590267e68fcc4656395d8dacf6d938ef97eaef289781cddebdb2846fccff44b989ba58e3411f3dc75158e6df1d3889539517ca49bf54fe43398d1dec4f46567f685fd9c539f43fc025f80c1c3ce8d93f28e77185f8bf0c6cfae4c0b5f9c3c6e5c0542a4b5876fe13708df39d2bd7716372aa8c93c4e4723bb2f977aadc26ceec4bdb7310e6b0bfab9c2445ecd49f1370694cebca65d260ffa6711a41aef14d24e94cee6be3348e0ae5e9c8765f07ca3e8db17f0f9c825794eb3489351fe9bb7217e4969f29388bd51ee9fda5715a19730696b852fea95c6471647ca95cf64bcf43e0cef4657b647bfe6acf213d6bb32f9a9f5992b5a64f9a8f990b6cf9ecc15d6cf9acf6b2da55a8a75cb973dee4b2d1b38b5c05de02434e87e01aacfb351df5bebddea74b5c67f9c795711ea15e357e2ecde358fb87efc0a867df8cac728a074e62e527706afb59f3cf6583be5c28bb3c35f693812d1fbdc6dbe57966fec932d899ffa4f7e38adca17e34beaeca4b9c271a18f1d5fc739257b0d70d9c68be7bed7fcee7827ab91cd8e4740cf6b19d4ffb87ab07b9bf516e72d4a3ac821b9cef6e60d84f47367ded2fae1d9f7704f6163f79000ffde27660f387ed3c5dbf54dfeebb0bf6acbe6b706bfa5ef32f8f8b18f5bf0f463f20edb77956a4e68fbc80b3c4facd163847be6bfde72ec86dbeac82715fbc0286be683cf3bc081d44f7df80d344fb0b6b7de64581fb916765297263d6fccd9b7ee97e566e8b06cfdb1f59cf2bda2f8bbc2c11df0c5c41aefdb328ca22b1feb0012eedbce24736f91b18fb796d64eb87cb60817dcdafb07d906bfd14d22f659d8785ef97b2f6d7b2df6ef1d6fb2babaac6f92e8c25b27ecc1f239b7f3a5fca5a8678ea7c2d9bc0e6ef1238b3fca2c7814d5f4cbf9334b5f833384bed3c7a5f5514f4adbe2ec07962e7590457f06f6f649b977afe2a16f42f5e070bfc591e18f7a5f1a812a9e0df39d827da4fbd8c6ccfd7785569bf945f953371a9d5a3de67950bfa2d75c63eb2fb15bdcfaaf011e6c7263846bf8f4636f91618f3c7d3c0f047fb69550efab2074e12bd6fd27957553ec33c5b043bcc7f9d0795f818fdb501a3df8ae673e507ff69021eea37063bc45ffb73550736ff36c0a84f3e0317a86f8b5f139e6ffe1f821de6d9127898ff3be00a7c3ab2cd03e3d697560ff40016e47b3bb2e96bbd559d8f32bbff4b7065f193042c98873acf240af6adbf3c83c5f2954bb0c7bcd77c107d81d2fdebc63e33ff640aaecc9e1c8151df5c803dfaadc64b52dfa03ed64636ffb4ff4b2867f453ede7227586fcd3f9264ded91fffafe236d5da37fe83c91ceb7b9e5b7f6731ff92ed7f747d6fbf7e185cf58347e3e6932e47b3430fa893edf87d795c2fc3f003b67f5f902cec17abfde0dfa3c053b3c5ffb832fc2eb8fddcf233887fc195c801f46b6f3cdc02558fba72f7d2d1a7f7e321ee58fe0cad86bbff24dd3e2fe74fef836b0c6eb60d62fa6bf5e07b3419f853dd7dc70fb8bd5f1255fd90ed30f9f3c5ff30ddff21ddff384a7fcc08ffcc4cf61cdf8855ff9e79c7e1db4dff89d3f7891977899577895d7789d377893b7f83b6fcfe937bc13b477798ff7f9800ff928ac633ee11f7cca6761d7f99c7e1b3cb908da11c7413be1943376e153cc39175c72f549ff9e17c31744429e6a6aa8a58e2ee98aaee9866e7f617fc24b7417a4f734a1293dd0233dd133cd8285177aa5f9f3b63ca5377aa78f607b919668995682e62aadd17ab0b1419b9ff41f682b48bed336edd02eed05ed7d5ea3033a0cdf1ed1f127fd273ae123fa41a774a6b685cee982228a837e42e927fd47caf8985c38651eb40b2ac38e4a5842658a97fab33fd248cb87d2c9a55cc9b5dcc82d1fc99ddccb44a6f230af2f8ff224cf417f262ff22a3fe54ddee543166549966545567f617f4dd66523dc6b2c9bb225df655b7682f692ecca9eeccfe97772c09b722847722c27c1f3eb70f66bf9116c9fca999ccbc59cfe25bf4a143a5ef8992561324a78bd92522acf9ebc78efe7cf7b153276db37bef59dbff457fedadff85b7f27abfede4ffcd4cf9ff76faeff4fffefeff8c7f5fedfdfbffc0fa355c495</data>
+ </image>
+</images>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kcolorbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/umbrello/umbrello/dialogs/codevieweroptionspage.cpp b/umbrello/umbrello/dialogs/codevieweroptionspage.cpp
new file mode 100644
index 00000000..dd120569
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codevieweroptionspage.cpp
@@ -0,0 +1,70 @@
+/***************************************************************************
+ codegenerationoptionspage.cpp - description
+ -------------------
+ begin : Thu Jul 25 2002
+ copyright : (C) 2002 by Luis De la Parra
+ email : luis@delaparra.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "codevieweroptionspage.h"
+
+// qt/kde includes
+#include <kdebug.h>
+#include <kfontdialog.h>
+#include <kcolorbutton.h>
+
+
+CodeViewerOptionsPage::CodeViewerOptionsPage( Settings::CodeViewerState options, QWidget *parent, const char *name )
+ :CodeViewerOptionsBase(parent,name)
+{
+ init (options);
+}
+
+CodeViewerOptionsPage::~CodeViewerOptionsPage() { }
+
+void CodeViewerOptionsPage::init( Settings::CodeViewerState options )
+{
+ m_options = options;
+
+ // set widget stuff
+ /*
+ fontChooser->setFont( options.font );
+ selectColorButton -> setColor (options.selectedColor);
+ fontColorButton -> setColor (options.fontColor);
+ paperColorButton -> setColor (options.paperColor);
+ editBlockColorButton -> setColor (options.editBlockColor);
+ nonEditBlockColorButton -> setColor (options.nonEditBlockColor);
+ umlObjectColorButton -> setColor (options.umlObjectColor);
+ */
+}
+
+void CodeViewerOptionsPage::apply() {
+ /*
+ m_options.umlObjectColor = umlObjectColorButton->color();
+ m_options.editBlockColor = editBlockColorButton->color();
+ m_options.nonEditBlockColor = nonEditBlockColorButton->color();
+ m_options.selectedColor = selectColorButton->color();
+ m_options.paperColor = paperColorButton->color();
+ m_options.fontColor = fontColorButton->color();
+ m_options.font = fontChooser->font();
+ */
+ emit applyClicked();
+}
+
+Settings::CodeViewerState CodeViewerOptionsPage::getOptions() {
+ return m_options;
+}
+
+#include "codevieweroptionspage.moc"
diff --git a/umbrello/umbrello/dialogs/codevieweroptionspage.h b/umbrello/umbrello/dialogs/codevieweroptionspage.h
new file mode 100644
index 00000000..ec01f170
--- /dev/null
+++ b/umbrello/umbrello/dialogs/codevieweroptionspage.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ codegenerationoptionspage.h - description
+ -------------------
+ begin : Thu Jul 25 2002
+ copyright : (C) 2002 by Luis De la Parra
+ email : luis@delaparra.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef CODEVIEWEROPTIONSPAGE_H
+#define CODEVIEWEROPTIONSPAGE_H
+
+#include <qwidget.h>
+#include "codevieweroptionsbase.h"
+#include "../codeviewerstate.h"
+
+/**
+ * @author Brian Thomas
+ */
+
+class CodeViewerOptionsPage : public CodeViewerOptionsBase {
+ Q_OBJECT
+public:
+ CodeViewerOptionsPage (Settings::CodeViewerState options, QWidget *parent, const char *name=0);
+ ~CodeViewerOptionsPage();
+
+ Settings::CodeViewerState getOptions();
+ void apply();
+
+protected:
+
+private:
+
+ Settings::CodeViewerState m_options;
+ void init ( Settings::CodeViewerState options);
+
+protected slots:
+
+signals:
+ void applyClicked();
+
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/defaultcodegenpolicypage.cpp b/umbrello/umbrello/dialogs/defaultcodegenpolicypage.cpp
new file mode 100644
index 00000000..668d732d
--- /dev/null
+++ b/umbrello/umbrello/dialogs/defaultcodegenpolicypage.cpp
@@ -0,0 +1,41 @@
+
+/***************************************************************************
+ codegenerationpolicypage.cpp - description
+ -------------------
+ begin : Tue Jul 29 2003
+ copyright : (C) 2003 by Brian Thomas
+ email : brian.thomas@gsfc.nasa.gov
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2004-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "defaultcodegenpolicypage.h"
+
+// qt/kde includes
+#include <qlabel.h>
+#include <klocale.h>
+
+
+/** This is the page which comes up IF there is no special options for the
+ * code generator.
+ */
+DefaultCodeGenPolicyPage::DefaultCodeGenPolicyPage ( QWidget *parent, const char *name, CodeGenPolicyExt * policy )
+ :CodeGenerationPolicyPage(parent,name,policy)
+{
+ textLabel = new QLabel(parent,"textLabel");
+ textLabel->setText(tr2i18n("<p align=\"center\">No Options Available.</p>"));
+}
+
+DefaultCodeGenPolicyPage::~DefaultCodeGenPolicyPage() { }
+
+#include "defaultcodegenpolicypage.moc"
diff --git a/umbrello/umbrello/dialogs/defaultcodegenpolicypage.h b/umbrello/umbrello/dialogs/defaultcodegenpolicypage.h
new file mode 100644
index 00000000..c3d36332
--- /dev/null
+++ b/umbrello/umbrello/dialogs/defaultcodegenpolicypage.h
@@ -0,0 +1,42 @@
+
+/****************************************************************************
+** Form interface generated from reading ui file 'Defaultcodegenpolicypage.ui'
+**
+** Created: Fri Aug 1 12:47:23 2003
+** by: The User Interface Compiler ($Id$)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#ifndef DEFAULTCODEGENPOLICYPAGE_H
+#define DEFAULTCODEGENPOLICYPAGE_H
+
+#include <qvariant.h>
+#include <qwidget.h>
+#include "codegenerationpolicypage.h"
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QLabel;
+class CodeGenePolicyExt;
+
+class DefaultCodeGenPolicyPage : public CodeGenerationPolicyPage
+{
+ Q_OBJECT
+
+public:
+
+ explicit DefaultCodeGenPolicyPage( QWidget* parent = 0, const char* name = 0, CodeGenPolicyExt * policy =0);
+
+ ~DefaultCodeGenPolicyPage();
+
+ QLabel* textLabel;
+
+protected:
+
+protected slots:
+
+};
+
+#endif // DEFAULTCODEGENPOLICYPAGE_H
diff --git a/umbrello/umbrello/dialogs/diagramprintpage.cpp b/umbrello/umbrello/dialogs/diagramprintpage.cpp
new file mode 100644
index 00000000..cf366197
--- /dev/null
+++ b/umbrello/umbrello/dialogs/diagramprintpage.cpp
@@ -0,0 +1,225 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "diagramprintpage.h"
+
+// qt/kde includes
+#include <qlayout.h>
+#include <qptrlist.h>
+#include <qlistbox.h>
+#include <qradiobutton.h>
+#include <qcombobox.h>
+#include <qbuttongroup.h>
+#include <qgroupbox.h>
+#include <klocale.h>
+
+// local includes
+#include "../uml.h"
+#include "../umldoc.h"
+#include "../umlview.h"
+#include "../umlviewlist.h"
+#include "../umlnamespace.h"
+
+
+DiagramPrintPage::DiagramPrintPage(QWidget * parent, UMLDoc * m_pDoc) : KPrintDialogPage(parent), m_pDoc(m_pDoc) {
+ int margin = fontMetrics().height();
+ setTitle(i18n("&Diagrams"));
+ QHBoxLayout * mainLayout = new QHBoxLayout(this);
+ mainLayout -> setSpacing(10);
+ mainLayout -> setMargin(margin);
+
+ m_pFilterBG = new QButtonGroup(i18n("Filter"), this);
+ mainLayout -> addWidget(m_pFilterBG);
+ m_pFilterBG -> setExclusive(true);
+
+ QVBoxLayout * filter = new QVBoxLayout(m_pFilterBG);
+ filter -> setSpacing(10);
+ filter-> setMargin(margin);
+
+ m_pCurrentRB = new QRadioButton(i18n("&Current diagram"), m_pFilterBG);
+ filter -> addWidget(m_pCurrentRB);
+ m_pCurrentRB -> setChecked(true);
+ m_pFilterBG -> insert(m_pCurrentRB, Current);
+
+ m_pAllRB = new QRadioButton(i18n("&All diagrams"), m_pFilterBG);
+ filter -> addWidget(m_pAllRB);
+ m_pFilterBG -> insert(m_pAllRB, All);
+
+ m_pSelectRB = new QRadioButton(i18n("&Select diagrams"), m_pFilterBG);
+ filter -> addWidget(m_pSelectRB);
+ m_pFilterBG -> insert(m_pSelectRB, Select);
+
+ m_pTypeRB = new QRadioButton(i18n("&Type of diagram"), m_pFilterBG);
+ filter -> addWidget(m_pTypeRB);
+ m_pFilterBG -> insert(m_pTypeRB, Type);
+
+ m_pSelectGB = new QGroupBox(i18n("Selection"), this);
+ mainLayout -> addWidget(m_pSelectGB);
+
+ QVBoxLayout * select = new QVBoxLayout(m_pSelectGB);
+ select -> setSpacing(10);
+ select-> setMargin(margin);
+
+ m_pTypeCB = new QComboBox(m_pSelectGB);
+ select -> addWidget(m_pTypeCB);
+ m_pTypeCB -> setEnabled(false);
+
+ m_pSelectLB = new QListBox(m_pSelectGB);
+ select -> addWidget(m_pSelectLB);
+ m_pSelectLB -> setEnabled(false);
+ m_pSelectLB -> setSelectionMode(QListBox::Multi);
+ m_pSelectLB -> insertItem(UMLApp::app()->getCurrentView()->getName());
+ m_pSelectLB -> setSelected(0, true);
+ m_nIdList.clear();
+ m_nIdList.append(UMLApp::app()->getCurrentView()->getID());
+
+
+
+ m_ViewType = Uml::dt_Class;
+ connect(m_pFilterBG, SIGNAL(clicked(int)), this, SLOT(slotClicked(int)));
+ connect(m_pTypeCB, SIGNAL(activated(const QString&)), this, SLOT(slotActivated(const QString&)));
+
+ m_pTypeCB -> insertItem(i18n("Class"));
+ m_pTypeCB -> insertItem(i18n("Use Case"));
+ m_pTypeCB -> insertItem(i18n("Collaboration"));
+ m_pTypeCB -> insertItem(i18n("Sequence"));
+ m_pTypeCB -> insertItem(i18n("State"));
+ m_pTypeCB -> insertItem(i18n("Activity"));
+ m_pTypeCB -> insertItem(i18n("Component"));
+ m_pTypeCB -> insertItem(i18n("Deployment"));
+}
+
+DiagramPrintPage::~DiagramPrintPage()
+{
+ disconnect(m_pFilterBG, SIGNAL(clicked(int)), this, SLOT(slotClicked(int)));
+ disconnect(m_pTypeCB, SIGNAL(activated(const QString&)), this, SLOT(slotActivated(const QString&)));
+}
+
+void DiagramPrintPage::getOptions( QMap<QString,QString>& opts, bool /*incldef = false*/ ) {
+ int listCount = m_pSelectLB -> count();
+ int count = 0;
+
+ QString diagram(i18n("kde-uml-Diagram"));
+ for(int i=0;i<listCount;i++) {
+ if(m_pSelectLB -> isSelected(i)) {
+ UMLView *view = (UMLView *)m_pDoc -> findView(m_nIdList[i]);
+ QString sCount = QString("%1").arg(count);
+ QString sID = QString("%1").arg(ID2STR(view -> getID()));
+ opts.insert(diagram + sCount, sID);
+ count++;
+ }
+ }
+ opts.insert("kde-uml-count", QString("%1").arg(count));
+}
+
+void DiagramPrintPage::setOptions( const QMap<QString,QString>& /*opts*/ ) {}
+
+bool DiagramPrintPage::isValid( QString& msg ) {
+ int listCount = m_pSelectLB -> count();
+ bool sel = false;
+ for(int i =0;i<listCount;i++) {
+ if(m_pSelectLB -> isSelected(i)) {
+ sel = true;
+ i = listCount;
+ }
+ }
+ msg = i18n("No diagrams selected.");
+ return sel;
+}
+
+void DiagramPrintPage::slotClicked(int id) {
+ UMLViewList list = m_pDoc -> getViewIterator();
+ UMLView * view = 0;
+ QString type;
+
+ // clear list with diagrams to print
+ m_nIdList.clear();
+
+ switch(id) {
+ case Current:
+ m_pTypeCB -> setEnabled(false);
+ m_pSelectLB -> setEnabled(false);
+ m_pSelectLB -> clear();
+ m_pSelectLB -> insertItem(UMLApp::app()->getCurrentView()->getName());
+ m_pSelectLB -> setSelected(0, true);
+ m_nIdList.append(UMLApp::app()->getCurrentView()->getID());
+ break;
+
+ case All:
+
+ m_pTypeCB -> setEnabled(false);
+ m_pSelectLB -> setEnabled(false);
+ m_pSelectLB -> clear();
+ for(view = list.first(); view; view = list.next()) {
+ m_pSelectLB -> insertItem(view -> getName());
+ m_nIdList.append(view -> getID());
+ }
+ m_pSelectLB -> selectAll(true);
+ break;
+
+ case Select:
+ m_pTypeCB -> setEnabled(false);
+ m_pSelectLB -> setEnabled(true);
+ m_pSelectLB -> clear();
+ for(view = list.first(); view; view = list.next()) {
+ m_pSelectLB -> insertItem(view -> getName());
+ m_nIdList.append(view -> getID());
+ }
+ break;
+
+ case Type:
+ m_pTypeCB -> setEnabled(true);
+ m_pSelectLB -> setEnabled(true);
+ m_pSelectLB -> clear();
+ for(view = list.first(); view; view = list.next()) {
+ if(view -> getType() == m_ViewType) {
+ m_pSelectLB -> insertItem(view -> getName());
+ m_nIdList.append(view -> getID());
+ }
+ }
+ m_pSelectLB -> selectAll(true);
+ break;
+ }
+}
+
+void DiagramPrintPage::slotActivated(const QString & text) {
+ UMLViewList list = m_pDoc -> getViewIterator();
+ UMLView * view = 0;
+
+ if(text == i18n("Class"))
+ m_ViewType = Uml::dt_Class;
+ else if(text == i18n("Sequence"))
+ m_ViewType = Uml::dt_Sequence;
+ else if(text == i18n("Use Case"))
+ m_ViewType = Uml::dt_UseCase;
+ else if(text == i18n("Collaboration"))
+ m_ViewType = Uml::dt_Collaboration;
+ else if(text == i18n("State"))
+ m_ViewType = Uml::dt_State;
+ else if(text == i18n("Activity"))
+ m_ViewType = Uml::dt_Activity;
+ else if(text == i18n("Component"))
+ m_ViewType = Uml::dt_Component;
+ else if(text == i18n("Deployment"))
+ m_ViewType = Uml::dt_Deployment;
+ m_pSelectLB -> clear();
+ m_nIdList.clear();
+ for(view = list.first(); view; view = list.next()) {
+ if(view -> getType() == m_ViewType) {
+ m_pSelectLB -> insertItem(view -> getName());
+ m_nIdList.append(view -> getID());
+ }
+ }
+ m_pSelectLB -> selectAll(true);
+}
+
+#include "diagramprintpage.moc"
diff --git a/umbrello/umbrello/dialogs/diagramprintpage.h b/umbrello/umbrello/dialogs/diagramprintpage.h
new file mode 100644
index 00000000..f2184a27
--- /dev/null
+++ b/umbrello/umbrello/dialogs/diagramprintpage.h
@@ -0,0 +1,101 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef DIAGRAMPRINTPAGE_H
+#define DIAGRAMPRINTPAGE_H
+
+class QListBox;
+class QRadioButton;
+class QComboBox;
+class QButtonGroup;
+class QGroupBox;
+
+#include <kdeprint/kprintdialogpage.h>
+
+#include "../umldoc.h"
+#include "../umlview.h"
+/**
+ * This is a page on the print dialog to select what diagram(s)
+ * you wish to print. You add it to the @ref KPrinter instance.
+ *
+ * You will then need to get the options as shown in @ref KPrinter.
+ *
+ * @short A print dialog page.
+ * @author Paul Hensgen <phensgen@techie.com>
+ * @see KPrinter
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+
+class DiagramPrintPage : public KPrintDialogPage {
+ Q_OBJECT
+public:
+ /**
+ * Constructs the diagram print page.
+ *
+ * @param parent The parent to the page.
+ * @param doc The @ref UMLDoc class instance being used.
+ */
+ DiagramPrintPage(QWidget * parent, UMLDoc *doc);
+
+ /**
+ * Stnadard deconstructor.
+ */
+ ~DiagramPrintPage();
+
+ /**
+ * Overriden method. It builds a list with the diagram name and the diagram
+ * IDs.
+ */
+ void getOptions(QMap<QString,QString>& opts, bool /* incldef=false */);
+
+ /**
+ * Overriden method.
+ */
+ void setOptions( const QMap<QString,QString>& /*opts*/ );
+
+ /**
+ * Overriden method.
+ */
+ bool isValid( QString& msg );
+
+private:
+ QButtonGroup * m_pFilterBG;
+ QGroupBox * m_pSelectGB;
+ QListBox * m_pSelectLB;
+ QRadioButton * m_pAllRB, * m_pCurrentRB, * m_pSelectRB, * m_pTypeRB;
+ QComboBox * m_pTypeCB;
+
+ UMLDoc * m_pDoc;
+ Uml::Diagram_Type m_ViewType;
+
+ /**
+ * list containing the IDs of diagrams to print
+ */
+ QValueList<Uml::IDType> m_nIdList;
+
+ enum FilterType{Current = 0, All, Select, Type};
+public slots:
+
+ /**
+ * Gets called when the users chooses to print all diagrams, the current
+ * diagram, a selection of diagrams or diagrams by type. It will change the
+ * listed diagrams in the diagram box.
+ */
+ void slotClicked(int id);
+
+ /**
+ * Gets called when the user chooses another diagram type. Only diagrams of
+ * this type will be shown in the diagram box.
+ */
+ void slotActivated(const QString & text);
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/diagrampropertiespage.ui b/umbrello/umbrello/dialogs/diagrampropertiespage.ui
new file mode 100644
index 00000000..8a8d2826
--- /dev/null
+++ b/umbrello/umbrello/dialogs/diagrampropertiespage.ui
@@ -0,0 +1,410 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>DiagramPropertiesPage</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>DiagramPropertiesPage</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>388</width>
+ <height>388</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>GroupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Diagram Properties</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>diagramName</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout20</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>Zoom:</string>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>zoom</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maxValue">
+ <number>500</number>
+ </property>
+ <property name="minValue">
+ <number>10</number>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>%</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>50</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>showOpSigs</cstring>
+ </property>
+ <property name="text">
+ <string>Show operation signature</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>Line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>showGrid</cstring>
+ </property>
+ <property name="text">
+ <string>Show &amp;grid</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>snapToGrid</cstring>
+ </property>
+ <property name="text">
+ <string>Snap &amp;to grid</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>snapComponentSizeToGrid</cstring>
+ </property>
+ <property name="text">
+ <string>Snap component size</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Snap the size of the components to be a multiple of the grid spacing.
+If 'Snap to Grid' is enabled a component will always be aligned with the grid on all 4 sides.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout8</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Grid spacing: </string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabelX</cstring>
+ </property>
+ <property name="text">
+ <string>X</string>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>gridSpaceX</cstring>
+ </property>
+ <property name="maxValue">
+ <number>100</number>
+ </property>
+ <property name="minValue">
+ <number>5</number>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Y</string>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>gridSpaceY</cstring>
+ </property>
+ <property name="maxValue">
+ <number>100</number>
+ </property>
+ <property name="minValue">
+ <number>5</number>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout10</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabe15</cstring>
+ </property>
+ <property name="text">
+ <string>Line width: </string>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>lineWidth</cstring>
+ </property>
+ <property name="maxValue">
+ <number>10</number>
+ </property>
+ <property name="minValue">
+ <number>0</number>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>GroupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>Documentation</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QTextEdit" row="0" column="0">
+ <property name="name">
+ <cstring>documentation</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/umbrello/umbrello/dialogs/exportallviewsdialog.cpp b/umbrello/umbrello/dialogs/exportallviewsdialog.cpp
new file mode 100644
index 00000000..9f47afa5
--- /dev/null
+++ b/umbrello/umbrello/dialogs/exportallviewsdialog.cpp
@@ -0,0 +1,55 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2006-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "exportallviewsdialog.h"
+
+// include files for Qt
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qtooltip.h>
+
+// kde include files
+#include <kfilefiltercombo.h>
+#include <klocale.h>
+
+// application specific includes
+#include "../umlviewimageexportermodel.h"
+
+ExportAllViewsDialog::ExportAllViewsDialog(
+ QWidget* parent /* = 0 */,
+ const char* name /* = 0 */,
+ bool modal /* = false */,
+ WFlags fl /* = 0*/,
+ const QString &defaultMimeType /*= "image/png"*/)
+ : ExportAllViewsDialogBase(parent,name, modal,fl) {
+ // create and initialize m_imageType
+ m_imageType = new KFileFilterCombo(this, "m_imageType");
+ m_imageType->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed, 0, 0, m_imageType->sizePolicy().hasHeightForWidth()));
+ m_imageType->setEditable(false);
+
+ m_imageType->setMimeFilter(UMLViewImageExporterModel::supportedMimeTypes(), defaultMimeType);
+
+ imageTypeLayout->addWidget(m_imageType);
+
+ imageTypeLabel->setBuddy(m_imageType);
+
+ // reload the strings so the m_imageType tooltip is added
+ languageChange();
+}
+
+void ExportAllViewsDialog::languageChange() {
+ ExportAllViewsDialogBase::languageChange();
+ QToolTip::add(m_imageType, tr2i18n("The format that the images will be exported to"));
+}
+
+#include "exportallviewsdialog.moc"
+
diff --git a/umbrello/umbrello/dialogs/exportallviewsdialog.h b/umbrello/umbrello/dialogs/exportallviewsdialog.h
new file mode 100644
index 00000000..37b0a2f3
--- /dev/null
+++ b/umbrello/umbrello/dialogs/exportallviewsdialog.h
@@ -0,0 +1,72 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2006-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef EXPORTALLVIEWSDIALOG_H
+#define EXPORTALLVIEWSDIALOG_H
+
+// application specific includes
+#include "exportallviewsdialogbase.h"
+
+// KDE forward declarations
+class KFileFilterCombo;
+
+/**
+ * Dialog for collecting the "Export all views" params.
+ * Inherits ExportAllViewsDialogBase and adds a KFileFilterCombo that uses
+ * only the mime types of the supported images types.
+ *
+ * The KFileFilterCombo is declared here instead of in the .ui file because QT
+ * Designer and uic don't recognize it.
+ */
+class ExportAllViewsDialog : public ExportAllViewsDialogBase {
+ Q_OBJECT
+
+public:
+
+ /**
+ * Constructor for UMLViewImageExporterModel.
+ *
+ * @param parent The parent of the dialog.
+ * @param name The internal name.
+ * @param modal If modal is true the dialog will block input to other the windows
+ * in the application until it's closed.
+ * @param fl Window flags.
+ * @param defaultMimeType The default mime type that appears in the mime types list.
+ *
+ * @see QDialog::QDialog
+ */
+ explicit ExportAllViewsDialog(QWidget* parent = 0, const char* name = 0,
+ bool modal = false, WFlags fl = 0,
+ const QString& defaultMimeType = "image/png");
+
+ /**
+ * Destructor for UMLViewImageExporterModel.
+ */
+ ~ExportAllViewsDialog() {
+ }
+
+ /**
+ * The image type selected.
+ */
+ KFileFilterCombo* m_imageType;
+
+protected slots:
+
+ /**
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+ virtual void languageChange();
+
+};
+
+#endif
+
diff --git a/umbrello/umbrello/dialogs/exportallviewsdialogbase.ui b/umbrello/umbrello/dialogs/exportallviewsdialogbase.ui
new file mode 100644
index 00000000..c82820a3
--- /dev/null
+++ b/umbrello/umbrello/dialogs/exportallviewsdialogbase.ui
@@ -0,0 +1,216 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>ExportAllViewsDialogBase</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>ExportAllViewsDialogBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>366</width>
+ <height>197</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Export all views</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>mainLayout</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="spacing">
+ <number>15</number>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>kURLRequesterLayout</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>kURLRequesterLabel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Directory to save the diagrams in:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>m_kURL</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>The base directory used to save the images</string>
+ </property>
+ </widget>
+ <widget class="KURLRequester">
+ <property name="name">
+ <cstring>m_kURL</cstring>
+ </property>
+ <property name="mode">
+ <number>2</number>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>The base directory used to save the images</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>imageTypeLayout</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>imageTypeLabel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Image type:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>m_imageType</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>The format that the images will be exported to</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_useFolders</cstring>
+ </property>
+ <property name="text">
+ <string>Use &amp;folders</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Create in the target directory the same tree structure used
+in the document to store the views</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The views are stored in folders in the document. The same tree structure used in the document to store the views can be created in the selected base directory with this option.
+Only the folders made by the user are created in the base directory (Logical view, use case view and so on aren't created).</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>buttonsLayout</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Horizontal Spacing2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonOk</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>ExportAllViewsDialogBase</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>ExportAllViewsDialogBase</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/umbrello/umbrello/dialogs/notedialog.cpp b/umbrello/umbrello/dialogs/notedialog.cpp
new file mode 100644
index 00000000..f310990d
--- /dev/null
+++ b/umbrello/umbrello/dialogs/notedialog.cpp
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "notedialog.h"
+
+// qt/kde includes
+#include <qlineedit.h>
+#include <qgroupbox.h>
+#include <qtextedit.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+
+NoteDialog::NoteDialog( QWidget * parent, NoteWidget * pNote ) : KDialogBase(Plain, i18n("Note Documentation"), Help | Ok | Cancel , Ok, parent, "_NOTEDIALOG_", true, true) {
+ m_pNoteWidget = pNote;
+ int margin = fontMetrics().height();
+
+ m_pDocGB = new QGroupBox(i18n("Documentation"), plainPage());
+ QVBoxLayout * mainLayout = new QVBoxLayout(plainPage());
+ mainLayout -> addWidget(m_pDocGB);
+ mainLayout -> setSpacing(10);
+ mainLayout -> setMargin(margin);
+
+ QHBoxLayout * docLayout = new QHBoxLayout(m_pDocGB);
+ docLayout -> setSpacing(10);
+ docLayout -> setMargin(margin);
+
+ m_pDocTE = new QTextEdit( m_pDocGB );
+ m_pDocTE -> setFocus();
+ docLayout -> addWidget( m_pDocTE );
+ m_pDocTE -> setText( pNote -> getDoc() );
+ setMinimumSize(330, 160);
+}
+
+NoteDialog::~NoteDialog() {}
+
+void NoteDialog::slotOk() {
+ m_pNoteWidget -> setDoc( m_pDocTE -> text() );
+ accept();
+}
+
+#include "notedialog.moc"
diff --git a/umbrello/umbrello/dialogs/notedialog.h b/umbrello/umbrello/dialogs/notedialog.h
new file mode 100644
index 00000000..3efd1404
--- /dev/null
+++ b/umbrello/umbrello/dialogs/notedialog.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef NOTEDIALOG_H
+#define NOTEDIALOG_H
+//kde includes
+#include <kdialogbase.h>
+//app includes
+#include "../notewidget.h"
+
+/**
+ * @author Paul Hensgen
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class QGroupBox;
+class QLineEdit;
+class QTextEdit;
+
+class NoteDialog : public KDialogBase {
+
+ Q_OBJECT
+
+public:
+ /**
+ * Constructs an NoteDialog.
+ */
+ NoteDialog( QWidget * parent, NoteWidget * pNote );
+
+ /**
+ * Standard deconstructor.
+ */
+ ~NoteDialog();
+
+public slots:
+ void slotOk();
+private:
+ //GUI widgets
+ QGroupBox * m_pDocGB;
+ QTextEdit * m_pDocTE;
+
+ /**
+ * Note widget to show documentation for.
+ */
+ NoteWidget * m_pNoteWidget;
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/overwritedialogue.cpp b/umbrello/umbrello/dialogs/overwritedialogue.cpp
new file mode 100644
index 00000000..b7c4a4f4
--- /dev/null
+++ b/umbrello/umbrello/dialogs/overwritedialogue.cpp
@@ -0,0 +1,62 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "overwritedialogue.h"
+
+// qt/kde includes
+#include <qcheckbox.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+
+OverwriteDialogue::OverwriteDialogue(
+ const QString& fileName,
+ const QString& outputDirectory,
+ bool applyToAllRemaining, QWidget* parent, const char* name) :
+KDialogBase(Plain, i18n("Destination File Already Exists"), Ok|Apply|Cancel, Yes, parent, name) {
+
+ QVBoxLayout* layout = new QVBoxLayout( plainPage(), 0, spacingHint() );
+
+ QLabel* dialogueLabel = new QLabel(i18n("The file %1 already exists in %2.\n\nUmbrello can overwrite the file, generate a similar\nfile name or not generate this file.").arg(fileName).arg(outputDirectory), plainPage() );
+ layout->addWidget(dialogueLabel);
+
+ m_applyToAllRemaining = new QCheckBox( i18n("&Apply to all remaining files"), plainPage() );
+ m_applyToAllRemaining->setChecked(applyToAllRemaining);
+ layout->addWidget(m_applyToAllRemaining);
+
+ setButtonText(KDialogBase::Ok, i18n("&Overwrite"));
+ setButtonText(KDialogBase::Apply, i18n("&Generate Similar File Name"));
+ setButtonText(KDialogBase::Cancel, i18n("&Do Not Generate File"));
+}
+
+OverwriteDialogue::~OverwriteDialogue() {
+}
+
+void OverwriteDialogue::slotOk() {
+ done(Yes);
+}
+
+void OverwriteDialogue::slotApply() {
+ done(No);
+}
+
+void OverwriteDialogue::slotCancel() {
+ done(Cancel);
+}
+
+bool OverwriteDialogue::applyToAllRemaining() {
+ return m_applyToAllRemaining->isChecked();
+}
+
+#include "overwritedialogue.moc"
diff --git a/umbrello/umbrello/dialogs/overwritedialogue.h b/umbrello/umbrello/dialogs/overwritedialogue.h
new file mode 100644
index 00000000..a01e3366
--- /dev/null
+++ b/umbrello/umbrello/dialogs/overwritedialogue.h
@@ -0,0 +1,72 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef OVERWRITEDIALOGUE_H
+#define OVERWRITEDIALOGUE_H
+
+#include <kdialogbase.h>
+
+class QCheckBox;
+
+/**
+ * Used by CodeGenerator::findFileName when it needs to ask
+ * the user if they want to overwrite and existing file, generate a similar name
+ * or cancel. Gives an option to apply the choice to all remaining files.
+ *
+ * Uses OK and Apply buttons but overrides their text and behaviour, probably
+ * better to use user defined buttons but I couldn't work out how. KDialogBase guru needed.
+ *
+ * @author Jonathan Riddell <jr@jriddell.org>
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class OverwriteDialogue: public KDialogBase {
+ Q_OBJECT
+
+public:
+ /**
+ * constructor sets up the dialog, adding checkbox and label
+ */
+ OverwriteDialogue(const QString& fileName, const QString& outputDirectory,
+ bool applyToAllRemaining, QWidget* parent=0, const char* name=0);
+
+ /**
+ * destrictor doesn't do anything
+ */
+ ~OverwriteDialogue();
+
+ /**
+ * @return the value of the Apply To All Remaining Files checkbox
+ */
+ bool applyToAllRemaining();
+
+protected slots:
+ /**
+ * Overrides standard operation to call QDialog::done(Yes).
+ * This is a kludge, see note in class description.
+ */
+ virtual void slotOk();
+
+ /**
+ * Overrides standard operation to call QDialog::done(No).
+ */
+ virtual void slotApply();
+
+
+ /**
+ * Overrides standard operation to call QDialog::done(Cancel).
+ */
+ virtual void slotCancel();
+
+private:
+ QCheckBox* m_applyToAllRemaining;
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/parmpropdlg.cpp b/umbrello/umbrello/dialogs/parmpropdlg.cpp
new file mode 100644
index 00000000..e8ddc245
--- /dev/null
+++ b/umbrello/umbrello/dialogs/parmpropdlg.cpp
@@ -0,0 +1,257 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "parmpropdlg.h"
+
+// qt includes
+#include <qlayout.h>
+#include <qtooltip.h>
+
+// kde includes
+#include <klocale.h>
+#include <kdebug.h>
+
+// local includes
+#include "../classifier.h"
+#include "../umltemplatelist.h"
+#include "../template.h"
+#include "../umldoc.h"
+#include "../dialog_utils.h"
+#include "../object_factory.h"
+#include "../stereotype.h"
+
+#include "parmpropdlg.moc"
+
+ParmPropDlg::ParmPropDlg(QWidget * parent, UMLDoc * doc, UMLAttribute * a)
+ : KDialogBase(Plain, i18n("Parameter Properties"), Help | Ok | Cancel , Ok, parent, "_PARMPROPDLG_", true, true)
+{
+ m_pUmldoc = doc;
+ m_pAtt = a;
+ QString type, text, name, initialValue;
+ if(!a) {
+ type = text = name = initialValue = "";
+ } else {
+ type = a -> getTypeName();
+ name = a -> getName();
+ initialValue = a -> getInitialValue();
+ text = a -> getDoc();
+ }
+ int margin = fontMetrics().height();
+ setMinimumSize(300, 400);
+ //disableResize();
+ QVBoxLayout * topLayout = new QVBoxLayout(plainPage());
+ topLayout -> setSpacing(10);
+ topLayout -> setMargin(margin);
+
+ m_pParmGB = new QGroupBox(i18n("Properties"), plainPage());
+ topLayout -> addWidget(m_pParmGB);
+
+ QGridLayout * propLayout = new QGridLayout(m_pParmGB, 4, 2);
+ propLayout -> setSpacing(10);
+ propLayout -> setMargin(margin);
+
+ m_pTypeL = new QLabel(i18n("&Type:"), m_pParmGB);
+ propLayout -> addWidget(m_pTypeL, 0, 0);
+
+ m_pTypeCB = new KComboBox(m_pParmGB);
+ propLayout -> addWidget(m_pTypeCB, 0, 1);
+ m_pTypeL->setBuddy(m_pTypeCB);
+
+ Dialog_Utils::makeLabeledEditField( m_pParmGB, propLayout, 1,
+ m_pNameL, i18n("&Name:"),
+ m_pNameLE, name );
+
+ Dialog_Utils::makeLabeledEditField( m_pParmGB, propLayout, 2,
+ m_pInitialL, i18n("&Initial value:"),
+ m_pInitialLE, initialValue );
+
+ m_pStereoTypeL = new QLabel( i18n("Stereotype name:"), m_pParmGB );
+ propLayout -> addWidget(m_pStereoTypeL, 3, 0);
+ m_pStereoTypeCB = new KComboBox(true, m_pParmGB );
+ propLayout -> addWidget(m_pStereoTypeCB, 3, 1);
+
+ m_pKind = new QButtonGroup(i18n("Passing Direction"), plainPage());
+ m_pKind->setExclusive(true);
+ QToolTip::add(m_pKind, i18n("\"in\" is a readonly parameter, \"out\" is a writeonly parameter and \"inout\" is a parameter for reading and writing."));
+
+ QHBoxLayout * kindLayout = new QHBoxLayout( m_pKind );
+ kindLayout->setMargin(margin);
+
+ m_pIn = new QRadioButton( "in", m_pKind );
+ kindLayout->addWidget( m_pIn );
+
+ m_pInOut = new QRadioButton( "inout", m_pKind );
+ kindLayout->addWidget( m_pInOut );
+
+ m_pOut = new QRadioButton( "out", m_pKind );
+ kindLayout->addWidget( m_pOut );
+
+ topLayout -> addWidget(m_pKind);
+
+ m_pDocGB = new QGroupBox(i18n("Documentation"), plainPage());
+ QHBoxLayout * docLayout = new QHBoxLayout(m_pDocGB);
+ docLayout -> setMargin(margin);
+
+ m_pDoc = new QMultiLineEdit(m_pDocGB);
+ ///////////
+ m_pDoc->setWordWrap(QMultiLineEdit::WidgetWidth);
+ //////////
+ m_pDoc -> setText(text);
+ docLayout -> addWidget(m_pDoc);
+ topLayout -> addWidget(m_pDocGB);
+
+ // Check the proper Kind radiobutton.
+ if (a) {
+ Uml::Parameter_Direction kind = a->getParmKind();
+ if (kind == Uml::pd_Out)
+ m_pOut->setChecked(true);
+ else if (kind == Uml::pd_InOut)
+ m_pInOut->setChecked(true);
+ else
+ m_pIn->setChecked(true);
+ } else
+ m_pIn->setChecked(true);
+
+ m_pTypeCB->setDuplicatesEnabled(false);//only allow one of each type in box
+ m_pTypeCB->setEditable(true);
+ m_pTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
+// m_pTypeCB->setAutoCompletion(false);
+
+ //add template parameters
+ UMLClassifier *pConcept = dynamic_cast<UMLClassifier*>( m_pAtt->parent()->parent() );
+ if (pConcept == NULL) {
+ kError() << "ParmPropDlg: grandparent of " << m_pAtt->getName()
+ << " is not a UMLClassifier" << endl;
+ } else {
+ UMLTemplateList tmplParams( pConcept->getTemplateList() );
+ for (UMLTemplate *t = tmplParams.first(); t; t = tmplParams.next())
+ insertType( t->getName() );
+ }
+ //now add the Concepts
+ UMLClassifierList namesList( m_pUmldoc->getConcepts() );
+ UMLClassifier * obj;
+ for(obj=namesList.first(); obj!=0 ;obj=namesList.next()) {
+ insertType( obj->getFullyQualifiedName() );
+ }
+
+ //work out which one to select
+ int typeBoxCount = 0;
+ bool foundType = false;
+ while (typeBoxCount < m_pTypeCB->count() && foundType == false) {
+ QString typeBoxString = m_pTypeCB->text(typeBoxCount);
+ if ( typeBoxString == type ) { //getTypeName()
+ foundType = true;
+ m_pTypeCB->setCurrentItem(typeBoxCount);
+ } else {
+ typeBoxCount++;
+ }
+ }
+
+ if (!foundType) {
+ insertType( type, 0 );
+ m_pTypeCB->setCurrentItem(0);
+ }
+
+ // manage stereotypes
+ m_pStereoTypeCB->setDuplicatesEnabled(false); //only allow one of each type in box
+ m_pStereoTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
+ insertStereotype (QString("")); // an empty stereotype is the default
+ int defaultStereotype=0;
+ bool foundDefaultStereotype = false;
+ for (UMLStereotypeListIt it(m_pUmldoc->getStereotypes()); it.current(); ++it) {
+ if (!foundDefaultStereotype) {
+ if ( m_pAtt->getStereotype() == it.current()->getName()) {
+ foundDefaultStereotype = true;
+ }
+ defaultStereotype++;
+ }
+ insertStereotype (it.current()->getName());
+ }
+ // lookup for a default stereotype, if the operation doesn't have one
+ if (foundDefaultStereotype)
+ m_pStereoTypeCB->setCurrentItem(defaultStereotype);
+ else
+ m_pStereoTypeCB->setCurrentItem(-1);
+
+ // set tab order
+ setTabOrder(m_pKind, m_pTypeCB);
+ setTabOrder(m_pTypeCB, m_pNameLE);
+ setTabOrder(m_pNameLE, m_pInitialLE);
+ setTabOrder(m_pInitialLE, m_pStereoTypeCB);
+ setTabOrder(m_pStereoTypeCB, m_pIn);
+ setTabOrder(m_pIn, m_pDoc);
+
+ m_pNameLE->setFocus();
+}
+
+void ParmPropDlg::insertType( const QString& type, int index )
+{
+ m_pTypeCB->insertItem( type, index );
+ m_pTypeCB->completionObject()->addItem( type );
+}
+
+void ParmPropDlg::insertStereotype( const QString& type, int index )
+{
+ m_pStereoTypeCB->insertItem( type, index );
+ m_pStereoTypeCB->completionObject()->addItem( type );
+}
+
+Uml::Parameter_Direction ParmPropDlg::getParmKind() {
+ Uml::Parameter_Direction pk = Uml::pd_In;
+ if (m_pOut->isChecked())
+ pk = Uml::pd_Out;
+ else if (m_pInOut->isChecked())
+ pk = Uml::pd_InOut;
+ return pk;
+}
+
+void ParmPropDlg::slotOk() {
+ if (m_pAtt != NULL) {
+ m_pAtt->setParmKind( getParmKind() );
+ m_pAtt->setStereotype( m_pStereoTypeCB->currentText() );
+ QString typeName = m_pTypeCB->currentText();
+ UMLClassifier * pConcept = dynamic_cast<UMLClassifier*>( m_pAtt->parent()->parent() );
+ if (pConcept == NULL) {
+ kError() << "ParmPropDlg::slotOk: grandparent of " << m_pAtt->getName()
+ << " is not a UMLClassifier" << endl;
+ } else {
+ UMLTemplate *tmplParam = pConcept->findTemplate(typeName);
+ if (tmplParam) {
+ m_pAtt->setType(tmplParam);
+ accept();
+ return;
+ }
+ }
+ UMLClassifierList namesList( m_pUmldoc->getConcepts() );
+ UMLClassifier * obj;
+ for (obj = namesList.first(); obj; obj = namesList.next()) {
+ if (obj->getFullyQualifiedName() == typeName) {
+ m_pAtt->setType( obj );
+ break;
+ }
+ }
+ if (obj == NULL) {
+ // Nothing found: Create a new type on the fly.
+ // @todo There should be an extra dialog to decide whether to
+ // create a datatype or a class. For now, we create a class.
+ kDebug() << "ParmPropDlg::slotOk: " << typeName << " not found."
+ << " Creating a new class for the type." << endl;
+ UMLObject *o = Object_Factory::createUMLObject(Uml::ot_Class, typeName);
+ m_pAtt->setType(o);
+ }
+
+ }
+ accept();
+}
+
+ParmPropDlg::~ParmPropDlg() {}
+
diff --git a/umbrello/umbrello/dialogs/parmpropdlg.h b/umbrello/umbrello/dialogs/parmpropdlg.h
new file mode 100644
index 00000000..25a6153a
--- /dev/null
+++ b/umbrello/umbrello/dialogs/parmpropdlg.h
@@ -0,0 +1,125 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef PARMPROPDLG_H
+#define PARMPROPDLG_H
+
+#include <kdialogbase.h>
+#include <kcombobox.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qradiobutton.h>
+#include <qlineedit.h>
+#include <qbuttongroup.h>
+#include <qmultilineedit.h>
+#include <qcombobox.h>
+#include "../attribute.h"
+
+class UMLDoc;
+
+/**
+ * Displays a dialog box that displays properties of a paramater.
+ * You need to make sure that @ref UMLDoc is made to be the
+ * parent.
+ *
+ * @short A properties dialog box for a parameter.
+ * @author Paul Hensgen <phensgen@techie.com>
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class ParmPropDlg : public KDialogBase {
+ Q_OBJECT
+public:
+ /**
+ * Constructs a ParmPropDlg.
+ *
+ * @param parent The parent of the dialog.
+ * @param a The parameter to represent.
+ */
+ ParmPropDlg(QWidget * parent, UMLDoc * doc, UMLAttribute * a);
+
+ /**
+ * Standard deconstructor.
+ */
+ ~ParmPropDlg();
+
+ /**
+ * Returns the documentation.
+ *
+ * @return Returns the documentation.
+ */
+ QString getDoc() {
+ return m_pDoc -> text();
+ }
+
+ /**
+ * Return the name of the parameter.
+ *
+ * @return Return the name of the parameter.
+ */
+ QString getName() {
+ return m_pNameLE -> text();
+ }
+
+ /**
+ * Return the initial value of the parameter.
+ *
+ * @return Return the initial value of the parameter.
+ */
+ QString getInitialValue() {
+ return m_pInitialLE -> text();
+ }
+
+ /**
+ * Return the type name of the parameter.
+ *
+ * @return Return the type name of the parameter.
+ */
+ QString getTypeName() {
+ return m_pTypeCB -> currentText();
+ }
+
+ /**
+ * Return the kind of the parameter (in, out, or inout).
+ *
+ * @return The Uml::Parameter_Direction corresponding to
+ * the selected "Kind" radiobutton.
+ */
+ Uml::Parameter_Direction getParmKind();
+
+public slots:
+ void slotOk();
+
+protected:
+ /**
+ * Inserts @p type into the type-combobox as well as its completion object.
+ */
+ void insertType( const QString& type, int index = -1 );
+
+ /**
+ * Inserts @p type into the stereotype-combobox as well as its completion object.
+ */
+ void insertStereotype( const QString& type, int index = -1 );
+
+
+private:
+ QGroupBox * m_pParmGB, * m_pDocGB;
+ QButtonGroup *m_pKind;
+ QRadioButton * m_pIn, * m_pOut, *m_pInOut;
+ QLabel * m_pTypeL, * m_pNameL, * m_pInitialL, * m_pStereoTypeL;
+ KComboBox * m_pTypeCB, * m_pStereoTypeCB;
+ QLineEdit * m_pNameLE, * m_pInitialLE;
+ QMultiLineEdit * m_pDoc;
+ UMLDoc * m_pUmldoc;
+ UMLAttribute * m_pAtt;
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/pkgcontentspage.cpp b/umbrello/umbrello/dialogs/pkgcontentspage.cpp
new file mode 100644
index 00000000..dd70f7fc
--- /dev/null
+++ b/umbrello/umbrello/dialogs/pkgcontentspage.cpp
@@ -0,0 +1,127 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#include "pkgcontentspage.h"
+#include <qlayout.h>
+#include <klocale.h>
+#include "../umlobjectlist.h"
+#include "../uml.h"
+#include "../umldoc.h"
+#include "classpropdlg.h"
+
+PkgContentsPage::PkgContentsPage(QWidget *parent, UMLPackage *pkg)
+ : QWidget(parent)
+{
+ m_pPackage = pkg;
+ int margin = fontMetrics().height();
+
+ QHBoxLayout * mainLayout = new QHBoxLayout(this);
+ mainLayout -> setSpacing(10);
+
+ m_pContentGB = new QGroupBox(i18n("Contained Items"), this);
+ mainLayout -> addWidget(m_pContentGB);
+
+ QHBoxLayout * layout = new QHBoxLayout(m_pContentGB);
+ layout -> setSpacing(10);
+ layout -> setMargin(margin);
+
+ m_pContentLB = new QListBox(m_pContentGB);
+ layout -> addWidget(m_pContentLB);
+ setMinimumSize(310, 330);
+ fillListBox();
+ m_pMenu = 0;
+
+ connect(m_pContentLB, SIGNAL(doubleClicked(QListBoxItem *)),
+ this, SLOT(slotDoubleClick(QListBoxItem *)));
+
+ connect(m_pContentLB, SIGNAL(rightButtonPressed(QListBoxItem *, const QPoint &)),
+ this, SLOT(slotRightButtonPressed(QListBoxItem *, const QPoint &)));
+
+ connect(m_pContentLB, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)),
+ this, SLOT(slotRightButtonClicked(QListBoxItem *, const QPoint &)));
+}
+
+PkgContentsPage::~PkgContentsPage() {
+ disconnect(m_pContentLB, SIGNAL(doubleClicked(QListBoxItem *)),
+ this, SLOT(slotDoubleClick(QListBoxItem *)));
+
+ disconnect(m_pContentLB, SIGNAL(rightButtonPressed(QListBoxItem *, const QPoint &)),
+ this, SLOT(slotRightButtonPressed(QListBoxItem *, const QPoint &)));
+
+ disconnect(m_pContentLB, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)),
+ this, SLOT(slotRightButtonClicked(QListBoxItem *, const QPoint &)));
+}
+
+void PkgContentsPage::slotDoubleClick(QListBoxItem * i) {
+ if (!i)
+ return;
+ int item = m_pContentLB -> currentItem();
+ UMLObjectList contents = m_pPackage->containedObjects();
+ UMLObject *o = contents.at(item);
+ ClassPropDlg dlg(this, o, item, true);
+ dlg.exec();
+}
+
+void PkgContentsPage::fillListBox() {
+ m_pContentLB->clear();
+ UMLObjectList contents = m_pPackage->containedObjects();
+ UMLObjectListIt objList_it(contents);
+ UMLObject* umlo = NULL;
+ int i = 0;
+ while ((umlo = objList_it.current()) != NULL) {
+ m_pContentLB->insertItem(umlo->getName(), i++);
+ ++objList_it;
+ }
+}
+
+void PkgContentsPage::slotRightButtonClicked(QListBoxItem */* item*/, const QPoint &/* p*/) {
+ if(m_pMenu) {
+ m_pMenu -> hide();
+ disconnect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotPopupMenuSel(int)));
+ delete m_pMenu;
+ m_pMenu = 0;
+ }
+}
+
+void PkgContentsPage::slotRightButtonPressed(QListBoxItem * item, const QPoint & p) {
+ if(!item)
+ return;
+ if(m_pMenu) {
+ m_pMenu -> hide();
+ disconnect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotPopupMenuSel(int)));
+ delete m_pMenu;
+ m_pMenu = 0;
+ }
+ m_pMenu = new ListPopupMenu(this, ListPopupMenu::mt_Association_Selected);
+ m_pMenu->popup(p);
+ connect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotPopupMenuSel(int)));
+}
+
+void PkgContentsPage::slotPopupMenuSel(int id) {
+ switch(id) {
+ case ListPopupMenu::mt_Delete:
+ {
+ UMLObjectList contents = m_pPackage->containedObjects();
+ UMLObject *o = contents.at( m_pContentLB->currentItem() );
+ UMLApp::app()->getDocument()->removeUMLObject(o);
+ fillListBox();
+ }
+ break;
+
+ case ListPopupMenu::mt_Properties:
+ slotDoubleClick(m_pContentLB->item(m_pContentLB->currentItem()));
+ break;
+ }
+}
+
+
+
+#include "pkgcontentspage.moc"
diff --git a/umbrello/umbrello/dialogs/pkgcontentspage.h b/umbrello/umbrello/dialogs/pkgcontentspage.h
new file mode 100644
index 00000000..8659e672
--- /dev/null
+++ b/umbrello/umbrello/dialogs/pkgcontentspage.h
@@ -0,0 +1,62 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef PKGCONTENTSPAGE_H
+#define PKGCONTENTSPAGE_H
+
+#include <qwidget.h>
+#include <qgroupbox.h>
+#include <qlistbox.h>
+#include <qptrlist.h>
+
+#include "../package.h"
+#include "../listpopupmenu.h"
+
+/**
+ * @short The page shows all the objects that belong to a @ref UMLPackage.
+ * @author Oliver Kellogg <okellogg@users.sourceforge.net>
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class PkgContentsPage : public QWidget {
+ Q_OBJECT
+public:
+ /**
+ * Constructs an instance of PkgContentsPage.
+ *
+ * @param parent The parent of the page.
+ * @param pkg The UMLPackage being represented.
+ */
+ PkgContentsPage(QWidget *parent, UMLPackage *pkg);
+
+ /**
+ * Standard destructor.
+ */
+ ~PkgContentsPage();
+
+private:
+ UMLPackage * m_pPackage;
+ QListBox * m_pContentLB;
+ QGroupBox * m_pContentGB;
+ ListPopupMenu * m_pMenu;
+
+ /**
+ * Fills the list box with the package's contents.
+ */
+ void fillListBox();
+
+public slots:
+ void slotDoubleClick(QListBoxItem * i);
+ void slotRightButtonClicked(QListBoxItem */* item*/, const QPoint &/* p*/);
+ void slotRightButtonPressed(QListBoxItem * item, const QPoint & p);
+ void slotPopupMenuSel(int id);
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/selectopdlg.cpp b/umbrello/umbrello/dialogs/selectopdlg.cpp
new file mode 100644
index 00000000..cb9e344d
--- /dev/null
+++ b/umbrello/umbrello/dialogs/selectopdlg.cpp
@@ -0,0 +1,141 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "selectopdlg.h"
+
+// qt includes
+#include <qlayout.h>
+
+// kde includes
+#include <klocale.h>
+#include <kdebug.h>
+
+// local includes
+#include "../attribute.h"
+#include "../operation.h"
+#include "../umlclassifierlistitemlist.h"
+#include "../umlview.h"
+#include "../dialog_utils.h"
+
+SelectOpDlg::SelectOpDlg(UMLView * parent, UMLClassifier * c)
+ : KDialogBase(Plain, i18n("Select Operation"), Ok | Cancel , Ok, parent, "_SELOPDLG_", true, true)
+{
+ m_pView = parent;
+ QVBoxLayout * topLayout = new QVBoxLayout(plainPage());
+
+ m_pOpGB = new QGroupBox(i18n("Select Operation"), plainPage());
+ topLayout -> addWidget(m_pOpGB);
+
+ QGridLayout * mainLayout = new QGridLayout(m_pOpGB, 3, 2);
+ mainLayout -> setSpacing(spacingHint());
+ mainLayout -> setMargin(fontMetrics().height());
+
+ Dialog_Utils::makeLabeledEditField( m_pOpGB, mainLayout, 0,
+ m_pSeqL, i18n("Sequence number:"),
+ m_pSeqLE );
+
+ m_pOpRB = new QRadioButton(i18n("Class operation:"), m_pOpGB);
+ mainLayout -> addWidget(m_pOpRB, 1, 0);
+
+ m_pOpCB = new KComboBox(m_pOpGB);
+ m_pOpCB->setCompletionMode( KGlobalSettings::CompletionPopup );
+ m_pOpCB->setDuplicatesEnabled(false);//only allow one of each type in box
+ mainLayout -> addWidget(m_pOpCB, 1, 1);
+
+ m_pCustomRB = new QRadioButton(i18n("Custom operation:"), m_pOpGB);
+ mainLayout -> addWidget(m_pCustomRB, 2, 0);
+
+ m_pOpLE = new QLineEdit(m_pOpGB);
+ mainLayout -> addWidget(m_pOpLE, 2, 1);
+
+ m_pOpBG = new QButtonGroup(0);
+ m_pOpBG -> insert(m_pOpRB, OP);
+ m_pOpBG -> insert(m_pCustomRB, CUSTOM);
+ m_pOpBG -> setExclusive(true);
+ m_pOpBG -> setButton(OP);
+
+ UMLOperationList list = c -> getOpList(true);
+ for (UMLOperation *obj = list.first(); obj; obj=list.next()) {
+ insertOperation( obj->toString(Uml::st_SigNoVis) );
+ }
+ //disableResize();
+ connect(m_pOpBG, SIGNAL(clicked(int)), this, SLOT(slotSelected(int)));
+ m_nOpCount = c -> operations();
+ slotSelected(OP);
+}
+
+SelectOpDlg::~SelectOpDlg() {
+ disconnect(m_pOpBG, SIGNAL(clicked(int)), this, SLOT(slotSelected(int)));
+ delete m_pOpBG;
+}
+
+void SelectOpDlg::insertOperation( const QString& type, int index )
+{
+ m_pOpCB->insertItem( type, index );
+ m_pOpCB->completionObject()->addItem( type );
+}
+
+QString SelectOpDlg::getOpText() {
+ if(m_pOpRB -> isChecked())
+ return m_pOpCB -> currentText();
+ else
+ return m_pOpLE -> text();
+}
+
+bool SelectOpDlg::isClassOp() const {
+ return (m_id == OP);
+}
+
+void SelectOpDlg::slotSelected(int id) {
+ if(id == OP) {
+ m_pOpLE -> setEnabled(false);
+ if(m_nOpCount > 0)
+ m_pOpCB -> setEnabled(true);
+ } else {
+ m_pOpLE -> setEnabled(true);
+ m_pOpCB -> setEnabled(false);
+ }
+ m_id = id;
+}
+
+void SelectOpDlg::setCustomOp(const QString &op) {
+ m_pOpLE -> setText(op);
+ if(op.length() > 0) {
+ slotSelected(CUSTOM);
+ m_pCustomRB -> setChecked(true);
+ }
+}
+
+bool SelectOpDlg::setClassOp(const QString &op) {
+ for (int i = 1; i!= m_pOpCB->count(); ++i)
+ {
+ if ( m_pOpCB->text(i) == op ) {
+ m_pOpCB->setCurrentItem(i);
+ m_pCustomRB -> setChecked(false);
+ slotSelected(OP);
+ return true;
+ }
+ }
+ return false;
+}
+
+QString SelectOpDlg::getSeqNumber() {
+ return m_pSeqLE->text();
+}
+
+void SelectOpDlg::setSeqNumber(const QString &num) {
+ m_pSeqLE->setText(num);
+}
+
+
+
+#include "selectopdlg.moc"
diff --git a/umbrello/umbrello/dialogs/selectopdlg.h b/umbrello/umbrello/dialogs/selectopdlg.h
new file mode 100644
index 00000000..c5d8c93b
--- /dev/null
+++ b/umbrello/umbrello/dialogs/selectopdlg.h
@@ -0,0 +1,120 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+
+#ifndef SELECTOPDLG_H
+#define SELECTOPDLG_H
+
+#include <kdialogbase.h>
+
+#include <qgroupbox.h>
+#include <kcombobox.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+#include "../classifier.h"
+
+class UMLView;
+
+#define OP 0
+#define CUSTOM 1
+
+/**
+ * A dialog used to select an operation.
+ *
+ * @short A dialog to select an operation.
+ * @author Paul Hensgen <phensgen@techie.com>
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+
+class SelectOpDlg : public KDialogBase
+{
+ Q_OBJECT
+public:
+ /**
+ * Constructs a SelectOpDlg instance.
+ *
+ * @param parent The parent to this instance.
+ * @param c The concept to get the operations from.
+ */
+ SelectOpDlg(UMLView * parent, UMLClassifier * c);
+
+ /**
+ * Standard deconstructor.
+ */
+ ~SelectOpDlg();
+
+ /**
+ * Returns the operation to display.
+ *
+ * @return The operation to display.
+ */
+ QString getOpText();
+
+ /**
+ * Return whether the user selected a class operation
+ * or a custom operation.
+ *
+ * @return True if user selected a class operation,
+ * false if user selected a custom operation
+ */
+ bool isClassOp() const;
+
+ /**
+ * Returns the sequence number for the operation.
+ *
+ * @return Returns the sequence number for the operation.
+ */
+ QString getSeqNumber();
+
+ /**
+ * Set the sequence number text.
+ *
+ * @param num The number to set the sequence to.
+ */
+ void setSeqNumber(const QString &num);
+
+ /**
+ * Set the custom operation text.
+ *
+ * @param op The operation to set as the custom operation.
+ */
+ void setCustomOp(const QString &op);
+ /**
+ * Set the class operation text.
+ *
+ * @param op The operation to set as the class operation.
+ * @return false if no such operation exists.
+ */
+ bool setClassOp(const QString &op);
+protected:
+ /**
+ * Inserts @p type into the type-combobox as well as its completion object.
+ */
+ void insertOperation( const QString& type, int index = -1 );
+private:
+ QGroupBox * m_pOpGB;
+ KComboBox * m_pOpCB;
+ QLabel * m_pSeqL;
+ QLineEdit * m_pOpLE, * m_pSeqLE;
+ QRadioButton * m_pCustomRB, * m_pOpRB;
+ QButtonGroup * m_pOpBG, * m_pDocGB;
+ QString m_Text;
+ int m_nOpCount;
+ int m_id; ///< takes on the value OP or CUSTOM according to what the user selected
+ UMLView *m_pView;
+public slots:
+ void slotSelected(int id);
+};
+
+#endif
+
diff --git a/umbrello/umbrello/dialogs/settingsdlg.cpp b/umbrello/umbrello/dialogs/settingsdlg.cpp
new file mode 100644
index 00000000..2bfaaf29
--- /dev/null
+++ b/umbrello/umbrello/dialogs/settingsdlg.cpp
@@ -0,0 +1,443 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "settingsdlg.h"
+
+// qt includes
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qvbox.h>
+// kde includes
+#include <kdebug.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kfiledialog.h>
+// app includes
+#include "codegenerationoptionspage.h"
+#include "codevieweroptionspage.h"
+#include "../dialog_utils.h"
+
+SettingsDlg::SettingsDlg( QWidget * parent, Settings::OptionState *state )
+ : KDialogBase( IconList, i18n("Umbrello Setup"),
+ Help | Default | Apply | Ok | Cancel, Ok, parent, 0, true, true ) {
+ m_bChangesApplied = false;
+ m_pOptionState = state;
+ setHelp( "umbrello/index.html", QString::null );
+ setupGeneralPage();
+ setupFontPage();
+ setupUIPage();
+ setupClassPage();
+ setupCodeGenPage();
+ setupCodeViewerPage(state->codeViewerState);
+}
+
+SettingsDlg::~SettingsDlg() {}
+
+void SettingsDlg::setupUIPage() {
+ //setup UI page
+ QVBox * page = addVBoxPage( i18n("User Interface"), i18n("User Interface Settings"), DesktopIcon( "window_list") );
+
+ m_UiWidgets.colorGB = new QGroupBox( i18n("Color"), page );
+ QGridLayout * colorLayout = new QGridLayout( m_UiWidgets.colorGB, 3, 3 );
+ colorLayout -> setSpacing( spacingHint() );
+ colorLayout -> setMargin( fontMetrics().height() );
+
+ m_UiWidgets.lineColorL = new QLabel( i18n("Line color:"), m_UiWidgets.colorGB );
+ colorLayout -> addWidget( m_UiWidgets.lineColorL, 0, 0 );
+
+ m_UiWidgets.lineColorB = new KColorButton( m_pOptionState->uiState.lineColor, m_UiWidgets.colorGB );
+ colorLayout -> addWidget( m_UiWidgets.lineColorB, 0, 1 );
+
+ m_UiWidgets.lineDefaultB = new QPushButton( i18n("D&efault Color"), m_UiWidgets.colorGB );
+ colorLayout -> addWidget( m_UiWidgets.lineDefaultB, 0, 2 );
+
+ m_UiWidgets.fillColorL = new QLabel( i18n("Fill color:"), m_UiWidgets.colorGB );
+ colorLayout -> addWidget( m_UiWidgets.fillColorL, 1, 0 );
+
+ m_UiWidgets.fillColorB = new KColorButton( m_pOptionState->uiState.fillColor, m_UiWidgets.colorGB );
+ colorLayout -> addWidget( m_UiWidgets.fillColorB, 1, 1 );
+
+ m_UiWidgets.fillDefaultB = new QPushButton( i18n("De&fault Color"), m_UiWidgets.colorGB );
+ colorLayout -> addWidget( m_UiWidgets.fillDefaultB, 1, 2 );
+
+
+ m_UiWidgets.lineWidthL = new QLabel( i18n("Line width:"), m_UiWidgets.colorGB );
+ colorLayout -> addWidget( m_UiWidgets.lineWidthL, 2, 0 );
+
+ // Low-Limit: 0, High-Limit: 10, Step: 1, Initial-Val: m_pOptionState->uiState.lineWidth
+ // Number-Base: 10 ( decimal ), Parent: m_UiWidgets.colorGB
+ m_UiWidgets.lineWidthB = new KIntSpinBox( 0, 10, 1, m_pOptionState->uiState.lineWidth, 10, m_UiWidgets.colorGB );
+ colorLayout -> addWidget( m_UiWidgets.lineWidthB, 2, 1 );
+
+ m_UiWidgets.lineWidthDefaultB = new QPushButton( i18n("D&efault Width"), m_UiWidgets.colorGB );
+ colorLayout -> addWidget( m_UiWidgets.lineWidthDefaultB, 2, 2 );
+
+
+
+ m_UiWidgets.useFillColorCB = new QCheckBox( i18n("&Use fill color"), m_UiWidgets.colorGB );
+ colorLayout -> setRowStretch( 3, 2 );
+ colorLayout -> addWidget( m_UiWidgets.useFillColorCB, 3, 0 );
+ m_UiWidgets.useFillColorCB -> setChecked( m_pOptionState->uiState.useFillColor );
+
+ //connect button signals up
+ connect( m_UiWidgets.lineDefaultB, SIGNAL(clicked()), this, SLOT(slotLineBClicked()) );
+ connect( m_UiWidgets.fillDefaultB, SIGNAL(clicked()), this, SLOT(slotFillBClicked()) );
+}
+
+void SettingsDlg::setupGeneralPage() {
+ //setup General page
+
+ QVBox * page = addVBoxPage( i18n("General"), i18n("General Settings"), DesktopIcon( "misc") );
+
+ // Set up undo setting
+ m_GeneralWidgets.miscGB = new QGroupBox( i18n("Miscellaneous"), page );
+
+ QGridLayout * miscLayout = new QGridLayout( m_GeneralWidgets.miscGB, 2, 2 );
+ miscLayout -> setSpacing( spacingHint() );
+ miscLayout -> setMargin( fontMetrics().height() );
+
+ m_GeneralWidgets.undoCB = new QCheckBox( i18n("Enable undo"), m_GeneralWidgets.miscGB );
+ m_GeneralWidgets.undoCB -> setChecked( m_pOptionState->generalState.undo );
+ miscLayout -> addWidget( m_GeneralWidgets.undoCB, 0, 0 );
+
+ m_GeneralWidgets.tabdiagramsCB = new QCheckBox( i18n("Use tabbed diagrams"), m_GeneralWidgets.miscGB );
+ m_GeneralWidgets.tabdiagramsCB -> setChecked( m_pOptionState->generalState.tabdiagrams );
+ miscLayout -> addWidget( m_GeneralWidgets.tabdiagramsCB, 0, 1 );
+
+ m_GeneralWidgets.newcodegenCB = new QCheckBox( i18n("Use new C++/Java/Ruby generators"), m_GeneralWidgets.miscGB );
+ m_GeneralWidgets.newcodegenCB -> setChecked( m_pOptionState->generalState.newcodegen );
+ miscLayout -> addWidget( m_GeneralWidgets.newcodegenCB, 1, 0 );
+
+ m_GeneralWidgets.angularLinesCB = new QCheckBox( i18n("Use angular association lines"), m_GeneralWidgets.miscGB );
+ m_GeneralWidgets.angularLinesCB -> setChecked( m_pOptionState->generalState.angularlines );
+ miscLayout -> addWidget( m_GeneralWidgets.angularLinesCB, 1, 1 );
+
+ //setup autosave settings
+
+ m_GeneralWidgets.autosaveGB = new QGroupBox( i18n("Autosave"), page );
+
+ QGridLayout * autosaveLayout = new QGridLayout( m_GeneralWidgets.autosaveGB, 3, 2 );
+ autosaveLayout -> setSpacing( spacingHint() );
+ autosaveLayout -> setMargin( fontMetrics().height() );
+
+ m_GeneralWidgets.autosaveCB = new QCheckBox( i18n("E&nable autosave"), m_GeneralWidgets.autosaveGB );
+ m_GeneralWidgets.autosaveCB -> setChecked( m_pOptionState->generalState.autosave );
+ autosaveLayout -> addWidget( m_GeneralWidgets.autosaveCB, 0, 0 );
+
+ m_GeneralWidgets.autosaveL = new QLabel( i18n("Select auto-save time interval (mins):"), m_GeneralWidgets.autosaveGB );
+ autosaveLayout -> addWidget( m_GeneralWidgets.autosaveL, 1, 0 );
+
+ m_GeneralWidgets.timeISB = new KIntSpinBox( 1, 600, 1, m_pOptionState->generalState.autosavetime, 10, m_GeneralWidgets.autosaveGB );
+ m_GeneralWidgets.timeISB -> setEnabled( m_pOptionState->generalState.autosave );
+ autosaveLayout -> addWidget( m_GeneralWidgets.timeISB, 1, 1 );
+
+ // 2004-05-17 Achim Spangler: Allow definition of Suffix for autosave
+ // ( default: ".xmi" )
+ Dialog_Utils::makeLabeledEditField( m_GeneralWidgets.autosaveGB, autosaveLayout, 2,
+ m_GeneralWidgets.autosaveSuffixL, i18n("Set autosave suffix:"),
+ m_GeneralWidgets.autosaveSuffixT, m_pOptionState->generalState.autosavesuffix );
+ QString autoSaveSuffixToolTip = i18n( "<qt><p>The autosave file will be saved to ~/autosave.xmi if the autosaving occurs "
+ "before you have manually saved the file.</p>"
+ "<p>If you've already saved it, the autosave file will be saved in the same folder as the file "
+ "and will be named like the file's name, followed by the suffix specified.</p>"
+ "<p>If the suffix is equal to the suffix of the file you've saved, "
+ "the autosave will overwrite your file automatically.</p></qt>" );
+ QToolTip::add( m_GeneralWidgets.autosaveSuffixL, autoSaveSuffixToolTip );
+ QToolTip::add( m_GeneralWidgets.autosaveSuffixT, autoSaveSuffixToolTip );
+
+ //setup startup settings
+ m_GeneralWidgets.startupGB = new QGroupBox( i18n("Startup"), page );
+
+ QGridLayout * startupLayout = new QGridLayout( m_GeneralWidgets.startupGB, 3, 2 );
+ startupLayout -> setSpacing( spacingHint() );
+ startupLayout -> setMargin( fontMetrics().height() );
+
+ m_GeneralWidgets.logoCB = new QCheckBox( i18n("Sta&rtup logo"), m_GeneralWidgets.startupGB );
+ m_GeneralWidgets.logoCB -> setChecked( m_pOptionState->generalState.logo );
+ startupLayout -> addWidget( m_GeneralWidgets.logoCB, 0, 0 );
+
+ m_GeneralWidgets.tipCB = new QCheckBox( i18n("&Tip of the day"), m_GeneralWidgets.startupGB );
+ m_GeneralWidgets.tipCB -> setChecked( m_pOptionState->generalState.tip );
+ startupLayout -> addWidget( m_GeneralWidgets.tipCB, 0, 1 );
+
+ m_GeneralWidgets.loadlastCB = new QCheckBox( i18n("&Load last project"), m_GeneralWidgets.startupGB );
+ m_GeneralWidgets.loadlastCB -> setChecked( m_pOptionState->generalState.loadlast );
+ startupLayout -> addWidget( m_GeneralWidgets.loadlastCB, 1, 0 );
+
+ m_GeneralWidgets.startL = new QLabel( i18n("Start new project with:"), m_GeneralWidgets.startupGB );
+ startupLayout -> addWidget( m_GeneralWidgets.startL, 2, 0 );
+
+ m_GeneralWidgets.diagramKB = new KComboBox( m_GeneralWidgets.startupGB );
+ m_GeneralWidgets.diagramKB->setCompletionMode( KGlobalSettings::CompletionPopup );
+ startupLayout -> addWidget( m_GeneralWidgets.diagramKB, 2, 1 );
+
+ QString diagrams [] = { i18n("No Diagram"), i18n("Class Diagram"),
+ i18n("Use Case Diagram"), i18n("Sequence Diagram"),
+ i18n("Collaboration Diagram"), i18n("State Diagram"),
+ i18n("Activity Diagram"), i18n("Component Diagram"),
+ i18n("Deployment Diagram") };
+
+ //start at 1 because we don't allow No Diagram any more
+ for (int i=1; i<9; i++) {
+ insertDiagram( diagrams[i] );
+ }
+
+ m_GeneralWidgets.diagramKB->setCurrentItem( (int)m_pOptionState->generalState.diagram-1 );
+ connect( m_GeneralWidgets.autosaveCB, SIGNAL(clicked()), this, SLOT(slotAutosaveCBClicked()) );
+}
+
+/**
+* Inserts @p type into the type-combobox as well as its completion object.
+*/
+void SettingsDlg::insertDiagram( const QString& type, int index )
+{
+ m_GeneralWidgets.diagramKB->insertItem( type, index );
+ m_GeneralWidgets.diagramKB->completionObject()->addItem( type );
+}
+
+void SettingsDlg::setupClassPage() {
+ //setup class settings page
+
+ QVBox * page = addVBoxPage( i18n("Class"), i18n("Class Settings"), DesktopIcon( "edit") );
+ m_ClassWidgets.visibilityGB = new QGroupBox( i18n("Visibility"), page );
+
+ QGridLayout * visibilityLayout = new QGridLayout( m_ClassWidgets.visibilityGB );
+ visibilityLayout -> setSpacing( spacingHint() );
+ visibilityLayout -> setMargin( fontMetrics().height() );
+
+ m_ClassWidgets.showVisibilityCB = new QCheckBox(i18n("Show &visibility"), m_ClassWidgets.visibilityGB);
+ m_ClassWidgets.showVisibilityCB -> setChecked( m_pOptionState->classState.showVisibility );
+ visibilityLayout -> addWidget( m_ClassWidgets.showVisibilityCB, 0, 0 );
+
+ m_ClassWidgets.showAttsCB = new QCheckBox( i18n("Show attributes"), m_ClassWidgets.visibilityGB );
+ m_ClassWidgets.showAttsCB -> setChecked( m_pOptionState->classState.showAtts );
+ visibilityLayout -> addWidget( m_ClassWidgets.showAttsCB, 0, 1 );
+
+ m_ClassWidgets.showOpsCB = new QCheckBox( i18n("Show operations"), m_ClassWidgets.visibilityGB );
+ m_ClassWidgets.showOpsCB -> setChecked( m_pOptionState->classState.showOps );
+ visibilityLayout -> addWidget( m_ClassWidgets.showOpsCB, 1, 0 );
+
+ m_ClassWidgets.showStereotypeCB = new QCheckBox( i18n("Show stereot&ype"), m_ClassWidgets.visibilityGB );
+ m_ClassWidgets.showStereotypeCB -> setChecked( m_pOptionState->classState.showStereoType );
+ visibilityLayout -> addWidget( m_ClassWidgets.showStereotypeCB, 1, 1 );
+
+ m_ClassWidgets.showAttSigCB = new QCheckBox(i18n("Show attribute signature"), m_ClassWidgets.visibilityGB);
+ m_ClassWidgets.showAttSigCB -> setChecked( m_pOptionState->classState.showAttSig );
+ visibilityLayout -> addWidget( m_ClassWidgets.showAttSigCB, 2, 0 );
+
+
+ m_ClassWidgets.showPackageCB = new QCheckBox(i18n("Show package"), m_ClassWidgets.visibilityGB);
+ m_ClassWidgets.showPackageCB -> setChecked( m_pOptionState->classState.showPackage );
+ visibilityLayout -> addWidget( m_ClassWidgets.showPackageCB, 2, 1 );
+
+ m_ClassWidgets.showOpSigCB = new QCheckBox( i18n("Show operation signature"), m_ClassWidgets.visibilityGB );
+ m_ClassWidgets.showOpSigCB -> setChecked( m_pOptionState->classState.showOpSig );
+ visibilityLayout -> addWidget( m_ClassWidgets.showOpSigCB, 3, 0 );
+ visibilityLayout -> setRowStretch( 3, 1 );
+
+ m_ClassWidgets.scopeGB = new QGroupBox( i18n("Starting Scope"), page );
+ QGridLayout * scopeLayout = new QGridLayout( m_ClassWidgets.scopeGB );
+ scopeLayout -> setSpacing( spacingHint() );
+ scopeLayout -> setMargin( fontMetrics().height() );
+
+ m_ClassWidgets.attributeLabel = new QLabel( i18n("Default attribute scope:"), m_ClassWidgets.scopeGB);
+ scopeLayout -> addWidget( m_ClassWidgets.attributeLabel, 0, 0 );
+
+ m_ClassWidgets.operationLabel = new QLabel( i18n("Default operation scope:"), m_ClassWidgets.scopeGB);
+ scopeLayout -> addWidget( m_ClassWidgets.operationLabel, 1, 0 );
+
+ m_ClassWidgets.m_pAttribScopeCB = new KComboBox(m_ClassWidgets.scopeGB);
+ insertAttribScope( tr2i18n( "Public" ) );
+ insertAttribScope( tr2i18n( "Private" ) );
+ insertAttribScope( tr2i18n( "Protected" ) );
+ m_ClassWidgets.m_pAttribScopeCB->setCurrentItem((m_pOptionState->classState.defaultAttributeScope - 200));
+ m_ClassWidgets.m_pAttribScopeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
+ scopeLayout -> addWidget( m_ClassWidgets.m_pAttribScopeCB, 0, 1 );
+
+ m_ClassWidgets.m_pOperationScopeCB = new KComboBox(m_ClassWidgets.scopeGB);
+ insertOperationScope( tr2i18n( "Public" ) );
+ insertOperationScope( tr2i18n( "Private" ) );
+ insertOperationScope( tr2i18n( "Protected" ) );
+ m_ClassWidgets.m_pOperationScopeCB->setCurrentItem((m_pOptionState->classState.defaultOperationScope - 200));
+ m_ClassWidgets.m_pOperationScopeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
+ scopeLayout -> addWidget( m_ClassWidgets.m_pOperationScopeCB, 1, 1 );
+
+}
+/**
+* Inserts @p type into the type-combobox as well as its completion object.
+*/
+void SettingsDlg::insertAttribScope( const QString& type, int index )
+{
+ m_ClassWidgets.m_pAttribScopeCB->insertItem( type, index );
+ m_ClassWidgets.m_pAttribScopeCB->completionObject()->addItem( type );
+}
+/**
+* Inserts @p type into the type-combobox as well as its completion object.
+*/
+void SettingsDlg::insertOperationScope( const QString& type, int index )
+{
+ m_ClassWidgets.m_pOperationScopeCB->insertItem( type, index );
+ m_ClassWidgets.m_pOperationScopeCB->completionObject()->addItem( type );
+}
+
+void SettingsDlg::setupCodeGenPage() {
+ //setup code generation settings page
+ QVBox * page = addVBoxPage( i18n("Code Generation"), i18n("Code Generation Settings"), DesktopIcon( "source") );
+ m_pCodeGenPage = new CodeGenerationOptionsPage(page);
+ connect( m_pCodeGenPage, SIGNAL(languageChanged()), this, SLOT(slotApply()) );
+}
+
+void SettingsDlg::setupCodeViewerPage(Settings::CodeViewerState options) {
+ //setup code generation settings page
+ QVBox * page = addVBoxPage( i18n("Code Viewer"), i18n("Code Viewer Settings"), DesktopIcon( "source") );
+ m_pCodeViewerPage = new CodeViewerOptionsPage(options, page);
+}
+
+void SettingsDlg::setupFontPage() {
+ QVBox * page = addVBoxPage( i18n("Font"), i18n("Font Settings"), DesktopIcon( "fonts") );
+ m_FontWidgets.chooser = new KFontChooser( page, "font", false, QStringList(), false);
+ m_FontWidgets.chooser->setFont( m_pOptionState->uiState.font );
+
+}
+
+void SettingsDlg::slotApply() {
+ applyPage( (Settings::Page) activePageIndex() );
+ //do no emit signal applyClicked in the slot slotApply -> infinite loop
+ //emit applyClicked();
+}
+
+void SettingsDlg::slotOk() {
+ applyPage( Settings::page_general );
+ applyPage( Settings::page_font );
+ applyPage( Settings::page_UI );
+ applyPage( Settings::page_class );
+ applyPage( Settings::page_codegen );
+ applyPage( Settings::page_codeview );
+ accept();
+}
+
+
+void SettingsDlg::slotDefault() {
+ /*
+ Defaults hard coded. Make sure that this is alright.
+ If defaults are set anywhere else, like in setting up config file, make sure the same.
+ */
+ switch( activePageIndex() ) {
+ case Settings::page_general:
+ m_GeneralWidgets.autosaveCB -> setChecked( false );
+ m_GeneralWidgets.timeISB -> setValue( 5 );
+ m_GeneralWidgets.timeISB->setEnabled( true );
+ m_GeneralWidgets.logoCB -> setChecked( true );
+ m_GeneralWidgets.tipCB -> setChecked( true );
+ m_GeneralWidgets.loadlastCB -> setChecked( true );
+ m_GeneralWidgets.diagramKB -> setCurrentItem( 0 );
+ break;
+
+ case Settings::page_font:
+ m_FontWidgets.chooser -> setFont( parentWidget() -> font() );
+ break;
+
+ case Settings::page_UI:
+ m_UiWidgets.useFillColorCB -> setChecked( true );
+ m_UiWidgets.fillColorB -> setColor( QColor( 255, 255, 192 ) );
+ m_UiWidgets.lineColorB -> setColor( Qt::red );
+ m_UiWidgets.lineWidthB -> setValue( 0 );
+ break;
+
+ case Settings::page_class:
+ m_ClassWidgets.showVisibilityCB -> setChecked( false );
+ m_ClassWidgets.showAttsCB -> setChecked( true );
+ m_ClassWidgets.showOpsCB -> setChecked( true );
+ m_ClassWidgets.showStereotypeCB -> setChecked( false );
+ m_ClassWidgets.showAttSigCB -> setChecked( false );
+ m_ClassWidgets.showOpSigCB -> setChecked( false );
+ m_ClassWidgets.showPackageCB -> setChecked( false );
+ m_ClassWidgets.m_pAttribScopeCB->setCurrentItem(1); // Private
+ m_ClassWidgets.m_pOperationScopeCB->setCurrentItem(0); // Public
+ break;
+
+ case Settings::page_codegen:
+ case Settings::page_codeview:
+ // do nothing
+ break;
+ };
+}
+
+void SettingsDlg::applyPage( Settings::Page page ) {
+ m_bChangesApplied = true;
+ switch( page ) {
+ case Settings::page_general:
+ m_pOptionState->generalState.undo = m_GeneralWidgets.undoCB -> isChecked();
+ m_pOptionState->generalState.tabdiagrams = m_GeneralWidgets.tabdiagramsCB->isChecked();
+ m_pOptionState->generalState.newcodegen = m_GeneralWidgets.newcodegenCB->isChecked();
+ m_pOptionState->generalState.angularlines = m_GeneralWidgets.angularLinesCB->isChecked();
+ m_pOptionState->generalState.autosave = m_GeneralWidgets.autosaveCB -> isChecked();
+ m_pOptionState->generalState.autosavetime = m_GeneralWidgets.timeISB -> value();
+ // 2004-05-17 Achim Spangler: retrieve Suffix setting from dialog entry
+ m_pOptionState->generalState.autosavesuffix = m_GeneralWidgets.autosaveSuffixT -> text();
+ m_pOptionState->generalState.logo = m_GeneralWidgets.logoCB -> isChecked();
+ m_pOptionState->generalState.tip = m_GeneralWidgets.tipCB -> isChecked();
+ m_pOptionState->generalState.loadlast = m_GeneralWidgets.loadlastCB -> isChecked();
+ m_pOptionState->generalState.diagram = (Uml::Diagram_Type)(m_GeneralWidgets.diagramKB->currentItem() + 1);
+ break;
+
+ case Settings::page_font:
+ m_pOptionState->uiState.font = m_FontWidgets.chooser -> font();
+ break;
+
+ case Settings::page_UI:
+ m_pOptionState->uiState.useFillColor = m_UiWidgets.useFillColorCB -> isChecked();
+ m_pOptionState->uiState.fillColor = m_UiWidgets.fillColorB -> color();
+ m_pOptionState->uiState.lineColor = m_UiWidgets.lineColorB -> color();
+ m_pOptionState->uiState.lineWidth = m_UiWidgets.lineWidthB -> value();
+ break;
+
+ case Settings::page_class:
+ m_pOptionState->classState.showVisibility = m_ClassWidgets.showVisibilityCB -> isChecked();
+ m_pOptionState->classState.showAtts = m_ClassWidgets.showAttsCB -> isChecked();
+ m_pOptionState->classState.showOps = m_ClassWidgets.showOpsCB -> isChecked();
+ m_pOptionState->classState.showStereoType = m_ClassWidgets.showStereotypeCB -> isChecked();
+ m_pOptionState->classState.showAttSig = m_ClassWidgets.showAttSigCB -> isChecked();
+ m_pOptionState->classState.showOpSig = m_ClassWidgets.showOpSigCB -> isChecked();
+ m_pOptionState->classState.showPackage = m_ClassWidgets.showPackageCB -> isChecked();
+ m_pOptionState->classState.defaultAttributeScope = (Uml::Visibility::Value) (m_ClassWidgets.m_pAttribScopeCB->currentItem() + 200);
+ m_pOptionState->classState.defaultOperationScope = (Uml::Visibility::Value) (m_ClassWidgets.m_pOperationScopeCB->currentItem() + 200);
+ break;
+
+ case Settings::page_codegen:
+ m_pCodeGenPage->apply();
+ break;
+
+ case Settings::page_codeview:
+ m_pCodeViewerPage->apply();
+ m_pOptionState->codeViewerState = m_pCodeViewerPage->getOptions();
+ break;
+ }
+}
+
+void SettingsDlg::slotLineBClicked() {
+ m_UiWidgets.lineColorB -> setColor( Qt::red );
+}
+
+void SettingsDlg::slotFillBClicked() {
+ m_UiWidgets.fillColorB -> setColor( QColor(255, 255, 192) );
+}
+
+void SettingsDlg::slotAutosaveCBClicked() {
+ m_GeneralWidgets.timeISB -> setEnabled( m_GeneralWidgets.autosaveCB -> isChecked() );
+}
+
+QString SettingsDlg::getCodeGenerationLanguage() {
+ return m_pCodeGenPage->getCodeGenerationLanguage();
+}
+
+#include "settingsdlg.moc"
diff --git a/umbrello/umbrello/dialogs/settingsdlg.h b/umbrello/umbrello/dialogs/settingsdlg.h
new file mode 100644
index 00000000..30579990
--- /dev/null
+++ b/umbrello/umbrello/dialogs/settingsdlg.h
@@ -0,0 +1,177 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+
+#ifndef SETTINGSDLG_H
+#define SETTINGSDLG_H
+//qt includes
+#include <qgroupbox.h>
+#include <qcheckbox.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
+#include <qdict.h>
+//kde includes
+#include <kcombobox.h>
+#include <kfontdialog.h>
+#include <kdialogbase.h>
+#include <kcolorbutton.h>
+#include <knuminput.h>
+//app includes
+
+#include "../optionstate.h"
+
+class CodeGenerationOptionsPage;
+class CodeViewerOptionsPage;
+class CodeGenerator;
+
+/**
+ * @author Paul Hensgen
+ * modified by brian thomas Aug-2003
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+
+class SettingsDlg : public KDialogBase {
+
+ Q_OBJECT
+
+public:
+ SettingsDlg(QWidget * parent, Settings::OptionState *state);
+ ~SettingsDlg();
+
+ //public methods
+ bool getChangesApplied() {
+ return m_bChangesApplied;
+ }
+
+ QString getCodeGenerationLanguage();
+
+protected:
+ /**
+ * Inserts @p type into the type-combobox as well as its completion object.
+ */
+ void insertDiagram( const QString& type, int index = -1 );
+ /**
+ * Inserts @p type into the type-combobox as well as its completion object.
+ */
+ void insertAttribScope( const QString& type, int index = -1 );
+ /**
+ * Inserts @p type into the type-combobox as well as its completion object.
+ */
+ void insertOperationScope( const QString& type, int index = -1 );
+
+private:
+ //private structs
+ struct UIWidgets {
+ QGroupBox * colorGB;
+
+ QLabel * lineColorL;
+ QLabel * fillColorL;
+ QLabel * lineWidthL;
+
+ QPushButton * lineDefaultB;
+ QPushButton * fillDefaultB;
+ QPushButton * lineWidthDefaultB;
+
+ KColorButton * lineColorB;
+ KColorButton * fillColorB;
+ KIntSpinBox * lineWidthB;
+
+ QCheckBox * useFillColorCB;
+ }
+ ;//end struct UIWidgets
+
+ struct GeneralWidgets {
+ QGroupBox * miscGB;
+ QGroupBox * autosaveGB;
+ QGroupBox * startupGB;
+
+ KIntSpinBox * timeISB;
+ KComboBox * diagramKB;
+
+ QCheckBox * undoCB;
+ QCheckBox * tabdiagramsCB;
+ QCheckBox * newcodegenCB;
+ QCheckBox * angularLinesCB;
+ QCheckBox * autosaveCB;
+ QCheckBox * logoCB;
+ QCheckBox * tipCB;
+ QCheckBox * loadlastCB;
+
+ // 2004-05-17 Achim Spangler: Allow definition of Suffix for autosave
+ // ( Default: ".xmi" )
+ QLineEdit * autosaveSuffixT;
+ QLabel * autosaveSuffixL;
+ // End AutoSave Suffix
+
+ QLabel * startL;
+ QLabel * autosaveL;
+ }
+ ;//end struct GeneralWidgets
+
+ struct ClassWidgets {
+ QGroupBox * visibilityGB;
+ QGroupBox * scopeGB;
+
+ QCheckBox * showVisibilityCB;
+ QCheckBox * showAttsCB;
+ QCheckBox * showOpsCB;
+ QCheckBox * showStereotypeCB;
+ QCheckBox * showAttSigCB;
+ QCheckBox * showPackageCB;
+
+ QCheckBox * showOpSigCB;
+
+ QLabel * attributeLabel;
+ QLabel * operationLabel;
+
+ KComboBox* m_pAttribScopeCB;
+ KComboBox* m_pOperationScopeCB;
+
+ }
+ ;//end struct ClassWidgets
+
+ struct FontWidgets {
+ KFontChooser * chooser;
+ };
+
+ //private methods
+ void setupFontPage();
+ void setupUIPage();
+ void setupGeneralPage();
+ void setupClassPage();
+ void setupCodeGenPage();
+ void setupCodeViewerPage(Settings::CodeViewerState options);
+ void applyPage( Settings::Page page );
+
+ //private attributes
+ FontWidgets m_FontWidgets;
+ GeneralWidgets m_GeneralWidgets;
+ UIWidgets m_UiWidgets;
+ ClassWidgets m_ClassWidgets;
+ Settings::OptionState *m_pOptionState;
+ CodeGenerationOptionsPage * m_pCodeGenPage;
+ CodeViewerOptionsPage * m_pCodeViewerPage;
+
+ KConfig * m_pCfg;
+ bool m_bChangesApplied;
+
+private slots:
+ void slotApply();
+ void slotOk();
+ void slotDefault();
+ void slotLineBClicked();
+ void slotFillBClicked();
+ void slotAutosaveCBClicked();
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/statedialog.cpp b/umbrello/umbrello/dialogs/statedialog.cpp
new file mode 100644
index 00000000..691597e9
--- /dev/null
+++ b/umbrello/umbrello/dialogs/statedialog.cpp
@@ -0,0 +1,147 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "statedialog.h"
+
+//qt includes
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qmultilineedit.h>
+#include <qgroupbox.h>
+
+//kde includes
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kfontdialog.h>
+
+//local includes
+#include "../umlview.h"
+#include "../statewidget.h"
+#include "../dialog_utils.h"
+
+StateDialog::StateDialog( UMLView * pView, StateWidget * pWidget )
+ : KDialogBase(IconList, i18n("Properties"), Ok | Apply | Cancel | Help, Ok, pView, "_STATEDIALOG_", true, true) {
+ m_pActivityPage = 0;
+ m_pView = pView;
+ m_pStateWidget = pWidget;
+ m_bChangesMade = false;
+ setupPages();
+}
+
+void StateDialog::slotOk() {
+ applyPage( GeneralPage );
+ applyPage( Activity_Page );
+ applyPage( ColorPage );
+ applyPage( FontPage );
+ accept();
+}
+
+void StateDialog::slotApply() {
+ applyPage( (Page) activePageIndex() );
+}
+
+void StateDialog::setupPages() {
+ setupGeneralPage();
+ if( m_pStateWidget -> getStateType() == StateWidget::Normal )
+ setupActivityPage();
+ setupColorPage();
+ setupFontPage();
+}
+
+void StateDialog::applyPage( Page page ) {
+ m_bChangesMade = true;
+ switch( page ) {
+ case GeneralPage:
+ m_pStateWidget -> setName( m_GenPageWidgets.nameLE -> text() );
+ m_pStateWidget -> setDoc( m_GenPageWidgets.docMLE -> text() );
+ break;
+
+ case Activity_Page:
+ if( m_pActivityPage )
+ m_pActivityPage -> updateActivities();
+ break;
+
+ case ColorPage:
+ m_pColorPage -> updateUMLWidget();
+ break;
+
+ case FontPage:
+ m_pStateWidget -> setFont( m_pChooser -> font() );
+ break;
+ }//end switch
+}
+
+void StateDialog::setupGeneralPage() {
+ QString types[ ] = { i18n("Initial state"), i18n("State"), i18n("End state") };
+ StateWidget::StateType type = m_pStateWidget -> getStateType();
+
+ QVBox * page = addVBoxPage( i18n("General"), i18n("General Properties"), DesktopIcon( "misc") );
+ m_GenPageWidgets.generalGB = new QGroupBox( i18n( "Properties"), (QWidget *)page );
+
+ QGridLayout * generalLayout = new QGridLayout( m_GenPageWidgets.generalGB, 2, 2 );
+ generalLayout -> setSpacing( spacingHint() );
+ generalLayout -> setMargin( fontMetrics().height() );
+
+ Dialog_Utils::makeLabeledEditField( m_GenPageWidgets.generalGB, generalLayout, 0,
+ m_GenPageWidgets.typeL, i18n("State type:"),
+ m_GenPageWidgets.typeLE, types[ (int)type ] );
+ m_GenPageWidgets.typeLE -> setEnabled( false );
+
+ Dialog_Utils::makeLabeledEditField( m_GenPageWidgets.generalGB, generalLayout, 1,
+ m_GenPageWidgets.nameL, i18n("State name:"),
+ m_GenPageWidgets.nameLE );
+
+ m_GenPageWidgets.docGB = new QGroupBox( i18n( "Documentation"), (QWidget *)page );
+
+ QHBoxLayout * docLayout = new QHBoxLayout( m_GenPageWidgets.docGB );
+ docLayout -> setSpacing( spacingHint() );
+ docLayout -> setMargin( fontMetrics().height() );
+
+ m_GenPageWidgets.docMLE = new QMultiLineEdit( m_GenPageWidgets.docGB );
+ m_GenPageWidgets.docMLE -> setText( m_pStateWidget -> getDoc() );
+ docLayout -> addWidget( m_GenPageWidgets.docMLE );
+
+ if( type != StateWidget::Normal ) {
+ m_GenPageWidgets.nameLE -> setEnabled( false );
+ m_GenPageWidgets.nameLE -> setText( "" );
+ } else
+ m_GenPageWidgets.nameLE -> setText( m_pStateWidget -> getName() );
+}
+
+void StateDialog::setupFontPage() {
+ if ( !m_pStateWidget )
+ return;
+ QVBox * page = addVBoxPage( i18n("Font"), i18n("Font Settings"), DesktopIcon( "fonts") );
+ m_pChooser = new KFontChooser( (QWidget*)page, "font", false, QStringList(), false);
+ m_pChooser -> setFont( m_pStateWidget -> getFont() );
+}
+
+void StateDialog::setupColorPage() {
+ QFrame * colorPage = addPage( i18n("Color"), i18n("Widget Color"), DesktopIcon( "colors") );
+ QHBoxLayout * m_pColorLayout = new QHBoxLayout(colorPage);
+ m_pColorPage = new UMLWidgetColorPage( colorPage, m_pStateWidget );
+ m_pColorLayout -> addWidget(m_pColorPage);
+}
+
+void StateDialog::setupActivityPage() {
+ QFrame * activityPage = addPage( i18n("Activities"), i18n("Activities"), DesktopIcon( "misc") );
+ QHBoxLayout * activityLayout = new QHBoxLayout( activityPage );
+ m_pActivityPage = new ActivityPage( activityPage, m_pStateWidget );
+ activityLayout -> addWidget( m_pActivityPage );
+}
+
+
+
+
+
+#include "statedialog.moc"
diff --git a/umbrello/umbrello/dialogs/statedialog.h b/umbrello/umbrello/dialogs/statedialog.h
new file mode 100644
index 00000000..d364d6be
--- /dev/null
+++ b/umbrello/umbrello/dialogs/statedialog.h
@@ -0,0 +1,144 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef STATEDIALOG_H
+#define STATEDIALOG_H
+
+//kde class includes
+#include <kdialogbase.h>
+
+//local class includes
+#include "umlwidgetcolorpage.h"
+#include "activitypage.h"
+
+//forward declarations
+class UMLView;
+class StateWidget;
+class QLabel;
+class QLineEdit;
+class QMultiLineEdit;
+class QGroupBox;
+class KFontChooser;
+
+/**
+ * Displays the properties for a @ref StateWidget
+ *
+ * @author Paul Hensgen
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+
+class StateDialog : public KDialogBase {
+ Q_OBJECT
+
+public:
+ /**
+ * Constructor
+ */
+ StateDialog( UMLView * pView, StateWidget * pWidget );
+
+ /**
+ * Returns whether changes were made.
+ */
+ bool getChangesMade() {
+ return m_bChangesMade;
+ }
+
+protected slots:
+
+ enum Page
+ {
+ GeneralPage = 0,
+ Activity_Page,
+ ColorPage,
+ FontPage
+ };
+
+ /**
+ * Entered when OK button pressed.
+ */
+ void slotOk();
+
+ /**
+ * Entered when Apply button pressed.
+ */
+ void slotApply();
+protected:
+ /**
+ * Sets up the pages of the dialog.
+ */
+ void setupPages();
+
+ /**
+ * Sets up the general page of the dialog.
+ */
+ void setupGeneralPage();
+
+ /**
+ * Sets up the color page.
+ */
+ void setupColorPage();
+
+ /**
+ * Sets up the font selection page.
+ */
+ void setupFontPage();
+
+ /**
+ * Sets up the activity page.
+ */
+ void setupActivityPage();
+
+ /**
+ * Applys changes to the given page.
+ */
+ void applyPage( Page page );
+
+ /**
+ * Font chooser widget for font page.
+ */
+ KFontChooser * m_pChooser;
+
+ /**
+ * Color page
+ */
+ UMLWidgetColorPage * m_pColorPage;
+
+ /**
+ * Activity page.
+ */
+ ActivityPage * m_pActivityPage;
+
+ /**
+ * The widget to represent.
+ */
+ StateWidget * m_pStateWidget;
+
+ /**
+ * The diagram the widget is on.
+ */
+ UMLView * m_pView;
+
+ /**
+ * Holds whether changes in the dialog have been made.
+ */
+ bool m_bChangesMade;
+
+ struct GeneralPageWidgets {
+ QLabel * nameL, * typeL;
+ QLineEdit * nameLE, * typeLE;
+ QMultiLineEdit * docMLE;
+
+ QGroupBox * docGB, * generalGB;
+ }
+ m_GenPageWidgets;
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/umlattributedialog.cpp b/umbrello/umbrello/dialogs/umlattributedialog.cpp
new file mode 100644
index 00000000..e6a52725
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umlattributedialog.cpp
@@ -0,0 +1,235 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "umlattributedialog.h"
+
+// qt includes
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qcheckbox.h>
+#include <qgroupbox.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+#include <qlabel.h>
+
+// kde includes
+#include <kcombobox.h>
+#include <kcompletion.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+
+// app includes
+#include "../attribute.h"
+#include "../classifier.h"
+#include "../template.h"
+#include "../umldoc.h"
+#include "../uml.h"
+#include "../dialog_utils.h"
+#include "../object_factory.h"
+#include "../codeimport/import_utils.h"
+
+UMLAttributeDialog::UMLAttributeDialog( QWidget * pParent, UMLAttribute * pAttribute )
+ : KDialogBase( Plain, i18n("Attribute Properties"), Help | Ok | Cancel , Ok, pParent, "_UMLATTRIBUTEDLG_", true, true) {
+ m_pAttribute = pAttribute;
+ setupDialog();
+}
+
+UMLAttributeDialog::~UMLAttributeDialog() {}
+
+void UMLAttributeDialog::setupDialog() {
+ UMLDoc * pDoc = UMLApp::app()->getDocument();
+ int margin = fontMetrics().height();
+
+ QVBoxLayout * mainLayout = new QVBoxLayout( plainPage() );
+
+ m_pValuesGB = new QGroupBox(i18n("General Properties"), plainPage() );
+ QGridLayout * valuesLayout = new QGridLayout(m_pValuesGB, 5, 2);
+ valuesLayout -> setMargin(margin);
+ valuesLayout -> setSpacing(10);
+
+ m_pTypeL = new QLabel(i18n("&Type:"), m_pValuesGB);
+ valuesLayout -> addWidget(m_pTypeL, 0, 0);
+
+ m_pTypeCB = new KComboBox(true, m_pValuesGB);
+ valuesLayout -> addWidget(m_pTypeCB, 0, 1);
+ m_pTypeL->setBuddy(m_pTypeCB);
+
+ Dialog_Utils::makeLabeledEditField( m_pValuesGB, valuesLayout, 1,
+ m_pNameL, i18n("&Name:"),
+ m_pNameLE, m_pAttribute->getName() );
+
+ Dialog_Utils::makeLabeledEditField( m_pValuesGB, valuesLayout, 2,
+ m_pInitialL, i18n("&Initial value:"),
+ m_pInitialLE, m_pAttribute->getInitialValue() );
+
+ Dialog_Utils::makeLabeledEditField( m_pValuesGB, valuesLayout, 3,
+ m_pStereoTypeL, i18n("Stereotype name:"),
+ m_pStereoTypeLE, m_pAttribute->getStereotype() );
+
+ m_pStaticCB = new QCheckBox( i18n("Classifier &scope (\"static\")"), m_pValuesGB );
+ m_pStaticCB -> setChecked( m_pAttribute -> getStatic() );
+ valuesLayout -> addWidget(m_pStaticCB, 4, 0);
+
+
+ mainLayout -> addWidget(m_pValuesGB);
+
+
+ m_pScopeBG = new QButtonGroup(i18n("Visibility"), plainPage() );
+ QHBoxLayout * scopeLayout = new QHBoxLayout(m_pScopeBG);
+ scopeLayout -> setMargin(margin);
+
+ m_pPublicRB = new QRadioButton(i18n("&Public"), m_pScopeBG);
+ scopeLayout -> addWidget(m_pPublicRB);
+
+ m_pPrivateRB = new QRadioButton(i18n("P&rivate"), m_pScopeBG);
+ scopeLayout -> addWidget(m_pPrivateRB);
+
+ m_pProtectedRB = new QRadioButton(i18n("Prot&ected"), m_pScopeBG);
+ scopeLayout -> addWidget(m_pProtectedRB);
+
+ m_pImplementationRB = new QRadioButton(i18n("I&mplementation"), m_pScopeBG);
+ scopeLayout -> addWidget(m_pImplementationRB);
+
+ mainLayout -> addWidget(m_pScopeBG);
+ Uml::Visibility scope = m_pAttribute -> getVisibility();
+ if( scope == Uml::Visibility::Public )
+ m_pPublicRB -> setChecked( true );
+ else if( scope == Uml::Visibility::Private )
+ m_pPrivateRB -> setChecked( true );
+ else if( scope == Uml::Visibility::Protected )
+ m_pProtectedRB -> setChecked( true );
+ else if( scope == Uml::Visibility::Implementation )
+ m_pImplementationRB -> setChecked( true );
+
+ m_pTypeCB->setDuplicatesEnabled(false);//only allow one of each type in box
+ m_pTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
+
+ //now add the Concepts
+ UMLClassifierList namesList( pDoc->getConcepts() );
+ UMLClassifier* obj;
+ for (obj=namesList.first(); obj!=0; obj=namesList.next()) {
+ insertType( obj->getFullyQualifiedName() );
+ }
+
+ //work out which one to select
+ int typeBoxCount = 0;
+ bool foundType = false;
+ while (typeBoxCount < m_pTypeCB->count() && foundType == false) {
+ QString typeBoxString = m_pTypeCB->text(typeBoxCount);
+ if ( typeBoxString == m_pAttribute->getTypeName() ) {
+ foundType = true;
+ m_pTypeCB->setCurrentItem(typeBoxCount);
+ } else {
+ typeBoxCount++;
+ }
+ }
+
+ if (!foundType) {
+ insertType( m_pAttribute->getTypeName(), 0 );
+ m_pTypeCB->setCurrentItem(0);
+ }
+
+ m_pNameLE->setFocus();
+ connect( m_pNameLE, SIGNAL( textChanged ( const QString & ) ), SLOT( slotNameChanged( const QString & ) ) );
+ slotNameChanged(m_pNameLE->text() );
+}
+
+void UMLAttributeDialog::slotNameChanged( const QString &_text )
+{
+ enableButtonOK( !_text.isEmpty() );
+}
+
+bool UMLAttributeDialog::apply() {
+ QString name = m_pNameLE->text();
+ if (name.isEmpty()) {
+ KMessageBox::error(this, i18n("You have entered an invalid attribute name."),
+ i18n("Attribute Name Invalid"), false);
+ m_pNameLE->setText( m_pAttribute->getName() );
+ return false;
+ }
+ UMLClassifier * pConcept = dynamic_cast<UMLClassifier *>( m_pAttribute->parent() );
+ UMLObject *o = pConcept->findChildObject(name);
+ if (o && o != m_pAttribute) {
+ KMessageBox::error(this, i18n("The attribute name you have chosen is already being used in this operation."),
+ i18n("Attribute Name Not Unique"), false);
+ m_pNameLE->setText( m_pAttribute->getName() );
+ return false;
+ }
+ m_pAttribute->setName(name);
+ Uml::Visibility scope = Uml::Visibility::Protected;
+ if ( m_pPublicRB->isChecked() ) {
+ scope = Uml::Visibility::Public;
+ } else if ( m_pPrivateRB->isChecked() ) {
+ scope = Uml::Visibility::Private;
+ } else if ( m_pImplementationRB->isChecked() ) {
+ scope = Uml::Visibility::Implementation;
+ }
+ m_pAttribute->setVisibility(scope);
+ // Set the scope as the default in the option state
+ Settings::OptionState optionState = Settings::getOptionState();
+ optionState.classState.defaultAttributeScope = scope;
+ Settings::setOptionState(optionState);
+
+ m_pAttribute->setInitialValue( m_pInitialLE->text() );
+ m_pAttribute->setStereotype( m_pStereoTypeLE->text() );
+ m_pAttribute->setStatic( m_pStaticCB->isChecked() );
+
+ QString typeName = m_pTypeCB->currentText();
+ UMLTemplate *tmplParam = pConcept->findTemplate(typeName);
+ if (tmplParam) {
+ m_pAttribute->setType(tmplParam);
+ return true;
+ }
+ UMLDoc * pDoc = UMLApp::app()->getDocument();
+ UMLObject *obj = pDoc->findUMLObject(typeName);
+ UMLClassifier *classifier = dynamic_cast<UMLClassifier*>(obj);
+ if (classifier == NULL) {
+ Uml::Programming_Language pl = UMLApp::app()->getActiveLanguage();
+ if (pl == Uml::pl_Cpp || pl == Uml::pl_Java) {
+ // Import_Utils::createUMLObject works better for C++ namespace and java package than Object_Factory::createUMLObject
+
+ Import_Utils::setRelatedClassifier(pConcept);
+ obj = Import_Utils::createUMLObject(Uml::ot_UMLObject, typeName);
+ Import_Utils::setRelatedClassifier(NULL);
+ } else {
+ // If it's obviously a pointer type (C++) then create a datatype.
+ // Else we don't know what it is so as a compromise create a class.
+ Uml::Object_Type ot = (typeName.contains('*') ? Uml::ot_Datatype : Uml::ot_Class);
+ obj = Object_Factory::createUMLObject(ot, typeName);
+ }
+ if (obj == NULL)
+ return false;
+ classifier = static_cast<UMLClassifier*>(obj);
+ }
+ m_pAttribute->setType( classifier );
+ return true;
+}
+
+void UMLAttributeDialog::slotApply() {
+ apply();
+}
+
+void UMLAttributeDialog::slotOk() {
+ if ( apply() ) {
+ accept();
+ }
+}
+
+void UMLAttributeDialog::insertType( const QString& type, int index )
+{
+ m_pTypeCB->insertItem( type, index );
+ m_pTypeCB->completionObject()->addItem( type );
+}
+
+
+#include "umlattributedialog.moc"
diff --git a/umbrello/umbrello/dialogs/umlattributedialog.h b/umbrello/umbrello/dialogs/umlattributedialog.h
new file mode 100644
index 00000000..92305d61
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umlattributedialog.h
@@ -0,0 +1,81 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef UMLATTRIBUTEDIALOG_H
+#define UMLATTRIBUTEDIALOG_H
+
+#include <kdialogbase.h>
+
+/**
+ * @author Paul Hensgen
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+
+class QButtonGroup;
+class QCheckBox;
+class QGroupBox;
+class QRadioButton;
+class UMLAttribute;
+class KComboBox;
+class QLineEdit;
+
+class UMLAttributeDialog : public KDialogBase {
+ Q_OBJECT
+public:
+ UMLAttributeDialog( QWidget * pParent, UMLAttribute * pAttribute );
+ ~UMLAttributeDialog();
+
+protected:
+ /**
+ * Sets up the dialog
+ */
+ void setupDialog();
+
+ /**
+ * Checks if changes are valid and applies them if they are,
+ * else returns false
+ */
+ bool apply();
+
+ /**
+ * Inserts @p type into the type-combobox as well as its completion object.
+ */
+ void insertType( const QString& type, int index = -1 );
+
+ /**
+ * The Attribute to represent
+ */
+ UMLAttribute * m_pAttribute;
+
+ //GUI Widgets
+ QGroupBox * m_pAttsGB, * m_pValuesGB;
+ QButtonGroup * m_pScopeBG;
+ QRadioButton * m_pPublicRB, * m_pPrivateRB, * m_pProtectedRB, * m_pImplementationRB;
+ QLabel * m_pTypeL, * m_pNameL, * m_pInitialL, * m_pStereoTypeL;
+ KComboBox * m_pTypeCB;
+ QLineEdit * m_pNameLE, * m_pInitialLE, * m_pStereoTypeLE;
+ QCheckBox* m_pStaticCB;
+
+public slots:
+ /**
+ * I don't think this is used, but if we had an apply button
+ * it would slot into here
+ */
+ void slotApply();
+
+ /**
+ * Used when the OK button is clicked. Calls apply()
+ */
+ void slotOk();
+ void slotNameChanged( const QString & );
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/umlentityattributedialog.cpp b/umbrello/umbrello/dialogs/umlentityattributedialog.cpp
new file mode 100644
index 00000000..ef6a5791
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umlentityattributedialog.cpp
@@ -0,0 +1,262 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "umlentityattributedialog.h"
+
+// qt includes
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qcheckbox.h>
+#include <qgroupbox.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+#include <qlabel.h>
+
+// kde includes
+#include <kcombobox.h>
+#include <kcompletion.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kapplication.h>
+#include <kdebug.h>
+
+// app includes
+#include "../entityattribute.h"
+#include "../classifier.h"
+#include "../umldoc.h"
+#include "../uml.h"
+#include "../codegenerator.h"
+#include "../dialog_utils.h"
+#include "../object_factory.h"
+#include "../umlclassifierlist.h"
+
+UMLEntityAttributeDialog::UMLEntityAttributeDialog( QWidget * pParent, UMLEntityAttribute * pEntityAttribute )
+ : KDialogBase( Plain, i18n("Entity Attribute Properties"), Help | Ok | Cancel , Ok, pParent, "_UMLENTITYATTRIBUTEDLG_", true, true) {
+ m_pEntityAttribute = pEntityAttribute;
+ setupDialog();
+}
+
+UMLEntityAttributeDialog::~UMLEntityAttributeDialog() {}
+
+void UMLEntityAttributeDialog::setupDialog() {
+ UMLDoc * pDoc = UMLApp::app()->getDocument();
+ int margin = fontMetrics().height();
+
+ QVBoxLayout * mainLayout = new QVBoxLayout( plainPage() );
+
+ m_pValuesGB = new QGroupBox(i18n("General Properties"), plainPage() );
+ QGridLayout * valuesLayout = new QGridLayout(m_pValuesGB, 5, 2);
+ valuesLayout -> setMargin(margin);
+ valuesLayout -> setSpacing(10);
+
+ m_pTypeL = new QLabel(i18n("&Type:"), m_pValuesGB);
+ valuesLayout -> addWidget(m_pTypeL, 0, 0);
+
+ m_pTypeCB = new KComboBox(true, m_pValuesGB);
+ valuesLayout -> addWidget(m_pTypeCB, 0, 1);
+ m_pTypeL->setBuddy(m_pTypeCB);
+
+ Dialog_Utils::makeLabeledEditField( m_pValuesGB, valuesLayout, 1,
+ m_pNameL, i18n("&Name:"),
+ m_pNameLE, m_pEntityAttribute->getName() );
+
+ Dialog_Utils::makeLabeledEditField( m_pValuesGB, valuesLayout, 2,
+ m_pInitialL, i18n("&Default value:"),
+ m_pInitialLE, m_pEntityAttribute->getInitialValue() );
+
+ Dialog_Utils::makeLabeledEditField( m_pValuesGB, valuesLayout, 3,
+ m_pStereoTypeL, i18n("Stereotype name:"),
+ m_pStereoTypeLE, m_pEntityAttribute->getStereotype() );
+
+ Dialog_Utils::makeLabeledEditField( m_pValuesGB, valuesLayout, 4,
+ m_pValuesL, i18n("Length/Values:"),
+ m_pValuesLE, m_pEntityAttribute->getValues() );
+
+ m_pAutoIncrementCB = new QCheckBox( i18n("&Auto increment"), m_pValuesGB );
+ m_pAutoIncrementCB->setChecked( m_pEntityAttribute->getAutoIncrement() );
+ valuesLayout->addWidget(m_pAutoIncrementCB, 5, 0);
+
+ m_pNullCB = new QCheckBox( i18n("Allow &null"), m_pValuesGB );
+ m_pNullCB->setChecked( m_pEntityAttribute->getNull() );
+ valuesLayout->addWidget(m_pNullCB, 6, 0);
+
+ m_pAttributesL = new QLabel(i18n("Attributes:"), m_pValuesGB);
+ valuesLayout->addWidget(m_pAttributesL, 7, 0);
+
+ m_pAttributesCB = new KComboBox(true, m_pValuesGB);
+ m_pAttributesCB->setCompletionMode( KGlobalSettings::CompletionPopup );
+ valuesLayout->addWidget(m_pAttributesCB, 7, 1);
+ m_pTypeL->setBuddy(m_pAttributesCB);
+
+ insertAttribute( m_pEntityAttribute->getAttributes() );
+ insertAttribute("");
+ insertAttribute("binary");
+ insertAttribute("unsigned");
+ insertAttribute("unsigned zerofill");
+
+ mainLayout -> addWidget(m_pValuesGB);
+
+ m_pScopeBG = new QButtonGroup(i18n("Indexing"), plainPage() );
+ QHBoxLayout* scopeLayout = new QHBoxLayout(m_pScopeBG);
+ scopeLayout->setMargin(margin);
+
+ m_pNoneRB = new QRadioButton(i18n("&None"), m_pScopeBG);
+ scopeLayout->addWidget(m_pNoneRB);
+
+ m_pPublicRB = new QRadioButton(i18n("&Primary"), m_pScopeBG);
+ scopeLayout->addWidget(m_pPublicRB);
+
+ m_pPrivateRB = new QRadioButton(i18n("&Index"), m_pScopeBG);
+ scopeLayout->addWidget(m_pPrivateRB);
+
+ m_pProtectedRB = new QRadioButton(i18n("&Unique"), m_pScopeBG);
+ scopeLayout->addWidget(m_pProtectedRB);
+
+ mainLayout->addWidget(m_pScopeBG);
+ Uml::DBIndex_Type scope = m_pEntityAttribute->getIndexType();
+ if ( scope == Uml::Primary )
+ m_pPublicRB->setChecked( true );
+ else if( scope == Uml::Index )
+ m_pPrivateRB -> setChecked( true );
+ else if( scope == Uml::Unique )
+ m_pProtectedRB -> setChecked( true );
+ else {
+ m_pNoneRB->setChecked(true);
+ }
+
+ m_pTypeCB->setDuplicatesEnabled(false);//only allow one of each type in box
+ m_pTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
+
+ // Add the data types.
+ UMLClassifierList dataTypes = pDoc->getDatatypes();
+ if (dataTypes.count() == 0) {
+ // Switch to SQL as the active language if no datatypes are set.
+ UMLApp::app()->setActiveLanguage("SQL");
+ pDoc->addDefaultDatatypes();
+ kapp->processEvents();
+ dataTypes = pDoc->getDatatypes();
+ }
+ UMLClassifier *dat;
+ for (UMLClassifierListIt dit(dataTypes); (dat = dit.current()) != NULL; ++dit) {
+ insertType(dat->getName());
+ }
+
+ //work out which one to select
+ int typeBoxCount = 0;
+ bool foundType = false;
+ while (typeBoxCount < m_pTypeCB->count() && foundType == false) {
+ QString typeBoxString = m_pTypeCB->text(typeBoxCount);
+ if ( typeBoxString == m_pEntityAttribute->getTypeName() ) {
+ foundType = true;
+ m_pTypeCB->setCurrentItem(typeBoxCount);
+ } else {
+ typeBoxCount++;
+ }
+ }
+
+ if (!foundType) {
+ insertType( m_pEntityAttribute->getTypeName(), 0 );
+ m_pTypeCB->setCurrentItem(0);
+ }
+
+ m_pNameLE->setFocus();
+ connect( m_pNameLE, SIGNAL( textChanged ( const QString & ) ), SLOT( slotNameChanged( const QString & ) ) );
+ slotNameChanged(m_pNameLE->text() );
+}
+
+void UMLEntityAttributeDialog::slotNameChanged( const QString &_text )
+{
+ enableButtonOK( !_text.isEmpty() );
+}
+
+bool UMLEntityAttributeDialog::apply() {
+ QString name = m_pNameLE->text();
+ if (name.isEmpty()) {
+ KMessageBox::error(this, i18n("You have entered an invalid entity attribute name."),
+ i18n("Entity Attribute Name Invalid"), false);
+ m_pNameLE->setText( m_pEntityAttribute->getName() );
+ return false;
+ }
+ UMLClassifier * pConcept = dynamic_cast<UMLClassifier *>( m_pEntityAttribute->parent() );
+ UMLObject *o = pConcept->findChildObject(name);
+ if (o && o != m_pEntityAttribute) {
+ KMessageBox::error(this, i18n("The entity attribute name you have chosen is already being used in this operation."),
+ i18n("Entity Attribute Name Not Unique"), false);
+ m_pNameLE->setText( m_pEntityAttribute->getName() );
+ return false;
+ }
+ m_pEntityAttribute->setName(name);
+ m_pEntityAttribute->setInitialValue( m_pInitialLE->text() );
+ m_pEntityAttribute->setStereotype( m_pStereoTypeLE->text() );
+ m_pEntityAttribute->setValues( m_pValuesLE->text() );
+ m_pEntityAttribute->setAttributes( m_pAttributesCB->currentText() );
+ m_pEntityAttribute->setAutoIncrement( m_pAutoIncrementCB->isChecked() );
+ m_pEntityAttribute->setNull( m_pNullCB->isChecked() );
+
+ if ( m_pPublicRB->isChecked() ) {
+ m_pEntityAttribute->setIndexType(Uml::Primary);
+ } else if ( m_pPrivateRB -> isChecked() ) {
+ m_pEntityAttribute->setIndexType(Uml::Index);
+ } else if ( m_pProtectedRB -> isChecked() ) {
+ m_pEntityAttribute->setIndexType(Uml::Unique);
+ } else {
+ m_pEntityAttribute->setIndexType(Uml::None);
+ }
+
+ QString typeName = m_pTypeCB->currentText();
+ UMLDoc *pDoc = UMLApp::app()->getDocument();
+ UMLClassifierList dataTypes = pDoc->getDatatypes();
+ UMLClassifier *dat;
+ for (UMLClassifierListIt dit(dataTypes); (dat = dit.current()) != NULL; ++dit) {
+ if (typeName == dat->getName()) {
+ m_pEntityAttribute->setType(dat);
+ return true;
+ }
+ }
+ UMLObject *obj = pDoc->findUMLObject(typeName);
+ UMLClassifier *classifier = dynamic_cast<UMLClassifier*>(obj);
+ if (classifier == NULL) {
+ // If it's obviously a pointer type (C++) then create a datatype.
+ // Else we don't know what it is so as a compromise create a class.
+ Uml::Object_Type ot = (typeName.contains('*') ? Uml::ot_Datatype
+ : Uml::ot_Class);
+ obj = Object_Factory::createUMLObject(ot, typeName);
+ if (obj == NULL)
+ return false;
+ classifier = static_cast<UMLClassifier*>(obj);
+ }
+ m_pEntityAttribute->setType( classifier );
+ return true;
+}
+
+void UMLEntityAttributeDialog::slotApply() {
+ apply();
+}
+
+void UMLEntityAttributeDialog::slotOk() {
+ if ( apply() ) {
+ accept();
+ }
+}
+
+void UMLEntityAttributeDialog::insertType( const QString& type, int index ) {
+ m_pTypeCB->insertItem( type, index );
+ m_pTypeCB->completionObject()->addItem( type );
+}
+
+void UMLEntityAttributeDialog::insertAttribute( const QString& type, int index ) {
+ m_pAttributesCB->insertItem( type, index );
+ m_pAttributesCB->completionObject()->addItem( type );
+}
+
+
+#include "umlentityattributedialog.moc"
diff --git a/umbrello/umbrello/dialogs/umlentityattributedialog.h b/umbrello/umbrello/dialogs/umlentityattributedialog.h
new file mode 100644
index 00000000..0b81472e
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umlentityattributedialog.h
@@ -0,0 +1,87 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef UMLENTITYATTRIBUTEDIALOG_H
+#define UMLENTITYATTRIBUTEDIALOG_H
+
+#include <kdialogbase.h>
+
+/**
+ * @author Jonathan Riddell
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+
+class QButtonGroup;
+class QCheckBox;
+class QGroupBox;
+class QRadioButton;
+class UMLEntityAttribute;
+class KComboBox;
+class QLineEdit;
+
+class UMLEntityAttributeDialog : public KDialogBase {
+ Q_OBJECT
+public:
+ UMLEntityAttributeDialog( QWidget* pParent, UMLEntityAttribute* pEntityAttribute );
+ ~UMLEntityAttributeDialog();
+
+protected:
+ /**
+ * Sets up the dialog
+ */
+ void setupDialog();
+
+ /**
+ * Checks if changes are valid and applies them if they are,
+ * else returns false
+ */
+ bool apply();
+
+ /**
+ * Inserts @p type into the type-combobox as well as its completion object.
+ */
+ void insertType( const QString& type, int index = -1 );
+ /**
+ * Inserts @p type into the type-combobox as well as its completion object.
+ */
+ void insertAttribute( const QString& type, int index = -1 );
+
+ /**
+ * The EntityAttribute to represent
+ */
+ UMLEntityAttribute * m_pEntityAttribute;
+
+ //GUI Widgets
+ QGroupBox * m_pAttsGB, * m_pValuesGB;
+ QButtonGroup * m_pScopeBG;
+ QRadioButton * m_pPublicRB, * m_pPrivateRB, * m_pProtectedRB, * m_pNoneRB;
+ QLabel * m_pTypeL, * m_pNameL, * m_pInitialL, * m_pStereoTypeL, * m_pValuesL, * m_pAttributesL ;
+ KComboBox * m_pTypeCB;
+ KComboBox * m_pAttributesCB;
+ QLineEdit * m_pNameLE, * m_pInitialLE, * m_pStereoTypeLE, * m_pValuesLE;
+ QCheckBox* m_pAutoIncrementCB;
+ QCheckBox* m_pNullCB;
+
+public slots:
+ /**
+ * I don't think this is used, but if we had an apply button
+ * it would slot into here
+ */
+ void slotApply();
+
+ /**
+ * Used when the OK button is clicked. Calls apply()
+ */
+ void slotOk();
+ void slotNameChanged( const QString & );
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/umloperationdialog.cpp b/umbrello/umbrello/dialogs/umloperationdialog.cpp
new file mode 100644
index 00000000..07c56d52
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umloperationdialog.cpp
@@ -0,0 +1,530 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "umloperationdialog.h"
+
+//qt includes
+#include <qlayout.h>
+#include <qgroupbox.h>
+#include <qlistbox.h>
+#include <qbuttongroup.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qlabel.h>
+#include <qcheckbox.h>
+#include <qlineedit.h>
+
+//kde includes
+#include <kcombobox.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kbuttonbox.h>
+#include <karrowbutton.h>
+
+//app includes
+#include "../uml.h"
+#include "../umldoc.h"
+#include "../operation.h"
+#include "../classifier.h"
+#include "../template.h"
+#include "../listpopupmenu.h"
+#include "../umlattributelist.h"
+#include "../classifierlistitem.h"
+#include "../umlclassifierlistitemlist.h"
+#include "../dialog_utils.h"
+#include "parmpropdlg.h"
+#include "../stereotype.h"
+#include "../uniqueid.h"
+
+UMLOperationDialog::UMLOperationDialog( QWidget * parent, UMLOperation * pOperation )
+ : KDialogBase( Plain, i18n("Operation Properties"), Help | Ok | Cancel , Ok, parent, "_UMLOPERATIONDLG_", true, true) {
+ m_pOperation = pOperation;
+ m_doc = UMLApp::app()->getDocument();
+ m_pMenu = 0;
+ setupDialog();
+}
+
+UMLOperationDialog::~UMLOperationDialog() {}
+
+void UMLOperationDialog::setupDialog() {
+
+ int margin = fontMetrics().height();
+ QVBoxLayout * topLayout = new QVBoxLayout( plainPage() );
+
+ m_pGenGB = new QGroupBox(i18n("General Properties"), plainPage() );
+ QGridLayout * genLayout = new QGridLayout(m_pGenGB, 3, 4 );
+ genLayout -> setColStretch(1, 1);
+ genLayout -> setColStretch(3, 1);
+ genLayout -> addColSpacing(1, 200);
+ genLayout -> addColSpacing(3, 200);
+ genLayout -> setMargin(margin);
+ genLayout -> setSpacing(10);
+
+ Dialog_Utils::makeLabeledEditField( m_pGenGB, genLayout, 0,
+ m_pNameL, i18n("&Name:"),
+ m_pNameLE, m_pOperation->getName() );
+
+ m_pRtypeL = new QLabel(i18n("&Type:"), m_pGenGB );
+ genLayout -> addWidget(m_pRtypeL, 0, 2);
+
+ m_pRtypeCB = new KComboBox(true, m_pGenGB );
+ genLayout -> addWidget(m_pRtypeCB, 0, 3);
+ m_pRtypeL->setBuddy(m_pRtypeCB);
+
+ m_pStereoTypeL = new QLabel( i18n("Stereotype name:"), m_pGenGB );
+ genLayout -> addWidget(m_pStereoTypeL, 1, 0);
+ m_pStereoTypeCB = new KComboBox(true, m_pGenGB );
+ genLayout -> addWidget(m_pStereoTypeCB, 1, 1);
+
+ m_pAbstractCB = new QCheckBox( i18n("&Abstract operation"), m_pGenGB );
+ m_pAbstractCB -> setChecked( m_pOperation->getAbstract() );
+ genLayout -> addWidget( m_pAbstractCB, 2, 0 );
+ m_pStaticCB = new QCheckBox( i18n("Classifier &scope (\"static\")"), m_pGenGB );
+ m_pStaticCB -> setChecked( m_pOperation->getStatic() );
+ genLayout -> addWidget( m_pStaticCB, 2, 1 );
+ m_pQueryCB = new QCheckBox( i18n("&Query (\"const\")"), m_pGenGB );
+ m_pQueryCB -> setChecked( m_pOperation->getConst() );
+ genLayout -> addWidget( m_pQueryCB, 2, 2 );
+
+ topLayout -> addWidget( m_pGenGB );
+
+ m_pScopeBG = new QButtonGroup(i18n("Visibility"), plainPage() );
+
+ QHBoxLayout * scopeLayout = new QHBoxLayout(m_pScopeBG);
+ scopeLayout -> setMargin(margin);
+
+ m_pPublicRB = new QRadioButton(i18n("P&ublic"), m_pScopeBG);
+ scopeLayout -> addWidget(m_pPublicRB);
+
+ m_pPrivateRB = new QRadioButton(i18n("P&rivate"), m_pScopeBG);
+ scopeLayout -> addWidget(m_pPrivateRB);
+
+ m_pProtectedRB = new QRadioButton(i18n("Prot&ected"), m_pScopeBG);
+ scopeLayout -> addWidget(m_pProtectedRB);
+
+ m_pImplementationRB = new QRadioButton(i18n("I&mplementation"), m_pScopeBG);
+ scopeLayout -> addWidget(m_pImplementationRB);
+
+ topLayout -> addWidget(m_pScopeBG);
+
+ m_pParmsGB = new QGroupBox(i18n("Parameters"), plainPage() );
+ QVBoxLayout* parmsLayout = new QVBoxLayout(m_pParmsGB);
+ parmsLayout->setMargin(margin);
+ parmsLayout->setSpacing(10);
+
+ //horizontal box contains the list box and the move up/down buttons
+ QHBoxLayout* parmsHBoxLayout = new QHBoxLayout(parmsLayout);
+ m_pParmsLB = new QListBox(m_pParmsGB);
+ parmsHBoxLayout->addWidget(m_pParmsLB);
+
+ //the move up/down buttons (another vertical box)
+ QVBoxLayout* buttonLayout = new QVBoxLayout( parmsHBoxLayout );
+ m_pUpButton = new KArrowButton( m_pParmsGB );
+ m_pUpButton->setEnabled( false );
+ buttonLayout->addWidget( m_pUpButton );
+
+ m_pDownButton = new KArrowButton( m_pParmsGB, Qt::DownArrow );
+ m_pDownButton->setEnabled( false );
+ buttonLayout->addWidget( m_pDownButton );
+
+ KButtonBox* buttonBox = new KButtonBox(m_pParmsGB);
+ buttonBox->addButton( i18n("Ne&w Parameter..."), this, SLOT(slotNewParameter()) );
+ m_pDeleteButton = buttonBox->addButton( i18n("&Delete"), this, SLOT(slotDeleteParameter()) );
+ m_pPropertiesButton = buttonBox->addButton( i18n("&Properties"), this,
+ SLOT(slotParameterProperties()) );
+ parmsLayout->addWidget(buttonBox);
+
+ topLayout -> addWidget(m_pParmsGB);
+
+ m_pDeleteButton->setEnabled(false);
+ m_pPropertiesButton->setEnabled(false);
+ m_pUpButton->setEnabled(false);
+ m_pDownButton->setEnabled(false);
+
+ // Add "void". We use this for denoting "no return type" independent
+ // of the programming language.
+ // For example, the Ada generator would interpret the return type
+ // "void" as an instruction to generate a procedure instead of a
+ // function.
+ insertType( "void" );
+
+ m_pRtypeCB->setDuplicatesEnabled(false);//only allow one of each type in box
+ m_pRtypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
+
+ // add template parameters
+ UMLClassifier *classifier = dynamic_cast<UMLClassifier*>(m_pOperation->parent());
+ if (classifier) {
+ UMLClassifierListItemList tmplParams( classifier->getFilteredList(Uml::ot_Template) );
+ for (UMLClassifierListItem *li = tmplParams.first(); li; li = tmplParams.next())
+ insertType( li->getName() );
+ }
+ //now add the Classes and Interfaces (both are Concepts)
+ UMLClassifierList namesList( m_doc->getConcepts() );
+ UMLClassifier* pConcept = 0;
+ for(pConcept=namesList.first(); pConcept!=0 ;pConcept=namesList.next()) {
+ insertType( pConcept->getFullyQualifiedName() );
+ }
+
+ //work out which one to select
+ int returnBoxCount = 0;
+ bool foundReturnType = false;
+ while (returnBoxCount < m_pRtypeCB->count() && foundReturnType == false) {
+ QString returnBoxString = m_pRtypeCB->text(returnBoxCount);
+ if ( returnBoxString == m_pOperation->getTypeName() ) {
+ foundReturnType = true;
+ m_pRtypeCB->setCurrentItem(returnBoxCount);
+ break;
+ }
+ returnBoxCount++;
+ }
+
+ if (!foundReturnType) {
+ insertType( m_pOperation->getTypeName(), 0 );
+ m_pRtypeCB->setCurrentItem(0);
+ }
+
+ //fill in parm list box
+ UMLAttributeList list = m_pOperation->getParmList();
+ UMLAttribute * pAtt = 0;
+ for (pAtt = list.first(); pAtt; pAtt = list.next())
+ m_pParmsLB->insertItem( pAtt->getName() );
+
+ //set scope
+ Uml::Visibility scope = m_pOperation -> getVisibility();
+ if( scope == Uml::Visibility::Public )
+ m_pPublicRB -> setChecked( true );
+ else if( scope == Uml::Visibility::Private )
+ m_pPrivateRB -> setChecked( true );
+ else if( scope == Uml::Visibility::Protected )
+ m_pProtectedRB -> setChecked( true );
+ else if( scope == Uml::Visibility::Implementation )
+ m_pImplementationRB -> setChecked( true );
+
+ // manage stereotypes
+ m_pStereoTypeCB -> setDuplicatesEnabled(false);//only allow one of each type in box
+ m_pStereoTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
+ insertStereotype (QString("")); // an empty stereotype is the default
+ int defaultStereotype=0;
+ bool foundDefaultStereotype = false;
+ for (UMLStereotypeListIt it(m_doc->getStereotypes()); it.current(); ++it) {
+ if (!foundDefaultStereotype) {
+ if ( m_pOperation->getStereotype() == it.current()->getName()) {
+ foundDefaultStereotype = true;
+ }
+ defaultStereotype++;
+ }
+ insertStereotype (it.current()->getName());
+ }
+ // lookup for a default stereotype, if the operation doesn't have one
+ if (foundDefaultStereotype)
+ m_pStereoTypeCB->setCurrentItem(defaultStereotype);
+ else
+ m_pStereoTypeCB->setCurrentItem(-1);
+
+ //setup parm list box signals
+ connect( m_pUpButton, SIGNAL( clicked() ), this, SLOT( slotParameterUp() ) );
+ connect( m_pDownButton, SIGNAL( clicked() ), this, SLOT( slotParameterDown() ) );
+
+ connect(m_pParmsLB, SIGNAL(clicked(QListBoxItem*)),
+ this, SLOT(slotParamsBoxClicked(QListBoxItem*)));
+
+ connect(m_pParmsLB, SIGNAL(rightButtonPressed(QListBoxItem *, const QPoint &)),
+ this, SLOT(slotParmRightButtonPressed(QListBoxItem *, const QPoint &)));
+
+ connect(m_pParmsLB, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)),
+ this, SLOT(slotParmRightButtonClicked(QListBoxItem *, const QPoint &)));
+
+
+ connect(m_pParmsLB, SIGNAL(doubleClicked(QListBoxItem *)),
+ this, SLOT(slotParmDoubleClick(QListBoxItem *)));
+
+ m_pNameLE->setFocus();
+ connect( m_pNameLE, SIGNAL( textChanged ( const QString & ) ), SLOT( slotNameChanged( const QString & ) ) );
+ slotNameChanged(m_pNameLE->text() );
+
+}
+
+void UMLOperationDialog::slotNameChanged( const QString &_text )
+{
+ enableButtonOK( !_text.isEmpty() );
+}
+
+
+void UMLOperationDialog::slotParmRightButtonPressed(QListBoxItem *item, const QPoint &p) {
+ ListPopupMenu::Menu_Type type = ListPopupMenu::mt_Undefined;
+ if(item)//pressed on an item
+ {
+ type = ListPopupMenu::mt_Parameter_Selected;
+ } else//pressed into fresh air
+ {
+ type = ListPopupMenu::mt_New_Parameter;
+ }
+ if(m_pMenu) {
+ m_pMenu -> hide();
+ disconnect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotParmPopupMenuSel(int)));
+ delete m_pMenu;
+ m_pMenu = 0;
+ }
+ m_pMenu = new ListPopupMenu(this, type);
+ m_pMenu->popup(p);
+ connect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotParmPopupMenuSel(int)));
+
+}
+
+void UMLOperationDialog::slotParmRightButtonClicked(QListBoxItem */*item*/, const QPoint &/*p*/) {
+ if(m_pMenu) {
+ m_pMenu -> hide();
+ disconnect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotParmPopupMenuSel(int)));
+ delete m_pMenu;
+ m_pMenu = 0;
+ }
+}
+
+void UMLOperationDialog::slotParmDoubleClick(QListBoxItem *item) {
+ if(!item)
+ return;
+ slotParmPopupMenuSel(ListPopupMenu::mt_Properties);
+}
+
+void UMLOperationDialog::slotParmPopupMenuSel(int id) {
+ if( id == ListPopupMenu::mt_Rename || id == ListPopupMenu::mt_Properties ) {
+ slotParameterProperties();
+ } else if( id == ListPopupMenu::mt_New_Parameter ) {
+ slotNewParameter();
+ }
+ else if( id == ListPopupMenu::mt_Delete ) {
+ slotDeleteParameter();
+ }
+}
+
+void UMLOperationDialog::slotNewParameter() {
+ int result = 0;
+ UMLAttribute* pAtt = 0;
+
+ QString currentName = m_pOperation->getUniqueParameterName();
+ UMLAttribute* newAttribute = new UMLAttribute(m_pOperation, currentName, Uml::id_Reserved);
+
+ ParmPropDlg dlg(this, m_doc, newAttribute);
+ result = dlg.exec();
+ QString name = dlg.getName();
+ pAtt = m_pOperation -> findParm( name );
+ if( result ) {
+ if( name.length() == 0 ) {
+ KMessageBox::error(this, i18n("You have entered an invalid parameter name."),
+ i18n("Parameter Name Invalid"), false);
+ delete newAttribute;
+ return;
+ }
+ if( !pAtt ) {
+ newAttribute->setID( UniqueID::gen() );
+ newAttribute->setName( name );
+ newAttribute->setTypeName( dlg.getTypeName() );
+ newAttribute->setInitialValue( dlg.getInitialValue() );
+ newAttribute->setDoc( dlg.getDoc() );
+ newAttribute->setParmKind( dlg.getParmKind() );
+ m_pOperation->addParm( newAttribute );
+ m_pParmsLB -> insertItem( name );
+ m_doc -> setModified( true );
+ } else {
+ KMessageBox::sorry(this, i18n("The parameter name you have chosen\nis already being used in this operation."),
+ i18n("Parameter Name Not Unique"), false);
+ delete newAttribute;
+ }
+ } else {
+ delete newAttribute;
+ }
+}
+
+void UMLOperationDialog::slotDeleteParameter() {
+ UMLAttribute* pOldAtt = m_pOperation->findParm( m_pParmsLB->currentText() );
+
+ m_pOperation->removeParm( pOldAtt );
+ m_pParmsLB->removeItem( m_pParmsLB->currentItem() );
+ m_doc->setModified(true);
+
+ m_pDeleteButton->setEnabled(false);
+ m_pPropertiesButton->setEnabled(false);
+ m_pUpButton->setEnabled(false);
+ m_pDownButton->setEnabled(false);
+}
+
+void UMLOperationDialog::slotParameterProperties() {
+ int result = 0;
+ UMLAttribute* pAtt = 0, * pOldAtt = 0;
+ pOldAtt = m_pOperation->findParm( m_pParmsLB->currentText() );
+
+ if( !pOldAtt ) {
+ kDebug() << "THE impossible has occurred for:" << m_pParmsLB->currentText() << endl;
+ return;
+ }//should never occur
+ ParmPropDlg dlg(this, m_doc, pOldAtt);
+ result = dlg.exec();
+ QString name = dlg.getName();
+ pAtt = m_pOperation->findParm( name );
+ if( result ) {
+ if( name.length() == 0 ) {
+ KMessageBox::error(this, i18n("You have entered an invalid parameter name."),
+ i18n("Parameter Name Invalid"), false);
+ return;
+ }
+ if ( !pAtt || pOldAtt->getTypeName() != dlg.getTypeName() ||
+ pOldAtt->getDoc() != dlg.getDoc() ||
+ pOldAtt->getInitialValue() != dlg.getInitialValue() ) {
+ pOldAtt->setName( name );
+ QString typeName = dlg.getTypeName();
+ if (pOldAtt->getTypeName() != typeName) {
+ UMLClassifierList namesList( m_doc->getConcepts() );
+ UMLClassifier* obj = NULL;
+ for (obj=namesList.first(); obj!=0; obj=namesList.next()) {
+ if (typeName == obj->getFullyQualifiedName()) {
+ pOldAtt->setType( obj );
+ break;
+ }
+ }
+ if (obj == NULL) {
+ // Nothing found: set type name directly. Bad.
+ kDebug() << "UMLOperationDialog::slotParameterProperties: "
+ << typeName << " not found." << endl;
+ pOldAtt->setTypeName( typeName ); // Bad.
+ }
+ }
+ m_pParmsLB->changeItem( dlg.getName(), m_pParmsLB -> currentItem() );
+ pOldAtt->setDoc( dlg.getDoc() );
+ pOldAtt->setInitialValue( dlg.getInitialValue() );
+ m_doc->setModified( true );
+ } else if( pAtt != pOldAtt ) {
+ KMessageBox::error(this, i18n("The parameter name you have chosen is already being used in this operation."),
+ i18n("Parameter Name Not Unique"), false);
+ }
+ }
+}
+
+void UMLOperationDialog::slotParameterUp()
+{
+ kDebug() << k_funcinfo << endl;
+ UMLAttribute* pOldAtt = m_pOperation->findParm( m_pParmsLB->currentText() );
+
+ m_pOperation->moveParmLeft( pOldAtt );
+ QString tmp = m_pParmsLB->currentText();
+ m_pParmsLB->changeItem( m_pParmsLB->item( m_pParmsLB->currentItem() - 1 )->text(), m_pParmsLB->currentItem() );
+ m_pParmsLB->changeItem( tmp, m_pParmsLB->currentItem() - 1 );
+ m_doc->setModified(true);
+ slotParamsBoxClicked( m_pParmsLB->selectedItem() );
+}
+
+void UMLOperationDialog::slotParameterDown()
+{
+ UMLAttribute* pOldAtt = m_pOperation->findParm( m_pParmsLB->currentText() );
+
+ m_pOperation->moveParmRight( pOldAtt );
+ QString tmp = m_pParmsLB->currentText();
+ m_pParmsLB->changeItem( m_pParmsLB->item( m_pParmsLB->currentItem() + 1 )->text(), m_pParmsLB->currentItem() );
+ m_pParmsLB->changeItem( tmp, m_pParmsLB->currentItem() + 1 );
+
+ m_doc->setModified(true);
+ slotParamsBoxClicked( m_pParmsLB->selectedItem() );
+}
+
+void UMLOperationDialog::slotParamsBoxClicked(QListBoxItem* parameterItem) {
+ if (parameterItem) {
+ m_pDeleteButton->setEnabled(true);
+ m_pPropertiesButton->setEnabled(true);
+ m_pUpButton->setEnabled( parameterItem->prev() );
+ m_pDownButton->setEnabled( parameterItem->next() );
+ } else {
+ m_pDeleteButton->setEnabled(false);
+ m_pPropertiesButton->setEnabled(false);
+ m_pUpButton->setEnabled(false);
+ m_pDownButton->setEnabled(false);
+ }
+}
+
+bool UMLOperationDialog::apply()
+{
+ QString name = m_pNameLE -> text();
+ if( name.length() == 0 ) {
+ KMessageBox::error(this, i18n("You have entered an invalid operation name."),
+ i18n("Operation Name Invalid"), false);
+ m_pNameLE -> setText( m_pOperation -> getName() );
+ return false;
+ }
+
+ UMLClassifier *classifier = dynamic_cast<UMLClassifier*>( m_pOperation->parent() );
+ if( classifier != 0L &&
+ classifier->checkOperationSignature(name, m_pOperation->getParmList(), m_pOperation) )
+ {
+ QString msg = QString(i18n("An operation with that signature already exists in %1.\n")).arg(classifier->getName())
+ +
+ QString(i18n("Choose a different name or parameter list." ));
+ KMessageBox::error(this, msg, i18n("Operation Name Invalid"), false);
+ return false;
+ }
+ m_pOperation -> setName( name );
+
+ if( m_pPublicRB -> isChecked() )
+ m_pOperation -> setVisibility( Uml::Visibility::Public );
+ else if( m_pPrivateRB -> isChecked() )
+ m_pOperation -> setVisibility( Uml::Visibility::Private );
+ else if (m_pProtectedRB -> isChecked() )
+ m_pOperation -> setVisibility( Uml::Visibility::Protected );
+ else if (m_pImplementationRB -> isChecked() )
+ m_pOperation -> setVisibility( Uml::Visibility::Implementation );
+
+ QString typeName = m_pRtypeCB->currentText();
+ UMLTemplate *tmplParam = classifier->findTemplate(typeName);
+ if (tmplParam)
+ m_pOperation->setType(tmplParam);
+ else
+ m_pOperation->setTypeName(typeName);
+
+ m_pOperation->setStereotype( m_pStereoTypeCB->currentText() );
+
+ bool isAbstract = m_pAbstractCB->isChecked();
+ m_pOperation -> setAbstract( isAbstract );
+ if (isAbstract) {
+ /* If any operation is abstract then the owning class needs
+ to be made abstract.
+ The inverse is not true: The fact that no operation is
+ abstract does not mean that the class must be non-abstract.
+ */
+ classifier->setAbstract(true);
+ }
+ m_pOperation->setStatic( m_pStaticCB->isChecked() );
+ m_pOperation->setConst( m_pQueryCB->isChecked() );
+
+ return true;
+}
+
+void UMLOperationDialog::slotApply() {
+ apply();
+}
+
+void UMLOperationDialog::slotOk() {
+ if ( apply() ) {
+ accept();
+ }
+}
+
+void UMLOperationDialog::insertType( const QString& type, int index )
+{
+ m_pRtypeCB->insertItem( type, index );
+ m_pRtypeCB->completionObject()->addItem( type );
+}
+
+void UMLOperationDialog::insertStereotype( const QString& type, int index )
+{
+ m_pStereoTypeCB->insertItem( type, index );
+ m_pStereoTypeCB->completionObject()->addItem( type );
+}
+
+#include "umloperationdialog.moc"
diff --git a/umbrello/umbrello/dialogs/umloperationdialog.h b/umbrello/umbrello/dialogs/umloperationdialog.h
new file mode 100644
index 00000000..1dee99ab
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umloperationdialog.h
@@ -0,0 +1,135 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+
+#ifndef UMLOPERATIONDIALOG_H
+#define UMLOPERATIONDIALOG_H
+
+//kde includes
+#include <kdialogbase.h>
+
+/**
+ * @author Paul Hensgen
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+
+class UMLOperation;
+class ListPopupMenu;
+class QGroupBox;
+class QListBox;
+class QButtonGroup;
+class QRadioButton;
+class QPushButton;
+class QLabel;
+class QCheckBox;
+class KComboBox;
+class QLineEdit;
+class UMLDoc;
+class KArrowButton;
+
+class UMLOperationDialog : public KDialogBase {
+ Q_OBJECT
+
+public:
+ /**
+ * Constructor
+ */
+ UMLOperationDialog( QWidget * parent, UMLOperation * pOperation );
+
+ /**
+ * Deconstructor
+ */
+ ~UMLOperationDialog();
+
+protected:
+ /**
+ * Sets up the dialog
+ */
+ void setupDialog();
+
+ /**
+ * Checks if changes are valid and applies them if they are,
+ * else returns false
+ */
+ bool apply();
+
+ /**
+ * Inserts @p type into the type-combobox as well as its completion object.
+ */
+ void insertType( const QString& type, int index = -1 );
+
+ /**
+ * The operation to represent.
+ */
+ UMLOperation * m_pOperation;
+
+ /**
+ * The UMLDocument where all objects live
+ */
+ UMLDoc *m_doc;
+
+ /**
+ * Menu used in paramater list box.
+ */
+ ListPopupMenu * m_pMenu;
+
+ /**
+ * Inserts @p stereotype into the stereotype-combobox as well as its completion object.
+ */
+ void insertStereotype( const QString& type, int index = -1 );
+
+ //GUI widgets
+ QGroupBox * m_pParmsGB, * m_pGenGB;
+ QListBox * m_pParmsLB;
+ QButtonGroup * m_pScopeBG;
+ QRadioButton * m_pPublicRB, * m_pPrivateRB, * m_pProtectedRB, *m_pImplementationRB;
+ QLabel * m_pRtypeL, * m_pNameL, * m_pStereoTypeL;
+ KComboBox * m_pRtypeCB, * m_pStereoTypeCB;
+ QLineEdit * m_pNameLE;
+ QCheckBox * m_pAbstractCB;
+ QCheckBox * m_pStaticCB;
+ QCheckBox * m_pQueryCB;
+ QPushButton* m_pDeleteButton;
+ QPushButton* m_pPropertiesButton;
+ KArrowButton* m_pUpButton;
+ KArrowButton* m_pDownButton;
+
+public slots:
+ void slotParmRightButtonPressed(QListBoxItem *item, const QPoint &p);
+ void slotParmRightButtonClicked(QListBoxItem *item, const QPoint &p);
+ void slotParmDoubleClick(QListBoxItem *item);
+ void slotParmPopupMenuSel(int id);
+ void slotNewParameter();
+ void slotDeleteParameter();
+ void slotParameterProperties();
+ void slotParameterUp();
+ void slotParameterDown();
+
+ /**
+ * enables or disables buttons
+ */
+ void slotParamsBoxClicked(QListBoxItem* parameterItem);
+
+ /**
+ * I don't think this is used, but if we had an apply button
+ * it would slot into here
+ */
+ void slotApply();
+
+ /**
+ * Used when the OK button is clicked. Calls apply()
+ */
+ void slotOk();
+ void slotNameChanged( const QString & );
+
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/umlroledialog.cpp b/umbrello/umbrello/dialogs/umlroledialog.cpp
new file mode 100644
index 00000000..91ad5c65
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umlroledialog.cpp
@@ -0,0 +1,63 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "umlroledialog.h"
+
+// qt/kde includes
+#include <qlayout.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+// app includes
+#include "../umlrole.h"
+#include "umlroleproperties.h"
+
+UMLRoleDialog::UMLRoleDialog( QWidget * parent, UMLRole * pRole )
+ : KDialogBase( Plain, i18n("Role Properties"), Help | Ok | Cancel , Ok, parent, "_UMLROLEDLG_", true, true)
+{
+ m_pRole = pRole;
+ setupDialog();
+}
+
+UMLRoleDialog::~UMLRoleDialog() {}
+
+void UMLRoleDialog::setupDialog() {
+ // UMLRoleDialogLayout = new QGridLayout( this, 1, 1, 11, 6, "UMLRoleLayout");
+ m_pRoleProps = new UMLRoleProperties(this, m_pRole);
+ setMainWidget( m_pRoleProps );
+
+ resize( QSize(425, 620).expandedTo(minimumSizeHint()) );
+
+ // topLayout -> addWidget( m_pParmsGB);
+
+}
+
+bool UMLRoleDialog::apply() {
+ if( m_pRoleProps ) {
+ m_pRoleProps->updateObject();
+ return true;
+ }
+ return false;
+}
+
+void UMLRoleDialog::slotApply() {
+ apply();
+}
+
+void UMLRoleDialog::slotOk() {
+ if ( apply() ) {
+ accept();
+ }
+}
+
+
+#include "umlroledialog.moc"
diff --git a/umbrello/umbrello/dialogs/umlroledialog.h b/umbrello/umbrello/dialogs/umlroledialog.h
new file mode 100644
index 00000000..09856d34
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umlroledialog.h
@@ -0,0 +1,75 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+
+#ifndef UMLROLEDIALOG_H
+#define UMLROLEDIALOG_H
+
+//kde includes
+#include <kdialogbase.h>
+
+/**
+ * @author Paul Hensgen
+ */
+
+class UMLRole;
+class UMLRoleProperties;
+
+class UMLRoleDialog : public KDialogBase {
+ Q_OBJECT
+public:
+ /**
+ * Constructor
+ */
+ UMLRoleDialog( QWidget * parent, UMLRole * pRole );
+
+ /**
+ * Deconstructor
+ */
+ ~UMLRoleDialog();
+
+protected:
+
+ /**
+ * Sets up the dialog
+ */
+ void setupDialog();
+
+ /**
+ * Checks if changes are valid and applies them if they are,
+ * else returns false
+ */
+ bool apply();
+
+ /**
+ * The role to represent.
+ */
+ UMLRole * m_pRole;
+
+private:
+
+ UMLRoleProperties * m_pRoleProps;
+
+public slots:
+
+ /**
+ * I don't think this is used, but if we had an apply button
+ * it would slot into here
+ */
+ void slotApply();
+
+ /**
+ * Used when the OK button is clicked. Calls apply()
+ */
+ void slotOk();
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/umlroleproperties.cpp b/umbrello/umbrello/dialogs/umlroleproperties.cpp
new file mode 100644
index 00000000..275d98f1
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umlroleproperties.cpp
@@ -0,0 +1,114 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "umlroleproperties.h"
+
+// qt/kde includes
+#include <qradiobutton.h>
+#include <qtextedit.h>
+#include <qlineedit.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+
+
+UMLRoleProperties::UMLRoleProperties ( QWidget *parent, UMLRole *role)
+ : UMLRolePropertiesBase (parent)
+{
+
+ m_pRole = role;
+ constructWidget();
+
+}
+
+UMLRoleProperties::~UMLRoleProperties() { }
+
+void UMLRoleProperties::constructWidget() {
+
+ // Use Parent Role to set starting Properties
+ //
+
+ // Rolename
+ m_pRoleLE -> setText(m_pRole->getName());
+
+ // Multiplicity
+ m_pMultiLE -> setText(m_pRole->getMultiplicity());
+
+ // Visibility
+ Uml::Visibility scope = m_pRole->getVisibility();
+ if( scope == Uml::Visibility::Public )
+ m_pPublicRB -> setChecked( true );
+ else if( scope == Uml::Visibility::Private )
+ m_pPrivateRB -> setChecked( true );
+ else if( scope == Uml::Visibility::Protected )
+ m_pProtectedRB -> setChecked( true );
+ else if( scope == Uml::Visibility::Implementation )
+ m_pImplementationRB -> setChecked( true );
+
+ // Changeability
+ Uml::Changeability_Type changeability = m_pRole->getChangeability();
+ if( changeability == Uml::chg_Changeable )
+ m_pChangeableRB -> setChecked( true );
+ else if( changeability == Uml::chg_Frozen )
+ m_pFrozenRB -> setChecked( true );
+ else
+ m_pAddOnlyRB -> setChecked( true );
+
+ // Documentation
+ //
+ m_pDocTE-> setText(m_pRole-> getDoc());
+ //m_pDocTE->setWordWrap(QMultiLineEdit::WidgetWidth);
+}
+
+void UMLRoleProperties::updateObject() {
+
+ if(m_pRole) {
+
+ // block signals to save work load..we only need to emit modified once,
+ // not each time we update an attribute of the association. I suppose
+ // we could check to see IF anything changed, but thats a lot more code,
+ // and not much gained. THis way is easier, if less 'beautiful'. -b.t.
+
+ m_pRole->blockSignals(true);
+
+ // set props
+ m_pRole->setName(m_pRoleLE->text());
+ m_pRole->setMultiplicity(m_pMultiLE->text());
+
+ if(m_pPrivateRB->isChecked())
+ m_pRole->setVisibility(Uml::Visibility::Private);
+ else if(m_pProtectedRB->isChecked())
+ m_pRole->setVisibility(Uml::Visibility::Protected);
+ else if(m_pPublicRB->isChecked())
+ m_pRole->setVisibility(Uml::Visibility::Public);
+ else if(m_pImplementationRB->isChecked())
+ m_pRole->setVisibility(Uml::Visibility::Implementation);
+
+ if(m_pFrozenRB->isChecked())
+ m_pRole->setChangeability(Uml::chg_Frozen);
+ else if(m_pAddOnlyRB->isChecked())
+ m_pRole->setChangeability(Uml::chg_AddOnly);
+ else
+ m_pRole->setChangeability(Uml::chg_Changeable);
+
+ m_pRole->setDoc(m_pDocTE->text());
+
+ m_pRole->blockSignals(false);
+
+ m_pRole->emitModified();
+
+ } //end if m_pRole
+
+}
+
+
+#include "umlroleproperties.moc"
diff --git a/umbrello/umbrello/dialogs/umlroleproperties.h b/umbrello/umbrello/dialogs/umlroleproperties.h
new file mode 100644
index 00000000..34f7d3e9
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umlroleproperties.h
@@ -0,0 +1,59 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef UMLROLEPROPERTIES_H
+#define UMLROLEPROPERTIES_H
+
+//my class includes
+#include "umlrolepropertiesbase.h"
+#include "../umlrole.h"
+
+/**
+ * Displays properties of a UMLRole in a widget which may be used as
+ * a properties page or a stand-alone dialog.
+ *
+ * @author Brian Thomas <brian.thomas@gsfc.nasa.gov>
+ */
+class UMLRoleProperties : public UMLRolePropertiesBase {
+ Q_OBJECT
+public:
+
+ /**
+ * Sets up the UMLRoleProperties.
+ *
+ * @param parent The parent widget to the UMLRoleProperties.
+ * @param role The UMLRole to display the properties of.
+ */
+ UMLRoleProperties( QWidget *parent, UMLRole *role);
+
+ /**
+ * Standard deconstructor.
+ */
+ ~UMLRoleProperties();
+
+ /**
+ * Will move information from the dialog into the object.
+ * Call when the ok or apply button is pressed.
+ */
+ void updateObject();
+
+protected:
+
+ // the parent role object
+ UMLRole * m_pRole;
+
+private:
+
+ void constructWidget();
+
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/umlrolepropertiesbase.ui b/umbrello/umbrello/dialogs/umlrolepropertiesbase.ui
new file mode 100644
index 00000000..7c35a284
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umlrolepropertiesbase.ui
@@ -0,0 +1,203 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>UMLRolePropertiesBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>UMLRolePropertiesBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>572</width>
+ <height>545</height>
+ </rect>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>400</width>
+ <height>520</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>propsGroupBox</cstring>
+ </property>
+ <property name="title">
+ <string>Role Properties</string>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>30</y>
+ <width>360</width>
+ <height>70</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>roleNameLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Rolename:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>m_pMultiLE</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>m_pRoleLE</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Multiplicity:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ <widget class="QGroupBox" row="3" column="0">
+ <property name="name">
+ <cstring>docGroupBox</cstring>
+ </property>
+ <property name="title">
+ <string>Documentation</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QTextEdit" row="0" column="0">
+ <property name="name">
+ <cstring>m_pDocTE</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QButtonGroup" row="2" column="0">
+ <property name="name">
+ <cstring>changeabilityButtonGroup</cstring>
+ </property>
+ <property name="title">
+ <string>Role Changeability</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton" row="0" column="2">
+ <property name="name">
+ <cstring>m_pAddOnlyRB</cstring>
+ </property>
+ <property name="text">
+ <string>Add only</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="0" column="1">
+ <property name="name">
+ <cstring>m_pFrozenRB</cstring>
+ </property>
+ <property name="text">
+ <string>Frozen</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>m_pChangeableRB</cstring>
+ </property>
+ <property name="text">
+ <string>Changeable</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QButtonGroup" row="1" column="0">
+ <property name="name">
+ <cstring>visibilityButtonGroup</cstring>
+ </property>
+ <property name="title">
+ <string>Role Visibility</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>m_pPublicRB</cstring>
+ </property>
+ <property name="text">
+ <string>Public</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="0" column="1">
+ <property name="name">
+ <cstring>m_pPrivateRB</cstring>
+ </property>
+ <property name="text">
+ <string>Private</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="0" column="2">
+ <property name="name">
+ <cstring>m_pProtectedRB</cstring>
+ </property>
+ <property name="text">
+ <string>Protected</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="0" column="3">
+ <property name="name">
+ <cstring>m_pImplementationRB</cstring>
+ </property>
+ <property name="text">
+ <string>Implementation</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/umbrello/umbrello/dialogs/umltemplatedialog.cpp b/umbrello/umbrello/dialogs/umltemplatedialog.cpp
new file mode 100644
index 00000000..a183d95d
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umltemplatedialog.cpp
@@ -0,0 +1,161 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "umltemplatedialog.h"
+
+// qt includes
+#include <qlayout.h>
+#include <qgroupbox.h>
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+
+// kde includes
+#include <kcombobox.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+
+// app includes
+#include "../template.h"
+#include "../classifier.h"
+#include "../umldoc.h"
+#include "../uml.h"
+#include "../dialog_utils.h"
+
+UMLTemplateDialog::UMLTemplateDialog(QWidget* pParent, UMLTemplate* pTemplate)
+ : KDialogBase( Plain, i18n("Template Properties"), Help | Ok | Cancel , Ok, pParent, "_UMLTemplateDLG_", true, true) {
+ m_pTemplate = pTemplate;
+ setupDialog();
+}
+
+UMLTemplateDialog::~UMLTemplateDialog() {}
+
+void UMLTemplateDialog::setupDialog() {
+ int margin = fontMetrics().height();
+
+ QVBoxLayout* mainLayout = new QVBoxLayout( plainPage() );
+
+ m_pValuesGB = new QGroupBox(i18n("General Properties"), plainPage() );
+ QGridLayout* valuesLayout = new QGridLayout(m_pValuesGB, 3, 2);
+ valuesLayout->setMargin(margin);
+ valuesLayout->setSpacing(10);
+
+ m_pTypeL = new QLabel(i18n("&Type:"), m_pValuesGB);
+ valuesLayout->addWidget(m_pTypeL, 0, 0);
+
+ m_pTypeCB = new KComboBox(m_pValuesGB);
+ valuesLayout->addWidget(m_pTypeCB, 0, 1);
+ m_pTypeL->setBuddy(m_pTypeCB);
+
+ Dialog_Utils::makeLabeledEditField( m_pValuesGB, valuesLayout, 1,
+ m_pNameL, i18n("&Name:"),
+ m_pNameLE, m_pTemplate->getName() );
+
+ Dialog_Utils::makeLabeledEditField( m_pValuesGB, valuesLayout, 2,
+ m_pStereoTypeL, i18n("&Stereotype name:"),
+ m_pStereoTypeLE, m_pTemplate->getStereotype() );
+
+ mainLayout->addWidget(m_pValuesGB);
+
+ // "class" is the nominal type of template parameter
+ insertType( "class" );
+ // Add the active data types to combo box
+ UMLDoc *pDoc = UMLApp::app()->getDocument();
+ UMLClassifierList namesList( pDoc->getConcepts() );
+ UMLClassifier* obj = 0;
+ for (obj = namesList.first(); obj; obj = namesList.next()) {
+ insertType( obj->getName() );
+ }
+
+ m_pTypeCB->setEditable(true);
+ m_pTypeCB->setDuplicatesEnabled(false);//only allow one of each type in box
+ m_pTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
+// m_pTypeCB->setAutoCompletion(true);
+
+ //work out which one to select
+ int typeBoxCount = 0;
+ bool foundType = false;
+ while (typeBoxCount < m_pTypeCB->count() && foundType == false) {
+ QString typeBoxString = m_pTypeCB->text(typeBoxCount);
+ if ( typeBoxString == m_pTemplate->getTypeName() ) {
+ foundType = true;
+ m_pTypeCB->setCurrentItem(typeBoxCount);
+ } else {
+ typeBoxCount++;
+ }
+ }
+
+ if (!foundType) {
+ insertType( m_pTemplate->getTypeName(), 0 );
+ m_pTypeCB->setCurrentItem(0);
+ }
+
+ m_pNameLE->setFocus();
+}
+
+void UMLTemplateDialog::insertType( const QString& type, int index )
+{
+ m_pTypeCB->insertItem( type, index );
+ m_pTypeCB->completionObject()->addItem( type );
+}
+
+bool UMLTemplateDialog::apply() {
+ QString typeName = m_pTypeCB->currentText();
+ UMLDoc *pDoc = UMLApp::app()->getDocument();
+ UMLClassifierList namesList( pDoc->getConcepts() );
+ UMLClassifier* obj = 0;
+ for (obj = namesList.first(); obj; obj = namesList.next()) {
+ if (typeName == obj->getName()) {
+ m_pTemplate->setType( obj );
+ }
+ }
+ if (obj == NULL) { // not found.
+ // FIXME: This implementation is not good yet.
+ m_pTemplate->setTypeName( typeName );
+ }
+ QString name = m_pNameLE->text();
+ if( name.length() == 0 ) {
+ KMessageBox::error(this, i18n("You have entered an invalid template name."),
+ i18n("Template Name Invalid"), false);
+ m_pNameLE->setText( m_pTemplate->getName() );
+ return false;
+ }
+
+ UMLClassifier * pClass = dynamic_cast<UMLClassifier *>( m_pTemplate->parent() );
+ if (pClass) {
+ UMLObject *o = pClass->findChildObject(name);
+ if (o && o != m_pTemplate) {
+ KMessageBox::error(this, i18n("The template parameter name you have chosen is already being used in this operation."),
+ i18n("Template Name Not Unique"), false);
+ m_pNameLE->setText( m_pTemplate->getName() );
+ return false;
+ }
+ }
+ m_pTemplate->setName(name);
+
+ m_pTemplate->setStereotype( m_pStereoTypeLE->text() );
+
+ return true;
+}
+
+void UMLTemplateDialog::slotApply() {
+ apply();
+}
+
+void UMLTemplateDialog::slotOk() {
+ if ( apply() ) {
+ accept();
+ }
+}
+
+#include "umltemplatedialog.moc"
diff --git a/umbrello/umbrello/dialogs/umltemplatedialog.h b/umbrello/umbrello/dialogs/umltemplatedialog.h
new file mode 100644
index 00000000..3bdd321b
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umltemplatedialog.h
@@ -0,0 +1,81 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef UMLTEMPLATEDIALOG_H
+#define UMLTEMPLATEDIALOG_H
+
+#include <kdialogbase.h>
+
+class QButtonGroup;
+class QCheckBox;
+class KComboBox;
+class QGroupBox;
+class QLineEdit;
+class QRadioButton;
+class UMLTemplate;
+
+/**
+ * A dialog to edit the properties of a class template (paramaterised class)
+ *
+ * @author Jonathan Riddell
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+
+class UMLTemplateDialog : public KDialogBase {
+ Q_OBJECT
+public:
+ UMLTemplateDialog(QWidget* pParent, UMLTemplate* pAttribute);
+ ~UMLTemplateDialog();
+
+protected:
+ /**
+ * Sets up the dialog
+ */
+ void setupDialog();
+
+ /**
+ * Checks if changes are valid and applies them if they are,
+ * else returns false
+ */
+ bool apply();
+
+ /**
+ * The Attribute to represent
+ */
+ UMLTemplate* m_pTemplate;
+
+ //GUI Widgets
+ QGroupBox* m_pTemplateGB;
+ QGroupBox* m_pValuesGB;
+ QLabel *m_pTypeL, *m_pNameL, *m_pStereoTypeL;
+ KComboBox* m_pTypeCB;
+ QLineEdit *m_pNameLE, *m_pStereoTypeLE;
+
+public slots:
+ /**
+ * I don't think this is used, but if we had an apply button
+ * it would slot into here
+ */
+ void slotApply();
+
+ /**
+ * Used when the OK button is clicked. Calls apply()
+ */
+ void slotOk();
+protected:
+ /**
+ * Inserts @p type into the type-combobox as well as its completion object.
+ */
+ void insertType( const QString& type, int index = -1 );
+
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/umlviewdialog.cpp b/umbrello/umbrello/dialogs/umlviewdialog.cpp
new file mode 100644
index 00000000..94f44059
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umlviewdialog.cpp
@@ -0,0 +1,184 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2007 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+// own header
+#include "umlviewdialog.h"
+
+// qt/kde includes
+#include <qvbox.h>
+#include <qlayout.h>
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qgroupbox.h>
+#include <qtextedit.h>
+#include <qspinbox.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kfontdialog.h>
+#include <kdebug.h>
+#include <knuminput.h>
+
+// local includes
+#include "../umlview.h"
+#include "../umldoc.h"
+#include "../uml.h"
+#include "diagrampropertiespage.h"
+
+
+UMLViewDialog::UMLViewDialog( QWidget * pParent, UMLView * pView ) : KDialogBase(IconList, i18n("Properties"), Ok | Apply | Cancel | Help,
+ Ok, pParent, "_VIEWDLG_", true, true) {
+ m_pView = pView;
+ m_options = m_pView -> getOptionState();
+ setupPages();
+}
+
+UMLViewDialog::~UMLViewDialog() {
+}
+
+void UMLViewDialog::slotOk() {
+ applyPage( General );
+ applyPage( Color );
+ applyPage( Font );
+ applyPage( Class );
+ accept();
+}
+
+void UMLViewDialog::slotApply() {
+ applyPage( (Page)activePageIndex() );
+}
+
+void UMLViewDialog::setupPages()
+{
+ setupDiagramPropertiesPage();
+ setupColorPage();
+ setupFontPage();
+ setupClassPage();
+}
+
+void UMLViewDialog::setupDiagramPropertiesPage()
+{
+ QVBox *page = addVBoxPage( i18n("General"), i18n("General Settings"), DesktopIcon( "misc") );
+ m_diagramProperties = new DiagramPropertiesPage(page);
+
+ m_diagramProperties->diagramName->setText( m_pView->getName() );
+ m_diagramProperties->zoom->setValue(m_pView->currentZoom());
+ m_diagramProperties->showOpSigs->setChecked( m_pView->getShowOpSig() );
+
+ m_diagramProperties->showGrid->setChecked(m_pView -> getShowSnapGrid());
+ m_diagramProperties->snapToGrid->setChecked(m_pView-> getSnapToGrid());
+ m_diagramProperties->snapComponentSizeToGrid->setChecked(m_pView-> getSnapComponentSizeToGrid());
+
+ m_diagramProperties->gridSpaceX->setValue( m_pView -> getSnapX());
+ m_diagramProperties->gridSpaceY->setValue( m_pView -> getSnapY());
+ m_diagramProperties->lineWidth->setValue( m_pView -> getLineWidth());
+ m_diagramProperties->documentation->setText(m_pView -> getDoc());
+
+}
+
+void UMLViewDialog::setupClassPage() {
+ if( m_pView -> getType() != Uml::dt_Class ) {
+ return;
+ }
+
+ QFrame * newPage = addPage( i18n("Display"), i18n("Classes Display Options"), DesktopIcon( "info") );
+ QHBoxLayout * m_pOptionsLayout = new QHBoxLayout( newPage );
+ m_pOptionsPage = new ClassOptionsPage( newPage, &m_options );
+ m_pOptionsLayout -> addWidget( m_pOptionsPage );
+}
+
+void UMLViewDialog::setupColorPage() {
+ QFrame * colorPage = addPage( i18n("Color"), i18n("Diagram Colors"), DesktopIcon( "colors") );
+ QHBoxLayout * m_pColorLayout = new QHBoxLayout(colorPage);
+ m_pColorPage = new UMLWidgetColorPage( colorPage, &m_options );
+ m_pColorLayout -> addWidget(m_pColorPage);
+}
+
+void UMLViewDialog::setupFontPage() {
+ QVBox * page = addVBoxPage( i18n("Font"), i18n("Font Settings"), DesktopIcon( "fonts") );
+ m_pChooser = new KFontChooser( (QWidget*)page, "font", false, QStringList(), false);
+ m_pChooser -> setFont( m_pView -> getOptionState().uiState.font );
+}
+
+void UMLViewDialog::applyPage( Page page ) {
+
+ switch (page) {
+ case General:
+ {
+ checkName();
+ m_pView->setZoom( m_diagramProperties->zoom->value() );
+ m_pView->setDoc( m_diagramProperties->documentation->text() );
+ m_pView->setSnapX( m_diagramProperties->gridSpaceX->value() );
+ m_pView->setSnapY( m_diagramProperties->gridSpaceY->value() );
+ m_pView->setLineWidth( m_diagramProperties->lineWidth->value() );
+ m_pView->setSnapToGrid( m_diagramProperties->snapToGrid->isChecked() );
+ m_pView->setSnapComponentSizeToGrid( m_diagramProperties->snapComponentSizeToGrid->isChecked() );
+ m_pView->setShowSnapGrid( m_diagramProperties->showGrid->isChecked() );
+ m_pView->setShowOpSig( m_diagramProperties->showOpSigs->isChecked() );
+ break;
+ }
+ case Color:
+ m_pColorPage->updateUMLWidget();
+ m_pView->setUseFillColor( m_options.uiState.useFillColor );
+ m_pView->setLineColor( m_options.uiState.lineColor );
+ m_pView->setFillColor( m_options.uiState.fillColor );
+ break;
+
+ case Font:
+ kDebug() << "UMLViewDialog::applyPage: setting font "
+ << m_pChooser->font().toString() << endl;
+ m_pView->setFont( m_pChooser->font(), true );
+ break;
+
+ case Class:
+ if( m_pView->getType() != Uml::dt_Class ) {
+ return;
+ }
+ m_pOptionsPage->updateUMLWidget();
+ m_pView->setClassWidgetOptions( m_pOptionsPage );
+ // sig = m_pTempWidget->getShowOpSigs();
+ // showSig = !( sig == Uml::st_NoSig || sig == Uml::st_NoSigNoVis );
+ // options.classState.showOpSig = showSig;
+ // sig = m_pTempWidget->getShowAttSigs();
+ // showSig = !( sig == Uml::st_NoSig || sig == Uml::st_NoSigNoVis );
+ // options.classState.showAttSig = showSig;
+ m_pView->setOptionState( m_options );
+ break;
+ }
+}
+
+void UMLViewDialog::checkName() {
+ QString name = m_diagramProperties->diagramName-> text();
+ UMLDoc * pDoc = UMLApp::app()-> getDocument();
+ UMLView * pView = pDoc -> findView( m_pView -> getType(), name );
+ if( name.length() == 0 ) {
+ KMessageBox::sorry(this, i18n("The name you have entered is invalid."),
+ i18n("Invalid Name"), false);
+ m_diagramProperties->diagramName->setText( m_pView->getName() );
+ return;
+ }
+ if( pView && pView != m_pView ) {
+ KMessageBox::sorry(this, i18n("The name you have entered is not unique."),
+ i18n("Name Not Unique"), false);
+ m_diagramProperties->diagramName->setText( m_pView->getName() );
+ return;
+ }
+ m_pView->setName( name );
+ pDoc->signalDiagramRenamed(m_pView);
+}
+
+
+
+
+
+
+#include "umlviewdialog.moc"
diff --git a/umbrello/umbrello/dialogs/umlviewdialog.h b/umbrello/umbrello/dialogs/umlviewdialog.h
new file mode 100644
index 00000000..b6fe4ebd
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umlviewdialog.h
@@ -0,0 +1,119 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef UMLVIEWDIALOG_H
+#define UMLVIEWDIALOG_H
+//kde includes
+#include <kdialogbase.h>
+//app includes
+#include "classoptionspage.h"
+#include "umlwidgetcolorpage.h"
+#include "../optionstate.h"
+
+/**
+ * @author Paul Hensgen
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class UMLView;
+class ClassWidget;
+
+class QCheckBox;
+class QLabel;
+class QLineEdit;
+class QGroupBox;
+class QTextEdit;
+class QSpinBox;
+class KFontChooser;
+class DiagramPropertiesPage;
+
+
+class UMLViewDialog : public KDialogBase {
+ Q_OBJECT
+public:
+ /**
+ * Constructor
+ */
+ UMLViewDialog( QWidget * pParent, UMLView * pView );
+
+ /**
+ * Deconstructor
+ */
+ ~UMLViewDialog();
+protected:
+ enum Page
+ {
+ General = 0,
+ Color,
+ Font,
+ Class
+ };
+
+ /**
+ * Sets up the dialog pages.
+ */
+ void setupPages();
+
+ /**
+ * Sets up the general Diagram Properties Page
+ */
+ void setupDiagramPropertiesPage();
+
+ /**
+ * Sets up the Class page
+ */
+ void setupClassPage();
+
+ /**
+ * Sets up the color page.
+ */
+ void setupColorPage();
+
+ /**
+ * Sets up font page.
+ */
+ void setupFontPage();
+
+ /**
+ * Applys the properties of the given page.
+ */
+ void applyPage( Page page );
+
+ /**
+ * Checks whether the name is unique and sets it if it is.
+ */
+ void checkName();
+
+ /**
+ * The view to represent.
+ */
+ UMLView * m_pView;
+
+ Settings::OptionState m_options;
+
+ KFontChooser * m_pChooser;
+ DiagramPropertiesPage *m_diagramProperties;
+ ClassOptionsPage * m_pOptionsPage;
+ UMLWidgetColorPage * m_pColorPage;
+
+ //GUI widgets
+ QLabel * m_pNameL, * m_pSpinXL, * m_pSpinYL;
+ QLineEdit * m_pNameLE;
+ QGroupBox * m_pDocGB, * m_pValuesGB;
+ QCheckBox * m_pSnapToGridCB, * m_pShowSnapCB;
+ QTextEdit * m_pDocTE;
+ QSpinBox * m_pSnapXSB, * m_pSnapYSB;
+ QSpinBox * m_pLineWidthSB;
+public slots:
+ void slotOk();
+ void slotApply();
+};
+
+#endif
diff --git a/umbrello/umbrello/dialogs/umlwidgetcolorpage.cpp b/umbrello/umbrello/dialogs/umlwidgetcolorpage.cpp
new file mode 100644
index 00000000..e234a8c2
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umlwidgetcolorpage.cpp
@@ -0,0 +1,114 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#include "umlwidgetcolorpage.h"
+#include "../optionstate.h"
+#include "../umlview.h"
+#include "../umlwidget.h"
+#include <klocale.h>
+#include <qlayout.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+
+#include <kcolorbutton.h>
+
+UMLWidgetColorPage::UMLWidgetColorPage( QWidget *pParent, UMLWidget *pWidget ) : QWidget( pParent )
+{
+ m_pUMLWidget = pWidget;
+ m_options = 0;
+ init();
+ m_pLineColorB->setColor( pWidget->getLineColor() );
+ m_pFillColorB->setColor( pWidget->getFillColour() );
+ m_pUseFillColorCB->setChecked( pWidget -> getUseFillColour() );
+}
+
+UMLWidgetColorPage::UMLWidgetColorPage( QWidget * pParent, Settings::OptionState *options ) : QWidget( pParent )
+{
+ m_options = options;
+ m_pUMLWidget = 0;
+ init();
+ m_pLineColorB->setColor( m_options->uiState.lineColor );
+ m_pFillColorB->setColor( m_options->uiState.fillColor );
+ m_pUseFillColorCB->setChecked( m_options->uiState.useFillColor );
+}
+
+void UMLWidgetColorPage::init()
+{
+ int margin = fontMetrics().height();
+
+ //setup GUI
+ QVBoxLayout * topLayout = new QVBoxLayout( this );
+ topLayout -> setSpacing( 6 );
+
+ m_pColorGB = new QGroupBox( i18n( "Color" ), this );
+ topLayout -> addWidget( m_pColorGB );
+ QGridLayout * colorLayout = new QGridLayout( m_pColorGB, 3, 3 );
+ colorLayout -> setMargin( margin );
+
+ m_pLineColorL = new QLabel( i18n( "&Line:" ), m_pColorGB );
+ colorLayout -> addWidget( m_pLineColorL, 0, 0 );
+
+ m_pLineColorB = new KColorButton( m_pColorGB );
+ colorLayout -> addWidget( m_pLineColorB, 0, 1 );
+ m_pLineColorL->setBuddy(m_pLineColorB);
+
+ m_pLineDefaultB = new QPushButton( i18n( "&Default" ), m_pColorGB) ;
+ colorLayout -> addWidget( m_pLineDefaultB, 0, 2 );
+
+ m_pFillColorL = new QLabel( i18n( "&Fill:" ), m_pColorGB );
+ colorLayout -> addWidget( m_pFillColorL, 1, 0 );
+
+ m_pFillColorB = new KColorButton( m_pColorGB );
+ colorLayout -> addWidget( m_pFillColorB, 1, 1 );
+ m_pFillColorL->setBuddy(m_pFillColorB);
+
+ m_pFillDefaultB = new QPushButton( i18n( "D&efault" ), m_pColorGB );
+ colorLayout -> addWidget( m_pFillDefaultB, 1, 2 );
+
+ m_pUseFillColorCB = new QCheckBox( i18n( "&Use fill" ), m_pColorGB );
+ colorLayout -> setRowStretch( 2, 2 );
+ colorLayout -> addWidget( m_pUseFillColorCB, 2, 0 );
+
+ //connect button signals up
+ connect( m_pLineDefaultB, SIGNAL( clicked() ), this, SLOT( slotLineButtonClicked() )) ;
+ connect( m_pFillDefaultB, SIGNAL( clicked() ), this, SLOT( slotFillButtonClicked() ) );
+}
+
+UMLWidgetColorPage::~UMLWidgetColorPage() {}
+
+void UMLWidgetColorPage::slotLineButtonClicked() {
+ // UMLView * pView = dynamic_cast<UMLView *>( m_pUMLWidget -> parent() );
+ m_pLineColorB -> setColor( Settings::getOptionState().uiState.lineColor );
+}
+
+void UMLWidgetColorPage::slotFillButtonClicked() {
+ // UMLView * pView = dynamic_cast<UMLView *>( m_pUMLWidget -> parent() );
+ m_pFillColorB -> setColor( Settings::getOptionState().uiState.fillColor );
+}
+
+void UMLWidgetColorPage::updateUMLWidget() {
+ if(m_pUMLWidget)
+ {
+ m_pUMLWidget->setUseFillColour( m_pUseFillColorCB -> isChecked() );
+ m_pUMLWidget->setLineColor( m_pLineColorB -> color() );
+ m_pUMLWidget->setFillColour( m_pFillColorB -> color() );
+ }
+ else if(m_options)
+ {
+ m_options->uiState.useFillColor = m_pUseFillColorCB -> isChecked();
+ m_options->uiState.lineColor = m_pLineColorB -> color();
+ m_options->uiState.fillColor = m_pFillColorB -> color();
+ }
+}
+
+#include "umlwidgetcolorpage.moc"
diff --git a/umbrello/umbrello/dialogs/umlwidgetcolorpage.h b/umbrello/umbrello/dialogs/umlwidgetcolorpage.h
new file mode 100644
index 00000000..45826338
--- /dev/null
+++ b/umbrello/umbrello/dialogs/umlwidgetcolorpage.h
@@ -0,0 +1,86 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2002-2006 *
+ * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
+ ***************************************************************************/
+
+#ifndef UMLWIDGETCOLORPAGE_H
+#define UMLWIDGETCOLORPAGE_H
+
+#include <qwidget.h>
+#include "../optionstate.h"
+
+/**
+ * @author Paul Hensgen
+ * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
+ */
+class UMLWidget;
+class UMLView;
+class KColorButton;
+class QLabel;
+class QPushButton;
+class QCheckBox;
+class QGroupBox;
+
+class UMLWidgetColorPage : public QWidget {
+ Q_OBJECT
+public:
+
+ /**
+ * Constructor - Observe a UMLWidget
+ */
+ UMLWidgetColorPage( QWidget * pParent, UMLWidget * pWidget );
+
+ /**
+ * Constructor - Observe an OptionState structure
+ */
+ UMLWidgetColorPage( QWidget * pParent, Settings::OptionState *options );
+
+ /**
+ * destructor
+ */
+ virtual ~UMLWidgetColorPage();
+
+ /**
+ * Updates the @ref UMLWidget with the dialog properties.
+ */
+ void updateUMLWidget();
+
+public slots:
+ /**
+ * Sets the default line color when default line button
+ * clicked.
+ */
+ void slotLineButtonClicked();
+
+ /**
+ * Sets the default fill color when default fill button
+ * clicked.
+ */
+ void slotFillButtonClicked();
+
+protected:
+ /**
+ * The widget to set the color for.
+ */
+ UMLWidget * m_pUMLWidget;
+
+ Settings::OptionState *m_options;
+
+ //GUI widgets
+ QGroupBox * m_pColorGB;
+ QLabel * m_pLineColorL, * m_pFillColorL;
+ QCheckBox * m_pUseFillColorCB;
+ QPushButton * m_pLineDefaultB, * m_pFillDefaultB;
+ KColorButton * m_pLineColorB, * m_pFillColorB;
+private:
+ void init();
+
+};
+
+#endif