33 #include <kmessagebox.h>
34 #include <kcombobox.h>
35 #include <klineedit.h>
36 #include <ktextedit.h>
40 #include <QGridLayout>
42 #include <QHBoxLayout>
44 #include <QRadioButton>
45 #include <QVBoxLayout>
49 m_pObject(o), m_pWidget(0), m_pInstanceWidget(0), m_pUmldoc(d)
52 uWarning() <<
"Given UMLObject is NULL.";
56 int margin = fontMetrics().height();
58 setMinimumSize(310, 330);
59 QVBoxLayout * topLayout =
new QVBoxLayout(
this);
60 topLayout->setSpacing(6);
63 QString name = QString();
67 name = i18n(
"Class &name:");
70 name = i18n(
"Actor &name:");
73 name = i18n(
"Package &name:");
76 name = i18n(
"Use case &name:");
79 name = i18n(
"Interface &name:");
82 name = i18n(
"Component &name:");
85 name = i18n(
"Node &name:");
88 name = i18n(
"Artifact &name:");
91 name = i18n(
"Enum &name:");
94 name = i18n(
"Datatype &name:");
97 name = i18n(
"Entity &name:");
100 name =
"<unknown> &name:";
101 uWarning() <<
"creating class gen page for unknown widget type";
104 QGridLayout * m_pNameLayout =
new QGridLayout();
105 m_pNameLayout->setSpacing(6);
106 topLayout->addLayout(m_pNameLayout, 4);
107 m_pNameL =
new QLabel(
this);
108 m_pNameL->setText(name);
109 m_pNameLayout->addWidget(m_pNameL, 0, 0);
111 m_pClassNameLE =
new KLineEdit(
this);
112 m_pNameLayout->addWidget(m_pClassNameLE, 0, 1);
113 m_pClassNameLE->setFocus();
114 m_pNameL->setBuddy(m_pClassNameLE);
121 m_pStereoTypeL =
new QLabel(i18n(
"&Stereotype name:"),
this);
122 m_pNameLayout->addWidget(m_pStereoTypeL, 1, 0);
124 m_pStereoTypeCB =
new KComboBox(
true,
this);
125 m_pNameLayout->addWidget(m_pStereoTypeCB, 1, 1);
127 m_pStereoTypeCB->setItemText(m_pStereoTypeCB->currentIndex(), m_pObject->
stereotype());
128 m_pStereoTypeL->setBuddy(m_pStereoTypeCB);
131 m_pStereoTypeCB->setEditable(
false);
135 m_pPackageL =
new QLabel(i18n(
"Package path:"),
this);
136 m_pNameLayout->addWidget(m_pPackageL, 2, 0);
138 m_pPackageCB =
new KComboBox(
this);
139 m_pPackageCB->setEditable(
true);
140 m_pNameLayout->addWidget(m_pPackageCB, 2, 1);
143 QStringList packages;
145 packages << package->
name();
148 m_pPackageCB->insertItems(-1, packages);
149 QString packagePath = m_pObject->
package();
154 if (parentPackage == NULL ||
155 parentPackage == folderLogicalView) {
156 m_pPackageCB->setEditText(QString());
159 m_pPackageCB->setEditText(packagePath);
164 QString abstractCaption;
166 abstractCaption = i18n(
"A&bstract class");
168 abstractCaption = i18n(
"A&bstract use case");
170 m_pAbstractCB =
new QCheckBox(abstractCaption,
this);
171 m_pAbstractCB->setChecked(m_pObject->
isAbstract());
172 m_pNameLayout->addWidget(m_pAbstractCB, 3, 0);
176 m_pExecutableCB =
new QCheckBox(i18nc(
"component is executable",
"&Executable"),
this);
177 m_pExecutableCB->setChecked((static_cast<UMLComponent*>(o))->getExecutable());
178 m_pNameLayout->addWidget(m_pExecutableCB, 3, 0);
183 m_pDrawAsGB =
new QGroupBox(i18n(
"Draw As"),
this);
184 QHBoxLayout* drawAsLayout =
new QHBoxLayout(m_pDrawAsGB);
185 drawAsLayout->setMargin(margin);
187 m_pDefaultRB =
new QRadioButton(i18nc(
"draw as default",
"&Default"), m_pDrawAsGB);
188 drawAsLayout->addWidget(m_pDefaultRB);
190 m_pFileRB =
new QRadioButton(i18n(
"&File"), m_pDrawAsGB);
191 drawAsLayout->addWidget(m_pFileRB);
193 m_pLibraryRB =
new QRadioButton(i18n(
"&Library"), m_pDrawAsGB);
194 drawAsLayout->addWidget(m_pLibraryRB);
196 m_pTableRB =
new QRadioButton(i18n(
"&Table"), m_pDrawAsGB);
197 drawAsLayout->addWidget(m_pTableRB);
199 topLayout->addWidget(m_pDrawAsGB);
203 m_pFileRB->setChecked(
true);
205 m_pLibraryRB->setChecked(
true);
207 m_pTableRB->setChecked(
true);
209 m_pDefaultRB->setChecked(
true);
214 m_pButtonGB =
new QGroupBox(i18n(
"Visibility"),
this);
215 QHBoxLayout * scopeLayout =
new QHBoxLayout(m_pButtonGB);
216 scopeLayout->setMargin(margin);
218 m_pPublicRB =
new QRadioButton(i18nc(
"public visibility",
"P&ublic"), m_pButtonGB);
219 scopeLayout->addWidget(m_pPublicRB);
221 m_pPrivateRB =
new QRadioButton(i18nc(
"private visibility",
"P&rivate"), m_pButtonGB);
222 scopeLayout->addWidget(m_pPrivateRB);
224 m_pProtectedRB =
new QRadioButton(i18nc(
"protected visibility",
"Pro&tected"), m_pButtonGB);
225 scopeLayout->addWidget(m_pProtectedRB);
226 topLayout->addWidget(m_pButtonGB);
228 m_pImplementationRB =
new QRadioButton(i18n(
"Imple&mentation"), m_pButtonGB);
229 scopeLayout->addWidget(m_pImplementationRB);
230 topLayout->addWidget(m_pButtonGB);
233 m_docGB =
new QGroupBox(
this);
234 QHBoxLayout * docLayout =
new QHBoxLayout(m_docGB);
235 docLayout->setMargin(margin);
236 m_docGB->setTitle(i18n(
"Documentation"));
239 docLayout->addWidget(m_doc);
240 topLayout->addWidget(m_docGB);
243 m_pClassNameLE->setText(m_pObject->
name());
244 m_doc->setText(m_pObject->
doc());
248 m_pPublicRB->setChecked(
true);
251 m_pPrivateRB->setChecked(
true);
254 m_pProtectedRB->setChecked(
true);
257 m_pImplementationRB->setChecked(
true);
262 m_pStereoTypeCB->setDuplicatesEnabled(
false);
263 m_pStereoTypeCB->setCompletionMode(KGlobalSettings::CompletionPopup);
264 insertStereotypesSorted(m_pObject->
stereotype());
266 m_doc->setLineWrapMode(QTextEdit::WidgetWidth);
271 m_pObject(0), m_pWidget(o), m_pInstanceWidget(0), m_pUmldoc(d)
274 uWarning() <<
"Given ObjectWidget is NULL.";
281 int margin = fontMetrics().height();
283 setMinimumSize(310, 330);
284 QGridLayout * topLayout =
new QGridLayout(
this);
285 topLayout->setSpacing(6);
288 QGridLayout * m_pNameLayout =
new QGridLayout();
289 m_pNameLayout->setSpacing(6);
290 topLayout->addLayout(m_pNameLayout, 3, 2);
291 m_pNameL =
new QLabel(
this);
292 m_pNameL->setText(i18n(
"Class name:"));
293 m_pNameLayout->addWidget(m_pNameL, 0, 0);
295 m_pClassNameLE =
new KLineEdit(
this);
296 m_pClassNameLE->setText(m_pWidget->
name());
297 m_pNameLayout->addWidget(m_pClassNameLE, 0, 1);
299 m_pInstanceL =
new QLabel(
this);
300 m_pInstanceL->setText(i18n(
"Instance name:"));
301 m_pNameLayout->addWidget(m_pInstanceL, 1, 0);
303 m_pInstanceLE =
new KLineEdit(
this);
305 m_pNameLayout->addWidget(m_pInstanceLE, 1, 1);
308 m_pDrawActorCB =
new QCheckBox(i18n(
"Draw as actor"),
this);
309 m_pDrawActorCB->setChecked(m_pWidget->
drawAsActor());
310 m_pNameLayout->addWidget(m_pDrawActorCB, 2, 0);
313 m_pMultiCB =
new QCheckBox(i18n(
"Multiple instance"),
this);
315 m_pNameLayout->addWidget(m_pMultiCB, 2, 1);
316 if (m_pDrawActorCB->isChecked())
317 m_pMultiCB->setEnabled(
false);
319 m_pDeconCB =
new QCheckBox(i18n(
"Show destruction"),
this);
321 m_pNameLayout->addWidget(m_pDeconCB, 2, 1);
324 m_docGB =
new QGroupBox(
this);
325 topLayout->addWidget(m_docGB, 1, 0);
326 QHBoxLayout * docLayout =
new QHBoxLayout(m_docGB);
327 docLayout->setMargin(margin);
328 m_docGB->setTitle(i18n(
"Documentation"));
331 m_doc->setLineWrapMode(QTextEdit::WidgetWidth);
333 docLayout->addWidget(m_doc);
335 connect(m_pDrawActorCB, SIGNAL(toggled(
bool)),
this, SLOT(
slotActorToggled(
bool)));
341 m_pObject(0), m_pWidget(0), m_pInstanceWidget(widget), m_pUmldoc(d)
346 int margin = fontMetrics().height();
348 setMinimumSize(310, 330);
349 QGridLayout* topLayout =
new QGridLayout(
this);
350 topLayout->setSpacing(6);
353 QGridLayout* m_pNameLayout =
new QGridLayout();
354 m_pNameLayout->setSpacing(6);
355 topLayout->addLayout(m_pNameLayout, 3, 2);
356 m_pNameL =
new QLabel(
this);
358 m_pNameL->setText(i18n(
"Component name:"));
360 m_pNameL->setText(i18n(
"Node name:"));
362 uWarning() <<
"ClassGenPage called on unknown widget type";
364 m_pNameLayout->addWidget(m_pNameL, 0, 0);
366 m_pClassNameLE =
new KLineEdit(
this);
367 m_pClassNameLE->setText(widget->
name());
368 m_pNameLayout->addWidget(m_pClassNameLE, 0, 1);
370 m_pStereoTypeL =
new QLabel(i18n(
"Stereotype name:"),
this);
371 m_pNameLayout->addWidget(m_pStereoTypeL, 1, 0);
373 m_pStereoTypeCB =
new KComboBox(
true,
this);
374 m_pNameLayout->addWidget(m_pStereoTypeCB, 1, 1);
376 m_pStereoTypeCB->setItemText(m_pStereoTypeCB->currentIndex(), widget->
umlObject()->
stereotype());
377 m_pStereoTypeCB->setCompletionMode(KGlobalSettings::CompletionPopup);
379 m_pInstanceL =
new QLabel(
this);
380 m_pInstanceL->setText(i18n(
"Instance name:"));
381 m_pNameLayout->addWidget(m_pInstanceL, 2, 0);
383 m_pInstanceLE =
new KLineEdit(
this);
385 m_pNameLayout->addWidget(m_pInstanceLE, 2, 1);
388 m_docGB =
new QGroupBox(
this);
389 topLayout->addWidget(m_docGB, 1, 0);
390 QHBoxLayout* docLayout =
new QHBoxLayout(m_docGB);
391 docLayout->setMargin(margin);
392 m_docGB->setTitle(i18n(
"Documentation"));
395 m_doc->setLineWrapMode(QTextEdit::WidgetWidth);
397 docLayout->addWidget(m_doc);
404 void ClassGenPage::insertStereotypesSorted(
const QString& type)
409 types << ust->
name();
412 if (!types.contains(type)) {
417 m_pStereoTypeCB->clear();
418 m_pStereoTypeCB->insertItems(-1, types);
421 int currentIndex = m_pStereoTypeCB->findText(type);
422 if (currentIndex > -1) {
423 m_pStereoTypeCB->setCurrentIndex(currentIndex);
425 m_pStereoTypeCB->completionObject()->addItem(type);
435 QString name = m_pClassNameLE->text();
437 m_pObject->
setDoc(m_doc->toPlainText());
439 if (m_pStereoTypeCB) {
445 QString packageName = m_pPackageCB->currentText().trimmed();
448 if (!packageName.isEmpty()) {
461 m_pObject->
setAbstract(m_pAbstractCB->isChecked());
466 if (o && m_pObject != o) {
467 KMessageBox::sorry(
this, i18n(
"The name you have chosen\nis already being used.\nThe name has been reset."),
468 i18n(
"Name is Not Unique"), 0);
469 m_pClassNameLE->setText(m_pObject->
name());
475 if (m_pPublicRB->isChecked())
477 else if (m_pPrivateRB->isChecked())
479 else if (m_pProtectedRB->isChecked())
484 (
static_cast<UMLComponent*
>(m_pObject))->setExecutable(m_pExecutableCB->isChecked());
489 if (m_pFileRB->isChecked()) {
491 }
else if (m_pLibraryRB->isChecked()) {
493 }
else if (m_pTableRB->isChecked()) {
498 (
static_cast<UMLArtifact*
>(m_pObject))->setDrawAsType(drawAsType);
502 else if (m_pWidget) {
511 QString name = m_pClassNameLE->text();
515 if (old && o != old) {
516 KMessageBox::sorry(
this, i18n(
"The name you have chosen\nis already being used.\nThe name has been reset."),
517 i18n(
"Name is Not Unique"), 0);
522 else if (m_pInstanceWidget) {
524 QString name = m_pClassNameLE->text();
528 if (old && o != old) {
529 KMessageBox::sorry(
this, i18n(
"The name you have chosen\nis already being used.\nThe name has been reset."),
530 i18n(
"Name is Not Unique"), 0);
546 m_pMultiCB->setEnabled(!state);
550 #include "classgenpage.moc"
virtual void setName(const QString &strName)
Set the UMLObject's name.
This class contains the non-graphical information required for a UML Package.
void slotActorToggled(bool state)
When the draw as actor check box is toggled, the draw as multi instance need to be enabled/disabled...
Uml::Visibility::Enum visibility() const
Returns the visibility of the object.
This class contains the non-graphical information required for a UML Component.
void setVisibility(Uml::Visibility::Enum visibility)
Sets the visibility of the object.
UMLView * currentView() const
Get the current view.
UMLView instances represent diagrams.
ClassGenPage(UMLDoc *d, QWidget *parent, UMLObject *o)
Sets up the ClassGenPage.
static UMLApp * app()
Get the last created instance of this class.
const UMLStereotypeList & stereotypes() const
Returns a list of the stereotypes in this UMLDoc.
This class is used to set up information for a stereotype.
~ClassGenPage()
Standard deconstructor.
This class is the non-graphical version of UMLWidget.
Uml::DiagramType::Enum type() const
Returns the type of the diagram.
UMLObject * createUMLObject(UMLObject::ObjectType type, const QString &inName, UMLPackage *parentPkg, const QString &comment, const QString &stereotype)
Find or create a document object.
void setDoc(const QString &d)
Sets the documentation for the object.
Draw_Type
Artifacts can be drawn using one of several icons.
QList< UMLPackage * > UMLPackageList
void emitModified()
Forces the emission of the modified signal.
QString stereotype(bool includeAdornments=false) const
Returns the stereotype.
ObjectType baseType() const
Returns the type of the object.
This class contains the non-graphical information required for a UML Artifact.
UMLScene * umlScene() const
Getter for the scene.
UMLPackage * umlPackage()
Returns the UMLPackage that this class is located in.
void updateObject()
Will move information from the dialog into the object.
QString package(const QString &separator=QString(), bool includeRoot=false)
Return the package(s) in which this UMLObject is contained as a text.
void treeViewMoveObjectTo(UMLObject *container, UMLObject *object)
Move an object to a new container in the tree view.
UMLPackageList packages(bool includeNested=true)
Returns a list of the packages in this UMLDoc,.
QString name() const
Returns a copy of m_name.
void setAbstract(bool bAbstract)
Sets the paste state of the object.
bool isAbstract() const
Returns the abstract state of the object.
UMLObject * findUMLObject(const QString &name, UMLObject::ObjectType type=UMLObject::ot_UMLObject, UMLObject *currentObj=0)
Used to find a UMLObject by its type and name.
void setStereotype(const QString &_name)
Sets the classes stereotype name.
UMLFolder * rootFolder(Uml::ModelType::Enum mt)
Return the predefined root folder of the given type.
QString doc() const
Returns the documentation for the object.
UMLDoc provides a document object for a document-view model.