mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 13:55:36 +08:00
Saving history of line edit for command line ("dot commands")
This commit is contained in:
committed by
Mathew Sutcliffe
parent
1967c82221
commit
5b3780543f
44
src/blackgui/lineedithistory.h
Normal file
44
src/blackgui/lineedithistory.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* Copyright (C) 2017
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_LINEEDITHISTORY_H
|
||||
#define BLACKGUI_LINEEDITHISTORY_H
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QStringList>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
/*!
|
||||
* Line edit with history
|
||||
*/
|
||||
class CLineEditHistory : public QLineEdit
|
||||
{
|
||||
public:
|
||||
//! Constructors
|
||||
using QLineEdit::QLineEdit;
|
||||
|
||||
//! Get the last entered line
|
||||
QString getLastEnteredLine() const;
|
||||
|
||||
//! Get the last entered line but simplified and trimmed
|
||||
QString getLastEnteredLineFormatted() const;
|
||||
|
||||
protected:
|
||||
//! \copydoc QLineEdit::keyPressEvent
|
||||
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
private:
|
||||
QStringList m_history;
|
||||
int m_position = 0;
|
||||
};
|
||||
} // ns
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user