/guitone-1.0rc5/src/model/GetFileProxyModel.cpp
C++ | 50 lines | 26 code | 7 blank | 17 comment | 14 complexity | bd2d245aecbddc6e3d8819c6ed258016 MD5 | raw file
Possible License(s): GPL-3.0
- /***************************************************************************
- * Copyright (C) 2006 by Ingo Maindorfer *
- * ingo@liquidcooling.de *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation, either version 3 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program. If not, see <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
- #include "GetFileProxyModel.h"
- #include "GetFile.h"
- GetFileProxyModel::GetFileProxyModel(QObject * parent)
- : QSortFilterProxyModel(parent), version(Both)
- {}
- GetFileProxyModel::~GetFileProxyModel() {}
- bool GetFileProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const
- {
- QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
- ContentLine * line = static_cast<ContentLine *>(index.internalPointer());
- if ((line->state == DiffLine::Added || line->state == DiffLine::AddedMissingNewline) && version == Left)
- return false;
- if ((line->state == DiffLine::Removed || line->state == DiffLine::RemovedMissingNewline) && version == Right)
- return false;
- return true;
- }
- void GetFileProxyModel::setFileVersion(FileVersion v)
- {
- if (version == v) return;
- version = v;
- clear();
- }
- GetFileProxyModel::FileVersion GetFileProxyModel::fileVersion() const
- {
- return version;
- }