summaryrefslogblamecommitdiffstats
path: root/src/server/connectionframe/connectionframe.h
blob: d5551cbfeace16c0d671bd494c50e5a48881a42c (plain) (tree)
1
2
3
4
5
6
7
8
9


                           
                          
 



                                                                               













                                        
                                             





                                 
                                
 


                         


                                    
                         

                      

                                                 
                                

                                           
                             



                                                             





                                                                       
                                                                                      

                                          
                                                                    
 

                                                                    


                                                                                              
                                                                 
                                                                                         


                                                              
                              











                                                       
                                                                    



                                                   
                                    
                                                                                              
                                


      
#ifndef _CONNECTIONFRAME_H_
#define _CONNECTIONFRAME_H_
#include <QtGui>
#include "../net/client.h"

/**
 * Class for representing the clients of current session, with a specific frame
 * displaying username and hostname for each one.
 */
class ConnectionFrame : public QGroupBox
{

Q_OBJECT

private:

	QString _computerId;

	QBoxLayout *_mainLayout;
	QBoxLayout *_iconLayout;
	QLabel *_lblUserName;
	QLabel *_lblHostName;

	QLabel *_icoCam, *_icoEye, *_icoLock;
	QList<QLabel*> _icons;

	QPixmap _remoteScreen;

	QPoint _clickPoint;
	QPoint _previousPosition;
	QPoint _currentPosition;

    QPoint _gridPosition;


	Client *_client;

	int _timerId, _timerCounter;
	bool _isSelected;
	bool _isTutor;

	static const int _startDragDistance = 40;

	void showDefaultThumb();
	QLabel* addIcon(const QIcon* icon);

	// Static stylesheets
	static const QString studentLblStyle, studentBgStyle;
	static const QString tutorLblStyle, tutorBgStyle;
	static const QString selectedBgStyle;

public:
	ConnectionFrame(QWidget* parent, int width, int height);
	virtual ~ConnectionFrame();

	const QPixmap& getFramePixmap() const { return _remoteScreen; }
	void setSize(int width, int height);
	const inline QPoint& getPreviousPosition() const { return _previousPosition; }
	void assignClient(Client *client);
	void setSelection(bool selected);
	const inline bool isSelected() const { return _isSelected; }

    inline void setGridPosition(QPoint pos) { _gridPosition = pos; }
    inline QPoint getGridPosition() const { return _gridPosition; };
	const inline void setCurrentPosition(QPoint position) { _currentPosition = position; }
	const inline QPoint& getCurrentPosition() const { return _currentPosition; }

	const QString& computerId() const { return _computerId; }
	const inline void setComputerId(QString computerId) { _computerId = computerId; }
	Client* client() const { return _client; }

	inline const bool isTutor() const { return _isTutor; }
	void setTutor(bool b);

protected:
	void mouseDoubleClickEvent(QMouseEvent* event);
	void mouseReleaseEvent(QMouseEvent* e);
	void enterEvent(QEvent* event);
	void leaveEvent(QEvent* event);
	void mousePressEvent(QMouseEvent* event);
	void mouseMoveEvent(QMouseEvent* event);
	void paintEvent(QPaintEvent *event);
	void timerEvent(QTimerEvent* event);

signals:
	void frameMoved(bool activateTrash, ConnectionFrame* frame);
	void doubleClicked(ConnectionFrame* frame);
	void clicked(ConnectionFrame* frame);

private slots:
	void onClientDisconnected();
	void onThumbUpdated(Client* client, const QPixmap& thumb, const QByteArray& rawImage);
	void updateAppearance();
};

#endif