forked from Ivasoft/DSView
update: protocol search key word was changed, list panel auto be show popup
This commit is contained in:
@@ -111,7 +111,7 @@ int main(int argc, char *argv[])
|
||||
QApplication::setOrganizationName("DreamSourceLab");
|
||||
QApplication::setOrganizationDomain("www.DreamSourceLab.com");
|
||||
|
||||
qDebug()<<"\n----------------- version:"<<DS_VERSION_STRING<<"-----------------\n\n";
|
||||
qDebug()<<"\n----------------- version:"<<DS_VERSION_STRING<<"-----------------\n";
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
// Use low version qt plugins, for able to debug
|
||||
|
||||
@@ -468,6 +468,7 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod
|
||||
uint64_t last_cnt = 0;
|
||||
uint64_t notify_cnt = (decode_end - decode_start + 1)/100;
|
||||
srd_decoder_inst *logic_di = NULL;
|
||||
|
||||
// find the first level decoder instant
|
||||
for (GSList *d = session->di_list; d; d = d->next) {
|
||||
srd_decoder_inst *di = (srd_decoder_inst *)d->data;
|
||||
@@ -479,6 +480,8 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod
|
||||
}
|
||||
}
|
||||
|
||||
assert(logic_di);
|
||||
|
||||
uint64_t entry_cnt = 0;
|
||||
uint64_t i = decode_start;
|
||||
char *error = NULL;
|
||||
@@ -487,12 +490,8 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod
|
||||
qDebug()<<"decode data index have been end:"<<i;
|
||||
}
|
||||
|
||||
while(i < decode_end && !_no_memory)
|
||||
{
|
||||
if (status->m_bStop){
|
||||
break;
|
||||
}
|
||||
|
||||
while(i < decode_end && !_no_memory && !status->m_bStop)
|
||||
{
|
||||
std::vector<const uint8_t *> chunk;
|
||||
std::vector<uint8_t> chunk_const;
|
||||
uint64_t chunk_end = decode_end;
|
||||
|
||||
@@ -52,24 +52,55 @@
|
||||
#include "../config/appconfig.h"
|
||||
#include "../data/decode/decoderstatus.h"
|
||||
|
||||
#define PROTOCOL_FIND_TITLE "Protocol search..."
|
||||
|
||||
using namespace std;
|
||||
|
||||
//--------------------------class KeywordLineEdit
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
namespace pv {
|
||||
namespace dock {
|
||||
|
||||
ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *session) :
|
||||
QScrollArea(parent),
|
||||
_session(session),
|
||||
_view(view),
|
||||
_cur_search_index(-1),
|
||||
_search_edited(false),
|
||||
_searching(false),
|
||||
_add_silent(false)
|
||||
_view(view)
|
||||
{
|
||||
_session = session;
|
||||
_cur_search_index = -1;
|
||||
_search_edited = false;
|
||||
_searching = false;
|
||||
_add_silent = false;
|
||||
|
||||
_up_widget = new QWidget(this);
|
||||
|
||||
QHBoxLayout *hori_layout = new QHBoxLayout();
|
||||
|
||||
|
||||
_add_button = new QPushButton(_up_widget);
|
||||
_add_button->setFlat(true);
|
||||
_del_all_button = new QPushButton(_up_widget);
|
||||
@@ -78,6 +109,7 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio
|
||||
|
||||
_protocol_combobox = new DsComboBox(_up_widget);
|
||||
_protocol_combobox->setEditable(true);
|
||||
_protocol_combobox->setLineEdit(new KeywordLineEdit(_protocol_combobox));
|
||||
_protocol_combobox->setCompleter(NULL);
|
||||
|
||||
GSList *l = g_slist_sort(g_slist_copy((GSList*)srd_decoder_list()), decoder_name_cmp);
|
||||
@@ -120,6 +152,8 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio
|
||||
for (auto info : _decoderInfoList){
|
||||
_protocol_combobox->addItem(QString::fromUtf8(info->Name), QVariant::fromValue(info->Index));
|
||||
}
|
||||
_protocol_combobox->setCurrentIndex(-1);
|
||||
_protocol_combobox->lineEdit()->setText(PROTOCOL_FIND_TITLE);
|
||||
|
||||
if (repeatNammes != ""){
|
||||
QString err = "Any protocol have repeated id or name: ";
|
||||
@@ -127,12 +161,14 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio
|
||||
MsgBox::Show("error", err.toUtf8().data());
|
||||
}
|
||||
|
||||
_up_layout = new QVBoxLayout();
|
||||
|
||||
QHBoxLayout *hori_layout = new QHBoxLayout();
|
||||
hori_layout->addWidget(_add_button);
|
||||
hori_layout->addWidget(_del_all_button);
|
||||
hori_layout->addWidget(_protocol_combobox);
|
||||
hori_layout->addStretch(1);
|
||||
|
||||
_up_layout = new QVBoxLayout();
|
||||
|
||||
_up_layout->addLayout(hori_layout);
|
||||
_up_layout->addStretch(1);
|
||||
|
||||
@@ -216,6 +252,12 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio
|
||||
|
||||
retranslateUi();
|
||||
|
||||
_key_find_timer.SetCallback(std::bind(&ProtocolDock::show_protocol_list_panel, this));
|
||||
//when porotocol list panel was showPopup statu, receive key press event
|
||||
QWidget *popup1 = _protocol_combobox->findChild<QFrame*>();
|
||||
QWidget *wid1 = popup1->findChild<QWidget*>();
|
||||
wid1->installEventFilter(this);
|
||||
|
||||
connect(_dn_nav_button, SIGNAL(clicked()),this, SLOT(nav_table_view()));
|
||||
connect(_dn_save_button, SIGNAL(clicked()),this, SLOT(export_table_view()));
|
||||
connect(_dn_set_button, SIGNAL(clicked()),this, SLOT(set_model()));
|
||||
@@ -857,8 +899,25 @@ void ProtocolDock::on_decoder_name_edited(const QString &value)
|
||||
|
||||
_protocol_combobox->setCurrentIndex(-1);
|
||||
_protocol_combobox->lineEdit()->setText(value);
|
||||
|
||||
if (_key_find_timer.IsActived() == false){
|
||||
//check input keep time
|
||||
_key_find_timer.Start(100);
|
||||
}
|
||||
else{
|
||||
_key_find_timer.ResetActiveTime();
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolDock::show_protocol_list_panel()
|
||||
{
|
||||
//press key end, to popup list panel
|
||||
if (_key_find_timer.GetActiveTimeLong() >= 1000){
|
||||
_key_find_timer.Stop();
|
||||
_protocol_combobox->showPopup();
|
||||
}
|
||||
}
|
||||
|
||||
bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const DecoderInfoItem *o2)
|
||||
{
|
||||
const char *s1 = o1->Name;
|
||||
@@ -891,6 +950,17 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProtocolDock::eventFilter(QObject *object, QEvent *event)
|
||||
{
|
||||
if ( event->type() == QEvent::KeyPress )
|
||||
{
|
||||
if (_protocol_combobox->IsPopup()){
|
||||
_protocol_combobox->hidePopup();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QTableView>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QLineEdit>
|
||||
#include <QFocusEvent>
|
||||
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
@@ -54,6 +55,21 @@ struct DecoderInfoItem{
|
||||
void *ObjectHandle; //srd_decoder* type
|
||||
};
|
||||
|
||||
class KeywordLineEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KeywordLineEdit(QComboBox *comboBox);
|
||||
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent *e) override;
|
||||
void focusOutEvent(QFocusEvent *e) override;
|
||||
|
||||
private:
|
||||
QComboBox *_comboBox;
|
||||
};
|
||||
|
||||
namespace pv {
|
||||
|
||||
class SigSession;
|
||||
@@ -124,6 +140,8 @@ private:
|
||||
static int decoder_name_cmp(const void *a, const void *b);
|
||||
void resize_table_view(data::DecoderModel *decoder_model);
|
||||
static bool protocol_sort_callback(const DecoderInfoItem *o1, const DecoderInfoItem *o2);
|
||||
void show_protocol_list_panel();
|
||||
bool eventFilter(QObject *object, QEvent *event);
|
||||
|
||||
private:
|
||||
SigSession *_session;
|
||||
@@ -162,6 +180,7 @@ private:
|
||||
bool _searching;
|
||||
|
||||
bool _add_silent;
|
||||
DsTimer _key_find_timer;
|
||||
};
|
||||
|
||||
} // namespace dock
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
#include "dstimer.h"
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
DsTimer::DsTimer(){
|
||||
_binded = false;
|
||||
_isActived = false;
|
||||
}
|
||||
|
||||
void DsTimer::on_timeout()
|
||||
{
|
||||
void DsTimer::on_timeout(){
|
||||
_call(); //call back
|
||||
}
|
||||
}
|
||||
|
||||
void DsTimer::TimeOut(int millsec, CALLBACL_FUNC f)
|
||||
{
|
||||
@@ -17,33 +18,61 @@ void DsTimer::TimeOut(int millsec, CALLBACL_FUNC f)
|
||||
QTimer::singleShot(millsec, this, SLOT(on_timeout()));
|
||||
}
|
||||
|
||||
void DsTimer::SetCallback(CALLBACL_FUNC f)
|
||||
{
|
||||
assert(!_binded);
|
||||
_binded = true;
|
||||
void DsTimer::Start(int millsec, CALLBACL_FUNC f)
|
||||
{
|
||||
if (_isActived)
|
||||
return;
|
||||
|
||||
_call = f;
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(on_timeout()));
|
||||
_call = f;
|
||||
|
||||
if (!_binded){
|
||||
_binded = true;
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(on_timeout()));
|
||||
}
|
||||
|
||||
_timer.start(millsec);
|
||||
_isActived = true;
|
||||
_beginTime = high_resolution_clock::now();
|
||||
}
|
||||
|
||||
void DsTimer::Start(int millsec, CALLBACL_FUNC f)
|
||||
void DsTimer::SetCallback(CALLBACL_FUNC f)
|
||||
{
|
||||
assert(!_binded);
|
||||
_binded = true;
|
||||
_call = f;
|
||||
|
||||
_call = f;
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(on_timeout()));
|
||||
_timer.start(millsec);
|
||||
if(!_binded){
|
||||
_binded = true;
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(on_timeout()));
|
||||
}
|
||||
}
|
||||
|
||||
void DsTimer::Start(int millsec)
|
||||
{
|
||||
//check if connectb
|
||||
//check if connect
|
||||
assert(_binded);
|
||||
|
||||
if (_isActived)
|
||||
return;
|
||||
|
||||
_timer.start(millsec);
|
||||
_isActived = true;
|
||||
_beginTime = high_resolution_clock::now();
|
||||
}
|
||||
|
||||
void DsTimer::Stop()
|
||||
{
|
||||
_timer.stop();
|
||||
if (_isActived)
|
||||
_timer.stop();
|
||||
_isActived = false;
|
||||
}
|
||||
|
||||
long long DsTimer::GetActiveTimeLong()
|
||||
{
|
||||
high_resolution_clock::time_point endTime = high_resolution_clock::now();
|
||||
milliseconds timeInterval = std::chrono::duration_cast<milliseconds>(endTime - _beginTime);
|
||||
return timeInterval.count();
|
||||
}
|
||||
|
||||
void DsTimer::ResetActiveTime()
|
||||
{
|
||||
_beginTime = high_resolution_clock::now();
|
||||
}
|
||||
|
||||
@@ -5,12 +5,17 @@
|
||||
#include <QObject>
|
||||
#include <functional>
|
||||
#include <QTimer>
|
||||
#include <chrono>
|
||||
|
||||
using std::chrono::high_resolution_clock;
|
||||
using std::chrono::milliseconds;
|
||||
|
||||
typedef std::function<void()> CALLBACL_FUNC;
|
||||
|
||||
class DsTimer : public QObject
|
||||
|
||||
class DsTimer : protected QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DsTimer();
|
||||
@@ -25,13 +30,23 @@ public:
|
||||
|
||||
void Stop();
|
||||
|
||||
inline bool IsActived(){
|
||||
return _isActived;
|
||||
}
|
||||
|
||||
long long GetActiveTimeLong();
|
||||
|
||||
void ResetActiveTime();
|
||||
|
||||
private slots:
|
||||
void on_timeout();
|
||||
|
||||
private:
|
||||
CALLBACL_FUNC _call;
|
||||
private:
|
||||
QTimer _timer;
|
||||
bool _binded;
|
||||
bool _isActived;
|
||||
high_resolution_clock::time_point _beginTime;
|
||||
CALLBACL_FUNC _call;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1900,7 +1900,7 @@ void SigSession::set_stop_scale(float scale)
|
||||
}
|
||||
|
||||
if (task->_delete_flag){
|
||||
qDebug()<<"desroy a decoder in task thread";
|
||||
qDebug()<<"destroy a decoder in task thread";
|
||||
|
||||
DESTROY_QT_LATER(task);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* DSView is based on PulseView.
|
||||
*
|
||||
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
|
||||
* Copyright (C) 2013 DreamSourceLab <support@dreamsourcelab.com>
|
||||
* Copyright (C) 2022 DreamSourceLab <support@dreamsourcelab.com>
|
||||
*
|
||||
* 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
|
||||
@@ -24,11 +24,14 @@
|
||||
#include "dscombobox.h"
|
||||
#include <QFontMetrics>
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
DsComboBox::DsComboBox(QWidget *parent) : QComboBox(parent)
|
||||
{
|
||||
_contentWidth = 0;
|
||||
_bPopup = false;
|
||||
QComboBox::setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
}
|
||||
|
||||
@@ -51,6 +54,7 @@ DsComboBox::DsComboBox(QWidget *parent) : QComboBox(parent)
|
||||
void DsComboBox::showPopup()
|
||||
{
|
||||
QComboBox::showPopup();
|
||||
_bPopup = true;
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
|
||||
@@ -70,3 +74,10 @@ DsComboBox::DsComboBox(QWidget *parent) : QComboBox(parent)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void DsComboBox::hidePopup()
|
||||
{
|
||||
QComboBox::hidePopup();
|
||||
_bPopup = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* DSView is based on PulseView.
|
||||
*
|
||||
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
|
||||
* Copyright (C) 2013 DreamSourceLab <support@dreamsourcelab.com>
|
||||
* Copyright (C) 2022 DreamSourceLab <support@dreamsourcelab.com>
|
||||
*
|
||||
* 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
|
||||
@@ -25,6 +25,7 @@
|
||||
#define DSCOMBOBOX_H
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QKeyEvent>
|
||||
|
||||
class DsComboBox : public QComboBox
|
||||
{
|
||||
@@ -35,11 +36,18 @@ public:
|
||||
|
||||
void addItem(const QString &atext, const QVariant &userData = QVariant());
|
||||
|
||||
protected:
|
||||
void showPopup();
|
||||
public:
|
||||
void showPopup() override;
|
||||
|
||||
void hidePopup() override;
|
||||
|
||||
inline bool IsPopup(){
|
||||
return _bPopup;
|
||||
}
|
||||
|
||||
private:
|
||||
int _contentWidth;
|
||||
int _contentWidth;
|
||||
bool _bPopup;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -26,4 +26,5 @@ c can call's method of python:
|
||||
5.printlog //print log to console, param type is string
|
||||
|
||||
|
||||
decode函数返回任意值,则表示解析任务终止
|
||||
|
||||
|
||||
Reference in New Issue
Block a user