2015-05-28 19:22:17 -04:00
|
|
|
#include "Modes.hpp"
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QVariant>
|
|
|
|
|
2015-06-09 10:30:23 -04:00
|
|
|
#include "moc_Modes.cpp"
|
|
|
|
|
2015-05-28 19:22:17 -04:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
char const * const mode_names[] =
|
|
|
|
{
|
|
|
|
"",
|
|
|
|
"JT65",
|
|
|
|
"JT9",
|
|
|
|
"JT9W-1",
|
|
|
|
"JT4",
|
|
|
|
"WSPR",
|
2015-06-04 12:42:38 -04:00
|
|
|
"Echo",
|
2015-05-28 19:22:17 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
Modes::Modes (QObject * parent)
|
|
|
|
: QAbstractListModel {parent}
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
char const * Modes::name (Mode m)
|
|
|
|
{
|
|
|
|
return mode_names[static_cast<int> (m)];
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Modes::value (QString const& s) -> Mode
|
|
|
|
{
|
|
|
|
auto end = mode_names + sizeof (mode_names) / sizeof (mode_names[0]);
|
|
|
|
auto p = std::find_if (mode_names, end
|
|
|
|
, [&s] (char const * const name) {
|
|
|
|
return name == s;
|
|
|
|
});
|
|
|
|
return p != end ? static_cast<Mode> (p - mode_names) : NULL_MODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant Modes::data (QModelIndex const& index, int role) const
|
|
|
|
{
|
|
|
|
QVariant item;
|
|
|
|
|
|
|
|
if (index.isValid ())
|
|
|
|
{
|
|
|
|
auto const& row = index.row ();
|
|
|
|
switch (role)
|
|
|
|
{
|
|
|
|
case Qt::ToolTipRole:
|
|
|
|
case Qt::AccessibleDescriptionRole:
|
|
|
|
item = tr ("Mode");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Qt::EditRole:
|
|
|
|
item = static_cast<Mode> (row);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Qt::DisplayRole:
|
|
|
|
case Qt::AccessibleTextRole:
|
|
|
|
item = mode_names[row];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Qt::TextAlignmentRole:
|
|
|
|
item = Qt::AlignHCenter + Qt::AlignVCenter;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant Modes::headerData (int section, Qt::Orientation orientation, int role) const
|
|
|
|
{
|
|
|
|
QVariant result;
|
|
|
|
|
|
|
|
if (Qt::DisplayRole == role && Qt::Horizontal == orientation)
|
|
|
|
{
|
|
|
|
result = tr ("Mode");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = QAbstractListModel::headerData (section, orientation, role);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if !defined (QT_NO_DEBUG_STREAM)
|
|
|
|
ENUM_QDEBUG_OPS_IMPL (Modes, Mode);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ENUM_QDATASTREAM_OPS_IMPL (Modes, Mode);
|
|
|
|
ENUM_CONVERSION_OPS_IMPL (Modes, Mode);
|