[Uml-devel] branches/work/soc-umbrello/umbrello
Gopala Krishna A
krishna.ggk at gmail.com
Mon Aug 31 21:54:44 UTC 2009
SVN commit 1017924 by gopala:
Implemented explicit visibility feature for TextItem so that they are
not visible when parent item is hidden while the child(TextItem) is shown.
M +15 -1 textitem.cpp
M +7 -0 textitem.h
M +7 -0 textitemgroup.cpp
M +2 -0 textitemgroup.h
M +10 -10 widgets/activitywidget.cpp
M +1 -1 widgets/artifactwidget.cpp
M +4 -4 widgets/classifierwidget.cpp
M +4 -4 widgets/combinedfragmentwidget.cpp
M +1 -1 widgets/componentwidget.cpp
M +1 -1 widgets/entitywidget.cpp
M +1 -1 widgets/floatingtextwidget.cpp
M +1 -1 widgets/nodewidget.cpp
M +7 -7 widgets/notewidget.cpp
M +2 -2 widgets/objectnodewidget.cpp
M +1 -1 widgets/packagewidget.cpp
M +2 -2 widgets/statewidget.cpp
M +4 -0 widgets/umlwidget.cpp
--- branches/work/soc-umbrello/umbrello/textitem.cpp #1017923:1017924
@@ -100,7 +100,8 @@
* @param parent The parent of this item.
*/
TextItem::TextItem(const QString& text, QGraphicsItem *parent) :
- QGraphicsTextItem(text, parent)
+ QGraphicsTextItem(text, parent),
+ m_explicitVisiblity(true)
{
setAcceptHoverEvents(false);
}
@@ -263,6 +264,19 @@
other->setBackgroundBrush(backgroundBrush());
}
+void TextItem::setExplicitVisibility(bool b)
+{
+ m_explicitVisiblity = b;
+ updateVisibility();
+}
+
+void TextItem::updateVisibility()
+{
+ bool actual = m_explicitVisiblity &&
+ (!parentItem() || parentItem()->isVisible());
+ setVisible(actual);
+}
+
void TextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *)
{
update();
--- branches/work/soc-umbrello/umbrello/textitem.h #1017923:1017924
@@ -80,6 +80,12 @@
void copyAttributesTo(TextItem *other) const;
+ bool explicitVisiblity() const {
+ return m_explicitVisiblity;
+ }
+ void setExplicitVisibility(bool b);
+ void updateVisibility();
+
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
@@ -89,6 +95,7 @@
QBrush m_hoverBrush;
QBrush m_backgroundBrush;
+ bool m_explicitVisiblity;
};
#endif //TEXTITEM_H
--- branches/work/soc-umbrello/umbrello/textitemgroup.cpp #1017923:1017924
@@ -193,6 +193,13 @@
m_groupGeometry = rect;
}
+void TextItemGroup::updateVisibility()
+{
+ foreach (TextItem *item, m_textItems) {
+ item->updateVisibility();
+ }
+}
+
void TextItemGroup::setAlignment(Qt::Alignment align)
{
m_alignment = align;
--- branches/work/soc-umbrello/umbrello/textitemgroup.h #1017923:1017924
@@ -82,6 +82,8 @@
}
void setGroupGeometry(const QRectF& rect);
+ void updateVisibility();
+
Qt::Alignment alignment() const {
return m_alignment;
}
--- branches/work/soc-umbrello/umbrello/widgets/activitywidget.cpp #1017923:1017924
@@ -242,28 +242,28 @@
TextItem *nameItem = grp->textItemAt(NameItemIndex);
nameItem->setText(name());
- nameItem->show();
+ nameItem->setExplicitVisibility(true);
if(m_activityType == Normal || m_activityType == Invok) {
- grp->textItemAt(PrecondtionItemIndex)->hide();
- grp->textItemAt(PostconditionItemIndex)->hide();
- nameItem->show();
+ grp->textItemAt(PrecondtionItemIndex)->setExplicitVisibility(false);
+ grp->textItemAt(PostconditionItemIndex)->setExplicitVisibility(false);
+ nameItem->setExplicitVisibility(true);
}
else if(m_activityType == Param) {
TextItem *preconditionItem = grp->textItemAt(PrecondtionItemIndex);
preconditionItem->setText(preconditionText().prepend("<<precondition>> "));
- preconditionItem->show();
+ preconditionItem->setExplicitVisibility(true);
TextItem *postconditionItem = grp->textItemAt(PostconditionItemIndex);
postconditionItem->setText(postconditionText().prepend("<<postcondition>> "));
- postconditionItem->show();
+ postconditionItem->setExplicitVisibility(true);
- nameItem->show();
+ nameItem->setExplicitVisibility(true);
}
else {
- grp->textItemAt(PrecondtionItemIndex)->hide();
- grp->textItemAt(PostconditionItemIndex)->hide();
- nameItem->hide();
+ grp->textItemAt(PrecondtionItemIndex)->setExplicitVisibility(false);
+ grp->textItemAt(PostconditionItemIndex)->setExplicitVisibility(false);
+ nameItem->setExplicitVisibility(false);
}
UMLWidget::updateTextItemGroups();
--- branches/work/soc-umbrello/umbrello/widgets/artifactwidget.cpp #1017923:1017924
@@ -149,7 +149,7 @@
stereoItem->setText(artifact->getStereotype(true));
bool hideStereo = artifact->getStereotype(false).isEmpty()
|| artifact->getDrawAsType() != UMLArtifact::defaultDraw ;
- stereoItem->setVisible(!hideStereo);
+ stereoItem->setExplicitVisibility(!hideStereo);
TextItem *nameItem = grp->textItemAt(ArtifactWidget::NameItemIndex);
nameItem->setText(name());
--- branches/work/soc-umbrello/umbrello/widgets/classifierwidget.cpp #1017923:1017924
@@ -622,7 +622,7 @@
for(int i = 0; i < tlist.size(); ++i) {
UMLTemplate *t = tlist[i];
templateGroup->textItemAt(i)->setText(t->toString());
- templateGroup->textItemAt(i)->setVisible(!templateHide);
+ templateGroup->textItemAt(i)->setExplicitVisibility(!templateHide);
}
// Stereo type and name.
@@ -640,7 +640,7 @@
bool v = !shouldDrawAsCircle()
&& visualProperty(ShowStereotype)
&& !(umlC->getStereotype(false).isEmpty());
- stereoItem->setVisible(v);
+ stereoItem->setExplicitVisibility(v);
// name item is always visible.
TextItem *nameItem = headerGroup->textItemAt(NameItemIndex);
@@ -674,7 +674,7 @@
|| obj->getVisibility() == Uml::Visibility::Public)
&& visualProperty(ShowAttributes) == true;
- item->setVisible(v);
+ item->setExplicitVisibility(v);
if (v) {
++visibleAttributes;
}
@@ -718,7 +718,7 @@
|| obj->getVisibility() == Uml::Visibility::Public)
&& visualProperty(ShowOperations);
- item->setVisible(v);
+ item->setExplicitVisibility(v);
if (v) {
++visibleOperations;
}
--- branches/work/soc-umbrello/umbrello/widgets/combinedfragmentwidget.cpp #1017923:1017924
@@ -370,14 +370,14 @@
TextItem *refItem = nameGroup->textItemAt(0);
- firstAltItem->hide();
- refItem->hide();
+ firstAltItem->setExplicitVisibility(false);
+ refItem->setExplicitVisibility(false);
switch(combinedFragmentType()) {
case Ref:
typeItem->setText("ref");
refItem->setText(combinedFragmentValue);
- refItem->show();
+ refItem->setExplicitVisibility(true);
break;
case Opt:
@@ -419,7 +419,7 @@
temp.append(']');
firstAltItem->setText(temp);
- firstAltItem->show();
+ firstAltItem->setExplicitVisibility(true);
}
break;
--- branches/work/soc-umbrello/umbrello/widgets/componentwidget.cpp #1017923:1017924
@@ -98,7 +98,7 @@
TextItem *stereo = grp->textItemAt(StereoItemIndex);
stereo->setText(umlObject()->getStereotype(true));
stereo->setBold(true);
- stereo->setVisible(umlObject()->getStereotype(false).isEmpty() == false);
+ stereo->setExplicitVisibility(umlObject()->getStereotype(false).isEmpty() == false);
TextItem *nameItem = grp->textItemAt(NameItemIndex);
nameItem->setBold(true);
--- branches/work/soc-umbrello/umbrello/widgets/entitywidget.cpp #1017923:1017924
@@ -101,7 +101,7 @@
stereo->setText(classifier->getStereotype(true));
stereo->setBold(true);
bool hideStereo = classifier->getStereotype(false).isEmpty();
- stereo->setVisible(!hideStereo);
+ stereo->setExplicitVisibility(!hideStereo);
TextItem *nameItem = grp->textItemAt(EntityWidget::NameItemIndex);
nameItem->setText(name());
--- branches/work/soc-umbrello/umbrello/widgets/floatingtextwidget.cpp #1017923:1017924
@@ -484,7 +484,7 @@
TextItem *item = grp->textItemAt(0);
item->setText(displayText());
- item->show();
+ item->setExplicitVisibility(true);
UMLWidget::updateTextItemGroups();
}
--- branches/work/soc-umbrello/umbrello/widgets/nodewidget.cpp #1017923:1017924
@@ -94,7 +94,7 @@
TextItem *stereo = grp->textItemAt(NodeWidget::StereoItemIndex);
stereo->setText(node->getStereotype(true));
stereo->setBold(true);
- stereo->setVisible(!node->getStereotype(false).isEmpty());
+ stereo->setExplicitVisibility(!node->getStereotype(false).isEmpty());
TextItem *nameItem = grp->textItemAt(NodeWidget::NameItemIndex);
QString nameText = name();
--- branches/work/soc-umbrello/umbrello/widgets/notewidget.cpp #1017923:1017924
@@ -191,9 +191,9 @@
// still. (happens during creation of object)
if(grp->textItemCount() > NoteTextItemIndex) {
TextItem *noteTextItem = grp->textItemAt(NoteTextItemIndex);
- noteTextItem->hide();
+ noteTextItem->setExplicitVisibility(false);
widthWithoutNote = grp->minimumSize().width();
- noteTextItem->show();
+ noteTextItem->setExplicitVisibility(true);
}
const qreal atleast6Chars = QFontMetricsF(grp->font()).width("w") * 6;
@@ -215,24 +215,24 @@
grp->setTextItemCount(TextItemCount);
TextItem *diagramLinkItem = grp->textItemAt(DiagramLinkItemIndex);
- diagramLinkItem->hide();
+ diagramLinkItem->setExplicitVisibility(false);
//FIXME: Fixe diagram link drawing
TextItem *noteTypeItem = grp->textItemAt(NoteTypeItemIndex);
if(m_noteType == NoteWidget::PreCondition) {
noteTypeItem->setText(i18n("<< precondition >>"));
- noteTypeItem->show();
+ noteTypeItem->setExplicitVisibility(true);
}
else if(m_noteType == NoteWidget::PostCondition) {
noteTypeItem->setText(i18n("<< postcondition >>"));
- noteTypeItem->show();
+ noteTypeItem->setExplicitVisibility(true);
}
else if(m_noteType == NoteWidget::Transformation) {
noteTypeItem->setText(i18n("<< transformation >>"));
- noteTypeItem->show();
+ noteTypeItem->setExplicitVisibility(true);
}
else { // = NoteWidget::Normal
- noteTypeItem->hide();
+ noteTypeItem->setExplicitVisibility(false);
}
TextItem *noteTextItem = grp->textItemAt(NoteTextItemIndex);
--- branches/work/soc-umbrello/umbrello/widgets/objectnodewidget.cpp #1017923:1017924
@@ -284,10 +284,10 @@
}
grp->textItemAt(0)->setText(first);
- grp->textItemAt(0)->setVisible(visible);
+ grp->textItemAt(0)->setExplicitVisibility(visible);
grp->textItemAt(1)->setText(second);
- grp->textItemAt(1)->setVisible(visible);
+ grp->textItemAt(1)->setExplicitVisibility(visible);
UMLWidget::updateTextItemGroups();
}
--- branches/work/soc-umbrello/umbrello/widgets/packagewidget.cpp #1017923:1017924
@@ -99,7 +99,7 @@
TextItem *stereo = grp->textItemAt(PackageWidget::StereoTypeItemIndex);
stereo->setText(umlObject()->getStereotype(true));
stereo->setBold(true);
- stereo->setVisible(umlObject()->getStereotype().isEmpty() == false);
+ stereo->setExplicitVisibility(umlObject()->getStereotype().isEmpty() == false);
TextItem *nameItem = grp->textItemAt(PackageWidget::NameItemIndex);
nameItem->setText(name());
--- branches/work/soc-umbrello/umbrello/widgets/statewidget.cpp #1017923:1017924
@@ -423,7 +423,7 @@
TextItemGroup *grp = textItemGroupAt(GroupIndex);
if (m_stateType != StateWidget::Normal) {
for (int i = 0; i < grp->textItemCount(); ++i) {
- grp->textItemAt(i)->hide();
+ grp->textItemAt(i)->setExplicitVisibility(false);
}
}
else {
@@ -435,7 +435,7 @@
}
for (int i = 0; i < sz; ++i) {
TextItem *item = grp->textItemAt(i);
- item->show();
+ item->setExplicitVisibility(true);
}
grp->textItemAt(StateWidget::NameItemIndex)->setText(name());
grp->textItemAt(StateWidget::NameItemIndex)->setBold(sz > 1);
--- branches/work/soc-umbrello/umbrello/widgets/umlwidget.cpp #1017923:1017924
@@ -515,6 +515,10 @@
} else if (change == QGraphicsItem::ItemPositionHasChanged) {
// adjust the association lines by new computations.
adjustAssociations();
+ } else if (change == QGraphicsItem::ItemVisibleHasChanged) {
+ foreach (TextItemGroup *grp, m_textItemGroups) {
+ grp->updateVisibility();
+ }
}
return WidgetBase::itemChange(change, value);
}
More information about the umbrello-devel
mailing list