/****************************************************************************
** $Id: quickqtkernel.cpp  beta1   edited Dec 10 13:07 $
**
** Copyright (C) 2001-2002 Trolltech AS.  All rights reserved.
**
** This file is part of the Qt Script for Applications framework (QSA).
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding a valid QSA Beta Evaluation Version license may use
** this file in accordance with the QSA Beta Evaluation Version License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
**   information about QSA Commercial License Agreements.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
*****************************************************************************/

#include "quickqtkernel.h"
#include <qregexp.h>

QuickProcess::QuickProcess( const QString &arg0 )
    : QProcess( arg0 )
{
}

QuickProcess::QuickProcess( const QStringList &args )
    : QProcess( args )
{
}

void QuickProcess::start()
{
    QProcess::start();
}

void QuickProcess::setArguments( const QStringList &args )
{
    QProcess::setArguments( args );
}

void QuickProcess::clearArguments()
{
    QProcess::clearArguments();
}

void QuickProcess::addArgument( const QString &arg )
{
    QProcess::addArgument( arg );
}

QByteArray QuickProcess::readStdout()
{
    return QProcess::readStdout();
}

QByteArray QuickProcess::readStderr()
{
    return QProcess::readStderr();
}

bool QuickProcess::canReadLineStdout() const
{
    return QProcess::canReadLineStdout();
}

bool QuickProcess::canReadLineStderr() const
{
    return QProcess::canReadLineStderr();
}

QString QuickProcess::readLineStdout()
{
    return QProcess::readLineStdout();
}

QString QuickProcess::readLineStderr()
{
    return QProcess::readLineStderr();
}



QuickFontDatabase::QuickFontDatabase()
    : QuickUnnamedObject()
{
}

int QuickFontDatabase::numFamilies() const
{
    return families().count();
}

QString QuickFontDatabase::family( int index ) const
{
    return *families().at( index );
}



QuickFile::QuickFile( const QString &name)
    : file( name )
{
}

bool QuickFile::open( int openMode )
{
    return file.open( (int)openMode );
}

void QuickFile::close()
{
    file.close();
}

QString QuickFile::readAll()
{
    QByteArray ba( file.size() + 1 );
    file.readBlock( ba.data(), file.size() );
    ba[ (int)file.size() ] = '\0';
    return QString( ba.data() );
}

QByteArray QuickFile::readAllRaw()
{
    QByteArray ba( file.size() + 1 );
    file.readBlock( ba.data(), file.size() );
    ba[ (int)file.size() ] = '\0';
    return ba;
}

QString QuickFile::readLine( bool removeEndingWhiteChars )
{
    QString s;
    file.readLine( s, file.size() );
    if ( s.isEmpty() )
	return "";
    if ( removeEndingWhiteChars ) 
	s.replace( QRegExp( "[\\c\\r\\n]*$" ), "" );
    
    return s;
}

void QuickFile::writeBlock( const QString &data )
{
    file.writeBlock( data.latin1(), data.length() );
    file.flush();
}

void QuickFile::writeBlock( const QByteArray &data )
{
    file.writeBlock( data, data.size() );
    file.flush();
}

void QuickFile::reset()
{
    file.reset();
}

void QuickFile::remove()
{
    file.remove();
}

bool QuickFile::exists()
{
    return file.exists();
}

bool QuickFile::atEnd()
{
    return file.atEnd();
}

QString QuickFile::fileName() const
{
    return file.name();
}


QuickDir::QuickDir( const QString &path )
    : dir( path )
{
}

QString QuickDir::path() const
{
    return dir.path();
}

QString QuickDir::nameFilter() const
{
    return dir.nameFilter();
}

int QuickDir::count() const
{
    return dir.count();
}

bool QuickDir::isReadable() const
{
    return dir.isReadable();
}

void QuickDir::setPath( const QString &path )
{
    dir.setPath( path );
}

void QuickDir::cd( const QString &relPath )
{
    dir.cd( relPath );
}

void QuickDir::setNameFilter( const QString &filter )
{
    dir.setNameFilter( filter );
}

QString QuickDir::entry( int num ) const
{
    return dir[ num ];
}

void QuickDir::mkdir( const QString &dirName )
{
    dir.mkdir( dirName );
}

void QuickDir::rmdir( const QString &dirName )
{
    dir.rmdir( dirName );
}

void QuickDir::remove( const QString &fileName )
{
    dir.remove( fileName );
}

void QuickDir::rename( const QString &oldName, const QString &newName )
{
    dir.rename( oldName, newName );
}
