1
/***************************************************************************
2
* Copyright (C) 2006 by Pino Toscano, toscano.pino@tiscali.it *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18
***************************************************************************/
23
#include "kalziumdataobject.h"
26
: m_isActive( false ), m_searchKind( Search::SearchAll )
30
QString Search::searchText() const
35
Search::SearchKind Search::searchKind() const
40
bool Search::isActive() const
45
const QList<Element*>& Search::foundElements() const
47
return m_foundElements;
50
bool Search::matches( Element* e ) const
52
return m_foundElements.contains( e );
55
bool Search::matches(int el) const
57
Element *element = KalziumDataObject::instance()->element( el );
58
return matches(element);
61
void Search::doSearch( const QString& text, SearchKind kind )
66
QList<Element*> newresults;
67
foreach( Element* e, KalziumDataObject::instance()->ElementList )
70
if ( !found && e->dataAsString( ChemicalDataObject::name ).contains( text, Qt::CaseInsensitive ) ) found = true;
71
if ( !found && e->dataAsString( ChemicalDataObject::symbol ).contains( text, Qt::CaseInsensitive ) ) found = true;
75
if ( newresults != m_foundElements )
77
m_foundElements = newresults;
82
void Search::resetSearch()
84
if ( !m_isActive ) return;
86
m_foundElements.clear();