diff --git a/CMakeLists.txt b/CMakeLists.txt index a573ff2..c25c9b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,88 +1,94 @@ cmake_minimum_required(VERSION 2.8.12) project(Purpose) find_package(ECM 5.50.0 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) set(REQUIRED_QT_VERSION 5.8.0) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Qml Gui DBus Widgets Network Test) include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) include(FeatureSummary) include(GenerateExportHeader) include(ECMSetupVersion) include(ECMAddTests) include(ECMInstallIcons) include(ECMGenerateHeaders) include(ECMMarkNonGuiExecutable) include(ECMQtDeclareLoggingCategory) set(KF5_VERSION "5.51.0") # handled by release scripts set(KF5_DEP_VERSION "5.50.0") # handled by release scripts find_package(KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS CoreAddons I18n Config) # Debian is a special snow flake and uses nodejs as binary name # https://lists.debian.org/debian-devel-announce/2012/07/msg00002.html if(EXISTS "/etc/debian_version") # is debian system? set(NODEJS_BINARY "nodejs" CACHE PATH "The binary name for the nodejs interpreter") else() # sane system set(NODEJS_BINARY "node" CACHE PATH "The binary name for the nodejs interpreter") endif() ecm_setup_version(${KF5_VERSION} VARIABLE_PREFIX PURPOSE VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/purpose_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5PurposeConfigVersion.cmake" SOVERSION 5) +add_definitions(-DQT_NO_CAST_FROM_ASCII) +add_definitions(-DQT_NO_CAST_TO_ASCII) +add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT) +add_definitions(-DQT_NO_URL_CAST_FROM_STRING) +add_definitions(-DQT_USE_QSTRINGBUILDER) +#add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000) add_subdirectory( src ) if (BUILD_TESTING) add_subdirectory( autotests ) add_subdirectory( tests ) endif() add_definitions(-DTRANSLATION_DOMAIN=\"purpose5\") if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install(po) endif() # create a Config.cmake and a ConfigVersion.cmake file and install them set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5Purpose") include(ECMPackageConfigHelpers) ecm_configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5PurposeConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5PurposeConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5PurposeConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5PurposeConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5PurposeTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5PurposeTargets.cmake NAMESPACE KF5:: ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/purpose_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/purpose COMPONENT Devel ) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) install( FILES purpose.categories DESTINATION ${KDE_INSTALL_CONFDIR} ) #TODO: Remove somewhen in the future install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/KDEExperimentalPurposeConfig.cmake" DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/KDEExperimentalPurpose" COMPONENT Devel ) diff --git a/src/plugins/phabricator/quick/difflistmodel.cpp b/src/plugins/phabricator/quick/difflistmodel.cpp index 0e8faca..d0f2beb 100644 --- a/src/plugins/phabricator/quick/difflistmodel.cpp +++ b/src/plugins/phabricator/quick/difflistmodel.cpp @@ -1,177 +1,177 @@ /* * Copyright 2017 René J.V. Bertin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "difflistmodel.h" #include "phabricatorjobs.h" #include #include #include #include DiffListModel::DiffListModel(QObject* parent) : QAbstractListModel(parent) , m_initialDir(QDir::currentPath()) , m_tempDir(nullptr) { refresh(); } void DiffListModel::refresh() { beginResetModel(); m_values.clear(); endResetModel(); if (m_tempDir) { qCritical() << "DiffListModel::refresh() called while still active!"; return; } // our CWD should be the directory from which the application was launched, which // may or may not be a git, mercurial or svn working copy, so we create a temporary // directory in which we initialise a git repository. This may be an empty repo. m_initialDir = QDir::currentPath(); m_tempDir = new QTemporaryDir; if (!m_tempDir->isValid()) { qCritical() << "DiffListModel::refresh() failed to create temporary directory" << m_tempDir->path() << ":" << m_tempDir->errorString(); } else { if (QDir::setCurrent(m_tempDir->path())) { // the directory will be removed in receivedDiffRevs() m_tempDir->setAutoRemove(false); QProcess initGit; bool ok = false; // create the virgin git repo. This is a very cheap operation that should // never fail in a fresh temporary directory we ourselves created, so it // should be OK to do this with a synchronous call. initGit.start(QLatin1String("git init")); if (initGit.waitForStarted(1000)) { ok = initGit.waitForFinished(500); } if (!ok) { qCritical() << "DiffListModel::refresh() : couldn't create temp. git repo:" << initGit.errorString(); } } else { qCritical() << "DiffListModel::refresh() failed to chdir to" << m_tempDir->path(); } } // create a list request with the current (= temp.) directory as the project directory. // This request is executed asynchronously, which is why we cannot restore the initial // working directory just yet, nor remove the temporary directory. Phabricator::DiffRevList* repo = new Phabricator::DiffRevList(QDir::currentPath(), this); connect(repo, &Phabricator::DiffRevList::finished, this, &DiffListModel::receivedDiffRevs); repo->start(); } void DiffListModel::receivedDiffRevs(KJob* job) { if (job->error() != 0) { qWarning() << "error getting differential revision list" << job->errorString(); beginResetModel(); m_values.clear(); endResetModel(); return; } const auto diffRevList = dynamic_cast(job); const auto revs = diffRevList->reviews(); QVector tmpValues; foreach (const auto review, revs) { auto status = diffRevList->statusMap()[review.second]; tmpValues += Value { review.second, review.first, status }; } - qSort(tmpValues.begin(), tmpValues.end()); + std::sort(tmpValues.begin(), tmpValues.end()); beginResetModel(); m_values.clear(); foreach (const auto value, tmpValues) { m_values += value; } endResetModel(); // now we can restore the initial working directory and remove the temp directory // (in that order!). if (!QDir::setCurrent(m_initialDir)) { qCritical() << "DiffListModel::receivedDiffRevs() failed to restore initial directory" << m_initialDir; } if (m_tempDir) { m_tempDir->remove(); delete m_tempDir; m_tempDir = nullptr; } } QHash DiffListModel::roleNames() const { const QHash roles = { {Qt::DisplayRole, QByteArrayLiteral("display")}, {Qt::ToolTipRole, QByteArrayLiteral("toolTip")}, {Qt::TextColorRole, QByteArrayLiteral("textColor")} }; return roles; } QVariant DiffListModel::data(const QModelIndex &idx, int role) const { if (!idx.isValid() || idx.column() != 0 || idx.row() >= m_values.size()) { return QVariant(); } switch (role) { case Qt::DisplayRole: return m_values[idx.row()].summary; case Qt::ToolTipRole: return m_values[idx.row()].id; case Qt::TextColorRole: // Use the colours arc also uses QVariant ret; switch (m_values[idx.row()].status.value()) { case Phabricator::DiffRevList::Accepted: // alternative: KColorScheme::ForegroundRole::PositiveText ret = QBrush(Qt::green); case Phabricator::DiffRevList::NeedsReview: // alternative: KColorScheme::ForegroundRole::NeutralText ret = QBrush(Qt::magenta); case Phabricator::DiffRevList::NeedsRevision: // alternative: KColorScheme::ForegroundRole::NegativeText ret = QBrush(Qt::red); } return ret; } return QVariant(); } int DiffListModel::rowCount(const QModelIndex & parent) const { return parent.isValid() ? 0 : m_values.count(); } QVariant DiffListModel::get(int row, const QByteArray &role) { return index(row, 0).data(roleNames().key(role)); } void DiffListModel::setStatus(const QString &status) { if (m_status != status) { m_status = status; refresh(); } }