Some more fixes.

This commit is contained in:
Martin Rotter 2015-05-02 20:00:04 +02:00
parent 2e6ab8dde7
commit df463338e6
8 changed files with 51 additions and 20 deletions

View File

@ -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/feedsmodelrootitem.h"
@ -15,21 +32,21 @@ FeedsSelection::FeedsSelection(const FeedsSelection &other) {
FeedsSelection::~FeedsSelection() {
}
FeedsSelection::MessageMode FeedsSelection::mode() {
FeedsSelection::SelectionMode FeedsSelection::mode() {
if (m_selectedItem == NULL) {
return MessageMode::NoMode;
return SelectionMode::NoMode;
}
switch (m_selectedItem->kind()) {
case FeedsModelRootItem::RecycleBin:
return MessageMode::MessagesFromRecycleBin;
return SelectionMode::MessagesFromRecycleBin;
case FeedsModelRootItem::Category:
case FeedsModelRootItem::Feed:
return MessageMode::MessagesFromFeeds;
return SelectionMode::MessagesFromFeeds;
default:
return MessageMode::NoMode;
return SelectionMode::NoMode;
}
}

View File

@ -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
#define FEEDSSELECTION_H
@ -9,7 +26,7 @@ class FeedsModelRootItem;
class FeedsSelection {
public:
enum MessageMode {
enum SelectionMode {
NoMode,
MessagesFromFeeds,
MessagesFromRecycleBin
@ -19,7 +36,7 @@ class FeedsSelection {
FeedsSelection(const FeedsSelection &other);
virtual ~FeedsSelection();
MessageMode mode();
SelectionMode mode();
FeedsModelRootItem *selectedItem() const;
QString generateListOfIds();
@ -27,6 +44,6 @@ class FeedsSelection {
FeedsModelRootItem *m_selectedItem;
};
Q_DECLARE_METATYPE(FeedsSelection::MessageMode)
Q_DECLARE_METATYPE(FeedsSelection::SelectionMode)
#endif // FEEDSSELECTION_H

View File

@ -170,7 +170,6 @@ QVariant MessagesModel::data(const QModelIndex &idx, int role) const {
if (m_customDateFormat.isEmpty()) {
return TextFactory::parseDateTime(QSqlTableModel::data(idx,
role).value<qint64>()).toLocalTime().toString(Qt::DefaultLocaleShortDate);
}
else {
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;
}
/*
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) {
return QSqlTableModel::data(idx, role);
}

View File

@ -138,7 +138,7 @@ class MessagesModel : public QSqlTableModel {
signals:
// 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:
// Sets up header data.

View File

@ -200,8 +200,8 @@ void FeedMessageViewer::createConnections() {
connect(m_feedsView, SIGNAL(feedsSelected(FeedsSelection)), m_messagesView, SLOT(loadFeeds(FeedsSelection)));
// If user changes status of some messages, recalculate message counts.
connect(m_messagesView->sourceModel(), SIGNAL(messageCountsChanged(FeedsSelection::MessageMode,bool,bool)),
m_feedsView, SLOT(receiveMessageCountsChange(FeedsSelection::MessageMode,bool,bool)));
connect(m_messagesView->sourceModel(), SIGNAL(messageCountsChanged(FeedsSelection::SelectionMode,bool,bool)),
m_feedsView, SLOT(receiveMessageCountsChange(FeedsSelection::SelectionMode,bool,bool)));
// State of many messages is changed, then we need
// to reload selections.

View File

@ -310,7 +310,7 @@ void FeedsView::editFeed(FeedsModelFeed *feed) {
delete form_pointer.data();
}
void FeedsView::receiveMessageCountsChange(FeedsSelection::MessageMode mode,
void FeedsView::receiveMessageCountsChange(FeedsSelection::SelectionMode mode,
bool total_msg_count_changed,
bool any_msg_restored) {
// If the change came from recycle bin mode, then:

View File

@ -117,7 +117,7 @@ class FeedsView : public QTreeView {
// Is called when counts of messages are changed externally,
// 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.
void updateCountsOfSelectedFeeds(bool update_total_too);

View File

@ -202,7 +202,10 @@ void DownloadItem::stop() {
}
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() {