Link against KF5, use KRecursiveFilterProxyModel, fix some issues.
authorMilian Wolff <mail@milianw.de>
Sun, 7 Jun 2015 15:57:26 +0000 (17:57 +0200)
committerMilian Wolff <mail@milianw.de>
Sun, 7 Jun 2015 15:57:26 +0000 (17:57 +0200)
CMakeLists.txt
accumulatedtracedata.h
gui/CMakeLists.txt
gui/mainwindow.cpp
gui/model.cpp

index 08e77d1..58ff41a 100644 (file)
@@ -7,17 +7,25 @@ set(HEAPTRACK_VERSION_PATCH 0)
 set(HEAPTRACK_LIB_VERSION 1.0.0)
 set(HEAPTRACK_LIB_SOVERSION 1)
 
-set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
-
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wpedantic")
-
 find_package(Boost 1.41.0 REQUIRED COMPONENTS iostreams program_options)
 find_package(Threads REQUIRED)
-find_package(Qt5 NO_MODULE QUIET OPTIONAL_COMPONENTS Widgets)
-if(Qt5_FOUND)
-    add_subdirectory(gui)
+find_package(Qt5 5.2.0 NO_MODULE OPTIONAL_COMPONENTS Widgets)
+find_package(ECM 1.0.0 NO_MODULE)
+
+include(FeatureSummary)
+
+if(Qt5_FOUND AND ECM_FOUND)
+    set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
+    find_package(KF5 OPTIONAL_COMPONENTS CoreAddons I18n ItemModels)
+    if (KF5_FOUND)
+        add_subdirectory(gui)
+    endif()
 endif()
 
+set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wpedantic")
+
 add_subdirectory(3rdparty)
 
 check_library_exists (${LIBUNWIND_LIBRARY} unw_backtrace "" HAVE_UNW_BACKTRACE)
@@ -96,3 +104,5 @@ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/heaptrack DESTINATION ${BIN_INSTALL
 install(TARGETS heaptrack_interpret RUNTIME DESTINATION ${LIBEXEC_INSTALL_DIR})
 install(TARGETS heaptrack_inject LIBRARY DESTINATION ${LIB_INSTALL_DIR}/heaptrack/)
 install(TARGETS heaptrack_preload LIBRARY DESTINATION ${LIB_INSTALL_DIR}/heaptrack/)
+
+feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
index e0767df..bdb2e73 100644 (file)
@@ -144,7 +144,7 @@ struct AllocationInfo
 struct AccumulatedTraceData
 {
     AccumulatedTraceData();
-    ~AccumulatedTraceData() = default;
+    virtual ~AccumulatedTraceData() = default;
 
     virtual void handleTimeStamp(size_t newStamp, size_t oldStamp);
     virtual void handleAllocation();
index a8fdd0d..9360d3f 100644 (file)
@@ -4,6 +4,13 @@ qt5_wrap_ui(UIFILES
     mainwindow.ui
 )
 
+include(KDEInstallDirs)
+include(KDECMakeSettings)
+include(KDECompilerSettings)
+include(ECMOptionalAddSubdirectory)
+include(ECMInstallIcons)
+include(ECMAddTests)
+
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
 add_executable(heaptrack_gui
@@ -14,6 +21,17 @@ add_executable(heaptrack_gui
     ${UIFILES}
 )
 
-target_link_libraries(heaptrack_gui Qt5::Widgets ${Boost_LIBRARIES} sharedprint)
+add_definitions(-Wall
+    -DQT_NO_URL_CAST_FROM_STRING
+    -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII
+    -DQT_NO_CAST_FROM_BYTEARRAY
+    -DQT_USE_QSTRINGBUILDER
+)
+
+target_link_libraries(heaptrack_gui
+    Qt5::Widgets
+    KF5::ItemModels
+    ${Boost_LIBRARIES}
+    sharedprint)
 
 install(TARGETS heaptrack_gui RUNTIME DESTINATION "bin")
\ No newline at end of file
index 3890a79..26652f3 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <ui_mainwindow.h>
 
-#include <QSortFilterProxyModel>
+#include <KRecursiveFilterProxyModel>
 
 #include <iostream>
 
 using namespace std;
 
 MainWindow::MainWindow(QWidget* parent)
-    : m_ui(new Ui::MainWindow)
+    : QMainWindow(parent)
+    , m_ui(new Ui::MainWindow)
     , m_model(new Model(this))
 {
     m_ui->setupUi(this);
-    auto proxy = new QSortFilterProxyModel(m_model);
+    auto proxy = new KRecursiveFilterProxyModel(m_model);
     proxy->setSourceModel(m_model);
     m_ui->results->setModel(proxy);
 
index d45c249..133b455 100644 (file)
@@ -50,8 +50,8 @@ int parentRow(const QModelIndex& child)
 }
 
 Model::Model(QObject* parent)
+    : QAbstractItemModel(parent)
 {
-
 }
 
 Model::~Model()
@@ -86,7 +86,7 @@ QVariant Model::headerData(int section, Qt::Orientation orientation, int role) c
 
 QVariant Model::data(const QModelIndex& index, int role) const
 {
-    if (index.row() < 0 || index.row() > m_data.mergedAllocations.size()
+    if (index.row() < 0 || static_cast<size_t>(index.row()) > m_data.mergedAllocations.size()
         || index.column() < 0 || index.column() > NUM_COLUMNS)
     {
         return QVariant();
@@ -142,7 +142,7 @@ QModelIndex Model::parent(const QModelIndex& child) const
 int Model::rowCount(const QModelIndex& parent) const
 {
     if (parent.isValid()) {
-        if (parent.column() != 0 || parent.row() < 0 || parent.row() >= m_data.mergedAllocations.size()
+        if (parent.column() != 0 || parent.row() < 0 || static_cast<size_t>(parent.row()) >= m_data.mergedAllocations.size()
             || parentRow(parent) != -1)
         {
             return 0;
@@ -185,13 +185,13 @@ QVariant Model::allocationData(const AllocationData& allocation, const IpIndex&
             if (ip.functionIndex) {
                 return QString::fromStdString(m_data.prettyFunction(m_data.stringify(ip.functionIndex)));
             } else {
-                return QLatin1String("0x") + QString::number(ip.instructionPointer, 16);
+                return static_cast<QString>(QLatin1String("0x") + QString::number(ip.instructionPointer, 16));
             }
         } else if (column == ModuleColumn) {
             return QString::fromStdString(m_data.stringify(ip.moduleIndex));
         } else if (ip.fileIndex) {
             auto file = QString::fromStdString(m_data.stringify(ip.fileIndex));
-            return file + QLatin1Char(':') + QString::number(ip.line);
+            return static_cast<QString>(file + QLatin1Char(':') + QString::number(ip.line));
         } else {
             return QString();
         }