Ejemplo n.º 1
0
void Controller::update()
{
    GuiDataVect data = engine.getVisibleData();
    clearCurrentFrameData();
    QString roomId = QString::fromStdString(engine.getRoomsManager()->currentRoom()->id);
    if (current_room != roomId) {
        current_room = roomId;
        emit roomChanged();
    }
    for (GuiDataVect::iterator i = data.begin(); i != data.end(); ++i){
        GuiData data = (*i);
        engine.relToAbsRect(data.rect);
        QGuiData *d = new QGuiData();
        d->setX(data.rect.x);
        d->setY(data.rect.y);
        d->setWidth(data.rect.w);
        d->setHeight(data.rect.h);
        d->setAlpha(data.alpha);
        d->setId(QString::fromStdString(data.id));
        if (data.text != ""){
            d->setTextFlag();
            d->setContent(QString::fromStdString(data.text));
        } else if (data.image != ""){
            d->setContent(QString::fromStdString(data.image));
        } else {
            continue; //inventory_label non ha ne testo ne immagine
        }
        _currentFrameData.append(d);
    }
    emit currentFrameChanged();
}
void WidgetChatMiddle::removeBuffer(Irc::Buffer* buffer)
{
	QList<WidgetChatRoom*> allRooms = ui->stackedWidgetChatRooms->findChildren<WidgetChatRoom*>();

	for(int i = 0; i < allRooms.size(); ++i)
	{
		if(allRooms.at(i)->sRoomName == buffer->receiver())
		{
			ui->stackedWidgetChatRooms->removeWidget(allRooms.at(i));
			allRooms.at(i)->~WidgetChatRoom();
		}
	}
	channelList.removeOne(buffer->receiver());
	channelListModel->setStringList(channelList);
	buffer->deleteLater();
	emit roomChanged(currentRoom());
}
WidgetChatRoom* WidgetChatMiddle::roomByBuffer(Irc::Buffer* buffer)
{
	QList<WidgetChatRoom*> allRooms = ui->stackedWidgetChatRooms->findChildren<WidgetChatRoom*>();
	for(int i = 0; i < allRooms.size(); ++i)
	{
		if(allRooms.at(i)->sRoomName == buffer->receiver() && allRooms.at(i) != 0)
		{
			return allRooms.at(i);
		}
	}
	//qDebug() << "CREATING A NEW TAB :: " + name;
	// if the tab doesn't exist, create it
	WidgetChatRoom *room = new WidgetChatRoom(quazaaIrc, buffer);
	connect(room->chatUserListModel, SIGNAL(updateUserCount(ChatUserListModel*,int,int)), this, SLOT(userCountUpdated(ChatUserListModel*,int,int)));
	room->setRoomName(buffer->receiver());
	ui->stackedWidgetChatRooms->addWidget(room);
	channelList << buffer->receiver();
	channelListModel->setStringList(channelList);
	emit roomChanged(room);
	return room;
}
WidgetChatRoom* WidgetChatMiddle::roomByName(QString roomName,Irc::Buffer *buffer)
{
	QList<WidgetChatRoom*> allRooms = ui->stackedWidgetChatRooms->findChildren<WidgetChatRoom*>();
	for(int i = 0; i < allRooms.size(); ++i)
	{
		if(allRooms.at(i)->sRoomName == roomName && allRooms.at(i) != 0)
		{
			return allRooms.at(i);
		}
	}
	WidgetChatRoom *room = new WidgetChatRoom(quazaaIrc, buffer);
	connect(room->chatUserListModel, SIGNAL(updateUserCount(ChatUserListModel*,int,int)), this, SLOT(userCountUpdated(ChatUserListModel*,int,int)));
	room->setRoomName(roomName);
	ui->stackedWidgetChatRooms->addWidget(room);
	channelList << buffer->receiver();
	channelListModel->setStringList(channelList);
	emit roomChanged(room);
	return room;

	return 0;
}
void WidgetChatMiddle::changeRoom(int index)
{
	ui->stackedWidgetChatRooms->setCurrentIndex(index);
	emit roomChanged(currentRoom());
}
void WidgetChatMiddle::on_stackedWidgetChatRooms_currentChanged(int)
{
	//qDebug() << "Emitting channel changed.";
	if(ui->stackedWidgetChatRooms->children().size() > -1)
		emit roomChanged(currentRoom());
}