mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-04 08:21:17 -05:00
c81b3c8e65
Basic validation, must have non-empty exchange sent and received. Abstracted log view window widget behaviour into a base class. Turned on auto resize to row height in log view windows and enabled alternating colours. Convert empty fields to NULL when inserting new log table rows to signify missing data. Trap insert row errors when adding to contest log table so that logging can be held back if constraints are not met. Re-factored log QSO processing to try insert row into log table first and pop up a message box if constraints are not met, this pops up the Log QSO window in case it was initiated by an auto log event.
69 lines
2.0 KiB
C++
69 lines
2.0 KiB
C++
#include "CabrilloLogWindow.hpp"
|
|
|
|
#include <QApplication>
|
|
#include <QIdentityProxyModel>
|
|
#include "Configuration.hpp"
|
|
#include "models/Bands.hpp"
|
|
#include "item_delegates/ForeignKeyDelegate.hpp"
|
|
#include "item_delegates/DateTimeAsSecsSinceEpochDelegate.hpp"
|
|
#include "item_delegates/CallsignDelegate.hpp"
|
|
#include "pimpl_impl.hpp"
|
|
|
|
#include "ui_CabrilloLogWindow.h"
|
|
|
|
namespace
|
|
{
|
|
class FormatProxyModel final
|
|
: public QIdentityProxyModel
|
|
{
|
|
public:
|
|
explicit FormatProxyModel (QObject * parent = nullptr)
|
|
: QIdentityProxyModel {parent}
|
|
{
|
|
}
|
|
|
|
QVariant data (QModelIndex const& index, int role) const override
|
|
{
|
|
if (Qt::TextAlignmentRole == role && index.isValid ())
|
|
{
|
|
switch (index.column ())
|
|
{
|
|
case 1:
|
|
case 6:
|
|
return Qt::AlignRight + Qt::AlignVCenter;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return QIdentityProxyModel::data (index, role);
|
|
}
|
|
};
|
|
}
|
|
|
|
class CabrilloLogWindow::impl final
|
|
{
|
|
public:
|
|
explicit impl () = default;
|
|
FormatProxyModel format_model_;
|
|
Ui::CabrilloLogWindow ui_;
|
|
};
|
|
|
|
CabrilloLogWindow::CabrilloLogWindow (QSettings * settings, Configuration const * configuration
|
|
, QAbstractItemModel * cabrillo_log_model, QWidget * parent)
|
|
: AbstractLogWindow {"Cabrillo Log Window", settings, configuration, parent}
|
|
{
|
|
setWindowTitle (QApplication::applicationName () + " - Cabrillo Log");
|
|
m_->ui_.setupUi (this);
|
|
m_->format_model_.setSourceModel (cabrillo_log_model);
|
|
set_log_model (&m_->format_model_);
|
|
set_log_view (m_->ui_.log_table_view);
|
|
m_->ui_.log_table_view->setItemDelegateForColumn (2, new DateTimeAsSecsSinceEpochDelegate {this});
|
|
m_->ui_.log_table_view->setItemDelegateForColumn (3, new CallsignDelegate {this});
|
|
m_->ui_.log_table_view->setItemDelegateForColumn (6, new ForeignKeyDelegate {configuration->bands (), cabrillo_log_model, 0, 6, this});
|
|
m_->ui_.log_table_view->horizontalHeader ()->moveSection (6, 1); // band to first column
|
|
}
|
|
|
|
CabrilloLogWindow::~CabrilloLogWindow ()
|
|
{
|
|
}
|