本文整理汇总了C++中CGUIDialogSelect::GetSelectedItem方法的典型用法代码示例。如果您正苦于以下问题:C++ CGUIDialogSelect::GetSelectedItem方法的具体用法?C++ CGUIDialogSelect::GetSelectedItem怎么用?C++ CGUIDialogSelect::GetSelectedItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGUIDialogSelect
的用法示例。
在下文中一共展示了CGUIDialogSelect::GetSelectedItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnField
void CGUIDialogSmartPlaylistRule::OnField()
{
const auto fields = CSmartPlaylistRule::GetFields(m_type);
CGUIDialogSelect* dialog = g_windowManager.GetWindow<CGUIDialogSelect>();
dialog->Reset();
dialog->SetHeading(CVariant{20427});
int selected = -1;
for (auto field = fields.begin(); field != fields.end(); field++)
{
dialog->Add(CSmartPlaylistRule::GetLocalizedField(*field));
if (*field == m_rule.m_field)
selected = std::distance(fields.begin(), field);
}
if (selected > -1)
dialog->SetSelected(selected);
dialog->Open();
int newSelected = dialog->GetSelectedItem();
// check if selection has changed
if (!dialog->IsConfirmed() || newSelected < 0 || newSelected == selected)
return;
m_rule.m_field = fields[newSelected];
// check if operator is still valid. if not, reset to first valid one
std::vector< std::pair<std::string, int> > validOperators = GetValidOperators(m_rule);
bool isValid = false;
for (auto op : validOperators)
if (std::get<0>(op) == std::get<0>(OperatorLabel(m_rule.m_operator)))
isValid = true;
if (!isValid)
m_rule.m_operator = (CDatabaseQueryRule::SEARCH_OPERATOR)std::get<1>(validOperators[0]);
m_rule.SetParameter("");
UpdateButtons();
}
示例2: open
int Interface_GUIDialogSelect::open(void* kodiBase, const char *heading, const char *entries[], unsigned int size, int selected, unsigned int autoclose)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
if (!addon)
{
CLog::Log(LOGERROR, "Interface_GUIDialogSelect::%s - invalid data", __FUNCTION__);
return -1;
}
CGUIDialogSelect* dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT);
if (!heading || !entries || !dialog)
{
CLog::Log(LOGERROR,
"Interface_GUIDialogSelect::%s - invalid handler data (heading='%p', entries='%p', "
"dialog='%p') on addon '%s'",
__FUNCTION__, heading, static_cast<const void*>(entries), static_cast<void*>(dialog),
addon->ID().c_str());
return -1;
}
dialog->Reset();
dialog->SetHeading(CVariant{heading});
for (unsigned int i = 0; i < size; ++i)
dialog->Add(entries[i]);
if (selected > 0)
dialog->SetSelected(selected);
if (autoclose > 0)
dialog->SetAutoClose(autoclose);
dialog->Open();
return dialog->GetSelectedItem();
}
示例3: OpenGroupSelectionDialog
bool CGUIWindowPVRBase::OpenGroupSelectionDialog(void)
{
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (!dialog)
return false;
CFileItemList options;
g_PVRChannelGroups->Get(m_bRadio)->GetGroupList(&options, true);
dialog->Reset();
dialog->SetHeading(CVariant{g_localizeStrings.Get(19146)});
dialog->SetItems(options);
dialog->SetMultiSelection(false);
dialog->SetSelected(m_group->GroupName());
dialog->Open();
if (!dialog->IsConfirmed())
return false;
const CFileItemPtr item = dialog->GetSelectedItem();
if (!item)
return false;
SetGroup(g_PVRChannelGroups->Get(m_bRadio)->GetByName(item->m_strTitle));
return true;
}
示例4: ChooseArtType
string CGUIDialogVideoInfo::ChooseArtType(const CFileItem &videoItem, map<string, string> ¤tArt)
{
// prompt for choice
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (!dialog || !videoItem.HasVideoInfoTag())
return "";
CFileItemList items;
dialog->SetHeading(13511);
dialog->Reset();
dialog->SetUseDetails(true);
dialog->EnableButton(true, 13516);
CVideoDatabase db;
db.Open();
vector<string> artTypes = CVideoThumbLoader::GetArtTypes(videoItem.GetVideoInfoTag()->m_type);
// add in any stored art for this item that is non-empty.
db.GetArtForItem(videoItem.GetVideoInfoTag()->m_iDbId, videoItem.GetVideoInfoTag()->m_type, currentArt);
for (CGUIListItem::ArtMap::iterator i = currentArt.begin(); i != currentArt.end(); ++i)
{
if (!i->second.empty() && find(artTypes.begin(), artTypes.end(), i->first) == artTypes.end())
artTypes.push_back(i->first);
}
// add any art types that exist for other media items of the same type
vector<string> dbArtTypes;
db.GetArtTypes(videoItem.GetVideoInfoTag()->m_type, dbArtTypes);
for (vector<string>::const_iterator it = dbArtTypes.begin(); it != dbArtTypes.end(); it++)
{
if (find(artTypes.begin(), artTypes.end(), *it) == artTypes.end())
artTypes.push_back(*it);
}
for (vector<string>::const_iterator i = artTypes.begin(); i != artTypes.end(); ++i)
{
string type = *i;
CFileItemPtr item(new CFileItem(type, "false"));
item->SetLabel(type);
if (videoItem.HasArt(type))
item->SetArt("thumb", videoItem.GetArt(type));
items.Add(item);
}
dialog->SetItems(&items);
dialog->DoModal();
if (dialog->IsButtonPressed())
{
// Get the new artwork name
CStdString strArtworkName;
if (!CGUIKeyboardFactory::ShowAndGetInput(strArtworkName, g_localizeStrings.Get(13516), false))
return "";
return strArtworkName;
}
return dialog->GetSelectedItem()->GetLabel();
}
示例5: DeleteAllRecordingsFromTrash
PVR_ERROR CPVRClients::DeleteAllRecordingsFromTrash()
{
PVR_ERROR error(PVR_ERROR_NO_ERROR);
PVR_CLIENTMAP clients;
GetConnectedClients(clients);
std::vector<PVR_CLIENT> suppClients;
for (PVR_CLIENTMAP_CITR itrClients = clients.begin(); itrClients != clients.end(); ++itrClients)
{
if (itrClients->second->SupportsRecordingsUndelete() && itrClients->second->GetRecordingsAmount(true) > 0)
suppClients.push_back(itrClients->second);
}
int selection = 0;
if (suppClients.size() > 1)
{
// have user select client
CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
pDialog->Reset();
pDialog->SetHeading(CVariant{19292}); //Delete all permanently
pDialog->Add(g_localizeStrings.Get(24032)); // All Add-ons
PVR_CLIENTMAP_CITR itrClients;
for (itrClients = clients.begin(); itrClients != clients.end(); ++itrClients)
{
if (itrClients->second->SupportsRecordingsUndelete() && itrClients->second->GetRecordingsAmount(true) > 0)
pDialog->Add(itrClients->second->GetBackendName());
}
pDialog->Open();
selection = pDialog->GetSelectedItem();
}
if (selection == 0)
{
typedef std::vector<PVR_CLIENT>::const_iterator suppClientsCITR;
for (suppClientsCITR itrSuppClients = suppClients.begin(); itrSuppClients != suppClients.end(); ++itrSuppClients)
{
PVR_ERROR currentError = (*itrSuppClients)->DeleteAllRecordingsFromTrash();
if (currentError != PVR_ERROR_NO_ERROR)
{
CLog::Log(LOGERROR, "PVR - %s - cannot delete all recordings from client '%d': %s",__FUNCTION__, (*itrSuppClients)->GetID(), CPVRClient::ToString(currentError));
error = currentError;
}
}
}
else if (selection >= 1 && selection <= (int)suppClients.size())
{
PVR_ERROR currentError = suppClients[selection-1]->DeleteAllRecordingsFromTrash();
if (currentError != PVR_ERROR_NO_ERROR)
{
CLog::Log(LOGERROR, "PVR - %s - cannot delete all recordings from client '%d': %s",__FUNCTION__, suppClients[selection-1]->GetID(), CPVRClient::ToString(currentError));
error = currentError;
}
}
return error;
}
示例6: GetAutoLoginProfileChoice
bool CGUIWindowSettingsProfile::GetAutoLoginProfileChoice(int &iProfile)
{
CGUIDialogSelect *dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT);
if (!dialog) return false;
const CProfilesManager &profileManager = CServiceBroker::GetProfileManager();
// add items
// "Last used profile" option comes first, so up indices by 1
int autoLoginProfileId = profileManager.GetAutoLoginProfileId() + 1;
CFileItemList items;
CFileItemPtr item(new CFileItem());
item->SetLabel(g_localizeStrings.Get(37014)); // Last used profile
item->SetIconImage("DefaultUser.png");
items.Add(item);
for (unsigned int i = 0; i < profileManager.GetNumberOfProfiles(); i++)
{
const CProfile *profile = profileManager.GetProfile(i);
std::string locked = g_localizeStrings.Get(profile->getLockMode() > 0 ? 20166 : 20165);
CFileItemPtr item(new CFileItem(profile->getName()));
item->SetLabel2(locked); // lock setting
std::string thumb = profile->getThumb();
if (thumb.empty())
thumb = "DefaultUser.png";
item->SetIconImage(thumb);
items.Add(item);
}
dialog->SetHeading(CVariant{20093}); // Profile name
dialog->Reset();
dialog->SetUseDetails(true);
dialog->SetItems(items);
dialog->SetSelected(autoLoginProfileId);
dialog->Open();
if (dialog->IsButtonPressed() || dialog->GetSelectedItem() < 0)
return false; // user cancelled
iProfile = dialog->GetSelectedItem() - 1;
return true;
}
示例7: OnAction
bool CGUIDialogMusicOSD::OnAction(const CAction &action)
{
switch (action.GetID())
{
case ACTION_SHOW_OSD:
Close();
return true;
case ACTION_SET_RATING:
{
CGUIDialogSelect *dialog = g_windowManager.GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT);
if (dialog)
{
dialog->SetHeading(CVariant{ 38023 });
dialog->Add(g_localizeStrings.Get(38022));
for (int i = 1; i <= 10; i++)
dialog->Add(StringUtils::Format("%s: %i", g_localizeStrings.Get(563).c_str(), i));
auto track = g_application.CurrentFileItemPtr();
dialog->SetSelected(track->GetMusicInfoTag()->GetUserrating());
dialog->Open();
int userrating = dialog->GetSelectedItem();
if (userrating < 0) userrating = 0;
if (userrating > 10) userrating = 10;
if (userrating != track->GetMusicInfoTag()->GetUserrating())
{
track->GetMusicInfoTag()->SetUserrating(userrating);
// send a message to all windows to tell them to update the fileitem (eg playlistplayer, media windows)
CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_ITEM, 0, track);
g_windowManager.SendMessage(msg);
CMusicDatabase db;
if (db.Open())
{
db.SetSongUserrating(track->GetMusicInfoTag()->GetURL(), userrating);
db.Close();
}
}
}
return true;
}
default:
break;
}
return CGUIDialog::OnAction(action);
}
示例8: ShowPlaySelection
bool CGUIDialogSimpleMenu::ShowPlaySelection(CFileItem& item, const std::string& directory)
{
CFileItemList items;
if (!XFILE::CDirectory::GetDirectory(directory, items, XFILE::CDirectory::CHints(), true))
{
CLog::Log(LOGERROR, "CGUIWindowVideoBase::ShowPlaySelection - Failed to get play directory for %s", directory.c_str());
return true;
}
if (items.IsEmpty())
{
CLog::Log(LOGERROR, "CGUIWindowVideoBase::ShowPlaySelection - Failed to get any items %s", directory.c_str());
return true;
}
CGUIDialogSelect* dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
while (true)
{
dialog->Reset();
dialog->SetHeading(CVariant{25006}); // Select playback item
dialog->SetItems(items);
dialog->SetUseDetails(true);
dialog->Open();
CFileItemPtr item_new = dialog->GetSelectedItem();
if (!item_new || dialog->GetSelectedLabel() < 0)
{
CLog::Log(LOGDEBUG, "CGUIWindowVideoBase::ShowPlaySelection - User aborted %s", directory.c_str());
break;
}
if (item_new->m_bIsFolder == false)
{
std::string original_path = item.GetPath();
item.Reset();
item = *item_new;
item.SetProperty("original_listitem_url", original_path);
return true;
}
items.Clear();
if (!XFILE::CDirectory::GetDirectory(item_new->GetPath(), items, XFILE::CDirectory::CHints(), true) || items.IsEmpty())
{
CLog::Log(LOGERROR, "CGUIWindowVideoBase::ShowPlaySelection - Failed to get any items %s", item_new->GetPath().c_str());
break;
}
}
return false;
}
示例9: OnSettingAction
void CPeripherals::OnSettingAction(const CSetting *setting)
{
if (setting == NULL)
return;
const std::string &settingId = setting->GetId();
if (settingId == CSettings::SETTING_INPUT_PERIPHERALS)
{
CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
CFileItemList items;
GetDirectory("peripherals://all/", items);
int iPos = -1;
do
{
pDialog->Reset();
pDialog->SetHeading(CVariant{35000});
pDialog->SetUseDetails(true);
pDialog->SetItems(items);
pDialog->SetSelected(iPos);
pDialog->Open();
iPos = pDialog->IsConfirmed() ? pDialog->GetSelectedItem() : -1;
if (iPos >= 0)
{
CFileItemPtr pItem = items.Get(iPos);
CGUIDialogPeripheralSettings *pSettingsDialog = (CGUIDialogPeripheralSettings *)g_windowManager.GetWindow(WINDOW_DIALOG_PERIPHERAL_SETTINGS);
if (pItem && pSettingsDialog)
{
// pass peripheral item properties to settings dialog so skin authors
// can use it to show more detailed information about the device
pSettingsDialog->SetProperty("vendor", pItem->GetProperty("vendor"));
pSettingsDialog->SetProperty("product", pItem->GetProperty("product"));
pSettingsDialog->SetProperty("bus", pItem->GetProperty("bus"));
pSettingsDialog->SetProperty("location", pItem->GetProperty("location"));
pSettingsDialog->SetProperty("class", pItem->GetProperty("class"));
pSettingsDialog->SetProperty("version", pItem->GetProperty("version"));
// open settings dialog
pSettingsDialog->SetFileItem(pItem.get());
pSettingsDialog->Open();
}
}
} while (pDialog->IsConfirmed());
}
}
示例10: GetStereoModeByUserChoice
RENDER_STEREO_MODE CStereoscopicsManager::GetStereoModeByUserChoice(const std::string &heading)
{
RENDER_STEREO_MODE mode = GetStereoMode();
// if no stereo mode is set already, suggest mode of current video by preselecting it
if (mode == RENDER_STEREO_MODE_OFF)
mode = GetStereoModeOfPlayingVideo();
CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
pDlgSelect->Reset();
if (heading.empty())
pDlgSelect->SetHeading(CVariant{g_localizeStrings.Get(36528)});
else
pDlgSelect->SetHeading(CVariant{heading});
// prepare selectable stereo modes
std::vector<RENDER_STEREO_MODE> selectableModes;
for (int i = RENDER_STEREO_MODE_OFF; i < RENDER_STEREO_MODE_COUNT; i++)
{
RENDER_STEREO_MODE selectableMode = (RENDER_STEREO_MODE) i;
if (g_Windowing.SupportsStereo(selectableMode))
{
selectableModes.push_back(selectableMode);
std::string label = GetLabelForStereoMode((RENDER_STEREO_MODE) i);
pDlgSelect->Add( label );
if (mode == selectableMode)
pDlgSelect->SetSelected( label );
}
// inject AUTO pseudo mode after OFF
if (i == RENDER_STEREO_MODE_OFF)
{
selectableModes.push_back(RENDER_STEREO_MODE_AUTO);
pDlgSelect->Add(GetLabelForStereoMode(RENDER_STEREO_MODE_AUTO));
}
}
pDlgSelect->Open();
int iItem = pDlgSelect->GetSelectedItem();
if (iItem > -1 && pDlgSelect->IsConfirmed())
mode = (RENDER_STEREO_MODE) selectableModes[iItem];
else
mode = GetStereoMode();
return mode;
}
示例11: OnOperator
void CGUIDialogSmartPlaylistRule::OnOperator()
{
const auto labels = GetValidOperators(m_rule);
CGUIDialogSelect* dialog = g_windowManager.GetWindow<CGUIDialogSelect>();
dialog->Reset();
dialog->SetHeading(CVariant{ 16023 });
for (auto label : labels)
dialog->Add(std::get<0>(label));
dialog->SetSelected(CSmartPlaylistRule::GetLocalizedOperator(m_rule.m_operator));
dialog->Open();
int newSelected = dialog->GetSelectedItem();
// check if selection has changed
if (!dialog->IsConfirmed() || newSelected < 0)
return;
m_rule.m_operator = (CDatabaseQueryRule::SEARCH_OPERATOR)std::get<1>(labels[newSelected]);
UpdateButtons();
}
示例12: OnClick
bool CGUIControlListSetting::OnClick()
{
if (m_pButton == NULL)
return false;
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (dialog == NULL)
return false;
CFileItemList options;
if (!GetItems(m_pSetting, options) || options.Size() <= 1)
return false;
dialog->Reset();
dialog->SetHeading(g_localizeStrings.Get(m_pSetting->GetLabel()));
dialog->SetItems(&options);
dialog->SetMultiSelection(false);
dialog->DoModal();
if (!dialog->IsConfirmed())
return false;
const CFileItemPtr item = dialog->GetSelectedItem();
if (item == NULL || !item->HasProperty("value"))
return false;
CVariant value = item->GetProperty("value");
switch (m_pSetting->GetType())
{
case SettingTypeInteger:
return ((CSettingInt *)m_pSetting)->SetValue((int)value.asInteger());
case SettingTypeString:
return ((CSettingString *)m_pSetting)->SetValue(value.asString());
default:
break;
}
return true;
}
示例13: ChooseSortMethod
bool CGUIViewState::ChooseSortMethod()
{
CGUIDialogSelect *dialog = g_windowManager.GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT);
if (!dialog)
return false;
dialog->Reset();
dialog->SetHeading(CVariant{ 39010 }); // Label "Sort by"
for (auto &sortMethod : m_sortMethods)
dialog->Add(g_localizeStrings.Get(sortMethod.m_buttonLabel));
dialog->SetSelected(m_currentSortMethod);
dialog->Open();
int newSelected = dialog->GetSelectedItem();
// check if selection has changed
if (!dialog->IsConfirmed() || newSelected < 0 || newSelected == m_currentSortMethod)
return false;
m_currentSortMethod = newSelected;
SaveViewState();
return true;
}
示例14: OnSetUserrating
void CGUIDialogMusicInfo::OnSetUserrating()
{
CGUIDialogSelect *dialog = (CGUIDialogSelect *)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (dialog)
{
dialog->SetHeading(CVariant{ 38023 });
dialog->Add(g_localizeStrings.Get(38022));
for (int i = 1; i <= 10; i++)
dialog->Add(StringUtils::Format("%s: %i", g_localizeStrings.Get(563).c_str(), i));
dialog->SetSelected(m_albumItem->GetMusicInfoTag()->GetUserrating());
dialog->Open();
int iItem = dialog->GetSelectedItem();
if (iItem < 0)
return;
SetUserrating(iItem);
}
}
示例15: ChooseArtType
string CGUIDialogVideoInfo::ChooseArtType(const CFileItem &videoItem, map<string, string> ¤tArt)
{
// prompt for choice
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (!dialog || !videoItem.HasVideoInfoTag())
return "";
CFileItemList items;
dialog->SetHeading(13511);
dialog->Reset();
dialog->SetUseDetails(true);
CVideoDatabase db;
db.Open();
vector<string> artTypes = CVideoThumbLoader::GetArtTypes(videoItem.GetVideoInfoTag()->m_type);
// add in any stored art for this item that is non-empty.
db.GetArtForItem(videoItem.GetVideoInfoTag()->m_iDbId, videoItem.GetVideoInfoTag()->m_type, currentArt);
for (CGUIListItem::ArtMap::iterator i = currentArt.begin(); i != currentArt.end(); ++i)
{
if (!i->second.empty() && find(artTypes.begin(), artTypes.end(), i->first) == artTypes.end())
artTypes.push_back(i->first);
}
for (vector<string>::const_iterator i = artTypes.begin(); i != artTypes.end(); ++i)
{
string type = *i;
CFileItemPtr item(new CFileItem(type, "false"));
item->SetLabel(type);
if (videoItem.HasArt(type))
item->SetArt("thumb", videoItem.GetArt(type));
items.Add(item);
}
dialog->SetItems(&items);
dialog->DoModal();
return dialog->GetSelectedItem()->GetLabel();
}