From ca7064e1ca60b8253a88008985d0ce87dde44503 Mon Sep 17 00:00:00 2001 From: morb_au Date: Fri, 14 Jul 2006 02:22:29 +0000 Subject: [PATCH] The Map Legend now has two more columns for Overview and Editing status. If the layer is in overview or editing modes, the appropriate icon will appear in the layer's file entry (you may need to enable "Show file groups" in the right-click menu of the layer in the legend to see file entries). QGIS used to do this already before the move to Qt4 - however the new QIcon idiom only seems to allow for square icons, therefore it is easier to split the results out to several columns and give them their own QIcons. I can see room for improvement after this commit: 1. Overview and Editing icons can be also shown beside the top-level layer name, to avoid having to enable "Show file groups". 2. There also seems to be a "projection not valid" icon floating around, however this hasn't been addressed in this commit. Perhaps we need to do something for it too. 3. The column sizes have been hard-coded to arbitrary values. I have no problem if these get tweaked further. This commit addresses trac ticket #117. git-svn-id: http://svn.osgeo.org/qgis/trunk@5594 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/legend/qgslegend.cpp | 20 ++++++++++++++++---- src/legend/qgslegendlayerfile.cpp | 12 ++++++++++++ src/legend/qgslegendlayerfile.h | 6 ++++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/legend/qgslegend.cpp b/src/legend/qgslegend.cpp index 138950d37172..67c530e9817e 100755 --- a/src/legend/qgslegend.cpp +++ b/src/legend/qgslegend.cpp @@ -63,17 +63,29 @@ QgsLegend::QgsLegend(QgisApp* app, QWidget * parent, const char *name) this, SLOT(handleCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*))); - setSortingEnabled(false); + setSortingEnabled(false); setDragEnabled(false); setAutoScroll(true); QFont f("Arial", 10, QFont::Normal); setFont(f); setBackgroundColor(QColor(192, 192, 192)); - setColumnCount(1); - QStringList myList("Layers"); + + setColumnCount(3); // main column, overview indicator and editing indicator + + header()->setDefaultAlignment(Qt::AlignLeft); + + QStringList myList; + myList += tr("Layer Name"); + myList += tr("Overview"); + myList += tr("Editing"); + setHeaderLabels(myList); + header()->resizeSection(0, 100); + header()->resizeSection(1, 24); // Enough to fit an overview action icon + header()->resizeSection(2, 17); // Enough to fit an editing icon + //added by Tim to hide the header - header is unneccessary - header()->setHidden(1); + // header()->setHidden(1); // morb_au - experiment setRootIsDecorated(true); } diff --git a/src/legend/qgslegendlayerfile.cpp b/src/legend/qgslegendlayerfile.cpp index 13e624e38f06..4c5cd5f65dc6 100644 --- a/src/legend/qgslegendlayerfile.cpp +++ b/src/legend/qgslegendlayerfile.cpp @@ -96,6 +96,18 @@ void QgsLegendLayerFile::setLegendPixmap(const QPixmap& pix) setIcon(0, theIcon); } +void QgsLegendLayerFile::setOverviewPixmap(const QPixmap& pix) +{ + QIcon theIcon(pix); + setIcon(1, theIcon); +} + +void QgsLegendLayerFile::setEditingPixmap(const QPixmap& pix) +{ + QIcon theIcon(pix); + setIcon(2, theIcon); +} + void QgsLegendLayerFile::toggleCheckBox(bool state) { //todo diff --git a/src/legend/qgslegendlayerfile.h b/src/legend/qgslegendlayerfile.h index c7bb4ac56f46..c0c5ac7062c1 100644 --- a/src/legend/qgslegendlayerfile.h +++ b/src/legend/qgslegendlayerfile.h @@ -42,7 +42,13 @@ class QgsLegendLayerFile : public QgsLegendItem This method is used by QgsMapLayer to paint additional information (overview, editable, pyramides) to the pixmap*/ QPixmap getOriginalPixmap() const; + void setLegendPixmap(const QPixmap& pix); + + void setOverviewPixmap(const QPixmap& pix); + + void setEditingPixmap(const QPixmap& pix); + /**Sets mVisibilityCheckBox to on/off*/ void toggleCheckBox(bool state); /**Returns a label for a layer. Is static such that