GSI Object Oriented Online Offline (Go4)
GO4-6.4.0
Loading...
Searching...
No Matches
qt4
Go4GUI
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
21
QGo4CommandsHistory::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
32
QGo4CommandsHistory::~QGo4CommandsHistory
()
33
{
34
}
35
36
void
QGo4CommandsHistory::keyPressEvent
(QKeyEvent* e)
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
46
QStringList
QGo4CommandsHistory::getHistory
(
int
max)
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
}
GO4_COMHIS_MAX
#define GO4_COMHIS_MAX
Definition
QGo4CommandsHistory.cpp:18
QGo4CommandsHistory.h
QGo4CommandsHistory::QGo4CommandsHistory
QGo4CommandsHistory(QWidget *parent, const char *name=nullptr)
Definition
QGo4CommandsHistory.cpp:21
QGo4CommandsHistory::enterPressedSingal
void enterPressedSingal()
QGo4CommandsHistory::~QGo4CommandsHistory
virtual ~QGo4CommandsHistory()
Definition
QGo4CommandsHistory.cpp:32
QGo4CommandsHistory::getHistory
QStringList getHistory(int max=50)
Definition
QGo4CommandsHistory.cpp:46
QGo4CommandsHistory::keyPressEvent
void keyPressEvent(QKeyEvent *e) override
Definition
QGo4CommandsHistory.cpp:36
Generated by
1.13.2