本文整理汇总了C++中CVariant::asInteger方法的典型用法代码示例。如果您正苦于以下问题:C++ CVariant::asInteger方法的具体用法?C++ CVariant::asInteger怎么用?C++ CVariant::asInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVariant
的用法示例。
在下文中一共展示了CVariant::asInteger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetHeading
void CGUIDialogKeyboard::SetHeading(const CVariant &heading)
{
if (heading.isString())
m_strHeading = heading.asString();
else if (heading.isInteger() && heading.asInteger())
m_strHeading = g_localizeStrings.Get((uint32_t)heading.asInteger());
}
示例2: ShowAndGetInput
// Show keyboard with initial value (aTextString) and replace with result string.
// Returns: true - successful display and input (empty result may return true or false depending on parameter)
// false - unsuccessful display of the keyboard or cancelled editing
bool CGUIKeyboardFactory::ShowAndGetInput(std::string& aTextString, CVariant heading, bool allowEmptyResult, bool hiddenInput /* = false */, unsigned int autoCloseMs /* = 0 */)
{
bool confirmed = false;
CGUIKeyboard *kb = NULL;
//heading can be a string or a localization id
std::string headingStr;
if (heading.isString())
headingStr = heading.asString();
else if (heading.isInteger() && heading.asInteger())
headingStr = g_localizeStrings.Get((uint32_t)heading.asInteger());
#if defined(TARGET_DARWIN_IOS)
kb = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogKeyboardTouch>(WINDOW_DIALOG_KEYBOARD_TOUCH);
#else
kb = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogKeyboardGeneric>(WINDOW_DIALOG_KEYBOARD);
#endif
if (kb)
{
g_activeKeyboard = kb;
kb->startAutoCloseTimer(autoCloseMs);
confirmed = kb->ShowAndGetInput(keyTypedCB, aTextString, aTextString, headingStr, hiddenInput);
g_activeKeyboard = NULL;
}
if (confirmed)
{
if (!allowEmptyResult && aTextString.empty())
confirmed = false;
}
return confirmed;
}
示例3: GetLocalized
std::string CGUIDialogBoxBase::GetLocalized(const CVariant &var) const
{
if (var.isString())
return var.asString();
else if (var.isInteger() && var.asInteger())
return g_localizeStrings.Get((uint32_t)var.asInteger());
return "";
}
示例4: GetLocalized
CStdString IDirectory::GetLocalized(const CVariant &var) const
{
if (var.isString())
return var.asString();
else if (var.isInteger() && var.asInteger())
return g_localizeStrings.Get(var.asInteger());
return "";
}
示例5: SetInputType
void CGUIEditControl::SetInputType(CGUIEditControl::INPUT_TYPE type, CVariant heading)
{
m_inputType = type;
if (heading.isString())
m_inputHeading = heading.asString();
else if (heading.isInteger() && heading.asInteger())
m_inputHeading = g_localizeStrings.Get(static_cast<uint32_t>(heading.asInteger()));
//! @todo Verify the current input string?
}
示例6: VariantToLocalizedString
std::string CBaseEvent::VariantToLocalizedString(const CVariant& variant)
{
if (variant.isString())
return variant.asString();
if (variant.isInteger() && variant.asInteger() > 0)
return g_localizeStrings.Get(static_cast<uint32_t>(variant.asInteger()));
if (variant.isUnsignedInteger() && variant.asUnsignedInteger() > 0)
return g_localizeStrings.Get(static_cast<uint32_t>(variant.asUnsignedInteger()));
return "";
}
示例7: SetDescription
void CGUIWindowSettingsCategory::SetDescription(const CVariant &label)
{
if (GetControl(CONTROL_DESCRIPTION) == NULL)
return;
if (label.isString())
SET_CONTROL_LABEL(CONTROL_DESCRIPTION, label.asString());
else if (label.isInteger() && label.asInteger() >= 0)
SET_CONTROL_LABEL(CONTROL_DESCRIPTION, (int)label.asInteger());
else
SET_CONTROL_LABEL(CONTROL_DESCRIPTION, "");
}
示例8: GetChannels
JSONRPC_STATUS CPVROperations::GetChannels(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
if (!g_PVRManager.IsStarted())
return FailedToExecute;
CPVRChannelGroupsContainer *channelGroupContainer = g_PVRChannelGroups;
if (channelGroupContainer == NULL)
return FailedToExecute;
CPVRChannelGroupPtr channelGroup;
CVariant id = parameterObject["channelgroupid"];
if (id.isInteger())
channelGroup = channelGroupContainer->GetByIdFromAll((int)id.asInteger());
else if (id.isString())
channelGroup = channelGroupContainer->GetGroupAll(id.asString() == "allradio");
if (channelGroup == NULL)
return InvalidParams;
CFileItemList channels;
if (channelGroup->GetMembers(channels) < 0)
return InvalidParams;
HandleFileItemList("channelid", false, "channels", channels, parameterObject, result, true);
return OK;
}
示例9: Zoom
JSONRPC_STATUS CPlayerOperations::Zoom(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CVariant zoom = parameterObject["zoom"];
switch (GetPlayer(parameterObject["playerid"]))
{
case Picture:
if (zoom.isInteger())
SendSlideshowAction(ACTION_ZOOM_LEVEL_NORMAL + ((int)zoom.asInteger() - 1));
else if (zoom.isString())
{
std::string strZoom = zoom.asString();
if (strZoom == "in")
SendSlideshowAction(ACTION_ZOOM_IN);
else if (strZoom == "out")
SendSlideshowAction(ACTION_ZOOM_OUT);
else
return InvalidParams;
}
else
return InvalidParams;
return ACK;
case Video:
case Audio:
case None:
default:
return FailedToExecute;
}
}
示例10: GetPlayer
PlayerType CPlayerOperations::GetPlayer(const CVariant &player)
{
int iPlayer = (int)player.asInteger();
PlayerType playerID;
switch (iPlayer)
{
case PLAYLIST_VIDEO:
playerID = Video;
break;
case PLAYLIST_MUSIC:
playerID = Audio;
break;
case PLAYLIST_PICTURE:
playerID = Picture;
break;
default:
playerID = None;
break;
}
if (GetPlaylist(playerID) == iPlayer)
return playerID;
else
return None;
}
示例11: GetPlaylist
int CPlaylistOperations::GetPlaylist(const CVariant &playlist)
{
int playlistid = (int)playlist.asInteger();
if (playlistid > PLAYLIST_NONE && playlistid <= PLAYLIST_PICTURE)
return playlistid;
return PLAYLIST_NONE;
}
示例12: GoTo
JSONRPC_STATUS CPlayerOperations::GoTo(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CVariant to = parameterObject["to"];
switch (GetPlayer(parameterObject["playerid"]))
{
case Video:
case Audio:
if (to.isString())
{
std::string strTo = to.asString();
int actionID;
if (strTo == "previous")
actionID = ACTION_PREV_ITEM;
else if (strTo == "next")
actionID = ACTION_NEXT_ITEM;
else
return InvalidParams;
CApplicationMessenger::GetInstance().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(actionID)));
}
else if (to.isInteger())
{
if (IsPVRChannel())
CApplicationMessenger::GetInstance().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(
new CAction(ACTION_CHANNEL_SWITCH, static_cast<float>(to.asInteger()))));
else
CApplicationMessenger::GetInstance().SendMsg(TMSG_PLAYLISTPLAYER_PLAY, static_cast<int>(to.asInteger()));
}
else
return InvalidParams;
break;
case Picture:
if (to.isString())
{
std::string strTo = to.asString();
int actionID;
if (strTo == "previous")
actionID = ACTION_PREV_PICTURE;
else if (strTo == "next")
actionID = ACTION_NEXT_PICTURE;
else
return InvalidParams;
SendSlideshowAction(actionID);
}
else
return FailedToExecute;
break;
case None:
default:
return FailedToExecute;
}
OnPlaylistChanged();
return ACK;
}
示例13: GoTo
JSONRPC_STATUS CPlayerOperations::GoTo(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CVariant to = parameterObject["to"];
switch (GetPlayer(parameterObject["playerid"]))
{
case Video:
case Audio:
if (to.isString())
{
std::string strTo = to.asString();
int actionID;
if (strTo == "previous")
actionID = ACTION_PREV_ITEM;
else if (strTo == "next")
actionID = ACTION_NEXT_ITEM;
else
return InvalidParams;
CApplicationMessenger::Get().SendAction(CAction(actionID));
}
else if (to.isInteger())
{
if (IsPVRChannel())
CApplicationMessenger::Get().SendAction(CAction(ACTION_CHANNEL_SWITCH, (float)to.asInteger()));
else
CApplicationMessenger::Get().PlayListPlayerPlay((int)to.asInteger());
}
else
return InvalidParams;
break;
case Picture:
if (to.isString())
{
std::string strTo = to.asString();
int actionID;
if (strTo == "previous")
actionID = ACTION_PREV_PICTURE;
else if (strTo == "next")
actionID = ACTION_NEXT_PICTURE;
else
return InvalidParams;
SendSlideshowAction(actionID);
}
else
return FailedToExecute;
break;
case None:
default:
return FailedToExecute;
}
OnPlaylistChanged();
return ACK;
}
示例14: Announce
void CPeripheralCecAdapter::Announce(AnnouncementFlag flag, const char *sender, const char *message, const CVariant &data)
{
if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnQuit") && m_bIsReady)
{
m_iExitCode = (int)data.asInteger(0);
StopThread(false);
}
else if (flag == GUI && !strcmp(sender, "xbmc") && !strcmp(message, "OnScreensaverDeactivated") && m_bIsReady)
{
if (m_configuration.bPowerOffScreensaver == 1)
{
// power off/on on screensaver is set, and devices to wake are set
if (!m_configuration.wakeDevices.IsEmpty())
m_cecAdapter->PowerOnDevices(CECDEVICE_BROADCAST);
// the option to make XBMC the active source is set
if (m_configuration.bActivateSource == 1)
m_cecAdapter->SetActiveSource();
}
}
else if (flag == GUI && !strcmp(sender, "xbmc") && !strcmp(message, "OnScreensaverActivated") && m_bIsReady)
{
// Don't put devices to standby if application is currently playing
if ((!g_application.IsPlaying() || g_application.IsPaused()) && m_configuration.bPowerOffScreensaver == 1)
{
m_screensaverLastActivated = CDateTime::GetCurrentDateTime();
// only power off when we're the active source
if (m_cecAdapter->IsLibCECActiveSource())
m_cecAdapter->StandbyDevices(CECDEVICE_BROADCAST);
}
}
else if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnSleep"))
{
// this will also power off devices when we're the active source
{
CSingleLock lock(m_critSection);
m_bStop = true;
}
WaitForThreadExit(0);
}
else if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnWake"))
{
{
// reconnect to the device
CSingleLock lock(m_critSection);
CLog::Log(LOGDEBUG, "%s - reconnecting to the CEC adapter after standby mode", __FUNCTION__);
// close the previous connection
m_cecAdapter->Close();
}
// and open a new one
StopThread();
Create();
}
}
示例15: SetControlLabel
void CGUIDialogSettingsBase::SetControlLabel(int controlId, const CVariant &label)
{
if (GetControl(controlId) == NULL)
return;
if (label.isString())
SET_CONTROL_LABEL(controlId, label.asString());
else if (label.isInteger() && label.asInteger() >= 0)
{
int labelId = static_cast<uint32_t>(label.asInteger());
std::string localizedString = GetLocalizedString(labelId);
if (!localizedString.empty())
SET_CONTROL_LABEL(controlId, localizedString);
else
SET_CONTROL_LABEL(controlId, labelId);
}
else
SET_CONTROL_LABEL(controlId, "");
}