File indexing completed on 2024-05-12 05:44:27
0001 /*************************************************************************** 0002 * Copyright (C) 2007 by Rajko Albrecht ral@alwins-world.de * 0003 * https://kde.org/applications/development/org.kde.kdesvn * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0019 ***************************************************************************/ 0020 0021 #include "logmodelhelper.h" 0022 #include "svnqt/log_entry.h" 0023 0024 #include <KLocalizedString> 0025 0026 #define TREE_PATH_ITEM_TYPE QTreeWidgetItem::UserType + 1 0027 0028 LogChangePathItem::LogChangePathItem(const svn::LogChangePathEntry &e, QTreeWidget *view) 0029 : QTreeWidgetItem(view, TREE_PATH_ITEM_TYPE) 0030 { 0031 init(e); 0032 } 0033 0034 void LogChangePathItem::init(const svn::LogChangePathEntry &e) 0035 { 0036 _action = e.action; 0037 setText(0, QString(QLatin1Char(_action))); 0038 _path = e.path; 0039 setText(1, e.path); 0040 _revision = e.copyFromRevision; 0041 _source = e.copyFromPath; 0042 if (e.copyFromRevision > -1) { 0043 setText(2, i18n("%1 at revision %2", e.copyFromPath, e.copyFromRevision)); 0044 } 0045 } 0046 0047 SvnLogModelNode::SvnLogModelNode(const svn::LogEntry &_entry) 0048 : _data(_entry) 0049 , _realName(QString()) 0050 , _date(svn::DateTime(_entry.date).toQDateTime()) 0051 { 0052 const QVector<QStringRef> sp = _entry.message.splitRef(QLatin1Char('\n')); 0053 if (sp.isEmpty()) { 0054 _shortMessage = _entry.message; 0055 } else { 0056 _shortMessage = sp.at(0).toString(); 0057 } 0058 } 0059 0060 const svn::LogChangePathEntries &SvnLogModelNode::changedPaths() const 0061 { 0062 return _data.changedPaths; 0063 } 0064 0065 bool SvnLogModelNode::copiedFrom(QString &_n, qlonglong &_rev) const 0066 { 0067 for (const svn::LogChangePathEntry &entry : _data.changedPaths) { 0068 if (entry.action == 'A' && !entry.copyFromPath.isEmpty() && isParent(entry.path, _realName)) { 0069 QString r = _realName.mid(entry.path.length()); 0070 _n = entry.copyFromPath; 0071 _n += r; 0072 _rev = entry.copyFromRevision; 0073 return true; 0074 } 0075 } 0076 return false; 0077 } 0078 0079 bool SvnLogModelNode::isParent(const QString &_par, const QString &tar) 0080 { 0081 if (_par == tar) { 0082 return true; 0083 } 0084 QString par = _par.endsWith(QLatin1Char('/')) ? _par : _par + QLatin1Char('/'); 0085 return tar.startsWith(par); 0086 } 0087 0088 void SvnLogModelNode::setChangedPaths(const svn::LogEntry &le) 0089 { 0090 _data.changedPaths = le.changedPaths; 0091 }