added parser and custom filter edit widget (parser not functional yet; always returns a false boolean node)
parent
236dc9fc43
commit
c38860fa72
@ -0,0 +1,33 @@
|
||||
|
||||
#include "parser.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "booleannode.hpp"
|
||||
|
||||
CSMFilter::Parser::Parser() : mState (State_Begin) {}
|
||||
|
||||
void CSMFilter::Parser::parse (const std::string& filter)
|
||||
{
|
||||
// reset
|
||||
mState = State_Begin;
|
||||
mFilter.reset();
|
||||
|
||||
|
||||
// for now we ignore the filter string
|
||||
mFilter.reset (new BooleanNode (false));
|
||||
mState = State_End;
|
||||
}
|
||||
|
||||
CSMFilter::Parser::State CSMFilter::Parser::getState() const
|
||||
{
|
||||
return mState;
|
||||
}
|
||||
|
||||
boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::getFilter() const
|
||||
{
|
||||
if (mState!=State_End)
|
||||
throw std::logic_error ("No filter available");
|
||||
|
||||
return mFilter;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
#ifndef CSM_FILTER_PARSER_H
|
||||
#define CSM_FILTER_PARSER_H
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "node.hpp"
|
||||
|
||||
namespace CSMFilter
|
||||
{
|
||||
class Parser
|
||||
{
|
||||
public:
|
||||
|
||||
enum State
|
||||
{
|
||||
State_Begin,
|
||||
State_End
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
State mState;
|
||||
boost::shared_ptr<Node> mFilter;
|
||||
|
||||
public:
|
||||
|
||||
Parser();
|
||||
|
||||
void parse (const std::string& filter);
|
||||
///< Discards any previous calls to parse
|
||||
|
||||
State getState() const;
|
||||
|
||||
boost::shared_ptr<Node> getFilter() const;
|
||||
///< Throws an exception if getState()!=State_End
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,20 @@
|
||||
|
||||
#include "editwidget.hpp"
|
||||
|
||||
CSVFilter::EditWidget::EditWidget (QWidget *parent)
|
||||
: QLineEdit (parent)
|
||||
{
|
||||
connect (this, SIGNAL (textChanged (const QString&)), this, SLOT (textChanged (const QString&)));
|
||||
}
|
||||
|
||||
void CSVFilter::EditWidget::textChanged (const QString& text)
|
||||
{
|
||||
mParser.parse (text.toUtf8().constData());
|
||||
|
||||
if (mParser.getState()==CSMFilter::Parser::State_End)
|
||||
emit filterChanged();
|
||||
else
|
||||
{
|
||||
/// \todo error handling
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
#ifndef CSV_FILTER_EDITWIDGET_H
|
||||
#define CSV_FILTER_EDITWIDGET_H
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
#include "../../model/filter/parser.hpp"
|
||||
|
||||
namespace CSVFilter
|
||||
{
|
||||
class EditWidget : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
CSMFilter::Parser mParser;
|
||||
|
||||
public:
|
||||
|
||||
EditWidget (QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
void filterChanged();
|
||||
|
||||
private slots:
|
||||
|
||||
void textChanged (const QString& text);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue