mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-15 07:34:45 -04:00
LessQt, part 1
- added wrappers over Qt classes for seamless replacement if Qt is not available - added bstrlib as submodule - only UEFIExtract works with this changes for now, others will followa bit later
This commit is contained in:
parent
71ce2a07b2
commit
bf8632c063
32 changed files with 2891 additions and 2774 deletions
|
@ -17,7 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
TreeModel::TreeModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
rootItem = new TreeItem(Types::Root, 0, QString(), QString(), QString(), QByteArray(), QByteArray(), QByteArray(), TRUE, FALSE, QByteArray());
|
||||
rootItem = new TreeItem(Types::Root, 0, UString(), UString(), UString(), UByteArray(), UByteArray(), UByteArray(), TRUE, FALSE, UByteArray());
|
||||
}
|
||||
|
||||
TreeModel::~TreeModel()
|
||||
|
@ -25,7 +25,7 @@ TreeModel::~TreeModel()
|
|||
delete rootItem;
|
||||
}
|
||||
|
||||
int TreeModel::columnCount(const QModelIndex &parent) const
|
||||
int TreeModel::columnCount(const UModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
return static_cast<TreeItem*>(parent.internalPointer())->columnCount();
|
||||
|
@ -33,7 +33,7 @@ int TreeModel::columnCount(const QModelIndex &parent) const
|
|||
return rootItem->columnCount();
|
||||
}
|
||||
|
||||
QVariant TreeModel::data(const QModelIndex &index, int role) const
|
||||
QVariant TreeModel::data(const UModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
@ -49,7 +49,7 @@ QVariant TreeModel::data(const QModelIndex &index, int role) const
|
|||
return item->info();
|
||||
}
|
||||
|
||||
Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
|
||||
Qt::ItemFlags TreeModel::flags(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
|
@ -79,10 +79,10 @@ QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
|
|||
return QVariant();
|
||||
}
|
||||
|
||||
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const
|
||||
UModelIndex TreeModel::index(int row, int column, const UModelIndex &parent) const
|
||||
{
|
||||
if (!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
return UModelIndex();
|
||||
|
||||
TreeItem *parentItem;
|
||||
|
||||
|
@ -95,27 +95,27 @@ QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) con
|
|||
if (childItem)
|
||||
return createIndex(row, column, childItem);
|
||||
else
|
||||
return QModelIndex();
|
||||
return UModelIndex();
|
||||
}
|
||||
|
||||
QModelIndex TreeModel::parent(const QModelIndex &index) const
|
||||
UModelIndex TreeModel::parent(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QModelIndex();
|
||||
return UModelIndex();
|
||||
|
||||
TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
|
||||
if (childItem == rootItem)
|
||||
return QModelIndex();
|
||||
return UModelIndex();
|
||||
|
||||
TreeItem *parentItem = childItem->parent();
|
||||
|
||||
if (parentItem == rootItem)
|
||||
return QModelIndex();
|
||||
return UModelIndex();
|
||||
|
||||
return createIndex(parentItem->row(), 0, parentItem);
|
||||
}
|
||||
|
||||
int TreeModel::rowCount(const QModelIndex &parent) const
|
||||
int TreeModel::rowCount(const UModelIndex &parent) const
|
||||
{
|
||||
TreeItem *parentItem;
|
||||
if (parent.column() > 0)
|
||||
|
@ -129,7 +129,7 @@ int TreeModel::rowCount(const QModelIndex &parent) const
|
|||
return parentItem->childCount();
|
||||
}
|
||||
|
||||
UINT8 TreeModel::type(const QModelIndex &index) const
|
||||
UINT8 TreeModel::type(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
|
@ -137,7 +137,7 @@ UINT8 TreeModel::type(const QModelIndex &index) const
|
|||
return item->type();
|
||||
}
|
||||
|
||||
UINT8 TreeModel::subtype(const QModelIndex &index) const
|
||||
UINT8 TreeModel::subtype(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
|
@ -145,15 +145,15 @@ UINT8 TreeModel::subtype(const QModelIndex &index) const
|
|||
return item->subtype();
|
||||
}
|
||||
|
||||
QByteArray TreeModel::header(const QModelIndex &index) const
|
||||
UByteArray TreeModel::header(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QByteArray();
|
||||
return UByteArray();
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
return item->header();
|
||||
}
|
||||
|
||||
bool TreeModel::hasEmptyHeader(const QModelIndex &index) const
|
||||
bool TreeModel::hasEmptyHeader(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return true;
|
||||
|
@ -161,15 +161,15 @@ bool TreeModel::hasEmptyHeader(const QModelIndex &index) const
|
|||
return item->hasEmptyHeader();
|
||||
}
|
||||
|
||||
QByteArray TreeModel::body(const QModelIndex &index) const
|
||||
UByteArray TreeModel::body(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QByteArray();
|
||||
return UByteArray();
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
return item->body();
|
||||
}
|
||||
|
||||
bool TreeModel::hasEmptyBody(const QModelIndex &index) const
|
||||
bool TreeModel::hasEmptyBody(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return true;
|
||||
|
@ -177,15 +177,15 @@ bool TreeModel::hasEmptyBody(const QModelIndex &index) const
|
|||
return item->hasEmptyBody();
|
||||
}
|
||||
|
||||
QByteArray TreeModel::tail(const QModelIndex &index) const
|
||||
UByteArray TreeModel::tail(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QByteArray();
|
||||
return UByteArray();
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
return item->tail();
|
||||
}
|
||||
|
||||
bool TreeModel::hasEmptyTail(const QModelIndex &index) const
|
||||
bool TreeModel::hasEmptyTail(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return true;
|
||||
|
@ -193,15 +193,15 @@ bool TreeModel::hasEmptyTail(const QModelIndex &index) const
|
|||
return item->hasEmptyTail();
|
||||
}
|
||||
|
||||
QByteArray TreeModel::parsingData(const QModelIndex &index) const
|
||||
UByteArray TreeModel::parsingData(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QByteArray();
|
||||
return UByteArray();
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
return item->parsingData();
|
||||
}
|
||||
|
||||
bool TreeModel::hasEmptyParsingData(const QModelIndex &index) const
|
||||
bool TreeModel::hasEmptyParsingData(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return true;
|
||||
|
@ -209,31 +209,31 @@ bool TreeModel::hasEmptyParsingData(const QModelIndex &index) const
|
|||
return item->hasEmptyParsingData();
|
||||
}
|
||||
|
||||
QString TreeModel::name(const QModelIndex &index) const
|
||||
UString TreeModel::name(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QString();
|
||||
return UString();
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
return item->name();
|
||||
}
|
||||
|
||||
QString TreeModel::text(const QModelIndex &index) const
|
||||
UString TreeModel::text(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QString();
|
||||
return UString();
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
return item->text();
|
||||
}
|
||||
|
||||
QString TreeModel::info(const QModelIndex &index) const
|
||||
UString TreeModel::info(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QString();
|
||||
return UString();
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
return item->info();
|
||||
}
|
||||
|
||||
UINT8 TreeModel::action(const QModelIndex &index) const
|
||||
UINT8 TreeModel::action(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return Actions::NoAction;
|
||||
|
@ -241,7 +241,7 @@ UINT8 TreeModel::action(const QModelIndex &index) const
|
|||
return item->action();
|
||||
}
|
||||
|
||||
bool TreeModel::fixed(const QModelIndex &index) const
|
||||
bool TreeModel::fixed(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return false;
|
||||
|
@ -249,7 +249,7 @@ bool TreeModel::fixed(const QModelIndex &index) const
|
|||
return item->fixed();
|
||||
}
|
||||
|
||||
bool TreeModel::compressed(const QModelIndex &index) const
|
||||
bool TreeModel::compressed(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return false;
|
||||
|
@ -257,7 +257,7 @@ bool TreeModel::compressed(const QModelIndex &index) const
|
|||
return item->compressed();
|
||||
}
|
||||
|
||||
void TreeModel::setFixed(const QModelIndex &index, const bool fixed)
|
||||
void TreeModel::setFixed(const UModelIndex &index, const bool fixed)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
@ -281,7 +281,7 @@ void TreeModel::setFixed(const QModelIndex &index, const bool fixed)
|
|||
emit dataChanged(index, index);
|
||||
}
|
||||
|
||||
void TreeModel::setCompressed(const QModelIndex &index, const bool compressed)
|
||||
void TreeModel::setCompressed(const UModelIndex &index, const bool compressed)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
@ -293,7 +293,7 @@ void TreeModel::setCompressed(const QModelIndex &index, const bool compressed)
|
|||
}
|
||||
|
||||
|
||||
void TreeModel::setSubtype(const QModelIndex & index, const UINT8 subtype)
|
||||
void TreeModel::setSubtype(const UModelIndex & index, const UINT8 subtype)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
@ -303,7 +303,7 @@ void TreeModel::setSubtype(const QModelIndex & index, const UINT8 subtype)
|
|||
emit dataChanged(index, index);
|
||||
}
|
||||
|
||||
void TreeModel::setName(const QModelIndex &index, const QString &data)
|
||||
void TreeModel::setName(const UModelIndex &index, const UString &data)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
@ -313,7 +313,7 @@ void TreeModel::setName(const QModelIndex &index, const QString &data)
|
|||
emit dataChanged(index, index);
|
||||
}
|
||||
|
||||
void TreeModel::setType(const QModelIndex &index, const UINT8 data)
|
||||
void TreeModel::setType(const UModelIndex &index, const UINT8 data)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
@ -323,7 +323,7 @@ void TreeModel::setType(const QModelIndex &index, const UINT8 data)
|
|||
emit dataChanged(index, index);
|
||||
}
|
||||
|
||||
void TreeModel::setText(const QModelIndex &index, const QString &data)
|
||||
void TreeModel::setText(const UModelIndex &index, const UString &data)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
@ -333,7 +333,7 @@ void TreeModel::setText(const QModelIndex &index, const QString &data)
|
|||
emit dataChanged(index, index);
|
||||
}
|
||||
|
||||
void TreeModel::setInfo(const QModelIndex &index, const QString &data)
|
||||
void TreeModel::setInfo(const UModelIndex &index, const UString &data)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
@ -343,7 +343,7 @@ void TreeModel::setInfo(const QModelIndex &index, const QString &data)
|
|||
emit dataChanged(index, index);
|
||||
}
|
||||
|
||||
void TreeModel::addInfo(const QModelIndex &index, const QString &data, const bool append)
|
||||
void TreeModel::addInfo(const UModelIndex &index, const UString &data, const bool append)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
@ -353,7 +353,7 @@ void TreeModel::addInfo(const QModelIndex &index, const QString &data, const boo
|
|||
emit dataChanged(index, index);
|
||||
}
|
||||
|
||||
void TreeModel::setAction(const QModelIndex &index, const UINT8 action)
|
||||
void TreeModel::setAction(const UModelIndex &index, const UINT8 action)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
@ -363,7 +363,7 @@ void TreeModel::setAction(const QModelIndex &index, const UINT8 action)
|
|||
emit dataChanged(index, index);
|
||||
}
|
||||
|
||||
void TreeModel::setParsingData(const QModelIndex &index, const QByteArray &data)
|
||||
void TreeModel::setParsingData(const UModelIndex &index, const UByteArray &data)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
@ -373,11 +373,11 @@ void TreeModel::setParsingData(const QModelIndex &index, const QByteArray &data)
|
|||
emit dataChanged(this->index(0, 0), index);
|
||||
}
|
||||
|
||||
QModelIndex TreeModel::addItem(const UINT8 type, const UINT8 subtype,
|
||||
const QString & name, const QString & text, const QString & info,
|
||||
const QByteArray & header, const QByteArray & body, const QByteArray & tail,
|
||||
const bool fixed, const QByteArray & parsingData,
|
||||
const QModelIndex & parent, const UINT8 mode)
|
||||
UModelIndex TreeModel::addItem(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 bool fixed, const UByteArray & parsingData,
|
||||
const UModelIndex & parent, const UINT8 mode)
|
||||
{
|
||||
TreeItem *item = 0;
|
||||
TreeItem *parentItem = 0;
|
||||
|
@ -418,23 +418,23 @@ QModelIndex TreeModel::addItem(const UINT8 type, const UINT8 subtype,
|
|||
}
|
||||
else {
|
||||
delete newItem;
|
||||
return QModelIndex();
|
||||
return UModelIndex();
|
||||
}
|
||||
|
||||
emit layoutChanged();
|
||||
|
||||
QModelIndex created = createIndex(newItem->row(), parentColumn, newItem);
|
||||
UModelIndex created = createIndex(newItem->row(), parentColumn, newItem);
|
||||
setFixed(created, fixed); // Non-trivial logic requires additional call
|
||||
return created;
|
||||
}
|
||||
|
||||
QModelIndex TreeModel::findParentOfType(const QModelIndex& index, UINT8 type) const
|
||||
UModelIndex TreeModel::findParentOfType(const UModelIndex& index, UINT8 type) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QModelIndex();
|
||||
return UModelIndex();
|
||||
|
||||
TreeItem *item;
|
||||
QModelIndex parent = index;
|
||||
UModelIndex parent = index;
|
||||
|
||||
for (item = static_cast<TreeItem*>(parent.internalPointer());
|
||||
item != NULL && item != rootItem && item->type() != type;
|
||||
|
@ -443,5 +443,5 @@ QModelIndex TreeModel::findParentOfType(const QModelIndex& index, UINT8 type) co
|
|||
if (item != NULL && item != rootItem)
|
||||
return parent;
|
||||
|
||||
return QModelIndex();
|
||||
return UModelIndex();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue