本文整理汇总了C++中IServerSPtr::discoveryInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ IServerSPtr::discoveryInfo方法的具体用法?C++ IServerSPtr::discoveryInfo怎么用?C++ IServerSPtr::discoveryInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServerSPtr
的用法示例。
在下文中一共展示了IServerSPtr::discoveryInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
QVariant ExplorerTreeModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid()){
return QVariant();
}
IExplorerTreeItem* node = common::utils_qt::item<IExplorerTreeItem*>(index);
if (!node){
return QVariant();
}
int col = index.column();
IExplorerTreeItem::eType t = node->type();
if(role == Qt::ToolTipRole){
IServerSPtr serv = node->server();
if(t == IExplorerTreeItem::eServer && serv){
ServerDiscoveryInfoSPtr disc = serv->discoveryInfo();
if(disc){
QString dname = common::convertFromString<QString>(disc->name());
QString dtype = common::convertFromString<QString>(common::convertToString(disc->type()));
QString dhost = common::convertFromString<QString>(common::convertToString(disc->host()));
return QString("<b>Name:</b> %1<br/>"
"<b>Type:</b> %2<br/>"
"<b>Host:</b> %3<br/>").arg(dname).arg(dtype).arg(dhost);
}
}
else if(t == IExplorerTreeItem::eDatabase){
ExplorerDatabaseItem* db = dynamic_cast<ExplorerDatabaseItem*>(node);
if(db && db->isDefault()){
return QString("<b>Db size:</b> %1 keys<br/>").arg(db->size());
}
}
}
if(role == Qt::DecorationRole && col == ExplorerServerItem::eName ){
if(t == IExplorerTreeItem::eCluster){
return GuiFactory::instance().clusterIcon();
}
else if(t == IExplorerTreeItem::eServer){
return GuiFactory::instance().icon(node->server()->type());
}
else if(t == IExplorerTreeItem::eKey){
return GuiFactory::instance().keyIcon();
}
else if(t == IExplorerTreeItem::eDatabase){
return GuiFactory::instance().databaseIcon();
}
else{
NOTREACHED();
}
}
if (role == Qt::DisplayRole) {
if (col == IExplorerTreeItem::eName) {
if(t == IExplorerTreeItem::eKey){
return node->name();
}
else{
return QString("%1 (%2)").arg(node->name()).arg(node->childrenCount());
}
}
}
if(role == Qt::ForegroundRole){
if(t == IExplorerTreeItem::eDatabase){
ExplorerDatabaseItem* db = dynamic_cast<ExplorerDatabaseItem*>(node);
if(db && db->isDefault()){
return QVariant( QColor( Qt::red ) );
}
}
}
return QVariant();
}