Some more fixes.
This commit is contained in:
parent
2e6ab8dde7
commit
df463338e6
@ -1,3 +1,20 @@
|
|||||||
|
// This file is part of RSS Guard.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
|
||||||
|
//
|
||||||
|
// RSS Guard is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// RSS Guard is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "core/feedsselection.h"
|
#include "core/feedsselection.h"
|
||||||
|
|
||||||
#include "core/feedsmodelrootitem.h"
|
#include "core/feedsmodelrootitem.h"
|
||||||
@ -15,21 +32,21 @@ FeedsSelection::FeedsSelection(const FeedsSelection &other) {
|
|||||||
FeedsSelection::~FeedsSelection() {
|
FeedsSelection::~FeedsSelection() {
|
||||||
}
|
}
|
||||||
|
|
||||||
FeedsSelection::MessageMode FeedsSelection::mode() {
|
FeedsSelection::SelectionMode FeedsSelection::mode() {
|
||||||
if (m_selectedItem == NULL) {
|
if (m_selectedItem == NULL) {
|
||||||
return MessageMode::NoMode;
|
return SelectionMode::NoMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (m_selectedItem->kind()) {
|
switch (m_selectedItem->kind()) {
|
||||||
case FeedsModelRootItem::RecycleBin:
|
case FeedsModelRootItem::RecycleBin:
|
||||||
return MessageMode::MessagesFromRecycleBin;
|
return SelectionMode::MessagesFromRecycleBin;
|
||||||
|
|
||||||
case FeedsModelRootItem::Category:
|
case FeedsModelRootItem::Category:
|
||||||
case FeedsModelRootItem::Feed:
|
case FeedsModelRootItem::Feed:
|
||||||
return MessageMode::MessagesFromFeeds;
|
return SelectionMode::MessagesFromFeeds;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return MessageMode::NoMode;
|
return SelectionMode::NoMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
// This file is part of RSS Guard.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
|
||||||
|
//
|
||||||
|
// RSS Guard is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// RSS Guard is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#ifndef FEEDSSELECTION_H
|
#ifndef FEEDSSELECTION_H
|
||||||
#define FEEDSSELECTION_H
|
#define FEEDSSELECTION_H
|
||||||
|
|
||||||
@ -9,7 +26,7 @@ class FeedsModelRootItem;
|
|||||||
|
|
||||||
class FeedsSelection {
|
class FeedsSelection {
|
||||||
public:
|
public:
|
||||||
enum MessageMode {
|
enum SelectionMode {
|
||||||
NoMode,
|
NoMode,
|
||||||
MessagesFromFeeds,
|
MessagesFromFeeds,
|
||||||
MessagesFromRecycleBin
|
MessagesFromRecycleBin
|
||||||
@ -19,7 +36,7 @@ class FeedsSelection {
|
|||||||
FeedsSelection(const FeedsSelection &other);
|
FeedsSelection(const FeedsSelection &other);
|
||||||
virtual ~FeedsSelection();
|
virtual ~FeedsSelection();
|
||||||
|
|
||||||
MessageMode mode();
|
SelectionMode mode();
|
||||||
FeedsModelRootItem *selectedItem() const;
|
FeedsModelRootItem *selectedItem() const;
|
||||||
QString generateListOfIds();
|
QString generateListOfIds();
|
||||||
|
|
||||||
@ -27,6 +44,6 @@ class FeedsSelection {
|
|||||||
FeedsModelRootItem *m_selectedItem;
|
FeedsModelRootItem *m_selectedItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(FeedsSelection::MessageMode)
|
Q_DECLARE_METATYPE(FeedsSelection::SelectionMode)
|
||||||
|
|
||||||
#endif // FEEDSSELECTION_H
|
#endif // FEEDSSELECTION_H
|
||||||
|
@ -170,7 +170,6 @@ QVariant MessagesModel::data(const QModelIndex &idx, int role) const {
|
|||||||
if (m_customDateFormat.isEmpty()) {
|
if (m_customDateFormat.isEmpty()) {
|
||||||
return TextFactory::parseDateTime(QSqlTableModel::data(idx,
|
return TextFactory::parseDateTime(QSqlTableModel::data(idx,
|
||||||
role).value<qint64>()).toLocalTime().toString(Qt::DefaultLocaleShortDate);
|
role).value<qint64>()).toLocalTime().toString(Qt::DefaultLocaleShortDate);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return TextFactory::parseDateTime(QSqlTableModel::data(idx, role).value<qint64>()).toLocalTime().toString(m_customDateFormat);
|
return TextFactory::parseDateTime(QSqlTableModel::data(idx, role).value<qint64>()).toLocalTime().toString(m_customDateFormat);
|
||||||
@ -181,11 +180,6 @@ QVariant MessagesModel::data(const QModelIndex &idx, int role) const {
|
|||||||
|
|
||||||
return author_name.isEmpty() ? "-" : author_name;
|
return author_name.isEmpty() ? "-" : author_name;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
else if (index_column == MSG_DB_ID_INDEX) {
|
|
||||||
return QSqlTableModel::data(index(idx.row(), MSG_DB_TITLE_INDEX, idx.parent()));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
else if (index_column != MSG_DB_IMPORTANT_INDEX && index_column != MSG_DB_READ_INDEX) {
|
else if (index_column != MSG_DB_IMPORTANT_INDEX && index_column != MSG_DB_READ_INDEX) {
|
||||||
return QSqlTableModel::data(idx, role);
|
return QSqlTableModel::data(idx, role);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ class MessagesModel : public QSqlTableModel {
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
// Emitted if some persistent change is made which affects count of "unread/all" messages.
|
// Emitted if some persistent change is made which affects count of "unread/all" messages.
|
||||||
void messageCountsChanged(FeedsSelection::MessageMode mode, bool total_msg_count_changed, bool any_msg_restored);
|
void messageCountsChanged(FeedsSelection::SelectionMode mode, bool total_msg_count_changed, bool any_msg_restored);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Sets up header data.
|
// Sets up header data.
|
||||||
|
@ -200,8 +200,8 @@ void FeedMessageViewer::createConnections() {
|
|||||||
connect(m_feedsView, SIGNAL(feedsSelected(FeedsSelection)), m_messagesView, SLOT(loadFeeds(FeedsSelection)));
|
connect(m_feedsView, SIGNAL(feedsSelected(FeedsSelection)), m_messagesView, SLOT(loadFeeds(FeedsSelection)));
|
||||||
|
|
||||||
// If user changes status of some messages, recalculate message counts.
|
// If user changes status of some messages, recalculate message counts.
|
||||||
connect(m_messagesView->sourceModel(), SIGNAL(messageCountsChanged(FeedsSelection::MessageMode,bool,bool)),
|
connect(m_messagesView->sourceModel(), SIGNAL(messageCountsChanged(FeedsSelection::SelectionMode,bool,bool)),
|
||||||
m_feedsView, SLOT(receiveMessageCountsChange(FeedsSelection::MessageMode,bool,bool)));
|
m_feedsView, SLOT(receiveMessageCountsChange(FeedsSelection::SelectionMode,bool,bool)));
|
||||||
|
|
||||||
// State of many messages is changed, then we need
|
// State of many messages is changed, then we need
|
||||||
// to reload selections.
|
// to reload selections.
|
||||||
|
@ -310,7 +310,7 @@ void FeedsView::editFeed(FeedsModelFeed *feed) {
|
|||||||
delete form_pointer.data();
|
delete form_pointer.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::receiveMessageCountsChange(FeedsSelection::MessageMode mode,
|
void FeedsView::receiveMessageCountsChange(FeedsSelection::SelectionMode mode,
|
||||||
bool total_msg_count_changed,
|
bool total_msg_count_changed,
|
||||||
bool any_msg_restored) {
|
bool any_msg_restored) {
|
||||||
// If the change came from recycle bin mode, then:
|
// If the change came from recycle bin mode, then:
|
||||||
|
@ -117,7 +117,7 @@ class FeedsView : public QTreeView {
|
|||||||
|
|
||||||
// Is called when counts of messages are changed externally,
|
// Is called when counts of messages are changed externally,
|
||||||
// typically from message view.
|
// typically from message view.
|
||||||
void receiveMessageCountsChange(FeedsSelection::MessageMode mode, bool total_msg_count_changed, bool any_msg_restored);
|
void receiveMessageCountsChange(FeedsSelection::SelectionMode mode, bool total_msg_count_changed, bool any_msg_restored);
|
||||||
|
|
||||||
// Reloads counts for selected feeds.
|
// Reloads counts for selected feeds.
|
||||||
void updateCountsOfSelectedFeeds(bool update_total_too);
|
void updateCountsOfSelectedFeeds(bool update_total_too);
|
||||||
|
@ -202,7 +202,10 @@ void DownloadItem::stop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DownloadItem::openFile() {
|
void DownloadItem::openFile() {
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(m_output.fileName()));
|
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(m_output.fileName()))) {
|
||||||
|
MessageBox::show(this, QMessageBox::Warning, tr("Cannot open file"), tr("Cannot open output file. Open it manually."),
|
||||||
|
QString(), QDir::toNativeSeparators(m_output.fileName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadItem::openFolder() {
|
void DownloadItem::openFolder() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user