0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-11-25 00:18: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,14 +1,17 @@
#include "XmlModel.h"
#include <QDebug>
XmlModel::XmlModel(QByteArray *data) {
XmlModel::XmlModel(QByteArray* data)
{
if (data) {
m_doc.setContent(*data);
initModel();
}
}
void XmlModel::setXMLData(QByteArray *data) {
void XmlModel::setXMLData(QByteArray* data)
{
if (data) {
beginResetModel();
m_doc.setContent(*data);
@@ -17,7 +20,8 @@ void XmlModel::setXMLData(QByteArray *data) {
}
}
void XmlModel::initModel(){
void XmlModel::initModel()
{
m_items = m_doc.firstChildElement("items");
parseHeaders();
}
@@ -27,47 +31,41 @@ void XmlModel::parseHeaders()
m_fields.clear();
QDomNode root = m_doc.firstChildElement("items");
QDomNode item = root.firstChild();
for (int i=0; i<item.childNodes().count();++i){
for (int i = 0; i < item.childNodes().count(); ++i) {
QDomNode attr = item.childNodes().item(i);
m_fields.append(attr.nodeName());
m_fields.append(attr.nodeName());
}
}
QModelIndex XmlModel::index(int row, int column, const QModelIndex &parent) const
QModelIndex XmlModel::index(int row, int column, const QModelIndex& parent) const
{
if (m_fields.isEmpty())
return QModelIndex();
return createIndex(row, column);
}
QModelIndex XmlModel::parent(const QModelIndex &child) const
{
return QModelIndex();
}
QModelIndex XmlModel::parent(const QModelIndex& child) const { return QModelIndex(); }
int XmlModel::rowCount(const QModelIndex &parent) const
{
return m_items.childNodes().count();
}
int XmlModel::rowCount(const QModelIndex& parent) const { return m_items.childNodes().count(); }
int XmlModel::columnCount(const QModelIndex &parent) const
{
return m_fields.count();
}
int XmlModel::columnCount(const QModelIndex& parent) const { return m_fields.count(); }
QVariant XmlModel::data(const QModelIndex &index, int role) const
QVariant XmlModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::DisplayRole) {
if (index.isValid()){
if (index.isValid()) {
QDomNode data = m_items.childNodes().at(index.row()).childNodes().item(index.column());
return data.toElement().text();
} else return QVariant();
} else return QVariant();
} else
return QVariant();
} else
return QVariant();
}
QVariant XmlModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(orientation==Qt::Horizontal&&role==Qt::DisplayRole){
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
return m_fields[section];
} else return QVariant();
} else
return QVariant();
}