...
 
Commits (593)
# general
build
/build*/
*.rej
*.orig
*.out
CMakeLists.txt.user*
.clang-format
# kate
*~
......@@ -19,3 +21,6 @@ build
# from dolphin
.directory
# LSP Server data
.clangd
{
"name": "Kate"
, "index": true
, "files": [ { "git": 1 } ]
, "build": {
"directory": "build"
, "build": "make all"
, "clean": "make clean"
, "quick": "gcc -Wall -g -o %n %f"
}
}
# minimal requirements
cmake_minimum_required (VERSION 3.0 FATAL_ERROR)
# 3.1 is required for `target_sources`.
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
# Kate project
project (kate)
# KDE Applications version, managed by release script.
set(KDE_APPLICATIONS_VERSION_MAJOR "19")
set(KDE_APPLICATIONS_VERSION_MINOR "11")
set(KDE_APPLICATIONS_VERSION_MICRO "70")
set(KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}")
set (QT_MIN_VERSION "5.4.0")
project(kate VERSION ${KDE_APPLICATIONS_VERSION})
set(QT_MIN_VERSION "5.10.0")
set(KF5_DEP_VERSION "5.40.0")
# KDE Application Version, managed by release script
set (KDE_APPLICATIONS_VERSION_MAJOR "19")
set (KDE_APPLICATIONS_VERSION_MINOR "04")
set (KDE_APPLICATIONS_VERSION_MICRO "0")
set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}")
# We need some parts of the ECM CMake helpers.
find_package(ECM ${KF5_DEP_VERSION} QUIET REQUIRED NO_MODULE)
# we need some parts of the ECM CMake helpers
find_package (ECM ${KF5_DEP_VERSION} REQUIRED NO_MODULE)
set (CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(ECMOptionalAddSubdirectory)
include(ECMInstallIcons)
include(ECMSetupVersion)
include(ECMMarkNonGuiExecutable)
include(ECMGenerateHeaders)
include(ECMAddAppIcon)
include(GenerateExportHeader)
# We append to the module path so modules can be overriden from the command line.
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
include(CMakePackageConfigHelpers)
include(FeatureSummary)
include(WriteBasicConfigVersionFile)
include (CheckFunctionExists)
# Allow adding Qt resource files with `add_executable` or `target_sources` instead of
# `qt5_add_resources`. See https://cmake.org/cmake/help/v3.0/manual/cmake-qt.7.html#autorcc.
set(CMAKE_AUTORCC ON)
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(KDEInstallDirs)
include(KDECMakeSettings)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core DBus Widgets Sql)
if(BUILD_TESTING)
find_package(Qt5Test ${QT_MIN_VERSION} CONFIG REQUIRED)
endif()
# Load the frameworks we need
find_package(KF5 "${KF5_DEP_VERSION}" REQUIRED COMPONENTS
Config
Crash
I18n
JobWidgets
KIO
Parts
TextEditor
WindowSystem
XmlGui
IconThemes
)
# some optional deps, to make compiling on some OSes easier
find_package(KF5 "${KF5_DEP_VERSION}" COMPONENTS
Activities
DocTools
)
if (KF5Activities_FOUND)
add_definitions(-DKActivities_FOUND)
endif ()
include(ECMOptionalAddSubdirectory)
include(ECMAddAppIcon)
include(ECMInstallIcons)
# config.h
check_function_exists (ctermid HAVE_CTERMID)
configure_file (config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
include(FeatureSummary)
# let our config.h be found first in any case
include_directories (BEFORE ${CMAKE_CURRENT_BINARY_DIR})
# forbid some old things
add_definitions(-DQT_NO_FOREACH)
# kwrite
ecm_optional_add_subdirectory (kwrite)
# Qt 5.13 deprecated QComboBox::currentIndexChanged(QString) and Qt 5.14 undid that...
if (Qt5Widgets_VERSION VERSION_GREATER_EQUAL 5.14.0)
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00)
endif()
# kate application
ecm_optional_add_subdirectory (kate)
ecm_optional_add_subdirectory(addons)
ecm_optional_add_subdirectory(kwrite)
ecm_optional_add_subdirectory(kate)
ecm_optional_add_subdirectory(doc)
# addons, e.g. kate plugins, plasma applets, ...
ecm_optional_add_subdirectory (addons)
feature_summary(INCLUDE_QUIET_PACKAGES WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
# docs, if doc tools around
if (KF5DocTools_FOUND)
ecm_optional_add_subdirectory (doc)
endif ()
# this needs at least ECM 5.64...
if(${ECM_VERSION} VERSION_GREATER "5.63.0")
include(KDEClangFormat)
# tell about our features (and what is missing)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
# add clang-format target for all our real source files
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
endif()
# detect additional frameworks
find_package(KF5 "${KF5_DEP_VERSION}" OPTIONAL_COMPONENTS Wallet Plasma Service ItemModels ThreadWeaver NewStuff IconThemes GuiAddons)
set_package_properties(KF5Wallet PROPERTIES PURPOSE "Required to build the katesql addon")
set_package_properties(KF5Plasma PROPERTIES PURPOSE "Required to build the sessionapplet addon")
set_package_properties(KF5Service PROPERTIES PURPOSE "Required to build the sessionapplet addon")
set_package_properties(KF5ItemModels PROPERTIES PURPOSE "Required to build the project, konsole addon")
set_package_properties(KF5ThreadWeaver PROPERTIES PURPOSE "Required to build the project addon")
set_package_properties(KF5NewStuff PROPERTIES PURPOSE "Required to build the snippets and project addons")
# document switcher
ecm_optional_add_subdirectory (filetree)
# search in open documents and files
ecm_optional_add_subdirectory (search)
# ALT+Tab like tab switcher
ecm_optional_add_subdirectory (tabswitcher)
# ctags
ecm_optional_add_subdirectory (kate-ctags)
# backtrace
ecm_optional_add_subdirectory (backtracebrowser)
# file browser
ecm_optional_add_subdirectory (filebrowser)
# xml completion
ecm_optional_add_subdirectory (xmltools)
# XML Validation plugin
ecm_optional_add_subdirectory (xmlcheck)
# open header matching to current file
ecm_optional_add_subdirectory (openheader)
# debugger plugin, needs windows love, guarded until ported to win32
if (NOT WIN32)
ecm_optional_add_subdirectory (gdbplugin)
endif ()
# list symbols and functions in a file
ecm_optional_add_subdirectory (symbolviewer)
# replicode integration
ecm_optional_add_subdirectory (replicode)
# pipe text through some external command
ecm_optional_add_subdirectory (textfilter)
# Rust complection plugin
ecm_optional_add_subdirectory (rustcompletion)
# D completion plugin
ecm_optional_add_subdirectory (lumen)
# build plugin
ecm_optional_add_subdirectory (katebuild-plugin)
# close document except this one (or similar)
ecm_optional_add_subdirectory (close-except-like)
if(KF5Wallet_FOUND)
# kate sql
ecm_optional_add_subdirectory (katesql)
endif()
if(KF5NewStuff_FOUND)
# snippets
ecm_optional_add_subdirectory (snippets)
endif()
# live preview of sources in target format
ecm_optional_add_subdirectory (preview)
# terminal tool view
if(KF5Service_FOUND AND NOT WIN32)
ecm_optional_add_subdirectory (konsole)
endif()
if(KF5ItemModels_FOUND AND KF5ThreadWeaver_FOUND AND KF5NewStuff_FOUND)
# small & smart project manager
ecm_optional_add_subdirectory (project)
endif()
if (KF5Plasma_FOUND AND KF5Service_FOUND)
ecm_optional_add_subdirectory (sessionapplet)
endif()
# Most plugins will need to link against KF5TextEditor to have access to its plugin interface.
find_package(KF5TextEditor QUIET REQUIRED)
ecm_optional_add_subdirectory(backtracebrowser)
ecm_optional_add_subdirectory(close-except-like) # Close all documents except this one (or similar).
ecm_optional_add_subdirectory(externaltools)
ecm_optional_add_subdirectory(filebrowser)
ecm_optional_add_subdirectory(filetree)
ecm_optional_add_subdirectory(gdbplugin)
ecm_optional_add_subdirectory(kate-ctags)
ecm_optional_add_subdirectory(katebuild-plugin)
ecm_optional_add_subdirectory(katesql)
ecm_optional_add_subdirectory(konsole)
ecm_optional_add_subdirectory(lspclient) # Language Server Protocol (LSP) client plugin.
ecm_optional_add_subdirectory(openheader) # Open header matching to current file.
ecm_optional_add_subdirectory(preview) # Live preview of sources in target format.
ecm_optional_add_subdirectory(project) # Small & smart project manager.
ecm_optional_add_subdirectory(replicode)
ecm_optional_add_subdirectory(search)
ecm_optional_add_subdirectory(sessionapplet)
ecm_optional_add_subdirectory(snippets)
ecm_optional_add_subdirectory(symbolviewer) # List symbols and functions in a file.
ecm_optional_add_subdirectory(tabswitcher) # ALT+Tab like tab switcher.
ecm_optional_add_subdirectory(textfilter) # Pipe text through some external command.
ecm_optional_add_subdirectory(xmlcheck) # XML Validation plugin
ecm_optional_add_subdirectory(xmltools) # XML completion
########### next target ###############
add_definitions(-DTRANSLATION_DOMAIN=\"katebacktracebrowserplugin\")
add_library(katebacktracebrowserplugin MODULE "")
target_compile_definitions(katebacktracebrowserplugin PRIVATE TRANSLATION_DOMAIN="katebacktracebrowserplugin")
target_link_libraries(katebacktracebrowserplugin PRIVATE KF5::TextEditor)
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
ki18n_wrap_ui(UI_SOURCES btbrowserwidget.ui btconfigwidget.ui)
target_sources(katebacktracebrowserplugin PRIVATE ${UI_SOURCES})
set(katebacktracebrowserplugin_PART_SRCS
target_sources(
katebacktracebrowserplugin
PRIVATE
katebacktracebrowser.cpp
btparser.cpp
btfileindexer.cpp
btdatabase.cpp
)
set(katebacktracebrowserplugin_PART_UI
btbrowserwidget.ui
btconfigwidget.ui
)
ki18n_wrap_ui(katebacktracebrowserplugin_PART_SRCS ${katebacktracebrowserplugin_PART_UI} )
add_library(katebacktracebrowserplugin MODULE ${katebacktracebrowserplugin_PART_SRCS})
# we compile in the .desktop file
kcoreaddons_desktop_to_json (katebacktracebrowserplugin katebacktracebrowserplugin.desktop)
target_link_libraries(katebacktracebrowserplugin
KF5::TextEditor
KF5::I18n
)
########### install files ###############
install( TARGETS katebacktracebrowserplugin DESTINATION ${PLUGIN_INSTALL_DIR}/ktexteditor )
kcoreaddons_desktop_to_json(katebacktracebrowserplugin katebacktracebrowserplugin.desktop)
install(TARGETS katebacktracebrowserplugin DESTINATION ${PLUGIN_INSTALL_DIR}/ktexteditor)
############# unit tests ################
if (BUILD_TESTING)
add_subdirectory(autotests)
if(BUILD_TESTING)
add_subdirectory(autotests)
endif()
include(ECMMarkAsTest)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
add_executable(btbrowser_test "")
target_include_directories(btbrowser_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)
find_package(Qt5Test QUIET REQUIRED)
target_link_libraries(
btbrowser_test
PRIVATE
Qt5::Widgets
Qt5::Test
)
target_sources(btbrowser_test PRIVATE
btbrowsertest.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../btparser.cpp
)
# Plugin Kate Backtrace Browser
set(BtBrowserSrc btbrowsertest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../btparser.cpp)
add_executable(btbrowser_test ${BtBrowserSrc})
add_test(NAME plugin-btbrowser_test COMMAND btbrowser_test)
target_link_libraries(btbrowser_test kdeinit_kate Qt5::Test)
ecm_mark_as_test(btbrowser_test)
......@@ -21,10 +21,9 @@
#include "btbrowsertest.h"
#include "btparser.h"
#include <QtTestWidgets>
#include <QTemporaryFile>
#include <QFileInfo>
#include <QTemporaryFile>
#include <QtTestWidgets>
QTEST_MAIN(KateBtBrowserTest)
......@@ -45,7 +44,6 @@ void KateBtBrowserTest::testParser()
// 3) #41 0x0805e690 in ?? ()
// 4) #5 0xffffe410 in __kernel_vsyscall ()
QString bt = QStringLiteral("#24 0xb688ff8e in QApplication::notify (this=0xbf997e8c, receiver=0x82607e8, e=0xbf997074) at kernel/qapplication.cpp:3115");
QList<BtInfo> info = KateBtParser::parseBacktrace(bt);
......@@ -93,7 +91,7 @@ void KateBtBrowserTest::testParser()
bt = QStringLiteral(" Thread 1 (Thread 0x7fb6ba260780 (LWP 16447)):\n[KCrash Handler]");
info = KateBtParser::parseBacktrace(bt);
QVERIFY(info.size() == 0);
QVERIFY(info.empty());
}
// kate: space-indent on; indent-width 4; replace-tabs on;
......@@ -18,11 +18,10 @@
#include "btdatabase.h"
#include <QFile>
#include <QDataStream>
#include <QDir>
#include <QDebug>
#include <QDir>
#include <QFile>
void KateBtDatabase::loadFromFile(const QString &url)
{
......@@ -32,7 +31,7 @@ void KateBtDatabase::loadFromFile(const QString &url)
QDataStream ds(&file);
ds >> db;
}
// qDebug() << "Number of entries in the backtrace database" << url << ":" << db.size();
// qDebug() << "Number of entries in the backtrace database" << url << ":" << db.size();
}
void KateBtDatabase::saveToFile(const QString &url) const
......@@ -43,7 +42,7 @@ void KateBtDatabase::saveToFile(const QString &url) const
QDataStream ds(&file);
ds << db;
}
// qDebug() << "Saved backtrace database to" << url;
// qDebug() << "Saved backtrace database to" << url;
}
QString KateBtDatabase::value(const QString &key)
......@@ -64,7 +63,7 @@ QString KateBtDatabase::value(const QString &key)
}
}
// try to use the first one
if (sl.size() > 0) {
if (!sl.empty()) {
return sl[0];
}
}
......@@ -75,7 +74,7 @@ QString KateBtDatabase::value(const QString &key)
void KateBtDatabase::add(const QString &folder, const QStringList &files)
{
QMutexLocker locker(&mutex);
foreach(const QString &file, files) {
for (const QString &file : files) {
QStringList &sl = db[file];
QString entry = QDir::fromNativeSeparators(folder + QLatin1Char('/') + file);
if (!sl.contains(entry)) {
......
......@@ -19,16 +19,20 @@
#ifndef BTDATABASE_H
#define BTDATABASE_H
#include <QString>
#include <QStringList>
#include <QHash>
#include <QMutex>
#include <QString>
#include <QStringList>
class KateBtDatabase
{
public:
KateBtDatabase() {}
~KateBtDatabase() {}
KateBtDatabase()
{
}
~KateBtDatabase()
{
}
void loadFromFile(const QString &url);
void saveToFile(const QString &url) const;
......@@ -44,6 +48,6 @@ private:
QHash<QString, QStringList> db;
};
#endif //BTDATABASE_H
#endif // BTDATABASE_H
// kate: space-indent on; indent-width 4; replace-tabs on;
......@@ -19,8 +19,8 @@
#include "btfileindexer.h"
#include "btdatabase.h"
#include <QDir>
#include <QDebug>
#include <QDir>
BtFileIndexer::BtFileIndexer(KateBtDatabase *database)
: QThread()
......@@ -36,7 +36,7 @@ BtFileIndexer::~BtFileIndexer()
void BtFileIndexer::setSearchPaths(const QStringList &urls)
{
searchPaths.clear();
foreach(const QString &url, urls) {
for (const QString &url : urls) {
if (!searchPaths.contains(url)) {
searchPaths += url;
}
......@@ -51,7 +51,7 @@ void BtFileIndexer::setFilter(const QStringList &fileFilter)
void BtFileIndexer::run()
{
if (filter.size() == 0) {
if (filter.empty()) {
qDebug() << "Filter is empty. Aborting.";
return;
}
......
......@@ -19,9 +19,9 @@
#ifndef BTFILEINDEXER_H
#define BTFILEINDEXER_H
#include <QThread>
#include <QString>
#include <QStringList>
#include <QThread>
class KateBtDatabase;
......
......@@ -18,15 +18,14 @@
#include "btparser.h"
#include <QStringList>
#include <QDebug>
#include <QStringList>
static QString eolDelimiter(const QString &str)
{
// find the split character
QString separator(QLatin1Char('\n'));
if (str.indexOf(QStringLiteral("\r\n")) != -1) {
if (str.indexOf(QLatin1String("\r\n")) != -1) {
separator = QStringLiteral("\r\n");
} else if (str.indexOf(QLatin1Char('\r')) != -1) {
separator = QLatin1Char('\r');
......@@ -84,7 +83,6 @@ static BtInfo parseBtLine(const QString &line)
// c) #41 0x0805e690 in ?? ()
// d) #5 0xffffe410 in __kernel_vsyscall ()
// try a) cap #number(1), address(2), function(3), filename(4), linenumber(5)
static QRegExp rxa(QStringLiteral("^#(\\d+)\\s+(0x\\w+)\\s+in\\s+(.+)\\s+at\\s+(.+):(\\d+)$"));
index = rxa.indexIn(line);
......@@ -152,7 +150,7 @@ static BtInfo parseBtLine(const QString &line)
return info;
}
QList<BtInfo> KateBtParser::parseBacktrace(const QString &bt)
QList<BtInfo> KateBtParser::parseBacktrace(const QString &bt)
{
QStringList l = bt.split(eolDelimiter(bt), QString::SkipEmptyParts);
......
......@@ -25,40 +25,30 @@
class BtInfo
{
public:
enum Type {
Source = 0,
Lib,
Unknown,
Invalid
};
enum Type { Source = 0, Lib, Unknown, Invalid };
/**
* Default constructor => invalid element
*/
BtInfo()
: step(-1)
, line(-1)
, type(Invalid) {
}
BtInfo() = default;
public:
QString original;
QString filename;
QString function;
QString address;
int step;
int line;
int step = -1;
int line = -1;
Type type;
Type type = Invalid;
};
namespace KateBtParser
{
QList<BtInfo> parseBacktrace(const QString &bt);
}
#endif //BTPARSER_H
#endif // BTPARSER_H
// kate: space-indent on; indent-width 4; replace-tabs on;
......@@ -16,49 +16,46 @@
Boston, MA 02110-1301, USA.
*/
//BEGIN Includes
// BEGIN Includes
#include "katebacktracebrowser.h"
#include "btparser.h"
#include "btfileindexer.h"
#include "btparser.h"
#include <klocalizedstring.h> // i18n
#include <KConfigGroup>
#include <KLineEdit>
#include <kaboutdata.h>
#include <klocalizedstring.h> // i18n
#include <kpluginfactory.h>
#include <kpluginloader.h>
#include <kaboutdata.h>
#include <ktexteditor/view.h>
#include <ksharedconfig.h>
#include <KConfigGroup>
#include <KLineEdit>
#include <ktexteditor/view.h>
#include <QClipboard>
#include <QDataStream>
#include <QDialogButtonBox>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QFileDialog>
#include <QDataStream>
#include <QFileInfo>
#include <QStandardPaths>
#include <QTimer>
#include <QClipboard>
#include <QDialogButtonBox>
#include <QUrl>
#include <QTreeWidget>
//END Includes
#include <QUrl>
// END Includes
K_PLUGIN_FACTORY_WITH_JSON(KateBtBrowserFactory, "katebacktracebrowserplugin.json", registerPlugin<KateBtBrowserPlugin>();)
KateBtBrowserPlugin *KateBtBrowserPlugin::s_self = nullptr;
static QStringList fileExtensions =
QStringList() << QStringLiteral("*.cpp") << QStringLiteral("*.cxx") <<
QStringLiteral("*.c") << QStringLiteral("*.cc") << QStringLiteral("*.h") <<
QStringLiteral("*.hpp") << QStringLiteral("*.hxx") << QStringLiteral("*.moc");
static QStringList fileExtensions = QStringList() << QStringLiteral("*.cpp") << QStringLiteral("*.cxx") << QStringLiteral("*.c") << QStringLiteral("*.cc") << QStringLiteral("*.h") << QStringLiteral("*.hpp") << QStringLiteral("*.hxx")
<< QStringLiteral("*.moc");
KateBtBrowserPlugin::KateBtBrowserPlugin(QObject *parent, const QList<QVariant> &)
: KTextEditor::Plugin(parent)
, indexer(&db)
{
s_self = this;
db.loadFromFile(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
+ QStringLiteral("/katebtbrowser/backtracedatabase.db"));
db.loadFromFile(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/katebtbrowser/backtracedatabase.db"));
}
KateBtBrowserPlugin::~KateBtBrowserPlugin()
......@@ -68,8 +65,7 @@ KateBtBrowserPlugin::~KateBtBrowserPlugin()
indexer.wait();
}
const QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
+ QStringLiteral("/katebtbrowser");
const QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/katebtbrowser");
QDir().mkpath(path);
db.saveToFile(path + QStringLiteral("/backtracedatabase.db"));
......@@ -124,19 +120,12 @@ KTextEditor::ConfigPage *KateBtBrowserPlugin::configPage(int number, QWidget *pa
return nullptr;
}
KateBtBrowserPluginView::KateBtBrowserPluginView(KateBtBrowserPlugin *plugin, KTextEditor::MainWindow *mainWindow)
: QObject(mainWindow), m_plugin(plugin)
: QObject(mainWindow)
, m_plugin(plugin)
{
// init console
QWidget *toolview = mainWindow->createToolView(plugin,
QStringLiteral("kate_private_plugin_katebacktracebrowserplugin"),
KTextEditor::MainWindow::Bottom,
QIcon::fromTheme(QStringLiteral("tools-report-bug")),
i18n("Backtrace Browser"));
QWidget *toolview = mainWindow->createToolView(plugin, QStringLiteral("kate_private_plugin_katebacktracebrowserplugin"), KTextEditor::MainWindow::Bottom, QIcon::fromTheme(QStringLiteral("tools-report-bug")), i18n("Backtrace Browser"));
m_widget = new KateBtBrowserWidget(mainWindow, toolview);
connect(plugin, &KateBtBrowserPlugin::newStatus, m_widget, &KateBtBrowserWidget::setStatus);
......@@ -150,11 +139,6 @@ KateBtBrowserPluginView::~KateBtBrowserPluginView()
delete toolview;
}
KateBtBrowserWidget::KateBtBrowserWidget(KTextEditor::MainWindow *mainwindow, QWidget *parent)
: QWidget(parent)
, mw(mainwindow)
......@@ -191,10 +175,10 @@ void KateBtBrowserWidget::loadClipboard()
void KateBtBrowserWidget::loadBacktrace(const QString &bt)
{
QList<BtInfo> infos = KateBtParser::parseBacktrace(bt);
const QList<BtInfo> infos = KateBtParser::parseBacktrace(bt);
lstBacktrace->clear();
foreach(const BtInfo &info, infos) {
for (const BtInfo &info : infos) {
QTreeWidgetItem *it = new QTreeWidgetItem(lstBacktrace);
it->setData(0, Qt::DisplayRole, QString::number(info.step));
it->setData(0, Qt::ToolTipRole, QString::number(info.step));
......@@ -223,7 +207,6 @@ void KateBtBrowserWidget::loadBacktrace(const QString &bt)
}
}
void KateBtBrowserWidget::configure()
{
KateBtConfigDialog dlg(mw->window());
......@@ -284,9 +267,6 @@ void KateBtBrowserWidget::clearStatus()
lblStatus->setText(QString());
}
KateBtConfigWidget::KateBtConfigWidget(QWidget *parent)
: KTextEditor::ConfigPage(parent)
{
......@@ -346,13 +326,13 @@ void KateBtConfigWidget::reset()
KConfigGroup cg(KSharedConfig::openConfig(), "backtracebrowser");
lstFolders->clear();
lstFolders->addItems(cg.readEntry("search-folders", QStringList()));
edtExtensions->setText(cg.readEntry("file-extensions", fileExtensions).join(QStringLiteral(" ")));
edtExtensions->setText(cg.readEntry("file-extensions", fileExtensions).join(QLatin1Char(' ')));
}
void KateBtConfigWidget::defaults()
{
lstFolders->clear();
edtExtensions->setText(fileExtensions.join(QStringLiteral(" ")));
edtExtensions->setText(fileExtensions.join(QLatin1Char(' ')));
m_changed = true;
}
......@@ -361,7 +341,7 @@ void KateBtConfigWidget::add()
{
QDir url(edtUrl->lineEdit()->text());
if (url.exists())
if (lstFolders->findItems(url.absolutePath(), Qt::MatchExactly).size() == 0) {
if (lstFolders->findItems(url.absolutePath(), Qt::MatchExactly).empty()) {
lstFolders->addItem(url.absolutePath());
emit changed();
m_changed = true;
......@@ -384,16 +364,11 @@ void KateBtConfigWidget::textChanged()
m_changed = true;
}
KateBtConfigDialog::KateBtConfigDialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle(i18n("Backtrace Browser Settings"));
m_configWidget = new KateBtConfigWidget(this);
QVBoxLayout *layout = new QVBoxLayout(this);
......
......@@ -20,18 +20,17 @@
#define KATE_BACKTRACEBROWSER_H
#include <KTextEditor/Plugin>
#include <ktexteditor/mainwindow.h>
#include <ktexteditor/configpage.h>
#include <ktexteditor/mainwindow.h>
#include "ui_btbrowserwidget.h"
#include "ui_btconfigwidget.h"
#include "btdatabase.h"
#include "btfileindexer.h"
#include "ui_btbrowserwidget.h"
#include "ui_btconfigwidget.h"
#include <QDialog>
#include <QString>
#include <QTimer>
#include <QDialog>
class KateBtConfigWidget;
class KateBtBrowserWidget;
......@@ -77,8 +76,8 @@ public:
KateBtBrowserPluginView(KateBtBrowserPlugin *plugin, KTextEditor::MainWindow *mainWindow);
/**
* Virtual destructor.
*/
* Virtual destructor.
*/
~KateBtBrowserPluginView() override;
private:
......@@ -148,6 +147,6 @@ private:
KateBtConfigWidget *m_configWidget;
};
#endif //KATE_BACKTRACEBROWSER_H
#endif // KATE_BACKTRACEBROWSER_H
// kate: space-indent on; indent-width 4; replace-tabs on;
......@@ -23,7 +23,7 @@ Name[ga]=Brabhsálaí Cúl-Loirg
Name[gl]=Navegador de trazados inversos
Name[hu]=Visszakövetési böngésző
Name[ia]=Navigator de tracia de retro
Name[id]=Penelusur Lacak-balik
Name[id]=Penelusur Backtrace
Name[is]=Afturrakningarvafri
Name[it]=Navigatore di backtrace
Name[ja]=バックトレースブラウザ
......@@ -67,9 +67,12 @@ Comment[de]=Ansicht zur Navigation in C/C++ Backtraces
Comment[el]=Προβολή C/C++ εργαλείου πλοήγησης Backtrace
Comment[en_GB]=C/C++ Backtrace navigation tool view
Comment[es]=Vista de la herramienta del navegador de trazado inverso de C/C++
Comment[eu]=C/C++ aztarnetan nabigatzeko tresnaren ikuspegia
Comment[fi]=C/C++-pinolistausnavigointinäkymä
Comment[fr]=Vue des outils de navigation dans les piles d'appels C/C++
Comment[gl]=Vista da ferramenta de navegación por trazados inversos de C e C++
Comment[ia]=Vista de instrumento de navigation de tracia de retro in C/C++
Comment[id]=Tampilan alat navigasi Backtrace C/C++
Comment[it]=Vista dello strumento di navigazione di backtrace C/C++
Comment[ko]=C/C++ 역추적 탐색기 도구 보기
Comment[nl]=C/C++ Backtrace hulpmiddel voor navigatieweergave
......
kate: space-indent on; tab-width 4; indent-width 4; replace-tabs on; hl C++/Qt4;
project(katecloseexceptplugin)
add_definitions(-DTRANSLATION_DOMAIN=\"katecloseexceptplugin\")
set(VERSION_MAJOR 0)
set(VERSION_MINOR 3)
set(VERSION_PATCH 5)
set(VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
find_package(KF5IconThemes QUIET)
set_package_properties(KF5IconThemes PROPERTIES PURPOSE "Required to build the close-except-like addon")
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
if(NOT KF5IconThemes_FOUND)
return()
endif()
set(KATE_CLOSE_EXCEPT_PLUGIN_SOURCES
close_confirm_dialog.cpp
close_except_plugin.cpp
)
add_library(katecloseexceptplugin MODULE "")
target_compile_definitions(katecloseexceptplugin PRIVATE TRANSLATION_DOMAIN="katecloseexceptplugin")
set(KATE_CLOSE_EXCEPT_PLUGIN_UI
close_confirm_dialog.ui
target_link_libraries(
katecloseexceptplugin
PRIVATE
KF5::TextEditor
KF5::IconThemes
)
ki18n_wrap_ui(KATE_CLOSE_EXCEPT_PLUGIN_SOURCES ${KATE_CLOSE_EXCEPT_PLUGIN_UI})
# resource for ui file and stuff
qt5_add_resources(KATE_CLOSE_EXCEPT_PLUGIN_SOURCES plugin.qrc)
ki18n_wrap_ui(UI_SOURCES close_confirm_dialog.ui)
target_sources(katecloseexceptplugin PRIVATE ${UI_SOURCES})
add_library(katecloseexceptplugin MODULE ${KATE_CLOSE_EXCEPT_PLUGIN_SOURCES})
target_sources(
katecloseexceptplugin
PRIVATE
close_confirm_dialog.cpp
close_except_plugin.cpp
plugin.qrc
)
# we compile in the .desktop file
kcoreaddons_desktop_to_json(katecloseexceptplugin katecloseexceptplugin.desktop)
target_link_libraries(katecloseexceptplugin
KF5::TextEditor
KF5::Parts
KF5::I18n
KF5::IconThemes
)
configure_file(config.h.in config.h)
install(TARGETS katecloseexceptplugin DESTINATION ${PLUGIN_INSTALL_DIR}/ktexteditor)
......@@ -27,64 +27,59 @@
// Standard includes
#include <KConfig>
#include <KLocalizedString> /// \todo Where is \c i18n() defined?
#include <KConfigGroup>
#include <KIconLoader>
#include <KLocalizedString> /// \todo Where is \c i18n() defined?
#include <KSharedConfig>
#include <KConfigGroup>
#include <QBoxLayout>
#include <QLabel>
#include <QHeaderView>
#include <QLabel>
#include <QPushButton>
#include <cassert>
namespace kate { namespace {
namespace kate
{
namespace
{
class KateDocItem : public QTreeWidgetItem
{
public:
KateDocItem(KTextEditor::Document* doc, QTreeWidget* tw)
: QTreeWidgetItem(tw)
, document(doc)
public:
KateDocItem(KTextEditor::Document *doc, QTreeWidget *tw)
: QTreeWidgetItem(tw)
, document(doc)
{
setText(0, doc->documentName());
setText(1, doc->url().toString());
setCheckState(0, Qt::Checked);
}
KTextEditor::Document* document;
KTextEditor::Document *document;
};
} // anonymous namespace
CloseConfirmDialog::CloseConfirmDialog(
QList<KTextEditor::Document*>& docs
, KToggleAction* show_confirmation_action
, QWidget* const parent
)
: QDialog(parent)
, m_docs(docs)
} // anonymous namespace
CloseConfirmDialog::CloseConfirmDialog(QList<KTextEditor::Document *> &docs, KToggleAction *show_confirmation_action, QWidget *const parent)
: QDialog(parent)
, m_docs(docs)
{
assert("Documents container expected to be non empty" && !docs.isEmpty());
setupUi(this);
setWindowTitle(i18nc("@title:window", "Close files confirmation"));
setModal(true);
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
icon->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("dialog-warning"),KIconLoader::Desktop,KIconLoader::SizeLarge));
text->setText(
i18nc("@label:listbox", "You are about to close the following documents:")
);
icon->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("dialog-warning"), KIconLoader::Desktop, KIconLoader::SizeLarge));
text->setText(i18nc("@label:listbox", "You are about to close the following documents:"));
QStringList headers;
headers << i18nc("@title:column", "Document") << i18nc("@title:column", "Location");
m_docs_tree->setHeaderLabels(headers);
m_docs_tree->setSelectionMode(QAbstractItemView::SingleSelection);
m_docs_tree->setRootIsDecorated(false);
for (int i = 0; i < m_docs.size(); i++)
{
new KateDocItem(m_docs[i], m_docs_tree);
for (auto &doc : qAsConst(m_docs)) {
new KateDocItem(doc, m_docs_tree);
}
m_docs_tree->header()->setStretchLastSection(false);
m_docs_tree->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
......@@ -101,13 +96,13 @@ CloseConfirmDialog::CloseConfirmDialog(
connect(this, &CloseConfirmDialog::accepted, this, &CloseConfirmDialog::updateDocsList);
KConfigGroup gcg(KSharedConfig::openConfig(), "kate-close-except-like-CloseConfirmationDialog");
KWindowConfig::restoreWindowSize(windowHandle(),gcg); // restore dialog geometry from config
KWindowConfig::restoreWindowSize(windowHandle(), gcg); // restore dialog geometry from config
}
CloseConfirmDialog::~CloseConfirmDialog()
{
KConfigGroup gcg(KSharedConfig::openConfig(), "kate-close-except-like-CloseConfirmationDialog");
KWindowConfig::saveWindowSize(windowHandle(),gcg); // write dialog geometry to config
KWindowConfig::saveWindowSize(windowHandle(), gcg); // write dialog geometry to config
gcg.sync();
}
......@@ -116,16 +111,11 @@ CloseConfirmDialog::~CloseConfirmDialog()
*/
void CloseConfirmDialog::updateDocsList()
{
for (
QTreeWidgetItemIterator it(m_docs_tree, QTreeWidgetItemIterator::NotChecked)
; *it
; ++it
)
{
KateDocItem* item = static_cast<KateDocItem*>(*it);
for (QTreeWidgetItemIterator it(m_docs_tree, QTreeWidgetItemIterator::NotChecked); *it; ++it) {
KateDocItem *item = static_cast<KateDocItem *>(*it);
m_docs.removeAll(item->document);
qDebug() << "do not close the file " << item->document->url().toString();
}
}
} // namespace kate
} // namespace kate
<
......@@ -23,43 +23,43 @@
*/
#ifndef __SRC__CLOSE_CONFIRM_DIALOG_H__
# define __SRC__CLOSE_CONFIRM_DIALOG_H__
#define __SRC__CLOSE_CONFIRM_DIALOG_H__
// Project specific includes
// Standard includes
# include <QDialog>
# include <KTextEditor/Document>
# include <KToggleAction>
# include <kwindowconfig.h>
# include <QList>
# include <QTreeWidget>
# include <QTreeWidgetItem>
# include <QCheckBox>
# include "ui_close_confirm_dialog.h"
namespace kate {
#include "ui_close_confirm_dialog.h"
#include <KTextEditor/Document>
#include <KToggleAction>
#include <QCheckBox>
#include <QDialog>
#include <QList>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <kwindowconfig.h>
namespace kate
{
/**
* \brief [Type brief class description here]
*
* [More detailed description here]
*
*/
class CloseConfirmDialog : public QDialog, public Ui::CloseConfirmDialog
class CloseConfirmDialog : public QDialog, public Ui::CloseConfirmDialog
{
Q_OBJECT
public:
/// Default constructor
explicit CloseConfirmDialog(QList<KTextEditor::Document*>&, KToggleAction*, QWidget* const = nullptr);
explicit CloseConfirmDialog(QList<KTextEditor::Document *> &, KToggleAction *, QWidget *const = nullptr);
~CloseConfirmDialog() override;
private Q_SLOTS: