Spreadsheet: Added alias as tooltip. Made background of cell light yellow if an alias is defined for it. Can be overridden by setting a background color.

This commit is contained in:
Eivind Kvedalen 2015-09-30 01:13:07 +02:00 committed by wmayer
parent e334ac3aed
commit 9fe3b0146a
3 changed files with 22 additions and 4 deletions

View File

@ -85,7 +85,7 @@ Cell::Cell(const CellAddress &_address, PropertySheet *_owner)
, alignment(ALIGNMENT_HIMPLIED | ALIGNMENT_LEFT | ALIGNMENT_VIMPLIED | ALIGNMENT_VCENTER)
, style()
, foregroundColor(0, 0, 0, 1)
, backgroundColor(1, 1, 1, 1)
, backgroundColor(1, 1, 1, 0)
, displayUnit()
, computedUnit()
, rowSpan(1)
@ -339,7 +339,7 @@ void Cell::setBackground(const App::Color &color)
PropertySheet::Signaller signaller(*owner);
backgroundColor = color;
setUsed(BACKGROUND_COLOR_SET, backgroundColor != App::Color(1, 1, 1, 1));
setUsed(BACKGROUND_COLOR_SET, backgroundColor != App::Color(1, 1, 1, 0));
}
}

View File

@ -28,6 +28,7 @@
# include <QMessageBox>
#endif
#include <Gui/Application.h>
#include "SheetModel.h"
#include <Mod/Spreadsheet/App/SpreadsheetExpression.h>
#include <Mod/Spreadsheet/App/Utils.h>
@ -46,6 +47,9 @@ SheetModel::SheetModel(Sheet *_sheet, QObject *parent)
, sheet(_sheet)
{
cellUpdatedConnection = sheet->cellUpdated.connect(bind(&SheetModel::cellUpdated, this, _1));
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Spreadsheet");
aliasBgColor = QColor(Base::Tools::fromStdString(hGrp->GetASCII("AliasedCellBackgroundColor", "#feff9e")));
}
SheetModel::~SheetModel()
@ -167,6 +171,13 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const
}
return QVariant(v);
}
#else
if (role == Qt::ToolTipRole) {
std::string alias;
if (cell->getAlias(alias))
return QVariant(Base::Tools::fromStdString(alias));
return QVariant();
}
#endif
if (cell->hasException()) {
@ -214,8 +225,14 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const
if (role == Qt::BackgroundRole) {
if (cell->getBackground(color))
return QVariant::fromValue(QColor(255.0 * color.r, 255.0 * color.g, 255.0 * color.b, 255.0 * color.a));
else
return QVariant();
else {
std::string alias;
if (cell->getAlias(alias)) {
return QVariant::fromValue(aliasBgColor);
}
else
return QVariant();
}
}
int qtAlignment = 0;

View File

@ -53,6 +53,7 @@ private:
boost::BOOST_SIGNALS_NAMESPACE::scoped_connection cellUpdatedConnection;
Spreadsheet::Sheet * sheet;
QColor aliasBgColor;
};
}