# # # add_file "guitone/src/model/GetFileProxyModel.cpp" # content [67674025940249d69bad5d528ec60712175f615f] # # add_file "guitone/src/model/GetFileProxyModel.h" # content [23c0b8575dafbb56f6c2ef4fc575d6e9887d700a] # ============================================================ --- guitone/src/model/GetFileProxyModel.cpp 67674025940249d69bad5d528ec60712175f615f +++ guitone/src/model/GetFileProxyModel.cpp 67674025940249d69bad5d528ec60712175f615f @@ -0,0 +1,53 @@ +/*************************************************************************** +* Copyright (C) 2006 by Ingo Maindorfer * +* address@hidden * +* * +* 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 2 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, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ + +#include "GetFileProxyModel.h" +#include "GetFile.h" + +GetFileProxyModel::GetFileProxyModel(QObject *parent) +: QSortFilterProxyModel(parent), version(Both) +{ +} + +GetFileProxyModel::~GetFileProxyModel(void) {} + +bool GetFileProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const +{ + QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); + ContentLine * line = static_cast(index.internalPointer()); + + if (line->marker == ContentLine::Added && version == Left) + return false; + if (line->marker == ContentLine::Removed && 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; +} ============================================================ --- guitone/src/model/GetFileProxyModel.h 23c0b8575dafbb56f6c2ef4fc575d6e9887d700a +++ guitone/src/model/GetFileProxyModel.h 23c0b8575dafbb56f6c2ef4fc575d6e9887d700a @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (C) 2006 by Ingo Maindorfer * + * address@hidden * + * * + * 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 2 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef GETFILEPROXYMODEL_H +#define GETFILEPROXYMODEL_H + +#include + +class GetFileProxyModel : public QSortFilterProxyModel +{ + +public: + explicit GetFileProxyModel(QObject * parent); + ~GetFileProxyModel(void); + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + + enum FileVersion { Left, Right, Both }; + + void setFileVersion(FileVersion version); + FileVersion fileVersion() const; + +private: + FileVersion version; +}; + +#endif