示例#1
0
QVariant qvariant_from_sexp(SEXP rvalue, int index) {
  QVariant variant;
  if (index == -1) {
    /* If a particular element is not selected, then non-lists of
       length one are considered scalars. Otherwise, collections.
       Except for raw vectors, which are naturally QByteArrays.
    */
    if (TYPEOF(rvalue) == RAWSXP)
      return QVariant(from_sexp<QByteArray>(rvalue));
    else if (TYPEOF(rvalue) == VECSXP || length(rvalue) > 1) {
      SEXP rlist = coerceVector(rvalue, VECSXP);
      if (getAttrib(rvalue, R_NamesSymbol) != R_NilValue)
        variant = asQVariantOfType(rlist, QMetaType::QVariantMap);
      else variant = asQVariantOfType(rlist, QMetaType::QVariantList);
      return variant;
    }
    index = 0;
  }
  switch(TYPEOF(rvalue)) {
  case RAWSXP:
    variant = qVariantFromValue(RAW(rvalue)[index]);
    break;
  case LGLSXP:
    // Rprintf("Logical\n");
    // FIXME: by converting to 'bool' all NA become TRUE
    variant = QVariant((bool)LOGICAL(rvalue)[index]);
    break;
  case REALSXP:
    // Rprintf("Real\n");
    variant = QVariant(REAL(rvalue)[index]);
    break;
  case INTSXP:
    // Rprintf("Integer\n");
    {
      SEXP levels;
      if ((levels = getAttrib(rvalue, R_LevelsSymbol)) != R_NilValue) {
        int level = INTEGER(rvalue)[index];
        SEXP level_str = NA_STRING;
        /*Rprintf("getting level: %d\n", level);*/
        if (level != NA_INTEGER)
          level_str = STRING_ELT(levels, level - 1);
        variant = QVariant(sexp2qstring(level_str));
      } else variant = QVariant(INTEGER(rvalue)[index]);
      break;
    }
  case STRSXP:
    // Rprintf("String\n");
    variant = QVariant(sexp2qstring(STRING_ELT(rvalue, index)));
    break;
  case EXTPTRSXP:
    // Rprintf("External pointer\n");
    variant = qVariantFromValue(unwrapPointer(rvalue, void));
    break;
  case VECSXP:
    variant = from_sexp<QVariant>(VECTOR_ELT(rvalue, index));
    break;
  case ENVSXP: {
    SmokeObject *so = SmokeObject::fromSexp(rvalue);
    if (so->instanceOf("QWidget"))
      variant =
        qVariantFromValue(reinterpret_cast<QWidget *>(so->castPtr("QWidget")));
    else if (so->instanceOf("QObject"))
      variant =
        qVariantFromValue(reinterpret_cast<QObject *>(so->castPtr("QObject")));
    else {
      QMetaType::Type type = (QMetaType::Type) QMetaType::type(so->className());
      if (type)
        variant = asQVariantOfType(rvalue, type, false);
      else variant = qVariantFromValue(so->ptr());
    }
  }
    break;
  case NILSXP: // invalid QVariant
    break;
  default:
    error("Converting to QVariant: unhandled R type");
  }
  return variant;
}
示例#2
0
     QScriptValue REcmaLinetypePattern::create(QScriptContext* context, QScriptEngine* engine) 
    
    {
    if (context->thisObject().strictlyEquals(
       engine->globalObject())) {
       return REcmaHelper::throwError(
       QString::fromLatin1("RLinetypePattern(): Did you forget to construct with 'new'?"),
           context);
    }

    QScriptValue result;
        
            // generate constructor variants:
            
    if( context->argumentCount() ==
        0
    ){
    // prepare arguments:
    
    // end of arguments

    // call C++ constructor:
    
            // copyable class:
            RLinetypePattern
                    cppResult;
                
            result = engine->newVariant(
            context->thisObject(), qVariantFromValue(cppResult));
        
    } else 

    if( context->argumentCount() ==
        1
                && (
                
                        context->argument(
                        0
                        ).isVariant()
                        ||
                    
                        context->argument(
                        0
                        ).isQObject()
                        ||
                    
                        context->argument(
                        0
                        ).isNull()
                ) /* type: RLinetypePattern */
            
    ){
    // prepare arguments:
    
                    // argument isCopyable and has default constructor and isSimpleClass 
                    RLinetypePattern*
                    ap0 =
                    qscriptvalue_cast<
                    RLinetypePattern*
                        >(
                        context->argument(
                        0
                        )
                    );
                    if (ap0 == NULL) {
                           return REcmaHelper::throwError("RLinetypePattern: Argument 0 is not of type RLinetypePattern.",
                               context);                    
                    }
                    RLinetypePattern 
                    a0 = 
                    *ap0;
                
    // end of arguments

    // call C++ constructor:
    
            // copyable class:
            RLinetypePattern
                    cppResult(
                    a0
                    );
                
            result = engine->newVariant(
            context->thisObject(), qVariantFromValue(cppResult));
        
    } else 

    {
       return REcmaHelper::throwError(
       QString::fromLatin1("RLinetypePattern(): no matching constructor found."),
           context);
    }
    
    return result;
    }
示例#3
0
void InterfaceTree::display()
{
#ifdef HAVE_LIBPCAP
    interface_t device;
#if HAVE_EXTCAP
    QIcon extcap_icon(StockIcon("x-capture-options"));
#endif

    setDisabled(false);
    clear();

    if (global_capture_opts.all_ifaces->len == 0) {
        // Error,or just no interfaces?
        QTreeWidgetItem *ti = new QTreeWidgetItem();
        QLabel *err_label;

        if (global_capture_opts.ifaces_err == 0) {
            err_label = new QLabel("No interfaces found");
        } else {
            err_label = new QLabel(global_capture_opts.ifaces_err_info);
        }
        err_label->setWordWrap(true);

        setColumnCount(1);
        addTopLevelItem(ti);
        setItemWidget(ti, 0, err_label);
        resizeColumnToContents(0);
        return;
    }

    /* when no interfaces were available initially and an update of the
       interface list called this function, the column count is set to 1
       reset it to ensure that the interface list is properly displayed */
    resetColumnCount();

    // List physical interfaces first. Alternatively we could sort them by
    // traffic, interface name, or most recently used.
    QList<QTreeWidgetItem *> phys_ifaces;
    QList<QTreeWidgetItem *> virt_ifaces;

    for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) {
        device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);

        /* Continue if capture device is hidden */
        if (device.hidden) {
            continue;
        }

        InterfaceTreeWidgetItem *ti = new InterfaceTreeWidgetItem();
        ti->setText(IFTREE_COL_NAME, QString().fromUtf8(device.display_name));
        ti->setData(IFTREE_COL_NAME, Qt::UserRole, QString(device.name));
        ti->setData(IFTREE_COL_STATS, Qt::UserRole, qVariantFromValue(&ti->points));
#if HAVE_EXTCAP
        if (device.if_info.type == IF_EXTCAP) {
            if (extcap_has_configuration((const char *)(device.name), FALSE)) {
                ti->setIcon(IFTREE_COL_EXTCAP, extcap_icon);
                ti->setData(IFTREE_COL_EXTCAP, Qt::UserRole, QString(device.if_info.extcap));

                if (!(device.external_cap_args_settings != 0 &&
                      g_hash_table_size(device.external_cap_args_settings) > 0))
                {
                    QFont ti_font = ti->font(IFTREE_COL_NAME);
                    ti_font.setItalic(true);
                    ti->setFont(IFTREE_COL_NAME, ti_font);
                }
            }
            virt_ifaces << ti;
        } else
#endif
        {
            phys_ifaces << ti;
        }

        // XXX Need to handle interfaces passed from the command line.
        if (strstr(prefs.capture_device, device.name) != NULL) {
            device.selected = TRUE;
            global_capture_opts.num_selected++;
            global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
            g_array_insert_val(global_capture_opts.all_ifaces, i, device);
        }
    }

    if (!phys_ifaces.isEmpty()) addTopLevelItems(phys_ifaces);
    if (!virt_ifaces.isEmpty()) addTopLevelItems(virt_ifaces);
    setSelectedInterfaces();

    // XXX Add other device information
    resizeColumnToContents(IFTREE_COL_NAME);
    resizeColumnToContents(IFTREE_COL_STATS);

#if HAVE_EXTCAP
    resizeColumnToContents(IFTREE_COL_EXTCAP);
#endif

#else
    QTreeWidgetItem *ti = new QTreeWidgetItem();

    clear();
    setColumnCount(1);
    ti->setText(0, tr("Interface information not available"));
    addTopLevelItem(ti);
    resizeColumnToContents(0);
#endif // HAVE_LIBPCAP
}
void RackWindow::createPluginHost(int position)
{
    //layout settings widget:
    QWidget *settingsWidget = new QWidget;
    settingsWidget->setPalette(QPalette(QColor(0,0,0,160)));
    settingsWidget->setAutoFillBackground(true);

    RPushButton *leftButton = new RPushButton;
    leftButton->setObjectName("rackSettingsLeftArrowButton");
    RPushButton *rightButton = new RPushButton;
    rightButton->setObjectName("rackSettingsRightArrowButton");
    RPushButton *topButton = new RPushButton;
    topButton->setObjectName("rackSettingsTopArrowButton");
    RPushButton *bottomButton = new RPushButton;
    bottomButton->setObjectName("rackSettingsBottomArrowButton");
    RPushButton *closeButton = new RPushButton;
    closeButton->setObjectName("rackSettingsCloseButton");

    //vertical toolbar for plugin buttons:
    QToolBar *pluginHostToolBar = new QToolBar;
    pluginHostToolBar->setObjectName("rackPluginHostToolBar");
    pluginHostToolBar->setOrientation(Qt::Vertical);
    //actiongroup for exclusive handling of buttons:
    QActionGroup *ag = new QActionGroup(pluginHostToolBar);
    ag->setExclusive(true);

    RPushButton *addPluginWidgetButton = new RPushButton(tr("Add Widget ..."));
    addPluginWidgetButton->setObjectName("rackAddPluginWidgetButton");

    QWidget *middleWidget = new QWidget;
    QVBoxLayout *middleLayout = new QVBoxLayout(middleWidget);
    middleLayout->setSpacing(0);
    middleLayout->setContentsMargins(0,0,0,0);
    middleLayout->addWidget(pluginHostToolBar, 0, Qt::AlignHCenter);
    middleLayout->addWidget(addPluginWidgetButton, 0, Qt::AlignHCenter);

    QGridLayout *settingsLayout = new QGridLayout(settingsWidget);
    settingsLayout->setSpacing(0);
    settingsLayout->setContentsMargins(0,0,0,0);
    settingsLayout->addWidget(topButton,0,1, Qt::AlignTop | Qt::AlignHCenter);
    settingsLayout->addWidget(closeButton,0,2, Qt::AlignTop | Qt::AlignRight);
    settingsLayout->addWidget(leftButton,1,0, Qt::AlignLeft);
    settingsLayout->addWidget(rightButton,1,2, Qt::AlignRight);
    settingsLayout->addWidget(bottomButton,2,1, Qt::AlignBottom| Qt::AlignHCenter);
    settingsLayout->addWidget(middleWidget,1,1);

    QStackedWidget *pluginStack = new QStackedWidget;
    pluginStack->setObjectName("rackPluginStack");
    pluginStack->setAutoFillBackground(true);

    QWidget *pluginHost = new QWidget;
    pluginHost->setMinimumSize(200,80);

    QStackedLayout *overlayLayout = new QStackedLayout(pluginHost);
    overlayLayout->setStackingMode(QStackedLayout::StackAll);
    overlayLayout->addWidget(pluginStack);
    overlayLayout->addWidget(settingsWidget);
    overlayLayout->setCurrentIndex(1);

    //enter/leave settings signals:
    QSignalMapper *mapperShowSettingsMode = new QSignalMapper(pluginHost);
    QObject::connect(this, SIGNAL(enterSettingsMode()), mapperShowSettingsMode, SLOT(map()));
    mapperShowSettingsMode->setMapping(this, 1);
    QSignalMapper *mapperHideSettingsMode = new QSignalMapper(pluginHost);
    QObject::connect(this, SIGNAL(leaveSettingsMode()), mapperHideSettingsMode, SLOT(map()));
    mapperHideSettingsMode->setMapping(this, 0);
    QObject::connect(mapperShowSettingsMode, SIGNAL(mapped(int)), overlayLayout, SLOT(setCurrentIndex(int)));
    QObject::connect(mapperHideSettingsMode, SIGNAL(mapped(int)), overlayLayout, SLOT(setCurrentIndex(int)));

    //create plugin host widget signals:
    QSignalMapper *mapperCreatePluginHost = new QSignalMapper(pluginHost);
    QObject::connect(leftButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(rightButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(topButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(bottomButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    mapperCreatePluginHost->setMapping(leftButton, NewSplitterLeft);
    mapperCreatePluginHost->setMapping(rightButton, NewSplitterRight);
    mapperCreatePluginHost->setMapping(topButton, NewSplitterTop);
    mapperCreatePluginHost->setMapping(bottomButton, NewSplitterBottom);
    QObject::connect(mapperCreatePluginHost, SIGNAL(mapped(int)), SLOT(createPluginHost(int)));

    //load plugin signal:
    QObject::connect(addPluginWidgetButton, SIGNAL(clicked()), m_mapperLoadNewPlugin, SLOT(map()));
    m_mapperLoadNewPlugin->setMapping(addPluginWidgetButton, pluginHost);

    //close plugin host signal:
    QObject::connect(closeButton, SIGNAL(clicked()), m_mapperClosePluginHost, SLOT(map()));
    m_mapperClosePluginHost->setMapping(closeButton, pluginHost);

    //create plugin switch signalmapper
    QSignalMapper *mapperSwitchPlugin = new QSignalMapper(pluginHost);
    mapperSwitchPlugin->setObjectName("rackPluginSwitchMapper");
    QObject::connect(mapperSwitchPlugin, SIGNAL(mapped(QWidget *)), pluginStack, SLOT(setCurrentWidget(QWidget *)));


    ////test show/hide plugin widget

    ////QObject::connect(mapperSwitchPlugin, SIGNAL(mapped(QWidget *)), this, SLOT(showHidePluginWidget(QWidget*)));


    //////


    //create plugin toolbar for mainwindow
    QToolBar *pluginToolBar = new QToolBar;
    pluginToolBar->setObjectName("rackPluginToolBar");
    pluginToolBar->setMovable(false);
    pluginToolBar->hide();
    addToolBar(Qt::BottomToolBarArea, pluginToolBar);

    //store the toolbar pointer as dynamic property to access later when creating plugin toolbar buttons
    pluginHost->setProperty("pluginToolBar", qVariantFromValue((QWidget *)pluginToolBar));

    //plugin bar signals & slots:
    QObject::connect(this, SIGNAL(enterSettingsMode()), pluginToolBar, SLOT(hide()));
    QObject::connect(this, SIGNAL(leaveSettingsMode()), pluginToolBar, SLOT(show()));







    //insert new pluginhost widget in splitter, create new splitter if necessary
    if (position == 0)
    {
        m_mainSplitter->addWidget(pluginHost);
        return;
    }
    QSignalMapper *sm = qobject_cast<QSignalMapper *>(sender());
    QWidget *senderPluginHost = qobject_cast<QWidget *>(sm->mapping(position)->parent()->parent());
    RSplitter *parentSplitter = qobject_cast<RSplitter *>(senderPluginHost->parent());
    QList<int> widgetsizes;
    int senderpos = parentSplitter->indexOf(senderPluginHost);
    int newposition;
    if ((position == NewSplitterLeft) or (position == NewSplitterTop)) newposition = senderpos;
    else newposition = senderpos + 1;
    switch (position + parentSplitter->orientation()) {             //horizontal=1 vertical=2
    case 0:                                                         //left   horizontal / top vertical
    case 2:                                                         //right  horizontal
    case 4:                                                         //bottom vertical
        widgetsizes = parentSplitter->sizes();
        widgetsizes.replace(senderpos, int(widgetsizes.at(senderpos)/2));
        widgetsizes.insert(senderpos + 1, widgetsizes.at(senderpos));
        parentSplitter->insertWidget(newposition, pluginHost);
        parentSplitter->setSizes(widgetsizes);
        break;
    case  1:                                                        //left  vertical
    case  3:                                                        //right vertical / bottom horizontal
    case -1:                                                        //top   horizontal
        if (parentSplitter->count() == 1)
        {
            parentSplitter->setOrientation(Qt::Orientation(abs(position)));
            widgetsizes = parentSplitter->sizes();
            widgetsizes.replace(0, int(widgetsizes.at(0)/2));
            widgetsizes.append(widgetsizes.at(0));
            parentSplitter->insertWidget(newposition, pluginHost);
            parentSplitter->setSizes(widgetsizes);
        }
        else if (parentSplitter->count() > 1)
        {
            RSplitter *newSplitter = new RSplitter(Qt::Orientation(abs(position)));
            QObject::connect(this, SIGNAL(enterSettingsMode()), newSplitter, SIGNAL(enterSettingsMode()));
            QObject::connect(this, SIGNAL(leaveSettingsMode()), newSplitter, SIGNAL(leaveSettingsMode()));
            widgetsizes = parentSplitter->sizes();
            parentSplitter->insertWidget(parentSplitter->indexOf(senderPluginHost), newSplitter);
            newSplitter->addWidget(senderPluginHost);
            QList<int> newsizes = newSplitter->sizes();
            newsizes.replace(0, int(newsizes.at(0)/2));
            newsizes.append(newsizes.at(0));
            if ((position == NewSplitterLeft) or (position == NewSplitterTop)) newSplitter->insertWidget(0, pluginHost);
            else newSplitter->addWidget(pluginHost);
            newSplitter->setSizes(newsizes);
            parentSplitter->setSizes(widgetsizes);
        }
        break;
    }
}
示例#5
0
                 void REcmaPointEntity::init(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RPointEntity*) 0)));
        protoCreated = true;
    }

    
        // primary base class REntity:
        
            QScriptValue dpt = engine.defaultPrototype(
                qMetaTypeId<REntity*>());

            if (dpt.isValid()) {
                proto->setPrototype(dpt);
            }
          
        /*
        
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class REntity
        REcmaHelper::registerFunction(&engine, proto, getREntity, "getREntity");
        
        // conversion for base class RObject
        REcmaHelper::registerFunction(&engine, proto, getRObject, "getRObject");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, clone, "clone");
            
            REcmaHelper::registerFunction(&engine, proto, getType, "getType");
            
            REcmaHelper::registerFunction(&engine, proto, setProperty, "setProperty");
            
            REcmaHelper::registerFunction(&engine, proto, getProperty, "getProperty");
            
            REcmaHelper::registerFunction(&engine, proto, exportEntity, "exportEntity");
            
            REcmaHelper::registerFunction(&engine, proto, getData, "getData");
            
            REcmaHelper::registerFunction(&engine, proto, getPosition, "getPosition");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RPointEntity*>(), *proto);

        
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    
            REcmaHelper::registerFunction(&engine, &ctor, init, "init");
            

    // static properties:
    
            ctor.setProperty("PropertyCustom",
                qScriptValueFromValue(&engine, RPointEntity::PropertyCustom),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyHandle",
                qScriptValueFromValue(&engine, RPointEntity::PropertyHandle),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyType",
                qScriptValueFromValue(&engine, RPointEntity::PropertyType),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyBlock",
                qScriptValueFromValue(&engine, RPointEntity::PropertyBlock),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLayer",
                qScriptValueFromValue(&engine, RPointEntity::PropertyLayer),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLinetype",
                qScriptValueFromValue(&engine, RPointEntity::PropertyLinetype),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLineweight",
                qScriptValueFromValue(&engine, RPointEntity::PropertyLineweight),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyColor",
                qScriptValueFromValue(&engine, RPointEntity::PropertyColor),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyDrawOrder",
                qScriptValueFromValue(&engine, RPointEntity::PropertyDrawOrder),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyPositionX",
                qScriptValueFromValue(&engine, RPointEntity::PropertyPositionX),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyPositionY",
                qScriptValueFromValue(&engine, RPointEntity::PropertyPositionY),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyPositionZ",
                qScriptValueFromValue(&engine, RPointEntity::PropertyPositionZ),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RPointEntity",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
static QScriptValue qtscript_QFontDialog_FontDialogOptions_toScriptValue(QScriptEngine *engine, const QFontDialog::FontDialogOptions &value)
{
    return engine->newVariant(qVariantFromValue(value));
}
示例#7
0
文件: gameui.cpp 项目: txase/mythtv
bool GameUI::Create()
{
    if (!LoadWindowFromXML("game-ui.xml", "gameui", this))
        return false;

    bool err = false;
    UIUtilE::Assign(this, m_gameUITree, "gametreelist", &err);
    UIUtilW::Assign(this, m_gameTitleText, "title");
    UIUtilW::Assign(this, m_gameSystemText, "system");
    UIUtilW::Assign(this, m_gameYearText, "year");
    UIUtilW::Assign(this, m_gameGenreText, "genre");
    UIUtilW::Assign(this, m_gameFavouriteState, "favorite");
    UIUtilW::Assign(this, m_gamePlotText, "description");
    UIUtilW::Assign(this, m_gameImage, "screenshot");
    UIUtilW::Assign(this, m_fanartImage, "fanart");
    UIUtilW::Assign(this, m_boxImage, "coverart");

    if (err)
    {
        LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'gameui'");
        return false;
    }

    connect(m_gameUITree, SIGNAL(itemClicked(MythUIButtonListItem*)),
            this, SLOT(itemClicked(MythUIButtonListItem*)));

    connect(m_gameUITree, SIGNAL(nodeChanged(MythGenericTree*)),
            this, SLOT(nodeChanged(MythGenericTree*)));

    m_gameShowFileName = gCoreContext->GetSetting("GameShowFileNames").toInt();

    m_gameTree = new MythGenericTree("game root", 0, false);

    //  create system filter to only select games where handlers are present
    QString systemFilter;

    // The call to GameHandler::count() fills the handler list for us
    // to move through.
    unsigned handlercount = GameHandler::count();

    for (unsigned i = 0; i < handlercount; ++i)
    {
        QString system = GameHandler::getHandler(i)->SystemName();
        if (i == 0)
            systemFilter = "system in ('" + system + "'";
        else
            systemFilter += ",'" + system + "'";
    }
    if (systemFilter.isEmpty())
    {
        systemFilter = "1=0";
        LOG(VB_GENERAL, LOG_ERR, QString("Couldn't find any game handlers!"));
    }
    else
        systemFilter += ")";

    m_showHashed = gCoreContext->GetSetting("GameTreeView").toInt();

    //  create a few top level nodes - this could be moved to a config based
    //  approach with multiple roots if/when someone has the time to create
    //  the relevant dialog screens

    QString levels = gCoreContext->GetSetting("GameFavTreeLevels");

    MythGenericTree *new_node = new MythGenericTree(tr("Favorites"), 1, true);
    new_node->SetData(qVariantFromValue(
                new GameTreeInfo(levels, systemFilter + " and favorite=1")));
    m_favouriteNode = m_gameTree->addNode(new_node);

    levels = gCoreContext->GetSetting("GameAllTreeLevels");

    if (m_showHashed)
    {
        int pos = levels.indexOf("gamename");
        if (pos >= 0)
            levels.insert(pos, " hash ");
    }

    new_node = new MythGenericTree(tr("All Games"), 1, true);
    new_node->SetData(qVariantFromValue(
                new GameTreeInfo(levels, systemFilter)));
    m_gameTree->addNode(new_node);

    new_node = new MythGenericTree(tr("-   By Genre"), 1, true);
    new_node->SetData(qVariantFromValue(
                new GameTreeInfo("genre gamename", systemFilter)));
    m_gameTree->addNode(new_node);

    new_node = new MythGenericTree(tr("-   By Year"), 1, true);
    new_node->SetData(qVariantFromValue(
                new GameTreeInfo("year gamename", systemFilter)));
    m_gameTree->addNode(new_node);

    new_node = new MythGenericTree(tr("-   By Name"), 1, true);
    new_node->SetData(qVariantFromValue(
                new GameTreeInfo("gamename", systemFilter)));
    m_gameTree->addNode(new_node);

    new_node = new MythGenericTree(tr("-   By Publisher"), 1, true);
    new_node->SetData(qVariantFromValue(
                new GameTreeInfo("publisher gamename", systemFilter)));
    m_gameTree->addNode(new_node);

    m_gameUITree->AssignTree(m_gameTree);

    BuildFocusList();

    return true;
}
示例#8
0
void ScreenSetup::customEvent(QEvent *event)
{
    if (event->type() == DialogCompletionEvent::kEventType)
    {
        DialogCompletionEvent *dce = (DialogCompletionEvent*)(event);

        QString resultid  = dce->GetId();
        int     buttonnum = dce->GetResult();

        if (resultid == "options")
        {
            if (buttonnum > -1)
            {
                MythUIButtonListItem *item =
                                dce->GetData().value<MythUIButtonListItem *>();
                        
                ScreenListInfo *si = item->GetData().value<ScreenListInfo *>();

                if (buttonnum == 0)
                {
                    m_activeList->MoveItemUpDown(item, true);
                }
                else if (buttonnum == 1)
                {
                    m_activeList->MoveItemUpDown(item, false);
                }
                else if (buttonnum == 2)
                {
                    deleteScreen();
                }
                else if (buttonnum == 3)
                {
                    si->updating = true;
                    doLocationDialog(si);
                }
                else if (si->hasUnits && buttonnum == 4)
                {
                    si->updating = true;
                    showUnitsPopup(item->GetText(), si);
                    updateHelpText();
                }
            }
        }
        else if (resultid == "units")
        {
            if (buttonnum > -1)
            {
                ScreenListInfo *si = dce->GetData().value<ScreenListInfo *>();

                if (buttonnum == 0)
                {
                    si->units = ENG_UNITS;
                }
                else if (buttonnum == 1)
                {
                    si->units = SI_UNITS;
                }

                updateHelpText();

                if (si->updating)
                    si->updating = false;
                else
                    doLocationDialog(si);
            }
        }
        else if (resultid == "location")
        {
            ScreenListInfo *si = dce->GetData().value<ScreenListInfo *>();

            TypeListMap::iterator it = si->types.begin();
            for (; it != si->types.end(); ++it)
            {
                if ((*it).location.isEmpty())
                    return;
            }

            if (si->updating)
            {
                si->updating = false;
                MythUIButtonListItem *item = m_activeList->GetItemCurrent();
                if (item)
                    item->SetData(qVariantFromValue(si));
            }
            else
            {
                QString txt = si->title; txt.detach();
                MythUIButtonListItem *item = 
                        new MythUIButtonListItem(m_activeList, txt);
                item->SetData(qVariantFromValue(si));
            }

            if (m_activeList->GetCount())
                m_activeList->SetEnabled(true);
        }
    }
}
示例#9
0
void LocationDialog::doSearch()
{
    QString busymessage = tr("Searching...");

    MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");

    MythUIBusyDialog *busyPopup = new MythUIBusyDialog(busymessage, popupStack,
                                                       "mythweatherbusydialog");

    if (busyPopup->Create())
    {
        popupStack->AddScreen(busyPopup, false);
    }
    else
    {
        delete busyPopup;
        busyPopup = NULL;
    }
       

    QMap<ScriptInfo *, QStringList> result_cache;
    int numresults = 0;
    clearResults();

    QString searchingresults = tr("Searching... Results: %1");

    m_resultsText->SetText(searchingresults.arg(0));
    qApp->processEvents();

    QList<ScriptInfo *> sources;
    // if a screen makes it this far, theres at least one source for it
    m_sourceManager->findPossibleSources(m_types, sources);
    QString search = m_locationEdit->GetText();
    ScriptInfo *si;
    for (int x = 0; x < sources.size(); x++)
    {
        si = sources.at(x);
        if (!result_cache.contains(si))
        {
            QStringList results = m_sourceManager->getLocationList(si, search);
            result_cache[si] = results;
            numresults += results.size();
            m_resultsText->SetText(searchingresults.arg(numresults));
            qApp->processEvents();
        }
    }

    QMap<ScriptInfo *, QStringList>::iterator it;
    for (it = result_cache.begin(); it != result_cache.end(); ++it)
    {
        si = it.key();
        QStringList results = it.value();
        QString name = si->name;
        QStringList::iterator rit;
        for (rit = results.begin(); rit != results.end(); ++rit)
        {
            QStringList tmp = (*rit).split("::");
            if (tmp.size() < 2)
            {
                LOG(VB_GENERAL, LOG_WARNING,
                        QString("Invalid line in Location Search reponse "
                                "from %1: %2")
                                    .arg(name).arg(*rit));
                continue;
            }
            QString resultstring = QString("%1 (%2)").arg(tmp[1]).arg(name);
            MythUIButtonListItem *item =
                new MythUIButtonListItem(m_locationList, resultstring);
            ResultListInfo *ri = new ResultListInfo;
            ri->idstr = tmp[0];
            ri->src = si;
            item->SetData(qVariantFromValue(ri));
            qApp->processEvents();
        }
    }

    if (busyPopup)
    {
        busyPopup->Close();
        busyPopup = NULL;
    }

    m_resultsText->SetText(tr("Search Complete. Results: %1").arg(numresults));
    if (numresults)
        SetFocusWidget(m_locationList);
}
示例#10
0
void ScreenSetup::loadData()
{
    ScreenListInfo *si;

    QStringList types;

    ScreenListMap screenListMap = loadScreens();

    // Fill the inactive screen button list.
    ScreenListMap::const_iterator i = screenListMap.constBegin();
    while (i != screenListMap.constEnd())
    {

        si = &screenListMap[i.key()];
        types = si->dataTypes;
        si->units = ENG_UNITS;

        QStringList type_strs;
        for (int typei = 0; typei < types.size(); ++typei)
        {
            TypeListInfo ti(types[typei]);
            si->types.insert(types[typei], ti);
            type_strs << types[typei];
        }

        QList<ScriptInfo *> scriptList;
        // Only add a screen to the list if we have a source
        // available to satisfy the requirements.
        if (m_sourceManager->findPossibleSources(type_strs, scriptList))
        {
            ScriptInfo *script;
            for (int x = 0; x < scriptList.size(); x++)
            {
                script = scriptList.at(x);
                si->sources.append(script->name);
            }
            MythUIButtonListItem *item =
                        new MythUIButtonListItem(m_inactiveList, si->title);
            item->SetData(qVariantFromValue(new ScreenListInfo(*si)));
        }

        ++i;
    }

    QMap<long, ScreenListInfo*> active_screens;

    MSqlQuery db(MSqlQuery::InitCon());
    QString query = "SELECT weatherscreens.container, weatherscreens.units, "
        "weatherdatalayout.dataitem, weatherdatalayout.location, "
        "weathersourcesettings.source_name, weatherscreens.draworder "
        "FROM weatherscreens, weatherdatalayout, weathersourcesettings "
        "WHERE weatherscreens.hostname = :HOST "
        "AND weatherscreens.screen_id = weatherdatalayout.weatherscreens_screen_id "
        "AND weathersourcesettings.sourceid = weatherdatalayout.weathersourcesettings_sourceid "
        "ORDER BY weatherscreens.draworder;";
    db.prepare(query);
    db.bindValue(":HOST", gCoreContext->GetHostName());
    if (!db.exec())
    {
        LOG(VB_GENERAL, LOG_ERR, db.lastError().text());
        return;
    }

    // Fill the active screen button list.
    while (db.next())
    {
        QString name = db.value(0).toString();
        units_t units = db.value(1).toUInt();
        QString dataitem = db.value(2).toString();
        QString location = db.value(3).toString();
        QString src = db.value(4).toString();
        uint draworder = db.value(5).toUInt();

        types = screenListMap[name].dataTypes;

        TypeListInfo ti(dataitem, location,
                        m_sourceManager->getSourceByName(src));

        if (active_screens.find(draworder) == active_screens.end())
        {
            si = new ScreenListInfo(screenListMap[name]);
            // Clear types first as we will re-insert the values from the database
            si->types.clear();
            si->units = units;
            
            MythUIButtonListItem *item =
                new MythUIButtonListItem(m_activeList, si->title);
            

            // Only insert types meant for this screen
            for (QStringList::Iterator type_i = types.begin();
                 type_i != types.end(); ++type_i )
            {
                if (*type_i == dataitem)
                    si->types.insert(dataitem, ti);
            }

            item->SetData(qVariantFromValue(si));
            active_screens.insert(draworder, si);
        }
        else
        {
            si = active_screens[draworder];
            for (QStringList::Iterator type_i = types.begin();
                 type_i != types.end(); ++type_i )
            {
                if (*type_i == dataitem)
                {
                    si->types.insert(dataitem, ti);
                }
            }
        }
    }
}
示例#11
0
void ScreenSetup::doListSelect(MythUIButtonListItem *selected)
{
    if (!selected)
        return;

    QString txt = selected->GetText();
    if (GetFocusWidget() == m_activeList)
    {
        ScreenListInfo *si = selected->GetData().value<ScreenListInfo *>();

        QString label = tr("Manipulate Screen");

        MythScreenStack *popupStack =
                                GetMythMainWindow()->GetStack("popup stack");

        MythDialogBox *menuPopup = new MythDialogBox(label, popupStack,
                                                    "screensetupmenupopup");

        if (menuPopup->Create())
        {
            popupStack->AddScreen(menuPopup);

            menuPopup->SetReturnEvent(this, "options");

            menuPopup->AddButton(tr("Move Up"), qVariantFromValue(selected));
            menuPopup->AddButton(tr("Move Down"), qVariantFromValue(selected));
            menuPopup->AddButton(tr("Remove"), qVariantFromValue(selected));
            menuPopup->AddButton(tr("Change Location"), qVariantFromValue(selected));
            if (si->hasUnits)
                menuPopup->AddButton(tr("Change Units"), qVariantFromValue(selected));
            menuPopup->AddButton(tr("Cancel"), qVariantFromValue(selected));
        }
        else
        {
            delete menuPopup;
        }

    }
    else if (GetFocusWidget() == m_inactiveList)
    {
        ScreenListInfo *si = selected->GetData().value<ScreenListInfo *>();
        QStringList type_strs;

        TypeListMap::iterator it = si->types.begin();
        TypeListMap types;
        for (; it != si->types.end(); ++it)
        {
            types.insert(it.key(), TypeListInfo(*it));
            type_strs << it.key();
        }
        bool hasUnits = si->hasUnits;

        QList<ScriptInfo *> tmp;
        if (m_sourceManager->findPossibleSources(type_strs, tmp))
        {
            if (!m_inactiveList->GetCount())
            {
                //m_inactiveList->SetActive(false);
                NextPrevWidgetFocus(true);
            }
            if (hasUnits)
                showUnitsPopup(selected->GetText(), si);
            else
                doLocationDialog(si);
        }
        else
            LOG(VB_GENERAL, LOG_ERR, "Screen cannot be used, not all required "
                                     "data is supplied by existing sources");
    }
}
示例#12
0
static QScriptValue qtscript_QQuaternion_static_call(QScriptContext *context, QScriptEngine *)
{
    uint _id = context->callee().data().toUInt32();
    Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000);
    _id &= 0x0000FFFF;
    switch (_id) {
    case 0:
    if (context->thisObject().strictlyEquals(context->engine()->globalObject())) {
        return context->throwError(QString::fromLatin1("QQuaternion(): Did you forget to construct with 'new'?"));
    }
    if (context->argumentCount() == 0) {
        QQuaternion _q_cpp_result;
        QScriptValue _q_result = context->engine()->newVariant(context->thisObject(), qVariantFromValue(_q_cpp_result));
        return _q_result;
    } else if (context->argumentCount() == 1) {
        QVector4D _q_arg0 = qscriptvalue_cast<QVector4D>(context->argument(0));
        QQuaternion _q_cpp_result(_q_arg0);
        QScriptValue _q_result = context->engine()->newVariant(context->thisObject(), qVariantFromValue(_q_cpp_result));
        return _q_result;
    } else if (context->argumentCount() == 2) {
        float _q_arg0 = qscriptvalue_cast<float>(context->argument(0));
        QVector3D _q_arg1 = qscriptvalue_cast<QVector3D>(context->argument(1));
        QQuaternion _q_cpp_result(_q_arg0, _q_arg1);
        QScriptValue _q_result = context->engine()->newVariant(context->thisObject(), qVariantFromValue(_q_cpp_result));
        return _q_result;
    } else if (context->argumentCount() == 4) {
        float _q_arg0 = qscriptvalue_cast<float>(context->argument(0));
        float _q_arg1 = qscriptvalue_cast<float>(context->argument(1));
        float _q_arg2 = qscriptvalue_cast<float>(context->argument(2));
        float _q_arg3 = qscriptvalue_cast<float>(context->argument(3));
        QQuaternion _q_cpp_result(_q_arg0, _q_arg1, _q_arg2, _q_arg3);
        QScriptValue _q_result = context->engine()->newVariant(context->thisObject(), qVariantFromValue(_q_cpp_result));
        return _q_result;
    }
    break;

    case 1:
    if (context->argumentCount() == 2) {
        QVector3D _q_arg0 = qscriptvalue_cast<QVector3D>(context->argument(0));
        float _q_arg1 = qscriptvalue_cast<float>(context->argument(1));
        QQuaternion _q_result = QQuaternion::fromAxisAndAngle(_q_arg0, _q_arg1);
        return qScriptValueFromValue(context->engine(), _q_result);
    }
    if (context->argumentCount() == 4) {
        float _q_arg0 = qscriptvalue_cast<float>(context->argument(0));
        float _q_arg1 = qscriptvalue_cast<float>(context->argument(1));
        float _q_arg2 = qscriptvalue_cast<float>(context->argument(2));
        float _q_arg3 = qscriptvalue_cast<float>(context->argument(3));
        QQuaternion _q_result = QQuaternion::fromAxisAndAngle(_q_arg0, _q_arg1, _q_arg2, _q_arg3);
        return qScriptValueFromValue(context->engine(), _q_result);
    }
    break;

    case 2:
    if (context->argumentCount() == 3) {
        QQuaternion _q_arg0 = qscriptvalue_cast<QQuaternion>(context->argument(0));
        QQuaternion _q_arg1 = qscriptvalue_cast<QQuaternion>(context->argument(1));
        float _q_arg2 = qscriptvalue_cast<float>(context->argument(2));
        QQuaternion _q_result = QQuaternion::nlerp(_q_arg0, _q_arg1, _q_arg2);
        return qScriptValueFromValue(context->engine(), _q_result);
    }
    break;

    case 3:
    if (context->argumentCount() == 3) {
        QQuaternion _q_arg0 = qscriptvalue_cast<QQuaternion>(context->argument(0));
        QQuaternion _q_arg1 = qscriptvalue_cast<QQuaternion>(context->argument(1));
        float _q_arg2 = qscriptvalue_cast<float>(context->argument(2));
        QQuaternion _q_result = QQuaternion::slerp(_q_arg0, _q_arg1, _q_arg2);
        return qScriptValueFromValue(context->engine(), _q_result);
    }
    break;

    default:
    Q_ASSERT(false);
    }
    return qtscript_QQuaternion_throw_ambiguity_error_helper(context,
        qtscript_QQuaternion_function_names[_id],
        qtscript_QQuaternion_function_signatures[_id]);
}
示例#13
0
void PythonQtTestApi::testCall()
{
  PythonQtObjectPtr main = PythonQt::self()->getMainModule();

  QVERIFY(qvariant_cast<QObject*>(PythonQt::self()->getVariable(main, "obj"))==_helper);

  PyRun_SimpleString("def testCallNoArgs():\n  obj.setPassed();\n");
  QVERIFY(_helper->call("testCallNoArgs", QVariantList(), QVariant()));

  PyRun_SimpleString("def testCall1(a):\n if a=='test': obj.setPassed();\n return 'test2';\n");
  QVERIFY(_helper->call("testCall1", QVariantList() << QVariant("test"), QVariant(QString("test2"))));

  PyRun_SimpleString("def testCall2(a, b):\n if a=='test' and b==obj: obj.setPassed();\n return obj;\n");
  QVariant r = PythonQt::self()->call(PythonQt::self()->getMainModule(), "testCall2", QVariantList() << QVariant("test") << qVariantFromValue((QObject*)_helper));
  QObject* p = qvariant_cast<QObject*>(r);
  QVERIFY(p==_helper);
}
示例#14
0
/* create a QVariant of specific type by first creating a QVariant
   directly, and then attempting to coerce it to the required type.
*/
QVariant asQVariantOfType(SEXP rvalue, QMetaType::Type type, bool tryDirect)
{
  QVariant ans;
  if (tryDirect) {
    QVariant direct = from_sexp<QVariant>(rvalue);
    if (direct.canConvert((QVariant::Type)type)) { // handles a few cases
      direct.convert((QVariant::Type)type);
      return direct;
    }
  }
  switch(type) {
  case QMetaType::QObjectStar:
    {
      SmokeType type(qt_Smoke, "QObject*");
      ans = qVariantFromValue(ptr_from_sexp<QObject *>(rvalue, type));
    }
    break;
  case QMetaType::QWidgetStar:
    {
      SmokeType type(qt_Smoke, "QWidget*");
      ans = qVariantFromValue(ptr_from_sexp<QWidget *>(rvalue, type));
    }
    break;
  case QMetaType::QCursor:
    ans = QVARIANT_FROM_SEXP(rvalue, QCursor);
    break;
  case QMetaType::QDate:
    ans = QVARIANT_FROM_SEXP(rvalue, QDate);
    break;
  case QMetaType::QSize:
    ans = QVARIANT_FROM_SEXP(rvalue, QSize);
    break;
  case QMetaType::QSizeF:
    ans = QVARIANT_FROM_SEXP(rvalue, QSizeF);
    break;
  case QMetaType::QTime:
    ans = QVARIANT_FROM_SEXP(rvalue, QTime);
    break;
  case QMetaType::QVariantList:
    {
      SmokeType type(qt_Smoke, "QList<QVariant>>");
      ans = QVariant(from_sexp<QList<QVariant> >(rvalue, type));
    }
    break;
  case QMetaType::QPolygon:
    ans = QVARIANT_FROM_SEXP(rvalue, QPolygon);
    break;
  case QMetaType::QColor:
    ans = QVARIANT_FROM_SEXP(rvalue, QColor);
    break;
  case QMetaType::QRectF:
    ans = QVARIANT_FROM_SEXP(rvalue, QRectF);
    break;
  case QMetaType::QRect:
    ans = QVARIANT_FROM_SEXP(rvalue, QRect);
    break;
  case QMetaType::QLine:
    ans = QVARIANT_FROM_SEXP(rvalue, QLine);
    break;
  case QMetaType::QTextLength:
    ans = QVARIANT_FROM_SEXP(rvalue, QTextLength);
    break;
  case QMetaType::QStringList:
    {
      SmokeType type(qt_Smoke, "QStringList");
      ans = QVariant(from_sexp<QStringList>(rvalue, type));
    }
    break;
  case QMetaType::QVariantMap:
    {
      SmokeType type(qt_Smoke, "QMap<QString,QVariant>");
      ans = QVariant(from_sexp<QMap<QString,QVariant> >(rvalue, type));
    }
    break;
#if QT_VERSION >= 0x40500
  case QMetaType::QVariantHash:
    {
      SmokeType type(qt_Smoke, "QHash<QString,QVariant>");
      ans = QVariant(from_sexp<QHash<QString,QVariant> >(rvalue, type));
    }
    break;
#endif
  case QMetaType::QIcon:
    ans = QVARIANT_FROM_SEXP(rvalue, QIcon);
    break;
  case QMetaType::QPen:
    ans = QVARIANT_FROM_SEXP(rvalue, QPen);
    break;
  case QMetaType::QLineF:
    ans = QVARIANT_FROM_SEXP(rvalue, QLineF);
    break;
  case QMetaType::QTextFormat:
    ans = QVARIANT_FROM_SEXP(rvalue, QTextFormat);
    break;
  case QMetaType::QPoint:
    ans = QVARIANT_FROM_SEXP(rvalue, QPoint);
  case QMetaType::QPointF:
    ans = QVARIANT_FROM_SEXP(rvalue, QPointF);
    break;
  case QMetaType::QUrl:
    ans = QVARIANT_FROM_SEXP(rvalue, QUrl);
    break;
#if QT_VERSION >= 0x40100
  case QMetaType::QRegExp:
    ans = QVARIANT_FROM_SEXP(rvalue, QRegExp);
    break;
#endif
  case QMetaType::QDateTime:
    ans = QVARIANT_FROM_SEXP(rvalue, QDateTime);
    break;
  case QMetaType::QPalette:
    ans = QVARIANT_FROM_SEXP(rvalue, QPalette);
    break;
  case QMetaType::QFont:
    ans = QVARIANT_FROM_SEXP(rvalue, QFont);
    break;
  case QMetaType::QBrush:
    ans = QVARIANT_FROM_SEXP(rvalue, QBrush);
    break;
  case QMetaType::QRegion:
    ans = QVARIANT_FROM_SEXP(rvalue, QRegion);
    break;
  case QMetaType::QBitArray:
    ans = QVARIANT_FROM_SEXP(rvalue, QBitArray);
    break;
  case QMetaType::QImage:
    ans = QVARIANT_FROM_SEXP(rvalue, QImage);
    break;
  case QMetaType::QKeySequence:
    ans = QVARIANT_FROM_SEXP(rvalue, QKeySequence);
    break;
  case QMetaType::QSizePolicy:
    ans = QVARIANT_FROM_SEXP(rvalue, QSizePolicy);
    break;
  case QMetaType::QPixmap:
    ans = QVARIANT_FROM_SEXP(rvalue, QPixmap);
    break;
  case QMetaType::QLocale:
    ans = QVARIANT_FROM_SEXP(rvalue, QLocale);
    break;
  case QMetaType::QBitmap:
    ans = QVARIANT_FROM_SEXP(rvalue, QBitmap);
    break;
  case QMetaType::QMatrix:
    ans = QVARIANT_FROM_SEXP(rvalue, QMatrix);
    break;
#if QT_VERSION >= 0x40300
  case QMetaType::QTransform:
    ans = QVARIANT_FROM_SEXP(rvalue, QTransform);
    break;
#endif
#if QT_VERSION >= 0x40600
  case QMetaType::QMatrix4x4:
    ans = QVARIANT_FROM_SEXP(rvalue, QMatrix4x4);
    break;
  case QMetaType::QVector2D:
    ans = QVARIANT_FROM_SEXP(rvalue, QVector2D);
    break;
  case QMetaType::QVector3D:
    ans = QVARIANT_FROM_SEXP(rvalue, QVector3D);
    break;
  case QMetaType::QVector4D:
    ans = QVARIANT_FROM_SEXP(rvalue, QVector4D);
    break;
  case QMetaType::QQuaternion:
    ans = QVARIANT_FROM_SEXP(rvalue, QQuaternion);
    break;
#endif
  case QMetaType::User:
    break;
  default:
    error("Converting to QVariant: unhandled Qt type");
  }
  if (!ans.isValid())
    error("Converting to QVariant: Qt type not yet implemented");
  return ans;
}
示例#15
0
static QScriptValue qtscript_QUrlInfo_static_call(QScriptContext *context, QScriptEngine *)
{
    uint _id = context->callee().data().toUInt32();
    Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000);
    _id &= 0x0000FFFF;
    switch (_id) {
    case 0:
    if (context->thisObject().strictlyEquals(context->engine()->globalObject())) {
        return context->throwError(QString::fromLatin1("QUrlInfo(): Did you forget to construct with 'new'?"));
    }
    if (context->argumentCount() == 0) {
        QtScriptShell_QUrlInfo _q_cpp_result;
        QScriptValue _q_result = context->engine()->newVariant(context->thisObject(), qVariantFromValue((QUrlInfo)_q_cpp_result));
        _q_cpp_result.__qtscript_self = _q_result;
        return _q_result;
    } else if (context->argumentCount() == 1) {
        QUrlInfo _q_arg0 = qscriptvalue_cast<QUrlInfo>(context->argument(0));
        QtScriptShell_QUrlInfo _q_cpp_result(_q_arg0);
        QScriptValue _q_result = context->engine()->newVariant(context->thisObject(), qVariantFromValue((QUrlInfo)_q_cpp_result));
        _q_cpp_result.__qtscript_self = _q_result;
        return _q_result;
    } else if (context->argumentCount() == 13) {
        if (context->argument(0).isString()
            && context->argument(1).isNumber()
            && context->argument(2).isString()
            && context->argument(3).isString()
            && (qMetaTypeId<qint64>() == context->argument(4).toVariant().userType())
            && (qMetaTypeId<QDateTime>() == context->argument(5).toVariant().userType())
            && (qMetaTypeId<QDateTime>() == context->argument(6).toVariant().userType())
            && context->argument(7).isBoolean()
            && context->argument(8).isBoolean()
            && context->argument(9).isBoolean()
            && context->argument(10).isBoolean()
            && context->argument(11).isBoolean()
            && context->argument(12).isBoolean()) {
            QString _q_arg0 = context->argument(0).toString();
            int _q_arg1 = context->argument(1).toInt32();
            QString _q_arg2 = context->argument(2).toString();
            QString _q_arg3 = context->argument(3).toString();
            qint64 _q_arg4 = qscriptvalue_cast<qint64>(context->argument(4));
            QDateTime _q_arg5 = context->argument(5).toDateTime();
            QDateTime _q_arg6 = context->argument(6).toDateTime();
            bool _q_arg7 = context->argument(7).toBoolean();
            bool _q_arg8 = context->argument(8).toBoolean();
            bool _q_arg9 = context->argument(9).toBoolean();
            bool _q_arg10 = context->argument(10).toBoolean();
            bool _q_arg11 = context->argument(11).toBoolean();
            bool _q_arg12 = context->argument(12).toBoolean();
            QtScriptShell_QUrlInfo _q_cpp_result(_q_arg0, _q_arg1, _q_arg2, _q_arg3, _q_arg4, _q_arg5, _q_arg6, _q_arg7, _q_arg8, _q_arg9, _q_arg10, _q_arg11, _q_arg12);
            QScriptValue _q_result = context->engine()->newVariant(context->thisObject(), qVariantFromValue((QUrlInfo)_q_cpp_result));
            _q_cpp_result.__qtscript_self = _q_result;
            return _q_result;
        } else if ((qMetaTypeId<QUrl>() == context->argument(0).toVariant().userType())
            && context->argument(1).isNumber()
            && context->argument(2).isString()
            && context->argument(3).isString()
            && (qMetaTypeId<qint64>() == context->argument(4).toVariant().userType())
            && (qMetaTypeId<QDateTime>() == context->argument(5).toVariant().userType())
            && (qMetaTypeId<QDateTime>() == context->argument(6).toVariant().userType())
            && context->argument(7).isBoolean()
            && context->argument(8).isBoolean()
            && context->argument(9).isBoolean()
            && context->argument(10).isBoolean()
            && context->argument(11).isBoolean()
            && context->argument(12).isBoolean()) {
            QUrl _q_arg0 = qscriptvalue_cast<QUrl>(context->argument(0));
            int _q_arg1 = context->argument(1).toInt32();
            QString _q_arg2 = context->argument(2).toString();
            QString _q_arg3 = context->argument(3).toString();
            qint64 _q_arg4 = qscriptvalue_cast<qint64>(context->argument(4));
            QDateTime _q_arg5 = context->argument(5).toDateTime();
            QDateTime _q_arg6 = context->argument(6).toDateTime();
            bool _q_arg7 = context->argument(7).toBoolean();
            bool _q_arg8 = context->argument(8).toBoolean();
            bool _q_arg9 = context->argument(9).toBoolean();
            bool _q_arg10 = context->argument(10).toBoolean();
            bool _q_arg11 = context->argument(11).toBoolean();
            bool _q_arg12 = context->argument(12).toBoolean();
            QtScriptShell_QUrlInfo _q_cpp_result(_q_arg0, _q_arg1, _q_arg2, _q_arg3, _q_arg4, _q_arg5, _q_arg6, _q_arg7, _q_arg8, _q_arg9, _q_arg10, _q_arg11, _q_arg12);
            QScriptValue _q_result = context->engine()->newVariant(context->thisObject(), qVariantFromValue((QUrlInfo)_q_cpp_result));
            _q_cpp_result.__qtscript_self = _q_result;
            return _q_result;
        }
    }
    break;

    case 1:
    if (context->argumentCount() == 3) {
        QUrlInfo _q_arg0 = qscriptvalue_cast<QUrlInfo>(context->argument(0));
        QUrlInfo _q_arg1 = qscriptvalue_cast<QUrlInfo>(context->argument(1));
        int _q_arg2 = context->argument(2).toInt32();
        bool _q_result = QUrlInfo::equal(_q_arg0, _q_arg1, _q_arg2);
        return QScriptValue(context->engine(), _q_result);
    }
    break;

    case 2:
    if (context->argumentCount() == 3) {
        QUrlInfo _q_arg0 = qscriptvalue_cast<QUrlInfo>(context->argument(0));
        QUrlInfo _q_arg1 = qscriptvalue_cast<QUrlInfo>(context->argument(1));
        int _q_arg2 = context->argument(2).toInt32();
        bool _q_result = QUrlInfo::greaterThan(_q_arg0, _q_arg1, _q_arg2);
        return QScriptValue(context->engine(), _q_result);
    }
    break;

    case 3:
    if (context->argumentCount() == 3) {
        QUrlInfo _q_arg0 = qscriptvalue_cast<QUrlInfo>(context->argument(0));
        QUrlInfo _q_arg1 = qscriptvalue_cast<QUrlInfo>(context->argument(1));
        int _q_arg2 = context->argument(2).toInt32();
        bool _q_result = QUrlInfo::lessThan(_q_arg0, _q_arg1, _q_arg2);
        return QScriptValue(context->engine(), _q_result);
    }
    break;

    default:
    Q_ASSERT(false);
    }
    return qtscript_QUrlInfo_throw_ambiguity_error_helper(context,
        qtscript_QUrlInfo_function_names[_id],
        qtscript_QUrlInfo_function_signatures[_id]);
}
示例#16
0
void VideoFilterDialog::fillWidgets()
{
    bool have_unknown_year = false;
    bool have_unknown_runtime = false;

    typedef std::set<int> int_list;
    int_list years;
    int_list runtimes;
    int_list user_ratings;

    const VideoMetadataListManager::metadata_list &mdl =
            m_videoList.getListCache().getList();
    for (VideoMetadataListManager::metadata_list::const_iterator p = mdl.begin();
         p != mdl.end(); ++p)
    {
        int year = (*p)->GetYear();
        if ((year == 0) || (year == VIDEO_YEAR_DEFAULT))
            have_unknown_year = true;
        else
            years.insert(year);

        int runtime = (*p)->GetLength();
        if (runtime == 0)
            have_unknown_runtime = true;
        else
            runtimes.insert(runtime / 30);

        user_ratings.insert(static_cast<int>((*p)->GetUserRating()));
    }

    // Category
    new MythUIButtonListItem(m_categoryList, QObject::tr("All"),
                           kCategoryFilterAll);

    const VideoCategory::entry_list &vcl =
            VideoCategory::GetCategory().getList();
    for (VideoCategory::entry_list::const_iterator p = vcl.begin();
            p != vcl.end(); ++p)
    {
        new MythUIButtonListItem(m_categoryList, p->second, p->first);
    }

    new MythUIButtonListItem(m_categoryList, VIDEO_CATEGORY_UNKNOWN,
                           kCategoryFilterUnknown);
    m_categoryList->SetValueByData(m_settings.GetCategory());

    // Genre
    new MythUIButtonListItem(m_genreList, QObject::tr("All"), kGenreFilterAll);

    const VideoGenre::entry_list &gl = VideoGenre::getGenre().getList();
    for (VideoGenre::entry_list::const_iterator p = gl.begin();
            p != gl.end(); ++p)
    {
        new MythUIButtonListItem(m_genreList, p->second, p->first);
    }

    new MythUIButtonListItem(m_genreList, VIDEO_GENRE_UNKNOWN, kGenreFilterUnknown);
    m_genreList->SetValueByData(m_settings.getGenre());

    // Cast
    new MythUIButtonListItem(m_castList, QObject::tr("All"), kCastFilterAll);

    const VideoCast::entry_list &cl = VideoCast::GetCast().getList();
    for (VideoCast::entry_list::const_iterator p = cl.begin();
            p != cl.end(); ++p)
    {
        new MythUIButtonListItem(m_castList, p->second, p->first);
    }

    new MythUIButtonListItem(m_castList, VIDEO_CAST_UNKNOWN, kCastFilterUnknown);
    m_castList->SetValueByData(m_settings.GetCast());

    // Country
    new MythUIButtonListItem(m_countryList, QObject::tr("All"), kCountryFilterAll);

    const VideoCountry::entry_list &cnl = VideoCountry::getCountry().getList();
    for (VideoCountry::entry_list::const_iterator p = cnl.begin();
            p != cnl.end(); ++p)
    {
        new MythUIButtonListItem(m_countryList, p->second, p->first);
    }

    new MythUIButtonListItem(m_countryList, VIDEO_COUNTRY_UNKNOWN,
                           kCountryFilterUnknown);
    m_countryList->SetValueByData(m_settings.getCountry());

    // Year
    new MythUIButtonListItem(m_yearList, QObject::tr("All"), kYearFilterAll);

    for (int_list::const_reverse_iterator p = years.rbegin();
            p != years.rend(); ++p)
    {
        new MythUIButtonListItem(m_yearList, QString::number(*p), *p);
    }

    if (have_unknown_year)
        new MythUIButtonListItem(m_yearList, VIDEO_YEAR_UNKNOWN,
                               kYearFilterUnknown);

    m_yearList->SetValueByData(m_settings.getYear());

    // Runtime
    new MythUIButtonListItem(m_runtimeList, QObject::tr("All"), kRuntimeFilterAll);

    if (have_unknown_runtime)
        new MythUIButtonListItem(m_runtimeList, VIDEO_RUNTIME_UNKNOWN,
                               kRuntimeFilterUnknown);

    for (int_list::const_iterator p = runtimes.begin();
            p != runtimes.end(); ++p)
    {
        QString s = QString("%1 %2 ~ %3 %4").arg(*p * 30).arg(tr("minutes"))
                .arg((*p + 1) * 30).arg(tr("minutes"));
        new MythUIButtonListItem(m_runtimeList, s, *p);
    }

    m_runtimeList->SetValueByData(m_settings.getRuntime());

    // User Rating
    new MythUIButtonListItem(m_userratingList, QObject::tr("All"),
                           kUserRatingFilterAll);

    for (int_list::const_reverse_iterator p = user_ratings.rbegin();
            p != user_ratings.rend(); ++p)
    {
        new MythUIButtonListItem(m_userratingList,
                               QString(">= %1").arg(QString::number(*p)),
                               *p);
    }

    m_userratingList->SetValueByData(m_settings.GetUserRating());

    // Browsable
    new MythUIButtonListItem(m_browseList, QObject::tr("All"), kBrowseFilterAll);
    new MythUIButtonListItem(m_browseList, QObject::tr("Yes"),
                                qVariantFromValue(1));
    new MythUIButtonListItem(m_browseList, QObject::tr("No"),
                                qVariantFromValue(0));
    m_browseList->SetValueByData(m_settings.GetBrowse());

    // Watched
    new MythUIButtonListItem(m_watchedList, QObject::tr("All"), kWatchedFilterAll);
    new MythUIButtonListItem(m_watchedList, QObject::tr("Yes"),
                                qVariantFromValue(1));
    new MythUIButtonListItem(m_watchedList, QObject::tr("No"),
                                qVariantFromValue(0));
    m_watchedList->SetValueByData(m_settings.GetWatched());

    // Inet Reference
    new MythUIButtonListItem(m_inetrefList, QObject::tr("All"),
                           kInetRefFilterAll);
    new MythUIButtonListItem(m_inetrefList, QObject::tr("Unknown"),
                           kInetRefFilterUnknown);
    m_inetrefList->SetValueByData(m_settings.getInteRef());

    // Coverfile
    new MythUIButtonListItem(m_coverfileList, QObject::tr("All"),
                           kCoverFileFilterAll);
    new MythUIButtonListItem(m_coverfileList, QObject::tr("None"),
                           kCoverFileFilterNone);
    m_coverfileList->SetValueByData(m_settings.GetCoverFile());

    // Order by
    new MythUIButtonListItem(m_orderbyList, QObject::tr("Title"),
                           VideoFilterSettings::kOrderByTitle);
    new MythUIButtonListItem(m_orderbyList, QObject::tr("Season/Episode"),
                           VideoFilterSettings::kOrderBySeasonEp);
    new MythUIButtonListItem(m_orderbyList, QObject::tr("Year"),
                           VideoFilterSettings::kOrderByYearDescending);
    new MythUIButtonListItem(m_orderbyList, QObject::tr("User Rating"),
                           VideoFilterSettings::kOrderByUserRatingDescending);
    new MythUIButtonListItem(m_orderbyList, QObject::tr("Runtime"),
                           VideoFilterSettings::kOrderByLength);
    new MythUIButtonListItem(m_orderbyList, QObject::tr("Filename"),
                           VideoFilterSettings::kOrderByFilename);
    new MythUIButtonListItem(m_orderbyList, QObject::tr("Video ID"),
                           VideoFilterSettings::kOrderByID);
    m_orderbyList->SetValueByData(m_settings.getOrderby());

    // Text Filter
    m_textfilter->SetText(m_settings.getTextFilter());
}
示例#17
0
void LayersRenderer::synchronize(QQuickFramebufferObject *item)
{
    try {

        bool needPrepare = false;
        LayersView *gdrawer = static_cast<LayersView *>(item);
        _viewPortSize =  QSize(gdrawer->width(), gdrawer->height());
        _windowSize = gdrawer->window()->size();
        _rootDrawer->pixelAreaSize(_viewPortSize);

        while(gdrawer->_attributerequests.size() > 0){
            auto pair = gdrawer->_attributerequests.front();
            gdrawer->_attributerequests.pop_front();
            QVariant var = _rootDrawer->attributeOfDrawer(pair.first, pair.second);
            gdrawer->_copiedAttributes[pair.first.toLower() + "|" + pair.second.toLower()] = var;
            needPrepare = true;
        }

        for(const Ilwis::OperationExpression& expr : gdrawer->_commands){
            quint64 id = commandhandler()->findOperationId(expr);
            if ( id != i64UNDEF) {
                QScopedPointer<OperationImplementation> oper(commandhandler()->create( expr));
                if ( !oper.isNull() && oper->isValid()) {
                    ExecutionContext ctx;
                    SymbolTable symTable;
                    QVariant v = qVariantFromValue((void *) _rootDrawer);
                    ctx._additionalInfo["rootdrawer"] = v;
                    if ( oper->execute(&ctx, symTable)){
                        Symbol sym = symTable.getSymbol("layerdrawer");
                        if ( sym.isValid()){
                            Ilwis::Geodrawer::DrawerInterface *drawer = static_cast<Ilwis::Geodrawer::DrawerInterface *>(sym._var.value<void *>());
                            if ( drawer){
                                ICoverage cov = drawer->attribute("coverage").value<ICoverage>();
                                if ( gdrawer->_manager)
                                    gdrawer->_manager->addDataSource(cov->source().url(),cov->ilwisType(),drawer);
                            }
                        }
                    }
                }
                needPrepare = true;
            }
        }
        gdrawer->_commands = std::deque<OperationExpression>();


        while( gdrawer->_attributeQueue.size() > 0){
            auto pair = gdrawer->_attributeQueue.front();
            gdrawer->_attributeQueue.pop_front();
            for(QVariantMap::const_iterator iter = pair.second.begin(); iter != pair.second.end(); ++iter) {
                _rootDrawer->drawerAttribute(pair.first.toLower(),iter.key(), iter.value());
            }
            needPrepare = true;
        }
        if ( needPrepare){
            _rootDrawer->prepare(Ilwis::Geodrawer::DrawerInterface::ptALL,Ilwis::IOOptions());
           emit synchronizeDone();
        }


    } catch ( const ErrorObject& ){

    } catch ( const std::exception ex){

    }
}
QScriptValue qtscript_create_QTextFormat_class(QScriptEngine *engine)
{
    static const int function_lengths[] = {
        1
        // static
        // prototype
        , 0
        , 1
        , 1
        , 0
        , 0
        , 1
        , 1
        , 1
        , 0
        , 1
        , 1
        , 0
        , 0
        , 0
        , 0
        , 0
        , 0
        , 0
        , 0
        , 0
        , 1
        , 1
        , 1
        , 0
        , 0
        , 1
        , 1
        , 0
        , 1
        , 0
        , 1
        , 1
        , 1
        , 1
        , 2
        , 1
        , 1
        , 2
        , 1
        , 0
        , 0
        , 0
        , 0
        , 0
        , 0
        , 0
        , 0
        , 1
        , 0
    };
    engine->setDefaultPrototype(qMetaTypeId<QTextFormat*>(), QScriptValue());
    QScriptValue proto = engine->newVariant(qVariantFromValue((QTextFormat*)0));
    for (int i = 0; i < 49; ++i) {
        QScriptValue fun = engine->newFunction(qtscript_QTextFormat_prototype_call, function_lengths[i+1]);
        fun.setData(QScriptValue(engine, uint(0xBABE0000 + i)));
        proto.setProperty(QString::fromLatin1(qtscript_QTextFormat_function_names[i+1]),
            fun, QScriptValue::SkipInEnumeration);
    }

    engine->setDefaultPrototype(qMetaTypeId<QTextFormat>(), proto);
    engine->setDefaultPrototype(qMetaTypeId<QTextFormat*>(), proto);

    QScriptValue ctor = engine->newFunction(qtscript_QTextFormat_static_call, proto, function_lengths[0]);
    ctor.setData(QScriptValue(engine, uint(0xBABE0000 + 0)));

    ctor.setProperty(QString::fromLatin1("Property"),
        qtscript_create_QTextFormat_Property_class(engine, ctor));
    ctor.setProperty(QString::fromLatin1("FormatType"),
        qtscript_create_QTextFormat_FormatType_class(engine, ctor));
    ctor.setProperty(QString::fromLatin1("ObjectTypes"),
        qtscript_create_QTextFormat_ObjectTypes_class(engine, ctor));
    ctor.setProperty(QString::fromLatin1("PageBreakFlag"),
        qtscript_create_QTextFormat_PageBreakFlag_class(engine, ctor));
    ctor.setProperty(QString::fromLatin1("PageBreakFlags"),
        qtscript_create_QTextFormat_PageBreakFlags_class(engine));
    return ctor;
}
示例#19
0
文件: gameui.cpp 项目: txase/mythtv
void GameUI::customEvent(QEvent *event)
{
    if (event->type() == DialogCompletionEvent::kEventType)
    {
        DialogCompletionEvent *dce = (DialogCompletionEvent*)(event);

        QString resultid   = dce->GetId();
        QString resulttext = dce->GetResultText();

        if (resultid == "showMenuPopup")
        {
            if (resulttext == tr("Edit Details"))
            {
                edit();
            }
            else if (resulttext == tr("Show Information"))
            {
                showInfo();
            }
            else if (resulttext == tr("Make Favorite") ||
                     resulttext == tr("Remove Favorite"))
            {
                toggleFavorite();
            }
            else if (resulttext == tr("Retrieve Details"))
            {
                gameSearch();
            }
        }
        else if (resultid == "chooseSystemPopup")
        {
            if (!resulttext.isEmpty() && resulttext != tr("Cancel"))
            {
                MythGenericTree *node = m_gameUITree->GetCurrentNode();
                RomInfo *romInfo = qVariantValue<RomInfo *>(node->GetData());
                GameHandler::Launchgame(romInfo, resulttext);
            }
        }
        else if (resultid == "editMetadata")
        {
            MythGenericTree *node = m_gameUITree->GetCurrentNode();
            RomInfo *oldRomInfo = qVariantValue<RomInfo *>(node->GetData());
            delete oldRomInfo;

            RomInfo *romInfo = qVariantValue<RomInfo *>(dce->GetData());
            node->SetData(qVariantFromValue(romInfo));
            node->setString(romInfo->Gamename());

            romInfo->UpdateDatabase();
            updateChangedNode(node, romInfo);
        }
        else if (resultid == "detailsPopup")
        {
            // Play button pushed
            itemClicked(0);
        }
    }
    if (event->type() == MetadataLookupEvent::kEventType)
    {
        MetadataLookupEvent *lue = (MetadataLookupEvent *)event;

        MetadataLookupList lul = lue->lookupList;

        if (m_busyPopup)
        {
            m_busyPopup->Close();
            m_busyPopup = NULL;
        }

        if (lul.isEmpty())
            return;

        if (lul.count() == 1)
        {
            OnGameSearchDone(lul.takeFirst());
        }
        else
        {
            MetadataResultsDialog *resultsdialog =
                  new MetadataResultsDialog(m_popupStack, lul);

            connect(resultsdialog, SIGNAL(haveResult(MetadataLookup*)),
                    SLOT(OnGameSearchListSelection(MetadataLookup*)),
                    Qt::QueuedConnection);

            if (resultsdialog->Create())
                m_popupStack->AddScreen(resultsdialog);
        }
    }
    else if (event->type() == MetadataLookupFailure::kEventType)
    {
        MetadataLookupFailure *luf = (MetadataLookupFailure *)event;

        MetadataLookupList lul = luf->lookupList;

        if (m_busyPopup)
        {
            m_busyPopup->Close();
            m_busyPopup = NULL;
        }

        if (lul.size())
        {
            MetadataLookup *lookup = lul.takeFirst();
            MythGenericTree *node = qVariantValue<MythGenericTree *>(lookup->GetData());
            if (node)
            {
                RomInfo *metadata = qVariantValue<RomInfo *>(node->GetData());
                if (metadata)
                {
                }
            }
            LOG(VB_GENERAL, LOG_ERR,
                QString("No results found for %1").arg(lookup->GetTitle()));
        }
    }
    else if (event->type() == ImageDLEvent::kEventType)
    {
        ImageDLEvent *ide = (ImageDLEvent *)event;

        MetadataLookup *lookup = ide->item;

        if (!lookup)
            return;

        handleDownloadedImages(lookup);
    }
}
static QScriptValue qtscript_QTextFormat_PageBreakFlags_toScriptValue(QScriptEngine *engine, const QTextFormat::PageBreakFlags &value)
{
    return engine->newVariant(qVariantFromValue(value));
}
示例#21
0
文件: gameui.cpp 项目: txase/mythtv
void GameUI::fillNode(MythGenericTree *node)
{
    QString layername = node->getString();
    RomInfo *romInfo = qVariantValue<RomInfo *>(node->GetData());

    MSqlQuery query(MSqlQuery::InitCon());

    query.prepare(getFillSql(node));

    if (romInfo)
    {
        if (!romInfo->System().isEmpty())
            query.bindValue(":SYSTEM",  romInfo->System());
        if (!romInfo->Year().isEmpty())
            query.bindValue(":YEAR", romInfo->Year());
        if (!romInfo->Genre().isEmpty())
            query.bindValue(":GENRE", romInfo->Genre());
        if (!romInfo->Plot().isEmpty())
            query.bindValue(":PLOT", romInfo->Plot());
        if (!romInfo->Publisher().isEmpty())
            query.bindValue(":PUBLISHER", romInfo->Publisher());
        if (!romInfo->Gamename().isEmpty())
            query.bindValue(":GAMENAME", romInfo->Gamename());
    }

    bool IsLeaf = node->getInt() == getLevelsOnThisBranch(node);
    if (query.exec() && query.size() > 0)
    {
        while (query.next())
        {
            QString current = query.value(0).toString().trimmed();
            MythGenericTree *new_node =
                new MythGenericTree(current, node->getInt() + 1, false);
            if (IsLeaf)
            {
                RomInfo *temp = new RomInfo();
                temp->setSystem(query.value(1).toString().trimmed());
                temp->setYear(query.value(2).toString());
                temp->setGenre(query.value(3).toString().trimmed());
                temp->setGamename(query.value(4).toString().trimmed());
                new_node->SetData(qVariantFromValue(temp));
                node->addNode(new_node);
            }
            else
            {
                RomInfo *newRomInfo;
                if (node->getInt() > 1)
                {
                    RomInfo *currentRomInfo;
                    currentRomInfo = qVariantValue<RomInfo *>(node->GetData());
                    newRomInfo = new RomInfo(*currentRomInfo);
                }
                else
                {
                    newRomInfo = new RomInfo();
                }
                new_node->SetData(qVariantFromValue(newRomInfo));
                node->addNode(new_node);
                if (getChildLevelString(node) != "hash")
                    newRomInfo->setField(getChildLevelString(node), current);
            }
        }
    }
}
示例#22
0
     QScriptValue REcmaRestrictOff::createEcma(QScriptContext* context, QScriptEngine* engine) 
    
    {
    if (context->thisObject().strictlyEquals(
       engine->globalObject())) {
       return REcmaHelper::throwError(
       QString::fromLatin1("RRestrictOff(): Did you forget to construct with 'new'?"),
           context);
    }

    QScriptValue result;
        
            // generate constructor variants:
            
    if( context->argumentCount() ==
        0
    ){
    // prepare arguments:
    
    // end of arguments

    // call C++ constructor:
    
            // non-copyable class:
            RRestrictOff
                    * cppResult =
                    new
                    RRestrictOff
                    ();
                
                    // TODO: triggers: Warning: QScriptEngine::newVariant(): changing class of non-QScriptObject not supported:
                    result = engine->newVariant(context->thisObject(), qVariantFromValue(cppResult));
                
    } else 

    if( context->argumentCount() ==
        1
                && (
                
                        context->argument(
                        0
                        ).isVariant()
                        ||
                    
                        context->argument(
                        0
                        ).isQObject()
                        ||
                    
                        context->argument(
                        0
                        ).isNull()
                ) /* type: RDocumentInterface * */
            
    ){
    // prepare arguments:
    
                    // argument is pointer
                    RDocumentInterface * a0 = NULL;

                    a0 = 
                        REcmaHelper::scriptValueTo<RDocumentInterface >(
                            context->argument(0)
                        );
                    
                    if (a0==NULL && 
                        !context->argument(0).isNull()) {
                        return REcmaHelper::throwError("RRestrictOff: Argument 0 is not of type RDocumentInterface *RDocumentInterface *.", context);                    
                    }
                
    // end of arguments

    // call C++ constructor:
    
            // non-copyable class:
            RRestrictOff
                    * cppResult =
                    new
                    RRestrictOff
                    (
                    a0
                    );
                
                    // TODO: triggers: Warning: QScriptEngine::newVariant(): changing class of non-QScriptObject not supported:
                    result = engine->newVariant(context->thisObject(), qVariantFromValue(cppResult));
                
    } else 

    {
       return REcmaHelper::throwError(
       QString::fromLatin1("RRestrictOff(): no matching constructor found."),
           context);
    }
    
    return result;
    }
示例#23
0
     QScriptValue REcmaPointEntity::create(QScriptContext* context, QScriptEngine* engine) 
    
    {
    if (context->thisObject().strictlyEquals(
       engine->globalObject())) {
       return REcmaHelper::throwError(
       QString::fromLatin1("RPointEntity(): Did you forget to construct with 'new'?"),
           context);
    }

    QScriptValue result;
        
            // generate constructor variants:
            
    if( context->argumentCount() ==
        2
                && (
                
                        context->argument(
                        0
                        ).isVariant()
                        ||
                    
                        context->argument(
                        0
                        ).isQObject()
                        ||
                    
                        context->argument(
                        0
                        ).isNull()
                ) /* type: RDocument * */
            
                && (
                
                        context->argument(
                        1
                        ).isVariant()
                        ||
                    
                        context->argument(
                        1
                        ).isQObject()
                        ||
                    
                        context->argument(
                        1
                        ).isNull()
                ) /* type: RPointData */
            
    ){
    // prepare arguments:
    
                    // argument is pointer
                    RDocument * a0 = NULL;

                    a0 = 
                        REcmaHelper::scriptValueTo<RDocument >(
                            context->argument(0)
                        );
                    
                    if (a0==NULL && 
                        !context->argument(0).isNull()) {
                        return REcmaHelper::throwError("RPointEntity: Argument 0 is not of type RDocument *RDocument *.", context);                    
                    }
                
                    // argument is reference
                    RPointData*
                    ap1 =
                    qscriptvalue_cast<
                    RPointData*
                        >(
                        context->argument(
                        1
                        )
                    );
                    if( ap1 == NULL ){
                           return REcmaHelper::throwError("RPointEntity: Argument 1 is not of type RPointData*.",
                               context);                    
                    }
                    RPointData& a1 = *ap1;
                
    // end of arguments

    // call C++ constructor:
    
            // non-copyable class:
            RPointEntity
                    * cppResult =
                    new
                    RPointEntity
                    (
                    a0
        ,
    a1
                    );
                
                    // TODO: triggers: Warning: QScriptEngine::newVariant(): changing class of non-QScriptObject not supported:
                    result = engine->newVariant(context->thisObject(), qVariantFromValue(cppResult));
                
    } else 

    if( context->argumentCount() ==
        3
                && (
                
                        context->argument(
                        0
                        ).isVariant()
                        ||
                    
                        context->argument(
                        0
                        ).isQObject()
                        ||
                    
                        context->argument(
                        0
                        ).isNull()
                ) /* type: RDocument * */
            
                && (
                
                        context->argument(
                        1
                        ).isVariant()
                        ||
                    
                        context->argument(
                        1
                        ).isQObject()
                        ||
                    
                        context->argument(
                        1
                        ).isNull()
                ) /* type: RPointData */
            
                && (
                
                        context->argument(
                        2
                        ).isNumber()
                ) /* type: RObject::Id */
            
    ){
    // prepare arguments:
    
                    // argument is pointer
                    RDocument * a0 = NULL;

                    a0 = 
                        REcmaHelper::scriptValueTo<RDocument >(
                            context->argument(0)
                        );
                    
                    if (a0==NULL && 
                        !context->argument(0).isNull()) {
                        return REcmaHelper::throwError("RPointEntity: Argument 0 is not of type RDocument *RDocument *.", context);                    
                    }
                
                    // argument is reference
                    RPointData*
                    ap1 =
                    qscriptvalue_cast<
                    RPointData*
                        >(
                        context->argument(
                        1
                        )
                    );
                    if( ap1 == NULL ){
                           return REcmaHelper::throwError("RPointEntity: Argument 1 is not of type RPointData*.",
                               context);                    
                    }
                    RPointData& a1 = *ap1;
                
                    // argument isStandardType
                    RObject::Id
                    a2 =
                    (RObject::Id)
                    (int)
                    context->argument( 2 ).
                    toNumber();
                
    // end of arguments

    // call C++ constructor:
    
            // non-copyable class:
            RPointEntity
                    * cppResult =
                    new
                    RPointEntity
                    (
                    a0
        ,
    a1
        ,
    a2
                    );
                
                    // TODO: triggers: Warning: QScriptEngine::newVariant(): changing class of non-QScriptObject not supported:
                    result = engine->newVariant(context->thisObject(), qVariantFromValue(cppResult));
                
    } else 

    {
       return REcmaHelper::throwError(
       QString::fromLatin1("RPointEntity(): no matching constructor found."),
           context);
    }
    
    return result;
    }
示例#24
0
                 void REcmaRestrictOff::initEcma(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RRestrictOff*) 0)));
        protoCreated = true;
    }

    
        // primary base class RSnapRestriction:
        
            QScriptValue dpt = engine.defaultPrototype(
                qMetaTypeId<RSnapRestriction*>());

            if (dpt.isValid()) {
                proto->setPrototype(dpt);
            }
          
        /*
        
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class RSnapRestriction
        REcmaHelper::registerFunction(&engine, proto, getRSnapRestriction, "getRSnapRestriction");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, restrictSnap, "restrictSnap");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RRestrictOff*>(), *proto);

        
    

    QScriptValue ctor = engine.newFunction(createEcma, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RRestrictOff",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
示例#25
0
QVariant MessageModel::data(const QModelIndex &index, int role) const
{
    int row = index.row();
    int column = index.column();

    ContextItem *cntxtItem = static_cast<ContextItem *>(index.internalPointer());
    if (cntxtItem) {
        if (row >= cntxtItem->messageItemsInList() || !index.isValid())
            return QVariant();

        MessageItem *msgItem = cntxtItem->messageItem(row);

        if (role == Qt::DisplayRole) {
            switch(column) {
            case 0: // done
                return QVariant();
            case 1: // source text
			    return msgItem->sourceText().simplified();
            case 2: // translation
                return msgItem->translation().simplified();
            }
        }
        else if ((role == Qt::DecorationRole) && (column == 0)) {
            if (msgItem->message().type() == MetaTranslatorMessage::Unfinished && msgItem->translation().isEmpty())
                return qVariantFromValue(*TrWindow::pxEmpty);
            else if (msgItem->message().type() == MetaTranslatorMessage::Unfinished && msgItem->danger())
                return qVariantFromValue(*TrWindow::pxDanger);
            else if (msgItem->message().type() == MetaTranslatorMessage::Finished && msgItem->danger())
                return qVariantFromValue(*TrWindow::pxWarning);
            else if (msgItem->message().type() == MetaTranslatorMessage::Finished)
                return qVariantFromValue(*TrWindow::pxOn);
            else if (msgItem->message().type() == MetaTranslatorMessage::Unfinished)
                return qVariantFromValue(*TrWindow::pxOff);
            else if (msgItem->message().type() == MetaTranslatorMessage::Obsolete)
                return qVariantFromValue(*TrWindow::pxObsolete);
        }
    } else {
        if (row >= cntxtList.count() || !index.isValid())
            return QVariant();

        ContextItem *cntxtItem = cntxtList.at(row);

        if (role == Qt::DisplayRole) {
            switch(column) {
            case 0: // done
                return QVariant();
            case 1: // context
                return cntxtItem->context().simplified();
            case 2: // items
                QString s;
                int itemCount = cntxtItem->messageItemsInList();
                int obsoleteCount = cntxtItem->obsolete();
                int finishedCount = cntxtItem->finishedCount();
                s.sprintf("%d/%d", finishedCount,
                    itemCount - obsoleteCount);
                return s;
            }
        }
        else if ((role == Qt::DecorationRole) && (column == 0)) {
            if (cntxtItem->isContextObsolete())
                return qVariantFromValue(*TrWindow::pxObsolete);
            else if (cntxtItem->isFinished())
                return qVariantFromValue(*TrWindow::pxOn);
            else
                return qVariantFromValue(*TrWindow::pxOff);
        }
    }
    return QVariant();
}
示例#26
0
        // includes for base ecma wrapper classes
         void REcmaModifiedListener::init(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RModifiedListener*) 0)));
        protoCreated = true;
    }

    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, updateModifiedListener, "updateModifiedListener");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RModifiedListener*>(), *proto);

        
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RModifiedListener",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
示例#27
0
        // includes for base ecma wrapper classes
         void REcmaLinetypePattern::init(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RLinetypePattern*) 0)));
        protoCreated = true;
    }

    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    
    // copy:
    REcmaHelper::registerFunction(&engine, proto, copy, "copy");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, set, "set");
            
            REcmaHelper::registerFunction(&engine, proto, isValid, "isValid");
            
            REcmaHelper::registerFunction(&engine, proto, getNumDashes, "getNumDashes");
            
            REcmaHelper::registerFunction(&engine, proto, getPatternLength, "getPatternLength");
            
            REcmaHelper::registerFunction(&engine, proto, getDashLengthAt, "getDashLengthAt");
            
            REcmaHelper::registerFunction(&engine, proto, getLargestGap, "getLargestGap");
            
            REcmaHelper::registerFunction(&engine, proto, hasDashAt, "hasDashAt");
            
            REcmaHelper::registerFunction(&engine, proto, getDelta, "getDelta");
            
            REcmaHelper::registerFunction(&engine, proto, isSymmetrical, "isSymmetrical");
            
            REcmaHelper::registerFunction(&engine, proto, scale, "scale");
            
            REcmaHelper::registerFunction(&engine, proto, operator_assign, "operator_assign");
            
            REcmaHelper::registerFunction(&engine, proto, equals, "equals");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RLinetypePattern*>(), *proto);

        
                engine.setDefaultPrototype(qMetaTypeId<
                RLinetypePattern
                > (), *proto);
            
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RLinetypePattern",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
示例#28
0
static QScriptValue qtscript_QTextBlock_static_call(QScriptContext *context, QScriptEngine *)
{
    uint _id = context->callee().data().toUInt32();
    Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000);
    _id &= 0x0000FFFF;
    switch (_id) {
    case 0:
    if (context->thisObject().strictlyEquals(context->engine()->globalObject())) {
        return context->throwError(QString::fromLatin1("QTextBlock(): Did you forget to construct with 'new'?"));
    }
    if (context->argumentCount() == 0) {
        QTextBlock _q_cpp_result;
        QScriptValue _q_result = context->engine()->newVariant(context->thisObject(), qVariantFromValue(_q_cpp_result));
        return _q_result;
    } else if (context->argumentCount() == 1) {
        QTextBlock _q_arg0 = qscriptvalue_cast<QTextBlock>(context->argument(0));
        QTextBlock _q_cpp_result(_q_arg0);
        QScriptValue _q_result = context->engine()->newVariant(context->thisObject(), qVariantFromValue(_q_cpp_result));
        return _q_result;
    }
    break;

    default:
    Q_ASSERT(false);
    }
    return qtscript_QTextBlock_throw_ambiguity_error_helper(context,
        qtscript_QTextBlock_function_names[_id],
        qtscript_QTextBlock_function_signatures[_id]);
}
                 void REcmaNewDocumentListenerAdapter::initEcma(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RNewDocumentListenerAdapter*) 0)));
        protoCreated = true;
    }

    
        // primary base class QObject:
        
            QScriptValue dpt = engine.defaultPrototype(
                qMetaTypeId<QObject*>());

            if (dpt.isValid()) {
                proto->setPrototype(dpt);
            }
          
        /*
        REcmaNewDocumentListener::initEcma(engine, proto);
          
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class QObject
        REcmaHelper::registerFunction(&engine, proto, getQObject, "getQObject");
        
        // conversion for base class RNewDocumentListener
        REcmaHelper::registerFunction(&engine, proto, getRNewDocumentListener, "getRNewDocumentListener");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

        // properties of secondary base class RNewDocumentListener:
        

        // methods of secondary base class RNewDocumentListener:
        

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, updateNewDocumentListener, "updateNewDocumentListener");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RNewDocumentListenerAdapter*>(), *proto);

        
                        qScriptRegisterMetaType<
                        RNewDocumentListenerAdapter*>(
                        &engine, toScriptValue, fromScriptValue, *proto);
                    
    

    QScriptValue ctor = engine.newFunction(createEcma, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RNewDocumentListenerAdapter",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
示例#30
0
/**
*  \brief Creates a dialog displaying current recording status and options
*         available
*/
void ScheduleCommon::ShowNotRecordingDialog(const RecordingInfo& recinfo)
{
    QString timeFormat = gCoreContext->GetSetting("TimeFormat", "h:mm AP");

    QString message = recinfo.toString(ProgramInfo::kTitleSubtitle, " - ");

    message += "\n\n";
    message += toDescription(recinfo.GetRecordingStatus(),
                             recinfo.GetRecordingRuleType(),
                             recinfo.GetRecordingStartTime());

    if (recinfo.GetRecordingStatus() == rsConflict ||
        recinfo.GetRecordingStatus() == rsLaterShowing)
    {
        vector<ProgramInfo *> *confList = RemoteGetConflictList(&recinfo);

        if (!confList->empty())
        {
            message += " ";
            message += tr("The following programs will be recorded instead:");
            message += "\n";
        }

        uint maxi = 0;
        for (; confList->begin() != confList->end() && maxi < 4; maxi++)
        {
            ProgramInfo *p = *confList->begin();
            message += QString("%1 - %2  %3\n")
                .arg(p->GetRecordingStartTime()
                     .toLocalTime().toString(timeFormat))
                .arg(p->GetRecordingEndTime()
                     .toLocalTime().toString(timeFormat))
                .arg(p->toString(ProgramInfo::kTitleSubtitle, " - "));
            delete p;
            confList->erase(confList->begin());
        }
        message += "\n";
        while (!confList->empty())
        {
            delete confList->back();
            confList->pop_back();
        }
        delete confList;
    }

    MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
    MythDialogBox *menuPopup = new MythDialogBox(message, popupStack,
                                                 "notRecOptionPopup", true);

    if (menuPopup->Create())
    {
        menuPopup->SetReturnEvent(this, "schedulenotrecording");

        QDateTime now = MythDate::current();

        if ((recinfo.GetRecordingStartTime() < now) &&
            (recinfo.GetRecordingEndTime() > now) &&
            (recinfo.GetRecordingStatus() != rsDontRecord) &&
            (recinfo.GetRecordingStatus() != rsNotListed))
        {
            menuPopup->AddButton(tr("Restart recording this showing"),
                                 qVariantFromValue(recinfo));
        }

        if (recinfo.GetRecordingEndTime() > now)
        {
            if ((recinfo.GetRecordingRuleType() != kSingleRecord &&
                recinfo.GetRecordingRuleType() != kOverrideRecord) &&
                (recinfo.GetRecordingStatus() == rsDontRecord ||
                recinfo.GetRecordingStatus() == rsPreviousRecording ||
                recinfo.GetRecordingStatus() == rsCurrentRecording ||
                recinfo.GetRecordingStatus() == rsEarlierShowing ||
                recinfo.GetRecordingStatus() == rsNeverRecord ||
                recinfo.GetRecordingStatus() == rsRepeat ||
                recinfo.GetRecordingStatus() == rsInactive ||
                recinfo.GetRecordingStatus() == rsLaterShowing))
            {
                menuPopup->AddButton(tr("Record this showing anyway"),
                                    qVariantFromValue(recinfo));
                if (recinfo.GetRecordingStatus() == rsPreviousRecording ||
                    recinfo.GetRecordingStatus() == rsNeverRecord)
                {
                    menuPopup->AddButton(tr("Forget previous recording"),
                                        qVariantFromValue(recinfo));
                }
            }

            if (recinfo.GetRecordingRuleType() != kOverrideRecord &&
                recinfo.GetRecordingRuleType() != kDontRecord)
            {
                if (recinfo.GetRecordingRuleType() != kSingleRecord &&
                    recinfo.GetRecordingStatus() != rsPreviousRecording &&
                    recinfo.GetRecordingStatus() != rsCurrentRecording &&
                    recinfo.GetRecordingStatus() != rsNeverRecord &&
                    recinfo.GetRecordingStatus() != rsNotListed)
                {
                    if (recinfo.GetRecordingStartTime() > now)
                    {
                        menuPopup->AddButton(tr("Don't record this showing"),
                                            qVariantFromValue(recinfo));
                    }

                    const RecordingDupMethodType dupmethod =
                        recinfo.GetDuplicateCheckMethod();

                    if (recinfo.GetRecordingRuleType() != kOneRecord &&
                        !((recinfo.GetFindID() == 0 ||
                           !IsFindApplicable(recinfo)) &&
                          recinfo.GetCategoryType() == "series" &&
                          recinfo.GetProgramID().contains(QRegExp("0000$"))) &&
                        ((!(dupmethod & kDupCheckNone) &&
                          !recinfo.GetProgramID().isEmpty() &&
                          (recinfo.GetFindID() != 0 ||
                           !IsFindApplicable(recinfo))) ||
                         ((dupmethod & kDupCheckSub) &&
                          !recinfo.GetSubtitle().isEmpty()) ||
                         ((dupmethod & kDupCheckDesc) &&
                          !recinfo.GetDescription().isEmpty()) ||
                         ((dupmethod & kDupCheckSubThenDesc) &&
                          (!recinfo.GetSubtitle().isEmpty() ||
                           !recinfo.GetDescription().isEmpty())) ))
                        {
                            menuPopup->AddButton(tr("Never record this episode"),
                                                 qVariantFromValue(recinfo));
                        }
                }

                if (recinfo.GetRecordingRuleType() != kSingleRecord &&
                    recinfo.GetRecordingRuleType() != kOneRecord &&
                    recinfo.GetRecordingStatus() != rsNotListed)
                {
                    menuPopup->AddButton(tr("Override this showing with options"),
                                        qVariantFromValue(recinfo));
                }

                menuPopup->AddButton(tr("Edit recording options"),
                                     qVariantFromValue(recinfo));
                menuPopup->AddButton(tr("Delete recording rule"),
                                     qVariantFromValue(recinfo));
            }

            if (recinfo.GetRecordingRuleType() == kOverrideRecord ||
                recinfo.GetRecordingRuleType() == kDontRecord)
            {
                menuPopup->AddButton(tr("Edit override options"),
                                    qVariantFromValue(recinfo));
                menuPopup->AddButton(tr("Delete override rule"),
                                    qVariantFromValue(recinfo));
            }
        }

        popupStack->AddScreen(menuPopup);
    }
    else
        delete menuPopup;
}