forked from teamnwah/openmw-tes3coop
TopicInfos result script are now displayed in dialogue subviews.
parent
cb3396643b
commit
18162557b0
@ -0,0 +1,110 @@
|
||||
#include "nestedinfocollection.hpp"
|
||||
|
||||
#include "nestedcoladapterimp.hpp"
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
NestedInfoCollection::NestedInfoCollection ()
|
||||
{}
|
||||
|
||||
NestedInfoCollection::~NestedInfoCollection()
|
||||
{
|
||||
for (std::map<const ColumnBase *, NestedColumnAdapter<Info>* >::iterator
|
||||
iter (mAdapters.begin()); iter!=mAdapters.end(); ++iter)
|
||||
{
|
||||
delete (*iter).second;
|
||||
}
|
||||
}
|
||||
|
||||
void NestedInfoCollection::addAdapter(std::pair<const ColumnBase*,
|
||||
NestedColumnAdapter<Info>* > adapter)
|
||||
{
|
||||
mAdapters.insert(adapter);
|
||||
}
|
||||
|
||||
const NestedColumnAdapter<Info>& NestedInfoCollection::getAdapter(const ColumnBase &column) const
|
||||
{
|
||||
std::map<const ColumnBase *, NestedColumnAdapter<Info>* >::const_iterator iter =
|
||||
mAdapters.find (&column);
|
||||
|
||||
if (iter==mAdapters.end())
|
||||
throw std::logic_error("No such column in the nestedidadapter");
|
||||
|
||||
return *iter->second;
|
||||
}
|
||||
|
||||
void NestedInfoCollection::addNestedRow(int row, int column, int position)
|
||||
{
|
||||
Record<Info> record;
|
||||
record.assign(Collection<Info, IdAccessor<Info> >::getRecord(row));
|
||||
|
||||
getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).addRow(record, position);
|
||||
|
||||
Collection<Info, IdAccessor<Info> >::setRecord(row, record);
|
||||
}
|
||||
|
||||
void NestedInfoCollection::removeNestedRows(int row, int column, int subRow)
|
||||
{
|
||||
Record<Info> record;
|
||||
record.assign(Collection<Info, IdAccessor<Info> >::getRecord(row));
|
||||
|
||||
getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).removeRow(record, subRow);
|
||||
|
||||
Collection<Info, IdAccessor<Info> >::setRecord(row, record);
|
||||
}
|
||||
|
||||
QVariant NestedInfoCollection::getNestedData (int row,
|
||||
int column, int subRow, int subColumn) const
|
||||
{
|
||||
return getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).getData(
|
||||
Collection<Info, IdAccessor<Info> >::getRecord(row), subRow, subColumn);
|
||||
}
|
||||
|
||||
void NestedInfoCollection::setNestedData(int row,
|
||||
int column, const QVariant& data, int subRow, int subColumn)
|
||||
{
|
||||
Record<Info> record;
|
||||
record.assign(Collection<Info, IdAccessor<Info> >::getRecord(row));
|
||||
|
||||
getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).setData(
|
||||
record, data, subRow, subColumn);
|
||||
|
||||
Collection<Info, IdAccessor<Info> >::setRecord(row, record);
|
||||
}
|
||||
|
||||
CSMWorld::NestedTableWrapperBase* NestedInfoCollection::nestedTable(int row,
|
||||
int column) const
|
||||
{
|
||||
return getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).table(
|
||||
Collection<Info, IdAccessor<Info> >::getRecord(row));
|
||||
}
|
||||
|
||||
void NestedInfoCollection::setNestedTable(int row,
|
||||
int column, const CSMWorld::NestedTableWrapperBase& nestedTable)
|
||||
{
|
||||
Record<Info> record;
|
||||
record.assign(Collection<Info, IdAccessor<Info> >::getRecord(row));
|
||||
|
||||
getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).setTable(
|
||||
record, nestedTable);
|
||||
|
||||
Collection<Info, IdAccessor<Info> >::setRecord(row, record);
|
||||
}
|
||||
|
||||
int NestedInfoCollection::getNestedRowsCount(int row, int column) const
|
||||
{
|
||||
return getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).getRowsCount(
|
||||
Collection<Info, IdAccessor<Info> >::getRecord(row));
|
||||
}
|
||||
|
||||
int NestedInfoCollection::getNestedColumnsCount(int row, int column) const
|
||||
{
|
||||
return getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).getColumnsCount(
|
||||
Collection<Info, IdAccessor<Info> >::getRecord(row));
|
||||
}
|
||||
|
||||
CSMWorld::NestableColumn *NestedInfoCollection::getNestableColumn(int column)
|
||||
{
|
||||
return Collection<Info, IdAccessor<Info> >::getNestableColumn(column);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
#ifndef CSM_WOLRD_NESTEDINFOCOLLECTION_H
|
||||
#define CSM_WOLRD_NESTEDINFOCOLLECTION_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "infocollection.hpp"
|
||||
#include "nestedcollection.hpp"
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
struct NestedTableWrapperBase;
|
||||
|
||||
template<typename ESXRecordT>
|
||||
class NestedColumnAdapter;
|
||||
|
||||
class NestedInfoCollection : public InfoCollection, public NestedCollection
|
||||
{
|
||||
std::map<const ColumnBase*, NestedColumnAdapter<Info>* > mAdapters;
|
||||
|
||||
const NestedColumnAdapter<Info>& getAdapter(const ColumnBase &column) const;
|
||||
|
||||
public:
|
||||
|
||||
NestedInfoCollection ();
|
||||
~NestedInfoCollection();
|
||||
|
||||
virtual void addNestedRow(int row, int column, int position);
|
||||
|
||||
virtual void removeNestedRows(int row, int column, int subRow);
|
||||
|
||||
virtual QVariant getNestedData(int row, int column, int subRow, int subColumn) const;
|
||||
|
||||
virtual void setNestedData(int row, int column, const QVariant& data, int subRow, int subColumn);
|
||||
|
||||
virtual NestedTableWrapperBase* nestedTable(int row, int column) const;
|
||||
|
||||
virtual void setNestedTable(int row, int column, const NestedTableWrapperBase& nestedTable);
|
||||
|
||||
virtual int getNestedRowsCount(int row, int column) const;
|
||||
|
||||
virtual int getNestedColumnsCount(int row, int column) const;
|
||||
|
||||
// this method is inherited from NestedCollection, not from Collection<Info, IdAccessor<Info> >
|
||||
virtual NestableColumn *getNestableColumn(int column);
|
||||
|
||||
void addAdapter(std::pair<const ColumnBase*, NestedColumnAdapter<Info>* > adapter);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CSM_WOLRD_NESTEDINFOCOLLECTION_H
|
Loading…
Reference in New Issue