~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/core/qgssearchstring.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 *   (at your option) any later version.                                   *
16
16
 *                                                                         *
17
17
 ***************************************************************************/
18
 
 /* $Id: qgssearchstring.cpp 4610 2006-01-08 02:11:54Z timlinux $ */
 
18
/* $Id$ */
19
19
 
20
20
#include "qgssearchstring.h"
21
21
#include "qgssearchtreenode.h"
22
22
 
23
23
 
24
24
//! global function from parser.y that interfaces parser
25
 
extern QgsSearchTreeNode* parseSearchString(const QString& str, QString& parserErrorMsg);
26
 
 
 
25
extern QgsSearchTreeNode* parseSearchString( const QString& str, QString& parserErrorMsg );
 
26
 
27
27
 
28
28
QgsSearchString::QgsSearchString()
29
29
{
31
31
}
32
32
 
33
33
 
34
 
QgsSearchString::QgsSearchString(const QgsSearchString& str)
 
34
QgsSearchString::QgsSearchString( const QgsSearchString& str )
35
35
{
36
 
  if (str.mTree)
37
 
    mTree = new QgsSearchTreeNode(*str.mTree);
 
36
  if ( str.mTree )
 
37
    mTree = new QgsSearchTreeNode( *str.mTree );
38
38
  else
39
39
    mTree = NULL;
40
40
  mString = str.mString;
41
41
}
42
42
 
43
 
QgsSearchString& QgsSearchString::operator=(const QgsSearchString& str)
 
43
QgsSearchString& QgsSearchString::operator=( const QgsSearchString & str )
44
44
{
45
 
  setEmpty();
 
45
  clear();
46
46
 
47
 
  if (str.mTree)
48
 
    mTree = new QgsSearchTreeNode(*str.mTree);
 
47
  if ( str.mTree )
 
48
    mTree = new QgsSearchTreeNode( *str.mTree );
49
49
  else
50
50
    mTree = NULL;
51
51
  mString = str.mString;
52
 
  
 
52
 
53
53
  return *this;
54
54
}
55
55
 
60
60
}
61
61
 
62
62
 
63
 
bool QgsSearchString::setString(QString str)
 
63
bool QgsSearchString::setString( QString str )
64
64
{
65
65
  // empty string
66
 
  if (str == "")
 
66
  if ( str == "" )
67
67
  {
68
 
    setEmpty();
 
68
    clear();
69
69
    return true;
70
70
  }
71
 
  
 
71
 
72
72
  // calls external C function that does all parsing
73
 
  QgsSearchTreeNode* tree = parseSearchString(str, mParserErrorMsg);
74
 
  if (tree)
 
73
  QgsSearchTreeNode* tree = parseSearchString( str, mParserErrorMsg );
 
74
  if ( tree )
75
75
  {
76
76
    delete mTree;
77
77
    mTree = tree;
83
83
}
84
84
 
85
85
 
86
 
bool QgsSearchString::setTree(QgsSearchTreeNode* tree)
 
86
bool QgsSearchString::setTree( QgsSearchTreeNode* tree )
87
87
{
88
 
  if (tree == NULL)
 
88
  if ( tree == NULL )
89
89
  {
90
 
    setEmpty();
 
90
    clear();
91
91
  }
92
92
  else
93
93
  {
94
94
    delete mTree;
95
 
    mTree = new QgsSearchTreeNode(*tree);
 
95
    mTree = new QgsSearchTreeNode( *tree );
96
96
    mString = mTree->makeSearchString();
97
97
  }
98
98
  return true;
100
100
 
101
101
bool QgsSearchString::isEmpty()
102
102
{
103
 
  return (mTree == NULL);
 
103
  return ( mTree == NULL );
104
104
}
105
105
 
106
 
void QgsSearchString::setEmpty()
 
106
void QgsSearchString::clear()
107
107
{
108
108
  delete mTree;
109
109
  mTree = NULL;