Permalink
Browse files

Restored "Export to Image"

  • Loading branch information...
aelliott committed Feb 17, 2012
1 parent cc7b90e commit deba8cae38becd3825e81a9c128b4cb9e2ee5c4c
Showing with 248 additions and 5 deletions.
  1. +2 −2 GraphicsItems/placeholdergraphicsitem.cpp
  2. +21 −1 mainwindow.cpp
  3. +225 −2 mainwindow.ui
@@ -61,8 +61,8 @@ void PlaceholderGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphic
QSettings settings;
QFont font = settings.value("Visualisation/Font", QFont("sans-serif", 10)).value<QFont>();
font.setPointSize(font.pointSize()+1);
- double horizontalPadding = 6.0;
- double verticalPadding = 5.0;
+ double horizontalPadding = 12.0;
+ double verticalPadding = 10.0;
double cornerRadius = 5.0;
painter->setFont(font);
View
@@ -22,6 +22,9 @@
#include "mainwindow.hpp"
#include "ui_mainwindow.h"
+#include <QFileDialog>
+#include <QPixmap>
+
/*!
* Create a new Expression Editor main window
*
@@ -146,7 +149,22 @@ void MainWindow::quit()
void MainWindow::exportAsImage()
{
-
+ QPixmap image(
+ _ui->expressionView->scene()->width(),
+ _ui->expressionView->scene()->height());
+ QPainter painter(&image);
+ painter.setRenderHint(QPainter::Antialiasing, true);
+ _ui->expressionView->scene()->setBackgroundBrush(Qt::white);
+ _ui->expressionView->scene()->render(&painter);
+
+ QString fileName = QFileDialog::getSaveFileName(
+ this,
+ tr("Save Expression Visualisation"),
+ QDir::homePath(),
+ tr("PNG File (*.png)"));
+
+ if(!fileName.isEmpty())
+ image.save(fileName);
}
void MainWindow::setRegexpFormat(int format)
@@ -271,11 +289,13 @@ void MainWindow::updateExpression(QString expression)
{
_visualisation = new ExpressionGraphicsItem(_expression, _factory->format());
scene->addItem(_visualisation);
+ _ui->actionExportAsImage->setEnabled(true);
}
else
{
_placeholder = new PlaceholderGraphicsItem();
scene->addItem(_placeholder);
+ _ui->actionExportAsImage->setEnabled(false);
}
scene->setSceneRect(scene->itemsBoundingRect());
View
@@ -62,16 +62,239 @@
</widget>
</item>
<item>
- <widget class="QListWidget" name="listWidget">
+ <widget class="QTreeWidget" name="treeWidget">
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragOnly</enum>
</property>
+ <attribute name="headerVisible">
+ <bool>false</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string>1</string>
+ </property>
+ </column>
+ <item>
+ <property name="text">
+ <string>Common</string>
+ </property>
+ <item>
+ <property name="text">
+ <string>Literal String</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Capture Group</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Bracket Expression</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Negated Bracket Expression</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Backreference</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Named Backreference</string>
+ </property>
+ </item>
+ </item>
+ <item>
+ <property name="text">
+ <string>Character Classes</string>
+ </property>
+ <item>
+ <property name="text">
+ <string>Any Character</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Word Character</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Digit Character</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Space Character</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Word Boundary</string>
+ </property>
+ </item>
+ </item>
+ <item>
+ <property name="text">
+ <string>Special Characters</string>
+ </property>
+ <item>
+ <property name="text">
+ <string>Bell</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Backspace</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Escape</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Form Feed</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Line Feed</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Carriage Return</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Horizontal Tab</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Vertical Tab</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>ASCII Control Character</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Unicode Newline</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Byte</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Octal Character</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Hexadecimal Character</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Unicode Character</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Unicode Named Character</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Grapheme Cluster</string>
+ </property>
+ </item>
+ </item>
+ <item>
+ <property name="text">
+ <string>Repeat Items</string>
+ </property>
+ <item>
+ <property name="text">
+ <string>Zero or One Time</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Any Number of Times</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>One or More Times</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Specified Number of Times</string>
+ </property>
+ </item>
+ </item>
+ <item>
+ <property name="text">
+ <string>Anchors</string>
+ </property>
+ <item>
+ <property name="text">
+ <string>Start of String</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>End of String</string>
+ </property>
+ </item>
+ </item>
+ <item>
+ <property name="text">
+ <string>Assertions</string>
+ </property>
+ <item>
+ <property name="text">
+ <string>Positive Lookahead</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Positive Lookbehind</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Negative Lookahead</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Negative Lookbehind</string>
+ </property>
+ </item>
+ </item>
<item>
<property name="text">
- <string>Literal String</string>
+ <string>Behaviour Flags</string>
</property>
</item>
</widget>

0 comments on commit deba8ca

Please sign in to comment.