0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-11-25 08:28:06 +03:00

Define code style and format all source file using clang-format-14

except those placed in 3rdparty directories.
This commit is contained in:
Андрей Лухнов
2024-09-04 17:31:16 +03:00
parent c5b9ac265d
commit 0fca7169d3
285 changed files with 19120 additions and 17875 deletions

View File

@@ -1,74 +1,78 @@
#include "lrcompletermodel.h"
#include <QDebug>
CompleterModel::CompleterModel(QObject *parent) : QAbstractItemModel(parent){m_root.setModel(this);}
QModelIndex CompleterModel::index(int row, int column, const QModelIndex &parent) const
CompleterModel::CompleterModel(QObject* parent): QAbstractItemModel(parent)
{
CompleterItem const *parentItem;
m_root.setModel(this);
}
QModelIndex CompleterModel::index(int row, int column, const QModelIndex& parent) const
{
CompleterItem const* parentItem;
if (!parent.isValid())
parentItem = &m_root;
else
parentItem = static_cast<CompleterItem*>(parent.internalPointer());
if ((parentItem == nullptr)
|| (row < 0)
|| (column < 0)
|| (row >= parentItem->rowCount())
|| (column >= 1))
{
if ((parentItem == nullptr) || (row < 0) || (column < 0) || (row >= parentItem->rowCount())
|| (column >= 1)) {
return QModelIndex();
}
return createIndex(row, column, parentItem->child(row));
}
QModelIndex CompleterModel::parent(const QModelIndex &child) const {
if(child.isValid()) {
if(CompleterItem *childItem = static_cast<CompleterItem *>(child.internalPointer());
childItem) {
CompleterItem *parentItem = childItem->parent();
if(parentItem != &m_root) {
return indexFromItem(parentItem);
}
QModelIndex CompleterModel::parent(const QModelIndex& child) const
{
if (child.isValid()) {
if (CompleterItem* childItem = static_cast<CompleterItem*>(child.internalPointer());
childItem) {
CompleterItem* parentItem = childItem->parent();
if (parentItem != &m_root) {
return indexFromItem(parentItem);
}
}
}
}
return QModelIndex();
return QModelIndex();
}
int CompleterModel::rowCount(const QModelIndex &parent) const
int CompleterModel::rowCount(const QModelIndex& parent) const
{
if (parent.isValid()){
CompleterItem *parentItem = static_cast<CompleterItem*>(parent.internalPointer());
if (parent.isValid()) {
CompleterItem* parentItem = static_cast<CompleterItem*>(parent.internalPointer());
return parentItem->rowCount();
}
return m_root.rowCount();
}
int CompleterModel::columnCount(const QModelIndex &parent) const
int CompleterModel::columnCount(const QModelIndex& parent) const
{
Q_UNUSED(parent)
return 1;
}
QVariant CompleterModel::data(const QModelIndex &index, int role) const
QVariant CompleterModel::data(const QModelIndex& index, int role) const
{
if (index.isValid()){
if (index.isValid()) {
CompleterItem* item = static_cast<CompleterItem*>(index.internalPointer());
switch (role) {
case Qt::DisplayRole:
case Qt::EditRole:
if (!item) return QVariant();
if (!item)
return QVariant();
if (index.column()==0){
if (index.column() == 0) {
return item->text();
} else {
return "";
}
case Qt::DecorationRole :
if (!item) return QIcon();
if (index.column()==0){
case Qt::DecorationRole:
if (!item)
return QIcon();
if (index.column() == 0) {
return item->icon();
} else return QIcon();
} else
return QIcon();
default:
return QVariant();
}
@@ -76,10 +80,11 @@ QVariant CompleterModel::data(const QModelIndex &index, int role) const
return QVariant();
}
QList<CompleterItem *> CompleterModel::findItems(const QString &text, Qt::MatchFlags flags, int column) const
QList<CompleterItem*> CompleterModel::findItems(const QString& text, Qt::MatchFlags flags,
int column) const
{
QModelIndexList indexes = match(index(0, column, QModelIndex()),
Qt::DisplayRole, text, -1, flags);
QModelIndexList indexes
= match(index(0, column, QModelIndex()), Qt::DisplayRole, text, -1, flags);
QList<CompleterItem*> items;
const int numIndexes = indexes.size();
items.reserve(numIndexes);
@@ -95,49 +100,45 @@ void CompleterModel::clear()
endResetModel();
}
CompleterItem *CompleterModel::itemFromIndex(const QModelIndex index) const
CompleterItem* CompleterModel::itemFromIndex(const QModelIndex index) const
{
if ((index.row() < 0) || (index.column() < 0) || (index.model() != this))
return nullptr;
CompleterItem *parent = static_cast<CompleterItem*>(index.internalPointer());
return nullptr;
CompleterItem* parent = static_cast<CompleterItem*>(index.internalPointer());
if (parent == nullptr)
return nullptr;
CompleterItem *item = parent->child(index.row());
return nullptr;
CompleterItem* item = parent->child(index.row());
return item;
}
QModelIndex CompleterModel::indexFromItem(CompleterItem *item) const
QModelIndex CompleterModel::indexFromItem(CompleterItem* item) const
{
if (item && item->parent()){
if (item && item->parent()) {
return createIndex(item->row(), 0, item);
}
return QModelIndex();
}
CompleterItem::~CompleterItem(){}
CompleterItem::~CompleterItem() { }
void CompleterItem::setIcon(const QIcon &newIcon)
void CompleterItem::setIcon(const QIcon& newIcon) { m_icon = newIcon; }
void CompleterItem::setText(const QString& newText) { m_text = newText; }
void CompleterItem::appendRow(CompleterItem* child)
{
m_icon = newIcon;
}
void CompleterItem::setText(const QString &newText)
{
m_text = newText;
}
void CompleterItem::appendRow(CompleterItem *child){
child->m_parent = this;
child->m_model = this->m_model;
m_children.append(QSharedPointer<CompleterItem>(child));
if (m_model){
if (m_model) {
QModelIndex start = m_model->indexFromItem(child);
emit m_model->dataChanged(start, start);
}
}
void CompleterItem::appendRows(const QList<CompleterItem*> &children){
foreach(CompleterItem* item, children){
void CompleterItem::appendRows(const QList<CompleterItem*>& children)
{
foreach (CompleterItem* item, children) {
appendRow(item);
}
}