|Home | Tutorial | Classes | Functions | QSA Developer | Language | Library | Qt API | QSA Articles Qt Script for Applications

qseditor.h

This is the verbatim text of the qseditor.h include file. It is provided only for illustration; the copyright remains with Trolltech.


/****************************************************************************
** $Id$
**
** Definition of the QSEditor class.
**
** 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.
**
*****************************************************************************/

#ifndef QSEDITOR_H
#define QSEDITOR_H

#include <qwidget.h>
#include <qptrlist.h>
#include <qsaglobal.h>

#include "qsproject.h"


struct EditorInterface;
class QObjectList;
class QTextEdit;
class QSProject;
class QSEditorPrivate;

class QSA_EXPORT QSEditor : public QWidget
{
    Q_OBJECT

public:
    QSEditor( QSProject *project, QWidget *parent = 0, const char *name = 0 );
    QSEditor( QWidget *parent, const char *name = 0 );
    ~QSEditor();

    void setProject( QSProject *project );

    void setText( const QString &text, QObject *context = 0 );
    void setSource( const QString &fileInProject );
    void setSource( QObject *appObject );

    QString text() const;

    void save();

    bool activate();
    void release();

    bool isActive() const { return active; }

    bool isUndoAvailable() const;
    bool isRedoAvailable() const;
    void undo();
    void redo();
    void cut();
    void copy();
    void paste();
    void selectAll();
    bool find( const QString &expr, bool cs, bool wo, bool forward, bool startAtCursor );
    bool replace( const QString &find, const QString &replace, bool cs, bool wo,
		  bool forward, bool startAtCursor, bool replaceAll );
    void gotoLine( int line );
    void indent();
    void readSettings();

    void highlightLine( int line );

    QSize sizeHint() const;
    QSize minimumSizeHint() const;

    QTextEdit *textEdit() const;

//     static QSEditor *activeEditor();
//     static const QPtrList<QSEditor> *editors();

    QSProject *project() const;

signals:
    void textChanged();

protected:
    void resizeEvent( QResizeEvent *e );

private:
    void init();
    bool setContext( QObject *o );

private:
    QSEditorPrivate *d;
    QSProject *proj;
    QWidget *editor;
    QTextEdit *tEdit;
    EditorInterface *eIface;
    bool active;
    QObject *contextObject;
    union {
	QString *sourceFile;
	QObject *aObject;
    };
    enum { NoSource, PlainSource, SourceFile, AppObject } sourceType;

};

inline QSProject *QSEditor::project() const
{
    return proj;
}

#endif


Copyright © 2001-2003 TrolltechTrademarks
QSA version 1.0.0-beta2