Commit e1ccd838 authored by Andreas Pakulat's avatar Andreas Pakulat

Use dot directly to generate the image, this allows to use the feature on larger projects

parent e8acac2d
......@@ -221,7 +221,7 @@ void DigraphView::parseDotResults(const QStringList &list)
}
void DigraphView::process()
void DigraphView::process( const QString& file, const QString& ext )
{
QString cmd = KGlobal::dirs()->findExe("dot");
if (cmd.isEmpty()) {
......@@ -243,9 +243,21 @@ void DigraphView::process()
ifile.close();
KProcess proc;
proc << cmd << "-Tplain" << ifile.name() << "-o" << ofile.name();
if( !file.isEmpty() && !ext.isEmpty() )
{
proc << cmd << QString("-T")+ext << ifile.name() << "-o" << file;
kdDebug() << "Executing: " << cmd <<" "<<QString("-T")+ext <<" "<< ifile.name() << "-o"<<file << endl;
}else
{
proc << cmd << "-Tplain" << ifile.name() << "-o" << ofile.name();
}
proc.start(KProcess::Block);
if( !file.isEmpty() && !ext.isEmpty() )
{
return;
}
QTextStream &os = *ofile.textStream();
while (!os.atEnd())
results << os.readLine();
......@@ -259,15 +271,6 @@ void DigraphView::process()
viewport()->update();
}
QPixmap DigraphView::pixmap()
{
QPixmap pix(width,height);
kdDebug(9003) << "drawing inheritance diagram to pixmap: " << width << " " << height << " " << pix.size() << endl;
QPainter p(&pix);
drawContents(&p, 0, 0, width, height);
return pix;
}
void DigraphView::drawContents(QPainter* p, int clipx, int clipy, int clipw, int cliph)
{
QRect clipRect(clipx, clipy, clipw, cliph);
......
......@@ -15,6 +15,7 @@
#include <qptrlist.h>
#include <qscrollview.h>
#include <qstringlist.h>
#include <qimage.h>
class DigraphNode;
class DigraphEdge;
......@@ -29,11 +30,10 @@ public:
~DigraphView();
void addEdge(const QString &name1, const QString &name2);
void process();
void process(const QString& file = "", const QString& ext = "");
void clear();
void setSelected(const QString &name);
void ensureVisible(const QString &name);
QPixmap pixmap();
signals:
void selected(const QString &name);
......
......@@ -96,25 +96,30 @@ HierarchyDialog::~HierarchyDialog()
void HierarchyDialog::save()
{
KURLRequesterDlg dlg(QString::null, this, "save_inheritance");
dlg.fileDialog()->setFilter("image/png image/jpeg image/bmp");
dlg.fileDialog()->setFilter("image/png image/jpeg image/bmp image/svg+xml");
dlg.fileDialog()->setOperationMode( KFileDialog::Saving );
dlg.fileDialog()->setMode( KFile::File | KFile::LocalOnly );
dlg.urlRequester()->setMode( KFile::File | KFile::LocalOnly );
if(dlg.exec() && dlg.selectedURL().isLocalFile())
{
QFileInfo fi(dlg.selectedURL().pathOrURL());
if( fi.extension() == "png" || fi.extension() == "jpeg" || fi.extension() == "jpg" || fi.extension() == "bmp")
{
QPixmap out = digraph->pixmap();
QString format = fi.extension().upper();
if( format == "JPG" )
format = "JPEG";
kdDebug(9003) << "Storing inheritance diagram to " << fi.absFilePath() << " using pixmap size: " << out.size() << endl;
out.save(fi.absFilePath(), format.ascii(), 75);
}else
{
KMessageBox::sorry(this, i18n("Couldn't store image %1. Filename not recognizes, only .jpg, .png and .bmp are supported").arg(fi.absFilePath()), i18n("Couldn't store image"));
}
KDevLanguageSupport *ls = m_part->languageSupport();
for (QMap<QString, ClassDom>::const_iterator it = classes.begin(); it != classes.end(); ++it)
{
kdDebug(9003) << "Adding class to graph: " << it.key() << endl;
QString formattedName = ls->formatClassName(it.key());
QStringList baseClasses = it.data()->baseClassList();
for (QStringList::const_iterator bit = baseClasses.begin(); bit != baseClasses.end(); ++bit)
{
QMap<QString, QString>::const_iterator baseIt = uclasses.find(*bit);
if (baseIt != uclasses.end())
{
QString formattedParentName = ls->formatClassName(baseIt.data());
digraph->addEdge(formattedParentName, formattedName);
}
}
}
digraph->process(fi.absFilePath(), fi.extension());
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment