QString KFileItem::getStatusBarInfo() const { QString text = d->m_strText; const QString comment = mimeComment(); if ( d->m_bLink ) { text += ' '; if ( comment.isEmpty() ) text += i18n ( "(Symbolic Link to %1)", linkDest() ); else text += i18n("(%1, Link to %2)", comment, linkDest()); } else if ( targetUrl() != url() ) { text += i18n ( " (Points to %1)", targetUrl().pathOrUrl()); } else if ( S_ISREG( d->m_fileMode ) ) { text += QString(" (%1, %2)").arg( comment, KIO::convertSize( size() ) ); } else { text += QString(" (%1)").arg( comment ); } return text; }
QString KFileItem::getStatusBarInfo() { QString text = m_strText; if ( m_bLink ) { QString comment = determineMimeType()->comment( m_url, m_bIsLocalURL ); QString tmp; if ( comment.isEmpty() ) tmp = i18n ( "Symbolic Link" ); else tmp = i18n("%1 (Link)").arg(comment); text += "->"; text += linkDest(); text += " "; text += tmp; } else if ( S_ISREG( m_fileMode ) ) { bool hasSize; KIO::filesize_t sizeValue = size(hasSize); if(hasSize) text += QString(" (%1) ").arg( KIO::convertSize( sizeValue ) ); text += mimeComment(); } else if ( S_ISDIR ( m_fileMode ) ) { text += "/ "; text += mimeComment(); } else { text += " "; text += mimeComment(); } text.replace('\n', " "); // replace any newlines with a space, so the statusbar doesn't get a two-line string which messes the display up, Alex return text; }
QString KFileItem::getToolTipText(int maxcount) const { // we can return QString() if no tool tip should be shown QString tip; KFileMetaInfo info = metaInfo(); // the font tags are a workaround for the fact that the tool tip gets // screwed if the color scheme uses white as default text color const QString colorName = QApplication::palette().color(QPalette::ToolTipText).name(); const QString start = "<tr><td align=\"right\"><nobr><font color=\"" + colorName + "\"><b>"; const QString mid = " </b></font></nobr></td><td><nobr><font color=\"" + colorName + "\">"; const char* end = "</font></nobr></td></tr>"; tip = "<table cellspacing=0 cellpadding=0>"; tip += start + i18n("Name:") + mid + text() + end; tip += start + i18n("Type:") + mid; QString type = Qt::escape(mimeComment()); if ( d->m_bLink ) { tip += i18n("Link to %1 (%2)", linkDest(), type) + end; } else tip += type + end; if ( !S_ISDIR ( d->m_fileMode ) ) tip += start + i18n("Size:") + mid + QString("%1").arg(KIO::convertSize(size())) + end; tip += start + i18n("Modified:") + mid + timeString( KFileItem::ModificationTime ) + end #ifndef Q_WS_WIN //TODO: show win32-specific permissions +start + i18n("Owner:") + mid + user() + " - " + group() + end + start + i18n("Permissions:") + mid + permissionsString() + end #endif ; if (info.isValid()) { const QStringList keys = info.preferredKeys(); // now the rest QStringList::ConstIterator it = keys.begin(); for (int count = 0; count<maxcount && it!=keys.end() ; ++it) { if ( count == 0 ) { tip += "<tr><td colspan=2><center><s> </s></center></td></tr>"; } KFileMetaInfoItem item = info.item( *it ); if ( item.isValid() ) { QString s = item.value().toString(); if ( !s.isEmpty() ) { count++; tip += start + Qt::escape( item.name() ) + ':' + mid + Qt::escape( s ) + end; } } } } tip += "</table>"; //kDebug() << "making this the tool tip rich text:\n"; //kDebug() << tip; return tip; }
QString KFileItem::getToolTipText(int maxcount) { // we can return QString::null if no tool tip should be shown QString tip; KFileMetaInfo info = metaInfo(); // the font tags are a workaround for the fact that the tool tip gets // screwed if the color scheme uses white as default text color const char* start = "<tr><td><nobr><font color=\"black\">"; const char* mid = "</font></nobr></td><td><nobr><font color=\"black\">"; const char* end = "</font></nobr></td></tr>"; tip = "<table cellspacing=0 cellpadding=0>"; tip += start + i18n("Name:") + mid + text() + end; tip += start + i18n("Type:") + mid; QString type = QStyleSheet::escape(mimeComment()); if ( m_bLink ) { tip += i18n("Link to %1 (%2)").arg(linkDest(), type) + end; } else tip += type + end; if ( !S_ISDIR ( m_fileMode ) ) { bool hasSize; KIO::filesize_t sizeValue = size(hasSize); if(hasSize) tip += start + i18n("Size:") + mid + KIO::convertSizeWithBytes(sizeValue) + end; } QString timeStr = timeString( KIO::UDS_MODIFICATION_TIME); if(!timeStr.isEmpty()) tip += start + i18n("Modified:") + mid + timeStr + end; #ifndef Q_WS_WIN //TODO: show win32-specific permissions QString userStr = user(); QString groupStr = group(); if(!userStr.isEmpty() || !groupStr.isEmpty()) tip += start + i18n("Owner:") + mid + userStr + " - " + groupStr + end + start + i18n("Permissions:") + mid + parsePermissions(m_permissions) + end; #endif if (info.isValid() && !info.isEmpty() ) { tip += "<tr><td colspan=2><center><s> </s></center></td></tr>"; QStringList keys = info.preferredKeys(); // now the rest QStringList::Iterator it = keys.begin(); for (int count = 0; count<maxcount && it!=keys.end() ; ++it) { KFileMetaInfoItem item = info.item( *it ); if ( item.isValid() ) { QString s = item.string(); if ( ( item.attributes() & KFileMimeTypeInfo::SqueezeText ) && s.length() > 50) { s.truncate(47); s.append("..."); } if ( !s.isEmpty() ) { count++; tip += start + QStyleSheet::escape( item.translatedKey() ) + ":" + mid + QStyleSheet::escape( s ) + end; } } } } tip += "</table>"; //kdDebug() << "making this the tool tip rich text:\n"; //kdDebug() << tip << endl; return tip; }