Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SDK
Umbrello
Commits
b795aa90
Commit
b795aa90
authored
Nov 27, 2019
by
Ralf Habacker
Browse files
Let class UMLDatatypeWidget use ComboBoxWidgetBase as base class
Followup for commit
f0b38d10
.
parent
345fb25b
Changes
4
Hide whitespace changes
Inline
Side-by-side
umbrello/dialogs/widgets/comboboxwidgetbase.cpp
View file @
b795aa90
...
...
@@ -46,11 +46,12 @@ ComboBoxWidgetBase::ComboBoxWidgetBase(const QString &title, const QString &post
* and the editable field in column 1.
* @param layout The layout to which the widget should be added
* @param row The row in the grid layout where the widget should be placed
* @param startColumn The first column in the grid layout where the widget should be placed
*/
void
ComboBoxWidgetBase
::
addToLayout
(
QGridLayout
*
layout
,
int
row
)
void
ComboBoxWidgetBase
::
addToLayout
(
QGridLayout
*
layout
,
int
row
,
int
startColumn
)
{
layout
->
addWidget
(
m_label
,
row
,
0
);
layout
->
addWidget
(
m_editField
,
row
,
1
);
layout
->
addWidget
(
m_label
,
row
,
startColumn
);
layout
->
addWidget
(
m_editField
,
row
,
startColumn
+
1
);
if
(
m_postLabel
)
layout
->
addWidget
(
m_postLabel
,
row
,
2
);
layout
->
addWidget
(
m_postLabel
,
row
,
startColumn
+
2
);
}
umbrello/dialogs/widgets/comboboxwidgetbase.h
View file @
b795aa90
...
...
@@ -22,7 +22,7 @@ class ComboBoxWidgetBase : public QWidget
Q_OBJECT
public:
explicit
ComboBoxWidgetBase
(
const
QString
&
title
,
const
QString
&
postLabel
=
QString
(),
QWidget
*
parent
=
nullptr
);
void
addToLayout
(
QGridLayout
*
layout
,
int
row
);
void
addToLayout
(
QGridLayout
*
layout
,
int
row
,
int
startColumn
=
0
);
protected:
QLabel
*
m_label
;
...
...
umbrello/dialogs/widgets/umldatatypewidget.cpp
View file @
b795aa90
...
...
@@ -4,7 +4,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2016 *
* copyright (C) 2016
,2019
*
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
...
...
@@ -31,7 +31,7 @@
#include
<QWidget>
UMLDatatypeWidget
::
UMLDatatypeWidget
(
UMLAttribute
*
attribute
,
QWidget
*
parent
)
:
QWidget
(
parent
),
:
ComboBoxWidgetBase
(
i18n
(
"&Type:"
),
QString
(),
parent
),
m_attribute
(
attribute
),
m_datatype
(
0
),
m_entityAttribute
(
0
),
...
...
@@ -44,7 +44,7 @@ UMLDatatypeWidget::UMLDatatypeWidget(UMLAttribute *attribute, QWidget *parent)
}
UMLDatatypeWidget
::
UMLDatatypeWidget
(
UMLClassifierListItem
*
datatype
,
QWidget
*
parent
)
:
QWidget
(
parent
),
:
ComboBoxWidgetBase
(
i18n
(
"&Type:"
),
QString
(),
parent
),
m_attribute
(
0
),
m_datatype
(
datatype
),
m_entityAttribute
(
0
),
...
...
@@ -57,7 +57,7 @@ UMLDatatypeWidget::UMLDatatypeWidget(UMLClassifierListItem *datatype, QWidget *p
}
UMLDatatypeWidget
::
UMLDatatypeWidget
(
UMLEntityAttribute
*
entityAttribute
,
QWidget
*
parent
)
:
QWidget
(
parent
),
:
ComboBoxWidgetBase
(
i18n
(
"&Type:"
),
QString
(),
parent
),
m_attribute
(
0
),
m_datatype
(
0
),
m_entityAttribute
(
entityAttribute
),
...
...
@@ -70,7 +70,7 @@ UMLDatatypeWidget::UMLDatatypeWidget(UMLEntityAttribute *entityAttribute, QWidge
}
UMLDatatypeWidget
::
UMLDatatypeWidget
(
UMLOperation
*
operation
,
QWidget
*
parent
)
:
QWidget
(
parent
),
:
ComboBoxWidgetBase
(
i18n
(
"&Type:"
),
QString
(),
parent
),
m_attribute
(
0
),
m_datatype
(
0
),
m_entityAttribute
(
0
),
...
...
@@ -83,7 +83,7 @@ UMLDatatypeWidget::UMLDatatypeWidget(UMLOperation *operation, QWidget *parent)
}
UMLDatatypeWidget
::
UMLDatatypeWidget
(
UMLTemplate
*
_template
,
QWidget
*
parent
)
:
QWidget
(
parent
),
:
ComboBoxWidgetBase
(
i18n
(
"&Type:"
),
QString
(),
parent
),
m_attribute
(
0
),
m_datatype
(
0
),
m_entityAttribute
(
0
),
...
...
@@ -97,27 +97,7 @@ UMLDatatypeWidget::UMLDatatypeWidget(UMLTemplate *_template, QWidget *parent)
void
UMLDatatypeWidget
::
init
()
{
QHBoxLayout
*
layout
=
new
QHBoxLayout
;
layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
m_label
=
new
QLabel
(
i18n
(
"&Type:"
),
this
);
layout
->
addWidget
(
m_label
);
m_comboBox
=
new
KComboBox
(
true
,
this
);
layout
->
addWidget
(
m_comboBox
);
m_label
->
setBuddy
(
m_comboBox
);
m_comboBox
->
setDuplicatesEnabled
(
false
);
// only allow one of each type in box
#if QT_VERSION < 0x050000
m_comboBox
->
setCompletionMode
(
KGlobalSettings
::
CompletionPopup
);
#endif
setLayout
(
layout
);
connect
(
m_comboBox
,
SIGNAL
(
editTextChanged
(
QString
)),
this
,
SIGNAL
(
editTextChanged
(
QString
)));
}
UMLDatatypeWidget
::~
UMLDatatypeWidget
()
{
delete
m_comboBox
;
delete
m_label
;
connect
(
m_editField
,
SIGNAL
(
editTextChanged
(
QString
)),
this
,
SIGNAL
(
editTextChanged
(
QString
)));
}
bool
UMLDatatypeWidget
::
apply
()
...
...
@@ -137,7 +117,7 @@ bool UMLDatatypeWidget::apply()
bool
UMLDatatypeWidget
::
applyAttribute
()
{
QString
typeName
=
m_
comboBox
->
currentText
();
QString
typeName
=
m_
editField
->
currentText
();
UMLTemplate
*
tmplParam
=
m_parent
->
findTemplate
(
typeName
);
if
(
tmplParam
)
{
m_datatype
->
setType
(
tmplParam
);
...
...
@@ -183,7 +163,7 @@ bool UMLDatatypeWidget::applyAttribute()
bool
UMLDatatypeWidget
::
applyEntityAttribute
()
{
QString
typeName
=
m_
comboBox
->
currentText
();
QString
typeName
=
m_
editField
->
currentText
();
UMLDoc
*
pDoc
=
UMLApp
::
app
()
->
document
();
UMLClassifierList
dataTypes
=
pDoc
->
datatypes
();
foreach
(
UMLClassifier
*
dat
,
dataTypes
)
{
...
...
@@ -211,7 +191,7 @@ bool UMLDatatypeWidget::applyEntityAttribute()
bool
UMLDatatypeWidget
::
applyOperation
()
{
QString
typeName
=
m_
comboBox
->
currentText
();
QString
typeName
=
m_
editField
->
currentText
();
UMLTemplate
*
tmplParam
=
0
;
if
(
m_parent
)
{
tmplParam
=
m_parent
->
findTemplate
(
typeName
);
...
...
@@ -226,7 +206,7 @@ bool UMLDatatypeWidget::applyOperation()
bool
UMLDatatypeWidget
::
applyParameter
()
{
// set the type name
QString
typeName
=
m_
comboBox
->
currentText
();
QString
typeName
=
m_
editField
->
currentText
();
if
(
m_parent
==
0
)
{
uError
()
<<
"grandparent of "
<<
m_attribute
->
name
()
<<
" is not a UMLClassifier"
;
}
else
{
...
...
@@ -261,7 +241,7 @@ bool UMLDatatypeWidget::applyParameter()
bool
UMLDatatypeWidget
::
applyTemplate
()
{
QString
typeName
=
m_
comboBox
->
currentText
();
QString
typeName
=
m_
editField
->
currentText
();
UMLDoc
*
pDoc
=
UMLApp
::
app
()
->
document
();
UMLClassifierList
namesList
(
pDoc
->
concepts
());
foreach
(
UMLClassifier
*
obj
,
namesList
)
{
...
...
@@ -288,14 +268,14 @@ void UMLDatatypeWidget::initTypesBox(QStringList &types, const QString& type)
}
types
.
sort
();
m_
comboBox
->
clear
();
m_
comboBox
->
insertItems
(
-
1
,
types
);
m_
editField
->
clear
();
m_
editField
->
insertItems
(
-
1
,
types
);
int
currentIndex
=
m_
comboBox
->
findText
(
type
);
int
currentIndex
=
m_
editField
->
findText
(
type
);
if
(
currentIndex
>
-
1
)
{
m_
comboBox
->
setCurrentIndex
(
currentIndex
);
m_
editField
->
setCurrentIndex
(
currentIndex
);
}
m_
comboBox
->
completionObject
()
->
addItem
(
type
);
m_
editField
->
completionObject
()
->
addItem
(
type
);
}
/**
...
...
@@ -420,15 +400,3 @@ void UMLDatatypeWidget::insertTypesSortedTemplate(const QString& type)
insertTypesFromConcepts
(
types
,
false
);
initTypesBox
(
types
,
type
);
}
/**
* Add this widget to a given grid layout. Umbrello dialogs places labels in column 0
* and the editable field in column 1.
* @param layout The layout to which the widget should be added
* @param row The row in the grid layout where the widget should be placed
*/
void
UMLDatatypeWidget
::
addToLayout
(
QGridLayout
*
layout
,
int
row
,
int
startColumn
)
{
layout
->
addWidget
(
m_label
,
row
,
startColumn
);
layout
->
addWidget
(
m_comboBox
,
row
,
startColumn
+
1
);
}
umbrello/dialogs/widgets/umldatatypewidget.h
View file @
b795aa90
...
...
@@ -4,18 +4,15 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2016
*
* copyright (C) 2016
,2019
*
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
#ifndef UMLDATATYPEWIDGET_H
#define UMLDATATYPEWIDGET_H
#include
<QWidget>
#include
"comboboxwidgetbase.h"
class
KComboBox
;
class
QGridLayout
;
class
QLabel
;
class
UMLAttribute
;
class
UMLEntityAttribute
;
class
UMLClassifier
;
...
...
@@ -23,7 +20,7 @@ class UMLClassifierListItem;
class
UMLOperation
;
class
UMLTemplate
;
class
UMLDatatypeWidget
:
public
Q
Widget
class
UMLDatatypeWidget
:
public
ComboBox
Widget
Base
{
Q_OBJECT
public:
...
...
@@ -32,9 +29,7 @@ public:
UMLDatatypeWidget
(
UMLEntityAttribute
*
entityAttribute
,
QWidget
*
parent
=
0
);
UMLDatatypeWidget
(
UMLOperation
*
operation
,
QWidget
*
parent
=
0
);
UMLDatatypeWidget
(
UMLTemplate
*
_template
,
QWidget
*
parent
=
0
);
~
UMLDatatypeWidget
();
void
addToLayout
(
QGridLayout
*
layout
,
int
row
,
int
startColumn
=
0
);
bool
apply
();
void
reset
();
...
...
@@ -42,8 +37,6 @@ Q_SIGNALS:
void
editTextChanged
(
const
QString
&
);
protected:
QLabel
*
m_label
;
KComboBox
*
m_comboBox
;
UMLAttribute
*
m_attribute
;
UMLClassifierListItem
*
m_datatype
;
UMLEntityAttribute
*
m_entityAttribute
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment