MIRA
Public Slots | Signals | Public Member Functions | Protected Slots | Protected Attributes | List of all members
ServiceSelectorBox Class Reference

This is a combobox with a method to populate it with names of services providing one of a set of specified interfaces. More...

#include <fw/ServiceSelectorBox.h>

Inheritance diagram for ServiceSelectorBox:
Inheritance graph
[legend]

Public Slots

void setAutoHide (bool hide)
 By default, the widget automatically hides and stays hidden unless there is more than one service providing the requested interface (only visible when there is something to select - within a layout, the widget does not require any space while hidden). More...
 

Signals

void selected (std::string service)
 

Public Member Functions

 ServiceSelectorBox (QWidget *parent=nullptr)
 
void setInterface (const std::string &interface)
 Set an interface to find services for. More...
 
void setInterfaces (const std::vector< std::string > &interfaces)
 Set multiple interfaces to find (union of) services for. More...
 
void preferInitially (const std::string &service)
 Set a specific service to select automatically when it is discovered for the first time. More...
 
bool updateServices (bool localFirst=true)
 Query available services for the selected interface and update the combobox. More...
 
std::string getSelectedService ()
 Get the name of the selected service. More...
 

Protected Slots

void selected (int index)
 

Protected Attributes

std::vector< std::string > mInterfaces
 
std::vector< std::string > mServices
 
std::string mPreferredService
 
bool mAutoHide = true
 

Detailed Description

This is a combobox with a method to populate it with names of services providing one of a set of specified interfaces.

Frequently call updateServices() to keep the list of available services valid.

Constructor & Destructor Documentation

◆ ServiceSelectorBox()

ServiceSelectorBox ( QWidget *  parent = nullptr)

Member Function Documentation

◆ setInterface()

void setInterface ( const std::string &  interface)
inline

Set an interface to find services for.

◆ setInterfaces()

void setInterfaces ( const std::vector< std::string > &  interfaces)
inline

Set multiple interfaces to find (union of) services for.

◆ preferInitially()

void preferInitially ( const std::string &  service)
inline

Set a specific service to select automatically when it is discovered for the first time.

◆ updateServices()

bool updateServices ( bool  localFirst = true)

Query available services for the selected interface and update the combobox.

If the previously selected service is still available, it remains selected.

This should be called in the Qt thread (so it does not need locking against signal/slot selected()).

Parameters
[in]localFirstIf true, order all local services' entries before all remote services' entries
Returns
True if the selection needed to change (because the previous selection is not available anymore), false otherwise

◆ getSelectedService()

std::string getSelectedService ( )

Get the name of the selected service.

Not protected against updateServices(). If this is to be called in a different thread, the caller must handle locking.

◆ setAutoHide

void setAutoHide ( bool  hide)
slot

By default, the widget automatically hides and stays hidden unless there is more than one service providing the requested interface (only visible when there is something to select - within a layout, the widget does not require any space while hidden).

This method can be used to control that behaviour - disabling autohide will make the widget visible immediately and not change again.

◆ selected [1/2]

void selected ( std::string  service)
signal

◆ selected [2/2]

void selected ( int  index)
inlineprotectedslot

Member Data Documentation

◆ mInterfaces

std::vector<std::string> mInterfaces
protected

◆ mServices

std::vector<std::string> mServices
protected

◆ mPreferredService

std::string mPreferredService
protected

◆ mAutoHide

bool mAutoHide = true
protected

The documentation for this class was generated from the following file: