WSJT-X/item_delegates/CallsignDelegate.cpp
Bill Somerville b8e4517718 Improve performance of Fox and contest log view windows
This include inverting  the order of table view rows  so the newest is
at the top, without that the Qt MVC interactions when using a database
table based model is too slow and complex to manage.

The table views  now have sort by column capability  in the normal way
(click column  header to  reverse sort order)  for timely  logging and
non-disruption  of  Tx  starts  the  log  view  should  be  sorted  in
descending time order and scrolled to the last row added. Without that
Fox and  contest logging will work  but serious delays may  be invoked
that disrupt operation.
2018-12-06 05:41:16 +00:00

32 lines
926 B
C++

#include "CallsignDelegate.hpp"
#include <QLineEdit>
#include "validators/CallsignValidator.hpp"
CallsignDelegate::CallsignDelegate (QObject * parent)
: QStyledItemDelegate {parent}
, validator_ {new CallsignValidator}
{
}
QWidget * CallsignDelegate::createEditor (QWidget * parent, QStyleOptionViewItem const&
, QModelIndex const&) const
{
auto * editor = new QLineEdit {parent};
editor->setFrame (false);
editor->setValidator (validator_.data ());
return editor;
}
void CallsignDelegate::setEditorData (QWidget * editor, QModelIndex const& index) const
{
static_cast<QLineEdit *> (editor)->setText (index.model ()->data (index, Qt::EditRole).toString ());
}
void CallsignDelegate::setModelData (QWidget * editor, QAbstractItemModel * model, QModelIndex const& index) const
{
model->setData (index, static_cast<QLineEdit *> (editor)->text (), Qt::EditRole);
}