int MoodBox::AppEventHandler::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: reopenApplication(); break;
        case 1: quitApplication(); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
/*! \brief Reload the selected entity node
*/
void EntitiesTreeWidget::onReopen()
{
    QTreeWidgetItem *it = currentItem();
    QTreeWidgetItem *parent = it -> parent();
    int index = it -> parent() -> indexOfChild(it);

    if(!it){
        return;
    }

    if(it->parent() == applicationNode){
        if(it->data(0,Qt::UserRole)  == yarp::manager::APPLICATION){
            yarp::manager::Application *app = (yarp::manager::Application*)it->data(0,Qt::UserRole + 1).toLongLong();
            if(app){
                QString fileName = QString("%1").arg(app->getXmlFile());
                QString appName = it->text(0);

                reopenApplication(appName,fileName);
            }

        }
    }else
    if(it->parent() == resourcesNode){
        if(it->data(0,Qt::UserRole)  == yarp::manager::RESOURCE){
            yarp::manager::Computer *res = (yarp::manager::Computer*)it->data(0,Qt::UserRole + 1).toLongLong();
            if(res){
                QString fileName = QString("%1").arg(res->getXmlFile());
                QString resName = it->text(0);

                reopenResource(resName,fileName);
            }
        }
    }else
    if(it->parent() == modulesNode){
        if(it->data(0,Qt::UserRole)  == yarp::manager::MODULE){
            yarp::manager::Module *mod = (yarp::manager::Module*)it->data(0,Qt::UserRole + 1).toLongLong();
            if(mod){
                QString fileName = QString("%1").arg(mod->getXmlFile());
                QString modName = it->text(0);

                reopenModule(modName,fileName);
            }
        }
    }

    parent -> child(index) -> setSelected(true);
    scrollToItem(parent -> child(index));
}