Warning, file /network/ktp-contact-list/contact-list-widget.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  *  Contact List Widget
0003  *  Copyright (C) 2011  Martin Klapetek <martin.klapetek@gmail.com>
0004  *
0005  *  This library is free software; you can redistribute it and/or
0006  *  modify it under the terms of the GNU Lesser General Public
0007  *  License as published by the Free Software Foundation; either
0008  *  version 2.1 of the License, or (at your option) any later version.
0009  *
0010  *  This library is distributed in the hope that it will be useful,
0011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  *  Lesser General Public License for more details.
0014  *
0015  *  You should have received a copy of the GNU Lesser General Public
0016  *  License along with this library; if not, write to the Free Software
0017  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0018  */
0019 
0020 #ifndef CONTACT_LIST_WIDGET_H
0021 #define CONTACT_LIST_WIDGET_H
0022 
0023 #include <QTreeView>
0024 #include <TelepathyQt/Types>
0025 #include <TelepathyQt/Connection>
0026 #include <KTp/Models/contacts-model.h>
0027 
0028 class ContactListWidgetPrivate;
0029 
0030 namespace Tp {
0031     class PendingOperation;
0032 }
0033 
0034 class ContactListWidget : public QTreeView
0035 {
0036     Q_OBJECT
0037     Q_DECLARE_PRIVATE(ContactListWidget)
0038     Q_DISABLE_COPY(ContactListWidget)
0039 
0040 public:
0041     explicit ContactListWidget(QWidget* parent);
0042     virtual ~ContactListWidget();
0043 
0044     void setAccountManager(const Tp::AccountManagerPtr &accountManager);
0045     void toggleGroups(bool show);
0046 
0047     KTp::ContactsModel* contactsModel() const;
0048 
0049 public Q_SLOTS:
0050     void toggleOfflineContacts(bool show);
0051     void showGrouped();
0052     void showUngrouped();
0053     void toggleSortByPresence(bool sort);
0054 
0055     void setFilterString(const QString &string);
0056     void showSettingsKCM();
0057 
0058     void onSwitchToFullView();
0059     void onSwitchToCompactView();
0060     void onSwitchToMiniView();
0061 
0062     void onShowAllContacts();
0063     void onShowUnblockedContacts();
0064     void onShowBlockedContacts();
0065 
0066 private Q_SLOTS:
0067     void onContactListClicked(const QModelIndex &index);
0068     void onContactListDoubleClicked(const QModelIndex &index);
0069 
0070     void onNewGroupModelItemsInserted(const QModelIndex &parentIndex, int start, int end);
0071     void addOverlayButtons();
0072 
0073     void startTextChannel(const Tp::AccountPtr &account, const Tp::ContactPtr &contact);
0074     void startFileTransferChannel(const Tp::AccountPtr &account, const Tp::ContactPtr &contact);
0075     void startAudioChannel(const Tp::AccountPtr &account, const Tp::ContactPtr &contact);
0076     void startVideoChannel(const Tp::AccountPtr &account, const Tp::ContactPtr &contact);
0077     void startDesktopSharing(const Tp::AccountPtr &account, const Tp::ContactPtr &contact);
0078     void startLogViewer(const Tp::AccountPtr &account, const Tp::ContactPtr &contact);
0079     void accountEnablingFinished(Tp::PendingOperation *op);
0080 
0081 Q_SIGNALS:
0082     void enableOverlays(bool);
0083     void accountManagerReady(Tp::PendingOperation* op);
0084     void genericOperationFinished(Tp::PendingOperation* op);
0085     void actionStarted();
0086     void contactSelectionChanged();
0087 
0088 protected:
0089     void setDropIndicatorRect(const QRect &rect);
0090     virtual bool event(QEvent *event);
0091     virtual void keyPressEvent(QKeyEvent *event);
0092     virtual void mousePressEvent(QMouseEvent *event);
0093     virtual void mouseMoveEvent(QMouseEvent *event);
0094     virtual void paintEvent(QPaintEvent *event);
0095     virtual void dropEvent(QDropEvent *event);
0096     virtual void dragEnterEvent(QDragEnterEvent *event);
0097     virtual void dragMoveEvent(QDragMoveEvent *event);
0098     virtual void dragLeaveEvent(QDragLeaveEvent *event);
0099     virtual void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const;
0100 
0101 private:
0102     /** Internally set the group mode used by the model. Note this function does not update d->groupMode*/
0103     void setGroupMode(KTp::ContactsModel::GroupMode groupMode);
0104 
0105     void requestFileTransferChannels(const Tp::AccountPtr &account,
0106                                      const Tp::ContactPtr &contact,
0107                                      const QStringList &filenames);
0108 
0109     void loadGroupStatesFromConfig();
0110 
0111     friend class ContextMenu;
0112     ContactListWidgetPrivate * const d_ptr;
0113 };
0114 
0115 #endif // CONTACT_LIST_WIDGET_H