Esempio n. 1
0
	void Cube::init() {

		std::vector<Vertex> vertexList(8);
		vertexList[0] = Vertex(-1.0, 1.0, 1.0, 1.0);
		vertexList[1] = Vertex(-1.0, -1.0, 1.0, 1.0);
		vertexList[2] = Vertex(1.0, -1.0, 1.0, 1.0);
		vertexList[3] = Vertex(1.0, 1.0, 1.0, 1.0);
		vertexList[4] = Vertex(-1.0, 1.0, -1.0, 1.0);
		vertexList[5] = Vertex(-1.0, -1.0, -1.0, 1.0);
		vertexList[6] = Vertex(1.0, -1.0, -1.0, 1.0);
		vertexList[7] = Vertex(1.0, 1.0, -1.0, 1.0);
		
		setVertexList(vertexList);

		std::vector<GLuint> indexList(24);
		indexList[0] = 0;   indexList[1] = 1;   indexList[2] = 2; 	indexList[3] = 3;
		indexList[4] = 3;   indexList[5] = 2;   indexList[6] = 6; 	indexList[7] = 7;   
		indexList[8] = 7;  indexList[9] = 6;  indexList[10] = 5; 	indexList[11] = 4;  
		indexList[12] = 4;  indexList[13] = 5;  indexList[14] = 1; 	indexList[15] = 0;  
		indexList[16] = 0;  indexList[17] = 3;  indexList[18] = 7; 	indexList[19] = 4; 
		indexList[20] = 1;  indexList[21] = 2;  indexList[22] = 6; 	indexList[23] = 5;  

		setIndexList(indexList);
	}
void ToolBarActionProvider::handleGeneralAction(ActionType type, QAction *action)
{
    setIndexList(_currentBuffer);
    NetworkModelController::handleGeneralAction(type, action);
}
// add a list of actions sensible for the current item(s)
void ContextMenuActionProvider::addActions(QMenu *menu,
    const QList<QModelIndex> &indexList_,
    MessageFilter *filter_,
    const QString &contextItem_,
    QObject *receiver_,
    const char *method_,
    bool isCustomBufferView)
{
    if (!indexList_.count())
        return;

    setIndexList(indexList_);
    setMessageFilter(filter_);
    setContextItem(contextItem_);
    setSlot(receiver_, method_);

    if (!messageFilter()) {
        // this means we are in a BufferView (or NickView) rather than a ChatView

        // first index in list determines the menu type (just in case we have both buffers and networks selected, for example)
        QModelIndex index = indexList().at(0);
        NetworkModel::ItemType itemType = static_cast<NetworkModel::ItemType>(index.data(NetworkModel::ItemTypeRole).toInt());

        switch (itemType) {
        case NetworkModel::NetworkItemType:
            addNetworkItemActions(menu, index);
            break;
        case NetworkModel::BufferItemType:
            addBufferItemActions(menu, index, isCustomBufferView);
            break;
        case NetworkModel::IrcUserItemType:
            addIrcUserActions(menu, index);
            break;
        default:
            return;
        }
    }
    else {
        // ChatView actions
        if (contextItem().isEmpty()) {
            // a) query buffer: handle like ircuser
            // b) general chatview: handle like channel iff it displays a single buffer
            // NOTE stuff breaks probably with merged buffers, need to rework a lot around here then
            if (messageFilter()->containedBuffers().count() == 1) {
                // we can handle this like a single bufferItem
                QModelIndex index = Client::networkModel()->bufferIndex(messageFilter()->containedBuffers().values().at(0));
                setIndexList(index);
                addBufferItemActions(menu, index);
                return;
            }
            else {
                // TODO: actions for merged buffers... _indexList contains the index of the message we clicked on
            }
        }
        else {
            // context item = chan or nick, _indexList = buf where the msg clicked on originated
            if (isChannelName(contextItem())) {
                QModelIndex msgIdx = indexList().at(0);
                if (!msgIdx.isValid())
                    return;
                NetworkId networkId = msgIdx.data(NetworkModel::NetworkIdRole).value<NetworkId>();
                BufferId bufId = Client::networkModel()->bufferId(networkId, contextItem());
                if (bufId.isValid()) {
                    QModelIndex targetIdx = Client::networkModel()->bufferIndex(bufId);
                    setIndexList(targetIdx);
                    addAction(BufferJoin, menu, targetIdx, InactiveState);
                    addAction(BufferSwitchTo, menu, targetIdx, ActiveState);
                }
                else
                    addAction(JoinChannel, menu);
            }
            else {
                // TODO: actions for a nick
            }
        }
    }
}
void ToolBarActionProvider::handleNickAction(ActionType type, QAction *action)
{
    setIndexList(_selectedNicks);
    NetworkModelController::handleNickAction(type, action);
}