Warning, file /sdk/cervisia/globalignorelist.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) 2004 Christian Loose <christian.loose@kdemail.net>
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 "globalignorelist.h"
0020 using namespace Cervisia;
0021 
0022 #include <QTemporaryFile>
0023 #include <qdir.h>
0024 
0025 #include "cvsserviceinterface.h"
0026 #include "progressdialog.h"
0027 
0028 StringMatcher GlobalIgnoreList::m_stringMatcher;
0029 bool GlobalIgnoreList::m_isInitialized = false;
0030 
0031 GlobalIgnoreList::GlobalIgnoreList()
0032 {
0033     if (!m_isInitialized)
0034         setup();
0035 }
0036 
0037 bool GlobalIgnoreList::matches(const QFileInfo *fi) const
0038 {
0039     return m_stringMatcher.match(fi->fileName());
0040 }
0041 
0042 void GlobalIgnoreList::retrieveServerIgnoreList(OrgKdeCervisia5CvsserviceCvsserviceInterface *cvsService, const QString &repository)
0043 {
0044     QTemporaryFile tmpFile;
0045     tmpFile.open();
0046 
0047     // clear old ignore list
0048     m_stringMatcher.clear();
0049 
0050     // now set it up again
0051     setup();
0052 
0053     QDBusReply<QDBusObjectPath> ref = cvsService->downloadCvsIgnoreFile(repository, tmpFile.fileName());
0054 
0055     ProgressDialog dlg(0, "Edit", cvsService->service(), ref, "checkout", "CVS Edit");
0056     if (!dlg.execute())
0057         return;
0058 
0059     addEntriesFromFile(tmpFile.fileName());
0060 }
0061 
0062 void GlobalIgnoreList::addEntry(const QString &entry)
0063 {
0064     if (entry != QLatin1String("!")) {
0065         m_stringMatcher.add(entry);
0066     } else {
0067         m_stringMatcher.clear();
0068 
0069         // Bug #89215:
0070         // Make sure '.' and '..' are always in the ignore list, so
0071         // UpdateDirItem::maybeScanDir() doesn't loop endlessly.
0072         addEntriesFromString(QLatin1String(". .."));
0073     }
0074 }
0075 
0076 void GlobalIgnoreList::setup()
0077 {
0078     static const char ignorestr[] =
0079         ". .. core RCSLOG tags TAGS RCS SCCS .make.state\
0080 .nse_depinfo #* .#* cvslog.* ,* CVS CVS.adm .del-* *.a *.olb *.o *.obj\
0081 *.so *.Z *~ *.old *.elc *.ln *.bak *.BAK *.orig *.rej *.exe _$* *$";
0082 
0083     addEntriesFromString(QLatin1String(ignorestr));
0084     addEntriesFromString(QString::fromLocal8Bit(qgetenv("CVSIGNORE")));
0085     addEntriesFromFile(QDir::homePath() + "/.cvsignore");
0086 
0087     m_isInitialized = true;
0088 }