1 /* range_syntax_lineedit.cpp 2 * Delegates for editing prefereneces. 3 * 4 * Wireshark - Network traffic analyzer 5 * By Gerald Combs <gerald@wireshark.org> 6 * Copyright 1998 Gerald Combs 7 * 8 * SPDX-License-Identifier: GPL-2.0-or-later 9 */ 10 11 #include <ui/qt/widgets/range_syntax_lineedit.h> 12 13 #include <epan/range.h> 14 RangeSyntaxLineEdit(QWidget * parent)15RangeSyntaxLineEdit::RangeSyntaxLineEdit(QWidget *parent) 16 : SyntaxLineEdit(parent), 17 maxRange_(0xFFFFFFFF) 18 { 19 connect(this, &RangeSyntaxLineEdit::textChanged, this, &RangeSyntaxLineEdit::checkRange); 20 } 21 setMaxRange(unsigned int max)22void RangeSyntaxLineEdit::setMaxRange(unsigned int max) 23 { 24 maxRange_ = max; 25 } 26 checkRange(QString range)27void RangeSyntaxLineEdit::checkRange(QString range) 28 { 29 if (range.isEmpty()) { 30 setSyntaxState(SyntaxLineEdit::Empty); 31 return; 32 } 33 34 range_t *newrange; 35 convert_ret_t ret = range_convert_str(NULL, &newrange, range.toUtf8().constData(), maxRange_); 36 37 if (ret == CVT_NO_ERROR) { 38 setSyntaxState(SyntaxLineEdit::Valid); 39 wmem_free(NULL, newrange); 40 } else { 41 setSyntaxState(SyntaxLineEdit::Invalid); 42 } 43 } 44