Project

General

Profile

enhanced_inputline_history_fixes167.diff

admin, 06/01/2008 12:29 AM

View differences:

src/uisupport/inputline.cpp
36 36

  
37 37
void InputLine::keyPressEvent(QKeyEvent * event) {
38 38
  if(event->key() == Qt::Key_Up) {
39
    if(!text().isEmpty() && !history.isEmpty()) {
40
      if(!history.contains(text())) {
41
        history << text();
42
        idx = history.count();
43
        if(idx > 1) idx--;
44
      }
45
    }
39 46
    if(idx > 0) { idx--; setText(history[idx]); }
40 47
    event->accept();
41 48
  } else if(event->key() == Qt::Key_Down) {
42 49
    if(idx < history.count()) idx++;
43 50
    if(idx < history.count()) setText(history[idx]);
44
    else setText("");
51
    else {
52
      if(!text().isEmpty()) {
53
        if(history.isEmpty() || history.last() != text()) {
54
          history << text();
55
          idx = history.count();
56
        }
57
        setText("");
58
      }
59
    }
45 60
    event->accept();
46 61
  } else if(event->key() == Qt::Key_Select) {  // for Qtopia
47 62
    emit returnPressed();
......
53 68
}
54 69

  
55 70
void InputLine::on_returnPressed() {
56
  history << text();
57
  idx = history.count();
71
  if(!text().isEmpty()) {
72
    if(history.isEmpty() || history.last() != text()) {
73
      history << text();
74
      idx = history.count();
75
    }
76
  }
58 77
  emit sendText(text());
59 78
  clear();
60 79
}