Skip to content

Commit a4c6da9

Browse files
committed
update selection mode
1 parent a431a35 commit a4c6da9

File tree

6 files changed

+41
-43
lines changed

6 files changed

+41
-43
lines changed

dbMeteoPoints/dbMeteoPointsHandler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,7 @@ bool Crit3DMeteoPointsDbHandler::setJointStations(const QString& idPoint, const
21502150
}
21512151

21522152

2153-
bool Crit3DMeteoPointsDbHandler::getPointListWithCriteria(QList<QString> &selectedPointsList, const QString &condition)
2153+
bool Crit3DMeteoPointsDbHandler::getPointListWithCriteria(QList<QString> &pointsList, const QString &condition)
21542154
{
21552155
QSqlQuery qry(_db);
21562156
QString queryString;
@@ -2165,7 +2165,7 @@ bool Crit3DMeteoPointsDbHandler::getPointListWithCriteria(QList<QString> &select
21652165

21662166
while (qry.next()) {
21672167
QString idPoint = qry.value("id_point").toString();;
2168-
selectedPointsList.append(idPoint);
2168+
pointsList.append(idPoint);
21692169
}
21702170

21712171
return true;

dbMeteoPoints/dbMeteoPointsHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
QList<QString> getStateList();
121121
QList<QString> getDatasetList();
122122
bool setActiveStateIfCondition(bool activeState, const QString &condition);
123-
bool getPointListWithCriteria(QList<QString> &selectedPointsList, const QString &condition);
123+
bool getPointListWithCriteria(QList<QString> &pointsList, const QString &condition);
124124
bool setOrogCode(QString id, int orogCode);
125125
QList<QString> getJointStations(const QString& idPoint);
126126
bool setJointStations(const QString& idPoint, const QList<QString> &stationsList);

project/dialogSelectionMeteoPoint.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "dialogSelectionMeteoPoint.h"
22

3-
DialogSelectionMeteoPoint::DialogSelectionMeteoPoint(bool isActive, bool isSelect, Crit3DMeteoPointsDbHandler *meteoPointsDbHandler)
4-
:isActive(isActive), isSelect(isSelect)
3+
DialogSelectionMeteoPoint::DialogSelectionMeteoPoint(QString type, bool isSelect, Crit3DMeteoPointsDbHandler *meteoPointsDbHandler)
4+
:_type(type), _isSelect(isSelect)
55
{
66
municipalityList = meteoPointsDbHandler->getMunicipalityList();
77
provinceList = meteoPointsDbHandler->getProvinceList();
@@ -42,21 +42,21 @@ DialogSelectionMeteoPoint::DialogSelectionMeteoPoint(bool isActive, bool isSelec
4242

4343
QDialogButtonBox buttonBox;
4444
QPushButton activeButton;
45-
if (isActive)
45+
if (_type.toUpper() == "ACTIVE")
4646
{
47-
activeButton.setText("Active");
47+
if (_isSelect)
48+
activeButton.setText("Activate");
49+
else
50+
activeButton.setText("Deactivate");
4851
}
49-
else
52+
else if (_type.toUpper() == "SELECT")
5053
{
51-
if (isSelect)
52-
{
54+
if (_isSelect)
5355
activeButton.setText("Select");
54-
}
5556
else
56-
{
57-
activeButton.setText("Deactive");
58-
}
57+
activeButton.setText("Deselect");
5958
}
59+
6060
activeButton.setCheckable(true);
6161
activeButton.setAutoDefault(false);
6262

project/dialogSelectionMeteoPoint.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class DialogSelectionMeteoPoint : public QDialog
1010
Q_OBJECT
1111

1212
private:
13-
bool isActive;
14-
bool isSelect;
13+
QString _type;
14+
bool _isSelect;
1515
QList<QString> municipalityList;
1616
QList<QString> provinceList;
1717
QList<QString> regionList;
@@ -26,7 +26,7 @@ class DialogSelectionMeteoPoint : public QDialog
2626

2727

2828
public:
29-
DialogSelectionMeteoPoint(bool isActive, bool isSelect, Crit3DMeteoPointsDbHandler* meteoPointsDbHandler);
29+
DialogSelectionMeteoPoint(QString type, bool isSelect, Crit3DMeteoPointsDbHandler* meteoPointsDbHandler);
3030
QString getSelection();
3131
QString getOperation();
3232
QString getItem();

project/project.cpp

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4839,8 +4839,7 @@ bool Project::setActiveStateWithCriteria(bool isActive)
48394839
return false;
48404840
}
48414841

4842-
bool isSelect = false;
4843-
DialogSelectionMeteoPoint dialogPointSelection(isActive, isSelect, meteoPointsDbHandler);
4842+
DialogSelectionMeteoPoint dialogPointSelection("Active", isActive, meteoPointsDbHandler);
48444843
if (dialogPointSelection.result() != QDialog::Accepted)
48454844
return false;
48464845

@@ -6238,10 +6237,10 @@ void Project::getMeteoPointsCurrentValues(std::vector<float> &validValues)
62386237
}
62396238

62406239

6241-
bool Project::setSelectedStatePointList(QString fileName)
6240+
bool Project::setSelectedStatePointList(QString fileName, bool isSelect, bool isShowVariable)
62426241
{
62436242
QList<QString> pointList = readListSingleColumn(fileName, errorString);
6244-
if (! selectPointList(pointList))
6243+
if (! selectPointList(pointList, isSelect, isShowVariable))
62456244
{
62466245
logWarning("No points to select.");
62476246
return false;
@@ -6251,47 +6250,46 @@ bool Project::setSelectedStatePointList(QString fileName)
62516250
}
62526251

62536252

6254-
bool Project::selectPointList(const QList<QString> &pointList)
6253+
bool Project::selectPointList(const QList<QString> &pointList, bool isSelect, bool isShowVariable)
62556254
{
62566255
if (pointList.size() == 0)
62576256
return false;
62586257

6259-
int nrValidPoints = 0;
6258+
int nrPoints = 0;
62606259
for (int i = 0; i < meteoPoints.size(); i++)
62616260
{
62626261
if (pointList.contains(QString::fromStdString(meteoPoints[i].id)))
62636262
{
6264-
meteoPoints[i].selected = true;
6265-
nrValidPoints++;
6263+
if (! isShowVariable || ! isEqual(meteoPoints[i].currentValue, NODATA))
6264+
{
6265+
meteoPoints[i].selected = isSelect;
6266+
++nrPoints;
6267+
}
62666268
}
62676269
}
62686270

6269-
return (nrValidPoints > 0);
6271+
return (nrPoints > 0);
62706272
}
62716273

62726274

6273-
bool Project::setSelectedStateWithCriteria()
6275+
bool Project::setSelectedStateWithCriteria(bool isSelect, bool isShowVariable)
62746276
{
62756277
if (! meteoPointsLoaded)
62766278
{
62776279
logError(ERROR_STR_MISSING_DB);
62786280
return false;
62796281
}
62806282

6281-
bool isActive = false;
6282-
bool isSelect = true;
6283-
DialogSelectionMeteoPoint dialogPointSelection(isActive, isSelect, meteoPointsDbHandler);
6283+
DialogSelectionMeteoPoint dialogPointSelection("Select", isSelect, meteoPointsDbHandler);
62846284
if (dialogPointSelection.result() != QDialog::Accepted)
6285-
{
62866285
return false;
6287-
}
62886286

62896287
QString selection = dialogPointSelection.getSelection();
62906288
QString operation = dialogPointSelection.getOperation();
62916289
QString item = dialogPointSelection.getItem();
62926290

62936291
QString condition;
6294-
QList<QString> selectedPointsList;
6292+
QList<QString> pointsList;
62956293

62966294
if (operation == "Like")
62976295
{
@@ -6304,7 +6302,7 @@ bool Project::setSelectedStateWithCriteria()
63046302

63056303
if (selection != "DEM distance [m]")
63066304
{
6307-
if (! meteoPointsDbHandler->getPointListWithCriteria(selectedPointsList, condition))
6305+
if (! meteoPointsDbHandler->getPointListWithCriteria(pointsList, condition))
63086306
{
63096307
logError(meteoPointsDbHandler->getErrorString());
63106308
return false;
@@ -6331,41 +6329,41 @@ bool Project::setSelectedStateWithCriteria()
63316329
{
63326330
if (isEqual(distance, item.toFloat()))
63336331
{
6334-
selectedPointsList.append(QString::fromStdString(meteoPoints[i].id));
6332+
pointsList.append(QString::fromStdString(meteoPoints[i].id));
63356333
}
63366334
}
63376335
else if (operation == "!=")
63386336
{
63396337
if (! isEqual(distance, item.toFloat()))
63406338
{
6341-
selectedPointsList.append(QString::fromStdString(meteoPoints[i].id));
6339+
pointsList.append(QString::fromStdString(meteoPoints[i].id));
63426340
}
63436341
}
63446342
else if (operation == ">")
63456343
{
63466344
if (distance > item.toFloat())
63476345
{
6348-
selectedPointsList.append(QString::fromStdString(meteoPoints[i].id));
6346+
pointsList.append(QString::fromStdString(meteoPoints[i].id));
63496347
}
63506348
}
63516349
else if (operation == "<")
63526350
{
63536351
if (distance < item.toFloat())
63546352
{
6355-
selectedPointsList.append(QString::fromStdString(meteoPoints[i].id));
6353+
pointsList.append(QString::fromStdString(meteoPoints[i].id));
63566354
}
63576355
}
63586356
}
63596357
closeProgressBar();
63606358
}
63616359

6362-
if (selectedPointsList.isEmpty())
6360+
if (pointsList.isEmpty())
63636361
{
63646362
logWarning("No point matches your requirements.");
63656363
return false;
63666364
}
63676365

6368-
if (! selectPointList(selectedPointsList))
6366+
if (! selectPointList(pointsList, isSelect, isShowVariable))
63696367
{
63706368
logWarning("No points to select");
63716369
return false;

project/project.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,10 @@
333333
void clearSelectedOutputPoints();
334334
bool setActiveStateSelectedPoints(bool isActive);
335335
bool setActiveStatePointList(QString fileName, bool isActive);
336-
bool setSelectedStatePointList(QString fileName);
337-
bool selectPointList(const QList<QString> &pointList);
336+
bool setSelectedStatePointList(QString fileName, bool isSelect, bool isShowVariable);
337+
bool selectPointList(const QList<QString> &pointList, bool isSelect, bool isShowVariable);
338338
bool setActiveStateWithCriteria(bool isActive);
339-
bool setSelectedStateWithCriteria();
339+
bool setSelectedStateWithCriteria(bool isSelect, bool isShowVariable);
340340
bool setMarkedFromPointList(QString fileName, bool isAdd);
341341
bool setMarkedPointsOfMacroArea(int areaNumber, bool viewNotActivePoints);
342342
bool deleteMeteoPoints(const QList<QString>& pointList);

0 commit comments

Comments
 (0)