Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix modified and main-window-close signals #532

Merged
merged 8 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 40 additions & 8 deletions lib/channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,91 +66,123 @@ Channel::copy(const ConfigItem &other) {
void
Channel::clear() {
ConfigObject::clear();
_rxFreq = Frequency::fromHz(0); _txFreq = Frequency::fromHz(0);

setRXFrequency(Frequency::fromHz(0));
setTXFrequency(Frequency::fromHz(0));
setDefaultPower();
setDefaultTimeout();
_rxOnly = false;
setRXOnly(false);
setVOXDefault();

_scanlist.clear();
if (_openGD77ChannelExtension)
_openGD77ChannelExtension->deleteLater();
_openGD77ChannelExtension = nullptr;
if (_tytChannelExtension)
_tytChannelExtension->deleteLater();
_tytChannelExtension = nullptr;

setOpenGD77ChannelExtension(nullptr);
setTyTChannelExtension(nullptr);
}


Frequency Channel::rxFrequency() const {
return _rxFreq;
}

bool
Channel::setRXFrequency(Frequency freq) {
if (freq == _rxFreq)
return true;

_rxFreq = freq;
emit modified(this);

return true;
}

Frequency
Channel::txFrequency() const {
return _txFreq;
}

bool
Channel::setTXFrequency(Frequency freq) {
if (freq == _txFreq)
return true;

_txFreq = freq;
emit modified(this);

return true;
}


bool
Channel::defaultPower() const {
return _defaultPower;
}

Channel::Power
Channel::power() const {
return _power;
}

void
Channel::setPower(Power power) {
if ((power == _power) && (! _defaultPower))
return;
_power = power;
_defaultPower = false;
emit modified(this);
}

void
Channel::setDefaultPower() {
if (defaultPower())
return;

_defaultPower = true;
emit modified(this);
}


bool
Channel::defaultTimeout() const {
return std::numeric_limits<unsigned>::max() == timeout();
}

bool
Channel::timeoutDisabled() const {
return 0 == timeout();
}

unsigned
Channel::timeout() const {
return _txTimeOut;
}

bool
Channel::setTimeout(unsigned dur) {
if (dur == _txTimeOut)
return true;

_txTimeOut = dur;
emit modified(this);

return true;
}

void
Channel::setDefaultTimeout() {
if (defaultTimeout())
return;

setTimeout(std::numeric_limits<unsigned>::max());
emit modified(this);
}

void
Channel::disableTimeout() {
setTimeout(0);
}


bool
Channel::rxOnly() const {
return _rxOnly;
Expand Down
3 changes: 3 additions & 0 deletions lib/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ Config::readCSV(QTextStream &stream, QString &errorMessage)
return true;
}


bool
Config::readYAML(const QString &filename, const ErrorStack &err) {
YAML::Node node;
Expand Down Expand Up @@ -364,9 +365,11 @@ Config::readYAML(const QString &filename, const ErrorStack &err) {
if (! link(node, context, err))
return false;

setModified(false);
return true;
}


bool
Config::parse(const YAML::Node &node, Context &ctx, const ErrorStack &err)
{
Expand Down
10 changes: 9 additions & 1 deletion lib/configobject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1323,12 +1323,15 @@ AbstractConfigObjectList::moveDown(int first, int last) {
return true;
}


bool
AbstractConfigObjectList::move(int source, int count, int destination) {
if ((0 == count) || (source == destination))
return true;

if ((source+count)>_items.size())
return false;

if (source > destination) {
// move up
for (int take=source, put=destination, i=0; i<count; i++, take++, put++)
Expand All @@ -1338,9 +1341,14 @@ AbstractConfigObjectList::move(int source, int count, int destination) {
for (int i=0; i<count; i++)
_items.insert(destination-1, _items.takeAt(source));
}

for (int i=0; i<count; i++)
emit elementModified(destination+i);

return true;
}


const QList<QMetaObject> &
AbstractConfigObjectList::elementTypes() const {
return _elementTypes;
Expand All @@ -1358,7 +1366,7 @@ AbstractConfigObjectList::classNames() const {
void
AbstractConfigObjectList::onElementModified(ConfigItem *obj) {
int idx = indexOf(obj->as<ConfigObject>());
if (0 >= idx)
if (0 <= idx)
emit elementModified(idx);
}

Expand Down
7 changes: 7 additions & 0 deletions lib/radiosettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ RadioSettings::setDefaultId(DMRRadioID *id) {
_defaultId->set(id);
}


TyTSettingsExtension *
RadioSettings::tytExtension() const {
return _tytExtension;
}

void
RadioSettings::setTyTExtension(TyTSettingsExtension *ext) {
if (_tytExtension) {
Expand All @@ -182,10 +184,12 @@ RadioSettings::setTyTExtension(TyTSettingsExtension *ext) {
emit modified(this);
}


RadiodditySettingsExtension *
RadioSettings::radioddityExtension() const {
return _radioddityExtension;
}

void
RadioSettings::setRadioddityExtension(RadiodditySettingsExtension *ext) {
if (_radioddityExtension) {
Expand All @@ -200,10 +204,12 @@ RadioSettings::setRadioddityExtension(RadiodditySettingsExtension *ext) {
emit modified(this);
}


AnytoneSettingsExtension *
RadioSettings::anytoneExtension() const {
return _anytoneExtension;
}

void
RadioSettings::setAnytoneExtension(AnytoneSettingsExtension *ext) {
if (_anytoneExtension) {
Expand All @@ -218,6 +224,7 @@ RadioSettings::setAnytoneExtension(AnytoneSettingsExtension *ext) {
emit modified(this);
}


void
RadioSettings::onExtensionModified() {
emit modified(this);
Expand Down
3 changes: 1 addition & 2 deletions shared/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
</qresource>
<qresource prefix="/ui">
<file alias="aboutdialog.ui">ui/aboutdialog.ui</file>
<file alias="mainwindow.ui">ui/mainwindow.ui</file>
</qresource>
<qresource prefix="/icons/aprs">
<file alias="table0.png">aprs/aprs-symbols-24-0.png</file>
Expand Down Expand Up @@ -112,7 +111,7 @@
<file alias="32x32/actions/edit-move-10-up.png">icons/dark/32x32/actions/edit-move-10-up.png</file>
<file alias="32x32/actions/edit-move-bottom.png">icons/dark/32x32/actions/edit-move-bottom.png</file>
<file alias="32x32/actions/edit-move-down.png">icons/dark/32x32/actions/edit-move-down.png</file>
<file alias="32x32/actions/edit-move-up.png">icons/dark/32x32/actions/edit-move-top.png</file>
<file alias="32x32/actions/edit-move-top.png">icons/dark/32x32/actions/edit-move-top.png</file>
<file alias="32x32/actions/edit-move-up.png">icons/dark/32x32/actions/edit-move-up.png</file>
<file alias="32x32/actions/help-about.png">icons/dark/32x32/actions/help-about.png</file>
<file alias="32x32/actions/help-contents.png">icons/dark/32x32/actions/help-contents.png</file>
Expand Down
12 changes: 8 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ SET(qdmr_SOURCES main.cc
configmergedialog.cc satellitedatabasedialog.cc satelliteselectiondialog.cc
repeaterdatabase.cc repeatercompleter.cc repeaterbooksource.cc repeatermapsource.cc
hearhamrepeatersource.cc radioidrepeatersource.cc selectivecallbox.cc
transponderfrequencydelegate.cc)
transponderfrequencydelegate.cc
mainwindow.cc)
SET(qdmr_MOC_HEADERS
configitemwrapper.hh
application.hh settings.hh dmrcontactdialog.hh dtmfcontactdialog.hh rxgrouplistdialog.hh
Expand All @@ -32,9 +33,11 @@ SET(qdmr_MOC_HEADERS
configmergedialog.hh satellitedatabasedialog.hh satelliteselectiondialog.hh
repeaterdatabase.hh repeatercompleter.hh repeaterbooksource.hh repeatermapsource.hh
hearhamrepeatersource.hh radioidrepeatersource.hh selectivecallbox.hh
transponderfrequencydelegate.hh)
transponderfrequencydelegate.hh
mainwindow.hh)
SET(qdmr_HEADERS )
SET(qdmr_UI_FORMS dmrcontactdialog.ui dtmfcontactdialog.ui rxgrouplistdialog.ui analogchanneldialog.ui zonedialog.ui
SET(qdmr_UI_FORMS dmrcontactdialog.ui dtmfcontactdialog.ui rxgrouplistdialog.ui
analogchanneldialog.ui zonedialog.ui
digitalchanneldialog.ui scanlistdialog.ui verifydialog.ui settingsdialog.ui
gpssystemdialog.ui aprssystemdialog.ui
roamingzonedialog.ui roamingchannellistview.ui roamingchanneldialog.ui
Expand All @@ -43,7 +46,8 @@ SET(qdmr_UI_FORMS dmrcontactdialog.ui dtmfcontactdialog.ui rxgrouplistdialog.ui
zonelistview.ui scanlistsview.ui positioningsystemlistview.ui roamingzonelistview.ui
errormessageview.ui extensionview.ui
deviceselectiondialog.ui radioselectiondialog.ui dmriddialog.ui configobjecttypeselectiondialog.ui
configmergedialog.ui satellitedatabasedialog.ui satelliteselectiondialog.ui)
configmergedialog.ui satellitedatabasedialog.ui satelliteselectiondialog.ui
mainwindow.ui)

set(qdmr_TS_FILES ../i18n/de.ts ../i18n/en_US.ts)
qt5_wrap_cpp(qdmr_MOC_SOURCES ${qdmr_MOC_HEADERS})
Expand Down
1 change: 1 addition & 0 deletions src/analogchanneldialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ AnalogChannelDialog::channel()
_channel->copy(*_myChannel);
channel = _channel;
}

return channel;
}

Expand Down
Loading
Loading