fix warnings, update clang file
This commit is contained in:
parent
ad4ffddf8d
commit
3e24129bf1
3 changed files with 105 additions and 109 deletions
|
@ -26,8 +26,8 @@ AlwaysBreakBeforeMultilineStrings: false
|
|||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
|
@ -124,11 +124,11 @@ PenaltyBreakAssignment: 2
|
|||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakOpenParenthesis: 5000
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PenaltyReturnTypeOnItsOwnLine: 5000
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PointerAlignment: Left
|
||||
PPIndentWidth: -1
|
||||
|
|
|
@ -56,9 +56,9 @@ QModelIndex MessagesProxyModel::getNextImportantItemIndex(int default_row, int m
|
|||
while (default_row <= max_row) {
|
||||
// Get info if the message is read or not.
|
||||
const QModelIndex proxy_index = index(default_row, MSG_DB_IMPORTANT_INDEX);
|
||||
const bool is_important = m_sourceModel->data(mapToSource(proxy_index).row(),
|
||||
MSG_DB_IMPORTANT_INDEX,
|
||||
Qt::ItemDataRole::EditRole).toInt() == 1;
|
||||
const bool is_important =
|
||||
m_sourceModel->data(mapToSource(proxy_index).row(), MSG_DB_IMPORTANT_INDEX, Qt::ItemDataRole::EditRole).toInt() ==
|
||||
1;
|
||||
|
||||
if (!is_important) {
|
||||
// We found unread message, mark it.
|
||||
|
@ -76,9 +76,8 @@ QModelIndex MessagesProxyModel::getNextUnreadItemIndex(int default_row, int max_
|
|||
while (default_row <= max_row) {
|
||||
// Get info if the message is read or not.
|
||||
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::ItemDataRole::EditRole).toInt() == 1;
|
||||
const bool is_read =
|
||||
m_sourceModel->data(mapToSource(proxy_index).row(), MSG_DB_READ_INDEX, Qt::ItemDataRole::EditRole).toInt() == 1;
|
||||
|
||||
if (!is_read) {
|
||||
// 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 {
|
||||
switch (m_filter) {
|
||||
case MessageListFilter::NoFiltering:
|
||||
return true;
|
||||
case MessageListFilter::NoFiltering:
|
||||
return true;
|
||||
|
||||
case MessageListFilter::ShowUnread:
|
||||
return !currentMessage.m_isRead;
|
||||
case MessageListFilter::ShowUnread:
|
||||
return !currentMessage.m_isRead;
|
||||
|
||||
case MessageListFilter::ShowImportant:
|
||||
return currentMessage.m_isImportant;
|
||||
case MessageListFilter::ShowImportant:
|
||||
return currentMessage.m_isImportant;
|
||||
|
||||
case MessageListFilter::ShowToday:
|
||||
{
|
||||
const QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
const QDate currentDate = currentDateTime.date();
|
||||
case MessageListFilter::ShowToday: {
|
||||
const QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
const QDate currentDate = currentDateTime.date();
|
||||
|
||||
return
|
||||
currentDate.startOfDay() <= currentMessage.m_created &&
|
||||
currentMessage.m_created <= currentDate.endOfDay();
|
||||
}
|
||||
return currentDate.startOfDay() <= currentMessage.m_created && currentMessage.m_created <= currentDate.endOfDay();
|
||||
}
|
||||
|
||||
case MessageListFilter::ShowYesterday:
|
||||
{
|
||||
const QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
const QDate currentDate = currentDateTime.date();
|
||||
case MessageListFilter::ShowYesterday: {
|
||||
const QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
const QDate currentDate = currentDateTime.date();
|
||||
|
||||
return
|
||||
currentDate.addDays(-1).startOfDay() <= currentMessage.m_created &&
|
||||
currentMessage.m_created <= currentDate.addDays(-1).endOfDay();
|
||||
}
|
||||
return currentDate.addDays(-1).startOfDay() <= currentMessage.m_created &&
|
||||
currentMessage.m_created <= currentDate.addDays(-1).endOfDay();
|
||||
}
|
||||
|
||||
case MessageListFilter::ShowLast24Hours:
|
||||
{
|
||||
const QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
case MessageListFilter::ShowLast24Hours: {
|
||||
const QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
|
||||
return
|
||||
currentDateTime.addSecs(-24 * 60 * 60) <= currentMessage.m_created &&
|
||||
currentMessage.m_created <= currentDateTime;
|
||||
}
|
||||
return currentDateTime.addSecs(-24 * 60 * 60) <= currentMessage.m_created &&
|
||||
currentMessage.m_created <= currentDateTime;
|
||||
}
|
||||
|
||||
case MessageListFilter::ShowLast48Hours:
|
||||
{
|
||||
const QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
case MessageListFilter::ShowLast48Hours: {
|
||||
const QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
|
||||
return
|
||||
currentDateTime.addSecs(-48 * 60 * 60) <= currentMessage.m_created &&
|
||||
currentMessage.m_created <= currentDateTime;
|
||||
}
|
||||
return currentDateTime.addSecs(-48 * 60 * 60) <= currentMessage.m_created &&
|
||||
currentMessage.m_created <= currentDateTime;
|
||||
}
|
||||
|
||||
case MessageListFilter::ShowThisWeek:
|
||||
{
|
||||
const QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
const QDate currentDate = currentDateTime.date();
|
||||
case MessageListFilter::ShowThisWeek: {
|
||||
const QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
const QDate currentDate = currentDateTime.date();
|
||||
|
||||
return
|
||||
currentDate.year() == currentMessage.m_created.date().year() &&
|
||||
currentDate.weekNumber() == currentMessage.m_created.date().weekNumber();
|
||||
}
|
||||
return currentDate.year() == currentMessage.m_created.date().year() &&
|
||||
currentDate.weekNumber() == currentMessage.m_created.date().weekNumber();
|
||||
}
|
||||
|
||||
case MessageListFilter::ShowLastWeek:
|
||||
{
|
||||
const QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
const QDate currentDate = currentDateTime.date();
|
||||
case MessageListFilter::ShowLastWeek: {
|
||||
const QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
const QDate currentDate = currentDateTime.date();
|
||||
|
||||
return
|
||||
currentDate.addDays(-7).year() == currentMessage.m_created.date().year() &&
|
||||
currentDate.addDays(-7).weekNumber() == currentMessage.m_created.date().weekNumber();
|
||||
}
|
||||
return currentDate.addDays(-7).year() == currentMessage.m_created.date().year() &&
|
||||
currentDate.addDays(-7).weekNumber() == currentMessage.m_created.date().weekNumber();
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
// otherwise they would just disappeaar from the list for example when batch marked as read
|
||||
// which is distracting.
|
||||
return
|
||||
QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent) &&
|
||||
(m_sourceModel->cache()->containsData(source_row) ||
|
||||
filterAcceptsMessage(m_sourceModel->messageAt(source_row)));
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent) &&
|
||||
(m_sourceModel->cache()->containsData(source_row) ||
|
||||
filterAcceptsMessage(m_sourceModel->messageAt(source_row)));
|
||||
}
|
||||
|
||||
void MessagesProxyModel::setFilter(MessageListFilter filter) {
|
||||
|
@ -206,12 +191,15 @@ QModelIndexList MessagesProxyModel::mapListFromSource(const QModelIndexList& ind
|
|||
return mapped_indexes;
|
||||
}
|
||||
|
||||
QModelIndexList MessagesProxyModel::match(const QModelIndex& start, int role,
|
||||
const QVariant& entered_value, int hits, Qt::MatchFlags flags) const {
|
||||
QModelIndexList MessagesProxyModel::match(const QModelIndex& start,
|
||||
int role,
|
||||
const QVariant& entered_value,
|
||||
int hits,
|
||||
Qt::MatchFlags flags) const {
|
||||
QModelIndexList result;
|
||||
const int match_type = flags & 0x0F;
|
||||
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);
|
||||
QString entered_text;
|
||||
int from = start.row();
|
||||
|
@ -244,55 +232,59 @@ QModelIndexList MessagesProxyModel::match(const QModelIndex& start, int role,
|
|||
|
||||
switch (match_type) {
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
case Qt::MatchFlag::MatchRegularExpression:
|
||||
case Qt::MatchFlag::MatchRegularExpression:
|
||||
#else
|
||||
case Qt::MatchFlag::MatchRegExp:
|
||||
case Qt::MatchFlag::MatchRegExp:
|
||||
#endif
|
||||
if (QRegularExpression(entered_text,
|
||||
QRegularExpression::PatternOption::CaseInsensitiveOption |
|
||||
QRegularExpression::PatternOption::UseUnicodePropertiesOption).match(item_text).hasMatch()) {
|
||||
result.append(idx);
|
||||
}
|
||||
if (QRegularExpression(entered_text,
|
||||
QRegularExpression::PatternOption::CaseInsensitiveOption |
|
||||
QRegularExpression::PatternOption::UseUnicodePropertiesOption)
|
||||
.match(item_text)
|
||||
.hasMatch()) {
|
||||
result.append(idx);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case Qt::MatchWildcard:
|
||||
if (QRegularExpression(RegexFactory::wildcardToRegularExpression(entered_text),
|
||||
QRegularExpression::PatternOption::CaseInsensitiveOption |
|
||||
QRegularExpression::PatternOption::UseUnicodePropertiesOption).match(item_text).hasMatch()) {
|
||||
result.append(idx);
|
||||
}
|
||||
case Qt::MatchWildcard:
|
||||
if (QRegularExpression(RegexFactory::wildcardToRegularExpression(entered_text),
|
||||
QRegularExpression::PatternOption::CaseInsensitiveOption |
|
||||
QRegularExpression::PatternOption::UseUnicodePropertiesOption)
|
||||
.match(item_text)
|
||||
.hasMatch()) {
|
||||
result.append(idx);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case Qt::MatchStartsWith:
|
||||
if (item_text.startsWith(entered_text, case_sensitivity)) {
|
||||
result.append(idx);
|
||||
}
|
||||
case Qt::MatchStartsWith:
|
||||
if (item_text.startsWith(entered_text, case_sensitivity)) {
|
||||
result.append(idx);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case Qt::MatchEndsWith:
|
||||
if (item_text.endsWith(entered_text, case_sensitivity)) {
|
||||
result.append(idx);
|
||||
}
|
||||
case Qt::MatchEndsWith:
|
||||
if (item_text.endsWith(entered_text, case_sensitivity)) {
|
||||
result.append(idx);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case Qt::MatchFixedString:
|
||||
if (item_text.compare(entered_text, case_sensitivity) == 0) {
|
||||
result.append(idx);
|
||||
}
|
||||
case Qt::MatchFixedString:
|
||||
if (item_text.compare(entered_text, case_sensitivity) == 0) {
|
||||
result.append(idx);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case Qt::MatchContains:
|
||||
default:
|
||||
if (item_text.contains(entered_text, case_sensitivity)) {
|
||||
result.append(idx);
|
||||
}
|
||||
case Qt::MatchContains:
|
||||
default:
|
||||
if (item_text.contains(entered_text, case_sensitivity)) {
|
||||
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 source_indexes; source_indexes.reserve(indexes.size());
|
||||
QModelIndexList source_indexes;
|
||||
source_indexes.reserve(indexes.size());
|
||||
|
||||
for (const QModelIndex& index : indexes) {
|
||||
source_indexes << mapToSource(index);
|
||||
|
|
|
@ -9,10 +9,9 @@ class MessagesModel;
|
|||
class Message;
|
||||
|
||||
class MessagesProxyModel : public QSortFilterProxyModel {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
// Enum which describes basic filtering schemes
|
||||
// for messages.
|
||||
enum class MessageListFilter {
|
||||
|
@ -38,7 +37,11 @@ class MessagesProxyModel : public QSortFilterProxyModel {
|
|||
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;
|
||||
QModelIndexList match(const QModelIndex& start,
|
||||
int role,
|
||||
const QVariant& entered_value,
|
||||
int hits,
|
||||
Qt::MatchFlags flags) const;
|
||||
|
||||
// Performs sort of items.
|
||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
||||
|
|
Loading…
Add table
Reference in a new issue