mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-20 15:23:52 +00:00
Don't reset the item model's sort/filter options in updatePlayer (Fixes #2863)
This commit is contained in:
parent
c8d6679a25
commit
9fad33cd14
4 changed files with 33 additions and 1 deletions
|
@ -119,7 +119,12 @@ namespace MWGui
|
|||
{
|
||||
mPtr = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
||||
mTradeModel = new TradeItemModel(new InventoryItemModel(mPtr), MWWorld::Ptr());
|
||||
mSortModel = new SortFilterItemModel(mTradeModel);
|
||||
|
||||
if (mSortModel) // reuse existing SortModel when possible to keep previous category/filter settings
|
||||
mSortModel->setSourceModel(mTradeModel);
|
||||
else
|
||||
mSortModel = new SortFilterItemModel(mTradeModel);
|
||||
|
||||
mItemView->setModel(mSortModel);
|
||||
|
||||
mPreview->updatePtr(mPtr);
|
||||
|
|
|
@ -120,6 +120,11 @@ namespace MWGui
|
|||
}
|
||||
|
||||
|
||||
ProxyItemModel::ProxyItemModel()
|
||||
: mSourceModel(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
ProxyItemModel::~ProxyItemModel()
|
||||
{
|
||||
delete mSourceModel;
|
||||
|
@ -164,4 +169,18 @@ namespace MWGui
|
|||
return mSourceModel->getIndex(item);
|
||||
}
|
||||
|
||||
void ProxyItemModel::setSourceModel(ItemModel *sourceModel)
|
||||
{
|
||||
if (mSourceModel == sourceModel)
|
||||
return;
|
||||
|
||||
if (mSourceModel)
|
||||
{
|
||||
delete mSourceModel;
|
||||
mSourceModel = NULL;
|
||||
}
|
||||
|
||||
mSourceModel = sourceModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,11 +80,15 @@ namespace MWGui
|
|||
class ProxyItemModel : public ItemModel
|
||||
{
|
||||
public:
|
||||
ProxyItemModel();
|
||||
virtual ~ProxyItemModel();
|
||||
virtual MWWorld::Ptr copyItem (const ItemStack& item, size_t count, bool setNewOwner=false);
|
||||
virtual void removeItem (const ItemStack& item, size_t count);
|
||||
virtual ModelIndex getIndex (ItemStack item);
|
||||
|
||||
/// @note Takes ownership of the passed pointer.
|
||||
void setSourceModel(ItemModel* sourceModel);
|
||||
|
||||
ModelIndex mapToSource (ModelIndex index);
|
||||
ModelIndex mapFromSource (ModelIndex index);
|
||||
protected:
|
||||
|
|
|
@ -30,8 +30,12 @@ ItemView::~ItemView()
|
|||
|
||||
void ItemView::setModel(ItemModel *model)
|
||||
{
|
||||
if (mModel == model)
|
||||
return;
|
||||
|
||||
delete mModel;
|
||||
mModel = model;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue