126 lines
3.0 KiB
C++
126 lines
3.0 KiB
C++
/****************************************************************************
|
|
**
|
|
** Copyright (C) 2006-2009 fullmetalcoder <fullmetalcoder@hotmail.fr>
|
|
**
|
|
** This file is part of the Edyuk project <http://edyuk.org>
|
|
**
|
|
** This file may be used under the terms of the GNU General Public License
|
|
** version 3 as published by the Free Software Foundation and appearing in the
|
|
** file GPL.txt included in the packaging of this file.
|
|
**
|
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
**
|
|
****************************************************************************/
|
|
|
|
#ifndef _QEDIT_SESSION_H_
|
|
#define _QEDIT_SESSION_H_
|
|
|
|
#include "qce-config.h"
|
|
|
|
/*!
|
|
\file qeditsession.h
|
|
\brief Definition of the QEditSession class.
|
|
*/
|
|
|
|
#include <QDateTime>
|
|
#include <QHash>
|
|
#include <QObject>
|
|
#include <QPointer>
|
|
#include <QStringList>
|
|
|
|
class QEditor;
|
|
|
|
class QDocument;
|
|
class QDocumentCursor;
|
|
class QDocumentCommand;
|
|
|
|
class QDataStream;
|
|
|
|
class QCE_EXPORT QEditSession : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
QEditSession(QObject *p = nullptr);
|
|
QEditSession(const QString &f, QObject *p = nullptr);
|
|
virtual ~QEditSession();
|
|
|
|
int autoUpdateInterval() const;
|
|
|
|
QString fileName() const;
|
|
|
|
public slots:
|
|
virtual void addEditor(QEditor *e);
|
|
virtual void removeEditor(QEditor *e);
|
|
|
|
virtual void updateData();
|
|
|
|
virtual void setAutoUpdateInterval(int ms);
|
|
|
|
virtual void setFileName(const QString &filename, bool restore = false);
|
|
|
|
virtual void clear(bool cleanup = false);
|
|
|
|
virtual void save();
|
|
virtual void restore();
|
|
|
|
virtual void save(QDataStream &s);
|
|
virtual void restore(QDataStream &s);
|
|
|
|
signals:
|
|
void restored(QEditor *e);
|
|
|
|
protected slots:
|
|
virtual void destroyed(QObject *o);
|
|
|
|
virtual void saved(QEditor *e, const QString &fn);
|
|
virtual void loaded(QEditor *e, const QString &fn);
|
|
|
|
protected:
|
|
virtual void timerEvent(QTimerEvent *e);
|
|
|
|
virtual QEditor *createEditor();
|
|
|
|
struct Cursor {
|
|
Cursor() : beginLine(-1), beginColumn(-1), endLine(-1), endColumn(-1) {}
|
|
|
|
Cursor(int line, int column)
|
|
: beginLine(line), beginColumn(column), endLine(-1), endColumn(-1) {
|
|
}
|
|
|
|
Cursor(const Cursor &c)
|
|
: beginLine(c.beginLine), beginColumn(c.beginColumn),
|
|
endLine(c.endLine), endColumn(c.endColumn) {}
|
|
|
|
Cursor(const QDocumentCursor &c);
|
|
|
|
QDocumentCursor toDocumentCursor(QDocument *d) const;
|
|
|
|
int beginLine;
|
|
int beginColumn;
|
|
int endLine;
|
|
int endColumn;
|
|
};
|
|
|
|
struct Document {
|
|
QString fileName;
|
|
QDateTime timeStamp;
|
|
|
|
int scrollX, scrollY;
|
|
|
|
QList<Cursor> cursors;
|
|
QHash<int, QList<int>> marks;
|
|
};
|
|
|
|
virtual void update(QEditor *e, Document *d);
|
|
|
|
int m_id;
|
|
int m_delay;
|
|
QString m_fileName;
|
|
|
|
QList<QEditor *> m_editors;
|
|
QList<Document *> m_sessionData;
|
|
};
|
|
|
|
#endif // ! _QEDIT_SESSION_H_
|