summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Klapetek <mklapetek@kde.org>2016-02-11 03:20:05 (GMT)
committerAlexandr Akulich <akulichalexander@gmail.com>2016-09-21 15:11:09 (GMT)
commitcf4fac5c8b6570adc94baa108f638cc4050ec3a8 (patch)
tree798ff584bc44a8e05e065c893d45cd9289d8b2c0
parent769e7a06ddfbc9adce044105b1af8e9c548c6080 (diff)
[declarative] Various style fixes that have accumulated here through time
Reviewed-by: Alexandr Akulich <akulichalexander@gmail.com>
-rw-r--r--KTp/Declarative/conversation.cpp8
-rw-r--r--KTp/Declarative/conversations-model.cpp41
-rw-r--r--KTp/Declarative/conversations-model.h22
-rw-r--r--KTp/Declarative/messages-model.cpp32
-rw-r--r--KTp/Declarative/pinned-contacts-model.cpp19
-rw-r--r--KTp/Declarative/pinned-contacts-model.h2
6 files changed, 62 insertions, 62 deletions
diff --git a/KTp/Declarative/conversation.cpp b/KTp/Declarative/conversation.cpp
index fa10aab..f97d707 100644
--- a/KTp/Declarative/conversation.cpp
+++ b/KTp/Declarative/conversation.cpp
@@ -81,7 +81,7 @@ Conversation::Conversation(QObject *parent)
{
}
-void Conversation::setTextChannel(const Tp::TextChannelPtr& channel)
+void Conversation::setTextChannel(const Tp::TextChannelPtr &channel)
{
if (!d->messages) {
d->messages = new MessagesModel(d->account, this);
@@ -161,7 +161,8 @@ QIcon Conversation::avatar() const
}
}
-KTp::ContactPtr Conversation::targetContact() const {
+KTp::ContactPtr Conversation::targetContact() const
+{
if (d->isGroupChat) {
return KTp::ContactPtr();
} else {
@@ -169,7 +170,8 @@ KTp::ContactPtr Conversation::targetContact() const {
}
}
-Tp::AccountPtr Conversation::account() const {
+Tp::AccountPtr Conversation::account() const
+{
return d->account;
}
diff --git a/KTp/Declarative/conversations-model.cpp b/KTp/Declarative/conversations-model.cpp
index a8ed75c..9cf8107 100644
--- a/KTp/Declarative/conversations-model.cpp
+++ b/KTp/Declarative/conversations-model.cpp
@@ -40,9 +40,9 @@ class ConversationsModel::ConversationsModelPrivate
};
ConversationsModel::ConversationsModel(QObject *parent) :
- QAbstractListModel(parent),
- Tp::AbstractClientHandler(channelClassList()),
- d(new ConversationsModelPrivate)
+ QAbstractListModel(parent),
+ Tp::AbstractClientHandler(channelClassList()),
+ d(new ConversationsModelPrivate)
{
d->activeChatIndex = -1;
connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), SIGNAL(totalUnreadCountChanged()));
@@ -65,10 +65,8 @@ QHash<int, QByteArray> ConversationsModel::roleNames() const
QVariant ConversationsModel::data(const QModelIndex &index, int role) const
{
QVariant result;
- if (index.isValid()) {
- if (role == ConversationRole) {
- result = QVariant::fromValue<Conversation*>(d->conversations[index.row()]);
- }
+ if (index.isValid() && role == ConversationRole) {
+ result = QVariant::fromValue<Conversation*>(d->conversations[index.row()]);
}
return result;
}
@@ -96,7 +94,7 @@ void ConversationsModel::handleChannels(const Tp::MethodInvocationContextPtr<> &
//check that the channel is of type text
Tp::TextChannelPtr textChannel;
- Q_FOREACH(const Tp::ChannelPtr &channel, channels) {
+ Q_FOREACH (const Tp::ChannelPtr &channel, channels) {
textChannel = Tp::TextChannelPtr::dynamicCast(channel);
if (textChannel) {
break;
@@ -106,9 +104,10 @@ void ConversationsModel::handleChannels(const Tp::MethodInvocationContextPtr<> &
Q_ASSERT(textChannel);
//find the relevant channelRequest
- Q_FOREACH(const Tp::ChannelRequestPtr channelRequest, channelRequests) {
+ Q_FOREACH (const Tp::ChannelRequestPtr channelRequest, channelRequests) {
qCDebug(KTP_DECLARATIVE) << channelRequest->hints().allHints();
- shouldDelegate = channelRequest->hints().hint(QLatin1String("org.freedesktop.Telepathy.ChannelRequest"), QLatin1String("DelegateToPreferredHandler")).toBool();
+ shouldDelegate = channelRequest->hints().hint(QLatin1String("org.freedesktop.Telepathy.ChannelRequest"),
+ QLatin1String("DelegateToPreferredHandler")).toBool();
}
//loop through all conversations checking for matches
@@ -116,18 +115,18 @@ void ConversationsModel::handleChannels(const Tp::MethodInvocationContextPtr<> &
//if we are handling and we're not told to delegate it, update the text channel
//if we are handling but should delegate, call delegate channel
int i = 0;
- Q_FOREACH(Conversation *convo, d->conversations) {
- if (convo->textChannel()->targetId() == textChannel->targetId() &&
- convo->textChannel()->targetHandleType() == textChannel->targetHandleType())
+ Q_FOREACH (Conversation *conversation, d->conversations) {
+ if (conversation->textChannel()->targetId() == textChannel->targetId()
+ && conversation->textChannel()->targetHandleType() == textChannel->targetHandleType())
{
if (!shouldDelegate) {
- convo->setTextChannel(textChannel);
+ conversation->setTextChannel(textChannel);
//Update the active chat index to this channel
d->activeChatIndex = i;
Q_EMIT activeChatIndexChanged();
} else {
- if (convo->textChannel() == textChannel) {
- convo->delegateToProperClient();
+ if (conversation->textChannel() == textChannel) {
+ conversation->delegateToProperClient();
}
}
handled = true;
@@ -148,7 +147,7 @@ void ConversationsModel::handleChannels(const Tp::MethodInvocationContextPtr<> &
//If this is a locally generated request or there is no active chat, the index of the newly inserted conversation is saved as the active chat
//The model is reset to load the newly created chat channel
- if(textChannel->isRequested() || d->activeChatIndex == -1) {
+ if (textChannel->isRequested() || d->activeChatIndex == -1) {
d->activeChatIndex = rowCount() - 1;
Q_EMIT activeChatIndexChanged();
}
@@ -181,14 +180,14 @@ void ConversationsModel::removeConversation(Conversation* conv)
int ConversationsModel::nextActiveConversation(int fromRow)
{
- if(d->conversations.isEmpty()) {
+ if (d->conversations.isEmpty()) {
return -1;
}
- Q_ASSERT(qBound(0, fromRow, d->conversations.count()-1) == fromRow);
+ Q_ASSERT(qBound(0, fromRow, d->conversations.count() - 1) == fromRow);
bool first = true; //let first be checked on the first loop
- for(int i = fromRow; i != fromRow || first; i = (i + 1) % d->conversations.count()) {
- if(d->conversations[i]->messages()->unreadCount() > 0) {
+ for (int i = fromRow; i != fromRow || first; i = (i + 1) % d->conversations.count()) {
+ if (d->conversations[i]->messages()->unreadCount() > 0) {
return i;
}
first = false;
diff --git a/KTp/Declarative/conversations-model.h b/KTp/Declarative/conversations-model.h
index 06e3b59..6ba159f 100644
--- a/KTp/Declarative/conversations-model.h
+++ b/KTp/Declarative/conversations-model.h
@@ -33,13 +33,13 @@ class ConversationsModel : public QAbstractListModel, public Tp::AbstractClientH
Q_PROPERTY(int totalUnreadCount READ totalUnreadCount NOTIFY totalUnreadCountChanged)
Q_PROPERTY(int activeChatIndex READ activeChatIndex NOTIFY activeChatIndexChanged)
- public:
- explicit ConversationsModel(QObject *parent=0);
+public:
+ explicit ConversationsModel(QObject *parent = 0);
virtual ~ConversationsModel();
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
- virtual QVariant data ( const QModelIndex &index, int role = Qt::DisplayRole ) const Q_DECL_OVERRIDE;
- virtual int rowCount ( const QModelIndex &parent = QModelIndex() ) const Q_DECL_OVERRIDE;
+ virtual QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
+ virtual int rowCount (const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
/** @returns the sum of all unread messages among all conversations */
int totalUnreadCount() const;
@@ -62,21 +62,21 @@ class ConversationsModel : public QAbstractListModel, public Tp::AbstractClientH
const HandlerInfo &handlerInfo);
bool bypassApproval() const;
- public Q_SLOTS:
+public Q_SLOTS:
int nextActiveConversation(int first);
- private:
- void removeConversation(Conversation* conversation);
+private:
+ void removeConversation(Conversation *conversation);
class ConversationsModelPrivate;
ConversationsModelPrivate *d;
- private Q_SLOTS:
+private Q_SLOTS:
void onConversationCloseRequested();
- Q_SIGNALS:
- void totalUnreadCountChanged();
- void activeChatIndexChanged();
+Q_SIGNALS:
+ void totalUnreadCountChanged();
+ void activeChatIndexChanged();
};
#endif // CONVERSATIONS_MODEL_H
diff --git a/KTp/Declarative/messages-model.cpp b/KTp/Declarative/messages-model.cpp
index 4e7a25c..128a0b8 100644
--- a/KTp/Declarative/messages-model.cpp
+++ b/KTp/Declarative/messages-model.cpp
@@ -195,22 +195,22 @@ void MessagesModel::onMessageReceived(const Tp::ReceivedMessage &message)
MessagePrivate &originalMessage = d->messages[originalMessageIndex.row()];
originalMessage.deliveryReportReceiveTime = message.received();
switch(deliveryDetails.status()) {
- case Tp::DeliveryStatusPermanentlyFailed:
- case Tp::DeliveryStatusTemporarilyFailed:
- originalMessage.deliveryStatus = DeliveryStatusFailed;
- if (deliveryDetails.hasDebugMessage()) {
- qCDebug(KTP_DECLARATIVE) << "Delivery failure debug message:" << deliveryDetails.debugMessage();
- }
- break;
- case Tp::DeliveryStatusDelivered:
- originalMessage.deliveryStatus = DeliveryStatusDelivered;
- break;
- case Tp::DeliveryStatusRead:
- originalMessage.deliveryStatus = DeliveryStatusRead;
- break;
- default:
- originalMessage.deliveryStatus = DeliveryStatusUnknown;
- break;
+ case Tp::DeliveryStatusPermanentlyFailed:
+ case Tp::DeliveryStatusTemporarilyFailed:
+ originalMessage.deliveryStatus = DeliveryStatusFailed;
+ if (deliveryDetails.hasDebugMessage()) {
+ qCDebug(KTP_DECLARATIVE) << "Delivery failure debug message:" << deliveryDetails.debugMessage();
+ }
+ break;
+ case Tp::DeliveryStatusDelivered:
+ originalMessage.deliveryStatus = DeliveryStatusDelivered;
+ break;
+ case Tp::DeliveryStatusRead:
+ originalMessage.deliveryStatus = DeliveryStatusRead;
+ break;
+ default:
+ originalMessage.deliveryStatus = DeliveryStatusUnknown;
+ break;
}
Q_EMIT dataChanged(originalMessageIndex, originalMessageIndex);
} else {
diff --git a/KTp/Declarative/pinned-contacts-model.cpp b/KTp/Declarative/pinned-contacts-model.cpp
index 19de777..918fa02 100644
--- a/KTp/Declarative/pinned-contacts-model.cpp
+++ b/KTp/Declarative/pinned-contacts-model.cpp
@@ -92,7 +92,7 @@ void PinnedContactsModel::setState(const QStringList &pins)
QModelIndex PinnedContactsModel::indexForContact(const KTp::ContactPtr &contact) const
{
- for (int i=0; i<d->m_pins.size() && contact; i++) {
+ for (int i = 0; i < d->m_pins.size() && contact; i++) {
if (d->m_pins[i]->contactId() == contact->id()) {
return index(i);
}
@@ -132,12 +132,11 @@ QVariant PinnedContactsModel::data(const QModelIndex &index, int role) const
case AvailabilityRole:
if (!p->contact()) {
return false;
- }
- else {
- return p->contact()->presence().type()!=Tp::ConnectionPresenceTypeOffline
- && p->contact()->presence().type()!=Tp::ConnectionPresenceTypeError
- && p->contact()->presence().type()!=Tp::ConnectionPresenceTypeUnset
- && p->contact()->presence().type()!=Tp::ConnectionPresenceTypeUnknown;
+ } else {
+ return p->contact()->presence().type() != Tp::ConnectionPresenceTypeOffline
+ && p->contact()->presence().type() != Tp::ConnectionPresenceTypeError
+ && p->contact()->presence().type() != Tp::ConnectionPresenceTypeUnset
+ && p->contact()->presence().type() != Tp::ConnectionPresenceTypeUnknown;
}
case ContactRole:
return QVariant::fromValue<KTp::ContactPtr>(p->contact());
@@ -184,7 +183,7 @@ int PinnedContactsModel::rowCount(const QModelIndex &parent) const
void PinnedContactsModel::removeContactPin(const KTp::PersistentContactPtr &pin)
{
int row = d->m_pins.indexOf(pin);
- if (row>=0) {
+ if (row >= 0) {
beginRemoveRows(QModelIndex(), row, row);
d->m_pins.removeAt(row);
endRemoveRows();
@@ -259,10 +258,10 @@ void PinnedContactsModel::conversationsStateChanged(const QModelIndex &parent, i
{
for (int i = start; i <= end; i++) {
QModelIndex idx = d->conversations->index(i, 0, parent);
- Conversation* conv = idx.data(ConversationsModel::ConversationRole).value<Conversation*>();
+ Conversation *conv = idx.data(ConversationsModel::ConversationRole).value<Conversation*>();
QString contactId = conv->targetContact()->id();
- Q_FOREACH(const KTp::PersistentContactPtr &p, d->m_pins) {
+ Q_FOREACH (const KTp::PersistentContactPtr &p, d->m_pins) {
if (p->contactId() == contactId) {
QModelIndex contactIdx = indexForContact(p->contact());
//We need to delay the dataChanged until the next event loop, when endRowsRemoved has been called
diff --git a/KTp/Declarative/pinned-contacts-model.h b/KTp/Declarative/pinned-contacts-model.h
index 27835b1..82cf36d 100644
--- a/KTp/Declarative/pinned-contacts-model.h
+++ b/KTp/Declarative/pinned-contacts-model.h
@@ -60,7 +60,7 @@ class PinnedContactsModel : public QAbstractListModel
void setConversationsModel(ConversationsModel *model);
QStringList state() const;
- void setState(const QStringList &s);
+ void setState(const QStringList &state);
private Q_SLOTS:
void contactDataChanged();