Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
The Map Legend now has two more columns for Overview and Editing stat…
…us. 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
  • Loading branch information
morb_au committed Jul 14, 2006
1 parent 8645462 commit ca7064e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/legend/qgslegend.cpp
Expand Up @@ -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);

}
Expand Down
12 changes: 12 additions & 0 deletions src/legend/qgslegendlayerfile.cpp
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/legend/qgslegendlayerfile.h
Expand Up @@ -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
Expand Down

0 comments on commit ca7064e

Please sign in to comment.