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_) {} CSMFilter::BooleanNode::BooleanNode (bool true_) : mTrue (true_) {}
bool CSMFilter::BooleanNode::test (const CSMWorld::IdTable& table, int row, 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
const std::map<int, int>& columns,
const std::string& userValue) const
{ {
return mTrue; return mTrue;
} }

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

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

@ -11,18 +11,12 @@ namespace CSMFilter
{ {
public: 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; virtual std::vector<int> getReferencedColumns() const;
///< Return a list of the IDs of the columns referenced by this node. The column mapping ///< 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. /// passed into test as columns must contain all columns listed here.
virtual bool isSimple() const; virtual bool isSimple() const;
///< \return Can this filter be displayed in simple mode. ///< \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); 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> CSMFilter::NAryNode::getReferencedColumns() const
{ {
std::vector<int> columns; std::vector<int> columns;
@ -50,12 +35,3 @@ bool CSMFilter::NAryNode::isSimple() const
return false; 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; 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; virtual std::vector<int> getReferencedColumns() const;
///< Return a list of the IDs of the columns referenced by this node. The column mapping ///< 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. /// passed into test as columns must contain all columns listed here.
@ -32,7 +28,6 @@ namespace CSMFilter
virtual bool isSimple() const; virtual bool isSimple() const;
///< \return Can this filter be displayed in simple mode. ///< \return Can this filter be displayed in simple mode.
virtual bool hasUserValue() const;
}; };
} }

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

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

@ -19,10 +19,6 @@ namespace CSMFilter
Node& getChild(); 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; virtual std::vector<int> getReferencedColumns() const;
///< Return a list of the IDs of the columns referenced by this node. The column mapping ///< 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. /// passed into test as columns must contain all columns listed here.
@ -30,7 +26,6 @@ namespace CSMFilter
virtual bool isSimple() const; virtual bool isSimple() const;
///< \return Can this filter be displayed in simple mode. ///< \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) if (!mFilter)
return true; return true;
std::map<std::string, const CSMFilter::Node *> otherFilters; /// \todo get other filters;
return mFilter->test ( return mFilter->test (
dynamic_cast<IdTable&> (*sourceModel()), sourceRow, otherFilters, mColumnMap, mUserValue); dynamic_cast<IdTable&> (*sourceModel()), sourceRow, mColumnMap);
} }
CSMWorld::IdTableProxyModel::IdTableProxyModel (QObject *parent) 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)); return mapFromSource (dynamic_cast<IdTable&> (*sourceModel()).getModelIndex (id, column));
} }
void CSMWorld::IdTableProxyModel::setFilter (const boost::shared_ptr<CSMFilter::Node>& filter, void CSMWorld::IdTableProxyModel::setFilter (const boost::shared_ptr<CSMFilter::Node>& filter)
const std::string& userValue)
{ {
mFilter = filter; mFilter = filter;
mUserValue = userValue;
updateColumnMap(); updateColumnMap();
invalidateFilter(); invalidateFilter();
} }

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

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

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

Loading…
Cancel
Save