GUI: Add button in statistics window to export statistics to PDF
This commit is contained in:
parent
b58562fc7d
commit
5338339c2c
20
gui/stats.ui
20
gui/stats.ui
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>502</width>
|
||||
<height>272</height>
|
||||
<height>274</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -342,7 +342,16 @@
|
|||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -365,6 +374,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="mPDFexport">
|
||||
<property name="text">
|
||||
<string>Pdf Export</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="mButtonBox">
|
||||
<property name="sizePolicy">
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QPrinter>
|
||||
#include <QDate>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QTextDocument>
|
||||
#include <QWidget>
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
|
@ -32,6 +36,8 @@ StatsDialog::StatsDialog(QWidget *parent)
|
|||
mUI.setupUi(this);
|
||||
|
||||
connect(mUI.mCopyToClipboard, SIGNAL(pressed()), this, SLOT(copyToClipboard()));
|
||||
connect(mUI.mPDFexport, SIGNAL(pressed()), this, SLOT(PDFexport()));
|
||||
|
||||
}
|
||||
|
||||
void StatsDialog::setProject(const Project& project)
|
||||
|
@ -88,6 +94,47 @@ void StatsDialog::setScanDuration(double seconds)
|
|||
|
||||
mUI.mScanDuration->setText(parts.join(tr(" and ")));
|
||||
}
|
||||
void StatsDialog::PDFexport()
|
||||
{
|
||||
const QString Stat = QString(
|
||||
"<center><h1>%1 %2</h1></center>\n"
|
||||
"<font color=\"red\"><h3>%3 : %4</h3></color>\n"
|
||||
"<font color=\"green\"><h3>%5 : %6</h3></color>\n"
|
||||
"<font color=\"orange\"><h3>%7 : %8</h3></color>\n"
|
||||
"<font color=\"blue\"><h3>%9 : %10</h3></color>\n"
|
||||
"<font color=\"blue\"><h3>%11 : %12</h3></color>\n"
|
||||
"<font color=\"purple\"><h3>%13 : %14</h3></color>\n")
|
||||
.arg("Statistics")
|
||||
.arg(QDate::currentDate().toString("dd.MM.yyyy"))
|
||||
.arg("Errors")
|
||||
.arg(mStatistics->GetCount(ShowTypes::ShowErrors))
|
||||
.arg("Warnings")
|
||||
.arg(mStatistics->GetCount(ShowTypes::ShowWarnings))
|
||||
.arg("Style warnings")
|
||||
.arg(mStatistics->GetCount(ShowTypes::ShowStyle))
|
||||
.arg("Portability warnings")
|
||||
.arg(mStatistics->GetCount(ShowTypes::ShowPortability))
|
||||
.arg("Performance warnings")
|
||||
.arg(mStatistics->GetCount(ShowTypes::ShowPerformance))
|
||||
.arg("Information messages")
|
||||
.arg(mStatistics->GetCount(ShowTypes::ShowInformation)
|
||||
);
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName((QWidget*)0, "Export PDF", QString(), "*.pdf");
|
||||
if (QFileInfo(fileName).suffix().isEmpty()) {
|
||||
fileName.append(".pdf");
|
||||
}
|
||||
QPrinter printer(QPrinter::PrinterResolution);
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
printer.setPaperSize(QPrinter::A4);
|
||||
printer.setOutputFileName(fileName);
|
||||
|
||||
QTextDocument doc;
|
||||
doc.setHtml(Stat);
|
||||
// doc.setPageSize(printer.pageRect().size());
|
||||
doc.print(&printer);
|
||||
|
||||
}
|
||||
|
||||
void StatsDialog::copyToClipboard()
|
||||
{
|
||||
|
|
|
@ -64,6 +64,7 @@ public:
|
|||
|
||||
private slots:
|
||||
void copyToClipboard();
|
||||
void PDFexport();
|
||||
|
||||
private:
|
||||
Ui::StatsDialog mUI;
|
||||
|
|
Loading…
Reference in New Issue