diff --git a/src/QHistoryLineEdit.cpp b/src/QHistoryLineEdit.cpp index ebfabaf..519ccd6 100644 --- a/src/QHistoryLineEdit.cpp +++ b/src/QHistoryLineEdit.cpp @@ -27,7 +27,7 @@ #include #include -QHistoryLineEdit::QHistoryLineEdit(QWidget *parent) : QLineEdit(parent), _currentLine(0), _completer(0), _completionMinchars(1), _completionMax(0) { +QHistoryLineEdit::QHistoryLineEdit (QWidget* parent) : QLineEdit(parent), _currentLine(0), _completer(0), _completionMinchars(1), _completionMax(0) { QObject::connect(this, &QLineEdit::returnPressed, this, &QHistoryLineEdit::execute); } @@ -35,7 +35,7 @@ QHistoryLineEdit::QHistoryLineEdit(QWidget *parent) : QLineEdit(parent), _curren /** * \brief Number of available lines */ -int QHistoryLineEdit::lineCount() const { +int QHistoryLineEdit::lineCount () const { return _lines.size(); } @@ -43,16 +43,16 @@ int QHistoryLineEdit::lineCount() const { /** * \brief Overwrite the line history */ -void QHistoryLineEdit::setHistory(const QStringList& history) { +void QHistoryLineEdit::setHistory (const QStringList& history) { - _lines = history; + _lines = history; _currentLine = _lines.size(); } /** * \brief Stored history */ -QStringList QHistoryLineEdit::history() const { +QStringList QHistoryLineEdit::history () const { return _lines; } @@ -64,7 +64,7 @@ QStringList QHistoryLineEdit::history() const { * * If \c completer is null it will remove the current completer */ -void QHistoryLineEdit::setWordCompleter(QCompleter* comp) { +void QHistoryLineEdit::setWordCompleter (QCompleter* comp) { if ( _completer ) { @@ -88,14 +88,14 @@ void QHistoryLineEdit::setWordCompleter(QCompleter* comp) { /** * \brief Sets a prefix that is ignored by the word completer */ -void QHistoryLineEdit::setWordCompleterPrefix(const QString& prefix) { +void QHistoryLineEdit::setWordCompleterPrefix (const QString& prefix) { _completionPrefix = prefix; } /** * \brief Sets the minimum number of characters required to display the word completer */ -void QHistoryLineEdit::setWordCompleterMinChars(int minChars) { +void QHistoryLineEdit::setWordCompleterMinChars (int minChars) { _completionMinchars = minChars; } @@ -104,27 +104,36 @@ void QHistoryLineEdit::setWordCompleterMinChars(int minChars) { * * If more than this many suggestions are found the completer isn't shown */ -void QHistoryLineEdit::setWordCompleterMaxSuggestions(int max) { +void QHistoryLineEdit::setWordCompleterMaxSuggestions (int max) { _completionMax = max; } /** * \brief Executes the current line */ -void QHistoryLineEdit::execute() { +void QHistoryLineEdit::execute () { + // Ignore blank lines. + if (text() == "") { + return; + } + + // Add the line if it doesn't equal the previous (that is store in the history). if ( _lines.empty() || _lines.back() != text() ) { _lines << text(); } + // Set our current position in the history list. _currentLine = _lines.size(); - clear(); + // If it wants to, the calling widget should clear the text line. + // clear(); + // Emit the entered text. emit lineExecuted(_lines.back()); } -void QHistoryLineEdit::keyPressEvent(QKeyEvent * ev) { +void QHistoryLineEdit::keyPressEvent (QKeyEvent* ev) { if ( ev->key() == Qt::Key_Up ) { previousLine(); @@ -158,7 +167,7 @@ void QHistoryLineEdit::keyPressEvent(QKeyEvent * ev) { } else { // Get the selection status - int sel = selectionStart(); + int sel = selectionStart(); int sellength = selectedText().size(); // Get the current cursor position @@ -193,7 +202,7 @@ void QHistoryLineEdit::keyPressEvent(QKeyEvent * ev) { } } -void QHistoryLineEdit::wheelEvent(QWheelEvent *ev) { +void QHistoryLineEdit::wheelEvent (QWheelEvent* ev) { if ( ev->angleDelta().y() > 0 ) { previousLine(); @@ -202,7 +211,7 @@ void QHistoryLineEdit::wheelEvent(QWheelEvent *ev) { } } -void QHistoryLineEdit::previousLine() { +void QHistoryLineEdit::previousLine () { if ( _lines.empty() ) { return; @@ -219,8 +228,7 @@ void QHistoryLineEdit::previousLine() { setText(_lines[_currentLine]); } - -void QHistoryLineEdit::nextLine() { +void QHistoryLineEdit::nextLine () { if ( _lines.empty() ) { return; @@ -242,7 +250,7 @@ void QHistoryLineEdit::nextLine() { /** * \brief Current word being edited (used to fire the completer) */ -QString QHistoryLineEdit::current_word() const { +QString QHistoryLineEdit::current_word () const { int completion_index = _wordStart(); @@ -252,7 +260,7 @@ QString QHistoryLineEdit::current_word() const { /** * \brief Autocompletes the current word */ -void QHistoryLineEdit::autoComplete(const QString& completion) { +void QHistoryLineEdit::autoComplete (const QString& completion) { int completion_index = _wordStart(); @@ -264,7 +272,7 @@ void QHistoryLineEdit::autoComplete(const QString& completion) { /** * \brief Returns the index of the character starting the currently edited word */ -int QHistoryLineEdit::_wordStart() const { +int QHistoryLineEdit::_wordStart () const { // lastIndexOf returns the index of the last space or -1 if there are no spaces // so that + 1 returns the index of the character starting the word or 0 diff --git a/src/SeerFunctionBrowserWidget.ui b/src/SeerFunctionBrowserWidget.ui index 16c0174..11035c8 100644 --- a/src/SeerFunctionBrowserWidget.ui +++ b/src/SeerFunctionBrowserWidget.ui @@ -52,7 +52,7 @@ - + Search in the list of functions. "*" is allowed. @@ -63,6 +63,13 @@ + + + QHistoryLineEdit + QLineEdit +
QHistoryLineEdit.h
+
+
diff --git a/src/SeerLibraryBrowserWidget.ui b/src/SeerLibraryBrowserWidget.ui index 659c666..aaf81d3 100644 --- a/src/SeerLibraryBrowserWidget.ui +++ b/src/SeerLibraryBrowserWidget.ui @@ -52,7 +52,7 @@ - + Search in the list of libraries. "*" is allowed. @@ -63,6 +63,13 @@ + + + QHistoryLineEdit + QLineEdit +
QHistoryLineEdit.h
+
+
diff --git a/src/SeerSourceBrowserWidget.ui b/src/SeerSourceBrowserWidget.ui index ff80b6c..99760fd 100644 --- a/src/SeerSourceBrowserWidget.ui +++ b/src/SeerSourceBrowserWidget.ui @@ -32,7 +32,7 @@ - + Search in the list of files. "*" is allowed. @@ -43,6 +43,13 @@ + + + QHistoryLineEdit + QLineEdit +
QHistoryLineEdit.h
+
+
diff --git a/src/SeerStructVisualizerWidget.cpp b/src/SeerStructVisualizerWidget.cpp index ffdf294..56cdbff 100644 --- a/src/SeerStructVisualizerWidget.cpp +++ b/src/SeerStructVisualizerWidget.cpp @@ -227,12 +227,16 @@ void SeerStructVisualizerWidget::handleRefreshButton () { emit evaluateVariableExpression(_variableId, variableNameLineEdit->text()); } -void SeerStructVisualizerWidget::handleVariableNameLineEdit (const QString& text) { +void SeerStructVisualizerWidget::handleVariableNameLineEdit () { - setVariableName (text); + if (variableNameLineEdit->text() == "") { + return; + } + + setVariableName (variableNameLineEdit->text()); } -void SeerStructVisualizerWidget::writeSettings() { +void SeerStructVisualizerWidget::writeSettings () { QSettings settings; @@ -241,7 +245,7 @@ void SeerStructVisualizerWidget::writeSettings() { settings.endGroup(); } -void SeerStructVisualizerWidget::readSettings() { +void SeerStructVisualizerWidget::readSettings () { QSettings settings; diff --git a/src/SeerStructVisualizerWidget.h b/src/SeerStructVisualizerWidget.h index bfcfd65..213230b 100644 --- a/src/SeerStructVisualizerWidget.h +++ b/src/SeerStructVisualizerWidget.h @@ -22,7 +22,7 @@ class SeerStructVisualizerWidget : public QWidget, protected Ui::SeerStructVisua protected slots: void handleRefreshButton (); - void handleVariableNameLineEdit (const QString& text); + void handleVariableNameLineEdit (); void handleItemEntered (QTreeWidgetItem* item, int column); void handleItemExpanded (QTreeWidgetItem* item); diff --git a/src/SeerTypeBrowserWidget.ui b/src/SeerTypeBrowserWidget.ui index 30b39cb..7857926 100644 --- a/src/SeerTypeBrowserWidget.ui +++ b/src/SeerTypeBrowserWidget.ui @@ -42,7 +42,7 @@ - + Search in the list of types. "*" is allowed. @@ -53,6 +53,13 @@ + + + QHistoryLineEdit + QLineEdit +
QHistoryLineEdit.h
+
+
diff --git a/src/SeerVariableBrowserWidget.ui b/src/SeerVariableBrowserWidget.ui index 230a902..6056711 100644 --- a/src/SeerVariableBrowserWidget.ui +++ b/src/SeerVariableBrowserWidget.ui @@ -15,7 +15,7 @@ - + Search for variable names. "*" is allowed. @@ -31,7 +31,7 @@ - + Search for variable types. "*" is allowed. @@ -85,6 +85,13 @@ + + + QHistoryLineEdit + QLineEdit +
QHistoryLineEdit.h
+
+
diff --git a/src/SeerVariableLoggerBrowserWidget.cpp b/src/SeerVariableLoggerBrowserWidget.cpp index 8496ec9..8240e4b 100644 --- a/src/SeerVariableLoggerBrowserWidget.cpp +++ b/src/SeerVariableLoggerBrowserWidget.cpp @@ -25,7 +25,7 @@ SeerVariableLoggerBrowserWidget::SeerVariableLoggerBrowserWidget (QWidget* paren // Connect things. QObject::connect(this, &SeerVariableLoggerBrowserWidget::evaluateVariableExpression, this, &SeerVariableLoggerBrowserWidget::handleEvaluateVariableExpression); - QObject::connect(variableAddLineEdit, &QLineEdit::returnPressed, this, &SeerVariableLoggerBrowserWidget::handleAddLineEdit); + QObject::connect(variableAddLineEdit, &QHistoryLineEdit::lineExecuted, this, &SeerVariableLoggerBrowserWidget::handleAddLineEdit); QObject::connect(variableDeleteToolButton, &QToolButton::clicked, this, &SeerVariableLoggerBrowserWidget::handleDeleteToolButton); QObject::connect(variableDeleteAllToolButton, &QToolButton::clicked, this, &SeerVariableLoggerBrowserWidget::handleDeleteAllToolButton); QObject::connect(variablesTreeWidget, &QTreeWidget::itemEntered, this, &SeerVariableLoggerBrowserWidget::handleItemEntered); diff --git a/src/SeerVariableLoggerBrowserWidget.ui b/src/SeerVariableLoggerBrowserWidget.ui index 86ea9ee..180a0cd 100644 --- a/src/SeerVariableLoggerBrowserWidget.ui +++ b/src/SeerVariableLoggerBrowserWidget.ui @@ -17,7 +17,7 @@ - + Add a variable to the loggger. @@ -88,6 +88,13 @@ + + + QHistoryLineEdit + QLineEdit +
QHistoryLineEdit.h
+
+
diff --git a/src/SeerVariableTrackerBrowserWidget.cpp b/src/SeerVariableTrackerBrowserWidget.cpp index 710ae40..6f59209 100644 --- a/src/SeerVariableTrackerBrowserWidget.cpp +++ b/src/SeerVariableTrackerBrowserWidget.cpp @@ -26,7 +26,7 @@ SeerVariableTrackerBrowserWidget::SeerVariableTrackerBrowserWidget (QWidget* par variablesTreeWidget->clear(); // Connect things. - QObject::connect(variableAddLineEdit, &QLineEdit::returnPressed, this, &SeerVariableTrackerBrowserWidget::handleAddLineEdit); + QObject::connect(variableAddLineEdit, &QHistoryLineEdit::lineExecuted, this, &SeerVariableTrackerBrowserWidget::handleAddLineEdit); QObject::connect(variableDeleteToolButton, &QToolButton::clicked, this, &SeerVariableTrackerBrowserWidget::handleDeleteToolButton); QObject::connect(variableDeleteAllToolButton, &QToolButton::clicked, this, &SeerVariableTrackerBrowserWidget::handleDeleteAllToolButton); QObject::connect(variablesTreeWidget, &QTreeWidget::itemEntered, this, &SeerVariableTrackerBrowserWidget::handleItemEntered); diff --git a/src/SeerVariableTrackerBrowserWidget.ui b/src/SeerVariableTrackerBrowserWidget.ui index d3c785e..9e3e78b 100644 --- a/src/SeerVariableTrackerBrowserWidget.ui +++ b/src/SeerVariableTrackerBrowserWidget.ui @@ -17,7 +17,7 @@ - + Add a variable to track. @@ -83,6 +83,13 @@ + + + QHistoryLineEdit + QLineEdit +
QHistoryLineEdit.h
+
+