Don't keep compiling/run if something failed.
[kdevelopdvcssupport.git] / plugins / teamwork / collaborationmanager.h
blobed8942d3e301d30c628a0d55d9b99ba8c1bbe60e
1 /***************************************************************************
2 Copyright 2006 David Nolden <david.nolden.kdevelop@art-master.de>
3 ***************************************************************************/
5 /***************************************************************************
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 ***************************************************************************/
14 #ifndef COLLABORATIONMANAGER_H
15 #define COLLABORATIONMANAGER_H
17 #include "lib/network/safesharedptr.h"
18 #include "filecollaborationmessages.h"
19 #include "kdevteamwork.h"
20 #include "utils.h"
21 #include <QObject>
22 #include <set>
23 #include "safelogger.h"
24 #include <QPointer>
25 #include <memory>
28 class QPoint;
29 class QModelIndex;
30 class QMenu;
31 class QStandardItemModel;
33 ///These helpers can be used to plug own actions into the tree-structure of the collaboration-manager. To get active, a CollaborationTreeActionPointer must be set as the UserData-entry in the model.
34 struct CollaborationTreeAction : public Shared {
35 virtual void fillContextMenu( QMenu* menu ) = 0;
36 virtual void doubleClicked() {
38 virtual void clicked() {
42 ///This class will call a fillContextMenu-function in the targetet-class
43 template <class targetet, class ValueType = int>
44 struct StandardCollaborationTreeAction : public CollaborationTreeAction {
45 QPointer<targetet> target;
46 ValueType var;
48 StandardCollaborationTreeAction( targetet* t, const ValueType& v ) : var( v ), target( t ) {}
49 StandardCollaborationTreeAction( targetet* t ) : target( t ) {}
51 virtual void fillContextMenu( QMenu* menu ) {
52 if ( target ) {
53 target->fillContextMenu( var, menu );
58 typedef SharedPtr< CollaborationTreeAction > CollaborationTreeActionPointer;
60 Q_DECLARE_METATYPE( CollaborationTreeActionPointer )
62 using namespace Teamwork;
63 class KDevTeamwork;
64 class FileCollaborationManager;
65 class FileCollaborationSession;
66 typedef SharedPtr<FileCollaborationSession> FileCollaborationSessionPointer;
68 using namespace std;
70 class CollaborationManager : public QObject, public SafeLogger {
71 Q_OBJECT
72 public:
73 CollaborationManager( KDevTeamwork* tw );
74 ~CollaborationManager();
77 void addCollaboratingUser( const UserPointer& u );
79 void removeCollaboratingUser( const UserPointer& user );
81 bool isCollaborating( const UserPointer& user );
83 void updateList();
85 void restorePartialProjectSession( const QDomElement* el );
87 void savePartialProjectSession( QDomElement* el );
89 void fillUserMenu( QMenu* menu, const UserPointer& user );
91 FileCollaborationManager& fileCollaborationManager() ;
93 QStandardItemModel* developersModel();
95 KDevTeamwork* teamwork();
96 signals:
97 void fillCollaboratingUserMenu( QMenu* menu, const UserPointer& user );
98 void updateModel( QStandardItemModel* model );
100 public slots:
101 void maybeContextMenu();
102 void init();
103 void collaboratingDeveloperClicked( const QModelIndex& i );
104 void collaboratingDeveloperDoubleClicked( const QModelIndex& i );
105 void collaboratingDeveloperContextMenu( const QPoint& );
106 void uiCloseCollaboration();
107 void updateConnection( const TeamworkClientPointer& );
108 void processMessage( const CollaborationMessagePointer& );
109 void sessionStateChanged( const FileCollaborationSessionPointer& session );
111 void uiAcceptCollaboration();
112 void uiDenyCollaboration();
113 void uiRequestCollaboration();
115 private:
116 void contextMenu( const QPoint& pos, const QModelIndex& index );
117 friend class ConnectionRequest;
118 KDevTeamwork* m_teamwork;
119 typedef set
120 <UserPointer> UserSet;
121 UserSet m_collaboratingUsers;
122 AutoConstructPointer<FileCollaborationManager> m_fileCollaboration;
123 QStandardItemModel* m_developersModel; ///Model for the collaborating-developers tree-view
124 auto_ptr<QPersistentModelIndex> m_contextMenuIndex; ///Only used for the timer
126 QAction* m_requestCollaborationAction;
127 QAction* m_closeCollaborationAction;
128 QAction* m_acceptConnectionAction;
129 QAction* m_denyConnectionAction;
131 QTimer* m_contextMenuTimer;
132 bool m_ignoreClick;
135 #endif
137 // kate: space-indent on; indent-width 2; tab-width 2; replace-tabs on