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.
@ -111,61 +110,48 @@ bool MessagesProxyModel::filterAcceptsMessage(Message currentMessage) const {
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();
} }
} }
@ -180,8 +166,7 @@ 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)));
} }
@ -206,8 +191,11 @@ 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;
@ -250,7 +238,9 @@ QModelIndexList MessagesProxyModel::match(const QModelIndex& start, int role,
#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)
.match(item_text)
.hasMatch()) {
result.append(idx); result.append(idx);
} }
@ -259,7 +249,9 @@ QModelIndexList MessagesProxyModel::match(const QModelIndex& start, int role,
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)
.match(item_text)
.hasMatch()) {
result.append(idx); result.append(idx);
} }
@ -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

@ -12,7 +12,6 @@ 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);