Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 656adfb50b9d8ecfc8d8719de61a7851a69b3ab9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
   client/inventorylistview.cc
   This file is part of the Osirion project and is distributed under
   the terms and conditions of the GNU General Public License version 2
*/

#include "client/inventorylistview.h"
#include "ui/listitem.h"

namespace client {

InventoryListView::InventoryListView(ui::Widget *parent) : ui::ListView (parent)
{
	set_inventory(0, 0);
}

void InventoryListView::set_inventory(core::Inventory *inventory, core::InfoType *info_type)
{
	remove_children();
	
	if (!inventory || !info_type) {
		return;
	}
	
	for (core::Inventory::Items::const_iterator it = inventory->items().begin(); it != inventory->items().end(); it++) {
		core::Item *item = (*it);
	
		if (item->info() && item->info()->type() == info_type) {
			ui::ListItem *listitem = 0;	
			listitem = new ui::ListItem(this, item->info()->name().c_str());
			listitem->set_height(listitem->font()->height() * 2.0f);
			listitem->set_info(item->info());
		}
	}
	
	event_resize();
}

} // namespace client