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
This commit is contained in:
morb_au 2006-07-14 02:22:29 +00:00
parent 8645462bf2
commit ca7064e1ca
3 changed files with 34 additions and 4 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -42,7 +42,13 @@ public:
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