File indexing completed on 2024-05-12 17:16:11
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2009 by Rajko Albrecht * 0003 * ral@alwins-world.de * 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 "itemdisplay.h" 0022 #include "svnitem.h" 0023 #include "settings/kdesvnsettings.h" 0024 #include "svnqt/status.h" 0025 0026 ItemDisplay::ItemDisplay() 0027 : m_isWorkingCopy(false), m_isNetworked(false) 0028 { 0029 } 0030 0031 bool ItemDisplay::isWorkingCopy()const 0032 { 0033 return m_isWorkingCopy; 0034 } 0035 0036 QString ItemDisplay::baseUri()const 0037 { 0038 return m_baseUri; 0039 } 0040 0041 QUrl ItemDisplay::baseUriAsUrl()const 0042 { 0043 return m_isWorkingCopy ? QUrl::fromLocalFile(m_baseUri) : QUrl(m_baseUri); 0044 } 0045 0046 /*! 0047 \fn ItemDisplay::isNetworked()const 0048 */ 0049 bool ItemDisplay::isNetworked()const 0050 { 0051 return m_isNetworked; 0052 } 0053 0054 void ItemDisplay::setWorkingCopy(bool how) 0055 { 0056 m_isWorkingCopy = how; 0057 } 0058 0059 void ItemDisplay::setNetworked(bool how) 0060 { 0061 m_isNetworked = how; 0062 } 0063 0064 void ItemDisplay::setBaseUri(const QString &uri) 0065 { 0066 m_baseUri = uri; 0067 /* otherwise subversion lib asserts! */ 0068 while (m_baseUri.endsWith(QLatin1Char('/'))) { 0069 m_baseUri.chop(1); 0070 } 0071 } 0072 0073 QString ItemDisplay::lastError()const 0074 { 0075 return m_LastException; 0076 } 0077 0078 /*! 0079 \fn ItemDisplay::filterOut(const SvnItem*) 0080 */ 0081 bool ItemDisplay::filterOut(const SvnItem *item) 0082 { 0083 if (!item->stat()->validReposStatus()) { 0084 if ((item->isIgnored() && !Kdesvnsettings::display_ignored_files()) || 0085 (Kdesvnsettings::hide_unchanged_files() && item->isRealVersioned() && !item->isModified() && !item->isChildModified()) || 0086 (!Kdesvnsettings::display_unknown_files() && !item->stat()->isVersioned()) 0087 ) { 0088 return true; 0089 } 0090 } 0091 return false; 0092 } 0093 0094 /*! 0095 \fn ItemDisplay::relativePath(const SvnItem*item) 0096 */ 0097 QString ItemDisplay::relativePath(const SvnItem *item) const 0098 { 0099 if (!isWorkingCopy() || !item->fullName().startsWith(baseUri())) { 0100 return item->fullName(); 0101 } 0102 QString name = item->fullName(); 0103 if (name == baseUri()) { 0104 name = QLatin1Char('.'); 0105 } else { 0106 name = name.right(name.length() - baseUri().length() - 1); 0107 } 0108 if (name.isEmpty()) { 0109 name = QLatin1Char('.'); 0110 } 0111 return name; 0112 }