From c6d3975e2865860deecd52fcb1e582400970d279 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Sun, 7 Jun 2015 17:57:26 +0200 Subject: [PATCH] Link against KF5, use KRecursiveFilterProxyModel, fix some issues. --- CMakeLists.txt | 24 +++++++++++++++++------- accumulatedtracedata.h | 2 +- gui/CMakeLists.txt | 20 +++++++++++++++++++- gui/mainwindow.cpp | 7 ++++--- gui/model.cpp | 10 +++++----- 5 files changed, 46 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08e77d1..58ff41a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/accumulatedtracedata.h b/accumulatedtracedata.h index e0767df..bdb2e73 100644 --- a/accumulatedtracedata.h +++ b/accumulatedtracedata.h @@ -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(); diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index a8fdd0d..9360d3f 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -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 diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 3890a79..26652f3 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -21,7 +21,7 @@ #include -#include +#include #include @@ -30,11 +30,12 @@ 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); diff --git a/gui/model.cpp b/gui/model.cpp index d45c249..133b455 100644 --- a/gui/model.cpp +++ b/gui/model.cpp @@ -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(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(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(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(file + QLatin1Char(':') + QString::number(ip.line)); } else { return QString(); } -- 2.7.4