[Uml-devel] branches/work/isi-umbrello/umbrello/umbrello
Florence Mattler
florence.mattler at libertysurf.fr
Fri Feb 16 05:19:27 UTC 2007
SVN commit 634031 by mattler:
Adding a delta which helps the user clicking the floatingdashline if he clicks near it
M +14 -0 floatingdashlinewidget.cpp
M +9 -0 floatingdashlinewidget.h
M +0 -1 linepath.cpp
M +23 -0 toolbarstate.cpp
M +11 -0 toolbarstate.h
M +5 -2 widget_factory.cpp
--- branches/work/isi-umbrello/umbrello/umbrello/floatingdashlinewidget.cpp #634030:634031
@@ -12,6 +12,7 @@
// own header
#include "floatingdashlinewidget.h"
#include "umlview.h"
+#include "widget_utils.h"
// qt includes
#include <qpainter.h>
@@ -46,6 +47,19 @@
m_text = text;
}
+bool FloatingDashLineWidget::onLine(const QPoint &point) {
+ /*check if the given point is the start or end point of the line */
+ if (( (abs( getY() + getHeight() - point.y() )) <= POINT_DELTA) || (abs( getY() - point.y() ) <= POINT_DELTA)) {
+ return true;
+ }
+ /* check if the given point is the start or end point of the line */
+ return false;
+}
+
+void FloatingDashLineWidget::selectLine(bool sel /* =true */) {
+
+}
+
void FloatingDashLineWidget::setY(int y)
{
if(y >= m_yMin + FLOATING_DASH_LINE_MARGIN && y <= m_yMax - FLOATING_DASH_LINE_MARGIN)
--- branches/work/isi-umbrello/umbrello/umbrello/floatingdashlinewidget.h #634030:634031
@@ -17,7 +17,10 @@
#define FLOATING_DASH_LINE_MARGIN 25
#define FLOATING_DASH_LINE_TEXT_MARGIN 5
+/* how many pixels a user could click around a point */
+#define POINT_DELTA 5
+
/**
* This class is used to draw dash lines for UML combined fragments. A FloatingDashLineWidget
* belongs to one @ref CombinedFragmentWidget instance.
@@ -50,6 +53,12 @@
*/
void draw(QPainter & p, int offsetX, int offsetY);
+
+ /**
+ * Returns true if the given point is near the floatingdashline
+ */
+ bool onLine(const QPoint & point);
+
/**
* Sets m_text
*/
--- branches/work/isi-umbrello/umbrello/umbrello/linepath.cpp #634030:634031
@@ -263,7 +263,6 @@
bool LinePath::setStartEndPoints( const QPoint &start, const QPoint &end ) {
int count = m_LineList.count();
- kDebug() << "setStartEndPoints!!!!!!!!!!!!! " <<count <<endl;
if( count == 0 ) {
Q3CanvasLine * line = new Q3CanvasLine(getCanvas() );
line -> setPoints( start.x(), start.y(),end.x(),end.y() );
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstate.cpp #634030:634031
@@ -18,6 +18,7 @@
// app includes
#include "associationwidget.h"
#include "messagewidget.h"
+#include "floatingdashlinewidget.h"
#include "uml.h"
#include "umlview.h"
#include "umlwidget.h"
@@ -173,6 +174,13 @@
setCurrentWidget(message);
return;
}
+
+ //TODO check why message widgets are treated different
+ FloatingDashLineWidget* floatingline = getFloatingLineAt(m_pMouseEvent->pos());
+ if (floatingline) {
+ setCurrentWidget(floatingline);
+ return;
+ }
// Check widgets.
UMLWidget *widget = m_pUMLView->testOnWidget(m_pMouseEvent->pos());
@@ -257,4 +265,19 @@
return association;
}
+FloatingDashLineWidget* ToolBarState::getFloatingLineAt(QPoint pos) {
+ FloatingDashLineWidget* floatingline = 0;
+ UMLWidget * widget = 0;
+ UMLWidgetListIt w_it(m_pUMLView->getWidgetList());
+ while( ( widget = w_it.current() ) ) {
+ ++w_it;
+ if (widget->getBaseType() == Uml::wt_FloatingDashLine){
+ if (dynamic_cast<FloatingDashLineWidget*>(widget)->onLine(pos)) {
+ floatingline = dynamic_cast<FloatingDashLineWidget*>(widget);
+ }
+ }
+ }
+
+ return floatingline;
+}
#include "toolbarstate.moc"
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstate.h #634030:634031
@@ -20,6 +20,7 @@
class AssociationWidget;
class MessageWidget;
+class FloatingDashLineWidget;
class UMLView;
class UMLWidget;
@@ -337,6 +338,16 @@
MessageWidget* getMessageAt(QPoint pos);
/**
+ * Returns the FloatingDashLineWidget at the specified position, or null if there is none.
+ * The floatingdashline is only returned if it is visible.
+ *
+ * @param pos The position to get the floatingLine.
+ * @return The MessageWidget at the specified position, or null if there is none.
+ */
+ FloatingDashLineWidget* getFloatingLineAt(QPoint pos);
+
+
+ /**
* The UMLView.
*/
UMLView* m_pUMLView;
--- branches/work/isi-umbrello/umbrello/umbrello/widget_factory.cpp #634030:634031
@@ -55,6 +55,7 @@
#include "preconditionwidget.h"
#include "endoflifewidget.h"
#include "signalwidget.h"
+#include "floatingdashlinewidget.h"
#include "cmds.h"
namespace Widget_Factory {
@@ -196,10 +197,12 @@
widget = new CombinedFragmentWidget(view, CombinedFragmentWidget::Ref, Uml::id_Reserved);
} else if (tag == "signalwidget") {
widget = new SignalWidget(view, SignalWidget::Send, Uml::id_Reserved);
+ } else if (tag == "floatingdashline") {
+ widget = new FloatingDashLineWidget(view,Uml::id_Reserved);
} else if (tag == "objectflowwidget") {
widget = new ObjectFlowWidget(view,Uml::id_Reserved);
- }
- } else {
+ }
+ else {
// Find the UMLObject and create the Widget to represent it
Uml::IDType id = STR2ID(idStr);
UMLDoc *umldoc = UMLApp::app()->getDocument();
More information about the umbrello-devel
mailing list