Warning, file /sdk/cervisia/loginfo.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Copyright (c) 2003-2008 André Wöbbeking <Woebbeking@kde.org> 0003 * 0004 * This program is free software; you can redistribute it and/or modify 0005 * it under the terms of the GNU General Public License as published by 0006 * the Free Software Foundation; either version 2 of the License, or 0007 * (at your option) any later version. 0008 * 0009 * This program is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 * GNU General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU General Public License 0015 * along with this program; if not, write to the Free Software 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #include "loginfo.h" 0020 0021 #include <QLocale> 0022 #include <qtextdocument.h> 0023 0024 #include <KLocalizedString> 0025 0026 namespace Cervisia 0027 { 0028 0029 TagInfo::TagInfo(const QString &name, Type type) 0030 : m_name(name) 0031 , m_type(type) 0032 { 0033 } 0034 0035 QString TagInfo::toString(bool prefixWithType) const 0036 { 0037 QString text; 0038 if (prefixWithType) { 0039 text += typeToString() + QLatin1String(": "); 0040 } 0041 text += m_name; 0042 0043 return text; 0044 } 0045 0046 QString TagInfo::typeToString() const 0047 { 0048 QString text; 0049 switch (m_type) { 0050 case Branch: 0051 text = i18n("Branchpoint"); 0052 break; 0053 case OnBranch: 0054 text = i18n("On Branch"); 0055 break; 0056 case Tag: 0057 text = i18n("Tag"); 0058 break; 0059 } 0060 0061 return text; 0062 } 0063 0064 QString LogInfo::createToolTipText(bool showTime) const 0065 { 0066 QString text(QLatin1String("<nobr><b>")); 0067 text += m_revision.toHtmlEscaped(); 0068 text += QLatin1String("</b> "); 0069 text += m_author.toHtmlEscaped(); 0070 text += QLatin1String(" <b>"); 0071 text += dateTimeToString(showTime).toHtmlEscaped(); 0072 text += QLatin1String("</b></nobr>"); 0073 0074 if (!m_comment.isEmpty()) { 0075 text += QLatin1String("<pre>"); 0076 text += m_comment.toHtmlEscaped(); 0077 text += QLatin1String("</pre>"); 0078 } 0079 0080 if (!m_tags.isEmpty()) { 0081 text += QLatin1String("<i>"); 0082 for (TTagInfoSeq::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { 0083 if (it != m_tags.begin() || m_comment.isEmpty()) 0084 text += QLatin1String("<br>"); 0085 text += (*it).toString().toHtmlEscaped(); 0086 } 0087 text += QLatin1String("</i>"); 0088 } 0089 0090 return text; 0091 } 0092 0093 QString LogInfo::dateTimeToString(bool showTime, bool shortFormat) const 0094 { 0095 QLocale::FormatType format = shortFormat ? QLocale::ShortFormat : QLocale::LongFormat; 0096 if (showTime) 0097 return QLocale().toString(m_dateTime, format); 0098 else 0099 return QLocale().toString(m_dateTime.date(), format); 0100 } 0101 0102 QString LogInfo::tagsToString(unsigned int types, unsigned int prefixWithType, const QString &separator) const 0103 { 0104 QString text; 0105 for (TTagInfoSeq::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { 0106 const TagInfo &tagInfo(*it); 0107 0108 if (tagInfo.m_type & types) { 0109 if (!text.isEmpty()) { 0110 text += separator; 0111 } 0112 0113 text += tagInfo.toString(tagInfo.m_type & prefixWithType); 0114 } 0115 } 0116 0117 return text; 0118 } 0119 0120 } // namespace Cervisia