#ifndef _CONNECTIONFRAME_H_ #define _CONNECTIONFRAME_H_ #include #include "../net/client.h" class MainWindow; /** * 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 *_lblExamMode; QLabel *_icoCam, *_icoEye, *_icoLock; QList _icons; QPixmap _remoteScreen; QPoint _clickPoint; QPoint _previousPosition; QPoint _gridPosition; Client *_client; int _timerId, _timerCounter; bool _isSelected; bool _isTutor; static const int _startDragDistance = 40; void showDefaultThumb(); QLabel* addIcon(const QIcon* icon); MainWindow *_mainWindow; public: static bool paintDisabled; ConnectionFrame(MainWindow* main, QWidget* parent); virtual ~ConnectionFrame(); const inline QPoint getGridPosition() const { return _gridPosition; } void setGridPosition(int x, int y); void setGridPosition(const QPoint& pos); void updateGeometry(); const QPixmap& getFramePixmap() const { return _remoteScreen; } void assignClient(Client *client); void setSelection(bool selected); inline bool isSelected() { return _isSelected; } const QString& computerId() const { return _computerId; } void setComputerId(QString computerId) { if (_client != NULL) return; _computerId = computerId; updateLabels(); } Client* client() const { return _client; } inline bool isTutor() { 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(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(); void updateLabels(); }; #endif