UEFITool/common/treeitem.cpp

83 lines
2.2 KiB
C++
Raw Normal View History

2013-10-08 15:07:03 +08:00
/* treeitem.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
2013-10-08 15:07:03 +08:00
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
2013-10-08 15:07:03 +08:00
*/
#include "treeitem.h"
#include "types.h"
2013-10-08 15:07:03 +08:00
TreeItem::TreeItem(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 BOOLEAN fixed, const BOOLEAN compressed, const UByteArray & parsingData,
TreeItem *parent) :
itemAction(Actions::NoAction),
itemType(type),
itemSubtype(subtype),
itemName(name),
itemText(text),
itemInfo(info),
itemHeader(header),
itemBody(body),
itemTail(tail),
itemParsingData(parsingData),
itemFixed(fixed),
itemCompressed(compressed),
parentItem(parent)
{
setFixed(fixed);
}
UINT8 TreeItem::insertChildBefore(TreeItem *item, TreeItem *newItem)
{
int index = childItems.indexOf(item);
if (index == -1)
return U_ITEM_NOT_FOUND;
childItems.insert(index, newItem);
return U_SUCCESS;
}
UINT8 TreeItem::insertChildAfter(TreeItem *item, TreeItem *newItem)
2013-10-08 15:07:03 +08:00
{
int index = childItems.indexOf(item);
if (index == -1)
return U_ITEM_NOT_FOUND;
childItems.insert(index + 1, newItem);
return U_SUCCESS;
2013-10-08 15:07:03 +08:00
}
QVariant TreeItem::data(int column) const
2013-10-08 15:07:03 +08:00
{
switch (column)
2013-10-08 15:07:03 +08:00
{
case 0: // Name
return itemName;
case 1: // Action
return actionTypeToUString(itemAction);
case 2: // Type
return itemTypeToUString(itemType);
case 3: // Subtype
return itemSubtypeToUString(itemType, itemSubtype);
case 4: // Text
2013-10-08 15:07:03 +08:00
return itemText;
default:
return QVariant();
2013-10-08 15:07:03 +08:00
}
}
int TreeItem::row() const
{
if (parentItem)
return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
return 0;
}