forked from mirror/openmw-tes3mp
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();
|
mPtr = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
||||||
mTradeModel = new TradeItemModel(new InventoryItemModel(mPtr), MWWorld::Ptr());
|
mTradeModel = new TradeItemModel(new InventoryItemModel(mPtr), MWWorld::Ptr());
|
||||||
|
|
||||||
|
if (mSortModel) // reuse existing SortModel when possible to keep previous category/filter settings
|
||||||
|
mSortModel->setSourceModel(mTradeModel);
|
||||||
|
else
|
||||||
mSortModel = new SortFilterItemModel(mTradeModel);
|
mSortModel = new SortFilterItemModel(mTradeModel);
|
||||||
|
|
||||||
mItemView->setModel(mSortModel);
|
mItemView->setModel(mSortModel);
|
||||||
|
|
||||||
mPreview->updatePtr(mPtr);
|
mPreview->updatePtr(mPtr);
|
||||||
|
|
|
@ -120,6 +120,11 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ProxyItemModel::ProxyItemModel()
|
||||||
|
: mSourceModel(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ProxyItemModel::~ProxyItemModel()
|
ProxyItemModel::~ProxyItemModel()
|
||||||
{
|
{
|
||||||
delete mSourceModel;
|
delete mSourceModel;
|
||||||
|
@ -164,4 +169,18 @@ namespace MWGui
|
||||||
return mSourceModel->getIndex(item);
|
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
|
class ProxyItemModel : public ItemModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
ProxyItemModel();
|
||||||
virtual ~ProxyItemModel();
|
virtual ~ProxyItemModel();
|
||||||
virtual MWWorld::Ptr copyItem (const ItemStack& item, size_t count, bool setNewOwner=false);
|
virtual MWWorld::Ptr copyItem (const ItemStack& item, size_t count, bool setNewOwner=false);
|
||||||
virtual void removeItem (const ItemStack& item, size_t count);
|
virtual void removeItem (const ItemStack& item, size_t count);
|
||||||
virtual ModelIndex getIndex (ItemStack item);
|
virtual ModelIndex getIndex (ItemStack item);
|
||||||
|
|
||||||
|
/// @note Takes ownership of the passed pointer.
|
||||||
|
void setSourceModel(ItemModel* sourceModel);
|
||||||
|
|
||||||
ModelIndex mapToSource (ModelIndex index);
|
ModelIndex mapToSource (ModelIndex index);
|
||||||
ModelIndex mapFromSource (ModelIndex index);
|
ModelIndex mapFromSource (ModelIndex index);
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -30,8 +30,12 @@ ItemView::~ItemView()
|
||||||
|
|
||||||
void ItemView::setModel(ItemModel *model)
|
void ItemView::setModel(ItemModel *model)
|
||||||
{
|
{
|
||||||
|
if (mModel == model)
|
||||||
|
return;
|
||||||
|
|
||||||
delete mModel;
|
delete mModel;
|
||||||
mModel = model;
|
mModel = model;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue