Browse Source

Add read-only stuff

master
squeaky otter 6 years ago
parent
commit
7140fa04a3
4 changed files with 36 additions and 1 deletions
  1. +22
    -0
      qthLog/delegates/readonlydelegate.h
  2. +2
    -1
      qthLog/qthLog.pro
  3. +11
    -0
      qthLog/qthlogmw.cpp
  4. +1
    -0
      qthLog/qthlogmw.h

+ 22
- 0
qthLog/delegates/readonlydelegate.h View File

@ -0,0 +1,22 @@
#ifndef READONLYDELEGATE_H
#define READONLYDELEGATE_H
#include <QObject>
#include <QStyledItemDelegate>
#include <QStringRef>
class ReadOnlyDelegate : public QStyledItemDelegate {
Q_OBJECT
public:
explicit ReadOnlyDelegate(QObject *parent = 0)
: QStyledItemDelegate(parent) {}
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
(void)parent;
(void)option;
(void)index;
return Q_NULLPTR;
}
};
#endif // READONLYDELEGATE_H

+ 2
- 1
qthLog/qthLog.pro View File

@ -52,7 +52,8 @@ HEADERS += qthlogmw.h \
updatecty.h \
databaseupdater.h \
adifmanager.h \
../libqth/qth.h
../libqth/qth.h \
delegates/readonlydelegate.h
FORMS += qthlogmw.ui \
preferences.ui \


+ 11
- 0
qthLog/qthlogmw.cpp View File

@ -100,6 +100,16 @@ bool qthLogMW::initialize() {
ui->tableViewQso->setItemDelegateForColumn(dbQsoModel->fieldIndex("time"), new AdifNumberDelegate(this));
ui->tableViewQso->setItemDelegateForColumn(dbQsoModel->fieldIndex("sat"), new AdifSatDelegate(this));
ui->tableViewQso->setItemDelegateForColumn(dbQsoModel->fieldIndex("power"), new AdifPowerDelegate(this));
// There is probably a better way, but this works anyway
ui->tableViewQso->setItemDelegateForColumn(dbQsoModel->fieldIndex("country"), new ReadOnlyDelegate(this));
ui->tableViewQso->setItemDelegateForColumn(dbQsoModel->fieldIndex("my_country"), new ReadOnlyDelegate(this));
ui->tableViewQso->setItemDelegateForColumn(dbQsoModel->fieldIndex("cqz"), new ReadOnlyDelegate(this));
ui->tableViewQso->setItemDelegateForColumn(dbQsoModel->fieldIndex("ituz"), new ReadOnlyDelegate(this));
ui->tableViewQso->setItemDelegateForColumn(dbQsoModel->fieldIndex("iota"), new ReadOnlyDelegate(this));
ui->tableViewQso->setItemDelegateForColumn(dbQsoModel->fieldIndex("qrz_url"), new ReadOnlyDelegate(this));
ui->tableViewQso->setItemDelegateForColumn(dbQsoModel->fieldIndex("state"), new ReadOnlyDelegate(this));
ui->tableViewQso->resizeColumnsToContents();
ui->tableViewQso->horizontalHeader()->moveSection(
@ -353,6 +363,7 @@ void qthLogMW::updateTableQso() {
ui->tableViewQso->setItemDelegate(new QSqlRelationalDelegate(ui->tableViewQso));
ui->tableViewQso->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableViewQso->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tableViewQso->setAlternatingRowColors(true);
// TODO: delegate for QRZ Url
if (!dbQsoModel->select()) {


+ 1
- 0
qthLog/qthlogmw.h View File

@ -39,6 +39,7 @@
#include "delegates/adifdatedelegate.h"
#include "delegates/sat.h"
#include "delegates/power.h"
#include "delegates/readonlydelegate.h"
#include "helpers.h"
#include "../crapdif/adif_parse.h"
#include "../crapdif/adif_export.h"


Loading…
Cancel
Save