umlviewdialog.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "umlviewdialog.h"
00014
00015
00016 #include <qvbox.h>
00017 #include <qlayout.h>
00018 #include <qcheckbox.h>
00019 #include <qlabel.h>
00020 #include <qlineedit.h>
00021 #include <qgroupbox.h>
00022 #include <qtextedit.h>
00023 #include <qspinbox.h>
00024 #include <kiconloader.h>
00025 #include <klocale.h>
00026 #include <kmessagebox.h>
00027 #include <kfontdialog.h>
00028 #include <kdebug.h>
00029 #include <knuminput.h>
00030
00031
00032 #include "../umlview.h"
00033 #include "../umldoc.h"
00034 #include "../uml.h"
00035 #include "diagrampropertiespage.h"
00036
00037
00038 UMLViewDialog::UMLViewDialog( QWidget * pParent, UMLView * pView ) : KDialogBase(IconList, i18n("Properties"), Ok | Apply | Cancel | Help,
00039 Ok, pParent, "_VIEWDLG_", true, true) {
00040 m_pView = pView;
00041 m_options = m_pView -> getOptionState();
00042 setupPages();
00043 }
00044
00045 UMLViewDialog::~UMLViewDialog() {
00046 }
00047
00048 void UMLViewDialog::slotOk() {
00049 applyPage( General );
00050 applyPage( Color );
00051 applyPage( Font );
00052 applyPage( Class );
00053 accept();
00054 }
00055
00056 void UMLViewDialog::slotApply() {
00057 applyPage( (Page)activePageIndex() );
00058 }
00059
00060 void UMLViewDialog::setupPages()
00061 {
00062 setupDiagramPropertiesPage();
00063 setupColorPage();
00064 setupFontPage();
00065 setupClassPage();
00066 }
00067
00068 void UMLViewDialog::setupDiagramPropertiesPage()
00069 {
00070 QVBox *page = addVBoxPage( i18n("General"), i18n("General Settings"), DesktopIcon( "misc") );
00071 m_diagramProperties = new DiagramPropertiesPage(page);
00072
00073 m_diagramProperties->diagramName->setText( m_pView->getName() );
00074 m_diagramProperties->zoom->setValue(m_pView->currentZoom());
00075 m_diagramProperties->showOpSigs->setChecked( m_pView->getShowOpSig() );
00076
00077 m_diagramProperties->showGrid->setChecked(m_pView -> getShowSnapGrid());
00078 m_diagramProperties->snapToGrid->setChecked(m_pView-> getSnapToGrid());
00079 m_diagramProperties->snapComponentSizeToGrid->setChecked(m_pView-> getSnapComponentSizeToGrid());
00080
00081 m_diagramProperties->gridSpaceX->setValue( m_pView -> getSnapX());
00082 m_diagramProperties->gridSpaceY->setValue( m_pView -> getSnapY());
00083 m_diagramProperties->lineWidth->setValue( m_pView -> getLineWidth());
00084 m_diagramProperties->documentation->setText(m_pView -> getDoc());
00085
00086 }
00087
00088 void UMLViewDialog::setupClassPage() {
00089 if( m_pView -> getType() != Uml::dt_Class ) {
00090 return;
00091 }
00092
00093 QFrame * newPage = addPage( i18n("Display"), i18n("Classes Display Options"), DesktopIcon( "info") );
00094 QHBoxLayout * m_pOptionsLayout = new QHBoxLayout( newPage );
00095 m_pOptionsPage = new ClassOptionsPage( newPage, &m_options );
00096 m_pOptionsLayout -> addWidget( m_pOptionsPage );
00097 }
00098
00099 void UMLViewDialog::setupColorPage() {
00100 QFrame * colorPage = addPage( i18n("Color"), i18n("Diagram Colors"), DesktopIcon( "colors") );
00101 QHBoxLayout * m_pColorLayout = new QHBoxLayout(colorPage);
00102 m_pColorPage = new UMLWidgetColorPage( colorPage, &m_options );
00103 m_pColorLayout -> addWidget(m_pColorPage);
00104 }
00105
00106 void UMLViewDialog::setupFontPage() {
00107 QVBox * page = addVBoxPage( i18n("Font"), i18n("Font Settings"), DesktopIcon( "fonts") );
00108 m_pChooser = new KFontChooser( (QWidget*)page, "font", false, QStringList(), false);
00109 m_pChooser -> setFont( m_pView -> getOptionState().uiState.font );
00110 }
00111
00112 void UMLViewDialog::applyPage( Page page ) {
00113
00114 switch (page) {
00115 case General:
00116 {
00117 checkName();
00118 m_pView->setZoom( m_diagramProperties->zoom->value() );
00119 m_pView->setDoc( m_diagramProperties->documentation->text() );
00120 m_pView->setSnapX( m_diagramProperties->gridSpaceX->value() );
00121 m_pView->setSnapY( m_diagramProperties->gridSpaceY->value() );
00122 m_pView->setLineWidth( m_diagramProperties->lineWidth->value() );
00123 m_pView->setSnapToGrid( m_diagramProperties->snapToGrid->isChecked() );
00124 m_pView->setSnapComponentSizeToGrid( m_diagramProperties->snapComponentSizeToGrid->isChecked() );
00125 m_pView->setShowSnapGrid( m_diagramProperties->showGrid->isChecked() );
00126 m_pView->setShowOpSig( m_diagramProperties->showOpSigs->isChecked() );
00127 break;
00128 }
00129 case Color:
00130 m_pColorPage->updateUMLWidget();
00131 m_pView->setUseFillColor( m_options.uiState.useFillColor );
00132 m_pView->setLineColor( m_options.uiState.lineColor );
00133 m_pView->setFillColor( m_options.uiState.fillColor );
00134 break;
00135
00136 case Font:
00137 kDebug() << "UMLViewDialog::applyPage: setting font "
00138 << m_pChooser->font().toString() << endl;
00139 m_pView->setFont( m_pChooser->font(), true );
00140 break;
00141
00142 case Class:
00143 if( m_pView->getType() != Uml::dt_Class ) {
00144 return;
00145 }
00146 m_pOptionsPage->updateUMLWidget();
00147 m_pView->setClassWidgetOptions( m_pOptionsPage );
00148
00149
00150
00151
00152
00153
00154 m_pView->setOptionState( m_options );
00155 break;
00156 }
00157 }
00158
00159 void UMLViewDialog::checkName() {
00160 QString name = m_diagramProperties->diagramName-> text();
00161 UMLDoc * pDoc = UMLApp::app()-> getDocument();
00162 UMLView * pView = pDoc -> findView( m_pView -> getType(), name );
00163 if( name.length() == 0 ) {
00164 KMessageBox::sorry(this, i18n("The name you have entered is invalid."),
00165 i18n("Invalid Name"), false);
00166 m_diagramProperties->diagramName->setText( m_pView->getName() );
00167 return;
00168 }
00169 if( pView && pView != m_pView ) {
00170 KMessageBox::sorry(this, i18n("The name you have entered is not unique."),
00171 i18n("Name Not Unique"), false);
00172 m_diagramProperties->diagramName->setText( m_pView->getName() );
00173 return;
00174 }
00175 m_pView->setName( name );
00176 pDoc->signalDiagramRenamed(m_pView);
00177 }
00178
00179
00180
00181
00182
00183
00184 #include "umlviewdialog.moc"
This file is part of the documentation for umbrello Version 3.1.0.