Put summary text into three columns to save vertical space.
authorMilian Wolff <mail@milianw.de>
Wed, 24 Feb 2016 00:58:06 +0000 (01:58 +0100)
committerMilian Wolff <mail@milianw.de>
Wed, 24 Feb 2016 00:58:06 +0000 (01:58 +0100)
gui/mainwindow.cpp
gui/mainwindow.ui
gui/parser.cpp
gui/parser.h

index 05b14d6..0cdd8d0 100644 (file)
@@ -147,7 +147,45 @@ MainWindow::MainWindow(QWidget* parent)
                 m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->sizesTab), true);
             });
     connect(m_parser, &Parser::summaryAvailable,
-            m_ui->summary, &QLabel::setText);
+            this, [this] (const SummaryData& data) {
+                KFormat format;
+                QString textLeft;
+                QString textCenter;
+                QString textRight;
+                const double totalTimeS = 0.001 * data.totalTime;
+                const double peakTimeS = 0.001 * data.peakTime;
+                {
+                    QTextStream stream(&textLeft);
+                    stream << "<qt><dl>"
+                           << i18n("<dt><b>debuggee</b>:</dt><dd style='font-family:monospace;'>%1</dd>", data.debuggee)
+                           // xgettext:no-c-format
+                           << i18n("<dt><b>total runtime</b>:</dt><dd>%1s</dd>", totalTimeS)
+                           << "</dl></qt>";
+                }
+                {
+                    QTextStream stream(&textCenter);
+                    stream << "<qt><dl>"
+                           << i18n("<dt><b>calls to allocation functions</b>:</dt><dd>%1 (%2/s)</dd>",
+                                   data.allocations, quint64(data.allocations / totalTimeS))
+                           << i18n("<dt><b>temporary allocations</b>:</dt><dd>%1 (%2%, %3/s)</dd>",
+                                   data.temporary, round(float(data.temporary) * 100.f * 100.f / data.allocations) / 100.f,
+                                   quint64(data.temporary / totalTimeS))
+                           << "</dl></qt>";
+                }
+                {
+                    QTextStream stream(&textRight);
+                    stream << "<qt><dl>"
+                           << i18n("<dt><b>peak heap memory consumption</b>:</dt><dd>%1 after %2s</dd>", format.formatByteSize(data.peak), peakTimeS)
+                           << i18n("<dt><b>total memory leaked</b>:</dt><dd>%1</dd>", format.formatByteSize(data.leaked))
+                           << i18n("<dt><b>bytes allocated in total</b> (ignoring deallocations):</dt><dd>%1 (%2/s)</dd>",
+                                   format.formatByteSize(data.allocated, 2), format.formatByteSize(data.allocated / totalTimeS))
+                           << "</dl></qt>";
+                }
+
+                m_ui->summaryLeft->setText(textLeft);
+                m_ui->summaryCenter->setText(textCenter);
+                m_ui->summaryRight->setText(textRight);
+            });
     connect(m_parser, &Parser::progressMessageAvailable,
             m_ui->progressLabel, &QLabel::setText);
     auto removeProgress = [this] {
index 0d42055..b8910f0 100644 (file)
@@ -21,7 +21,8 @@
        <enum>KMessageWidget::Information</enum>
       </property>
       <property name="icon">
-       <iconset theme="dialog-error"/>
+       <iconset theme="dialog-error">
+        <normaloff>.</normaloff>.</iconset>
       </property>
      </widget>
     </item>
            </attribute>
            <layout class="QVBoxLayout" name="verticalLayout_7">
             <item>
-             <widget class="QLabel" name="summary">
-              <property name="sizePolicy">
-               <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
-                <horstretch>0</horstretch>
-                <verstretch>0</verstretch>
-               </sizepolicy>
-              </property>
-              <property name="text">
-               <string notr="true">summary goes here</string>
-              </property>
-              <property name="alignment">
-               <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
-              </property>
-              <property name="wordWrap">
-               <bool>true</bool>
+             <widget class="QWidget" name="widget_10" native="true">
+              <layout class="QHBoxLayout" name="horizontalLayout_6">
+               <item>
+                <widget class="QLabel" name="summaryLeft">
+                 <property name="text">
+                  <string notr="true">summary</string>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <widget class="QLabel" name="summaryCenter">
+                 <property name="text">
+                  <string notr="true">summary</string>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <widget class="QLabel" name="summaryRight">
+                 <property name="sizePolicy">
+                  <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+                   <horstretch>0</horstretch>
+                   <verstretch>0</verstretch>
+                  </sizepolicy>
+                 </property>
+                 <property name="text">
+                  <string notr="true">summary goes here</string>
+                 </property>
+                 <property name="alignment">
+                  <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+                 </property>
+                 <property name="wordWrap">
+                  <bool>true</bool>
+                 </property>
+                </widget>
+               </item>
+              </layout>
+             </widget>
+            </item>
+            <item>
+             <widget class="Line" name="line">
+              <property name="orientation">
+               <enum>Qt::Horizontal</enum>
               </property>
              </widget>
             </item>
                 </widget>
                </item>
               </layout>
-              <zorder>summary</zorder>
-              <zorder>widget_5</zorder>
-              <zorder>widget_6</zorder>
-              <zorder>widget_7</zorder>
-              <zorder>widget_8</zorder>
-              <zorder>widget_9</zorder>
              </widget>
             </item>
            </layout>
index ec44a78..fc24251 100644 (file)
 #include "parser.h"
 
 #include <ThreadWeaver/ThreadWeaver>
-#include <KFormat>
 #include <KLocalizedString>
 
-#include <QTextStream>
 #include <QDebug>
 
 #include "../accumulatedtracedata.h"
@@ -294,30 +292,6 @@ struct ParserData final : public AccumulatedTraceData
     bool buildCharts = false;
 };
 
-QString generateSummary(const ParserData& data)
-{
-    QString ret;
-    KFormat format;
-    QTextStream stream(&ret);
-    const double totalTimeS = 0.001 * data.totalTime;
-    const double peakTimeS = 0.001 * data.peakTime;
-    stream << "<qt><dl>"
-           << i18n("<dt><b>debuggee</b>:</dt><dd style='font-family:monospace;'>%1</dd>", QString::fromStdString(data.debuggee))
-           // xgettext:no-c-format
-           << i18n("<dt><b>total runtime</b>:</dt><dd>%1s</dd>", totalTimeS)
-           << i18n("<dt><b>bytes allocated in total</b> (ignoring deallocations):</dt><dd>%1 (%2/s)</dd>",
-                   format.formatByteSize(data.totalAllocated, 2), format.formatByteSize(data.totalAllocated / totalTimeS))
-           << i18n("<dt><b>calls to allocation functions</b>:</dt><dd>%1 (%2/s)</dd>",
-                   data.totalAllocations, quint64(data.totalAllocations / totalTimeS))
-           << i18n("<dt><b>temporary allocations</b>:</dt><dd>%1 (%2%, %3/s)</dd>",
-                   data.totalTemporary, round(float(data.totalTemporary) * 100.f * 100.f / data.totalAllocations) / 100.f,
-                   quint64(data.totalTemporary / totalTimeS))
-           << i18n("<dt><b>peak heap memory consumption</b>:</dt><dd>%1 after %2s</dd>", format.formatByteSize(data.peak), peakTimeS)
-           << i18n("<dt><b>total memory leaked</b>:</dt><dd>%1</dd>", format.formatByteSize(data.leaked));
-    stream << "</dl></qt>";
-    return ret;
-}
-
 void setParents(QVector<RowData>& children, const RowData* parent)
 {
     for (auto& row: children) {
@@ -486,7 +460,9 @@ HistogramData buildSizeHistogram(ParserData& data)
 
 Parser::Parser(QObject* parent)
     : QObject(parent)
-{}
+{
+    qRegisterMetaType<SummaryData>();
+}
 
 Parser::~Parser() = default;
 
@@ -504,7 +480,16 @@ void Parser::parse(const QString& path)
 
         data->updateStringCache();
 
-        emit summaryAvailable(generateSummary(*data));
+        emit summaryAvailable({
+            QString::fromStdString(data->debuggee),
+            data->totalTime,
+            data->peakTime,
+            data->peak,
+            data->leaked,
+            data->totalAllocations,
+            data->totalTemporary,
+            data->totalAllocated
+        });
 
         emit progressMessageAvailable(i18n("merging allocations..."));
         // merge allocations before modifying the data again
index 22e1eb6..0036371 100644 (file)
 #include "chartmodel.h"
 #include "histogrammodel.h"
 
+struct SummaryData
+{
+    QString debuggee;
+    uint64_t totalTime;
+    uint64_t peakTime;
+    uint64_t peak;
+    uint64_t leaked;
+    uint64_t allocations;
+    uint64_t temporary;
+    uint64_t allocated;
+};
+Q_DECLARE_METATYPE(SummaryData);
+
 class Parser : public QObject
 {
     Q_OBJECT
@@ -38,7 +51,7 @@ public slots:
 
 signals:
     void progressMessageAvailable(const QString& progress);
-    void summaryAvailable(const QString& summary);
+    void summaryAvailable(const SummaryData& summary);
     void bottomUpDataAvailable(const TreeData& data);
     void topDownDataAvailable(const TreeData& data);
     void consumedChartDataAvailable(const ChartData& data);