modernize: Use auto where the type is clear from context
[quassel.git] / src / qtui / chatlinemodelitem.cpp
index 5582fe8..1451858 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2016 by the Quassel Project                        *
+ *   Copyright (C) 2005-2018 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
 
 // This Struct is taken from Harfbuzz. We use it only to calc it's size.
 // we use a shared memory region so we do not have to malloc a buffer area for every line
-typedef struct {
+using HB_CharAttributes_Dummy = struct {
     /*HB_LineBreakType*/ unsigned lineBreakType  : 2;
     /*HB_Bool*/ unsigned whiteSpace              : 1;     /* A unicode whitespace character, except NBSP, ZWNBSP */
     /*HB_Bool*/ unsigned charStop                : 1;     /* Valid cursor position (for left/right arrow) */
     /*HB_Bool*/ unsigned wordBoundary            : 1;
     /*HB_Bool*/ unsigned sentenceBoundary        : 1;
     unsigned unused                  : 2;
-} HB_CharAttributes_Dummy;
+};
 
 unsigned char *ChatLineModelItem::TextBoundaryFinderBuffer = (unsigned char *)malloc(512 * sizeof(HB_CharAttributes_Dummy));
 int ChatLineModelItem::TextBoundaryFinderBufferSize = 512 * (sizeof(HB_CharAttributes_Dummy) / sizeof(unsigned char));
@@ -65,7 +65,7 @@ bool ChatLineModelItem::setData(int column, const QVariant &value, int role)
 {
     switch (role) {
     case MessageModel::FlagsRole:
-        _styledMsg.setFlags((Message::Flags)value.toUInt());
+        _styledMsg.setFlags((Message::Flags)value.toInt());
         return true;
     default:
         return MessageModelItem::setData(column, value, role);
@@ -79,7 +79,7 @@ QVariant ChatLineModelItem::data(int column, int role) const
         return QVariant::fromValue<UiStyle::MessageLabel>(messageLabel());
 
     QVariant variant;
-    MessageModel::ColumnType col = (MessageModel::ColumnType)column;
+    auto col = (MessageModel::ColumnType)column;
     switch (col) {
     case ChatLineModel::TimestampColumn:
         variant = timestampData(role);
@@ -111,7 +111,7 @@ QVariant ChatLineModelItem::timestampData(int role) const
     case ChatLineModel::SelectedBackgroundRole:
         return backgroundBrush(UiStyle::FormatType::Timestamp, true);
     case ChatLineModel::FormatRole:
-        return QVariant::fromValue<UiStyle::FormatList>({std::make_pair(quint16{0}, UiStyle::Format{UiStyle::formatType(_styledMsg.type()) | UiStyle::FormatType::Timestamp})});
+        return QVariant::fromValue<UiStyle::FormatList>({std::make_pair(quint16{0}, UiStyle::Format{UiStyle::formatType(_styledMsg.type()) | UiStyle::FormatType::Timestamp, {}, {}})});
     }
     return QVariant();
 }
@@ -129,7 +129,7 @@ QVariant ChatLineModelItem::senderData(int role) const
     case ChatLineModel::SelectedBackgroundRole:
         return backgroundBrush(UiStyle::FormatType::Sender, true);
     case ChatLineModel::FormatRole:
-        return QVariant::fromValue<UiStyle::FormatList>({std::make_pair(quint16{0}, UiStyle::Format{UiStyle::formatType(_styledMsg.type()) | UiStyle::FormatType::Sender})});
+        return QVariant::fromValue<UiStyle::FormatList>({std::make_pair(quint16{0}, UiStyle::Format{UiStyle::formatType(_styledMsg.type()) | UiStyle::FormatType::Sender, {}, {}})});
     }
     return QVariant();
 }
@@ -160,7 +160,7 @@ UiStyle::MessageLabel ChatLineModelItem::messageLabel() const
 {
     using MessageLabel = UiStyle::MessageLabel;
 
-    MessageLabel label = static_cast<MessageLabel>(_styledMsg.senderHash() << 16);
+    auto label = static_cast<MessageLabel>(_styledMsg.senderHash() << 16);
     if (_styledMsg.flags() & Message::Self)
         label |= MessageLabel::OwnMsg;
     if (_styledMsg.flags() & Message::Highlight)
@@ -171,7 +171,7 @@ UiStyle::MessageLabel ChatLineModelItem::messageLabel() const
 
 QVariant ChatLineModelItem::backgroundBrush(UiStyle::FormatType subelement, bool selected) const
 {
-    QTextCharFormat fmt = QtUi::style()->format(UiStyle::formatType(_styledMsg.type()) | subelement,
+    QTextCharFormat fmt = QtUi::style()->format({UiStyle::formatType(_styledMsg.type()) | subelement, {}, {}},
                                                 messageLabel() | (selected ? UiStyle::MessageLabel::Selected : UiStyle::MessageLabel::None));
     if (fmt.hasProperty(QTextFormat::BackgroundBrush))
         return QVariant::fromValue<QBrush>(fmt.background());