mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-16 16:14:47 -04:00
Downcast all qtsizetype to UINT32 manually, apply consistent identation
This commit is contained in:
parent
10e2e60183
commit
4006954bc1
25 changed files with 3398 additions and 3398 deletions
|
@ -1,15 +1,15 @@
|
|||
/* treemodel.cpp
|
||||
|
||||
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
*/
|
||||
|
||||
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
*/
|
||||
|
||||
#include "treemodel.h"
|
||||
|
||||
|
@ -20,9 +20,9 @@ QVariant TreeModel::data(const UModelIndex &index, int role) const
|
|||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
return item->data(index.column()).toLocal8Bit();
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ QVariant TreeModel::data(const UModelIndex &index, int role) const
|
|||
else if (role == Qt::UserRole) {
|
||||
return item->info().toLocal8Bit();
|
||||
}
|
||||
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
@ -44,23 +44,23 @@ Qt::ItemFlags TreeModel::flags(const UModelIndex &index) const
|
|||
{
|
||||
if (!index.isValid())
|
||||
return Qt::NoItemFlags;
|
||||
|
||||
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
}
|
||||
|
||||
QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const
|
||||
int role) const
|
||||
{
|
||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
||||
switch (section) {
|
||||
case 0: return tr("Name");
|
||||
case 1: return tr("Action");
|
||||
case 2: return tr("Type");
|
||||
case 3: return tr("Subtype");
|
||||
case 4: return tr("Text");
|
||||
case 0: return tr("Name");
|
||||
case 1: return tr("Action");
|
||||
case 2: return tr("Type");
|
||||
case 3: return tr("Subtype");
|
||||
case 4: return tr("Text");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
#else
|
||||
|
@ -68,12 +68,12 @@ UString TreeModel::data(const UModelIndex &index, int role) const
|
|||
{
|
||||
if (!index.isValid())
|
||||
return UString();
|
||||
|
||||
|
||||
if (role != 0 && role != 0x0100)
|
||||
return UString();
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
|
||||
|
||||
if (role == 0)
|
||||
return item->data(index.column());
|
||||
else
|
||||
|
@ -81,19 +81,19 @@ UString TreeModel::data(const UModelIndex &index, int role) const
|
|||
}
|
||||
|
||||
UString TreeModel::headerData(int section, int orientation,
|
||||
int role) const
|
||||
int role) const
|
||||
{
|
||||
if (orientation == 1 && role == 0) {
|
||||
switch (section)
|
||||
{
|
||||
case 0: return UString("Name");
|
||||
case 1: return UString("Action");
|
||||
case 2: return UString("Type");
|
||||
case 3: return UString("Subtype");
|
||||
case 4: return UString("Text");
|
||||
case 0: return UString("Name");
|
||||
case 1: return UString("Action");
|
||||
case 2: return UString("Type");
|
||||
case 3: return UString("Subtype");
|
||||
case 4: return UString("Text");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return UString();
|
||||
}
|
||||
#endif
|
||||
|
@ -110,14 +110,14 @@ UModelIndex TreeModel::index(int row, int column, const UModelIndex &parent) con
|
|||
{
|
||||
if (!hasIndex(row, column, parent))
|
||||
return UModelIndex();
|
||||
|
||||
|
||||
TreeItem *parentItem;
|
||||
|
||||
|
||||
if (!parent.isValid())
|
||||
parentItem = rootItem;
|
||||
else
|
||||
parentItem = static_cast<TreeItem*>(parent.internalPointer());
|
||||
|
||||
|
||||
TreeItem *childItem = parentItem->child(row);
|
||||
if (childItem)
|
||||
return createIndex(row, column, childItem);
|
||||
|
@ -129,16 +129,16 @@ UModelIndex TreeModel::parent(const UModelIndex &index) const
|
|||
{
|
||||
if (!index.isValid())
|
||||
return UModelIndex();
|
||||
|
||||
|
||||
TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
|
||||
if (childItem == rootItem)
|
||||
return UModelIndex();
|
||||
|
||||
|
||||
TreeItem *parentItem = childItem->parent();
|
||||
|
||||
|
||||
if (parentItem == rootItem)
|
||||
return UModelIndex();
|
||||
|
||||
|
||||
return createIndex(parentItem->row(), 0, parentItem);
|
||||
}
|
||||
|
||||
|
@ -147,12 +147,12 @@ int TreeModel::rowCount(const UModelIndex &parent) const
|
|||
TreeItem *parentItem;
|
||||
if (parent.column() > 0)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!parent.isValid())
|
||||
parentItem = rootItem;
|
||||
else
|
||||
parentItem = static_cast<TreeItem*>(parent.internalPointer());
|
||||
|
||||
|
||||
return parentItem->childCount();
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ UINT32 TreeModel::base(const UModelIndex ¤t) const
|
|||
// TODO: rewrite this as loop if we ever see an image that is too deep for this naive implementation
|
||||
if (!current.isValid())
|
||||
return 0;
|
||||
|
||||
|
||||
UModelIndex parent = current.parent();
|
||||
if (!parent.isValid())
|
||||
return offset(current);
|
||||
|
@ -302,24 +302,24 @@ void TreeModel::setFixed(const UModelIndex &index, const bool fixed)
|
|||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
item->setFixed(fixed);
|
||||
|
||||
|
||||
if (!item->parent())
|
||||
return;
|
||||
|
||||
|
||||
if (fixed) {
|
||||
// Special handling for uncompressed to compressed boundary
|
||||
if (item->compressed() && item->parent()->compressed() == FALSE) {
|
||||
item->setFixed(item->parent()->fixed());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Propagate fixed flag until root
|
||||
setFixed(index.parent(), true);
|
||||
}
|
||||
|
||||
|
||||
emit dataChanged(index, index);
|
||||
}
|
||||
|
||||
|
@ -327,10 +327,10 @@ void TreeModel::setCompressed(const UModelIndex &index, const bool compressed)
|
|||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
item->setCompressed(compressed);
|
||||
|
||||
|
||||
emit dataChanged(index, index);
|
||||
}
|
||||
|
||||
|
@ -345,10 +345,10 @@ void TreeModel::setMarking(const UModelIndex &index, const UINT8 marking)
|
|||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
item->setMarking(marking);
|
||||
|
||||
|
||||
emit dataChanged(index, index);
|
||||
}
|
||||
|
||||
|
@ -356,7 +356,7 @@ void TreeModel::setOffset(const UModelIndex &index, const UINT32 offset)
|
|||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
item->setOffset(offset);
|
||||
emit dataChanged(index, index);
|
||||
|
@ -366,7 +366,7 @@ void TreeModel::setType(const UModelIndex &index, const UINT8 data)
|
|||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
item->setType(data);
|
||||
emit dataChanged(index, index);
|
||||
|
@ -376,7 +376,7 @@ void TreeModel::setSubtype(const UModelIndex & index, const UINT8 subtype)
|
|||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
item->setSubtype(subtype);
|
||||
emit dataChanged(index, index);
|
||||
|
@ -386,7 +386,7 @@ void TreeModel::setName(const UModelIndex &index, const UString &data)
|
|||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
item->setName(data);
|
||||
emit dataChanged(index, index);
|
||||
|
@ -396,7 +396,7 @@ void TreeModel::setText(const UModelIndex &index, const UString &data)
|
|||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
item->setText(data);
|
||||
emit dataChanged(index, index);
|
||||
|
@ -406,7 +406,7 @@ void TreeModel::setInfo(const UModelIndex &index, const UString &data)
|
|||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
item->setInfo(data);
|
||||
emit dataChanged(index, index);
|
||||
|
@ -416,7 +416,7 @@ void TreeModel::addInfo(const UModelIndex &index, const UString &data, const boo
|
|||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
item->addInfo(data, append);
|
||||
emit dataChanged(index, index);
|
||||
|
@ -426,7 +426,7 @@ void TreeModel::setAction(const UModelIndex &index, const UINT8 action)
|
|||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
item->setAction(action);
|
||||
emit dataChanged(index, index);
|
||||
|
@ -436,7 +436,7 @@ UByteArray TreeModel::parsingData(const UModelIndex &index) const
|
|||
{
|
||||
if (!index.isValid())
|
||||
return UByteArray();
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
return item->parsingData();
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ bool TreeModel::hasEmptyParsingData(const UModelIndex &index) const
|
|||
{
|
||||
if (!index.isValid())
|
||||
return true;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
return item->hasEmptyParsingData();
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ void TreeModel::setParsingData(const UModelIndex &index, const UByteArray &data)
|
|||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
item->setParsingData(data);
|
||||
emit dataChanged(this->index(0, 0), index);
|
||||
|
@ -464,7 +464,7 @@ UByteArray TreeModel::uncompressedData(const UModelIndex &index) const
|
|||
{
|
||||
if (!index.isValid())
|
||||
return UByteArray();
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
return item->uncompressedData();
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ bool TreeModel::hasEmptyUncompressedData(const UModelIndex &index) const
|
|||
{
|
||||
if (!index.isValid())
|
||||
return true;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
return item->hasEmptyUncompressedData();
|
||||
}
|
||||
|
@ -482,22 +482,22 @@ void TreeModel::setUncompressedData(const UModelIndex &index, const UByteArray &
|
|||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
item->setUncompressedData(data);
|
||||
emit dataChanged(this->index(0, 0), index);
|
||||
}
|
||||
|
||||
UModelIndex TreeModel::addItem(const UINT32 offset, const UINT8 type, const UINT8 subtype,
|
||||
const UString & name, const UString & text, const UString & info,
|
||||
const UByteArray & header, const UByteArray & body, const UByteArray & tail,
|
||||
const ItemFixedState fixed,
|
||||
const UModelIndex & parent, const UINT8 mode)
|
||||
const UString & name, const UString & text, const UString & info,
|
||||
const UByteArray & header, const UByteArray & body, const UByteArray & tail,
|
||||
const ItemFixedState fixed,
|
||||
const UModelIndex & parent, const UINT8 mode)
|
||||
{
|
||||
TreeItem *item = 0;
|
||||
TreeItem *parentItem = 0;
|
||||
int parentColumn = 0;
|
||||
|
||||
|
||||
if (!parent.isValid())
|
||||
parentItem = rootItem;
|
||||
else
|
||||
|
@ -512,9 +512,9 @@ UModelIndex TreeModel::addItem(const UINT32 offset, const UINT8 type, const UINT
|
|||
parentColumn = parent.column();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TreeItem *newItem = new TreeItem(offset, type, subtype, name, text, info, header, body, tail, Movable, this->compressed(parent), parentItem);
|
||||
|
||||
|
||||
if (mode == CREATE_MODE_APPEND) {
|
||||
emit layoutAboutToBeChanged();
|
||||
parentItem->appendChild(newItem);
|
||||
|
@ -535,9 +535,9 @@ UModelIndex TreeModel::addItem(const UINT32 offset, const UINT8 type, const UINT
|
|||
delete newItem;
|
||||
return UModelIndex();
|
||||
}
|
||||
|
||||
|
||||
emit layoutChanged();
|
||||
|
||||
|
||||
UModelIndex created = createIndex(newItem->row(), parentColumn, newItem);
|
||||
setFixed(created, (bool)fixed); // Non-trivial logic requires additional call
|
||||
return created;
|
||||
|
@ -547,17 +547,17 @@ UModelIndex TreeModel::findParentOfType(const UModelIndex& index, UINT8 type) co
|
|||
{
|
||||
if (!index.isValid() || !index.parent().isValid())
|
||||
return UModelIndex();
|
||||
|
||||
|
||||
TreeItem *item;
|
||||
UModelIndex parent = index.parent();
|
||||
|
||||
|
||||
for (item = static_cast<TreeItem*>(parent.internalPointer());
|
||||
item != NULL && item != rootItem && item->type() != type;
|
||||
item = static_cast<TreeItem*>(parent.internalPointer()))
|
||||
parent = parent.parent();
|
||||
item != NULL && item != rootItem && item->type() != type;
|
||||
item = static_cast<TreeItem*>(parent.internalPointer()))
|
||||
parent = parent.parent();
|
||||
if (item != NULL && item != rootItem)
|
||||
return parent;
|
||||
|
||||
|
||||
return UModelIndex();
|
||||
}
|
||||
|
||||
|
@ -565,30 +565,30 @@ UModelIndex TreeModel::findLastParentOfType(const UModelIndex& index, UINT8 type
|
|||
{
|
||||
if (!index.isValid())
|
||||
return UModelIndex();
|
||||
|
||||
|
||||
UModelIndex lastParentOfType = findParentOfType(index, type);
|
||||
|
||||
|
||||
if (!lastParentOfType.isValid())
|
||||
return UModelIndex();
|
||||
|
||||
|
||||
UModelIndex currentParentOfType = findParentOfType(lastParentOfType, type);
|
||||
while (currentParentOfType.isValid()) {
|
||||
lastParentOfType = currentParentOfType;
|
||||
currentParentOfType = findParentOfType(lastParentOfType, type);
|
||||
}
|
||||
|
||||
|
||||
return lastParentOfType;
|
||||
}
|
||||
|
||||
UModelIndex TreeModel::findByBase(UINT32 base) const
|
||||
{
|
||||
UModelIndex parentIndex = index(0,0);
|
||||
|
||||
|
||||
goDeeper:
|
||||
int n = rowCount(parentIndex);
|
||||
for (int i = 0; i < n; i++) {
|
||||
UModelIndex currentIndex = parentIndex.model()->index(i, 0, parentIndex);
|
||||
|
||||
|
||||
UINT32 currentBase = this->base(currentIndex);
|
||||
UINT32 fullSize = (UINT32)(header(currentIndex).size() + body(currentIndex).size() + tail(currentIndex).size());
|
||||
if ((compressed(currentIndex) == false || (compressed(currentIndex) == true && compressed(currentIndex.parent()) == false)) // Base is meaningful only for true uncompressed items
|
||||
|
@ -598,6 +598,6 @@ goDeeper:
|
|||
goto goDeeper;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (parentIndex == index(0, 0) ? UModelIndex() : parentIndex);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue