[Uml-devel] KDE/kdesdk/umbrello/umbrello
Ralf Habacker
ralf.habacker at gmail.com
Wed Mar 7 13:00:56 UTC 2012
SVN commit 1284085 by habacker:
Implemented first version of diagram auto layout feature.
CCBUG 67059
M +4 -0 CMakeLists.txt
A layoutgenerator.h [License: GPL (v2+)]
A layouts (directory)
A layouts/class-horizontal.desktop
A layouts/class-vertical.desktop
A layouts/usecase-default.desktop
M +15 -0 listpopupmenu.cpp
M +10 -0 listpopupmenu.h
M +7 -0 umllistview.cpp
M +21 -0 umlview.cpp
M +5 -0 umlview.h
--- trunk/KDE/kdesdk/umbrello/umbrello/CMakeLists.txt #1284084:1284085
@@ -507,5 +507,9 @@
docgenerators/common.ent
DESTINATION ${DATA_INSTALL_DIR}/umbrello )
+install( DIRECTORY
+ layouts
+ DESTINATION ${DATA_INSTALL_DIR}/umbrello )
+
kde4_install_icons( ${ICON_INSTALL_DIR} )
--- trunk/KDE/kdesdk/umbrello/umbrello/listpopupmenu.cpp #1284084:1284085
@@ -21,6 +21,7 @@
#include "floatingtextwidget.h"
#include "folder.h"
#include "forkjoinwidget.h"
+#include "layoutgenerator.h"
#include "model_utils.h"
#include "objectnodewidget.h"
#include "objectwidget.h"
@@ -1705,6 +1706,20 @@
insert(mt_Clear, Icon_Utils::SmallIcon(Icon_Utils::it_Clear), i18n("Clear Diagram"));
insert(mt_Export_Image);
addSeparator();
+ QHash<QString, QString> configFiles;
+ QList<MenuType> types;
+ types << mt_Apply_Layout << mt_Apply_Layout1 << mt_Apply_Layout2 << mt_Apply_Layout3 << mt_Apply_Layout4 << mt_Apply_Layout5 << mt_Apply_Layout6 << mt_Apply_Layout7 << mt_Apply_Layout8 << mt_Apply_Layout9;
+ if (LayoutGenerator::availableConfigFiles(view->umlScene(), configFiles)) {
+ int i = 0;
+ foreach(const QString &key, configFiles.keys()) {
+ if (i >= types.size())
+ break;
+ insert(types[i], QPixmap(), i18n("apply '%1'").arg(configFiles[key]));
+ getAction(types[i])->setData(QVariant(key));
+ i++;
+ }
+ }
+ addSeparator();
insert(mt_SnapToGrid, i18n("Snap to Grid"), CHECKABLE);
setActionChecked(mt_SnapToGrid, view->getSnapToGrid() );
insert(mt_ShowSnapGrid, i18n("Show Grid"), CHECKABLE);
--- trunk/KDE/kdesdk/umbrello/umbrello/listpopupmenu.h #1284084:1284085
@@ -209,6 +209,16 @@
mt_Internalize_Folder, // Reintegrate separate submodel into main model
mt_AddInteractionOperand, // add a dash line to an alternative or a parallel combined fragment
+ mt_Apply_Layout, // apply automatically created layout
+ mt_Apply_Layout1, // apply automatically created layout
+ mt_Apply_Layout2, // apply automatically created layout
+ mt_Apply_Layout3, // apply automatically created layout
+ mt_Apply_Layout4, // apply automatically created layout
+ mt_Apply_Layout5, // apply automatically created layout
+ mt_Apply_Layout6, // apply automatically created layout
+ mt_Apply_Layout7, // apply automatically created layout
+ mt_Apply_Layout8, // apply automatically created layout
+ mt_Apply_Layout9, // apply automatically created layout
mt_Undefined = - 1
};
--- trunk/KDE/kdesdk/umbrello/umbrello/umllistview.cpp #1284084:1284085
@@ -25,6 +25,7 @@
#include "entity.h"
#include "category.h"
#include "docwindow.h"
+#include "layoutgenerator.h"
#include "listpopupmenu.h"
#include "template.h"
#include "operation.h"
@@ -347,6 +348,12 @@
foreach(UMLListViewItem *item, itemsSelected) {
deleteItem(item);
}
+ } else if (k == Qt::Key_F3) {
+ // prelimary support for layout generator
+ LayoutGenerator r;
+ if (!r.generate(UMLApp::app()->currentView()->umlScene()))
+ return;
+ r.apply(UMLApp::app()->currentView()->umlScene());
} else {
QTreeWidget::keyPressEvent(ke); // let parent handle it
}
--- trunk/KDE/kdesdk/umbrello/umbrello/umlview.cpp #1284084:1284085
@@ -10,6 +10,7 @@
// own header
#include "umlview.h"
+#include "layoutgenerator.h"
// system includes
#include <climits>
@@ -2654,6 +2655,19 @@
m_pImageExporter->exportView();
break;
+ case ListPopupMenu::mt_Apply_Layout:
+ case ListPopupMenu::mt_Apply_Layout1:
+ case ListPopupMenu::mt_Apply_Layout2:
+ case ListPopupMenu::mt_Apply_Layout3:
+ case ListPopupMenu::mt_Apply_Layout4:
+ case ListPopupMenu::mt_Apply_Layout5:
+ case ListPopupMenu::mt_Apply_Layout6:
+ case ListPopupMenu::mt_Apply_Layout7:
+ case ListPopupMenu::mt_Apply_Layout8:
+ case ListPopupMenu::mt_Apply_Layout9:
+ applyLayout(action->data().toString());
+ break;
+
case ListPopupMenu::mt_FloatText: {
FloatingTextWidget* ft = new FloatingTextWidget(umlScene());
ft->showChangeTextDialog();
@@ -3035,6 +3049,13 @@
}
}
+void UMLView::applyLayout(const QString &variant)
+{
+ LayoutGenerator r;
+ r.generate(umlScene(),variant);
+ r.apply(umlScene());
+}
+
void UMLView::toggleSnapToGrid()
{
setSnapToGrid(!getSnapToGrid());
--- trunk/KDE/kdesdk/umbrello/umbrello/umlview.h #1284084:1284085
@@ -806,6 +806,11 @@
void clearDiagram();
/**
+ * apply an automatic layout
+ */
+ void applyLayout(const QString &actionText);
+
+ /**
* Changes snap to grid boolean.
* Called from menus.
*/
More information about the umbrello-devel
mailing list