fixing build errors in some environments (Qt 5.11.0 MSVC2017 64bit, Release build...
authorAlexey Chernobaev <achernobaev@dev.rtsoft.ru>
Wed, 4 Apr 2018 19:07:08 +0000 (22:07 +0300)
committerAlexey Chernobaev <achernobaev@dev.rtsoft.ru>
Wed, 4 Apr 2018 19:07:08 +0000 (22:07 +0300)
- removed 'include "xxx.moc"' from chartwidget.cpp and histogramwidget.cpp;
- renamed HelpWidget to ChartHelpWindow and moved it from chartwidget.cpp to separate .h and .cpp files.

src/analyze/gui/charthelpwindow.cpp [new file with mode: 0644]
src/analyze/gui/charthelpwindow.h [new file with mode: 0644]
src/analyze/gui/chartwidget.cpp
src/analyze/gui/histogramwidget.cpp
src/heaptrack_gui.pro

diff --git a/src/analyze/gui/charthelpwindow.cpp b/src/analyze/gui/charthelpwindow.cpp
new file mode 100644 (file)
index 0000000..6c5f7e1
--- /dev/null
@@ -0,0 +1,51 @@
+#include "charthelpwindow.h"
+#include "chartwidget.h"
+
+#include <QTextEdit>
+#include <QToolTip>
+
+ChartHelpWindow::ChartHelpWindow(QWidget *parent) :
+    QMainWindow(parent)
+{
+    setWindowTitle("Chart Help");
+    setWindowFlags(Qt::Tool);
+    setAttribute(Qt::WA_ShowWithoutActivating);
+    setAttribute(Qt::WA_DeleteOnClose);
+    setPalette(QToolTip::palette());
+    setWindowOpacity(0.9);
+    setAutoFillBackground(true);
+    auto textEdit = new QTextEdit(this);
+    textEdit->setReadOnly(true);
+    textEdit->setContextMenuPolicy(Qt::NoContextMenu);
+    textEdit->viewport()->setAutoFillBackground(false);
+    setCentralWidget(textEdit);
+    const auto text =
+        "<p>Use <u>Context Menu</u> (right click inside the chart to open) to control different chart options.</p>" \
+        "<p>Use <u>left mouse button</u> to <b>zoom in</b> to selection: press the button, drag " \
+        "to make a rectangular selection, release.</p>" \
+        "<p>Use <u>left mouse button</u> with modifier keys to:</p>" \
+        "<ul>" \
+        "<li><b>zoom out</b> (one step back) - <b>&lt;Shift&gt;</b>+click;" \
+        "<li><b>reset zoom</b> - <b>&lt;Ctrl&gt;</b>+click;" \
+        "<li><b>move (pan)</b> the chart  - <b>&lt;Alt&gt;</b>+drag." \
+        "</ul>";
+    textEdit->setHtml(text);
+    QFontMetrics fm(textEdit->font());
+    QRect rect = fm.boundingRect("Use left mouse button to zoom in to selection: press the ");
+    int textWidth = std::max(292, (int)round(rect.width() * 1.03));
+    int textHeight = std::max(164, (int)round(rect.height() * 1.03 * 12));
+    setGeometry(0, 0, textWidth, textHeight);
+    setMinimumSize(120, 80);
+    setMaximumSize(std::max(400, textWidth * 2), std::max(280, textHeight * 2));
+}
+
+ChartHelpWindow::~ChartHelpWindow()
+{
+    ChartWidget::HelpWindow = nullptr;
+}
+
+void ChartHelpWindow::closeEvent(QCloseEvent *event)
+{
+    QMainWindow::closeEvent(event);
+    ChartOptions::GlobalOptions = ChartOptions::setOption(ChartOptions::GlobalOptions, ChartOptions::ShowHelp, false);
+}
diff --git a/src/analyze/gui/charthelpwindow.h b/src/analyze/gui/charthelpwindow.h
new file mode 100644 (file)
index 0000000..f1cab9b
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef HELPWIDGET_H
+#define HELPWIDGET_H
+
+#include <QMainWindow>
+#include <QWidget>
+
+class ChartHelpWindow: public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    explicit ChartHelpWindow(QWidget *parent = 0);
+    ~ChartHelpWindow();
+
+protected:
+    virtual void closeEvent(QCloseEvent *event) override;
+};
+
+#endif // HELPWIDGET_H
index c68cbab..5142048 100644 (file)
@@ -19,8 +19,6 @@
 #include "chartwidget.h"
 
 #include <QMainWindow>
-#include <QTextEdit>
-#include <QToolTip>
 #include <QVBoxLayout>
 
 #if defined(KChart_FOUND)
@@ -35,6 +33,8 @@
 #include <KChartHeaderFooter>
 #include <KChartLegend>
 #elif defined(QWT_FOUND)
+#include "charthelpwindow.h"
+
 #include <algorithm>
 #include <math.h>
 #include <QAction>
@@ -89,56 +89,6 @@ public:
 };
 }
 #elif defined(QWT_FOUND)
-class HelpWidget : public QMainWindow
-{
-    Q_OBJECT
-public:
-    explicit HelpWidget(QWidget *parent) : QMainWindow(parent)
-    {
-        setWindowTitle("Chart Help");
-        setWindowFlags(Qt::Tool);
-        setAttribute(Qt::WA_ShowWithoutActivating);
-        setAttribute(Qt::WA_DeleteOnClose);
-        setPalette(QToolTip::palette());
-        setWindowOpacity(0.9);
-        setAutoFillBackground(true);
-        auto textEdit = new QTextEdit(this);
-        textEdit->setReadOnly(true);
-        textEdit->setContextMenuPolicy(Qt::NoContextMenu);
-        textEdit->viewport()->setAutoFillBackground(false);
-        setCentralWidget(textEdit);
-        const auto text =
-            "<p>Use <u>Context Menu</u> (right click inside the chart to open) to control different chart options.</p>" \
-            "<p>Use <u>left mouse button</u> to <b>zoom in</b> to selection: press the button, drag " \
-            "to make a rectangular selection, release.</p>" \
-            "<p>Use <u>left mouse button</u> with modifier keys to:</p>" \
-            "<ul>" \
-            "<li><b>zoom out</b> (one step back) - <b>&lt;Shift&gt;</b>+click;" \
-            "<li><b>reset zoom</b> - <b>&lt;Ctrl&gt;</b>+click;" \
-            "<li><b>move (pan)</b> the chart  - <b>&lt;Alt&gt;</b>+drag." \
-            "</ul>";
-        textEdit->setHtml(text);
-        QFontMetrics fm(textEdit->font());
-        QRect rect = fm.boundingRect("Use left mouse button to zoom in to selection: press the ");
-        int textWidth = std::max(292, (int)round(rect.width() * 1.03));
-        int textHeight = std::max(164, (int)round(rect.height() * 1.03 * 12));
-        setGeometry(0, 0, textWidth, textHeight);
-        setMinimumSize(120, 80);
-        setMaximumSize(std::max(400, textWidth * 2), std::max(280, textHeight * 2));
-    }
-
-    virtual ~HelpWidget()
-    {
-        ChartWidget::HelpWindow = nullptr;
-    }
-protected:
-    virtual void closeEvent(QCloseEvent *event) override
-    {
-        QMainWindow::closeEvent(event);
-        ChartOptions::GlobalOptions = ChartOptions::setOption(ChartOptions::GlobalOptions, ChartOptions::ShowHelp, false);
-    }
-};
-
 QWidget* ChartWidget::HelpWindow;
 QWidget* ChartWidget::MainWindow;
 #endif // QWT_FOUND
@@ -420,7 +370,7 @@ void ChartWidget::showHelp()
 {
     if (HelpWindow == nullptr)
     {
-        HelpWindow = new HelpWidget(MainWindow);
+        HelpWindow = new ChartHelpWindow(MainWindow);
         QPoint p = mapToGlobal(pos());
         HelpWindow->move(p.x() + 32, p.y() + 32);
     }
@@ -428,4 +378,6 @@ void ChartWidget::showHelp()
 }
 #endif // QWT_FOUND
 
-#include "chartwidget.moc"
+// seems it's not needed; causes build errors in some environments
+// (e.g. Qt 5.11.0 MSVC2017 64bit, Release build only)
+//#include "chartwidget.moc"
index 1d4f23f..5350305 100644 (file)
@@ -264,4 +264,6 @@ void HistogramWidget::toggleShowUnresolved()
 }
 #endif // QWT_FOUND
 
-#include "histogramwidget.moc"
+// seems it's not needed; causes build errors in some environments
+// (e.g. Qt 5.11.0 MSVC2017 64bit, Release build only)
+//#include "histogramwidget.moc"
index 4c26551..1896294 100644 (file)
@@ -146,12 +146,14 @@ HEADERS += \
 
 QWT_CHART {
     SOURCES += \
+        analyze/gui/charthelpwindow.cpp \
         analyze/gui/chartmodel2qwtseriesdata.cpp \
         analyze/gui/chartwidgetqwtplot.cpp \
         analyze/gui/contextmenuqwt.cpp \
         analyze/gui/histogramwidgetqwtplot.cpp
 
     HEADERS += \
+        analyze/gui/charthelpwindow.h \
         analyze/gui/chartmodel2qwtseriesdata.h \
         analyze/gui/chartwidgetqwtplot.h \
         analyze/gui/contextmenuqwt.h \