Merge branch 'master' of github.com:martinrotter/rssguard into master

This commit is contained in:
Martin Rotter 2020-11-04 07:19:33 +01:00
commit abbeb9f968
6 changed files with 24 additions and 15 deletions

View File

@ -50,7 +50,7 @@ void LabelsMenu::keyPressEvent(QKeyEvent* event) {
LabelAction* act = qobject_cast<LabelAction*>(activeAction());
if (act != nullptr && event->key() == Qt::Key::Key_Space) {
act->toggle();
act->toggleCheckState();
}
NonClosableMenu::keyPressEvent(event);
@ -60,10 +60,11 @@ void LabelsMenu::mousePressEvent(QMouseEvent* event) {
LabelAction* act = qobject_cast<LabelAction*>(activeAction());
if (act != nullptr) {
act->toggle();
act->toggleCheckState();
}
else {
NonClosableMenu::mousePressEvent(event);
}
NonClosableMenu::mousePressEvent(event);
}
void LabelsMenu::changeLabelAssignment(Qt::CheckState state) {
@ -121,7 +122,7 @@ Label* LabelAction::label() const {
return m_label;
}
void LabelAction::toggle() {
void LabelAction::toggleCheckState() {
if (m_checkState == Qt::CheckState::Unchecked) {
setCheckState(Qt::CheckState::Checked);
}

View File

@ -42,7 +42,7 @@ class LabelAction : public QAction {
Label* label() const;
public slots:
void toggle();
void toggleCheckState();
signals:
void checkStateChanged(Qt::CheckState state);

View File

@ -15,7 +15,14 @@ void NonClosableMenu::keyPressEvent(QKeyEvent* event) {
}
void NonClosableMenu::mousePressEvent(QMouseEvent* event) {
Q_UNUSED(event)
auto* act = dynamic_cast<QAction*>(activeAction());
if (act != nullptr) {
act->toggle();
}
else {
QMenu::mousePressEvent(event);
}
}
void NonClosableMenu::mouseReleaseEvent(QMouseEvent* event) {

View File

@ -4,7 +4,7 @@
#include <QHeaderView>
TreeViewColumnsMenu::TreeViewColumnsMenu(QHeaderView* parent) : QMenu(parent) {
TreeViewColumnsMenu::TreeViewColumnsMenu(QHeaderView* parent) : NonClosableMenu(parent) {
connect(this, &TreeViewColumnsMenu::aboutToShow, this, &TreeViewColumnsMenu::prepareMenu);
}
@ -17,6 +17,7 @@ void TreeViewColumnsMenu::prepareMenu() {
act->setData(i);
act->setCheckable(true);
act->setChecked(!header_view->isSectionHidden(i));
connect(act, &QAction::toggled, this, &TreeViewColumnsMenu::actionTriggered);
}
}

View File

@ -3,11 +3,11 @@
#ifndef TREEVIEWCOLUMNSMENU_H
#define TREEVIEWCOLUMNSMENU_H
#include <QMenu>
#include "gui/nonclosablemenu.h"
class QHeaderView;
class TreeViewColumnsMenu : public QMenu {
class TreeViewColumnsMenu : public NonClosableMenu {
public:
explicit TreeViewColumnsMenu(QHeaderView* parent);

View File

@ -1130,13 +1130,13 @@ bool DatabaseQueries::deleteAccount(const QSqlDatabase& db, int account_id) {
query.setForwardOnly(true);
QStringList queries;
queries << QSL("DELETE FROM Messages WHERE account_id = :account_id;")
queries << QSL("DELETE FROM MessageFiltersInFeeds WHERE account_id = :account_id;")
<< QSL("DELETE FROM LabelsInMessages WHERE account_id = :account_id;")
<< QSL("DELETE FROM Messages WHERE account_id = :account_id;")
<< QSL("DELETE FROM Feeds WHERE account_id = :account_id;")
<< QSL("DELETE FROM Categories WHERE account_id = :account_id;")
<< QSL("DELETE FROM MessageFiltersInFeeds WHERE account_id = :account_id;")
<< QSL("DELETE FROM Accounts WHERE id = :account_id;")
<< QSL("DELETE FROM LabelsInMessages WHERE account_id = :account_id;")
<< QSL("DELETE FROM Labels WHERE account_id = :account_id;");
<< QSL("DELETE FROM Labels WHERE account_id = :account_id;")
<< QSL("DELETE FROM Accounts WHERE id = :account_id;");
for (const QString& q : queries) {
query.prepare(q);