Exemplo 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());
}
Exemplo n.º 2
0
WebIpToLocationResolver::~WebIpToLocationResolver() {
    qCDebug(jtIpToLocation) << "Saving cache file";
    //save cache content into file
    QDir cacheDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
    QFile cacheFile(cacheDir.absoluteFilePath(CACHE_FILE_NAME));
    if(cacheFile.open(QFile::WriteOnly)) {
        QTextStream stream(&cacheFile);
        foreach (const QString& ip, locationCache.keys()) {
            Geo::Location location = locationCache[ip];
            stream << ip << ";" << location.getCountryName() << ";" << location.getCountryCode() << endl;
        }
        qCDebug(jtIpToLocation) << locationCache.size() << " items stored in cache file!";
    }
Exemplo n.º 3
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);
        }
    }