Source Code (Use browser search to find items of interest.)
Class Index
kdelibs'UndoHistory (./kdelibs/kwrite/undohistory.h:41)
class UndoHistory : public QDialog
{
Q_OBJECT
public:
/**
Constructed just like a regular QDialog
*/
UndoHistory( KWrite*, QWidget *parent = 0, const char *name = 0, bool modal = FALSE, WFlags f = 0 );
virtual ~UndoHistory();
public slots:
/**
This should be called whenever a change occurs in the undo/redo list.
Causes the dialog to update its interface.
*/
void newUndo();
signals:
/**
Emitted when the user hits the Undo button. Specifies the number of
operations to undo.
*/
void undo( int );
/**
Emitted when the user hits the Redo button. Specifies the number of
undone operations to redo.
*/
void redo( int );
protected:
KWrite *m_mainview;
UndoListBox *lbUndo, *lbRedo;
QPushButton *btnUndo, *btnRedo;
protected slots:
void slotUndo();
void slotRedo();
void slotUndoSelChanged( int );
void slotRedoSelChanged( int );
};
// listbox class used to provide contiguous, 0-based selection
// this is used internally
kdelibs'UndoHistory::UndoHistory() (./kdelibs/kwrite/undohistory.cpp:48)
UndoHistory::UndoHistory( KWrite *kWrite, QWidget *parent, const char *name, bool modal, WFlags f )
: QDialog( parent, name, modal, f )
, m_mainview( kWrite )
{
QHBoxLayout *hLayout = new QHBoxLayout(this, 5, 4);
QVBoxLayout *vLayout = new QVBoxLayout(hLayout);
QLabel *lbl = new QLabel(i18n("Undo List"), this);
lbUndo = new UndoListBox(this);
vLayout->addWidget(lbl);
vLayout->addWidget(lbUndo);
vLayout = new QVBoxLayout(hLayout);
lbl = new QLabel(i18n("Redo List"), this);
lbRedo = new UndoListBox(this);
vLayout->addWidget(lbl);
vLayout->addWidget(lbRedo);
lbUndo->setMinimumSize(QSize(150,140));
lbRedo->setMinimumSize(QSize(150,140));
connect(lbUndo, SIGNAL(sigSelected(int)), this, SLOT(slotUndoSelChanged(int)));
connect(lbRedo, SIGNAL(sigSelected(int)), this, SLOT(slotRedoSelChanged(int)));
vLayout = new QVBoxLayout(hLayout);
btnUndo = new QPushButton(this);
btnUndo->setText(i18n("&Undo"));
btnUndo->setEnabled(false);
btnUndo->setFixedSize(btnUndo->sizeHint());
connect(btnUndo, SIGNAL(clicked()), this, SLOT(slotUndo()));
vLayout->addWidget(btnUndo, 0);
btnRedo = new QPushButton(this);
btnRedo->setText(i18n("&Redo"));
btnRedo->setEnabled(false);
btnRedo->setFixedSize(btnRedo->sizeHint());
connect(btnRedo, SIGNAL(clicked()), this, SLOT(slotRedo()));
vLayout->addWidget(btnRedo, 0);
QPushButton *btn = new QPushButton(this);
btn->setText(i18n("&Close"));
btn->setFixedSize(btn->sizeHint());
connect(btn, SIGNAL(clicked()), this, SLOT(close()));
vLayout->addWidget(btn, 0, AlignBottom);
newUndo();
}
kdelibs'UndoHistory::~UndoHistory() (./kdelibs/kwrite/undohistory.cpp:100)
UndoHistory::~UndoHistory()
{}
kdelibs'UndoHistory::newUndo() (./kdelibs/kwrite/undohistory.cpp:103)
void UndoHistory::newUndo()
{
// we don't want a signal storm...
disconnect( lbUndo, SIGNAL( sigSelected( int ) ), this, SLOT( slotUndoSelChanged( int ) ) );
disconnect( lbRedo, SIGNAL( sigSelected( int ) ), this, SLOT( slotRedoSelChanged( int ) ) );
QValueList<int> undoList;
QValueList<int>::Iterator it;
m_mainview->undoTypeList( undoList );
lbUndo->clear();
for( it = undoList.begin(); it != undoList.end() ; ++it )
lbUndo->insertItem( i18n( m_mainview->undoTypeName( *it ) ) );
m_mainview->redoTypeList( undoList );
lbRedo->clear();
for( it = undoList.begin() ; it != undoList.end() ; ++it )
lbRedo->insertItem( i18n( m_mainview->undoTypeName( *it ) ) );
connect( lbUndo, SIGNAL( sigSelected( int ) ), this, SLOT( slotUndoSelChanged( int ) ) );
connect( lbRedo, SIGNAL( sigSelected( int ) ), this, SLOT( slotRedoSelChanged( int ) ) );
slotUndoSelChanged( lbUndo->selCount() );
slotRedoSelChanged( lbRedo->selCount() );
}
kdelibs'UndoHistory::slotUndo() (./kdelibs/kwrite/undohistory.cpp:131)
void UndoHistory::slotUndo()
{
int selCount = lbUndo->selCount();
emit undo(selCount);
lbRedo->setSelCount(selCount);
}
kdelibs'UndoHistory::slotRedo() (./kdelibs/kwrite/undohistory.cpp:137)
void UndoHistory::slotRedo()
{
int selCount = lbRedo->selCount();
emit redo(selCount);
lbUndo->setSelCount(selCount);
}
kdelibs'UndoHistory::slotUndoSelChanged() (./kdelibs/kwrite/undohistory.cpp:144)
void UndoHistory::slotUndoSelChanged(int cnt)
{
btnUndo->setEnabled(cnt > 0);
}
kdelibs'UndoHistory::slotRedoSelChanged() (./kdelibs/kwrite/undohistory.cpp:149)
void UndoHistory::slotRedoSelChanged(int cnt)
{
btnRedo->setEnabled(cnt > 0);
}
/////////////////////////////////////////////////////////////////////
// UndoListBox implementation
//