• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kig

  • sources
  • kde-4.12
  • kdeedu
  • kig
  • modes
historydialog.cc
Go to the documentation of this file.
1 /*
2  This file is part of Kig, a KDE program for Interactive Geometry...
3  Copyright (C) 2006 Pino Toscano <toscano.pino@tiscali.it>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #include "historydialog.h"
22 #include "historydialog.moc"
23 
24 #include "ui_historywidget.h"
25 
26 #include <qlabel.h>
27 #include <qtextedit.h>
28 #include <qtimer.h>
29 #include <qundostack.h>
30 
31 #include <kdebug.h>
32 #include <kicon.h>
33 #include <klineedit.h>
34 #include <klocale.h>
35 #include <knumvalidator.h>
36 #include <kpushbutton.h>
37 
38 HistoryDialog::HistoryDialog( QUndoStack* kch, QWidget* parent )
39  : KDialog( parent ), mch( kch )
40 {
41  setCaption( i18n( "History Browser" ) );
42  setButtons( Close );
43 
44  QWidget* main = new QWidget( this );
45  mwidget = new Ui_HistoryWidget();
46  mwidget->setupUi( main );
47  setMainWidget( main );
48 
49  mtotalsteps = mch->count() + 1;
50 
51  bool reversed = layoutDirection() == Qt::RightToLeft;
52 
53  mwidget->buttonFirst->setIcon( KIcon( reversed ? "go-last" : "go-first" ) );
54  connect( mwidget->buttonFirst, SIGNAL( clicked() ), this, SLOT( goToFirst() ) );
55 
56  mwidget->buttonBack->setIcon( KIcon( reversed ? "go-next" : "go-previous" ) );
57  connect( mwidget->buttonBack, SIGNAL( clicked() ), this, SLOT( goBack() ) );
58 
59  mwidget->editStep->setValidator( new KIntValidator( 1, mtotalsteps, mwidget->editStep ) );
60  mwidget->labelSteps->setText( QString::number( mtotalsteps ) );
61 
62  mwidget->buttonNext->setIcon( KIcon( reversed ? "go-previous" : "go-next" ) );
63  connect( mwidget->buttonNext, SIGNAL( clicked() ), this, SLOT( goToNext() ) );
64 
65  mwidget->buttonLast->setIcon( KIcon( reversed ? "go-first" : "go-last" ) );
66  connect( mwidget->buttonLast, SIGNAL( clicked() ), this, SLOT( goToLast() ) );
67 
68  updateWidgets();
69 
70  resize( 400, 200 );
71 }
72 
73 HistoryDialog::~HistoryDialog()
74 {
75  delete mwidget;
76 }
77 
78 void HistoryDialog::goToFirst()
79 {
80  int undosteps = mch->index();
81  for ( int i = 0; i < undosteps; ++i )
82  {
83  mch->undo();
84  }
85 
86  updateWidgets();
87 }
88 
89 void HistoryDialog::goBack()
90 {
91  mch->undo();
92 
93  updateWidgets();
94 }
95 
96 void HistoryDialog::goToNext()
97 {
98  mch->redo();
99 
100  updateWidgets();
101 }
102 
103 void HistoryDialog::goToLast()
104 {
105  int redosteps = mch->count() - mch->index();
106  for ( int i = 0; i < redosteps; ++i )
107  {
108  mch->redo();
109  }
110 
111  updateWidgets();
112 }
113 
114 void HistoryDialog::updateWidgets()
115 {
116  int currentstep = mch->index() + 1;
117 
118  mwidget->editStep->setText( QString::number( currentstep ) );
119  if ( mch->index() > 0 )
120  {
121  mwidget->description->setPlainText( mch->text( mch->index() - 1 ) );
122  }
123  else
124  {
125  mwidget->description->setPlainText( i18n( "Start of the construction" ) );
126  }
127 
128  bool notfirst = currentstep > 1;
129  bool notlast = currentstep < mtotalsteps;
130  mwidget->buttonFirst->setEnabled( notfirst );
131  mwidget->buttonBack->setEnabled( notfirst );
132  mwidget->buttonNext->setEnabled( notlast );
133  mwidget->buttonLast->setEnabled( notlast );
134 }
historydialog.h
main
int main(int argc, char **argv)
Definition: main.cpp:97
QWidget
KDialog
HistoryDialog::HistoryDialog
HistoryDialog(QUndoStack *kch, QWidget *parent)
Definition: historydialog.cc:38
HistoryDialog::~HistoryDialog
virtual ~HistoryDialog()
Definition: historydialog.cc:73
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

Skip menu "kig"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal