fix warnings, update clang file

This commit is contained in:
Martin Rotter 2022-04-09 09:41:51 +02:00
parent ad4ffddf8d
commit 3e24129bf1
3 changed files with 105 additions and 109 deletions

View file

@ -26,8 +26,8 @@ AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros: AttributeMacros:
- __capability - __capability
BinPackArguments: true BinPackArguments: false
BinPackParameters: true BinPackParameters: false
BraceWrapping: BraceWrapping:
AfterCaseLabel: false AfterCaseLabel: false
AfterClass: false AfterClass: false
@ -124,11 +124,11 @@ PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300 PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120 PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0 PenaltyBreakOpenParenthesis: 5000
PenaltyBreakString: 1000 PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10 PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000 PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60 PenaltyReturnTypeOnItsOwnLine: 5000
PenaltyIndentedWhitespace: 0 PenaltyIndentedWhitespace: 0
PointerAlignment: Left PointerAlignment: Left
PPIndentWidth: -1 PPIndentWidth: -1

View file

@ -56,9 +56,9 @@ QModelIndex MessagesProxyModel::getNextImportantItemIndex(int default_row, int m
while (default_row <= max_row) { while (default_row <= max_row) {
// Get info if the message is read or not. // Get info if the message is read or not.
const QModelIndex proxy_index = index(default_row, MSG_DB_IMPORTANT_INDEX); const QModelIndex proxy_index = index(default_row, MSG_DB_IMPORTANT_INDEX);
const bool is_important = m_sourceModel->data(mapToSource(proxy_index).row(), const bool is_important =
MSG_DB_IMPORTANT_INDEX, m_sourceModel->data(mapToSource(proxy_index).row(), MSG_DB_IMPORTANT_INDEX, Qt::ItemDataRole::EditRole).toInt() ==
Qt::ItemDataRole::EditRole).toInt() == 1; 1;
if (!is_important) { if (!is_important) {
// We found unread message, mark it. // We found unread message, mark it.
@ -76,9 +76,8 @@ QModelIndex MessagesProxyModel::getNextUnreadItemIndex(int default_row, int max_
while (default_row <= max_row) { while (default_row <= max_row) {
// Get info if the message is read or not. // Get info if the message is read or not.
const QModelIndex proxy_index = index(default_row, MSG_DB_READ_INDEX); const QModelIndex proxy_index = index(default_row, MSG_DB_READ_INDEX);
const bool is_read = m_sourceModel->data(mapToSource(proxy_index).row(), const bool is_read =
MSG_DB_READ_INDEX, m_sourceModel->data(mapToSource(proxy_index).row(), MSG_DB_READ_INDEX, Qt::ItemDataRole::EditRole).toInt() == 1;
Qt::ItemDataRole::EditRole).toInt() == 1;
if (!is_read) { if (!is_read) {
// We found unread message, mark it. // We found unread message, mark it.
@ -102,72 +101,59 @@ bool MessagesProxyModel::lessThan(const QModelIndex& left, const QModelIndex& ri
bool MessagesProxyModel::filterAcceptsMessage(Message currentMessage) const { bool MessagesProxyModel::filterAcceptsMessage(Message currentMessage) const {
switch (m_filter) { switch (m_filter) {
case MessageListFilter::NoFiltering: case MessageListFilter::NoFiltering:
return true; return true;
case MessageListFilter::ShowUnread: case MessageListFilter::ShowUnread:
return !currentMessage.m_isRead; return !currentMessage.m_isRead;
case MessageListFilter::ShowImportant: case MessageListFilter::ShowImportant:
return currentMessage.m_isImportant; return currentMessage.m_isImportant;
case MessageListFilter::ShowToday: case MessageListFilter::ShowToday: {
{ const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDateTime currentDateTime = QDateTime::currentDateTime(); const QDate currentDate = currentDateTime.date();
const QDate currentDate = currentDateTime.date();
return return currentDate.startOfDay() <= currentMessage.m_created && currentMessage.m_created <= currentDate.endOfDay();
currentDate.startOfDay() <= currentMessage.m_created && }
currentMessage.m_created <= currentDate.endOfDay();
}
case MessageListFilter::ShowYesterday: case MessageListFilter::ShowYesterday: {
{ const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDateTime currentDateTime = QDateTime::currentDateTime(); const QDate currentDate = currentDateTime.date();
const QDate currentDate = currentDateTime.date();
return return currentDate.addDays(-1).startOfDay() <= currentMessage.m_created &&
currentDate.addDays(-1).startOfDay() <= currentMessage.m_created && currentMessage.m_created <= currentDate.addDays(-1).endOfDay();
currentMessage.m_created <= currentDate.addDays(-1).endOfDay(); }
}
case MessageListFilter::ShowLast24Hours: case MessageListFilter::ShowLast24Hours: {
{ const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDateTime currentDateTime = QDateTime::currentDateTime();
return return currentDateTime.addSecs(-24 * 60 * 60) <= currentMessage.m_created &&
currentDateTime.addSecs(-24 * 60 * 60) <= currentMessage.m_created && currentMessage.m_created <= currentDateTime;
currentMessage.m_created <= currentDateTime; }
}
case MessageListFilter::ShowLast48Hours: case MessageListFilter::ShowLast48Hours: {
{ const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDateTime currentDateTime = QDateTime::currentDateTime();
return return currentDateTime.addSecs(-48 * 60 * 60) <= currentMessage.m_created &&
currentDateTime.addSecs(-48 * 60 * 60) <= currentMessage.m_created && currentMessage.m_created <= currentDateTime;
currentMessage.m_created <= currentDateTime; }
}
case MessageListFilter::ShowThisWeek: case MessageListFilter::ShowThisWeek: {
{ const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDateTime currentDateTime = QDateTime::currentDateTime(); const QDate currentDate = currentDateTime.date();
const QDate currentDate = currentDateTime.date();
return return currentDate.year() == currentMessage.m_created.date().year() &&
currentDate.year() == currentMessage.m_created.date().year() && currentDate.weekNumber() == currentMessage.m_created.date().weekNumber();
currentDate.weekNumber() == currentMessage.m_created.date().weekNumber(); }
}
case MessageListFilter::ShowLastWeek: case MessageListFilter::ShowLastWeek: {
{ const QDateTime currentDateTime = QDateTime::currentDateTime();
const QDateTime currentDateTime = QDateTime::currentDateTime(); const QDate currentDate = currentDateTime.date();
const QDate currentDate = currentDateTime.date();
return return currentDate.addDays(-7).year() == currentMessage.m_created.date().year() &&
currentDate.addDays(-7).year() == currentMessage.m_created.date().year() && currentDate.addDays(-7).weekNumber() == currentMessage.m_created.date().weekNumber();
currentDate.addDays(-7).weekNumber() == currentMessage.m_created.date().weekNumber(); }
}
} }
return false; return false;
@ -180,10 +166,9 @@ bool MessagesProxyModel::filterAcceptsRow(int source_row, const QModelIndex& sou
// But also, we want to see messages which have their dirty states cached, because // But also, we want to see messages which have their dirty states cached, because
// otherwise they would just disappeaar from the list for example when batch marked as read // otherwise they would just disappeaar from the list for example when batch marked as read
// which is distracting. // which is distracting.
return return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent) &&
QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent) && (m_sourceModel->cache()->containsData(source_row) ||
(m_sourceModel->cache()->containsData(source_row) || filterAcceptsMessage(m_sourceModel->messageAt(source_row)));
filterAcceptsMessage(m_sourceModel->messageAt(source_row)));
} }
void MessagesProxyModel::setFilter(MessageListFilter filter) { void MessagesProxyModel::setFilter(MessageListFilter filter) {
@ -206,12 +191,15 @@ QModelIndexList MessagesProxyModel::mapListFromSource(const QModelIndexList& ind
return mapped_indexes; return mapped_indexes;
} }
QModelIndexList MessagesProxyModel::match(const QModelIndex& start, int role, QModelIndexList MessagesProxyModel::match(const QModelIndex& start,
const QVariant& entered_value, int hits, Qt::MatchFlags flags) const { int role,
const QVariant& entered_value,
int hits,
Qt::MatchFlags flags) const {
QModelIndexList result; QModelIndexList result;
const int match_type = flags & 0x0F; const int match_type = flags & 0x0F;
const Qt::CaseSensitivity case_sensitivity = Qt::CaseSensitivity::CaseInsensitive; const Qt::CaseSensitivity case_sensitivity = Qt::CaseSensitivity::CaseInsensitive;
const bool wrap = (flags& Qt::MatchFlag::MatchWrap) > 0; const bool wrap = (flags & Qt::MatchFlag::MatchWrap) > 0;
const bool all_hits = (hits == -1); const bool all_hits = (hits == -1);
QString entered_text; QString entered_text;
int from = start.row(); int from = start.row();
@ -244,55 +232,59 @@ QModelIndexList MessagesProxyModel::match(const QModelIndex& start, int role,
switch (match_type) { switch (match_type) {
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0 #if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
case Qt::MatchFlag::MatchRegularExpression: case Qt::MatchFlag::MatchRegularExpression:
#else #else
case Qt::MatchFlag::MatchRegExp: case Qt::MatchFlag::MatchRegExp:
#endif #endif
if (QRegularExpression(entered_text, if (QRegularExpression(entered_text,
QRegularExpression::PatternOption::CaseInsensitiveOption | QRegularExpression::PatternOption::CaseInsensitiveOption |
QRegularExpression::PatternOption::UseUnicodePropertiesOption).match(item_text).hasMatch()) { QRegularExpression::PatternOption::UseUnicodePropertiesOption)
result.append(idx); .match(item_text)
} .hasMatch()) {
result.append(idx);
}
break; break;
case Qt::MatchWildcard: case Qt::MatchWildcard:
if (QRegularExpression(RegexFactory::wildcardToRegularExpression(entered_text), if (QRegularExpression(RegexFactory::wildcardToRegularExpression(entered_text),
QRegularExpression::PatternOption::CaseInsensitiveOption | QRegularExpression::PatternOption::CaseInsensitiveOption |
QRegularExpression::PatternOption::UseUnicodePropertiesOption).match(item_text).hasMatch()) { QRegularExpression::PatternOption::UseUnicodePropertiesOption)
result.append(idx); .match(item_text)
} .hasMatch()) {
result.append(idx);
}
break; break;
case Qt::MatchStartsWith: case Qt::MatchStartsWith:
if (item_text.startsWith(entered_text, case_sensitivity)) { if (item_text.startsWith(entered_text, case_sensitivity)) {
result.append(idx); result.append(idx);
} }
break; break;
case Qt::MatchEndsWith: case Qt::MatchEndsWith:
if (item_text.endsWith(entered_text, case_sensitivity)) { if (item_text.endsWith(entered_text, case_sensitivity)) {
result.append(idx); result.append(idx);
} }
break; break;
case Qt::MatchFixedString: case Qt::MatchFixedString:
if (item_text.compare(entered_text, case_sensitivity) == 0) { if (item_text.compare(entered_text, case_sensitivity) == 0) {
result.append(idx); result.append(idx);
} }
break; break;
case Qt::MatchContains: case Qt::MatchContains:
default: default:
if (item_text.contains(entered_text, case_sensitivity)) { if (item_text.contains(entered_text, case_sensitivity)) {
result.append(idx); result.append(idx);
} }
break; break;
} }
} }
} }
@ -312,7 +304,8 @@ void MessagesProxyModel::sort(int column, Qt::SortOrder order) {
} }
QModelIndexList MessagesProxyModel::mapListToSource(const QModelIndexList& indexes) const { QModelIndexList MessagesProxyModel::mapListToSource(const QModelIndexList& indexes) const {
QModelIndexList source_indexes; source_indexes.reserve(indexes.size()); QModelIndexList source_indexes;
source_indexes.reserve(indexes.size());
for (const QModelIndex& index : indexes) { for (const QModelIndex& index : indexes) {
source_indexes << mapToSource(index); source_indexes << mapToSource(index);

View file

@ -9,10 +9,9 @@ class MessagesModel;
class Message; class Message;
class MessagesProxyModel : public QSortFilterProxyModel { class MessagesProxyModel : public QSortFilterProxyModel {
Q_OBJECT Q_OBJECT
public: public:
// Enum which describes basic filtering schemes // Enum which describes basic filtering schemes
// for messages. // for messages.
enum class MessageListFilter { enum class MessageListFilter {
@ -38,7 +37,11 @@ class MessagesProxyModel : public QSortFilterProxyModel {
QModelIndexList mapListFromSource(const QModelIndexList& indexes, bool deep = false) const; QModelIndexList mapListFromSource(const QModelIndexList& indexes, bool deep = false) const;
// Fix for matching indexes with respect to specifics of the message model. // 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; QModelIndexList match(const QModelIndex& start,
int role,
const QVariant& entered_value,
int hits,
Qt::MatchFlags flags) const;
// Performs sort of items. // Performs sort of items.
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);