QVariant PlaylistModel::Implementation::data(const QModelIndex& index, int role) const
{
    if(!index.isValid())
    {
        return QVariant();
    }
    if(index.row() < 0 || index.row() >= m_tracks.count())
    {
        return QVariant();
    }
    const Jerboa::TrackData& track = m_tracks.at(index.row());
    if(role == Qt::DisplayRole)
    {
        switch(index.column())
        {
        case 0:
            return track.title();
        case 1:
            return track.artist();
        case 2:
            return track.album();
        default:
            return QVariant();
        }
    }
    else if(role == Qt::ToolTipRole)
    {
        return QString(
                   "<b>%1</b><br/><i>%2 &mdash; %3</i><br/>"
                   "<font size='90%'>%4</font>"
               ).arg(
                   HTML_ESCAPE(track.title())
               ).arg(
                   HTML_ESCAPE(track.artist())
               ).arg(
                   HTML_ESCAPE(track.album())
               ).arg(
                   HTML_ESCAPE(
                       track.url().scheme() == "file"
                       ? QDir::toNativeSeparators(track.url().toLocalFile())
                       : track.url().toString()
                   )
               );
    }

    if(index.row() == m_playlist->currentTrack())
    {
        if(role == Qt::FontRole)
        {
            QFont font;
            font.setBold(true);
            font.setItalic(true);
            return font;
        }
        else if(role == Qt::BackgroundRole)
        {
            return QApplication::palette().alternateBase();
        }
    }
    return QVariant();
}
void EditProfilesDialog::onRemoveProfileClicked()
{
	QListWidgetItem *listItem = ui.lstProfiles->selectedItems().value(0);
	if (listItem)
	{
		QString profile = listItem->text();
		if (QMessageBox::question(this,tr("Remove Profile"),tr("Are you sure you want to delete profile '<b>%1</b>'?").arg(HTML_ESCAPE(profile)),QMessageBox::Yes|QMessageBox::No) == QMessageBox::Yes)
		{
			if (!FOptionsManager->removeProfile(profile))
			{
				REPORT_ERROR("Failed to remove profile");
				QMessageBox::warning(this,tr("Error"),tr("Failed to remove profile"));
			}
		}
	}
}
void ClientInfoDialog::updateText()
{
	QString itemMask = "%1 %2<br>";
	QString html = QString("<b>%1</b> (%2)<br><br>").arg(HTML_ESCAPE(FContactName)).arg(HTML_ESCAPE(FContactJid.uFull()));
	//Software Info
	if ((FInfoTypes & IClientInfo::SoftwareVersion)>0)
	{
		html += "<b>" + tr("Software Version") + "</b><br>";
		if (FClientInfo->hasSoftwareInfo(FContactJid))
		{
			html += itemMask.arg(tr("Name:")).arg(HTML_ESCAPE(FClientInfo->softwareName(FContactJid)));
			if (!FClientInfo->softwareVersion(FContactJid).isEmpty())
				html += itemMask.arg(tr("Version:")).arg(HTML_ESCAPE(FClientInfo->softwareVersion(FContactJid)));
			if (!FClientInfo->softwareOs(FContactJid).isEmpty())
				html += itemMask.arg(tr("OS:")).arg(HTML_ESCAPE(FClientInfo->softwareOs(FContactJid)));
		}
		else if (FClientInfo->softwareStatus(FContactJid) == IClientInfo::SoftwareError)
		{
			html += itemMask.arg(tr("Error:")).arg(FClientInfo->softwareName(FContactJid));
		}
		else
		{
			html += tr("Waiting response...") + "<br>";
		}
		html += "<br>";
	}

	//Last Activity
	if ((FInfoTypes & IClientInfo::LastActivity)>0)
	{
		if (!FContactJid.hasNode())
			html += "<b>" + tr("Service Uptime") + "</b>";
		else if (!FContactJid.hasResource())
			html += "<b>" + tr("Last Activity") + "</b>";
		else
			html += "<b>" + tr("Idle Time") + "</b>";
		html += "<br>";

		if (FClientInfo->hasLastActivity(FContactJid))
		{
			if (!FContactJid.hasNode())
			{
				html += itemMask.arg(tr("Uptime:")).arg(secsToString(FClientInfo->lastActivityTime(FContactJid).secsTo(QDateTime::currentDateTime())));
			}
			else if (!FContactJid.hasResource())
			{
				html += itemMask.arg(tr("Inactive:")).arg(secsToString(FClientInfo->lastActivityTime(FContactJid).secsTo(QDateTime::currentDateTime())));
				if (!FClientInfo->lastActivityText(FContactJid).isEmpty())
					html += itemMask.arg(tr("Status:")).arg(HTML_ESCAPE(FClientInfo->lastActivityText(FContactJid)));
			}
			else
			{
				html += itemMask.arg(tr("Idle:")).arg(secsToString(FClientInfo->lastActivityTime(FContactJid).secsTo(QDateTime::currentDateTime())));
			}
		}
		else if (!FClientInfo->lastActivityText(FContactJid).isEmpty())
		{
			html += itemMask.arg(tr("Error:")).arg(FClientInfo->lastActivityText(FContactJid));
		}
		else
		{
			html += tr("Waiting response...") + "<br>";
		}
		html += "<br>";
	}

	//Entity Time
	if ((FInfoTypes & IClientInfo::EntityTime)>0)
	{
		html += "<b>" + tr("Entity Time") + "</b><br>";
		if (FClientInfo->hasEntityTime(FContactJid))
		{
			html += itemMask.arg(tr("Time:")).arg(FClientInfo->entityTime(FContactJid).time().toString());
			html += itemMask.arg(tr("Delta:")).arg(secsToString(FClientInfo->entityTimeDelta(FContactJid)));
			html += itemMask.arg(tr("Ping, msec:")).arg(FClientInfo->entityTimePing(FContactJid));
		}
		else if (FClientInfo->entityTimePing(FContactJid) < -1)
		{
			html += tr("Waiting response...") + "<br>";
		}
		else
		{
			html += tr("Not available") + "<br>";
		}
		html += "<br>";
	}

	ui.tedText->setHtml(html);
	this->adjustSize();
}