Ejemplo n.º 1
0
void ChatPanel::setItemCountryDetails(QTreeWidgetItem *item, const geo::Location &location)
{
    auto icon = QIcon(QString(":/flags/flags/%1.png").arg(location.getCountryCode().toLower()));

    auto countryCollumn = 1;

    item->setIcon(countryCollumn, icon);
    item->setText(countryCollumn, location.getCountryName());
}
Ejemplo n.º 2
0
    foreach (const Login::UserInfo &user, userInfos) {
        if (!userIsBot(user)) {
            QLabel *label = new QLabel(ui->usersPanel);
            label->setTextFormat(Qt::RichText);
            Geo::Location userLocation = mainController->getGeoLocation(user.getIp());
            QString userString = user.getName();
            QString imageString = "";
            if (!userLocation.isUnknown()) {
                userString += " <i>(" + userLocation.getCountryName() + ")</i>";
                QString countryCode = userLocation.getCountryCode().toLower();
                imageString = "<img src=:/flags/flags/" + countryCode +".png> ";
                label->setToolTip("");
            } else {
                imageString = "<img src=:/images/warning.png> ";
                label->setToolTip(user.getName() + " location is not available at moment!");
            }
            label->setText(imageString + userString);

            ui->usersPanel->layout()->addWidget(label);
            ui->usersPanel->layout()->setAlignment(Qt::AlignTop);
        }
    }