2013-10-08 15:07:03 +08:00
|
|
|
/* treeitem.h
|
|
|
|
|
2015-01-31 22:00:00 +08:00
|
|
|
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
2013-12-29 23:13:46 +08:00
|
|
|
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
|
|
|
|
2013-12-29 23:13:46 +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
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __TREEITEM_H__
|
|
|
|
#define __TREEITEM_H__
|
|
|
|
|
|
|
|
#include <QByteArray>
|
|
|
|
#include <QList>
|
|
|
|
#include <QString>
|
2013-11-07 21:46:28 +08:00
|
|
|
#include <QVariant>
|
2013-10-08 15:07:03 +08:00
|
|
|
|
|
|
|
#include "basetypes.h"
|
|
|
|
|
|
|
|
class TreeItem
|
|
|
|
{
|
|
|
|
public:
|
2015-01-31 22:00:00 +08:00
|
|
|
TreeItem(const UINT8 type, const UINT32 attributes = 0, const UINT8 compression = COMPRESSION_ALGORITHM_NONE,
|
2014-07-25 07:59:51 +08:00
|
|
|
const QString &name = QString(), const QString &text = QString(), const QString &info = QString(),
|
2015-01-31 22:00:00 +08:00
|
|
|
const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(),
|
2014-07-25 07:59:51 +08:00
|
|
|
TreeItem *parent = 0);
|
2013-10-08 15:07:03 +08:00
|
|
|
~TreeItem();
|
|
|
|
|
2013-11-07 21:46:28 +08:00
|
|
|
// Operations with items
|
2013-10-08 15:07:03 +08:00
|
|
|
void appendChild(TreeItem *item);
|
2013-11-07 21:46:28 +08:00
|
|
|
void prependChild(TreeItem *item);
|
|
|
|
UINT8 insertChildBefore(TreeItem *item, TreeItem *newItem);
|
|
|
|
UINT8 insertChildAfter(TreeItem *item, TreeItem *newItem);
|
|
|
|
|
|
|
|
// Model support operations
|
2013-10-08 15:07:03 +08:00
|
|
|
TreeItem *child(int row);
|
|
|
|
int childCount() const;
|
|
|
|
int columnCount() const;
|
2013-11-07 21:46:28 +08:00
|
|
|
QVariant data(int column) const;
|
2013-10-08 15:07:03 +08:00
|
|
|
int row() const;
|
|
|
|
TreeItem *parent();
|
|
|
|
|
2013-11-07 21:46:28 +08:00
|
|
|
// Reading operations for item parameters
|
2015-01-31 22:00:00 +08:00
|
|
|
QString name() const;
|
|
|
|
void setName(const QString &text);
|
|
|
|
|
2013-11-07 21:46:28 +08:00
|
|
|
UINT8 type() const;
|
2015-01-31 22:00:00 +08:00
|
|
|
void setType(const UINT8 type);
|
|
|
|
|
|
|
|
UINT32 attributes() const;
|
|
|
|
void setAttributes(const UINT32 attributes);
|
|
|
|
|
|
|
|
QString text() const;
|
|
|
|
void setText(const QString &text);
|
|
|
|
|
2013-11-07 21:46:28 +08:00
|
|
|
QByteArray header() const;
|
|
|
|
bool hasEmptyHeader() const;
|
2015-01-31 22:00:00 +08:00
|
|
|
|
2013-11-07 21:46:28 +08:00
|
|
|
QByteArray body() const;
|
|
|
|
bool hasEmptyBody() const;
|
2015-01-31 22:00:00 +08:00
|
|
|
|
2013-11-07 21:46:28 +08:00
|
|
|
QString info() const;
|
2015-01-31 22:00:00 +08:00
|
|
|
void addInfo(const QString &info);
|
|
|
|
void setInfo(const QString &info);
|
|
|
|
|
2013-11-18 23:23:59 +08:00
|
|
|
UINT8 action() const;
|
2013-12-29 23:13:46 +08:00
|
|
|
void setAction(const UINT8 action);
|
2013-10-08 15:07:03 +08:00
|
|
|
|
2015-01-31 22:00:00 +08:00
|
|
|
UINT8 compression() const;
|
2013-12-29 23:13:46 +08:00
|
|
|
|
2015-01-31 22:00:00 +08:00
|
|
|
private:
|
2013-10-08 15:07:03 +08:00
|
|
|
QList<TreeItem*> childItems;
|
2015-01-31 22:00:00 +08:00
|
|
|
UINT8 itemAction;
|
|
|
|
UINT8 itemType;
|
|
|
|
UINT32 itemAttributes;
|
|
|
|
UINT8 itemCompression;
|
2015-01-31 22:46:17 +08:00
|
|
|
QString itemName;
|
|
|
|
QString itemText;
|
|
|
|
QString itemInfo;
|
2013-10-08 15:07:03 +08:00
|
|
|
QByteArray itemHeader;
|
|
|
|
QByteArray itemBody;
|
|
|
|
TreeItem *parentItem;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|