diff --git a/KTp/Declarative/contact-pin.cpp b/KTp/Declarative/contact-pin.cpp index 150b4b2..9ad3bcd 100644 --- a/KTp/Declarative/contact-pin.cpp +++ b/KTp/Declarative/contact-pin.cpp @@ -1,80 +1,80 @@ /* Copyright (C) 2012 Aleix Pol This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "contact-pin.h" #include #include #include "pinned-contacts-model.h" ContactPin::ContactPin(QObject *parent) : QObject(parent) , m_model(0) { } Tp::AccountPtr ContactPin::account() const { return m_account; } -Tp::ContactPtr ContactPin::contact() const +KTp::ContactPtr ContactPin::contact() const { return m_contact; } PinnedContactsModel* ContactPin::model() const { return m_model; } bool ContactPin::isPinned() const { bool ret = false; if (m_model && m_account && m_contact) { QModelIndex idx = m_model->indexForContact(m_account, m_contact); ret = idx.isValid(); } return ret; } void ContactPin::toggle() { Q_ASSERT(m_model && m_account && m_contact); m_model->setPinning(m_account, m_contact, !isPinned()); Q_EMIT pinnedChanged(); } void ContactPin::setAccount(const Tp::AccountPtr &account) { Q_ASSERT(account); m_account = account; Q_EMIT pinnedChanged(); } -void ContactPin::setContact(const Tp::ContactPtr &contact) +void ContactPin::setContact(const KTp::ContactPtr &contact) { m_contact = contact; Q_EMIT pinnedChanged(); } void ContactPin::setModel(PinnedContactsModel *model) { m_model = model; Q_EMIT pinnedChanged(); } diff --git a/KTp/Declarative/contact-pin.h b/KTp/Declarative/contact-pin.h index 8463931..ec740b6 100644 --- a/KTp/Declarative/contact-pin.h +++ b/KTp/Declarative/contact-pin.h @@ -1,58 +1,58 @@ /* Copyright (C) 2012 Aleix Pol This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CONTACTPIN_H #define CONTACTPIN_H #include -#include "ktp-metatypes.h" +#include "types.h" class PinnedContactsModel; class ContactPin : public QObject { Q_OBJECT - Q_PROPERTY(Tp::ContactPtr contact READ contact WRITE setContact) + Q_PROPERTY(KTp::ContactPtr contact READ contact WRITE setContact) Q_PROPERTY(Tp::AccountPtr account READ account WRITE setAccount) Q_PROPERTY(PinnedContactsModel *model READ model WRITE setModel) Q_PROPERTY(bool pinned READ isPinned NOTIFY pinnedChanged) public: explicit ContactPin(QObject *parent = 0); - Tp::ContactPtr contact() const; + KTp::ContactPtr contact() const; Tp::AccountPtr account() const; PinnedContactsModel* model() const; bool isPinned() const; - void setContact(const Tp::ContactPtr &contact); + void setContact(const KTp::ContactPtr &contact); void setAccount(const Tp::AccountPtr &account); void setModel(PinnedContactsModel *model); Q_SCRIPTABLE void toggle(); Q_SIGNALS: void pinnedChanged(); private: PinnedContactsModel *m_model; - Tp::ContactPtr m_contact; + KTp::ContactPtr m_contact; Tp::AccountPtr m_account; }; #endif // CONTACTPIN_H diff --git a/KTp/Declarative/conversation-target.cpp b/KTp/Declarative/conversation-target.cpp index d726f0c..4e8af19 100644 --- a/KTp/Declarative/conversation-target.cpp +++ b/KTp/Declarative/conversation-target.cpp @@ -1,139 +1,139 @@ /* Copyright (C) 2011 Lasath Fernando This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "conversation-target.h" #include #include #include #include class ConversationTarget::ConversationTargetPrivate { public: - Tp::ContactPtr contact; + KTp::ContactPtr contact; KIcon avatar; Tp::AccountPtr account; }; -ConversationTarget::ConversationTarget(const Tp::AccountPtr &account, const Tp::ContactPtr &contact, QObject *parent) : +ConversationTarget::ConversationTarget(const Tp::AccountPtr &account, const KTp::ContactPtr &contact, QObject *parent) : QObject(parent), d(new ConversationTargetPrivate) { kDebug(); if (contact) { setupContactSignals(contact); } d->contact = contact; d->account = account; updateAvatar(); } -void ConversationTarget::setupContactSignals(Tp::ContactPtr contact) +void ConversationTarget::setupContactSignals(KTp::ContactPtr contact) { connect(contact.constData(), SIGNAL(aliasChanged(QString)), SIGNAL(nickChanged(QString))); connect(contact.constData(), SIGNAL(avatarDataChanged(Tp::AvatarData)), SLOT(onAvatarDataChanged())); connect(contact.constData(), SIGNAL(presenceChanged(Tp::Presence)), SLOT(onPresenceChanged())); } QIcon ConversationTarget::avatar() const { if (d->contact) { return d->avatar; } else { return QIcon(); } } QString ConversationTarget::id() const { if (d->contact) { return d->contact->id(); } else { return QString(); } } QString ConversationTarget::nick() const { if (d->contact) { return d->contact->alias(); } else { return QString(); } } QIcon ConversationTarget::presenceIcon() const { if (d->contact) { return KTp::Presence(d->contact->presence()).icon(); } else { return QIcon(); } } QString ConversationTarget::presenceIconName() const { if (d->contact) { return KTp::Presence(d->contact->presence()).iconName(); } else { return QString(); } } void ConversationTarget::onPresenceChanged() { Q_EMIT presenceIconChanged(presenceIcon()); Q_EMIT presenceIconNameChanged(presenceIconName()); } void ConversationTarget::onAvatarDataChanged() { updateAvatar(); Q_EMIT avatarChanged(avatar()); } void ConversationTarget::updateAvatar() { QString path; if (d->contact) { path = d->contact->avatarData().fileName; } if (path.isEmpty()) { path = QLatin1String("im-user"); } d->avatar = KIcon(path); } -Tp::ContactPtr ConversationTarget::contact() const +KTp::ContactPtr ConversationTarget::contact() const { return d->contact; } Tp::AccountPtr ConversationTarget::account() const { return d->account; } ConversationTarget::~ConversationTarget() { delete d; } diff --git a/KTp/Declarative/conversation-target.h b/KTp/Declarative/conversation-target.h index 2822c45..1e7f159 100644 --- a/KTp/Declarative/conversation-target.h +++ b/KTp/Declarative/conversation-target.h @@ -1,73 +1,73 @@ /* Copyright (C) 2011 Lasath Fernando This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CONVERSATION_TARGET_H #define CONVERSATION_TARGET_H #include #include -#include "ktp-metatypes.h" +#include "types.h" class ConversationTarget : public QObject { Q_OBJECT Q_PROPERTY(QIcon avatar READ avatar NOTIFY avatarChanged); Q_PROPERTY(QString nick READ nick NOTIFY nickChanged); Q_PROPERTY(QIcon presenceIcon READ presenceIcon NOTIFY presenceIconChanged); Q_PROPERTY(QString presenceIconName READ presenceIconName NOTIFY presenceIconNameChanged) Q_PROPERTY(QString id READ id CONSTANT) - Q_PROPERTY(Tp::ContactPtr contact READ contact CONSTANT) + Q_PROPERTY(KTp::ContactPtr contact READ contact CONSTANT) Q_PROPERTY(Tp::AccountPtr account READ account CONSTANT) public: - explicit ConversationTarget(const Tp::AccountPtr &account, const Tp::ContactPtr &contact, QObject *parent = 0); + explicit ConversationTarget(const Tp::AccountPtr &account, const KTp::ContactPtr &contact, QObject *parent = 0); virtual ~ConversationTarget(); QIcon avatar() const; QString id() const; QString nick() const; QIcon presenceIcon() const; QString presenceIconName() const; - Tp::ContactPtr contact() const; + KTp::ContactPtr contact() const; Tp::AccountPtr account() const; Q_SIGNALS: void avatarChanged(QIcon avatar); void nickChanged(QString nick); void presenceIconChanged(QIcon icon); void presenceIconNameChanged(QString icon); private Q_SLOTS: void onAvatarDataChanged(); void onPresenceChanged(); private: - void setupContactSignals(Tp::ContactPtr contact); + void setupContactSignals(KTp::ContactPtr contact); void updateAvatar(); class ConversationTargetPrivate; ConversationTargetPrivate *d; }; Q_DECLARE_METATYPE(ConversationTarget*) #endif // CONVERSATION_TARGET_H diff --git a/KTp/Declarative/conversation.cpp b/KTp/Declarative/conversation.cpp index b7a87db..7a1a259 100644 --- a/KTp/Declarative/conversation.cpp +++ b/KTp/Declarative/conversation.cpp @@ -1,103 +1,103 @@ /* Copyright (C) 2011 Lasath Fernando This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "conversation.h" #include "messages-model.h" #include #include #include "conversation-target.h" #include "channel-delegator.h" class Conversation::ConversationPrivate { public: MessagesModel *messages; ConversationTarget *target; bool valid; Tp::AccountPtr account; }; Conversation::Conversation(const Tp::TextChannelPtr &channel, const Tp::AccountPtr &account, QObject *parent) : QObject(parent), d (new ConversationPrivate) { kDebug(); d->account = account; d->messages = new MessagesModel(this); d->messages->setTextChannel(channel); - d->target = new ConversationTarget(account, channel->targetContact(), this); + d->target = new ConversationTarget(account, KTp::ContactPtr::qObjectCast(channel->targetContact()), this); d->valid = channel->isValid(); connect(channel.data(), SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)), SLOT(onChannelInvalidated(Tp::DBusProxy*,QString,QString))); } Conversation::Conversation(QObject *parent) : QObject(parent) { kError() << "Conversation should not be created directly. Use ConversationWatcher instead."; Q_ASSERT(false); } MessagesModel* Conversation::messages() const { return d->messages; } ConversationTarget* Conversation::target() const { return d->target; } bool Conversation::isValid() { return d->valid; } void Conversation::onChannelInvalidated(Tp::DBusProxy *proxy, const QString &errorName, const QString &errorMessage) { kDebug() << proxy << errorName << ":" << errorMessage; d->valid = false; Q_EMIT validityChanged(d->valid); } void Conversation::delegateToProperClient() { ChannelDelegator::delegateChannel(d->account, d->messages->textChannel()); } void Conversation::requestClose() { kDebug(); d->messages->textChannel()->requestClose(); } Conversation::~Conversation() { kDebug(); delete d; } diff --git a/KTp/Declarative/pinned-contacts-model.cpp b/KTp/Declarative/pinned-contacts-model.cpp index 3c2c558..f80b20c 100644 --- a/KTp/Declarative/pinned-contacts-model.cpp +++ b/KTp/Declarative/pinned-contacts-model.cpp @@ -1,295 +1,295 @@ /* Copyright (C) 2012 Aleix Pol This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "pinned-contacts-model.h" #include "conversations-model.h" #include "conversation.h" #include -#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include +#include struct Pin { Tp::ContactPtr contact; Tp::AccountPtr account; }; class PinnedContactsModelPrivate { public: QVector m_pins; Tp::AccountManagerPtr accountManager; ConversationsModel *convesations; QStringList pinsToString() const { QStringList ret; Q_FOREACH(const Pin &p, m_pins) { ret += p.account->uniqueIdentifier(); ret += p.contact->id(); } return ret; } }; static Tp::AccountPtr findAccountByUniqueId(Tp::AccountManagerPtr manager, const QString &id) { QList accounts = manager->allAccounts(); Q_FOREACH(const Tp::AccountPtr account, accounts) { if (account->uniqueIdentifier() == id) { return account; } } Q_ASSERT(false && "account not found"); return Tp::AccountPtr(); } PinnedContactsModel::PinnedContactsModel(QObject *parent) : QAbstractListModel(parent) , d(new PinnedContactsModelPrivate) { QHash roles = roleNames(); roles[PresenceIconRole] = "presenceIcon"; roles[AvailabilityRole] = "available"; roles[ContactRole] = "contact"; roles[AccountRole] = "account"; roles[AlreadyChattingRole] = "alreadyChatting"; setRoleNames(roles); connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), SIGNAL(countChanged())); connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), SIGNAL(countChanged())); } PinnedContactsModel::~PinnedContactsModel() { delete d; } QStringList PinnedContactsModel::state() const { return d->pinsToString(); } void PinnedContactsModel::setState(const QStringList &pins) { Q_ASSERT(pins.size() % 2 == 0 && "the state should be a pair number of account id and contact name"); if(!d->accountManager->isReady()) { Tp::PendingReady *r = d->accountManager->becomeReady(); r->setProperty("newState", pins); connect(r, SIGNAL(finished(Tp::PendingOperation*)), SLOT(initializeState(Tp::PendingOperation*))); } else { kDebug() << "loading pinned...." << pins; for (int i = 0; i < pins.count(); i += 2) { Tp::AccountPtr account = findAccountByUniqueId(d->accountManager, pins[i]); if (account->connection()) { Tp::PendingContacts *pending = account->connection()->contactManager()->contactsForIdentifiers(QStringList(pins[i+1])); pending->setProperty("account", qVariantFromValue(account)); connect(pending, SIGNAL(finished(Tp::PendingOperation*)), SLOT(pinPendingContacts(Tp::PendingOperation*))); } } } } void PinnedContactsModel::pinPendingContacts(Tp::PendingOperation* j) { if (j->isValid()) { Tp::PendingContacts *job = qobject_cast(j); Tp::AccountPtr account = job->property("account").value(); - Tp::ContactPtr contact = job->contacts().first(); + KTp::ContactPtr contact = KTp::ContactPtr::qObjectCast(job->contacts().first()); setPinning(account, contact, true); } else kDebug() << "error:" << j->errorName() << j->errorMessage(); } -QModelIndex PinnedContactsModel::indexForContact(Tp::AccountPtr account, Tp::ContactPtr contact) const +QModelIndex PinnedContactsModel::indexForContact(Tp::AccountPtr account, KTp::ContactPtr contact) const { int i = 0; Q_FOREACH(const Pin &p, d->m_pins) { if (p.account->uniqueIdentifier() == account->uniqueIdentifier() && p.contact->id() == contact->id()) { break; } i++; } if (i < d->m_pins.count()) { return index(i); } else { return QModelIndex(); } } -void PinnedContactsModel::setPinning(const Tp::AccountPtr &account, const Tp::ContactPtr &contact, bool newState) +void PinnedContactsModel::setPinning(const Tp::AccountPtr &account, const KTp::ContactPtr &contact, bool newState) { QModelIndex idx = indexForContact(account, contact); bool found = idx.isValid(); if (newState && !found) { Pin p; p.account = account; p.contact = contact; appendContact(p); } else if (!newState && found) { removeRow(idx.row()); } } QVariant PinnedContactsModel::data(const QModelIndex &index, int role) const { if (index.isValid()) { const Pin &p = d->m_pins[index.row()]; switch(role) { case Qt::DisplayRole: return p.contact->alias(); case PresenceIconRole: return KTp::Presence(p.contact->presence()).icon(); case AvailabilityRole: 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(p.contact); + return QVariant::fromValue(KTp::ContactPtr::qObjectCast(p.contact)); case AccountRole: return QVariant::fromValue(p.account); case AlreadyChattingRole: { bool found = false; for (int i = 0; !found && i < d->convesations->rowCount(); i++) { QModelIndex idx = d->convesations->index(i, 0); - Tp::ContactPtr contact = idx.data(ConversationsModel::ConversationRole).value()->target()->contact(); + KTp::ContactPtr contact = KTp::ContactPtr::qObjectCast(idx.data(ConversationsModel::ConversationRole).value()->target()->contact()); found |= contact->id() == p.contact->id(); } return found; } case Qt::DecorationRole: { KIcon icon; if (p.contact) { icon = KIcon(p.contact->avatarData().fileName); } if (icon.isNull()) { icon = KIcon(QLatin1String("im-user")); } return icon; } } } return QVariant(); } int PinnedContactsModel::rowCount(const QModelIndex &parent) const { if (parent.isValid()) { return 0; } return d->m_pins.count(); } bool PinnedContactsModel::removeRows(int row, int count, const QModelIndex &parent) { if (parent.isValid() || (row + count) > d->m_pins.count()) { return false; } beginRemoveRows(parent, row, row + count - 1); d->m_pins.remove(row, count); endRemoveRows(); return true; } void PinnedContactsModel::appendContact(const Pin &p) { int s = d->m_pins.size(); beginInsertRows(QModelIndex(), s, s); d->m_pins += p; endInsertRows(); connect(p.contact.data(), SIGNAL(avatarDataChanged(Tp::AvatarData)), SLOT(contactDataChanged())); connect(p.contact.data(), SIGNAL(aliasChanged(QString)), SLOT(contactDataChanged())); connect(p.contact.data(), SIGNAL(presenceChanged(Tp::Presence)), SLOT(contactDataChanged())); } void PinnedContactsModel::contactDataChanged() { - Tp::Contact *c = qobject_cast(sender()); + KTp::Contact *c = qobject_cast(sender()); int i = 0; Q_FOREACH(const Pin &p, d->m_pins) { if (p.contact == c) { QModelIndex idx = index(i); Q_EMIT dataChanged(idx, idx); return; } i++; } } void PinnedContactsModel::setConversationsModel(ConversationsModel *model) { beginResetModel(); d->convesations = model; connect(d->convesations, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), SLOT(conversationsStateChanged(QModelIndex, int, int))); connect(d->convesations, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(conversationsStateChanged(QModelIndex, int, int))); endResetModel(); } void PinnedContactsModel::conversationsStateChanged(const QModelIndex &parent, int start, int end) { for (int i = start; i <= end; i++) { QModelIndex idx = d->convesations->index(i, 0, parent); - Tp::ContactPtr contact = idx.data(ConversationsModel::ConversationRole).value()->target()->contact(); + KTp::ContactPtr contact = KTp::ContactPtr::qObjectCast(idx.data(ConversationsModel::ConversationRole).value()->target()->contact()); Q_FOREACH(const Pin &p, d->m_pins) { if (p.contact->id() == contact->id()) QMetaObject::invokeMethod(this, "dataChanged", Qt::QueuedConnection, Q_ARG(QModelIndex, idx), Q_ARG(QModelIndex, idx)); } } } ConversationsModel* PinnedContactsModel::conversationsModel() const { return d->convesations; } Tp::AccountManagerPtr PinnedContactsModel::accountManager() const { return d->accountManager; } void PinnedContactsModel::setAccountManager(const Tp::AccountManagerPtr &accounts) { accounts->becomeReady(); d->accountManager = accounts; } void PinnedContactsModel::initializeState(Tp::PendingOperation *op) { setState(op->property("newState").toStringList()); } diff --git a/KTp/Declarative/pinned-contacts-model.h b/KTp/Declarative/pinned-contacts-model.h index 0b4db83..216c517 100644 --- a/KTp/Declarative/pinned-contacts-model.h +++ b/KTp/Declarative/pinned-contacts-model.h @@ -1,79 +1,79 @@ /* Copyright (C) 2012 Aleix Pol This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PINNEDCONTACTSMODEL_H #define PINNEDCONTACTSMODEL_H #include #include -#include "ktp-metatypes.h" +#include "types.h" struct Pin; class ConversationsModel; class PinnedContactsModelPrivate; class PinnedContactsModel : public QAbstractListModel { Q_OBJECT Q_PROPERTY(ConversationsModel *conversations READ conversationsModel WRITE setConversationsModel) Q_PROPERTY(Tp::AccountManagerPtr accountManager READ accountManager WRITE setAccountManager) Q_PROPERTY(QStringList state READ state WRITE setState) Q_PROPERTY(int count READ rowCount NOTIFY countChanged); public: explicit PinnedContactsModel(QObject *parent = 0); virtual ~PinnedContactsModel(); enum role { PresenceIconRole = Qt::UserRole + 1, AvailabilityRole, ContactRole, AccountRole, AlreadyChattingRole }; virtual QVariant data(const QModelIndex &index, int role) const; virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); - Q_SLOT void setPinning(const Tp::AccountPtr &account, const Tp::ContactPtr &contact, bool newState); - QModelIndex indexForContact(Tp::AccountPtr account, Tp::ContactPtr contact) const; + Q_SLOT void setPinning(const Tp::AccountPtr &account, const KTp::ContactPtr &contact, bool newState); + QModelIndex indexForContact(Tp::AccountPtr account, KTp::ContactPtr contact) const; ConversationsModel* conversationsModel() const; void setConversationsModel(ConversationsModel *model); Tp::AccountManagerPtr accountManager() const; void setAccountManager(const Tp::AccountManagerPtr &accounts); QStringList state() const; void setState(const QStringList &s); private Q_SLOTS: void contactDataChanged(); void pinPendingContacts(Tp::PendingOperation *job); void initializeState(Tp::PendingOperation *op); void conversationsStateChanged(const QModelIndex &parent, int start, int end); Q_SIGNALS: void countChanged(); private: void appendContact(const Pin &p); PinnedContactsModelPrivate * const d; }; #endif // PINNEDCONTACTSMODEL_H diff --git a/KTp/Declarative/qml-plugins.cpp b/KTp/Declarative/qml-plugins.cpp index e9c258d..bd2a927 100644 --- a/KTp/Declarative/qml-plugins.cpp +++ b/KTp/Declarative/qml-plugins.cpp @@ -1,59 +1,59 @@ /* Copyright (C) 2011 Lasath Fernando Copyright (C) 2013 Dan Vrátil Copyright (C) 2013 Aleix Pol Gonzalez This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "qml-plugins.h" #include #include "contact-list.h" #include "conversation.h" #include "conversations-model.h" #include "conversation-target.h" #include "hide-window-component.h" #include "messages-model.h" #include "telepathy-text-observer.h" #include "pinned-contacts-model.h" #include "contact-pin.h" -#include "Models/accounts-filter-model.h" +#include "Models/contacts-filter-model.h" void QmlPlugins::registerTypes(const char *uri) { qmlRegisterType (uri, 0, 1, "ContactList"); qmlRegisterType (uri, 0, 1, "TelepathyTextObserver"); qmlRegisterType(uri, 0, 1, "Conversation"); qmlRegisterType(uri, 0, 1, "HideWindowComponent"); qmlRegisterType(uri, 0, 1, "PinnedContactsModel"); qmlRegisterType(uri, 0, 1, "ContactPin"); - qmlRegisterUncreatableType (uri, 0, 1, "AccountsFilterModel", + qmlRegisterUncreatableType (uri, 0, 1, "AccountsFilterModel", QLatin1String("Filter cannot be created. Access through ContactList.filter")); qmlRegisterUncreatableType (uri, 0, 1, "MessagesModel", QLatin1String("It will be created once the conversation is created")); qmlRegisterType(); qmlRegisterType(); qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); qRegisterMetaType(); } Q_EXPORT_PLUGIN2(conversation, QmlPlugins); diff --git a/KTp/Declarative/telepathy-text-observer.h b/KTp/Declarative/telepathy-text-observer.h index 85c0a5e..d60b5a3 100644 --- a/KTp/Declarative/telepathy-text-observer.h +++ b/KTp/Declarative/telepathy-text-observer.h @@ -1,49 +1,48 @@ /* Copyright (C) 2011 Lasath Fernando This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef TELEPATHY_TEXT_OBSERVER_H #define TELEPATHY_TEXT_OBSERVER_H #include "conversations-model.h" +#include "types.h" #include -#include "ktp-metatypes.h" - class TelepathyTextObserver : public QObject { Q_OBJECT Q_PROPERTY(ConversationsModel *conversations READ conversationModel CONSTANT) Q_PROPERTY(Tp::AccountManagerPtr accountManager READ accountManager CONSTANT) public: TelepathyTextObserver(QObject *parent = 0); ~TelepathyTextObserver(); ConversationsModel* conversationModel() const; Tp::AccountManagerPtr accountManager() const; private: Tp::SharedPtr m_handler; Tp::ClientRegistrarPtr m_registrar; Tp::AccountManagerPtr m_accountManager; }; #endif // CONVERSATION_WATCHER_H