Skip to content

Commit eaf92a1

Browse files
author
morb_au
committedJul 14, 2006
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/qgis@5594 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed
 

‎src/legend/qgslegend.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,29 @@ QgsLegend::QgsLegend(QgisApp* app, QWidget * parent, const char *name)
6363
this, SLOT(handleCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
6464

6565

66-
setSortingEnabled(false);
66+
setSortingEnabled(false);
6767
setDragEnabled(false);
6868
setAutoScroll(true);
6969
QFont f("Arial", 10, QFont::Normal);
7070
setFont(f);
7171
setBackgroundColor(QColor(192, 192, 192));
72-
setColumnCount(1);
73-
QStringList myList("Layers");
72+
73+
setColumnCount(3); // main column, overview indicator and editing indicator
74+
75+
header()->setDefaultAlignment(Qt::AlignLeft);
76+
77+
QStringList myList;
78+
myList += tr("Layer Name");
79+
myList += tr("Overview");
80+
myList += tr("Editing");
81+
7482
setHeaderLabels(myList);
83+
header()->resizeSection(0, 100);
84+
header()->resizeSection(1, 24); // Enough to fit an overview action icon
85+
header()->resizeSection(2, 17); // Enough to fit an editing icon
86+
7587
//added by Tim to hide the header - header is unneccessary
76-
header()->setHidden(1);
88+
// header()->setHidden(1); // morb_au - experiment
7789
setRootIsDecorated(true);
7890

7991
}

‎src/legend/qgslegendlayerfile.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,18 @@ void QgsLegendLayerFile::setLegendPixmap(const QPixmap& pix)
9696
setIcon(0, theIcon);
9797
}
9898

99+
void QgsLegendLayerFile::setOverviewPixmap(const QPixmap& pix)
100+
{
101+
QIcon theIcon(pix);
102+
setIcon(1, theIcon);
103+
}
104+
105+
void QgsLegendLayerFile::setEditingPixmap(const QPixmap& pix)
106+
{
107+
QIcon theIcon(pix);
108+
setIcon(2, theIcon);
109+
}
110+
99111
void QgsLegendLayerFile::toggleCheckBox(bool state)
100112
{
101113
//todo

‎src/legend/qgslegendlayerfile.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ class QgsLegendLayerFile : public QgsLegendItem
4242
This method is used by QgsMapLayer to paint additional
4343
information (overview, editable, pyramides) to the pixmap*/
4444
QPixmap getOriginalPixmap() const;
45+
4546
void setLegendPixmap(const QPixmap& pix);
47+
48+
void setOverviewPixmap(const QPixmap& pix);
49+
50+
void setEditingPixmap(const QPixmap& pix);
51+
4652
/**Sets mVisibilityCheckBox to on/off*/
4753
void toggleCheckBox(bool state);
4854
/**Returns a label for a layer. Is static such that

0 commit comments

Comments
 (0)
Please sign in to comment.