GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
QGo4CommandsHistory.cpp
Go to the documentation of this file.
1// $Id$
2//-----------------------------------------------------------------------
3// The GSI Online Offline Object Oriented (Go4) Project
4// Experiment Data Processing at EE department, GSI
5//-----------------------------------------------------------------------
6// Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7// Planckstr. 1, 64291 Darmstadt, Germany
8// Contact: http://go4.gsi.de
9//-----------------------------------------------------------------------
10// This software can be used under the license agreements as stated
11// in Go4License.txt file which is part of the distribution.
12//-----------------------------------------------------------------------
13
14#include "QGo4CommandsHistory.h"
15
16#include <QKeyEvent>
17
18#define GO4_COMHIS_MAX 50
19
20
21QGo4CommandsHistory::QGo4CommandsHistory(QWidget *parent, const char *name) :
22 QComboBox(parent)
23{
24 setObjectName(name ? name : "Go4CommandsHistory");
25 setMaxCount(GO4_COMHIS_MAX);
26 setInsertPolicy(InsertAtTop);
27 setDuplicatesEnabled(false);
28 setEditable(true);
29 // setAutoCompletion(true); // not needed, by default is auto-completion is enabled, this is deprecated method
30}
31
35
37{
38 if ( (e->key()==Qt::Key_Return) || (e->key()==Qt::Key_Enter) ){
39 if(count()>=GO4_COMHIS_MAX) setInsertPolicy(InsertAtCurrent); // overwrite last command
40 emit enterPressedSingal();
41 }
42
43 QComboBox::keyPressEvent(e);
44}
45
47{
48 QStringList lst;
49 if (max > count()) max = count();
50
51 for (int i = 0; i < max; i++)
52 lst.append(itemText(i));
53
54 return lst;
55}
#define GO4_COMHIS_MAX
QGo4CommandsHistory(QWidget *parent, const char *name=nullptr)
QStringList getHistory(int max=50)
void keyPressEvent(QKeyEvent *e) override