#include "query.h"
#include "baseadaptor.h"

#include <QStringList>

bool Query::canConvert( const QVariant &other )
{
    if( qVariantCanConvert<Query>( other ) )
        return true;

    return false;
}

Query Query::convert( const QVariant &other )
{
    return qVariantValue<Query>( other );
}

Query::Query( const BaseAdaptor *db,
            QString(BaseAdaptor::*call)(const QVariantList& )const,
            const QVariantList &args ) : Argument( db, call, args)
{
    m_nativeTypeId = qMetaTypeId<Query>();
}

bool Query::isValid() const
{
    if( m_db != 0 && m_call != 0 )
        return true;
    return false;
}

Query Query::operator && ( const QVariant &other ) const
{
    QVariantList args;
    args << *this;
    args << other;
    return Query(m_db,&BaseAdaptor::AND,args);
}

Query Query::operator || ( const QVariant &other ) const
{
    QVariantList args;
    args << *this;
    args << other;
    return Query(m_db,&BaseAdaptor::OR,args);
}

Query Query::operator ! ( ) const
{
    QVariantList args;
    args << *this;
    return Query(m_db,&BaseAdaptor::NOT,args);
}

QStringList Query::tables() const
{

}

QStringList Query::fieldsForTable( const QString &table ) const
{

}

