Source Code (Use browser search to find items of interest.)

Class Index

kdevelop'UndoHistory (./kdevelop/kdevelop/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        *kWrite;

    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

kdevelop'UndoHistory::UndoHistory() (./kdevelop/kdevelop/kwrite/undohistory.cpp:50)

UndoHistory::UndoHistory(KWrite *kWrite, QWidget *parent, const char *name, bool modal, WFlags f)
  : QDialog(parent, name, modal, f)
{
  this->kWrite = kWrite;

  QPushButton     *btn;
  QLabel          *lbl;
  QHBoxLayout     *hLayout;
  QVBoxLayout     *vLayout;

  hLayout = new QHBoxLayout(this, 5, 4);

  vLayout = new QVBoxLayout(hLayout);
  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);

  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();
}


kdevelop'UndoHistory::~UndoHistory() (./kdevelop/kdevelop/kwrite/undohistory.cpp:108)

UndoHistory::~UndoHistory()
{}


kdevelop'UndoHistory::newUndo() (./kdevelop/kdevelop/kwrite/undohistory.cpp:111)

void UndoHistory::newUndo()
{
  typedef std::list<int>       lst;

  lst             undoList;
  lst::iterator   it;

  // 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)));

  kWrite->undoTypeList(undoList);

  lbUndo->clear();
  for (it = undoList.begin() ; it != undoList.end() ; it++) {
    lbUndo->insertItem(i18n(kWrite->undoTypeName(*it)));
  }

  kWrite->redoTypeList(undoList);

  lbRedo->clear();
  for (it = undoList.begin() ; it != undoList.end() ; it++) {
    lbRedo->insertItem(i18n(kWrite->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());
}


kdevelop'UndoHistory::slotUndo() (./kdevelop/kdevelop/kwrite/undohistory.cpp:143)

void UndoHistory::slotUndo()
{
  int selCount = lbUndo->selCount();
  emit undo(selCount);
  lbRedo->setSelCount(selCount);
}

kdevelop'UndoHistory::slotRedo() (./kdevelop/kdevelop/kwrite/undohistory.cpp:149)

void UndoHistory::slotRedo()
{
  int selCount = lbRedo->selCount();
  emit redo(selCount);
  lbUndo->setSelCount(selCount);
}


kdevelop'UndoHistory::slotUndoSelChanged() (./kdevelop/kdevelop/kwrite/undohistory.cpp:156)

void UndoHistory::slotUndoSelChanged(int cnt)
{
  btnUndo->setEnabled(cnt > 0);
}


kdevelop'UndoHistory::slotRedoSelChanged() (./kdevelop/kdevelop/kwrite/undohistory.cpp:161)

void UndoHistory::slotRedoSelChanged(int cnt)
{
  btnRedo->setEnabled(cnt > 0);
}

/////////////////////////////////////////////////////////////////////
// UndoListBox implementation
//