Beispiel #1
0
User::User(QTcpSocket *socket, Server *server) : _nextBlockSize((quint16)0)
{
    _socketUser = socket;
    _serverUser = server;
    _isAuthorized = false;
    _nameUser = "";

    connect(_socketUser,SIGNAL(readyRead()),this,SLOT(slotReadyClient()));
    connect(_socketUser, SIGNAL(disconnected()), this, SLOT(slotDisconnectUser()));
}
/**
	popup menu
 */
void MainWindows::slotPopupMenu(  const QPoint & point )
{
	currentPopupMenuItem = treeWidget->itemAt ( point );
	// if object is dead
	if (!QTreeWidgetItemList.contains(currentPopupMenuItem)) return;

	if( currentPopupMenuItem )
	{
		// create popup menu
		menuPopup->clear();

		if (currentPopupMenuItem==item_server) // if a server item
		{
			menuPopup->addAction ( tr( "Properties"),this,SLOT(InfoServer() ) );
			QAction * action=menuPopup->addAction ( tr( "Send out message to all users"),this,SLOT(slotSendMessageAllUsers() ) );
			action->setEnabled(permitSendMsg);
			menuPopup->exec( QCursor::pos() );
			return;
		}
		if (currentPopupMenuItem->parent()==item_server) // if a machine item
		{
			machine * myItem=dynamic_cast<machine *>(currentPopupMenuItem);
			if (!myItem) return;
			menuPopup->addAction ( tr( "Properties"),this,SLOT(InfoMachine() ) );
			QAction * action=menuPopup->addAction ( tr( "Send out message to")+ " " + myItem->machine_name,this,SLOT(slotSendMessage() ) );
			action->setEnabled(permitSendMsg); // if client can send popup messages
			menuPopup->exec( QCursor::pos() );
			return;
		}
		if (currentPopupMenuItem->parent()->parent()==item_server) // if an user item
		{
			user * myItem=dynamic_cast<user *>(currentPopupMenuItem);
			if (!myItem) return;
			menuPopup->addAction ( tr( "Properties"),this,SLOT(InfoUser() ) );
			QAction * action=menuPopup->addAction ( tr( "Disconnect user")+ " " + myItem->username,this,SLOT(slotDisconnectUser() ) );
			action->setEnabled(permitDisconnectUser); //  if client can disconnect an user
			menuPopup->exec( QCursor::pos() );
			return;
		}
		// it's a locked file or share
		menuPopup->addAction ( tr( "Properties"),this,SLOT(InfoService() ) );
		menuPopup->exec( QCursor::pos() );
	}
}