simplified filter system by taking out filter references and user values for now (these are post-1.0 features anyway)

actorid
Marc Zinnschlag 12 years ago
parent a61215dab1
commit 50041fc211

@ -4,9 +4,7 @@
CSMFilter::BooleanNode::BooleanNode (bool true_) : mTrue (true_) {}
bool CSMFilter::BooleanNode::test (const CSMWorld::IdTable& table, int row,
const std::map<std::string, const Node *>& otherFilters,
const std::map<int, int>& columns,
const std::string& userValue) const
const std::map<int, int>& columns) const
{
return mTrue;
}

@ -14,9 +14,7 @@ namespace CSMFilter
BooleanNode (bool true_);
virtual bool test (const CSMWorld::IdTable& table, int row,
const std::map<std::string, const Node *>& otherFilters,
const std::map<int, int>& columns,
const std::string& userValue) const;
const std::map<int, int>& columns) const;
///< \return Can the specified table row pass through to filter?
/// \param columns column ID to column index mapping

@ -1,11 +1,6 @@
#include "leafnode.hpp"
std::vector<std::string> CSMFilter::LeafNode::getReferencedFilters() const
{
return std::vector<std::string>();
}
std::vector<int> CSMFilter::LeafNode::getReferencedColumns() const
{
return std::vector<int>();
@ -15,8 +10,3 @@ bool CSMFilter::LeafNode::isSimple() const
{
return true;
}
bool CSMFilter::LeafNode::hasUserValue() const
{
return false;
}

@ -11,18 +11,12 @@ namespace CSMFilter
{
public:
virtual std::vector<std::string> getReferencedFilters() const;
///< Return a list of filters that are used by this node (and must be passed as
/// otherFilters when calling test).
virtual std::vector<int> getReferencedColumns() const;
///< Return a list of the IDs of the columns referenced by this node. The column mapping
/// passed into test as columns must contain all columns listed here.
virtual bool isSimple() const;
///< \return Can this filter be displayed in simple mode.
virtual bool hasUserValue() const;
};
}

@ -15,21 +15,6 @@ const CSMFilter::Node& CSMFilter::NAryNode::operator[] (int index) const
return *mNodes.at (index);
}
std::vector<std::string> CSMFilter::NAryNode::getReferencedFilters() const
{
std::vector<std::string> filters;
for (std::vector<boost::shared_ptr<Node> >::const_iterator iter (mNodes.begin());
iter!=mNodes.end(); ++iter)
{
std::vector<std::string> filters2 = (*iter)->getReferencedFilters();
filters.insert (filters.end(), filters2.begin(), filters2.end());
}
return filters;
}
std::vector<int> CSMFilter::NAryNode::getReferencedColumns() const
{
std::vector<int> columns;
@ -50,12 +35,3 @@ bool CSMFilter::NAryNode::isSimple() const
return false;
}
bool CSMFilter::NAryNode::hasUserValue() const
{
for (std::vector<boost::shared_ptr<Node> >::const_iterator iter (mNodes.begin());
iter!=mNodes.end(); ++iter)
if ((*iter)->hasUserValue())
return true;
return false;
}

@ -21,10 +21,6 @@ namespace CSMFilter
const Node& operator[] (int index) const;
virtual std::vector<std::string> getReferencedFilters() const;
///< Return a list of filters that are used by this node (and must be passed as
/// otherFilters when calling test).
virtual std::vector<int> getReferencedColumns() const;
///< Return a list of the IDs of the columns referenced by this node. The column mapping
/// passed into test as columns must contain all columns listed here.
@ -32,7 +28,6 @@ namespace CSMFilter
virtual bool isSimple() const;
///< \return Can this filter be displayed in simple mode.
virtual bool hasUserValue() const;
};
}

@ -33,16 +33,10 @@ namespace CSMFilter
virtual ~Node();
virtual bool test (const CSMWorld::IdTable& table, int row,
const std::map<std::string, const Node *>& otherFilters,
const std::map<int, int>& columns,
const std::string& userValue) const = 0;
const std::map<int, int>& columns) const = 0;
///< \return Can the specified table row pass through to filter?
/// \param columns column ID to column index mapping
virtual std::vector<std::string> getReferencedFilters() const = 0;
///< Return a list of filters that are used by this node (and must be passed as
/// otherFilters when calling test).
virtual std::vector<int> getReferencedColumns() const = 0;
///< Return a list of the IDs of the columns referenced by this node. The column mapping
/// passed into test as columns must contain all columns listed here.
@ -50,8 +44,6 @@ namespace CSMFilter
virtual bool isSimple() const = 0;
///< \return Can this filter be displayed in simple mode.
virtual bool hasUserValue() const = 0;
virtual std::string toString (bool numericColumns) const = 0;
///< Return a string that represents this node.
///

@ -13,11 +13,6 @@ CSMFilter::Node& CSMFilter::UnaryNode::getChild()
return *mChild;
}
std::vector<std::string> CSMFilter::UnaryNode::getReferencedFilters() const
{
return mChild->getReferencedFilters();
}
std::vector<int> CSMFilter::UnaryNode::getReferencedColumns() const
{
return mChild->getReferencedColumns();
@ -28,7 +23,3 @@ bool CSMFilter::UnaryNode::isSimple() const
return false;
}
bool CSMFilter::UnaryNode::hasUserValue() const
{
return mChild->hasUserValue();
}

@ -19,10 +19,6 @@ namespace CSMFilter
Node& getChild();
virtual std::vector<std::string> getReferencedFilters() const;
///< Return a list of filters that are used by this node (and must be passed as
/// otherFilters when calling test).
virtual std::vector<int> getReferencedColumns() const;
///< Return a list of the IDs of the columns referenced by this node. The column mapping
/// passed into test as columns must contain all columns listed here.
@ -30,7 +26,6 @@ namespace CSMFilter
virtual bool isSimple() const;
///< \return Can this filter be displayed in simple mode.
virtual bool hasUserValue() const;
};
}

@ -27,10 +27,8 @@ bool CSMWorld::IdTableProxyModel::filterAcceptsRow (int sourceRow, const QModelI
if (!mFilter)
return true;
std::map<std::string, const CSMFilter::Node *> otherFilters; /// \todo get other filters;
return mFilter->test (
dynamic_cast<IdTable&> (*sourceModel()), sourceRow, otherFilters, mColumnMap, mUserValue);
dynamic_cast<IdTable&> (*sourceModel()), sourceRow, mColumnMap);
}
CSMWorld::IdTableProxyModel::IdTableProxyModel (QObject *parent)
@ -42,11 +40,9 @@ QModelIndex CSMWorld::IdTableProxyModel::getModelIndex (const std::string& id, i
return mapFromSource (dynamic_cast<IdTable&> (*sourceModel()).getModelIndex (id, column));
}
void CSMWorld::IdTableProxyModel::setFilter (const boost::shared_ptr<CSMFilter::Node>& filter,
const std::string& userValue)
void CSMWorld::IdTableProxyModel::setFilter (const boost::shared_ptr<CSMFilter::Node>& filter)
{
mFilter = filter;
mUserValue = userValue;
updateColumnMap();
invalidateFilter();
}

@ -18,7 +18,6 @@ namespace CSMWorld
Q_OBJECT
boost::shared_ptr<CSMFilter::Node> mFilter;
std::string mUserValue;
std::map<int, int> mColumnMap; // column ID, column index in this model (or -1)
private:
@ -33,8 +32,7 @@ namespace CSMWorld
virtual QModelIndex getModelIndex (const std::string& id, int column) const;
void setFilter (const boost::shared_ptr<CSMFilter::Node>& filter,
const std::string& userValue);
void setFilter (const boost::shared_ptr<CSMFilter::Node>& filter);
};
}

@ -294,8 +294,7 @@ void CSVWorld::Table::requestFocus (const std::string& id)
scrollTo (index, QAbstractItemView::PositionAtTop);
}
void CSVWorld::Table::recordFilterChanged (boost::shared_ptr<CSMFilter::Node> filter,
const std::string& userValue)
void CSVWorld::Table::recordFilterChanged (boost::shared_ptr<CSMFilter::Node> filter)
{
mProxyModel->setFilter (filter, userValue);
mProxyModel->setFilter (filter);
}

@ -87,8 +87,7 @@ namespace CSVWorld
void requestFocus (const std::string& id);
void recordFilterChanged (boost::shared_ptr<CSMFilter::Node> filter,
const std::string& userValue);
void recordFilterChanged (boost::shared_ptr<CSMFilter::Node> filter);
};
}

Loading…
Cancel
Save