diff --git a/analyzers/cppcheck/kdevcppcheck.rc b/analyzers/cppcheck/kdevcppcheck.rc
index ffc540c3c2..363b324867 100644
--- a/analyzers/cppcheck/kdevcppcheck.rc
+++ b/analyzers/cppcheck/kdevcppcheck.rc
@@ -1,10 +1,10 @@
-
+
-
+
diff --git a/languages/plugins/custom-definesandincludes/compilerprovider/widget/compilersmodel.cpp b/languages/plugins/custom-definesandincludes/compilerprovider/widget/compilersmodel.cpp
index efe6e1b672..e66e732994 100644
--- a/languages/plugins/custom-definesandincludes/compilerprovider/widget/compilersmodel.cpp
+++ b/languages/plugins/custom-definesandincludes/compilerprovider/widget/compilersmodel.cpp
@@ -1,308 +1,313 @@
/*
* This file is part of KDevelop
*
* Copyright 2014 Sergey Kalinichev
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* 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, see .
*
*/
#include "compilersmodel.h"
#include
#include
//Represents a single row in the table
class TreeItem
{
public:
explicit TreeItem(const QList &data, TreeItem *parent = nullptr)
:m_itemData(data)
,m_parentItem(parent)
{}
virtual ~TreeItem()
{
removeChilds();
}
void appendChild(TreeItem *item)
{
m_childItems.append(item);
}
void removeChild(int row)
{
m_childItems.removeAt(row);
}
TreeItem *child(int row)
{
return m_childItems.value(row);
}
int childCount() const
{
return m_childItems.count();
}
int columnCount() const
{
return m_itemData.count();
}
virtual QVariant data(int column) const
{
return m_itemData.value(column);
}
TreeItem *parent()
{
return m_parentItem;
}
int row() const
{
if (m_parentItem) {
return m_parentItem->m_childItems.indexOf(const_cast(this));
}
return 0;
}
void removeChilds()
{
qDeleteAll(m_childItems);
m_childItems.clear();
}
private:
QList m_childItems;
QList m_itemData;
TreeItem *m_parentItem;
};
class CompilerItem : public TreeItem {
public:
CompilerItem(const CompilerPointer& compiler, TreeItem* parent)
: TreeItem(QList{compiler->name(), compiler->factoryName()}, parent)
, m_compiler(compiler)
{}
CompilerPointer compiler()
{
return m_compiler;
}
QVariant data(int column) const override
{
return !column ? m_compiler->name() : m_compiler->factoryName();
}
private:
CompilerPointer m_compiler;
};
namespace {
TreeItem* autoDetectedRootItem(TreeItem* root)
{
return root->child(0);
}
TreeItem* manualRootItem(TreeItem* root)
{
return root->child(1);
}
}
CompilersModel::CompilersModel(QObject* parent)
: QAbstractItemModel(parent)
- , m_rootItem(new TreeItem( QList{i18n("Name"), i18n("Type")}))
+ , m_rootItem(new TreeItem({i18n("Name"), i18n("Type")}))
{
m_rootItem->appendChild(new TreeItem( QList{i18n("Auto-detected"), QString()}, m_rootItem));
m_rootItem->appendChild(new TreeItem( QList{i18n("Manual"), QString()}, m_rootItem));
}
+CompilersModel::~CompilersModel()
+{
+ delete m_rootItem;
+}
+
QVariant CompilersModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid() || (role != Qt::DisplayRole && role != CompilerDataRole)) {
return QVariant();
}
TreeItem *item = static_cast(index.internalPointer());
if (role == CompilerDataRole) {
QVariant v;
if (auto c = dynamic_cast(item)) {
if (item->parent() == manualRootItem(m_rootItem)) {
v.setValue(c->compiler());
}
}
return v;
}
return item->data(index.column());
}
int CompilersModel::rowCount(const QModelIndex& parent) const
{
TreeItem *parentItem;
if (parent.column() > 0) {
return 0;
}
if (!parent.isValid()) {
parentItem = m_rootItem;
} else {
parentItem = static_cast(parent.internalPointer());
}
return parentItem->childCount();
}
int CompilersModel::columnCount(const QModelIndex& parent) const
{
if (parent.isValid()) {
return static_cast(parent.internalPointer())->columnCount();
} else {
return m_rootItem->columnCount();
}
}
QVariant CompilersModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
return m_rootItem->data(section);
}
return QVariant();
}
Qt::ItemFlags CompilersModel::flags(const QModelIndex& index) const
{
if (!index.isValid()) {
return nullptr;
}
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
QModelIndex CompilersModel::index(int row, int column, const QModelIndex& parent) const
{
if (!hasIndex(row, column, parent)) {
return QModelIndex();
}
TreeItem *parentItem;
if (!parent.isValid()) {
parentItem = m_rootItem;
} else {
parentItem = static_cast(parent.internalPointer());
}
TreeItem* childItem = parentItem->child(row);
if (childItem) {
return createIndex(row, column, childItem);
} else {
return QModelIndex();
}
}
QModelIndex CompilersModel::parent(const QModelIndex& index) const
{
if (!index.isValid()) {
return QModelIndex();
}
TreeItem *childItem = static_cast(index.internalPointer());
TreeItem *parentItem = childItem->parent();
if (parentItem == m_rootItem) {
return QModelIndex();
}
return createIndex(parentItem->row(), 0, parentItem);
}
QVector< CompilerPointer > CompilersModel::compilers() const
{
QVector compilers;
for (int idx = 0; idx < 2; idx++) {
for (int i = 0; i< m_rootItem->child(idx)->childCount(); i++) {
auto compiler = static_cast(m_rootItem->child(idx)->child(i))->compiler();
if (!compiler->name().isEmpty() && !compiler->path().isEmpty()) {
compilers.append(compiler);
}
}
}
return compilers;
}
void CompilersModel::setCompilers(const QVector< CompilerPointer >& compilers)
{
beginResetModel();
autoDetectedRootItem(m_rootItem)->removeChilds();
manualRootItem(m_rootItem)->removeChilds();
for (auto compiler: compilers) {
if (compiler->factoryName().isEmpty()) {
continue;
}
TreeItem* parent = autoDetectedRootItem(m_rootItem);
if (compiler->editable()) {
parent = manualRootItem(m_rootItem);
}
parent->appendChild(new CompilerItem(compiler, parent));
}
endResetModel();
}
QModelIndex CompilersModel::addCompiler(const CompilerPointer& compiler)
{
beginInsertRows(index(1, 0), manualRootItem(m_rootItem)->childCount(), manualRootItem(m_rootItem)->childCount());
Q_ASSERT(!compiler->factoryName().isEmpty());
manualRootItem(m_rootItem)->appendChild(new CompilerItem(compiler, manualRootItem(m_rootItem)));
endInsertRows();
emit compilerChanged();
return index(manualRootItem(m_rootItem)->childCount()-1, 0, index(1, 0));
}
bool CompilersModel::removeRows(int row, int count, const QModelIndex& parent)
{
if (row >= 0 && count > 0 && parent.isValid() && static_cast(parent.internalPointer()) == manualRootItem(m_rootItem)) {
beginRemoveRows(parent, row, row + count - 1);
for (int i = 0; i < count; ++i) {
manualRootItem(m_rootItem)->removeChild(row);
}
endRemoveRows();
emit compilerChanged();
return true;
}
return false;
}
void CompilersModel::updateCompiler(const QItemSelection& compiler)
{
for (const auto& idx: compiler.indexes()) {
emit dataChanged(idx, idx);
}
emit compilerChanged();
}
diff --git a/languages/plugins/custom-definesandincludes/compilerprovider/widget/compilersmodel.h b/languages/plugins/custom-definesandincludes/compilerprovider/widget/compilersmodel.h
index b5c3c5a0d5..6c2e1e34aa 100644
--- a/languages/plugins/custom-definesandincludes/compilerprovider/widget/compilersmodel.h
+++ b/languages/plugins/custom-definesandincludes/compilerprovider/widget/compilersmodel.h
@@ -1,68 +1,69 @@
/*
* This file is part of KDevelop
*
* Copyright 2014 Sergey Kalinichev
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* 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, see .
*
*/
#ifndef COMPILERMODEL_H
#define COMPILERMODEL_H
#include
#include
#include "../compilerprovider/icompiler.h"
class TreeItem;
class CompilersModel : public QAbstractItemModel
{
Q_OBJECT
public:
enum SpecialRole {
CompilerDataRole = Qt::UserRole + 1
};
explicit CompilersModel( QObject* parent = nullptr );
+ ~CompilersModel() override;
void setCompilers( const QVector& compilers );
QVector compilers() const;
QModelIndex addCompiler(const CompilerPointer& compiler);
void updateCompiler(const QItemSelection& compiler);
signals:
/// emitted whenever new compiler added or existing one modified/deleted.
void compilerChanged();
public:
QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
Qt::ItemFlags flags( const QModelIndex& index ) const override;
int columnCount( const QModelIndex& parent = QModelIndex() ) const override;
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex& child) const override;
bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
private:
TreeItem* m_rootItem;
};
#endif // COMPILERMODEL_H
diff --git a/utils/okteta/kdevokteta.rc b/utils/okteta/kdevokteta.rc
index 042bbfa0f9..6c8bcaf497 100644
--- a/utils/okteta/kdevokteta.rc
+++ b/utils/okteta/kdevokteta.rc
@@ -1,90 +1,86 @@
-
+
-
-
- View
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Bookmarks
-
-
-
-
-
-
-
-
-
-
-
-
-
+ View
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Bookmarks
+
+
+
+
+
+
+
+
+
+
+