Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::EventLog Class Reference

A simple log for maintaining a history of committed, undone and redone events along with their type. More...

#include <event-log.h>

Inheritance diagram for Inkscape::EventLog:
Inkscape::UndoStackObserver

Classes

struct  EventModelColumns
 Event datatype. More...
 

Public Types

enum  CallbackTypes { CALLB_SELECTION_CHANGE , CALLB_EXPAND , CALLB_COLLAPSE , CALLB_LAST }
 
typedef Gtk::TreeModel::iterator iterator
 
typedef Gtk::TreeModel::const_iterator const_iterator
 
typedef std::map< const CallbackTypes, sigc::connection > CallbackMap
 

Public Member Functions

 EventLog (SPDocument *document)
 
 ~EventLog () override
 
void notifyUndoEvent (Event *log) override
 Modifies the log's entries and the view's selection when triggered.
 
void notifyRedoEvent (Event *log) override
 Triggered when the user issues a redo command.
 
void notifyUndoCommitEvent (Event *log) override
 Triggered when a set of transactions is committed to the undo log.
 
void notifyUndoExpired (Event *log) override
 Triggered when undo items are removed from the back of the log (expired)
 
void notifyClearUndoEvent () override
 Triggered when the undo log is cleared.
 
void notifyClearRedoEvent () override
 Triggered when the redo log is cleared.
 
Glib::RefPtr< Gtk::TreeModel > getEventListStore () const
 
iterator getCurrEvent () const
 
iterator getCurrEventParent () const
 
void setCurrEvent (iterator event)
 
void setCurrEventParent (iterator event)
 
void blockNotifications (bool status=true)
 
void rememberFileSave ()
 
void addDialogConnection (Gtk::TreeView *event_list_view, CallbackMap *callback_connections)
 Connect with a TreeView.
 
void removeDialogConnection (Gtk::TreeView *event_list_view, CallbackMap *callback_connections)
 Disconnect from a TreeView.
 
void updateUndoVerbs ()
 
- Public Member Functions inherited from Inkscape::UndoStackObserver
 UndoStackObserver ()=default
 
virtual ~UndoStackObserver ()=default
 

Static Public Member Functions

static const EventModelColumnsgetColumns ()
 

Private Member Functions

const_iterator _getUndoEvent () const
 
const_iterator _getRedoEvent () const
 
void _clearUndo ()
 
void _clearRedo ()
 
void checkForVirginity ()
 
 EventLog (EventLog const &other)=delete
 
EventLogoperator= (EventLog const &other)=delete
 

Private Attributes

EventLogPrivate * _priv
 
SPDocument_document
 
Glib::RefPtr< Gtk::TreeStore > _event_list_store
 
iterator _first_event
 
iterator _curr_event
 
iterator _last_event
 
iterator _curr_event_parent
 
iterator _last_saved
 
bool _notifications_blocked
 

Detailed Description

A simple log for maintaining a history of committed, undone and redone events along with their type.

It implements the UndoStackObserver and should be registered with a CompositeUndoStackObserver for each document. The event log is then notified on all commit, undo and redo events and will store a representation of them in an internal Gtk::TreeStore.

Consecutive events of the same type are grouped with the first event as a parent and following as its children.

If a Gtk::TreeView is connected to the event log, the TreeView's selection and its nodes expanded/collapsed state will be updated as events are committed, undone and redone. Whenever this happens, the event log will block the TreeView's callbacks to prevent circular updates.

Definition at line 43 of file event-log.h.

Member Typedef Documentation

◆ CallbackMap

typedef std::map<const CallbackTypes, sigc::connection> Inkscape::EventLog::CallbackMap

Definition at line 102 of file event-log.h.

◆ const_iterator

typedef Gtk::TreeModel::const_iterator Inkscape::EventLog::const_iterator

Definition at line 48 of file event-log.h.

◆ iterator

typedef Gtk::TreeModel::iterator Inkscape::EventLog::iterator

Definition at line 47 of file event-log.h.

Member Enumeration Documentation

◆ CallbackTypes

Enumerator
CALLB_SELECTION_CHANGE 
CALLB_EXPAND 
CALLB_COLLAPSE 
CALLB_LAST 

Definition at line 95 of file event-log.h.

Constructor & Destructor Documentation

◆ EventLog() [1/2]

Inkscape::EventLog::EventLog ( SPDocument document)

◆ ~EventLog()

Inkscape::EventLog::~EventLog ( )
override

Definition at line 194 of file event-log.cpp.

References _event_list_store, and _priv.

◆ EventLog() [2/2]

Inkscape::EventLog::EventLog ( EventLog const &  other)
privatedelete

Member Function Documentation

◆ _clearRedo()

void Inkscape::EventLog::_clearRedo ( )
private

Definition at line 469 of file event-log.cpp.

References _curr_event, _event_list_store, _last_event, and getColumns().

Referenced by notifyClearRedoEvent(), and notifyUndoCommitEvent().

◆ _clearUndo()

void Inkscape::EventLog::_clearUndo ( )
private

Definition at line 463 of file event-log.cpp.

Referenced by notifyClearUndoEvent().

◆ _getRedoEvent()

EventLog::const_iterator Inkscape::EventLog::_getRedoEvent ( ) const
private

Definition at line 436 of file event-log.cpp.

References _curr_event, and _last_event.

Referenced by notifyRedoEvent(), and updateUndoVerbs().

◆ _getUndoEvent()

EventLog::const_iterator Inkscape::EventLog::_getUndoEvent ( ) const
private

Definition at line 427 of file event-log.cpp.

References _curr_event, and _event_list_store.

Referenced by notifyUndoEvent(), and updateUndoVerbs().

◆ addDialogConnection()

void Inkscape::EventLog::addDialogConnection ( Gtk::TreeView *  event_list_view,
CallbackMap callback_connections 
)

Connect with a TreeView.

Definition at line 406 of file event-log.cpp.

References _curr_event, _event_list_store, and _priv.

Referenced by Inkscape::UI::Dialog::UndoHistory::connectEventLog().

◆ blockNotifications()

void Inkscape::EventLog::blockNotifications ( bool  status = true)
inline

◆ checkForVirginity()

void Inkscape::EventLog::checkForVirginity ( )
private

◆ getColumns()

◆ getCurrEvent()

◆ getCurrEventParent()

iterator Inkscape::EventLog::getCurrEventParent ( ) const
inline

Definition at line 86 of file event-log.h.

References _curr_event_parent.

◆ getEventListStore()

Glib::RefPtr< Gtk::TreeModel > Inkscape::EventLog::getEventListStore ( ) const
inline

Definition at line 83 of file event-log.h.

References _event_list_store.

Referenced by Inkscape::UI::Dialog::UndoHistory::connectEventLog().

◆ notifyClearRedoEvent()

void Inkscape::EventLog::notifyClearRedoEvent ( )
overridevirtual

Triggered when the redo log is cleared.

Implements Inkscape::UndoStackObserver.

Definition at line 400 of file event-log.cpp.

References _clearRedo(), and updateUndoVerbs().

◆ notifyClearUndoEvent()

void Inkscape::EventLog::notifyClearUndoEvent ( )
overridevirtual

Triggered when the undo log is cleared.

Implements Inkscape::UndoStackObserver.

Definition at line 393 of file event-log.cpp.

References _clearUndo(), and updateUndoVerbs().

◆ notifyRedoEvent()

void Inkscape::EventLog::notifyRedoEvent ( Event log)
overridevirtual

Triggered when the user issues a redo command.

Parameters
logPointer to an Event describing the redone event.

Implements Inkscape::UndoStackObserver.

Definition at line 250 of file event-log.cpp.

References _curr_event, _curr_event_parent, _event_list_store, _getRedoEvent(), _notifications_blocked, _priv, checkForVirginity(), getColumns(), log(), and updateUndoVerbs().

◆ notifyUndoCommitEvent()

void Inkscape::EventLog::notifyUndoCommitEvent ( Event log)
overridevirtual

Triggered when a set of transactions is committed to the undo log.

Parameters
logPointer to an Event describing the committed events.

Implements Inkscape::UndoStackObserver.

Definition at line 299 of file event-log.cpp.

References _clearRedo(), _curr_event, _curr_event_parent, _event_list_store, _last_event, _priv, checkForVirginity(), getColumns(), log(), and updateUndoVerbs().

◆ notifyUndoEvent()

void Inkscape::EventLog::notifyUndoEvent ( Event log)
overridevirtual

Modifies the log's entries and the view's selection when triggered.

Implements Inkscape::UndoStackObserver.

Definition at line 203 of file event-log.cpp.

References _curr_event, _curr_event_parent, _event_list_store, _getUndoEvent(), _notifications_blocked, _priv, checkForVirginity(), getColumns(), log(), and updateUndoVerbs().

◆ notifyUndoExpired()

void Inkscape::EventLog::notifyUndoExpired ( Event log)
overridevirtual

Triggered when undo items are removed from the back of the log (expired)

Implements Inkscape::UndoStackObserver.

Definition at line 347 of file event-log.cpp.

References _event_list_store, _first_event, getColumns(), log(), and parent.

◆ operator=()

EventLog & Inkscape::EventLog::operator= ( EventLog const &  other)
privatedelete

◆ rememberFileSave()

void Inkscape::EventLog::rememberFileSave ( )
inline

Definition at line 91 of file event-log.h.

References _curr_event, and _last_saved.

Referenced by file_save().

◆ removeDialogConnection()

void Inkscape::EventLog::removeDialogConnection ( Gtk::TreeView *  event_list_view,
CallbackMap callback_connections 
)

Disconnect from a TreeView.

Definition at line 411 of file event-log.cpp.

References _priv.

Referenced by Inkscape::UI::Dialog::UndoHistory::disconnectEventLog().

◆ setCurrEvent()

void Inkscape::EventLog::setCurrEvent ( iterator  event)
inline

◆ setCurrEventParent()

void Inkscape::EventLog::setCurrEventParent ( iterator  event)
inline

◆ updateUndoVerbs()

Member Data Documentation

◆ _curr_event

◆ _curr_event_parent

iterator Inkscape::EventLog::_curr_event_parent
private

◆ _document

SPDocument* Inkscape::EventLog::_document
private

Definition at line 122 of file event-log.h.

Referenced by checkForVirginity(), and updateUndoVerbs().

◆ _event_list_store

Glib::RefPtr<Gtk::TreeStore> Inkscape::EventLog::_event_list_store
private

◆ _first_event

iterator Inkscape::EventLog::_first_event
private

Definition at line 126 of file event-log.h.

Referenced by EventLog(), and notifyUndoExpired().

◆ _last_event

iterator Inkscape::EventLog::_last_event
private

Definition at line 128 of file event-log.h.

Referenced by _clearRedo(), _getRedoEvent(), EventLog(), and notifyUndoCommitEvent().

◆ _last_saved

iterator Inkscape::EventLog::_last_saved
private

Definition at line 131 of file event-log.h.

Referenced by checkForVirginity(), EventLog(), and rememberFileSave().

◆ _notifications_blocked

bool Inkscape::EventLog::_notifications_blocked
private

Definition at line 133 of file event-log.h.

Referenced by blockNotifications(), notifyRedoEvent(), and notifyUndoEvent().

◆ _priv

EventLogPrivate* Inkscape::EventLog::_priv
private

The documentation for this class was generated from the following files: