[Uml-devel] KDE/kdesdk/umbrello/umbrello
Ralf Habacker
ralf.habacker at gmail.com
Fri Jun 15 20:23:15 UTC 2012
SVN commit 1300948 by habacker:
Added layout generator auto detection and auto layout setting page.
BUG:301969
M +2 -0 CMakeLists.txt
A dialogs/autolayoutoptionpage.cpp [License: GPL (v2+)]
A dialogs/autolayoutoptionpage.h [License: GPL (v2+)]
A dialogs/autolayoutoptionpage.ui
M +23 -0 dialogs/settingsdlg.cpp
M +4 -1 dialogs/settingsdlg.h
M +3 -3 dotgenerator.cpp
M +0 -1 dotgenerator.h
M +40 -11 layoutgenerator.h
M +6 -0 optionstate.h
M +10 -0 umbrello.kcfg
M +4 -0 uml.cpp
--- trunk/KDE/kdesdk/umbrello/umbrello/CMakeLists.txt #1300947:1300948
@@ -198,6 +198,7 @@
)
set(libdialogs_SRCS
+ dialogs/autolayoutoptionpage.cpp
dialogs/activitydialog.cpp
dialogs/activitypage.cpp
dialogs/assocgenpage.cpp
@@ -245,6 +246,7 @@
)
kde4_add_ui_files( libdialogs_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/autolayoutoptionpage.ui
${CMAKE_CURRENT_SOURCE_DIR}/dialogs/codeviewerdialogbase.ui
${CMAKE_CURRENT_SOURCE_DIR}/dialogs/codevieweroptionsbase.ui
${CMAKE_CURRENT_SOURCE_DIR}/dialogs/exportallviewsdialogbase.ui
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/settingsdlg.cpp #1300947:1300948
@@ -12,6 +12,7 @@
#include "settingsdlg.h"
// app includes
+#include "autolayoutoptionpage.h"
#include "codeimportoptionspage.h"
#include "codegenoptionspage.h"
#include "umlwidgetstylepage.h"
@@ -19,7 +20,9 @@
#include "dialog_utils.h"
#include "debug_utils.h"
#include "icon_utils.h"
+#include "layoutgenerator.h"
+#include <kfiledialog.h>
#include <kvbox.h>
//TODO don't do that, but it's better than hardcoded in the functions body
@@ -47,6 +50,7 @@
setupCodeImportPage();
setupCodeGenPage();
setupCodeViewerPage(state->codeViewerState);
+ setupAutoLayoutPage();
connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
connect(this,SIGNAL(applyClicked()),this,SLOT(slotApply()));
connect(this,SIGNAL(defaultClicked()),this,SLOT(slotDefault()));
@@ -415,6 +419,16 @@
m_FontWidgets.chooser->setFont( m_pOptionState->uiState.font );
}
+void SettingsDlg::setupAutoLayoutPage()
+{
+ KVBox * page = new KVBox();
+ pageAutoLayout = new KPageWidgetItem( page,i18n("Auto Layout") );
+ pageAutoLayout->setHeader( i18n("Auto Layout Settings") );
+ pageAutoLayout->setIcon( Icon_Utils::DesktopIcon(Icon_Utils::it_Properties_Font) );
+ addPage( pageAutoLayout );
+ m_pAutoLayoutPage = new AutoLayoutOptionPage( page );
+}
+
void SettingsDlg::slotApply()
{
applyPage( currentPage() );
@@ -431,6 +445,7 @@
applyPage( pageCodeImport );
applyPage( pageCodeGen );
applyPage( pageFont );
+ applyPage( pageAutoLayout );
accept();
}
@@ -482,7 +497,11 @@
else if ( current == pageCodeViewer )
{
}
+ else if ( current == pageAutoLayout )
+ {
+ m_pAutoLayoutPage->setDefaults();
}
+}
void SettingsDlg::applyPage( KPageWidgetItem*item )
{
@@ -542,7 +561,11 @@
m_pCodeViewerPage->apply();
m_pOptionState->codeViewerState = m_pCodeViewerPage->getOptions();
}
+ else if ( item == pageAutoLayout )
+ {
+ m_pAutoLayoutPage->apply();
}
+}
void SettingsDlg::slotTextCBChecked(bool value)
{
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/settingsdlg.h #1300947:1300948
@@ -29,6 +29,7 @@
#include "optionstate.h"
class UMLWidgetStylePage;
+class AutoLayoutOptionPage;
class CodeImportOptionsPage;
class CodeGenOptionsPage;
class CodeViewerOptionsPage;
@@ -145,6 +146,7 @@
void setupCodeImportPage();
void setupCodeGenPage();
void setupCodeViewerPage(Settings::CodeViewerState options);
+ void setupAutoLayoutPage();
void applyPage( KPageWidgetItem* );
//private attributes
@@ -154,12 +156,13 @@
ClassWidgets m_ClassWidgets;
Settings::OptionState *m_pOptionState;
UMLWidgetStylePage * m_pUserInterfacePage;
+ AutoLayoutOptionPage * m_pAutoLayoutPage;
CodeImportOptionsPage * m_pCodeImportPage;
CodeGenOptionsPage * m_pCodeGenPage;
CodeViewerOptionsPage * m_pCodeViewerPage;
bool m_bChangesApplied;
- KPageWidgetItem *pageCodeViewer, *pageFont, *pageCodeImport, *pageCodeGen, *pageUserInterface, *pageGeneral, *pageClass;
+ KPageWidgetItem *pageCodeViewer, *pageFont, *pageCodeImport, *pageCodeGen, *pageUserInterface, *pageGeneral, *pageClass, *pageAutoLayout;
private slots:
void slotApply();
--- trunk/KDE/kdesdk/umbrello/umbrello/dotgenerator.cpp #1300947:1300948
@@ -127,7 +127,8 @@
DotGenerator::DotGenerator()
: m_scale(72),
m_usePosition(false),
- m_useFullNodeLabels(true)
+ m_useFullNodeLabels(true),
+ m_generator("dot")
{
}
@@ -467,12 +468,11 @@
#if 0
static QDebug operator<<(QDebug out, LayoutGenerator &c)
{
- out << "LayoutGenerator:"
+ out << "DotGenerator:"
<< "m_boundingRect:" << c.m_boundingRect
<< "m_nodes:" << c.m_nodes
<< "m_edges:" << c.m_edges
<< "m_scale:" << c.m_scale
- << "m_executable:" << c.m_executable;
return out;
}
#endif
--- trunk/KDE/kdesdk/umbrello/umbrello/dotgenerator.h #1300947:1300948
@@ -41,7 +41,6 @@
QString fixID(const QString &_id);
double m_scale; ///< scale factor
- QString m_executable; ///< dot executable
QString m_configFileName; ///< template filename
QHash<QString, QString> m_dotParameters; ///< contains global graph parameters
QHash<QString, QString> m_edgeParameters; ///< contains global edge parameters
--- trunk/KDE/kdesdk/umbrello/umbrello/layoutgenerator.h #1300947:1300948
@@ -14,12 +14,15 @@
#include "debug_utils.h"
#include "dotgenerator.h"
#include "floatingtextwidget.h"
+#include "optionstate.h"
#include "umlwidget.h"
// app includes
#include <KStandardDirs>
// qt includes
+#include <QDesktopServices>
+#include <QDir>
#include <QFile>
#include <QHash>
#include <QProcess>
@@ -107,12 +110,44 @@
*/
bool isEnabled()
{
- if (m_executable.isEmpty())
- m_executable = KStandardDirs::findExe("dot");
- return !m_executable.isEmpty();
+ Settings::OptionState& optionState = Settings::optionState();
+ if (optionState.autoLayoutState.autoDotPath) {
+ m_dotPath = currentDotPath();
}
+ else if (!optionState.autoLayoutState.dotPath.isEmpty()) {
+ m_dotPath = optionState.autoLayoutState.dotPath;
+ }
+ return !m_dotPath.isEmpty();
+ }
/**
+ * Return the path where dot is installed.
+ *
+ * @return string with dot path
+ */
+ static QString currentDotPath()
+ {
+ QString executable = KStandardDirs::findExe("dot");
+ if (!executable.isEmpty()) {
+ QFileInfo fi(executable);
+ return fi.absolutePath();
+ }
+#ifdef Q_OS_WIN
+ // search for dot installation
+ QString appDir(qgetenv("ProgramFiles"));
+ QDir dir(appDir);
+ dir.setFilter(QDir::Dirs);
+ dir.setNameFilters(QStringList() << "Graphviz*");
+ dir.setSorting(QDir::Reversed);
+ QFileInfoList list = dir.entryInfoList();
+ if (list.size() > 0) {
+ return list.at(0).absoluteFilePath();
+ }
+#endif
+ return QString();
+ }
+
+ /**
* generate layout and apply it to the given diagram.
*
* @return true if generating succeded
@@ -150,14 +185,7 @@
if (!createDotFile(scene, in.fileName(), variant))
return false;
- QString executable;
- if (!m_generator.isEmpty()) {
- QFileInfo fi(m_executable);
- QString path = fi.absolutePath();
- executable = path + "/" + m_generator;
- }
- else
- executable = m_executable;
+ QString executable = m_dotPath + "/" + m_generator;
QProcess p;
QStringList args;
@@ -555,6 +583,7 @@
NodeType m_nodes; ///< list of nodes found in parsed dot file
EdgeType m_edges; ///< list of edges found in parsed dot file
QHash<QString, QPointF> m_edgeLabelPosition; ///< contains global node parameters
+ QString m_dotPath; ///< contains path to dot executable
friend QDebug operator<<(QDebug out, LayoutGenerator &c);
};
--- trunk/KDE/kdesdk/umbrello/umbrello/optionstate.h #1300947:1300948
@@ -131,6 +131,11 @@
bool createArtifacts;
};
+struct AutoLayoutState {
+ bool autoDotPath; ///< determine path to dot executable automatically
+ QString dotPath; ///< path to dot executable
+};
+
struct OptionState {
GeneralState generalState;
UIState uiState;
@@ -138,6 +143,7 @@
CodeViewerState codeViewerState;
CodeGenerationState codeGenerationState;
CodeImportState codeImportState;
+ AutoLayoutState autoLayoutState;
};
OptionState& optionState();
--- trunk/KDE/kdesdk/umbrello/umbrello/umbrello.kcfg #1300947:1300948
@@ -44,6 +44,16 @@
<whatsthis>Enables/Disables Support for footer printing</whatsthis>
<default>true</default>
</entry>
+ <entry name="autoDotPath" type="bool">
+ <label>Automatic Dot Path</label>
+ <whatsthis>determine automatically the path of dot executable</whatsthis>
+ <default>true</default>
+ </entry>
+ <entry name="dotPath" type="String">
+ <label>Dot Path</label>
+ <whatsthis>set path to dot executable (optional)</whatsthis>
+ <default></default>
+ </entry>
<entry name="autosave" type="Bool">
<label>Auto Save</label>
<whatsthis>Enables/Disables Auto Saving at Regular Intervals</whatsthis>
--- trunk/KDE/kdesdk/umbrello/umbrello/uml.cpp #1300947:1300948
@@ -892,6 +892,8 @@
UmbrelloSettings::setNewcodegen( optionState.generalState.newcodegen );
UmbrelloSettings::setAngularlines( optionState.generalState.angularlines );
UmbrelloSettings::setFooterPrinting( optionState.generalState.footerPrinting );
+ UmbrelloSettings::setAutoDotPath( optionState.autoLayoutState.autoDotPath );
+ UmbrelloSettings::setDotPath( optionState.autoLayoutState.dotPath );
UmbrelloSettings::setAutosave( optionState.generalState.autosave );
UmbrelloSettings::setTime( optionState.generalState.time );
UmbrelloSettings::setAutosavetime( optionState.generalState.autosavetime );
@@ -1925,6 +1927,8 @@
optionState.generalState.newcodegen = UmbrelloSettings::newcodegen();
optionState.generalState.angularlines = UmbrelloSettings::angularlines();
optionState.generalState.footerPrinting = UmbrelloSettings::footerPrinting();
+ optionState.autoLayoutState.autoDotPath = UmbrelloSettings::autoDotPath();
+ optionState.autoLayoutState.dotPath = UmbrelloSettings::dotPath();
optionState.generalState.autosave = UmbrelloSettings::autosave();
optionState.generalState.time = UmbrelloSettings::time(); //old autosavetime value kept for compatibility
optionState.generalState.autosavetime = UmbrelloSettings::autosavetime();
More information about the umbrello-devel
mailing list