[Uml-devel] branches/work/soc-umbrello/umbrello
Andi Fischer
andi.fischer at hispeed.ch
Thu Sep 10 10:16:25 UTC 2009
SVN commit 1021933 by fischer:
Fixes a crash when rdouble clicking a diagram in the tree view and renaming it in the dialog. Also some minor code formatting added.
M +11 -8 dialogs/umlviewdialog.cpp
M +23 -21 uml.cpp
M +3 -8 uml.h
M +9 -8 umldoc.cpp
M +0 -1 umlnamespace.h
M +11 -17 umlscene.cpp
M +0 -20 umlscene.h
--- branches/work/soc-umbrello/umbrello/dialogs/umlviewdialog.cpp #1021932:1021933
@@ -205,23 +205,26 @@
*/
void UMLViewDialog::checkName()
{
- QString name = m_diagramProperties->ui_diagramName->text();
- UMLDoc * pDoc = UMLApp::app()->getDocument();
- UMLScene * pScene = pDoc->findView( m_pScene->getType(), name )->umlScene();
- if ( name.length() == 0 ) {
+ QString newName = m_diagramProperties->ui_diagramName->text();
+ if ( newName.length() == 0 ) {
KMessageBox::sorry(this, i18n("The name you have entered is invalid."),
i18n("Invalid Name"), false);
m_diagramProperties->ui_diagramName->setText( m_pScene->getName() );
return;
}
- if ( pScene && pScene != m_pScene ) {
+
+ UMLDoc* doc = UMLApp::app()->getDocument();
+ UMLView* view = doc->findView( m_pScene->getType(), newName);
+ if (view) {
KMessageBox::sorry(this, i18n("The name you have entered is not unique."),
i18n("Name Not Unique"), false);
m_diagramProperties->ui_diagramName->setText( m_pScene->getName() );
- return;
}
- m_pScene->setName( name );
- pDoc->signalDiagramRenamed(m_pScene->activeView());
+ else {
+ // uDebug() << "Cannot find view with name " << newName;
+ m_pScene->setName( newName );
+ doc->signalDiagramRenamed(m_pScene->activeView());
+ }
}
--- branches/work/soc-umbrello/umbrello/uml.cpp #1021932:1021933
@@ -173,7 +173,7 @@
m_imageExporterAll = new UMLViewImageExporterAll();
setAutoSaveSettings();
- toolsbar->setToolButtonStyle(Qt::ToolButtonIconOnly); //too many items for text, really we want a toolbox widget
+ m_toolsbar->setToolButtonStyle(Qt::ToolButtonIconOnly); // too many items for text, really we want a toolbox widget
}
/**
@@ -641,9 +641,9 @@
{
setCaption(m_doc->url().fileName(),false);
m_view = NULL;
- toolsbar = new WorkToolBar(this);
- toolsbar->setWindowTitle(i18n("Diagram Toolbar"));
- addToolBar(Qt::TopToolBarArea, toolsbar);
+ m_toolsbar = new WorkToolBar(this);
+ m_toolsbar->setWindowTitle(i18n("Diagram Toolbar"));
+ addToolBar(Qt::TopToolBarArea, m_toolsbar);
// m_mainDock = new QDockWidget( this );
// addDockWidget ( Qt::RightDockWidgetArea, m_mainDock );
@@ -688,6 +688,7 @@
widget->setLayout(m_layout);
setCentralWidget(widget);
+ // create the tree viewer
m_listDock = new QDockWidget( i18n("&Tree View"), this );
m_listDock->setObjectName("TreeViewDock");
addDockWidget(Qt::LeftDockWidgetArea, m_listDock);
@@ -697,31 +698,32 @@
m_listView->init();
m_listDock->setWidget(m_listView);
+ // create the documentation viewer
m_documentationDock = new QDockWidget( i18n("Doc&umentation"), this );
m_documentationDock->setObjectName("DocumentationDock");
-
addDockWidget(Qt::LeftDockWidgetArea, m_documentationDock);
m_pDocWindow = new DocWindow(m_doc, m_documentationDock);
m_pDocWindow->setObjectName("DOCWINDOW");
m_documentationDock->setWidget(m_pDocWindow);
- m_doc->setupSignals();//make sure gets signal from list view
+ m_doc->setupSignals(); // make sure gets signal from list view
+ // create the command history viewer
m_cmdHistoryDock = new QDockWidget(i18n("Co&mmand history"), this);
m_cmdHistoryDock->setObjectName("CmdHistoryDock");
addDockWidget(Qt::LeftDockWidgetArea, m_cmdHistoryDock);
- // create cmd history view
m_pQUndoView = new QUndoView(m_cmdHistoryDock);
- m_cmdHistoryDock->setWidget(m_pQUndoView);
m_pQUndoView->setCleanIcon(Icon_Utils::SmallIcon(Icon_Utils::it_UndoView));
m_pQUndoView->setStack(m_pUndoStack);
+ m_cmdHistoryDock->setWidget(m_pQUndoView);
- // Create the property viewer
+ // create the property viewer
//m_propertyDock = new QDockWidget(i18n("&Properties"), this);
- //addDockWidget(Qt::LeftDockWidgetArea, m_propertyDock);
+ //m_propertyDock->setObjectName("PropertyDock");
+ //addDockWidget(Qt::LeftDockWidgetArea, m_propertyDock); //:TODO:
tabifyDockWidget(m_documentationDock, m_cmdHistoryDock);
- //tabifyDockWidget(m_cmdHistoryDock, m_propertyDock);
+ //tabifyDockWidget(m_cmdHistoryDock, m_propertyDock); //:TODO:
}
/**
@@ -769,7 +771,7 @@
KConfigGroup cg( m_config, "toolbar" );
toolBar("mainToolBar")->saveSettings( cg );
KConfigGroup workBarConfig(m_config, "workbar" );
- toolsbar->saveSettings(workBarConfig );
+ m_toolsbar->saveSettings(workBarConfig );
fileOpenRecent->saveEntries( m_config->group( "Recent Files") );
UmbrelloSettings::setGeometry( size() );
@@ -881,7 +883,7 @@
// bar status settings
toolBar("mainToolBar")->applySettings(m_config->group( "toolbar") );
// do config for work toolbar
- toolsbar->applySettings(m_config->group( "workbar") );
+ m_toolsbar->applySettings(m_config->group( "workbar") );
fileOpenRecent->loadEntries(m_config->group( "Recent Files") );
setImageMimeType( UmbrelloSettings::imageMimeType() );
resize( UmbrelloSettings::geometry());
@@ -1462,7 +1464,7 @@
*/
WorkToolBar* UMLApp::getWorkToolBar()
{
- return toolsbar;
+ return m_toolsbar;
}
/**
@@ -2420,7 +2422,7 @@
{
switch(e->key()) {
case Qt::Key_Shift:
- //toolsbar->setOldTool();
+ //m_toolsbar->setOldTool();
e->accept();
break;
@@ -2491,12 +2493,12 @@
switch(e->key()) {
case Qt::Key_Backspace:
if (!m_pDocWindow->isTyping()) {
- toolsbar->setOldTool();
+ m_toolsbar->setOldTool();
}
e->accept();
break;
case Qt::Key_Escape:
- toolsbar->setDefaultTool();
+ m_toolsbar->setDefaultTool();
e->accept();
break;
case Qt::Key_Left:
@@ -2625,7 +2627,7 @@
UMLViewList views = m_doc->getViewIterator();
UMLView *currView = m_view;
int viewIndex = 0;
- if ( (viewIndex = views.indexOf(currView)) < 0) {
+ if ((viewIndex = views.indexOf(currView)) < 0) {
uError() << "currView not found in viewlist";
return;
}
@@ -2655,7 +2657,7 @@
UMLViewList views = m_doc->getViewIterator();
UMLView *currView = m_view;
int viewIndex = 0;
- if (( viewIndex = views.indexOf(currView) ) < 0) {
+ if ((viewIndex = views.indexOf(currView)) < 0) {
uError() << "currView not found in viewlist";
return;
}
@@ -2813,7 +2815,7 @@
/**
* Begin a U/R command macro
*/
-void UMLApp::BeginMacro( const QString & text )
+void UMLApp::beginMacro( const QString & text )
{
if (m_hasBegunMacro) {
return;
@@ -2826,7 +2828,7 @@
/**
* End an U/R command macro
*/
-void UMLApp::EndMacro()
+void UMLApp::endMacro()
{
if (m_hasBegunMacro) {
m_pUndoStack->endMacro();
--- branches/work/soc-umbrello/umbrello/uml.h #1021932:1021933
@@ -18,7 +18,6 @@
#include <ksharedconfig.h>
// forward declaration of the UML classes
-class AlignToolBar;
class CodeDocument;
class CodeGenerator;
class CodeGenerationPolicy;
@@ -147,10 +146,9 @@
void executeCommand(QUndoCommand* cmd);
- void BeginMacro( const QString & text );
+ void beginMacro( const QString & text );
+ void endMacro();
- void EndMacro();
-
protected:
virtual void keyPressEvent(QKeyEvent* e);
virtual void keyReleaseEvent(QKeyEvent* e);
@@ -371,12 +369,9 @@
QToolButton* m_newSessionButton;
KMenu* m_diagramMenu;
- KToggleAction* viewToolBar;
- KToggleAction* viewStatusBar;
- WorkToolBar* toolsbar;
+ WorkToolBar* m_toolsbar;
QTimer* m_clipTimer;
QTimer* m_copyTimer;
- AlignToolBar* m_alignToolBar;
bool m_loading; ///< True if the application is opening an existing document.
--- branches/work/soc-umbrello/umbrello/umldoc.cpp #1021932:1021933
@@ -135,7 +135,7 @@
connect(this, SIGNAL(sigDiagramCreated(Uml::IDType)), pApp, SLOT(slotUpdateViews()));
connect(this, SIGNAL(sigDiagramRemoved(Uml::IDType)), pApp, SLOT(slotUpdateViews()));
connect(this, SIGNAL(sigDiagramRenamed(Uml::IDType)), pApp, SLOT(slotUpdateViews()));
- connect(this, SIGNAL( sigCurrentViewChanged() ), pApp, SLOT( slotCurrentViewChanged() ) );
+ connect(this, SIGNAL(sigCurrentViewChanged()), pApp, SLOT(slotCurrentViewChanged()));
}
/**
@@ -1261,7 +1261,7 @@
}
/**
- * Used to rename a document. This method takes care of everything.
+ * Used to rename a document. This method takes care of everything.
* You just need to give the ID of the diagram to the method.
*
* @param id The ID of the diagram to rename.
@@ -1270,10 +1270,10 @@
{
bool ok = false;
- UMLView *temp = findView(id);
- Diagram_Type type = temp->umlScene()->getType();
+ UMLView *view = findView(id);
+ Diagram_Type type = view->umlScene()->getType();
- QString oldName= temp->umlScene()->getName();
+ QString oldName= view->umlScene()->getName();
while (true) {
QString name = KInputDialog::getText(i18nc("renaming diagram", "Name"), i18n("Enter name:"), oldName, &ok, (QWidget*)UMLApp::app());
@@ -1284,13 +1284,14 @@
KMessageBox::error(0, i18n("That is an invalid name for a diagram."), i18n("Invalid Name"));
}
else if (!findView(type, name)) {
- temp->umlScene()->setName(name);
-
+ view->umlScene()->setName(name);
emit sigDiagramRenamed(id);
setModified(true);
break;
- } else
+ }
+ else {
KMessageBox::error(0, i18n("A diagram is already using that name."), i18n("Not a Unique Name"));
+ }
}
}
--- branches/work/soc-umbrello/umbrello/umlnamespace.h #1021932:1021933
@@ -1,5 +1,4 @@
/***************************************************************************
- * *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
--- branches/work/soc-umbrello/umbrello/umlscene.cpp #1021932:1021933
@@ -878,7 +878,6 @@
AssociationWidget * UMLScene::findAssocWidget(Uml::Association_Type at,
UMLWidget *pWidgetA, UMLWidget *pWidgetB)
{
-
foreach(AssociationWidget* assoc, m_AssociationList) {
Association_Type testType = assoc->associationType();
if (testType != at) {
@@ -1128,7 +1127,7 @@
*/
void UMLScene::selectionSetLineColor(const QColor &color)
{
- UMLApp::app()->BeginMacro("Change Line Color");
+ UMLApp::app()->beginMacro("Change Line Color");
foreach(UMLWidget *temp , selectedWidgets()) {
temp->setLineColor(color);
// [PORT] temp->setUsesDiagramLineColour(false);
@@ -1138,7 +1137,7 @@
aw->setLineColor(color);
// [PORT] aw->setUsesDiagramLineColour(false);
}
- UMLApp::app()->EndMacro();
+ UMLApp::app()->endMacro();
}
/**
@@ -1162,13 +1161,13 @@
*/
void UMLScene::selectionSetFillColor(const QColor &color)
{
- UMLApp::app()->BeginMacro("Change Fill Color");
+ UMLApp::app()->beginMacro("Change Fill Color");
foreach(UMLWidget* temp , selectedWidgets()) {
temp->setFillColour(color);
// [PORT] temp->setUsesDiagramFillColour(false);
}
- UMLApp::app()->EndMacro();
+ UMLApp::app()->endMacro();
}
/**
@@ -1579,7 +1578,7 @@
} else {
WidgetList.append(temp);
}
- }//end for
+ }
return true;
}
@@ -1976,7 +1975,7 @@
void UMLScene::endPartialWidgetPaste()
{
- delete m_pIDChangesLog;
+ delete m_pIDChangesLog;
m_pIDChangesLog = 0;
m_bPaste = false;
@@ -2035,10 +2034,11 @@
}
}
-/** Removes all the associations related to Widget */
+/**
+ * Removes all the associations related to Widget.
+ */
void UMLScene::removeAssociations(UMLWidget* Widget)
{
-
foreach(AssociationWidget* assocwidget, m_AssociationList) {
if (assocwidget->containsWidget(Widget)) {
removeAssoc(assocwidget);
@@ -2062,7 +2062,7 @@
} else {
assocwidget->setSelected(false);
}
- }//end foreach
+ }
}
/**
@@ -2077,7 +2077,7 @@
if (assocwidget->widgetForRole(Uml::A)->umlObject() == Obj ||
assocwidget->widgetForRole(Uml::B)->umlObject() == Obj)
Associations.append(assocwidget);
- }//end foreach
+ }
}
@@ -2589,7 +2589,6 @@
void UMLScene::createAutoConstraintAssociation(UMLEntity* refEntity, UMLForeignKeyConstraint* fkConstraint, UMLWidget* widget)
{
-
if (refEntity == NULL) {
return;
}
@@ -3480,7 +3479,6 @@
viewElement.setAttribute("canvaswidth", canvasWidth());
//now save all the widgets
-
QDomElement widgetElement = qDoc.createElement("widgets");
foreach(UMLWidget *widget , m_WidgetList) {
// Having an exception is bad I know, but gotta work with
@@ -3691,7 +3689,6 @@
*/
UMLWidget* UMLScene::loadWidgetFromXMI(QDomElement& widgetElement)
{
-
if (!m_pDoc) {
uWarning() << "m_pDoc is NULL";
return 0L;
@@ -3920,7 +3917,6 @@
return true;
}
-
/**
* Left Alignment
*/
@@ -4151,7 +4147,6 @@
*/
qreal UMLScene::getSmallestY(const UMLWidgetList &widgetList)
{
-
if (widgetList.isEmpty())
return -1;
@@ -4205,7 +4200,6 @@
*/
qreal UMLScene::getBiggestY(const UMLWidgetList &widgetList)
{
-
if (widgetList.isEmpty())
return -1;
--- branches/work/soc-umbrello/umbrello/umlscene.h #1021932:1021933
@@ -229,25 +229,20 @@
}
qreal snappedX(qreal x);
-
qreal snappedY(qreal y);
bool getShowSnapGrid() const;
-
void setShowSnapGrid(bool bShow);
void setSnapComponentSizeToGrid(bool bSnap);
bool getUseFillColor() const;
-
void setUseFillColor(bool ufc);
QFont getFont() const;
-
void setFont(QFont font, bool changeAllWidgets = false);
bool getShowOpSig() const;
-
void setShowOpSig(bool bShowOpSig);
/**
@@ -315,15 +310,10 @@
int getSelectCount(bool filterText = false) const;
void selectionUseFillColor(bool useFC);
-
void selectionSetFont(const QFont &font);
-
void selectionSetLineColor(const QColor &color);
-
void selectionSetLineWidth(uint width);
-
void selectionSetFillColor(const QColor &color);
-
void selectionToggleShow(int sel);
void deleteSelection();
@@ -428,9 +418,7 @@
}
void createAutoAssociations(UMLWidget * widget);
-
void createAutoAttributeAssociations(UMLWidget *widget);
-
void createAutoConstraintAssociations(UMLWidget* widget);
void updateContainment(UMLCanvasObject *self);
@@ -446,9 +434,7 @@
void clearDiagram();
void toggleSnapToGrid();
-
void toggleSnapComponentSizeToGrid();
-
void toggleShowGrid();
void fileLoaded();
@@ -704,19 +690,13 @@
UMLWidget* widget);
static bool hasWidgetSmallerX(const UMLWidget* widget1, const UMLWidget* widget2);
-
static bool hasWidgetSmallerY(const UMLWidget* widget1, const UMLWidget* widget2);
qreal getSmallestX(const UMLWidgetList &widgetList);
-
qreal getSmallestY(const UMLWidgetList &widgetList);
-
qreal getBiggestX(const UMLWidgetList &widgetList);
-
qreal getBiggestY(const UMLWidgetList &widgetList);
-
qreal getHeightsSum(const UMLWidgetList &widgetList);
-
qreal getWidthsSum(const UMLWidgetList &widgetList);
/**
More information about the umbrello-devel
mailing list