Skip to content

Commit

Permalink
Store header states for all extension views. Fixes #189.
Browse files Browse the repository at this point in the history
  • Loading branch information
hmatuschek committed Jan 18, 2022
1 parent 243e730 commit 76bc9dd
Show file tree
Hide file tree
Showing 20 changed files with 53 additions and 50 deletions.
1 change: 1 addition & 0 deletions src/analogchanneldialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ AnalogChannelDialog::construct() {
if (! settings.showCommercialFeatures())
tabWidget->tabBar()->hide();

extensionView->setObjectName("AnalogChannelExtension");
extensionView->setObject(_myChannel);

connect(powerDefault, SIGNAL(toggled(bool)), this, SLOT(onPowerDefaultToggled(bool)));
Expand Down
1 change: 1 addition & 0 deletions src/aprssystemdialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ APRSSystemDialog::construct() {
ui->updatePeriod->setValue(_myAPRS->period());
ui->message->setText(_myAPRS->message());

ui->extensionView->setObjectName("aprsSystemExtension");
ui->extensionView->setObject(_myAPRS);
if (! settings.showCommercialFeatures())
ui->tabWidget->tabBar()->hide();
Expand Down
4 changes: 2 additions & 2 deletions src/channellistview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ ChannelListView::onEditChannel(unsigned row) {
void
ChannelListView::loadChannelListSectionState() {
Settings settings;
ui->listView->header()->restoreState(settings.channelListHeaderState());
ui->listView->header()->restoreState(settings.headerState("channelList"));
}
void
ChannelListView::storeChannelListSectionState() {
Settings settings;
settings.setChannelListHeaderState(ui->listView->header()->saveState());
settings.setHeaderState("channelList", ui->listView->header()->saveState());
}

4 changes: 2 additions & 2 deletions src/contactlistview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ ContactListView::onEditContact(unsigned row) {
void
ContactListView::loadHeaderState() {
Settings settings;
ui->listView->header()->restoreState(settings.contactListHeaderState());
ui->listView->header()->restoreState(settings.headerState("contactList"));
}
void
ContactListView::storeHeaderState() {
Settings settings;
settings.setContactListHeaderState(ui->listView->header()->saveState());
settings.setHeaderState("contactList", ui->listView->header()->saveState());
}
2 changes: 2 additions & 0 deletions src/digitalchanneldialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ DigitalChannelDialog::construct() {
voxDefault->setChecked(false); voxValue->setEnabled(true);
voxValue->setValue(_channel->vox());
}

extensionView->setObjectName("digitalChannelExtension");
extensionView->setObject(_myChannel);

if (! settings.showCommercialFeatures())
Expand Down
1 change: 1 addition & 0 deletions src/dmrcontactdialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ DMRContactDialog::construct() {
ui->numberLineEdit->setValidator(new QRegExpValidator(QRegExp("[0-9]+")));
ui->ringCheckBox->setChecked(_myContact->ring());

ui->extensionView->setObjectName("dmrContactExtension");
ui->extensionView->setObject(_myContact);
if (! settings.showCommercialFeatures())
ui->tabWidget->tabBar()->hide();
Expand Down
2 changes: 2 additions & 0 deletions src/dmriddialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ DMRIDDialog::construct() {

if (! settings.showCommercialFeatures())
ui->tabWidget->tabBar()->hide();

ui->extensionView->setObjectName("dmrRadioIdExtension");
ui->extensionView->setObject(_myID);
}

Expand Down
1 change: 1 addition & 0 deletions src/dtmfcontactdialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ DTMFContactDialog::construct() {
ui->numberLineEdit->setValidator(new QRegExpValidator(QRegExp("[0-9a-dA-D\\*#]+")));
ui->ringCheckBox->setChecked(_myContact->ring());

ui->extensionView->setObjectName("dtmfContactExtension");
ui->extensionView->setObject(_myContact);
if (! settings.showCommercialFeatures())
ui->tabWidget->tabBar()->hide();
Expand Down
17 changes: 17 additions & 0 deletions src/extensionview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "ui_extensionview.h"
#include "propertydelegate.hh"
#include "extensionwrapper.hh"
#include "settings.hh"
#include <QMessageBox>


Expand All @@ -21,6 +22,10 @@ ExtensionView::ExtensionView(QWidget *parent) :
this, SLOT(onSelectionChanged(QItemSelection,QItemSelection)));
connect(ui->create, SIGNAL(clicked(bool)), this, SLOT(onCreateExtension()));
connect(ui->remove, SIGNAL(clicked(bool)), this, SLOT(onDeleteExtension()));
connect(ui->view->header(), SIGNAL(sectionCountChanged(int,int)),
this, SLOT(loadSectionState()));
connect(ui->view->header(), SIGNAL(sectionResized(int,int,int)),
this, SLOT(storeSectionState()));
}

ExtensionView::~ExtensionView()
Expand Down Expand Up @@ -95,3 +100,15 @@ ExtensionView::onDeleteExtension() {
_model->deleteInstanceAt(item);
ui->view->selectionModel()->clearSelection();
}

void
ExtensionView::loadSectionState() {
Settings settings;
ui->view->header()->restoreState(settings.headerState(this->objectName()));
}

void
ExtensionView::storeSectionState() {
Settings settings;
settings.setHeaderState(this->objectName(), ui->view->header()->saveState());
}
2 changes: 2 additions & 0 deletions src/extensionview.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ protected slots:
void onSelectionChanged(const QItemSelection &current, const QItemSelection &last);
void onCreateExtension();
void onDeleteExtension();
void loadSectionState();
void storeSectionState();

private:
Ui::ExtensionView *ui;
Expand Down
1 change: 1 addition & 0 deletions src/generalsettingsview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ GeneralSettingsView::GeneralSettingsView(Config *config, QWidget *parent)
ui->totValue->setValue(config->settings()->tot());
ui->voxValue->setValue(config->settings()->vox());

ui->extensionView->setObjectName("radioSettingsExtension");
ui->extensionView->setObject(config->settings());

connect(_config, SIGNAL(modified(ConfigItem*)), this, SLOT(onConfigModified()));
Expand Down
1 change: 1 addition & 0 deletions src/gpssystemdialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ GPSSystemDialog::construct() {
i++;
}

extensionView->setObjectName("dmrAPRSSystemExtension");
extensionView->setObject(_myGPSSystem);
if (! settings.showCommercialFeatures())
return tabWidget->tabBar()->hide();
Expand Down
4 changes: 2 additions & 2 deletions src/positioningsystemlistview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ PositioningSystemListView::onHideGPSNote() {
void
PositioningSystemListView::loadPositioningSectionState() {
Settings settings;
ui->listView->header()->restoreState(settings.positioningHeaderState());
ui->listView->header()->restoreState(settings.headerState("positioningList"));
}
void
PositioningSystemListView::storePositioningSectionState() {
Settings settings;
settings.setPositioningHeaderState(ui->listView->header()->saveState());
settings.setHeaderState("positioningList", ui->listView->header()->saveState());
}

4 changes: 2 additions & 2 deletions src/radioidlistview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ RadioIDListView::onDefaultIDSelected(int idx) {

void
RadioIDListView::loadHeaderState() {
ui->listView->header()->restoreState(Settings().radioIdListHeaderState());
ui->listView->header()->restoreState(Settings().headerState("radioIDList"));
}
void
RadioIDListView::storeHeaderState() {
Settings().setRadioIdListHeaderState(ui->listView->header()->saveState());
Settings().setHeaderState("radioIDList", ui->listView->header()->saveState());
}


Expand Down
1 change: 1 addition & 0 deletions src/roamingzonedialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ RoamingZoneDialog::construct() {
zoneName->setText(_myZone->name());
channelListView->setModel(new ChannelRefListWrapper(_myZone->channels(), channelListView));

extensionView->setObjectName("roamingZoneExtension");
extensionView->setObject(_myZone);
if (! settings.showCommercialFeatures())
tabWidget->tabBar()->hide();
Expand Down
1 change: 1 addition & 0 deletions src/rxgrouplistdialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ RXGroupListDialog::construct() {
groupListName->setText(_myGroupList->name());
contactListView->setModel(new GroupListWrapper(_myGroupList, contactListView));

extensionView->setObjectName("groupListExtension");
extensionView->setObject(_myGroupList);
if (! settings.showCommercialFeatures())
tabWidget->tabBar()->hide();
Expand Down
1 change: 1 addition & 0 deletions src/scanlistdialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ ScanListDialog::construct() {

channelListView->setModel(new ChannelRefListWrapper(_myScanList->channels(), channelListView));

extensionView->setObjectName("scanListExtension");
extensionView->setObject(_myScanList);
if (! settings.showCommercialFeatures())
tabWidget->tabBar()->hide();
Expand Down
41 changes: 10 additions & 31 deletions src/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -288,39 +288,18 @@ Settings::setMainWindowState(const QByteArray &state) {
}

QByteArray
Settings::radioIdListHeaderState() const {
return value("radioIdListHeaderState", QByteArray()).toByteArray();
Settings::headerState(const QString &objName) const {
if (objName.isEmpty())
return QByteArray();
QString key = QString("headerState/%1").arg(objName);
return value(key, QByteArray()).toByteArray();
}
void
Settings::setRadioIdListHeaderState(const QByteArray &state) {
setValue("radioIdListHeaderState", state);
}

QByteArray
Settings::contactListHeaderState() const {
return value("contactListHeaderState", QByteArray()).toByteArray();
}
void
Settings::setContactListHeaderState(const QByteArray &state) {
setValue("contactListHeaderState", state);
}

QByteArray
Settings::channelListHeaderState() const {
return value("channelListHeaderState", QByteArray()).toByteArray();
}
void
Settings::setChannelListHeaderState(const QByteArray &state) {
setValue("channelListHeaderState", state);
}

QByteArray
Settings::positioningHeaderState() const {
return value("positioningHeaderState", QByteArray()).toByteArray();
}
void
Settings::setPositioningHeaderState(const QByteArray &state) {
setValue("positioningHeaderState", state);
Settings::setHeaderState(const QString &objName, const QByteArray &state) {
if (objName.isEmpty())
return;
QString key = QString("headerState/%1").arg(objName);
setValue(key, state);
}

bool
Expand Down
13 changes: 2 additions & 11 deletions src/settings.hh
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,8 @@ public:
QByteArray mainWindowState() const;
void setMainWindowState(const QByteArray &state);

QByteArray radioIdListHeaderState() const;
void setRadioIdListHeaderState(const QByteArray &state);

QByteArray contactListHeaderState() const;
void setContactListHeaderState(const QByteArray &state);

QByteArray channelListHeaderState() const;
void setChannelListHeaderState(const QByteArray &state);

QByteArray positioningHeaderState() const;
void setPositioningHeaderState(const QByteArray &state);
QByteArray headerState(const QString &objName) const;
void setHeaderState(const QString &objName, const QByteArray &state);

bool isUpdated() const;
void markUpdated();
Expand Down
1 change: 1 addition & 0 deletions src/zonedialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ZoneDialog::construct() {
listAView->setModel(new ChannelRefListWrapper(_myZone->A()));
listBView->setModel(new ChannelRefListWrapper(_myZone->B()));

extensionView->setObjectName("zoneExtension");
extensionView->setObject(_myZone);
if (! settings.showCommercialFeatures()) {
tabWidget->tabBar()->hide();
Expand Down

0 comments on commit 76bc9dd

Please sign in to comment.