Save work.
This commit is contained in:
parent
32b6775c83
commit
112d5dcc28
@ -736,5 +736,3 @@ QList<Feed*> FeedsModel::allFeeds() const {
|
||||
QList<Category*> FeedsModel::allCategories() const {
|
||||
return m_rootItem->getSubTreeCategories();
|
||||
}
|
||||
|
||||
// TODO: pokračovat s const upravami v dalsi tride
|
||||
|
@ -49,13 +49,13 @@ FeedsProxyModel::~FeedsProxyModel() {
|
||||
|
||||
QModelIndexList FeedsProxyModel::match(const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const {
|
||||
QModelIndexList result;
|
||||
uint match_type = flags & 0x0F;
|
||||
Qt::CaseSensitivity cs = Qt::CaseInsensitive;
|
||||
bool recurse = flags & Qt::MatchRecursive;
|
||||
bool wrap = flags & Qt::MatchWrap;
|
||||
bool all_hits = (hits == -1);
|
||||
const uint match_type = flags & 0x0F;
|
||||
const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
|
||||
const bool recurse = flags & Qt::MatchRecursive;
|
||||
const bool wrap = flags & Qt::MatchWrap;
|
||||
const bool all_hits = (hits == -1);
|
||||
QString entered_text;
|
||||
QModelIndex p = parent(start);
|
||||
const QModelIndex p = parent(start);
|
||||
int from = start.row();
|
||||
int to = rowCount(p);
|
||||
|
||||
@ -139,8 +139,8 @@ QModelIndexList FeedsProxyModel::match(const QModelIndex &start, int role, const
|
||||
bool FeedsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const {
|
||||
if (left.isValid() && right.isValid()) {
|
||||
// Make necessary castings.
|
||||
RootItem *left_item = m_sourceModel->itemForIndex(left);
|
||||
RootItem *right_item = m_sourceModel->itemForIndex(right);
|
||||
const RootItem *left_item = m_sourceModel->itemForIndex(left);
|
||||
const RootItem *right_item = m_sourceModel->itemForIndex(right);
|
||||
|
||||
// NOTE: Here we want to accomplish that ALL
|
||||
// categories are queued one after another and all
|
||||
@ -189,13 +189,13 @@ bool FeedsProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
}
|
||||
|
||||
QModelIndex idx = m_sourceModel->index(source_row, 0, source_parent);
|
||||
const QModelIndex idx = m_sourceModel->index(source_row, 0, source_parent);
|
||||
|
||||
if (!idx.isValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RootItem *item = m_sourceModel->itemForIndex(idx);
|
||||
const RootItem *item = m_sourceModel->itemForIndex(idx);
|
||||
|
||||
if (item->kind() == RootItemKind::Bin || item->kind() == RootItemKind::ServiceRoot) {
|
||||
// Recycle bin is always displayed.
|
||||
@ -237,7 +237,7 @@ void FeedsProxyModel::setShowUnreadOnly(bool show_unread_only) {
|
||||
qApp->settings()->setValue(GROUP(Feeds), Feeds::ShowOnlyUnreadFeeds, show_unread_only);
|
||||
}
|
||||
|
||||
QModelIndexList FeedsProxyModel::mapListToSource(const QModelIndexList &indexes) {
|
||||
QModelIndexList FeedsProxyModel::mapListToSource(const QModelIndexList &indexes) const {
|
||||
QModelIndexList source_indexes;
|
||||
|
||||
foreach (const QModelIndex &index, indexes) {
|
||||
|
@ -33,7 +33,7 @@ class FeedsProxyModel : public QSortFilterProxyModel {
|
||||
virtual ~FeedsProxyModel();
|
||||
|
||||
// Access to the source model.
|
||||
inline FeedsModel *sourceModel() {
|
||||
inline FeedsModel *sourceModel() const {
|
||||
return m_sourceModel;
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ class FeedsProxyModel : public QSortFilterProxyModel {
|
||||
QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const;
|
||||
|
||||
// Maps list of indexes.
|
||||
QModelIndexList mapListToSource(const QModelIndexList &indexes);
|
||||
QModelIndexList mapListToSource(const QModelIndexList &indexes) const;
|
||||
|
||||
bool showUnreadOnly() const;
|
||||
void setShowUnreadOnly(bool show_unread_only);
|
||||
@ -63,7 +63,6 @@ class FeedsProxyModel : public QSortFilterProxyModel {
|
||||
|
||||
// Source model pointer.
|
||||
FeedsModel *m_sourceModel;
|
||||
|
||||
RootItem *m_selectedItem;
|
||||
bool m_showUnreadOnly;
|
||||
};
|
||||
|
@ -83,7 +83,6 @@ Message Message::fromSqlRecord(const QSqlRecord &record, bool *result) {
|
||||
|
||||
message.m_id = record.value(MSG_DB_ID_INDEX).toInt();
|
||||
message.m_isRead = record.value(MSG_DB_READ_INDEX).toBool();
|
||||
//message = record.value(MSG_DB_DELETED_INDEX).toInt();
|
||||
message.m_isImportant = record.value(MSG_DB_IMPORTANT_INDEX).toBool();
|
||||
message.m_feedId = record.value(MSG_DB_FEED_INDEX).toString();
|
||||
message.m_title = record.value(MSG_DB_TITLE_INDEX).toString();
|
||||
@ -91,7 +90,6 @@ Message Message::fromSqlRecord(const QSqlRecord &record, bool *result) {
|
||||
message.m_author = record.value(MSG_DB_AUTHOR_INDEX).toString();
|
||||
message.m_created = TextFactory::parseDateTime(record.value(MSG_DB_DCREATED_INDEX).value<qint64>());
|
||||
message.m_contents = record.value(MSG_DB_CONTENTS_INDEX).toString();
|
||||
//message = record.value(MSG_DB_PDELETED_INDEX).toInt();
|
||||
message.m_enclosures = Enclosures::decodeEnclosuresFromString(record.value(MSG_DB_ENCLOSURES_INDEX).toString());
|
||||
message.m_accountId = record.value(MSG_DB_ACCOUNT_ID_INDEX).toInt();
|
||||
message.m_customId = record.value(MSG_DB_CUSTOM_ID_INDEX).toString();
|
||||
|
@ -27,10 +27,11 @@
|
||||
|
||||
// Represents single enclosure.
|
||||
struct Enclosure {
|
||||
public:
|
||||
explicit Enclosure(const QString &url = QString(), const QString &mime = QString());
|
||||
|
||||
QString m_url;
|
||||
QString m_mimeType;
|
||||
|
||||
explicit Enclosure(const QString &url = QString(), const QString &mime = QString());
|
||||
};
|
||||
|
||||
// Represents single enclosure.
|
||||
|
@ -188,7 +188,7 @@ QVariant MessagesModel::data(const QModelIndex &idx, int role) const {
|
||||
}
|
||||
}
|
||||
else if (index_column == MSG_DB_AUTHOR_INDEX) {
|
||||
QString author_name = QSqlTableModel::data(idx, role).toString();
|
||||
const QString author_name = QSqlTableModel::data(idx, role).toString();
|
||||
|
||||
return author_name.isEmpty() ? "-" : author_name;
|
||||
}
|
||||
@ -220,7 +220,7 @@ QVariant MessagesModel::data(const QModelIndex &idx, int role) const {
|
||||
}
|
||||
|
||||
case Qt::DecorationRole: {
|
||||
int index_column = idx.column();
|
||||
const int index_column = idx.column();
|
||||
|
||||
if (index_column == MSG_DB_READ_INDEX) {
|
||||
return QSqlTableModel::data(idx).toInt() == 1 ? m_readIcon : m_unreadIcon;
|
||||
@ -281,12 +281,12 @@ bool MessagesModel::setMessageRead(int row_index, RootItem::ReadStatus read) {
|
||||
}
|
||||
|
||||
bool MessagesModel::switchMessageImportance(int row_index) {
|
||||
QModelIndex target_index = index(row_index, MSG_DB_IMPORTANT_INDEX);
|
||||
RootItem::Importance current_importance = (RootItem::Importance) data(target_index, Qt::EditRole).toInt();
|
||||
RootItem::Importance next_importance = current_importance == RootItem::Important ?
|
||||
RootItem::NotImportant : RootItem::Important;
|
||||
Message message = messageAt(row_index);
|
||||
QPair<Message,RootItem::Importance> pair(message, next_importance);
|
||||
const QModelIndex target_index = index(row_index, MSG_DB_IMPORTANT_INDEX);
|
||||
const RootItem::Importance current_importance = (RootItem::Importance) data(target_index, Qt::EditRole).toInt();
|
||||
const RootItem::Importance next_importance = current_importance == RootItem::Important ?
|
||||
RootItem::NotImportant : RootItem::Important;
|
||||
const Message message = messageAt(row_index);
|
||||
const QPair<Message,RootItem::Importance> pair(message, next_importance);
|
||||
|
||||
if (!m_selectedItem->getParentServiceRoot()->onBeforeSwitchMessageImportance(m_selectedItem,
|
||||
QList<QPair<Message,RootItem::Importance> >() << pair)) {
|
||||
@ -294,7 +294,7 @@ bool MessagesModel::switchMessageImportance(int row_index) {
|
||||
}
|
||||
|
||||
// Rewrite "visible" data in the model.
|
||||
bool working_change = setData(target_index, next_importance);
|
||||
const bool working_change = setData(target_index, next_importance);
|
||||
|
||||
if (!working_change) {
|
||||
// If rewriting in the model failed, then cancel all actions.
|
||||
@ -313,7 +313,6 @@ bool MessagesModel::switchMessageImportance(int row_index) {
|
||||
query_importance_msg.bindValue(QSL(":id"), message.m_id);
|
||||
query_importance_msg.bindValue(QSL(":important"), (int) next_importance);
|
||||
|
||||
|
||||
// Commit changes.
|
||||
if (query_importance_msg.exec()) {
|
||||
return m_selectedItem->getParentServiceRoot()->onAfterSwitchMessageImportance(m_selectedItem,
|
||||
@ -333,7 +332,7 @@ bool MessagesModel::switchBatchMessageImportance(const QModelIndexList &messages
|
||||
|
||||
// Obtain IDs of all desired messages.
|
||||
foreach (const QModelIndex &message, messages) {
|
||||
Message msg = messageAt(message.row());
|
||||
const Message msg = messageAt(message.row());
|
||||
RootItem::Importance message_importance = messageImportance((message.row()));
|
||||
|
||||
message_states.append(QPair<Message,RootItem::Importance>(msg, message_importance));
|
||||
@ -360,7 +359,7 @@ bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList &messages) {
|
||||
|
||||
// Obtain IDs of all desired messages.
|
||||
foreach (const QModelIndex &message, messages) {
|
||||
Message msg = messageAt(message.row());
|
||||
const Message msg = messageAt(message.row());
|
||||
|
||||
msgs.append(msg);
|
||||
message_ids.append(QString::number(msg.m_id));
|
||||
@ -427,7 +426,7 @@ bool MessagesModel::setBatchMessagesRestored(const QModelIndexList &messages) {
|
||||
|
||||
// Obtain IDs of all desired messages.
|
||||
foreach (const QModelIndex &message, messages) {
|
||||
Message msg = messageAt(message.row());
|
||||
const Message msg = messageAt(message.row());
|
||||
|
||||
msgs.append(msg);
|
||||
message_ids.append(QString::number(msg.m_id));
|
||||
|
@ -39,7 +39,7 @@ MessagesProxyModel::~MessagesProxyModel() {
|
||||
}
|
||||
|
||||
QModelIndex MessagesProxyModel::getNextPreviousUnreadItemIndex(int default_row) {
|
||||
bool started_from_zero = default_row == 0;
|
||||
const bool started_from_zero = default_row == 0;
|
||||
QModelIndex next_index = getNextUnreadItemIndex(default_row, rowCount() - 1);
|
||||
|
||||
// There is no next message, check previous.
|
||||
@ -50,12 +50,12 @@ QModelIndex MessagesProxyModel::getNextPreviousUnreadItemIndex(int default_row)
|
||||
return next_index;
|
||||
}
|
||||
|
||||
QModelIndex MessagesProxyModel::getNextUnreadItemIndex(int default_row, int max_row) {
|
||||
QModelIndex MessagesProxyModel::getNextUnreadItemIndex(int default_row, int max_row) const {
|
||||
while (default_row <= max_row) {
|
||||
// Get info if the message is read or not.
|
||||
QModelIndex proxy_index = index(default_row, MSG_DB_READ_INDEX);
|
||||
bool is_read = m_sourceModel->data(mapToSource(proxy_index).row(),
|
||||
MSG_DB_READ_INDEX, Qt::EditRole).toInt() == 1;
|
||||
const QModelIndex proxy_index = index(default_row, MSG_DB_READ_INDEX);
|
||||
const bool is_read = m_sourceModel->data(mapToSource(proxy_index).row(),
|
||||
MSG_DB_READ_INDEX, Qt::EditRole).toInt() == 1;
|
||||
|
||||
if (!is_read) {
|
||||
// We found unread message, mark it.
|
||||
@ -79,7 +79,7 @@ bool MessagesProxyModel::lessThan(const QModelIndex &left, const QModelIndex &ri
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndexList MessagesProxyModel::mapListFromSource(const QModelIndexList &indexes, bool deep) {
|
||||
QModelIndexList MessagesProxyModel::mapListFromSource(const QModelIndexList &indexes, bool deep) const {
|
||||
QModelIndexList mapped_indexes;
|
||||
|
||||
foreach (const QModelIndex &index, indexes) {
|
||||
@ -98,10 +98,10 @@ QModelIndexList MessagesProxyModel::mapListFromSource(const QModelIndexList &ind
|
||||
QModelIndexList MessagesProxyModel::match(const QModelIndex &start, int role,
|
||||
const QVariant &entered_value, int hits, Qt::MatchFlags flags) const {
|
||||
QModelIndexList result;
|
||||
uint match_type = flags & 0x0F;
|
||||
Qt::CaseSensitivity case_sensitivity = Qt::CaseInsensitive;
|
||||
bool wrap = flags & Qt::MatchWrap;
|
||||
bool all_hits = (hits == -1);
|
||||
const uint match_type = flags & 0x0F;
|
||||
const Qt::CaseSensitivity case_sensitivity = Qt::CaseInsensitive;
|
||||
const bool wrap = flags & Qt::MatchWrap;
|
||||
const bool all_hits = (hits == -1);
|
||||
QString entered_text;
|
||||
int from = start.row();
|
||||
int to = rowCount();
|
||||
@ -179,7 +179,7 @@ QModelIndexList MessagesProxyModel::match(const QModelIndex &start, int role,
|
||||
return result;
|
||||
}
|
||||
|
||||
QModelIndexList MessagesProxyModel::mapListToSource(const QModelIndexList &indexes) {
|
||||
QModelIndexList MessagesProxyModel::mapListToSource(const QModelIndexList &indexes) const {
|
||||
QModelIndexList source_indexes;
|
||||
|
||||
foreach (const QModelIndex &index, indexes) {
|
||||
|
@ -39,14 +39,14 @@ class MessagesProxyModel : public QSortFilterProxyModel {
|
||||
QModelIndex getNextPreviousUnreadItemIndex(int default_row);
|
||||
|
||||
// Maps list of indexes.
|
||||
QModelIndexList mapListToSource(const QModelIndexList &indexes);
|
||||
QModelIndexList mapListFromSource(const QModelIndexList &indexes, bool deep = false);
|
||||
QModelIndexList mapListToSource(const QModelIndexList &indexes) const;
|
||||
QModelIndexList mapListFromSource(const QModelIndexList &indexes, bool deep = false) const;
|
||||
|
||||
// Fix for matching indexes with respect to specifics of the message model.
|
||||
QModelIndexList match(const QModelIndex &start, int role, const QVariant &entered_value, int hits, Qt::MatchFlags flags) const;
|
||||
|
||||
private:
|
||||
QModelIndex getNextUnreadItemIndex(int default_row, int max_row);
|
||||
QModelIndex getNextUnreadItemIndex(int default_row, int max_row) const;
|
||||
|
||||
// Compares two rows of data.
|
||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
||||
|
@ -30,7 +30,7 @@ DynamicShortcuts::DynamicShortcuts() {
|
||||
void DynamicShortcuts::save(const QList<QAction*> actions) {
|
||||
Settings *settings = qApp->settings();
|
||||
|
||||
foreach (QAction *action, actions) {
|
||||
foreach (const QAction *action, actions) {
|
||||
settings->setValue(GROUP(Keyboard), action->objectName(), action->shortcut().toString(QKeySequence::PortableText));
|
||||
}
|
||||
}
|
||||
|
@ -40,12 +40,12 @@ DynamicShortcutsWidget::~DynamicShortcutsWidget() {
|
||||
delete m_layout;
|
||||
}
|
||||
|
||||
bool DynamicShortcutsWidget::areShortcutsUnique() {
|
||||
bool DynamicShortcutsWidget::areShortcutsUnique() const {
|
||||
QList<QKeySequence> all_shortcuts;
|
||||
|
||||
// Obtain all shortcuts.
|
||||
foreach (const ActionBinding &binding, m_actionBindings) {
|
||||
QKeySequence new_shortcut = binding.second->shortcut();
|
||||
const QKeySequence new_shortcut = binding.second->shortcut();
|
||||
|
||||
if (!new_shortcut.isEmpty() && all_shortcuts.contains(new_shortcut)) {
|
||||
// Problem, two identical non-empty shortcuts found.
|
||||
|
@ -42,7 +42,7 @@ class DynamicShortcutsWidget : public QWidget {
|
||||
|
||||
// Returns true if all shortcuts are unique,
|
||||
// otherwise false.
|
||||
bool areShortcutsUnique();
|
||||
bool areShortcutsUnique() const;
|
||||
|
||||
// Populates this widget with shortcut widgets for given actions.
|
||||
// NOTE: This gets initial shortcut for each action from its properties, NOT from
|
||||
|
@ -65,7 +65,7 @@ void ShortcutButton::keyPressEvent(QKeyEvent *event) {
|
||||
m_catcher->doneRecording();
|
||||
}
|
||||
|
||||
Qt::KeyboardModifiers new_modifiers = event->modifiers() & (Qt::SHIFT | Qt::CTRL | Qt::ALT | Qt::META);
|
||||
const Qt::KeyboardModifiers new_modifiers = event->modifiers() & (Qt::SHIFT | Qt::CTRL | Qt::ALT | Qt::META);
|
||||
|
||||
if (!m_catcher->m_isRecording && (pressed_key == Qt::Key_Return || pressed_key == Qt::Key_Space)) {
|
||||
return;
|
||||
@ -129,7 +129,7 @@ void ShortcutButton::keyReleaseEvent(QKeyEvent *event) {
|
||||
|
||||
event->accept();
|
||||
|
||||
Qt::KeyboardModifiers new_modifiers = event->modifiers() &
|
||||
const Qt::KeyboardModifiers new_modifiers = event->modifiers() &
|
||||
(Qt::SHIFT | Qt::CTRL | Qt::ALT | Qt::META);
|
||||
|
||||
if (((uint) new_modifiers & m_catcher->m_modifierKeys) < m_catcher->m_modifierKeys) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user