summaryrefslogtreecommitdiff
path: root/indra/newview/llwearableitemslist.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llwearableitemslist.h')
-rw-r--r--indra/newview/llwearableitemslist.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h
index 5e3202c687..2cab5a07a2 100644
--- a/indra/newview/llwearableitemslist.h
+++ b/indra/newview/llwearableitemslist.h
@@ -172,6 +172,98 @@ private:
};
/**
+ * @class LLWearableListItemComparator
+ *
+ * Abstract comparator of wearable list items.
+ */
+class LLWearableListItemComparator : public LLFlatListView::ItemComparator
+{
+ LOG_CLASS(LLWearableListItemComparator);
+
+public:
+ LLWearableListItemComparator() {};
+ virtual ~LLWearableListItemComparator() {};
+
+ virtual bool compare(const LLPanel* item1, const LLPanel* item2) const
+ {
+ const LLPanelInventoryListItemBase* wearable_item1 = dynamic_cast<const LLPanelInventoryListItemBase*>(item1);
+ const LLPanelInventoryListItemBase* wearable_item2 = dynamic_cast<const LLPanelInventoryListItemBase*>(item2);
+
+ if (!wearable_item1 || !wearable_item2)
+ {
+ llwarning("item1 and item2 cannot be null", 0);
+ return true;
+ }
+
+ return doCompare(wearable_item1, wearable_item2);
+ }
+
+protected:
+
+ /**
+ * Returns true if wearable_item1 < wearable_item2, false otherwise
+ * Implement this method in your particular comparator.
+ */
+ virtual bool doCompare(const LLPanelInventoryListItemBase* wearable_item1, const LLPanelInventoryListItemBase* wearable_item2) const = 0;
+};
+
+/**
+ * @class LLWearableItemNameComparator
+ *
+ * Comparator for sorting wearable list items by name.
+ */
+class LLWearableItemNameComparator : public LLWearableListItemComparator
+{
+ LOG_CLASS(LLWearableItemNameComparator);
+
+public:
+ LLWearableItemNameComparator() {};
+ virtual ~LLWearableItemNameComparator() {};
+
+protected:
+ /*virtual*/ bool doCompare(const LLPanelInventoryListItemBase* wearable_item1, const LLPanelInventoryListItemBase* wearable_item2) const;
+};
+
+/**
+ * @class LLWearableItemTypeNameComparator
+ *
+ * Comparator for sorting wearable list items by type and name.
+ */
+class LLWearableItemTypeNameComparator : public LLWearableItemNameComparator
+{
+ LOG_CLASS(LLWearableItemTypeNameComparator);
+
+public:
+ LLWearableItemTypeNameComparator() {};
+ virtual ~LLWearableItemTypeNameComparator() {};
+
+protected:
+ /**
+ * Returns "true" if wearable_item1 is placed before wearable_item2 sorted by the following:
+ * - Attachments (abc order)
+ * - Clothing
+ * - by type (types order determined in LLWearableType::EType)
+ * - outer layer on top
+ * - Body Parts (abc order),
+ * "false" otherwise.
+ */
+ /*virtual*/ bool doCompare(const LLPanelInventoryListItemBase* wearable_item1, const LLPanelInventoryListItemBase* wearable_item2) const;
+
+private:
+ enum ETypeListOrder
+ {
+ TLO_ATTACHMENT = 0x01,
+ TLO_CLOTHING = 0x02,
+ TLO_BODYPART = 0x04,
+ TLO_UNKNOWN = 0x08,
+
+ TLO_NOT_CLOTHING = TLO_ATTACHMENT | TLO_BODYPART | TLO_UNKNOWN
+ };
+
+ static LLWearableItemTypeNameComparator::ETypeListOrder getTypeListOrder(LLAssetType::EType item_type);
+};
+
+/**
* @class LLWearableItemsList
*
* A flat list of wearable inventory items.