# HG changeset patch # User Chris Cannam # Date 1189005435 0 # Node ID 5c59c433b358cdbc52d1976883e50a507bd5ae8a # Parent 226cb289bdf42db4883b95e7b8052e2ab3f29701 * Show colour swatch next to layer name in pane (if available) * Fix for incorrect layer name prefix handling (was making some layers appear to have the same model name in cases where the model names differed by the final character only) diff -r 226cb289bdf4 -r 5c59c433b358 layer/Layer.h --- a/layer/Layer.h Thu Aug 16 16:47:07 2007 +0000 +++ b/layer/Layer.h Wed Sep 05 15:17:15 2007 +0000 @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -95,6 +96,7 @@ } virtual QString getLayerPresentationName() const; + virtual QPixmap getLayerPresentationPixmap(QSize) const { return QPixmap(); } virtual int getVerticalScaleWidth(View *, QPainter &) const { return 0; } virtual void paintVerticalScale(View *, QPainter &, QRect) const { } diff -r 226cb289bdf4 -r 5c59c433b358 layer/SingleColourLayer.cpp --- a/layer/SingleColourLayer.cpp Thu Aug 16 16:47:07 2007 +0000 +++ b/layer/SingleColourLayer.cpp Wed Sep 05 15:17:15 2007 +0000 @@ -31,6 +31,12 @@ setDefaultColourFor(0); } +QPixmap +SingleColourLayer::getLayerPresentationPixmap(QSize size) const +{ + return ColourDatabase::getInstance()->getExamplePixmap(m_colour, size); +} + bool SingleColourLayer::hasLightBackground() const { diff -r 226cb289bdf4 -r 5c59c433b358 layer/SingleColourLayer.h --- a/layer/SingleColourLayer.h Thu Aug 16 16:47:07 2007 +0000 +++ b/layer/SingleColourLayer.h Wed Sep 05 15:17:15 2007 +0000 @@ -33,6 +33,8 @@ return ColourDistinguishes; } + virtual QPixmap getLayerPresentationPixmap(QSize size) const; + virtual PropertyList getProperties() const; virtual QString getPropertyLabel(const PropertyName &) const; virtual PropertyType getPropertyType(const PropertyName &) const; diff -r 226cb289bdf4 -r 5c59c433b358 view/Pane.cpp --- a/view/Pane.cpp Thu Aug 16 16:47:07 2007 +0000 +++ b/view/Pane.cpp Wed Sep 05 15:17:15 2007 +0000 @@ -716,8 +716,13 @@ } QStringList texts; + std::vector pixmaps; for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { texts.push_back((*i)->getLayerPresentationName()); +// std::cerr << "Pane " << this << ": Layer presentation name for " << *i << ": " +// << texts[texts.size()-1].toStdString() << std::endl; + pixmaps.push_back((*i)->getLayerPresentationPixmap + (QSize(fontAscent, fontAscent))); } int maxTextWidth = width() / 3; @@ -734,6 +739,8 @@ if (r.x() + r.width() >= llx) { for (size_t i = 0; i < texts.size(); ++i) { + +// std::cerr << "Pane "<< this << ": text " << i << ": " << texts[i].toStdString() << std::endl; if (i + 1 == texts.size()) { paint.setPen(getForeground()); @@ -742,6 +749,12 @@ drawVisibleText(paint, llx, lly - fontHeight + fontAscent, texts[i], OutlinedText); + + if (!pixmaps[i].isNull()) { + paint.drawPixmap(llx - fontAscent - 3, + lly - fontHeight + (fontHeight-fontAscent)/2, + pixmaps[i]); + } lly -= fontHeight; }