mirror of
				https://github.com/TES3MP/openmw-tes3mp.git
				synced 2025-11-04 05:26:41 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			64 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			64 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#include "itemselection.hpp"
 | 
						|
 | 
						|
#include "itemview.hpp"
 | 
						|
#include "inventoryitemmodel.hpp"
 | 
						|
#include "sortfilteritemmodel.hpp"
 | 
						|
 | 
						|
namespace MWGui
 | 
						|
{
 | 
						|
 | 
						|
    ItemSelectionDialog::ItemSelectionDialog(const std::string &label)
 | 
						|
        : WindowModal("openmw_itemselection_dialog.layout")
 | 
						|
        , mSortModel(NULL)
 | 
						|
        , mModel(NULL)
 | 
						|
    {
 | 
						|
        getWidget(mItemView, "ItemView");
 | 
						|
        mItemView->eventItemClicked += MyGUI::newDelegate(this, &ItemSelectionDialog::onSelectedItem);
 | 
						|
 | 
						|
        MyGUI::TextBox* l;
 | 
						|
        getWidget(l, "Label");
 | 
						|
        l->setCaptionWithReplacing (label);
 | 
						|
 | 
						|
        MyGUI::Button* cancelButton;
 | 
						|
        getWidget(cancelButton, "CancelButton");
 | 
						|
        cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemSelectionDialog::onCancelButtonClicked);
 | 
						|
 | 
						|
        center();
 | 
						|
    }
 | 
						|
 | 
						|
    void ItemSelectionDialog::exit()
 | 
						|
    {
 | 
						|
        eventDialogCanceled();
 | 
						|
    }
 | 
						|
 | 
						|
    void ItemSelectionDialog::openContainer(const MWWorld::Ptr& container)
 | 
						|
    {
 | 
						|
        mModel = new InventoryItemModel(container);
 | 
						|
        mSortModel = new SortFilterItemModel(mModel);
 | 
						|
        mItemView->setModel(mSortModel);
 | 
						|
    }
 | 
						|
 | 
						|
    void ItemSelectionDialog::setCategory(int category)
 | 
						|
    {
 | 
						|
        mSortModel->setCategory(category);
 | 
						|
        mItemView->update();
 | 
						|
    }
 | 
						|
 | 
						|
    void ItemSelectionDialog::setFilter(int filter)
 | 
						|
    {
 | 
						|
        mSortModel->setFilter(filter);
 | 
						|
        mItemView->update();
 | 
						|
    }
 | 
						|
 | 
						|
    void ItemSelectionDialog::onSelectedItem(int index)
 | 
						|
    {
 | 
						|
        ItemStack item = mSortModel->getItem(index);
 | 
						|
        eventItemSelected(item.mBase);
 | 
						|
    }
 | 
						|
 | 
						|
    void ItemSelectionDialog::onCancelButtonClicked(MyGUI::Widget* sender)
 | 
						|
    {
 | 
						|
        exit();
 | 
						|
    }
 | 
						|
 | 
						|
}
 |