WSJT-X/item_delegates/FrequencyDeltaDelegate.cpp
Bill Somerville 19c46774b4
Moving toward multiplier and dupe detection for contest modes
There's not  much to show  for this so far  but some of  the necessary
infrastructure is in place.
2019-05-30 22:20:09 +01:00

27 lines
941 B
C++

#include "FrequencyDeltaDelegate.hpp"
#include "widgets/FrequencyDeltaLineEdit.hpp"
FrequencyDeltaDelegate::FrequencyDeltaDelegate (QObject * parent)
: QStyledItemDelegate {parent}
{
}
QWidget * FrequencyDeltaDelegate::createEditor (QWidget * parent, QStyleOptionViewItem const&
, QModelIndex const&) const
{
auto * editor = new FrequencyDeltaLineEdit {parent};
editor->setFrame (false);
return editor;
}
void FrequencyDeltaDelegate::setEditorData (QWidget * editor, QModelIndex const& index) const
{
static_cast<FrequencyDeltaLineEdit *> (editor)->frequency_delta (index.model ()->data (index, Qt::EditRole).value<Radio::FrequencyDelta> ());
}
void FrequencyDeltaDelegate::setModelData (QWidget * editor, QAbstractItemModel * model, QModelIndex const& index) const
{
model->setData (index, static_cast<FrequencyDeltaLineEdit *> (editor)->frequency_delta (), Qt::EditRole);
}