mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
refs #452, removed some classes which will be replaced by new classes
* CAircraftMappings -> will be replace by CAircraftModel * CAircraftIcaoData aircraft ICAO data -> aircraft/airline ICAO code and livery * CAircraft class no longer to be used, but CSimulatedAircraft * removed corresponding GUI model classes / filters
This commit is contained in:
committed by
Mathew Sutcliffe
parent
51e8a6a208
commit
874f29098b
@@ -1,68 +0,0 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "listmodelfilter.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
template<class ContainerType>
|
||||
bool IModelFilter<ContainerType>::stringMatchesFilterExpression(const QString &value, const QString &filter, Qt::CaseSensitivity cs) const
|
||||
{
|
||||
QString v = value.trimmed();
|
||||
QString f = filter.trimmed();
|
||||
|
||||
if (v.isEmpty() && f.isEmpty()) { return true; }
|
||||
if (v.isEmpty()) { return false; }
|
||||
|
||||
// no wildcard, just string matching
|
||||
if (!filter.contains('*'))
|
||||
{
|
||||
return (v.indexOf(f, 0, cs) == 0) &&
|
||||
(v.length() == f.length());
|
||||
}
|
||||
|
||||
const QString filterNoWildcard = stripWildcard(f);
|
||||
|
||||
// included?
|
||||
if (f.startsWith('*') && f.endsWith('*'))
|
||||
{
|
||||
return v.contains(filterNoWildcard, cs);
|
||||
}
|
||||
|
||||
// starting with
|
||||
if (f.startsWith('*'))
|
||||
{
|
||||
return v.endsWith(filterNoWildcard, cs);
|
||||
}
|
||||
|
||||
if (f.endsWith('*'))
|
||||
{
|
||||
return v.startsWith(filterNoWildcard, cs);
|
||||
}
|
||||
|
||||
// should never happen
|
||||
Q_ASSERT(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class ContainerType>
|
||||
QString IModelFilter<ContainerType>::stripWildcard(const QString &value) const
|
||||
{
|
||||
QString sw(value);
|
||||
return sw.remove('*');
|
||||
}
|
||||
|
||||
// Forward instantiations
|
||||
template class IModelFilter<BlackMisc::Simulation::CAircraftModelList>;
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
@@ -1,48 +0,0 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_LISTMODELFILTER_H
|
||||
#define BLACKGUI_LISTMODELFILTER_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include <QString>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
//! Model filter interface
|
||||
template<class ContainerType> class IModelFilter
|
||||
{
|
||||
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~IModelFilter() {}
|
||||
|
||||
//! Used container data
|
||||
virtual ContainerType filter(const ContainerType &container) const = 0;
|
||||
|
||||
//! Anything to do?
|
||||
virtual bool isValid() const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
//! Standard string search supporting wildcard at begin and end: "*xyz", "abc*"
|
||||
bool stringMatchesFilterExpression(const QString &value, const QString &filter, Qt::CaseSensitivity cs = Qt::CaseInsensitive) const;
|
||||
|
||||
//! Remove the * wildcards
|
||||
QString stripWildcard(const QString &value) const;
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user