00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "classpropdlg.h"
00014
00015
00016 #include <qlayout.h>
00017 #include <kiconloader.h>
00018 #include <klocale.h>
00019 #include <kdebug.h>
00020
00021
00022 #include "classgenpage.h"
00023 #include "classifierlistpage.h"
00024 #include "pkgcontentspage.h"
00025 #include "assocpage.h"
00026 #include "classoptionspage.h"
00027 #include "umlwidgetcolorpage.h"
00028 #include "../umlobject.h"
00029 #include "../umldoc.h"
00030 #include "../classifierwidget.h"
00031 #include "../objectwidget.h"
00032 #include "../componentwidget.h"
00033 #include "../uml.h"
00034 #include "../umlview.h"
00035
00036 ClassPropDlg::ClassPropDlg(QWidget *parent, UMLObject * c, int pageNum, bool assoc)
00037 : KDialogBase(IconList, i18n("Properties"), Ok | Apply | Cancel | Help,
00038 Ok, parent, "_CLASSDLG_", true, true) {
00039 m_pWidget = 0;
00040 m_pGenPage = 0;
00041 m_pAttPage = 0;
00042 m_pOpsPage = 0;
00043 m_pTemplatePage = 0;
00044 m_pEnumLiteralPage = 0;
00045 m_pEntityAttributePage = 0;
00046 m_pOptionsPage = 0;
00047 m_pColorPage = 0;
00048 m_Type = pt_Object;
00049 m_pDoc = UMLApp::app()->getDocument();
00050 m_pObject = c;
00051 setupPages(c, assoc);
00052 showPage(pageNum);
00053 }
00054
00055 ClassPropDlg::ClassPropDlg(QWidget *parent, ObjectWidget * o)
00056 : KDialogBase(IconList, i18n("Properties"), Ok | Apply | Cancel | Help,
00057 Ok, parent, "_CLASSDLG_", true, true) {
00058 m_pWidget = o;
00059 m_pGenPage = 0;
00060 m_pAttPage = 0;
00061 m_pOpsPage = 0;
00062 m_pTemplatePage = 0;
00063 m_pEnumLiteralPage = 0;
00064 m_pEntityAttributePage = 0;
00065 m_pOptionsPage = 0;
00066 m_Type = pt_ObjectWidget;
00067 m_pObject = m_pWidget->getUMLObject();
00068 m_pDoc = UMLApp::app()->getDocument();
00069 QFrame *page = addPage( i18n("General"), i18n("General Settings"), DesktopIcon( "misc") );
00070 page -> setMinimumSize(310, 330);
00071 QHBoxLayout * topLayout = new QHBoxLayout(page);
00072 m_pGenPage = new ClassGenPage(m_pDoc, page, o);
00073 topLayout -> addWidget(m_pGenPage);
00074
00075 QFrame * newPage = addPage( i18n("Color"), i18n("Widget Colors"), DesktopIcon( "colors") );
00076 QHBoxLayout * m_pColorLayout = new QHBoxLayout(newPage);
00077 m_pColorPage = new UMLWidgetColorPage(newPage, o);
00078 m_pColorLayout -> addWidget(m_pColorPage);
00079
00080 setupFontPage();
00081 showPage(0);
00082 setMinimumSize(340,420);
00083 }
00084
00085 ClassPropDlg::ClassPropDlg(QWidget *parent, UMLWidget * w)
00086 : KDialogBase(IconList, i18n("Properties"), Ok | Apply | Cancel | Help,
00087 Ok, parent, "_CLASSDLG_", true, true) {
00088 m_pWidget = w;
00089 m_pGenPage = 0;
00090 m_pAttPage = 0;
00091 m_pOpsPage = 0;
00092 m_pTemplatePage = 0;
00093 m_pEnumLiteralPage = 0;
00094 m_pEntityAttributePage = 0;
00095 m_pOptionsPage = 0;
00096 m_Type = pt_Widget;
00097 m_pObject = w -> getUMLObject();
00098 m_pDoc = ((UMLApp *)parent) -> getDocument();
00099
00100 if (w->getBaseType() == Uml::wt_Class
00101 || w->getBaseType() == Uml::wt_Interface
00102 || w->getBaseType() == Uml::wt_Package) {
00103 setupPages(m_pObject, true);
00104 } else if (w->getBaseType() == Uml::wt_Component) {
00105 if ( w->getIsInstance() ) {
00106 setupInstancePages(w);
00107 } else {
00108 setupPages(m_pObject);
00109 }
00110 } else if (w->getBaseType() == Uml::wt_Node) {
00111 setupInstancePages(w);
00112 } else {
00113 setupPages(m_pObject);
00114 }
00115
00116
00117 if (w->getBaseType() == Uml::wt_Class || w->getBaseType() == Uml::wt_Interface) {
00118 QFrame* newPage = addPage( i18n("Display"), i18n("Display Options"), DesktopIcon("info") );
00119 QHBoxLayout* m_pOptionsLayout = new QHBoxLayout(newPage);
00120 ClassifierWidget *cw = static_cast<ClassifierWidget*>(w);
00121 m_pOptionsPage = new ClassOptionsPage( newPage, cw );
00122 m_pOptionsLayout -> addWidget(m_pOptionsPage);
00123 }
00124
00125 QFrame* colorPage = addPage( i18n("Color"), i18n("Widget Colors"), DesktopIcon("colors") );
00126 QHBoxLayout * m_pColorLayout = new QHBoxLayout(colorPage);
00127 m_pColorPage = new UMLWidgetColorPage(colorPage, w);
00128 m_pColorLayout -> addWidget(m_pColorPage);
00129 setupFontPage();
00130 }
00131
00132 ClassPropDlg::~ClassPropDlg() {}
00133
00134 void ClassPropDlg::slotOk() {
00135 slotApply();
00136 KDialogBase::accept();
00137 }
00138
00139 void ClassPropDlg::slotApply() {
00140 if (m_pGenPage) {
00141 m_pGenPage->updateObject();
00142 }
00143 if (m_pAttPage) {
00144 m_pAttPage->updateObject();
00145 }
00146 if (m_pOpsPage) {
00147 m_pOpsPage->updateObject();
00148 }
00149 if (m_pTemplatePage) {
00150 m_pTemplatePage->updateObject();
00151 }
00152 if (m_pEnumLiteralPage) {
00153 m_pEnumLiteralPage->updateObject();
00154 }
00155 if (m_pEntityAttributePage) {
00156 m_pEntityAttributePage->updateObject();
00157 }
00158 if (m_pOptionsPage) {
00159 m_pOptionsPage->updateUMLWidget();
00160 }
00161 if (m_pColorPage) {
00162 m_pColorPage->updateUMLWidget();
00163 }
00164 if (m_pWidget) {
00165 m_pWidget->setFont( m_pChooser->font() );
00166 }
00167 }
00168
00169 void ClassPropDlg::setupPages(UMLObject * c, bool assoc) {
00170 QFrame *page = addPage(i18n("General"), i18n("General Settings"), DesktopIcon( "misc") );
00171 QHBoxLayout * genLayout = new QHBoxLayout(page);
00172 page -> setMinimumSize(310, 330);
00173 m_pGenPage = new ClassGenPage(m_pDoc, page, c);
00174 genLayout -> addWidget(m_pGenPage);
00175 Uml::Object_Type ot = c->getBaseType();
00176
00177 if (ot == Uml::ot_Class ) {
00178
00179 QFrame* newPage = addPage( i18n("Attributes"), i18n("Attribute Settings"), DesktopIcon("misc") );
00180 m_pAttPage = new ClassifierListPage(newPage, (UMLClassifier *)c, m_pDoc, Uml::ot_Attribute);
00181 QHBoxLayout * attLayout = new QHBoxLayout(newPage);
00182 attLayout -> addWidget(m_pAttPage);
00183 }
00184
00185 if (ot == Uml::ot_Class || ot == Uml::ot_Interface) {
00186
00187 QFrame* newPage = addPage( i18n("Operations"), i18n("Operation Settings"), DesktopIcon("misc") );
00188 m_pOpsPage = new ClassifierListPage(newPage, (UMLClassifier*)c, m_pDoc, Uml::ot_Operation);
00189 QHBoxLayout* pOpsLayout = new QHBoxLayout(newPage);
00190 pOpsLayout -> addWidget(m_pOpsPage);
00191 }
00192
00193 if (ot == Uml::ot_Class || ot == Uml::ot_Interface) {
00194
00195 QFrame* newPage = addPage( i18n("Templates"), i18n("Templates Settings"), DesktopIcon("misc") );
00196 m_pTemplatePage = new ClassifierListPage(newPage, (UMLClassifier *)c, m_pDoc, Uml::ot_Template);
00197 QHBoxLayout* templatesLayout = new QHBoxLayout(newPage);
00198 templatesLayout->addWidget(m_pTemplatePage);
00199 }
00200 if (ot == Uml::ot_Enum) {
00201
00202 QFrame* newPage = addPage( i18n("Enum Literals"), i18n("Enum Literals Settings"), DesktopIcon("misc") );
00203 m_pEnumLiteralPage = new ClassifierListPage(newPage, (UMLClassifier*)c, m_pDoc, Uml::ot_EnumLiteral);
00204 QHBoxLayout* enumLiteralsLayout = new QHBoxLayout(newPage);
00205 enumLiteralsLayout->addWidget(m_pEnumLiteralPage);
00206 }
00207 if (ot == Uml::ot_Entity) {
00208
00209 QFrame* newPage = addPage( i18n("Entity Attributes"), i18n("Entity Attributes Settings"), DesktopIcon("misc") );
00210 m_pEntityAttributePage = new ClassifierListPage(newPage, (UMLClassifier*)c, m_pDoc, Uml::ot_EntityAttribute);
00211 QHBoxLayout* entityAttributesLayout = new QHBoxLayout(newPage);
00212 entityAttributesLayout->addWidget(m_pEntityAttributePage);
00213 }
00214 if (ot == Uml::ot_Package ) {
00215
00216 QFrame* newPage = addPage( i18n("Contents"), i18n("Contents Settings"), DesktopIcon("misc") );
00217 m_pPkgContentsPage = new PkgContentsPage(newPage, (UMLPackage*)(c));
00218 QHBoxLayout* contentsLayout = new QHBoxLayout(newPage);
00219 contentsLayout->addWidget(m_pPkgContentsPage);
00220 }
00221 if (assoc) {
00222 QFrame* newPage = addPage(i18n("Associations"), i18n("Class Associations"), DesktopIcon( "misc") );
00223 m_pAssocPage = new AssocPage(newPage, UMLApp::app()->getCurrentView(), m_pObject);
00224 QHBoxLayout* assocLayout = new QHBoxLayout(newPage);
00225 assocLayout -> addWidget(m_pAssocPage);
00226 } else {
00227 m_pAssocPage = 0;
00228 }
00229 }
00230
00231 void ClassPropDlg::setupInstancePages(UMLWidget* widget) {
00232 QFrame* page = addPage( i18n("General"), i18n("General Settings"), DesktopIcon("misc") );
00233 QHBoxLayout* genLayout = new QHBoxLayout(page);
00234 page->setMinimumSize(310, 330);
00235 m_pGenPage = new ClassGenPage(m_pDoc, page, widget);
00236 genLayout->addWidget(m_pGenPage);
00237 m_pAssocPage = 0;
00238 }
00239
00240 void ClassPropDlg::setupFontPage() {
00241 if( !m_pWidget )
00242 return;
00243 QVBox * page = addVBoxPage( i18n("Font"), i18n("Font Settings"), DesktopIcon( "fonts") );
00244 m_pChooser = new KFontChooser( (QWidget*)page, "font", false, QStringList(), false);
00245 m_pChooser -> setFont( m_pWidget -> getFont() );
00246 }
00247
00248
00249
00250 #include "classpropdlg.moc"