Great. This was in spam. I did something very similar and pushed it already.
Sorry. Need to go through my spam more often. /D On Sat, Aug 02, 2014 at 04:25:07PM -0700, Linus Torvalds wrote: > On Sat, Aug 2, 2014 at 4:13 PM, Dirk Hohndel <[email protected]> wrote: > > > > I usually think the same, but we have several people filing bugs that > > complain that you can enter silly pressure values (start at 230bar, end at > > 1200bar) > > > > There's no way we'll make everyone happy. > > How about showing them in red or something? We already do special > things for pressure: we set a different font when the pressure comes > from the samples, for example. > > Here's a patch that does exactly that. It works, but I wouldn't > suggest taking it as-is simply because of the whole hardcoding of > red-vs-white background. There's presumably some way to set it to > default values - somebody who knows more about Qt would know. > > I really think it's wrong to try to say "you can't do that". And part > of it really is that you might want to *fix* things, and then having > to fix it in "just the right order" (because the wrong order results > in higher end pressures than beginning pressures _momentarily_) is > actually really annoying. > > Making it visually clear that "you did something wrong" is a *much* > better option, I think. > > Linus > qt-ui/models.cpp | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp > index 6cf5c2bd24b3..c38b4b6bb35e 100644 > --- a/qt-ui/models.cpp > +++ b/qt-ui/models.cpp > @@ -95,6 +95,15 @@ QVariant CylindersModel::data(const QModelIndex &index, > int role) const > > cylinder_t *cyl = &displayed_dive.cylinder[index.row()]; > switch (role) { > + case Qt::BackgroundRole: { > + switch (index.column()) { > + case START: > + case END: > + if (cyl->start.mbar < cyl->end.mbar) > + return QColor("red"); > + } > + return QColor("white"); > + } > case Qt::FontRole: { > QFont font = defaultModelFont(); > switch (index.column()) { > _______________________________________________ > subsurface mailing list > [email protected] > http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface _______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
