diff --git a/kcalcdisplay.h b/kcalcdisplay.h --- a/kcalcdisplay.h +++ b/kcalcdisplay.h @@ -141,6 +141,7 @@ QVector history_list_; int history_index_; + bool history_displays_last_; // only used for input of new numbers bool eestate_; diff --git a/kcalcdisplay.cpp b/kcalcdisplay.cpp --- a/kcalcdisplay.cpp +++ b/kcalcdisplay.cpp @@ -43,7 +43,7 @@ KCalcDisplay::KCalcDisplay(QWidget *parent) : QFrame(parent), beep_(false), groupdigits_(true), twoscomplement_(true), button_(0), lit_(false), num_base_(NB_DECIMAL), precision_(9), fixed_precision_(-1), display_amount_(0), - history_index_(0), selection_timer_(new QTimer(this)) { + history_index_(0), history_displays_last_(false), selection_timer_(new QTimer(this)) { setFocusPolicy(Qt::StrongFocus); @@ -126,6 +126,7 @@ history_list_.insert(history_list_.begin(), output); history_index_ = 0; } + history_displays_last_ = store_result_in_history; } //------------------------------------------------------------------------------ @@ -185,12 +186,15 @@ return; } - if (history_index_ >= history_list_.size()) { + if (history_index_ >= history_list_.size() - 1) { return; } - setAmount(history_list_[history_index_]); - history_index_++; + if(history_displays_last_) { + history_index_++; + } + setAmount(history_list_[history_index_]); + history_displays_last_ = true; } //------------------------------------------------------------------------------ @@ -879,6 +883,7 @@ } } + history_displays_last_ = false; updateDisplay(); }