//----------------------------------------------------------------------------- //! //----------------------------------------------------------------------------- // Activate the Select From Favorites popup void tSiriusController::SelectFavoriteChannels() { bool hasList = RefreshFavoriteChannels(tAudioSettings::Instance()->Favorites()); //if returns false that means we have no subscriptions yet, we're still powering up if (hasList == true) { Assert( m_pFavoriteChannels != 0 ); QSet<int> favoriteSet = QSet<int>::fromList(*m_pFavoriteChannels); if (favoriteSet.isEmpty()) { tMessageBox::Error( 0, tr( "Favorites"), tr("No favorites defined"), tMessageBox::CLOSE ); return; } const QList<tChannelRecord *>& chanList = GetSubscribedSubsetList(favoriteSet); SelectFromChannels(chanList, tr("Channels") + QString(" - ") + tr("Favorites"), false); //no favorites column needed for the favorites list (all we'd be able to do is unfavorite them, not sure that is entirely useful?) } else { tMessageBox::Error( 0, tr( "Favorites"), tr("Still powering up, please try again."), tMessageBox::CLOSE ); } }
int selector::select(lua_State *L) { int top = lua_gettop(L); if (top !=1) { lua_pushnumber(L,API_WRONG_PARAMETER); return 1; } if (_hv->size() == 0) { if (lua_istable(L,-1) == FALSE) { lua_pushnumber(L,API_WRONG_PARAMETER); return 1; } // find named parameter "actors" and ensure it is table lua_pushstring(L, "actors"); lua_gettable(L, -2); if (lua_istable(L,-1) == FALSE) { lua_settop(L,top); lua_pushnumber(L,API_WRONG_PARAMETER); return 1; } int param_counter = 0; lua_pushnil(L); while(lua_next(L,-2)) { switch (lua_type(L,-1)) { case LUA_TUSERDATA: { userdataType *x = (userdataType *)lua_touserdata(L,-1); luaobject *lo = x->lo; if (lo->get_active_object()) { AOSlot slot; slot.h = LpHandlePtr(new LpHandle()); slot.h->HandleName("Active Object Listener"); slot.ao = lo->get_active_object(); _hv->push_back(slot.h); lo->get_active_object()->AddEventListener(slot.h); _slots.push_back(slot); } else { lua_settop(L,top); lua_pushnumber(L,API_WRONG_PARAMETER); return 1; } break; } default: { lua_settop(L,top); lua_pushnumber(L,API_WRONG_PARAMETER); return 1; } } lua_pop(L, 1); } // pop the actors table from the stack lua_pop(L,1); } if (_hv->size() == 0) { lua_settop(L,top); lua_pushnumber(L,API_WRONG_PARAMETER); return 1; } int timeout = 35; GetTableNumberParam(L,-1,&timeout,"timeout",35); ApiErrorCode err = API_SUCCESS; int selected_index = -1; IwMessagePtr event; err = SelectFromChannels( *_hv, Seconds(timeout), selected_index, event); lua_pushnumber(L,err); if (IW_SUCCESS(err)) { lua_pushnumber(L,selected_index+1); } else { lua_pushnumber(L,-1); }; // unset listeners return 2; }
//----------------------------------------------------------------------------- //! //----------------------------------------------------------------------------- void tSiriusController::SelectChannels() { const QList<tChannelRecord *>& chanList = GetSubscribedChannelList(); SelectFromChannels(chanList, tr("Channels") + QString(" - ") + tr("Subscribed"), true); }