Example #1
0
void lmcChatRoomWindow::setUIText(void) {
	ui.retranslateUi(this);

	setWindowTitle(getWindowTitle());

	QTreeWidgetItem* pGroupItem = getGroupItem(&GroupId);
	pGroupItem->setText(0, tr("Participants"));

	userChatAction->setText(tr("&Conversation"));
	userFileAction->setText(tr("Send &File"));
	userInfoAction->setText(tr("Get &Information"));
	pbtnSmiley->setToolTip(tr("Insert Smiley"));
	pSaveAction->setText(tr("&Save As..."));
	pSaveAction->setToolTip(tr("Save this conversation"));
	pFontAction->setText(tr("Change Font..."));
	pFontAction->setToolTip(tr("Change message font"));
	pFontColorAction->setText(tr("Change Color..."));
	pFontColorAction->setToolTip(tr("Change message text color"));

	if(groupMode) {
		addContactAction->setText(tr("&Add Contacts..."));
		addContactAction->setToolTip(tr("Add people to this conversation"));
	}

	showStatus(IT_Ok, true);	//	this will force the info label to retranslate
}
Example #2
0
void lmcChatRoomWindow::addUser(User* pUser)
{
	if(!pUser)
		return;

	// Do not add user if user's version is 1.2.10 or less. These versions do not
	// support Public Chat feature.
	if(Helper::compareVersions(pUser->version, "1.2.10") <= 0)
		return;

	//	Do not add user if user is already in the list of participants
	if(peerIds.contains(pUser->id))
		return;

	peerIds.insert(pUser->id, pUser->id);
	peerNames.insert(pUser->id, pUser->name);

	int index = Helper::statusIndexFromCode(pUser->status);

	lmcUserTreeWidgetUserItem *pItem = new lmcUserTreeWidgetUserItem();
	pItem->setData(0, IdRole, pUser->id);
	pItem->setData(0, TypeRole, "User");
	pItem->setData(0, StatusRole, index);
	pItem->setData(0, SubtextRole, pUser->note);
	pItem->setText(0, pUser->name);

	if(index != -1)
		pItem->setIcon(0, QIcon(QPixmap(statusPic[index], "PNG")));

	lmcUserTreeWidgetGroupItem* pGroupItem = (lmcUserTreeWidgetGroupItem*)getGroupItem(&GroupId);
	pGroupItem->addChild(pItem);
	pGroupItem->sortChildren(0, Qt::AscendingOrder);

	// this should be called after item has been added to tree
	setUserAvatar(&pUser->id);

	if(groupMode) {
		XmlMessage xmlMessage;
		xmlMessage.addData(XN_THREAD, threadId);
		xmlMessage.addData(XN_GROUPMSGOP, GroupMsgOpNames[GMO_Join]);

		appendMessageLog(MT_Join, &pUser->id, &pUser->name, &xmlMessage);
		setWindowTitle(getWindowTitle());
		emit messageSent(MT_GroupMessage, NULL, &xmlMessage);
	}

	//	Local user cannot participate in public chat if status is offline
	if(!groupMode && pUser->id.compare(localId) == 0) {
		bool offline = (statusType[Helper::statusIndexFromCode(pUser->status)] == StatusTypeOffline);
		ui.txtMessage->setEnabled(!offline);
		ui.txtMessage->setFocus();
	}
}
Example #3
0
void LogScene::drawIndex(const QModelIndex &index) {
    if (!index.isValid()) {
        return;
    }
    if (_model->rowCount(index) > 0) {
        getGroupItem(index);
    } else {
        Task* task = _model->task(index);
        if (task != NULL) {
            getTaskItem(index);
        }
    }
}
void SimpleNetworkVisualizationHandler::markElementsAsSelected(
						QList<NeuralNetworkElement*> elements) 
{
	//get selected items
	QList<PaintItem*> selectedItems;

	for(QListIterator<NeuralNetworkElement*> i(elements); i.hasNext();) {
		NeuralNetworkElement *elem = i.next();

		Neuron *neuron = dynamic_cast<Neuron*>(elem);
		if(neuron != 0) {
			PaintItem *item = getNeuronItem(neuron);
			if(item != 0) {
				selectedItems.append(item);
			}
			continue;
		}

		Synapse *synapse = dynamic_cast<Synapse*>(elem);
		if(synapse != 0) {
			PaintItem *item = getSynapseItem(synapse);
			if(item != 0) {
				selectedItems.append(item);
			}
			continue;
		}

		NeuroModule *module = dynamic_cast<NeuroModule*>(elem);
		if(module != 0) {
			PaintItem *item = getModuleItem(module);
			if(item != 0) {
				selectedItems.append(item);
			}
			continue;
		}

		NeuronGroup * group = dynamic_cast<NeuronGroup*>(elem);	
		if(group != 0) {
			PaintItem *item = getGroupItem(group);
			if(item != 0) {
				selectedItems.append(item);
			}
			continue;
		}
	}

	mOwner->setSelectedItems(selectedItems);
}
void SimpleNetworkVisualizationHandler::restoreSelection() {

	QList<PaintItem*> selectedItems;

	for(QListIterator<NeuralNetworkElement*> i(mSelectedElements); i.hasNext();) {
		NeuralNetworkElement *elem = i.next();
		Neuron *neuron = dynamic_cast<Neuron*>(elem);
		if(neuron != 0) {
			NeuronItem *item = getNeuronItem(neuron);
			if(item != 0) {
				selectedItems.append(item);
			}
		}
		Synapse *synapse = dynamic_cast<Synapse*>(elem);
		if(synapse != 0) {
			SynapseItem *item = getSynapseItem(synapse);
			if(item != 0) {
				selectedItems.append(item);
			}
		}
		NeuroModule *module = dynamic_cast<NeuroModule*>(elem);
		if(module != 0) {
			ModuleItem *item = getModuleItem(module);
			if(item != 0) {
				selectedItems.append(item);
			}
		}
		NeuronGroup *group = dynamic_cast<NeuronGroup*>(elem);
		if(group != 0) {
			GroupItem *item = getGroupItem(group);
			if(item != 0) {
				selectedItems.append(item);
			}
		}
	}
	if(mOwner != 0) {
		mOwner->setSelectedItems(selectedItems);
	}
	mSelectedElements.clear();
}
Example #6
0
void KonqSidebarHistoryModule::slotEntryAdded( const KonqHistoryEntry *entry )
{
    if ( !m_initialized )
	return;

    m_currentTime = QDateTime::currentDateTime();
    KonqSidebarHistoryGroupItem *group = getGroupItem( entry->url );
    KonqSidebarHistoryItem *item = group->findChild( entry );
    if ( !item )
	item = new KonqSidebarHistoryItem( entry, group, m_topLevelItem );
    else
	item->update( entry );

    // QListView scrolls when calling sort(), so we have to hack around that
    // (we don't want no scrolling every time an entry is added)
    KonqSidebarTree *t = tree();
    t->lockScrolling( true );
    group->sort();
    m_topLevelItem->sort();
    qApp->processOneEvent();
    t->lockScrolling( false );
}
Example #7
0
void KonqSidebarHistoryModule::slotCreateItems()
{
    QApplication::setOverrideCursor( KCursor::waitCursor() );
    clear();

    KonqSidebarHistoryItem *item;
    KonqHistoryEntry *entry;
    KonqHistoryList entries( KonqHistoryManager::kself()->entries() );
    KonqHistoryIterator it( entries );
    m_currentTime = QDateTime::currentDateTime();

    // the group item and the item of the serverroot '/' get a fav-icon
    // if available. All others get the protocol icon.
    while ( (entry = it.current()) ) {
	KonqSidebarHistoryGroupItem *group = getGroupItem( entry->url );
	item = new KonqSidebarHistoryItem( entry, group, m_topLevelItem );

	++it;
    }

    KConfig *kc = KGlobal::config();
    KConfigGroupSaver cs( kc, "HistorySettings" );
    QStringList openGroups = kc->readListEntry("OpenGroups");
    QStringList::Iterator it2 = openGroups.begin();
    KonqSidebarHistoryGroupItem *group;
    while ( it2 != openGroups.end() ) {
	group = m_dict.find( *it2 );
	if ( group )
	    group->setOpen( true );

	++it2;
    }

    QApplication::restoreOverrideCursor();
    m_initialized = true;
}
bool SimpleNetworkVisualizationHandler::updateNetworkView() {
	TRACE("SimpleNetworkVisualizationHandler::updateNetworkView");

	QMutexLocker locker(Neuro::getNeuralNetworkManager()->getNetworkExecutionMutex());
	
	QList<NeuronItem*> currentNeuronItems = mNeurons;
	QList<SynapseItem*> currentSynapseItems = mSynapses;
	QList<ModuleItem*> currentModuleItems = mModules;
	QList<GroupItem*> currentGroupItems = mGroups;

	for(QListIterator<ModuleItem*> i(currentModuleItems); i.hasNext();) {
		ModuleItem *moduleItem = i.next();
		QList<PaintItem*> members = moduleItem->getMemberItems();
		for(QListIterator<PaintItem*> j(members); j.hasNext();) {
			moduleItem->removeMemberItem(j.next());
		}
	}


	mNeurons.clear();
	mSynapses.clear();
	mModules.clear();
	mGroups.clear();

	if(mNetwork != 0) {

		//setup neurons
		QList<Neuron*> neurons = mNetwork->getNeurons();
		
		for(int i = 0; i < neurons.size(); ++i) {

			Neuron *neuron = neurons.at(i);

			NeuronItem *item = getNeuronItem(neuron);
			if(item == 0) {
				if(!mNeuronItemPool.empty()) {
					item = mNeuronItemPool.takeFirst();
				}
				if(item == 0) {
					item = mNeuronItemPrototype->createCopy();
				}
			}

			if(neuron->hasProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION)) {
				NetworkEditorUtil::setPaintItemLocation(item, 
						neuron->getProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION));
			}
			else {
				setLocationByGrid(item);
			}

			item->setNeuron(neuron);
			item->setActive(true);
			item->setHidden(false);

			if(!mNeurons.contains(item)) {
				mNeuronLookup.insert(neuron, item);
				mNeurons.append(item);
			}

			currentNeuronItems.removeAll(item);
		}

		//remove obsolete neuron items
		for(QListIterator<NeuronItem*> i(currentNeuronItems); i.hasNext();) {
			NeuronItem *item = i.next();
			item->setHidden(true);
			item->setActive(false);
			item->setToHiddenLayer(false);
			mNeuronLookup.remove(item->getNeuron());
			item->setNeuron(0);
			item->setParent(0);
			mNeuronItemPool.append(item);
		}

		//setup synapses
		QList<Synapse*> synapses = mNetwork->getSynapses();

		for(int i = 0; i < synapses.size(); ++i) {

			Synapse *synapse = synapses.at(i);

			SynapseItem *item = getSynapseItem(synapse);

			if(item == 0) {
				if(!mSynapseItemPool.empty()) {
					item = mSynapseItemPool.takeFirst();
				}
				if(item == 0) {
					item = mSynapseItemPrototype->createCopy();
				}
			}
			if(synapse->hasProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION)) {
				NetworkEditorUtil::setPaintItemLocation(item, 
						synapse->getProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION));
			}
			else {
				setLocationByGrid(item);
			}

			item->setSynapse(synapse);
			item->setActive(true);
			item->setHidden(false);

			if(!mSynapses.contains(item)) {
				mSynapseLookup.insert(synapse, item);
				mSynapses.append(item);
			}

			currentSynapseItems.removeAll(item);
		}

		//remove obsolete synapse items
		for(QListIterator<SynapseItem*> i(currentSynapseItems); i.hasNext();) {
			SynapseItem *item = i.next();
			item->setHidden(true);
			item->setActive(false);
			item->setToHiddenLayer(false);
			mSynapseLookup.remove(item->getSynapse());
			item->setSynapse(0);
			item->setParent(0);
			mSynapseItemPool.append(item);
		}

		//setup modules
		QList<NeuroModule*> modules = mNetwork->getNeuroModules();

		for(int i = 0; i < modules.size(); ++i) {

			NeuroModule *module = modules.at(i);

			ModuleItem *item = getModuleItem(module);

			if(item == 0) {
				if(!mModuleItemPool.empty()) {
					item = mModuleItemPool.takeFirst();
				}
				if(item == 0) {
					item = mModuleItemPrototype->createCopy();
				}
			}
			if(module->hasProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION)) {
				NetworkEditorUtil::setPaintItemLocation(item, 
						module->getProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION));
			}
			else {
				setLocationByGrid(item);
			}
			if(module->hasProperty(NeuralNetworkConstants::TAG_MODULE_SIZE)) {
				NetworkEditorUtil::setModuleItemSize(item, 
						module->getProperty(NeuralNetworkConstants::TAG_MODULE_SIZE));
			}

			item->setModule(module);
			item->setActive(true);
			item->setHidden(false);

			QList<PaintItem*> memberItems = item->getMemberItems();

			for(QListIterator<PaintItem*> k(memberItems); k.hasNext();) {
				PaintItem *it = k.next();
				QPointF pos = it->getGlobalPosition();
				item->removeMemberItem(it);
				it->setLocalPosition(pos);
			}

			if(!mModules.contains(item)) {
				mModuleLookup.insert(module, item);
				mModules.append(item);
			}
			currentModuleItems.removeAll(item);

			//add member neurons to module
			QRectF moduleBounds = item->getBoundingBox();
			QList<Neuron*> members = module->getNeurons();

			for(QListIterator<Neuron*> j(members); j.hasNext();) {
				Neuron *n = j.next();

				if(n == 0) {
					continue;
				}

				NeuronItem *neuronItem = getNeuronItem(n);
				if(neuronItem == 0) {
					continue;
				}
				QRectF neuronBounds = neuronItem->getBoundingBox();

				QPointF pos = neuronItem->getLocalPosition() - item->getGlobalPosition();
				pos.setX(Math::min(Math::max(pos.x(), (neuronBounds.width() / 2.0)),
						 moduleBounds.width() - (neuronBounds.width() / 2.0)));
				pos.setY(Math::min(Math::max(pos.y(), (neuronBounds.height() / 2.0)),
						 moduleBounds.height() - (neuronBounds.height() / 2.0)));
				

				neuronItem->setLocalPosition(pos);
				item->addMemberItem(neuronItem);
			}

			//add member synapses to module
			for(QListIterator<Synapse*> j(synapses); j.hasNext();) {		
				Synapse *s = j.next();
				if(s == 0) {
					continue;
				}
				Neuron *n = s->getSource();
				if(n == 0) {
					continue;
				}

				if(!members.contains(n)) {
					continue;
				}

				SynapseItem *synapseItem = getSynapseItem(s);
				if(synapseItem == 0) {
					continue;
				}
				synapseItem->setLocalPosition(
								synapseItem->getLocalPosition() - item->getGlobalPosition());

				item->addMemberItem(synapseItem);
			}	
		}

		//remove obsolete module items
		for(QListIterator<ModuleItem*> i(currentModuleItems); i.hasNext();) {
			ModuleItem *item = i.next();
			item->setHidden(true);
			item->setActive(false);
			item->setToHiddenLayer(false);
			mModuleLookup.remove(item->getNeuroModule());
			item->setModule(0);
			item->setParent(0);
			mModuleItemPool.append(item);
		}

		//check if submodules have to be added.
		for(int i = 0; i < modules.size(); ++i) {
			NeuroModule *module = modules.at(i);

			if(module == 0) {
				continue;
			}

			ModuleItem *moduleItem = getModuleItem(module);

			if(moduleItem == 0) {
				continue;
			}

			QList<NeuroModule*> subModules = module->getSubModules();

			for(QListIterator<NeuroModule*> j(subModules); j.hasNext();) {
				NeuroModule *subModule = j.next();

				if(subModule == 0) {
					continue;
				}

				ModuleItem *subModuleItem = getModuleItem(subModule);

				if(subModuleItem == 0) {
					continue;
				}

				subModuleItem->setLocalPosition(
						subModuleItem->getLocalPosition() - moduleItem->getGlobalPosition());
				moduleItem->addMemberItem(subModuleItem);
			}
		}

		//setup groups
		QList<NeuronGroup*> groups = mNetwork->getNeuronGroups();

		for(int i = 0; i < groups.size(); ++i) {

			NeuronGroup *group = groups.at(i);
			if(dynamic_cast<NeuroModule*>(group) != 0) {
				//ignore neuro modules
				continue;
			}

			GroupItem *item = getGroupItem(group);

			if(item == 0) {
				if(!mGroupItemPool.empty()) {
					item = mGroupItemPool.takeFirst();
				}
				if(item == 0) {
					item = mGroupItemPrototype->createCopy();
				}
			}
			if(group->hasProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION)) {
				NetworkEditorUtil::setPaintItemLocation(item, 
						group->getProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION));
			}
			else {
				setLocationByGrid(item);
			}

			item->setNeuronGroup(group);
			item->setActive(true);
			item->setHidden(false);

			if(!mGroups.contains(item)) {
				mGroupLookup.insert(group, item);
				mGroups.append(item);
			}

			currentGroupItems.removeAll(item);
		}

		//remove obsolete group items
		for(QListIterator<GroupItem*> i(currentGroupItems); i.hasNext();) {
			GroupItem *item = i.next();
			item->setHidden(true);
			item->setActive(false);
			item->setToHiddenLayer(false);
			mGroupLookup.remove(item->getNeuronGroup());
			item->setNeuronGroup(0);
			item->setParent(0);
			mGroupItemPool.append(item);
		}

		//update location property
		for(QListIterator<NeuronItem*> i(mNeurons); i.hasNext();) {
			NeuronItem *item = i.next();
			if(item == 0) {
				continue;
			}
			Neuron *neuron = item->getNeuron();
			if(neuron == 0 || neuron->hasProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION)) {
				continue;
			}
			neuron->setProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION, 
											QString::number(item->getGlobalPosition().x()) + "," 
											+ QString::number(item->getGlobalPosition().y()) + ",0");
		}
		for(QListIterator<SynapseItem*> i(mSynapses); i.hasNext();) {
			SynapseItem *item = i.next();
			if(item == 0) {
				continue;
			}
			Synapse *synapse = item->getSynapse();
			if(synapse == 0 || synapse->hasProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION)) {
				continue;
			}
			synapse->setProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION,
 											QString::number(item->getGlobalPosition().x()) + "," 
											+ QString::number(item->getGlobalPosition().y()) + ",0");
		}
		for(QListIterator<ModuleItem*> i(mModules); i.hasNext();) {
			ModuleItem *item = i.next();
			if(item == 0) {
				continue;
			}
			NeuroModule *module = item->getNeuroModule();
			if(module == 0 || module->hasProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION)) {
				continue;
			}
			module->setProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION,
											QString::number(item->getGlobalPosition().x()) + "," 
											+ QString::number(item->getGlobalPosition().y()) + ",0");
		}
		for(QListIterator<GroupItem*> i(mGroups); i.hasNext();) {
			GroupItem *item = i.next();
			if(item == 0) {
				continue;
			}
			NeuronGroup *group = item->getNeuronGroup();
			if(group == 0 || group->hasProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION)) {
				continue;
			}
			group->setProperty(NeuralNetworkConstants::TAG_ELEMENT_LOCATION,
											QString::number(item->getGlobalPosition().x()) + "," 
											+ QString::number(item->getGlobalPosition().y()) + ",0");
		}
	}
	else {
		clearVisualization();
	}
	updateVisualizationSet(); 
	
	if(mOwner != 0) {
		mOwner->updateHiddenLayerMode();
	}

	return true;
}
Example #9
0
/****************************************************************************
**
** Copyright (C) 2015
**
** This file is generated by the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

// Include
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QMessageBox>
#include <QHeaderView>
#include <QEvent>
#include <QImage>
#include <QPixmap>
#include <QTreeWidgetItem>
#include "tool_sceneviewwidget.h"

namespace Magus
{
//****************************************************************************/
QtSceneViewWidget::QtSceneViewWidget(const QString& iconDir, QWidget* parent) : QWidget(parent)
{
    setWindowTitle(QString("Scene view"));
    mIconDir = iconDir;
    QVBoxLayout* mainLayout = new QVBoxLayout;
    mSearchLayout = new QHBoxLayout;
    mTreeLayout = new QVBoxLayout;

    // Create edit
    mSearchLine = new QLineEdit();
    connect(mSearchLine, SIGNAL(textChanged(QString)), this, SLOT(searchLineTextChanged(QString)));

    // Create findbutton
    QImage imageSearch(mIconDir + TOOL_SCENEVIEW_ICON_SEARCH);
    QPixmap pixMapSearch = QPixmap::fromImage(imageSearch).scaled(TOOL_SCENEVIEW_ICON_WIDTH, TOOL_SCENEVIEW_ICON_WIDTH);
    mSearchLabel = new QLabel();
    mSearchLabel->setPixmap(pixMapSearch);
    mSearchLabel->setContentsMargins(-8, -8, -8, -8);

    // Create clearbutton
    QImage imageClear(mIconDir + TOOL_SCENEVIEW_ICON_CLOSE);
    QPixmap pixMapClear = QPixmap::fromImage(imageClear).scaled(TOOL_SCENEVIEW_ICON_WIDTH, TOOL_SCENEVIEW_ICON_WIDTH);
    mSearchClearButton = new QPushButton();
    mSearchClearButton->setStyleSheet(QString("QPushButton {border: none; background: transparent;} QPushButton:hover {background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #565656, stop:1 #464646);}"));
    mSearchClearButton->setIcon(QIcon(pixMapClear));
    mSearchClearButton->setIconSize(QSize(TOOL_SCENEVIEW_ICON_WIDTH, TOOL_SCENEVIEW_ICON_WIDTH));
    mSearchClearButton->setContentsMargins(-8, -8, -8, -8);
    connect(mSearchClearButton, SIGNAL(clicked()), this, SLOT(clearSearchLine()));


    // Misc
    mVisibilityIconVisibleForGroups = true;
    mVisibilityIconVisibleForAssets = true;
    mDeletionIconVisibleForGroups = true;
    mDeletionIconVisibleForAssets = true;

    // Layout
    mSearchLayout->addWidget(mSearchLabel, 1);
    mSearchLayout->addWidget(mSearchLine, 2000);
    mSearchLayout->addWidget(mSearchClearButton, 1);
    setVisibilitySearchWidgets(false);
    mainLayout->addLayout(mSearchLayout, 1);
    mainLayout->addLayout(mTreeLayout, 2000);
    setLayout(mainLayout);
}

//****************************************************************************/
QtSceneViewWidget::~QtSceneViewWidget(void)
{
    // Delete all QtAssetGroups in mAssetGroupMap
    foreach (QtAssetGroup* group, mAssetGroupMap)
        delete group;

    mAssetGroupMap.clear();

}

//****************************************************************************/
bool QtSceneViewWidget::eventFilter(QObject* object, QEvent* event)
{
    QMouseEvent* mouseEvent = (QMouseEvent*) event;
    switch ((int) event->type())
    {
    case QEvent::MouseButtonPress:
        mouseClickHandler(mouseEvent);
        break;
    }
    return QObject::eventFilter(object, event);
}

//****************************************************************************/
void QtSceneViewWidget::mouseClickHandler(QMouseEvent* event)
{
    switch ((int) event->button())
    {
    case Qt::LeftButton:
    {
        // Get the selected item of the visible sceneview
        QTreeWidget* sceneView = getCurrentVisibleScene();
        if (sceneView)
        {
            QTreeWidgetItem* item = sceneView->itemAt(event->pos());
            int col = sceneView->columnAt(event->pos().x());
            if (itemIsGroup(item))
            {
                if (col == TOOL_SCENEVIEW_COLUMN_GROUP_CLOSE)
                {
                    handleDeletionOfGroup(sceneView, item);
                    return;
                }
                else if (col == TOOL_SCENEVIEW_COLUMN_GROUP_VISIBILITY)
                {
                    // Toggle visibility
                    toggleVisibilityOfGroup(item);
                }

                int groupId = getGroupIdOfGroupItem(item);
                emit groupSelected(sceneView, groupId);
            }
            else if (itemIsAsset(item))
            {
                if (col == TOOL_SCENEVIEW_COLUMN_ASSET_CLOSE)
                {
                    handleDeletionOfAsset(sceneView, item);
                    return;
                }
                else if (col == TOOL_SCENEVIEW_COLUMN_ASSET_VISIBILITY)
                {
                    // Toggle visibility
                    toggleVisibilityOfAsset(item);
                }

                int groupId = getGroupIdOfAssetItem(item);
                int assetId = getAssetIdOfAssetItem(item);
                emit assetSelected(sceneView, groupId, assetId);
            }
        }
    }
    break;

    case Qt::RightButton:
    {
        // TODO
    }
    break;
    }
}

//****************************************************************************/
bool QtSceneViewWidget::groupIsVisible(QTreeWidgetItem* groupItem)
{
    if (itemIsGroup(groupItem))
    {
        return (groupItem->data(TOOL_SCENEVIEW_KEY_VISIBLE, Qt::UserRole)).toBool();
    }

    return false;
}

//****************************************************************************/
bool QtSceneViewWidget::groupOfAssetItemIsVisible(QTreeWidgetItem* assetItem)
{
    if (itemIsAsset(assetItem))
    {
        QTreeWidgetItem* groupItem = assetItem->parent();
        if (groupItem)
        {
            return (groupItem->data(TOOL_SCENEVIEW_KEY_VISIBLE, Qt::UserRole)).toBool();
        }
    }

    return false;
}

//****************************************************************************/
bool QtSceneViewWidget::assetIsVisible(QTreeWidgetItem* assetItem)
{
    if (itemIsAsset(assetItem))
    {
        return (assetItem->data(TOOL_SCENEVIEW_KEY_VISIBLE, Qt::UserRole)).toBool();
    }

    return false;
}

//****************************************************************************/
void QtSceneViewWidget::toggleVisibilityOfGroup(QTreeWidgetItem* groupItem)
{
    if (!groupItem)
        return;

    bool visible = groupIsVisible(groupItem);
    setVisibilityOfGroup(groupItem, !visible);
}

//****************************************************************************/
void QtSceneViewWidget::setVisibilityOfGroup(int sceneId, int groupId, bool visible)
{
    QTreeWidgetItem* groupItem = getGroupItem(sceneId, groupId);
    setVisibilityOfGroup(groupItem, visible);
}