Skip to content

Commit

Permalink
add tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Jun 26, 2024
1 parent 0d1e092 commit bbcd4e6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
3 changes: 2 additions & 1 deletion agrolib/criteria1DWidget/tabIrrigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,15 @@ void TabIrrigation::tooltipLAI(QPointF point, bool isShow)
}


// TODO Giada
void TabIrrigation::tooltipEvapTransp(QPointF point, bool isShow)
{
if (isShow)
{
QDate xDate(firstYear, 1, 1);
int doy = int(round(point.x()));
xDate = xDate.addDays(doy);
m_tooltip->setText(xDate.toString("yyyy-MM-dd") + "\n" + "evap/transp." + QString::number(point.y(),'f', 2));
m_tooltip->setText(xDate.toString("yyyy-MM-dd") + "\n" + "evap/transp. " + QString::number(point.y(),'f', 2)+ "mm");
m_tooltip->setAnchor(point);
m_tooltip->setZValue(11);
m_tooltip->updateGeometry();
Expand Down
19 changes: 15 additions & 4 deletions agrolib/criteriaModel/criteria1DMeteo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,6 @@ bool fillDailyTempPrecCriteria1D(QSqlDatabase* dbMeteo, QString table, Crit3DMet
}

QDate date;
QDate previousDate(validYear-1, 12, 31);
QDate lastDate(validYear, 12, 31);
float tmin = NODATA;
float tmax = NODATA;
float tavg = NODATA;
Expand All @@ -728,6 +726,9 @@ bool fillDailyTempPrecCriteria1D(QSqlDatabase* dbMeteo, QString table, Crit3DMet
const float tmax_min = -40;
const float tmax_max = 60;

QList<QString> fieldList = getFieldsUpperCase(query);
bool existWatertable = fieldList.contains("WATERTABLE");

do
{
getValue(query.value("date"), &date);
Expand All @@ -736,8 +737,18 @@ bool fillDailyTempPrecCriteria1D(QSqlDatabase* dbMeteo, QString table, Crit3DMet
getValue(query.value("prec"), &prec);

// Watertable depth [m]
getValue(query.value("watertable"), &waterTable);
if (waterTable < 0.f) waterTable = NODATA;
if (existWatertable)
{
getValue(query.value("watertable"), &waterTable);
if (waterTable < 0.f)
{
waterTable = NODATA;
}
}
else
{
waterTable = NODATA;
}

if (tmin < tmin_min || tmin > tmin_max)
{
Expand Down
19 changes: 17 additions & 2 deletions agrolib/soilWidget/soilTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Crit3DSoilTable::Crit3DSoilTable(tableType type) : type(type)
this->resizeColumnsToContents();
this->setSelectionMode(QAbstractItemView::SingleSelection);
this->setShowGrid(true);
//this->setStyleSheet("QTableView {selection-background-color: green;}");
this->setStyleSheet("QTableView::item:selected { color:black; border: 3px solid black}");

if (type == dbTable)
Expand All @@ -45,14 +44,30 @@ Crit3DSoilTable::Crit3DSoilTable(tableType type) : type(type)
{
this->setEditTriggers(QAbstractItemView::NoEditTriggers);
}

if (type == dbTable)
{
QTableWidgetItem *currentHeaderItem = this->horizontalHeaderItem(2);
if (currentHeaderItem)
currentHeaderItem->setToolTip("Percentage of sand (from 2.0 to 0.05 mm)");

//currentHeaderItem = this->horizontalHeaderItem(3);
//..
// TODO
}
else if (type == modelTable)
{
// TODO
}
}


void Crit3DSoilTable::mouseMoveEvent(QMouseEvent *event)
{
QPoint pos = event->pos();
QTableWidgetItem *item = this->itemAt(pos);
if(!item) return;
if(! item)
return;

if (item->background().color() == Qt::red)
{
Expand Down
6 changes: 3 additions & 3 deletions agrolib/soilWidget/soilWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Crit3DSoilWidget::Crit3DSoilWidget()
geotechnicsClassList.resize(19);

this->setWindowTitle(QStringLiteral("CRITERIA - Soil Editor"));
this->resize(1240, 700);
this->resize(1400, 700);

// layout
QVBoxLayout *mainLayout = new QVBoxLayout();
Expand Down Expand Up @@ -286,14 +286,14 @@ void Crit3DSoilWidget::setDbSoil(QSqlDatabase dbOpened, QString soilCode)
// load default VG parameters
if (! loadVanGenuchtenParameters(dbSoil, textureClassList, errorStr))
{
QMessageBox::critical(nullptr, "Error", "loadVanGenuchtenParameters: " + errorStr);
QMessageBox::critical(nullptr, "Error", "loadVanGenuchtenParameters\n" + errorStr);
return;
}

// load default geotechnics parameters (not mandatory)
if (! loadGeotechnicsParameters(dbSoil, geotechnicsClassList, errorStr))
{
QMessageBox::warning(nullptr, "Warning", "loadGeotechnicsParameters: " + errorStr);
QMessageBox::warning(nullptr, "Warning", "loadGeotechnicsParameters\n" + errorStr);
}

// read soil list
Expand Down

0 comments on commit bbcd4e6

Please sign in to comment.