00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _QEDIT_SESSION_H_
00017 #define _QEDIT_SESSION_H_
00018
00019 #include "qce-config.h"
00020
00026 #include <QObject>
00027 #include <QPointer>
00028 #include <QStringList>
00029
00030 class QEditor;
00031
00032 class QDocument;
00033 class QDocumentCommand;
00034
00035 class QDataStream;
00036
00037 class QCE_EXPORT QEditSession : public QObject
00038 {
00039 Q_OBJECT
00040
00041 public:
00042 QEditSession(QObject *p = 0);
00043 virtual ~QEditSession();
00044
00045 int autoUpdateInterval() const;
00046
00047 QString fileName() const;
00048
00049 public slots:
00050 virtual void addEditor(QEditor *e);
00051 virtual void removeEditor(QEditor *e);
00052
00053 virtual void updateData();
00054
00055 virtual void setAutoUpdateInterval(int ms);
00056
00057 virtual void setFileName(const QString& filename);
00058
00059 virtual void save(QDataStream& s);
00060 virtual void restore(const QDataStream& s);
00061
00062 protected:
00063 virtual void saved(QEditor *e);
00064 virtual void timerEvent(QTimerEvent *e);
00065
00066 virtual QEditor* createEditor();
00067
00068 struct Cursor
00069 {
00070 Cursor()
00071 : beginLine(-1), beginColumn(-1), endLine(-1), endColumn(-1) {}
00072
00073 Cursor(int line, int column)
00074 : beginLine(line), beginColumn(column), endLine(-1), endColumn(-1) {}
00075
00076 Cursor(const Cursor& c)
00077 : beginLine(c.beginLine), beginColumn(c.beginColumn), endLine(c.endLine), endColumn(c.endColumn) {}
00078
00079 Cursor(const QDocumentCursor& c);
00080
00081 int beginLine;
00082 int beginColumn;
00083 int endLine;
00084 int endColumn;
00085 };
00086
00087 struct Command
00088 {
00089 enum Type
00090 {
00091 Nop,
00092 Insert,
00093 Remove
00094 };
00095
00096 int type;
00097 Cursor cursor;
00098 QVariant data;
00099 };
00100
00101 struct Document
00102 {
00103 QString fileName;
00104 QDateTime timeStamp;
00105
00106 QList<Cursor> cursors;
00107 QHash<int, QList<int> > marks;
00108
00109 int commandIndex;
00110 QStack<Command> commands;
00111 };
00112
00113 int m_id;
00114 int m_delay;
00115 QString m_fileName;
00116
00117 QList< QPointer<QEditor*> > m_editors;
00118 QList<Document*> m_sessionData;
00119 };
00120
00121 #endif // ! _QEDIT_SESSION_H_