Update: app/xtreewidgetitem.cpp
This commit is contained in:
parent
39cd33efd4
commit
12c9e79bf2
@ -1,56 +1,56 @@
|
|||||||
#include "xtreewidgetitem.h"
|
#include "xtreewidgetitem.h"
|
||||||
|
|
||||||
XTreeWidgetItem::XTreeWidgetItem(QTreeWidget *parent, bool group)
|
XTreeWidgetItem::XTreeWidgetItem(QTreeWidget *parent, bool group)
|
||||||
: QTreeWidgetItem(parent)
|
: QTreeWidgetItem(parent)
|
||||||
, isGroup(group)
|
, isGroup(group)
|
||||||
, mCategory(CATEGORY_NONE) {
|
, mCategory(CATEGORY_NONE) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XTreeWidgetItem::XTreeWidgetItem(QTreeWidgetItem *parent, bool group)
|
XTreeWidgetItem::XTreeWidgetItem(QTreeWidgetItem *parent, bool group)
|
||||||
: QTreeWidgetItem(parent)
|
: QTreeWidgetItem(parent)
|
||||||
, isGroup(group)
|
, isGroup(group)
|
||||||
, mCategory(CATEGORY_NONE) {
|
, mCategory(CATEGORY_NONE) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XTreeWidgetItem::SetCategory(TREE_CATEGORY category)
|
void XTreeWidgetItem::SetCategory(TREE_CATEGORY category)
|
||||||
{
|
{
|
||||||
mCategory = category;
|
mCategory = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
TREE_CATEGORY XTreeWidgetItem::GetCategory()
|
TREE_CATEGORY XTreeWidgetItem::GetCategory()
|
||||||
{
|
{
|
||||||
return mCategory;
|
return mCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XTreeWidgetItem::operator<(const QTreeWidgetItem &other) const {
|
bool XTreeWidgetItem::operator<(const QTreeWidgetItem &other) const {
|
||||||
// Attempt to cast the other item to our custom type.
|
// Attempt to cast the other item to our custom type.
|
||||||
const XTreeWidgetItem* otherItem = dynamic_cast<const XTreeWidgetItem*>(&other);
|
const XTreeWidgetItem* otherItem = dynamic_cast<const XTreeWidgetItem*>(&other);
|
||||||
if (otherItem) {
|
if (otherItem) {
|
||||||
bool thisIsGroup = this->childCount() > 0;
|
bool thisIsGroup = this->childCount() > 0;
|
||||||
bool otherIsGroup = otherItem->childCount() > 0;
|
bool otherIsGroup = otherItem->childCount() > 0;
|
||||||
|
|
||||||
if (thisIsGroup != otherIsGroup) {
|
if (thisIsGroup != otherIsGroup) {
|
||||||
return otherIsGroup; // Groups should come before non-groups
|
return otherIsGroup; // Groups should come before non-groups
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Fallback to the default string comparison on the current sort column.
|
// Fallback to the default string comparison on the current sort column.
|
||||||
return QTreeWidgetItem::operator<(other);
|
return QTreeWidgetItem::operator<(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XTreeWidgetItem& XTreeWidgetItem::operator=(const XTreeWidgetItem &other)
|
XTreeWidgetItem& XTreeWidgetItem::operator=(const XTreeWidgetItem &other)
|
||||||
{
|
{
|
||||||
if (this != &other) {
|
if (this != &other) {
|
||||||
// Copy text and icon for each column.
|
// Copy text and icon for each column.
|
||||||
const int colCount = other.columnCount();
|
const int colCount = other.columnCount();
|
||||||
for (int i = 0; i < colCount; ++i) {
|
for (int i = 0; i < colCount; ++i) {
|
||||||
setText(i, other.text(i));
|
setText(i, other.text(i));
|
||||||
setIcon(i, other.icon(i));
|
setIcon(i, other.icon(i));
|
||||||
}
|
}
|
||||||
// Copy custom members.
|
// Copy custom members.
|
||||||
this->isGroup = other.isGroup;
|
this->isGroup = other.isGroup;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user