[Uml-devel] KDE/kdesdk/umbrello/umbrello/widgets
Andi Fischer
andi.fischer at hispeed.ch
Thu Jan 5 08:51:36 UTC 2012
SVN commit 1271761 by fischer:
Cleanup of code.
M +20 -40 notewidget.cpp
M +16 -24 notewidget.h
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/notewidget.cpp #1271760:1271761
@@ -4,19 +4,21 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
- * copyright (C) 2002-2011 *
+ * copyright (C) 2002-2012 *
* Umbrello UML Modeller Authors <uml-devel at uml.sf.net> *
***************************************************************************/
// own header
#include "notewidget.h"
+
//qt includes
#include <QtGui/QPainter>
-#include <QtGui/QFrame>
+
// kde includes
#include <klocale.h>
#include <kcolordialog.h>
#include <kinputdialog.h>
+
// app includes
#include "debug_utils.h"
#include "dialog_utils.h"
@@ -36,16 +38,16 @@
* The default (-1) will prompt a new ID.
*/
NoteWidget::NoteWidget(UMLScene * scene, NoteType noteType , Uml::IDType id)
- : UMLWidget(scene, id, new NoteWidgetController(this))
+ : UMLWidget(scene, id, new NoteWidgetController(this)),
+ m_diagramLink(Uml::id_None),
+ m_noteType(noteType)
{
UMLWidget::setBaseType(WidgetBase::wt_Note);
- m_diagramLink = Uml::id_None;
- m_noteType = noteType;
setZ(20); //make sure always on top.
}
/**
- * destructor
+ * Destructor.
*/
NoteWidget::~NoteWidget()
{
@@ -105,15 +107,15 @@
/**
* Returns the type of note.
*/
-NoteWidget::NoteType NoteWidget::getNoteType() const
+NoteWidget::NoteType NoteWidget::noteType() const
{
return m_noteType;
}
/**
- * Returns the type of note.
+ * Converts a string to NoteWidget::NoteType.
*/
-NoteWidget::NoteType NoteWidget::getNoteType(const QString& noteType) const
+NoteWidget::NoteType NoteWidget::stringToNoteType(const QString& noteType)
{
if (noteType == "Precondition")
return NoteWidget::PreCondition;
@@ -138,34 +140,10 @@
*/
void NoteWidget::setNoteType( const QString& noteType )
{
- setNoteType(getNoteType(noteType));
+ setNoteType(stringToNoteType(noteType));
}
/**
- * Override method from UMLWidget.
- */
-void NoteWidget::setFont(QFont font)
-{
- UMLWidget::setFont(font);
-}
-
-/**
- * Override method from UMLWidget.
- */
-void NoteWidget::setX( int x )
-{
- UMLWidget::setX(x);
-}
-
-/**
- * Override method from UMLWidget.
- */
-void NoteWidget::setY( int y )
-{
- UMLWidget::setY(y);
-}
-
-/**
* Returns the text in the box.
*
* @return The text in the box.
@@ -192,7 +170,7 @@
* @return ID of an UMLView, or Uml::id_None if no
* hyperlink is set.
*/
-Uml::IDType NoteWidget::getDiagramLink() const
+Uml::IDType NoteWidget::diagramLink() const
{
return m_diagramLink;
}
@@ -217,20 +195,23 @@
}
/**
-* Display a dialogBox to allow the user to choose the note's type
+ * Display a dialog box to allow the user to choose the note's type.
*/
void NoteWidget::askForNoteType(UMLWidget* &targetWidget)
{
+ static const QStringList list = QStringList() << i18n("Precondition")
+ << i18n("Postcondition")
+ << i18n("Transformation");
bool pressedOK = false;
- const QStringList list = QStringList() << "Precondition" << "Postcondition" << "Transformation";
- QString type = KInputDialog::getItem (i18n("Note Type"), i18n("Select the Note Type"), list, 0, false, &pressedOK, UMLApp::app());
+ QString type = KInputDialog::getItem (i18n("Note Type"), i18n("Select the Note Type"), list,
+ 0, false, &pressedOK, UMLApp::app());
if (pressedOK) {
dynamic_cast<NoteWidget*>(targetWidget)->setNoteType(type);
} else {
targetWidget->cleanup();
delete targetWidget;
- targetWidget = NULL;
+ targetWidget = 0;
}
}
@@ -487,4 +468,3 @@
}
#include "notewidget.moc"
-
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/notewidget.h #1271760:1271761
@@ -4,7 +4,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
- * copyright (C) 2002-2010 *
+ * copyright (C) 2002-2012 *
* Umbrello UML Modeller Authors <uml-devel at uml.sf.net> *
***************************************************************************/
@@ -36,6 +36,7 @@
public:
friend class NoteWidgetController;
+ /// This enum type is used to specify the type of note.
enum NoteType
{
Normal,
@@ -43,50 +44,41 @@
PostCondition,
Transformation
};
- explicit NoteWidget(UMLScene * scene, NoteWidget::NoteType noteType = Normal, Uml::IDType id = Uml::id_None );
+
+ explicit NoteWidget(UMLScene * scene, NoteWidget::NoteType noteType = Normal,
+ Uml::IDType id = Uml::id_None);
virtual ~NoteWidget();
- void paint(QPainter & p, int offsetX, int offsetY);
+ static NoteType stringToNoteType(const QString& noteType);
- NoteType getNoteType() const;
- NoteType getNoteType(const QString& noteType) const;
+ NoteType noteType() const;
void setNoteType( NoteType noteType );
void setNoteType( const QString& noteType );
QString documentation() const;
void setDocumentation(const QString &newText);
- Uml::IDType getDiagramLink() const;
+ Uml::IDType diagramLink() const;
void setDiagramLink(Uml::IDType viewID);
- // this method is obsolate
- void setFont(QFont font);
+ virtual void paint(QPainter & p, int offsetX, int offsetY);
- // this method is obsolate
- void setX(int x);
- // this method is obsolate
- void setY(int y);
-
void askForNoteType(UMLWidget* &targetWidget);
- bool loadFromXMI( QDomElement & qElement );
- void saveToXMI( QDomDocument & qDoc, QDomElement & qElement );
+ virtual bool loadFromXMI(QDomElement & qElement);
+ virtual void saveToXMI(QDomDocument & qDoc, QDomElement & qElement);
-
public Q_SLOTS:
void slotMenuSelection(QAction* action);
protected:
- QSize calculateSize();
- void drawText(QPainter * p = NULL, int offsetX = 0, int offsetY = 0);
- void drawTextWordWrap(QPainter * p = NULL, int offsetX = 0, int offsetY = 0);
+ virtual QSize calculateSize();
+ void drawText(QPainter * p = 0, int offsetX = 0, int offsetY = 0);
+ void drawTextWordWrap(QPainter * p = 0, int offsetX = 0, int offsetY = 0);
- Uml::IDType m_diagramLink; ///< Data loaded/saved.
- NoteType m_noteType; ///< Type of note.
- QString m_type; ///< Label to see the note's type.
-
-
private:
+ Uml::IDType m_diagramLink; ///< The diagram/scene this note links to.
+ NoteType m_noteType; ///< The type of note. @see NoteWidget::NoteType
QString m_Text;
};
More information about the umbrello-devel
mailing list