1
/* This file is part of the KDE project
2
Copyright (C) 2002 Norbert Andres, nandres@web.de
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
20
#ifndef __kspread_changes__
21
#define __kspread_changes__
24
#include <qdatetime.h>
33
class KSpreadAcceptDlg;
35
class KSpreadFilterDlg;
47
bool loadXml( QDomElement const & settings );
48
void saveXml( QDomDocument & doc, QDomElement & parent ) const;
50
void setShowChanges( bool b );
51
void setShowAccepted( bool b );
52
void setShowRejected( bool b );
54
bool dateSet() const { return m_dateSet; }
55
bool authorSet() const { return m_authorSet; }
56
bool commentSet() const { return m_commentSet; }
57
bool rangeSet() const { return m_rangeSet; }
59
bool showChanges() const { return m_showChanges; }
60
bool showRejected() const { return m_showRejected; }
61
bool showAccepted() const { return m_showAccepted; }
63
int dateUsage() const { return m_dateUsage; }
65
QString author() const { return m_author; }
66
QString comment() const { return m_comment; }
67
QString range() const { return m_range; }
69
QDateTime firstTime() const { return m_firstTime; }
70
QDateTime secondTime() const { return m_secondTime; }
73
friend class FilterMain;
77
QDateTime m_firstTime;
78
QDateTime m_secondTime;
94
class KSpreadChanges : public QObject
97
KSpreadChanges( KSpreadMap * map );
100
void setProtected( QCString const & hash );
101
bool isProtected() const { return !m_strPassword.isNull(); }
102
void password( QCString & passwd ) const { passwd = m_strPassword; }
103
bool checkPassword( QCString const & passwd ) const { return ( passwd == m_strPassword ); }
105
void addChange( KSpreadSheet * table, KSpreadCell * cell, QPoint const & point,
106
QString const & oldFormat, QString const & oldValue, bool hasDepandancy = true );
107
void fillDependancyList();
109
void saveXml( QDomDocument & doc, QDomElement & map );
110
bool loadXml( QDomElement const & changes );
114
class RecordMap : public QMap<int, ChangeRecord *> {};
119
AuthorInfo( int id, QString const & name )
120
: m_id( id ), m_name( name ) {}
122
int id() const { return m_id; };
123
QString name() const { return m_name; }
133
Change() : timestamp( QDateTime::currentDateTime() ), comment( 0 ) {}
134
Change( int _authorID, QDateTime const & _timestamp, QString const & _comment )
135
: authorID( _authorID ), timestamp( _timestamp ), comment( new QString( _comment ) ) {}
139
virtual bool loadXml( QDomElement const & change, KSpreadSheet const * const table,
140
QPoint const & cellRef ) = 0;
141
virtual void saveXml( QDomDocument & doc, QDomElement & change ) const = 0;
150
class CellChange : public Change
153
CellChange() : Change(), cell( 0 ) {}
157
bool loadXml( QDomElement const & change, KSpreadSheet const * const table,
158
QPoint const & cellRef );
160
void saveXml( QDomDocument & doc, QDomElement & change ) const;
162
QString formatString;
170
typedef enum E1 { ACCEPTED, FILTERED, PENDING, REJECTED } State;
171
typedef enum E2 { CELL, INSERTCOLUMN, INSERTROW, INSERTTABLE,
172
DELETECOLUMN, DELETEROW, DELETETABLE, MOVE } ChangeType;
176
ChangeRecord( int id, State state, ChangeType type, KSpreadSheet * table,
177
QPoint const & cellRef, Change * change );
180
bool loadXml( QDomElement & changes, KSpreadMap * map, RecordMap & records );
181
void saveXml( QDomDocument & doc, QDomElement & parent ) const;
183
bool isDependant( KSpreadSheet const * const table, QPoint const & cell ) const;
184
void addDependant( ChangeRecord * record, QPoint const & cellRef );
186
void setState( State state ) { m_state = state; }
187
State state() const { return m_state; }
189
int id() const { return m_id; }
190
KSpreadSheet const * const table() const { return m_table; }
192
int dependancies() const { return m_dependancies; }
193
void increaseDependancyCounter() { ++m_dependancies; }
196
friend class KSpreadAcceptDlg;
197
friend class KSpreadCommentDlg;
198
friend class KSpreadFilterDlg;
203
KSpreadSheet * m_table;
204
QPoint m_cell; // Rows: (0, row), Columns: (col, 0), Cells (>0, >0)
208
QPtrList<ChangeRecord> m_dependants;
211
friend class KSpreadAcceptDlg;
212
friend class KSpreadCommentDlg;
213
friend class KSpreadFilterDlg;
215
QPtrList<ChangeRecord> m_dependancyList;
216
QPtrList<AuthorInfo> m_authors;
217
RecordMap m_changeRecords;
220
QCString m_strPassword;
222
FilterSettings m_filterSettings;
226
bool loadAuthors( QDomElement const & authors );
227
bool loadChanges( QDomElement const & changes );
228
void saveAuthors( QDomDocument & doc, QDomElement & changes );
229
void saveChanges( QDomDocument & doc, QDomElement & changes );
230
QString getAuthor( int id );