From 470747cb896d6dcf7f13602b6cb32fc526c0e9d1 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Wed, 6 Apr 2022 18:20:43 +0800 Subject: [PATCH] add: keywordlineEdit class file --- DSView/pv/dialogs/dsdialog.cpp | 11 ++++--- DSView/pv/dock/keywordlineedit.cpp | 48 ++++++++++++++++++++++++++++++ DSView/pv/dock/keywordlineedit.h | 48 ++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 DSView/pv/dock/keywordlineedit.cpp create mode 100644 DSView/pv/dock/keywordlineedit.h diff --git a/DSView/pv/dialogs/dsdialog.cpp b/DSView/pv/dialogs/dsdialog.cpp index 37a0e7cd..94569abb 100755 --- a/DSView/pv/dialogs/dsdialog.cpp +++ b/DSView/pv/dialogs/dsdialog.cpp @@ -33,20 +33,23 @@ namespace pv { namespace dialogs { -DSDialog::DSDialog() : DSDialog(NULL, false, false) +DSDialog::DSDialog() : + DSDialog(NULL, false, false) { } -DSDialog::DSDialog(QWidget *parent): DSDialog(parent, false, false) +DSDialog::DSDialog(QWidget *parent): + DSDialog(parent, false, false) { } -DSDialog::DSDialog(QWidget *parent, bool hasClose): DSDialog(parent, hasClose, false) +DSDialog::DSDialog(QWidget *parent, bool hasClose): + DSDialog(parent, hasClose, false) { } DSDialog::DSDialog(QWidget *parent, bool hasClose, bool bBaseButton) : - QDialog(NULL), //must be null, otherwise window can not able to move + QDialog(parent), //must be null, otherwise window can not able to move m_bBaseButton(bBaseButton) { (void)parent; diff --git a/DSView/pv/dock/keywordlineedit.cpp b/DSView/pv/dock/keywordlineedit.cpp new file mode 100644 index 00000000..d15805f4 --- /dev/null +++ b/DSView/pv/dock/keywordlineedit.cpp @@ -0,0 +1,48 @@ +/* + * This file is part of the DSView project. + * DSView is based on PulseView. + * + * Copyright (C) 2022 DreamSourceLab + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "keywordlineedit.h" + +KeywordLineEdit::KeywordLineEdit(QComboBox *comboBox) +:QLineEdit() +{ + assert(comboBox); + _comboBox = comboBox; +} + + + void KeywordLineEdit::focusInEvent(QFocusEvent *e) + { + QLineEdit::focusInEvent(e); + QString key(PROTOCOL_FIND_TITLE); + if (this->text() == key){ + this->setText(""); + } + } + +void KeywordLineEdit::focusOutEvent(QFocusEvent *e) + { + QLineEdit::focusOutEvent(e); + + if (this->text() == ""){ + this->setText(PROTOCOL_FIND_TITLE); + } + } \ No newline at end of file diff --git a/DSView/pv/dock/keywordlineedit.h b/DSView/pv/dock/keywordlineedit.h new file mode 100644 index 00000000..205de9e2 --- /dev/null +++ b/DSView/pv/dock/keywordlineedit.h @@ -0,0 +1,48 @@ +/* + * This file is part of the DSView project. + * DSView is based on PulseView. + * + * Copyright (C) 2022 DreamSourceLab + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef KEY_WORD_LINE_EDIT_H +#define KEY_WORD_LINE_EDIT_H + +#include +#include +#include +#include + +#define PROTOCOL_FIND_TITLE "Protocol search..." + +class KeywordLineEdit : public QLineEdit + { + Q_OBJECT + +public: + KeywordLineEdit(QComboBox *comboBox); + +protected: + void focusInEvent(QFocusEvent *e) override; + void focusOutEvent(QFocusEvent *e) override; + +private: + QComboBox *_comboBox; +}; + + +#endif