-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
District search criteria #2
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ | |
*.la | ||
*.a | ||
/oxygen/ | ||
/build/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/**************************************************************************** | ||
** | ||
** | ||
** Authors : don-vip | ||
** Project : Housing | ||
** FileName : AbstractDistrictQuery.cpp | ||
** Date : 2015-09-05T23:26:14 | ||
** License : GPL3 | ||
** Home Page : https://github.com/don-vip/housing | ||
** Comment : An application to search for rent / purchase of appartment / house. | ||
** | ||
** 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 package 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 "AbstractDistrictQuery.h" | ||
|
||
AbstractDistrictQuery::AbstractDistrictQuery( QObject* parent ) | ||
: QObject( parent ) | ||
{ | ||
} | ||
|
||
AbstractDistrictQuery::~AbstractDistrictQuery() | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/**************************************************************************** | ||
** | ||
** | ||
** Authors : don-vip | ||
** Project : Housing | ||
** FileName : AbstractDistrictQuery.h | ||
** Date : 2015-09-05T23:26:14 | ||
** License : GPL3 | ||
** Home Page : https://github.com/don-vip/housing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Url |
||
** Comment : An application to search for rent / purchase of appartment / house. | ||
** | ||
** 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 package 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/>. | ||
** | ||
****************************************************************************/ | ||
#ifndef ABSTRACTDISTRICTQUERY_H | ||
#define ABSTRACTDISTRICTQUERY_H | ||
|
||
#include <QObject> | ||
|
||
#include "District.h" | ||
|
||
class AbstractDistrictQuery : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
AbstractDistrictQuery( QObject* parent = 0 ); | ||
virtual ~AbstractDistrictQuery(); | ||
|
||
virtual void setMinimumSearchLength( int length ) = 0; | ||
virtual int minimumSearchLength() const = 0; | ||
|
||
public slots: | ||
virtual void search( const QString& text ) = 0; | ||
|
||
signals: | ||
void districtsReceived( const District::List& districts ); | ||
void error( const QString& error ); | ||
}; | ||
|
||
#endif // ABSTRACTDISTRICTQUERY_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
/**************************************************************************** | ||
** | ||
** | ||
** Authors : don-vip | ||
** Project : Housing | ||
** FileName : District.cpp | ||
** Date : 2015-09-05T23:44:14 | ||
** License : GPL3 | ||
** Home Page : https://github.com/don-vip/housing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Url |
||
** Comment : An application to search for rent / purchase of appartment / house. | ||
** | ||
** 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 package 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 "District.h" | ||
|
||
#include <QSharedData> | ||
#include <QString> | ||
|
||
class DistrictData : public QSharedData { | ||
public: | ||
QString label; | ||
QString value; | ||
QString valuesup; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the meaning of valueSup ? |
||
QString code; | ||
|
||
public: | ||
DistrictData() { | ||
} | ||
|
||
DistrictData( const DistrictData& other ) | ||
: QSharedData( other ), | ||
label( other.label ), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align members to the Q of QSharedData |
||
value( other.value ), | ||
valuesup( other.valuesup ), | ||
code( other.code ) | ||
{ | ||
} | ||
|
||
~DistrictData() { | ||
} | ||
}; | ||
|
||
District::District( const QVariant& variant ) | ||
: d( new DistrictData ) | ||
{ | ||
if ( !variant.isNull() ) { | ||
fromVariant( variant ); | ||
} | ||
} | ||
|
||
District::District( const District& other ) | ||
: d( other.d ) | ||
{ | ||
} | ||
|
||
District::District( const QString& label, const QString& value, const QString& code, const QString& valuesup ) | ||
: d( new DistrictData ) | ||
{ | ||
d->label = label; | ||
d->value = value; | ||
d->valuesup = valuesup; | ||
d->code = code; | ||
} | ||
|
||
District::~District() | ||
{ | ||
} | ||
|
||
District& District::operator=( const District& other ) | ||
{ | ||
if ( this != &other ) { | ||
d = other.d; | ||
} | ||
|
||
return *this; | ||
} | ||
|
||
bool District::operator==( const District& other ) const | ||
{ | ||
return d->value == other.d->value && d->valuesup == other.d->valuesup; | ||
} | ||
|
||
bool District::operator<( const District& other ) const | ||
{ | ||
return d->label.compare( other.d->label ) < 0; | ||
} | ||
|
||
bool District::isNull() const | ||
{ | ||
return d->label.isEmpty() && | ||
d->value.isEmpty() && | ||
d->valuesup.isEmpty() && | ||
d->code.isEmpty() | ||
; | ||
} | ||
|
||
QString District::label() const | ||
{ | ||
return d->label; | ||
} | ||
|
||
QString District::value() const | ||
{ | ||
return d->value; | ||
} | ||
|
||
QString District::valuesup() const | ||
{ | ||
return d->valuesup; | ||
} | ||
|
||
QString District::code() const | ||
{ | ||
return d->code; | ||
} | ||
|
||
QVariant District::toVariant() const | ||
{ | ||
QVariantMap map; | ||
map[ "label" ] = d->label; | ||
map[ "value" ] = d->value; | ||
map[ "valuesup" ] = d->valuesup; | ||
map[ "code" ] = d->code; | ||
return map; | ||
} | ||
|
||
void District::fromVariant( const QVariant& variant ) | ||
{ | ||
if ( !variant.type() == QVariant::Map ) { | ||
return; | ||
} | ||
|
||
const QVariantMap map = variant.toMap(); | ||
d->label = map.value( "label" ).toString(); | ||
d->value = map.value( "value" ).toString(); | ||
d->valuesup = map.value( "valuesup" ).toString(); | ||
d->code = map.value( "code" ).toString(); | ||
} | ||
|
||
QVariant District::listToVariant( const District::List& districts ) | ||
{ | ||
QVariantList list; | ||
|
||
foreach ( const District& district, districts ) { | ||
list << district.toVariant(); | ||
} | ||
|
||
return list; | ||
} | ||
|
||
District::List District::variantToList( const QVariant& variant ) | ||
{ | ||
District::List list; | ||
|
||
if ( variant.type() == QVariant::List ) { | ||
const QVariantList districts = variant.toList(); | ||
|
||
foreach ( const QVariant& district, districts ) { | ||
list << District( district ); | ||
} | ||
} | ||
|
||
return list; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/**************************************************************************** | ||
** | ||
** | ||
** Authors : don-vip | ||
** Project : Housing | ||
** FileName : District.h | ||
** Date : 2015-09-05T23:44:14 | ||
** License : GPL3 | ||
** Home Page : https://github.com/don-vip/housing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Url |
||
** Comment : An application to search for rent / purchase of appartment / house. | ||
** | ||
** 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 package 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/>. | ||
** | ||
****************************************************************************/ | ||
#ifndef DISTRICT_H | ||
#define DISTRICT_H | ||
|
||
#include <QSharedDataPointer> | ||
#include <QList> | ||
#include <QVariant> | ||
|
||
class DistrictData; | ||
|
||
class District | ||
{ | ||
public: | ||
typedef QList<District> List; | ||
|
||
District( const QVariant& variant = QVariant() ); | ||
District( const District& other ); | ||
District( const QString& label, const QString& value, const QString& code, const QString& valuesup ); | ||
virtual ~District(); | ||
|
||
virtual District& operator=( const District& other ); | ||
virtual bool operator==( const District& other ) const; | ||
virtual bool operator<( const District& other ) const; | ||
|
||
bool isNull() const; | ||
QString label() const; | ||
QString value() const; | ||
QString valuesup() const; | ||
QString code() const; | ||
|
||
QVariant toVariant() const; | ||
void fromVariant( const QVariant& variant ); | ||
|
||
static QVariant listToVariant( const District::List& districts ); | ||
static District::List variantToList( const QVariant& variant ); | ||
|
||
private: | ||
QSharedDataPointer<DistrictData> d; | ||
}; | ||
|
||
#endif // DISTRICT_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update to this repo url please.