00001 // $Id: QGo4CommandsHistory.cpp 1134 2014-01-22 14:53:40Z linev $ 00002 //----------------------------------------------------------------------- 00003 // The GSI Online Offline Object Oriented (Go4) Project 00004 // Experiment Data Processing at EE department, GSI 00005 //----------------------------------------------------------------------- 00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH 00007 // Planckstr. 1, 64291 Darmstadt, Germany 00008 // Contact: http://go4.gsi.de 00009 //----------------------------------------------------------------------- 00010 // This software can be used under the license agreements as stated 00011 // in Go4License.txt file which is part of the distribution. 00012 //----------------------------------------------------------------------- 00013 00014 #include "QGo4CommandsHistory.h" 00015 00016 #include <QKeyEvent> 00017 00018 QGo4CommandsHistory::QGo4CommandsHistory(QWidget* w, const char* name) : 00019 QComboBox(w) 00020 { 00021 setObjectName(name ? name : "Go4CommandsHistory"); 00022 setMaxCount(50); 00023 setInsertPolicy(InsertAtTop); 00024 setDuplicatesEnabled(false); 00025 setAutoCompletion(true); 00026 setEditable(true); 00027 } 00028 00029 QGo4CommandsHistory::~QGo4CommandsHistory() 00030 { 00031 } 00032 00033 void QGo4CommandsHistory::keyPressEvent(QKeyEvent* e) 00034 { 00035 if (e->key()==Qt::Key_Return) 00036 emit enterPressedSingal(); 00037 00038 QComboBox::keyPressEvent(e); 00039 } 00040 00041 QStringList QGo4CommandsHistory::getHistory(int max) 00042 { 00043 QStringList lst; 00044 if (max>count()) max = count(); 00045 00046 for(int i=0; i<max; i++) 00047 lst.append(itemText(i)); 00048 00049 return lst; 00050 }