Skip to content

Commit 7f9b89a

Browse files
author
g_j_m
committed
Use icon overlays for the editable and overview status of a layer
instead of separate icons in separate columns. Still only applies to the actual layer file entry in the legend, but removes the need for the extra columns. However, I'm hopeless at icon drawing... These changes are a variation on the suggestions in ticket #191. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5616 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent f850939 commit 7f9b89a

File tree

5 files changed

+29
-51
lines changed

5 files changed

+29
-51
lines changed
846 Bytes
Loading

src/gui/qgsmaplayer.cpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -452,29 +452,8 @@ void QgsMapLayer::updateItemPixmap()
452452
{
453453
if (mLegendLayerFile)
454454
{
455-
QPixmap originalPix=mLegendLayerFile->getOriginalPixmap();
456-
457-
if(mShowInOverview)
458-
{
459-
//add overview glasses to the pixmap
460-
mLegendLayerFile->setOverviewPixmap(mInOverviewPixmap);
461-
}
462-
else
463-
{
464-
mLegendLayerFile->setOverviewPixmap( QPixmap() );
465-
}
466-
467-
if(isEditable())
468-
{
469-
//add editing icon to the pixmap
470-
mLegendLayerFile->setEditingPixmap(mEditablePixmap);
471-
}
472-
else
473-
{
474-
mLegendLayerFile->setEditingPixmap( QPixmap() );
475-
}
476-
477-
mLegendLayerFile->setLegendPixmap(originalPix);
455+
mLegendLayerFile->setIconAppearance(mShowInOverview,
456+
isEditable());
478457
}
479458
}
480459

@@ -490,7 +469,7 @@ void QgsMapLayer::invalidTransformInput()
490469
QPainter p(&pix);
491470
p.drawPixmap(60,0,mProjectionErrorPixmap);
492471
}
493-
mLegendLayerFile->setLegendPixmap(pix);
472+
mLegendLayerFile->setLegendPixmap(pix);
494473
}
495474
}
496475

src/legend/qgslegend.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,8 @@ QgsLegend::QgsLegend(QgisApp* app, QWidget * parent, const char *name)
6969
setFont(f);
7070
setBackgroundColor(QColor(192, 192, 192));
7171

72-
setColumnCount(3); // main column, overview indicator and editing indicator
73-
74-
header()->setDefaultAlignment(Qt::AlignLeft);
75-
76-
QStringList myList;
77-
myList += tr("Layer Name");
78-
myList += tr("Overview");
79-
myList += tr("Editing");
80-
81-
setHeaderLabels(myList);
82-
header()->resizeSection(0, 100);
83-
header()->resizeSection(1, 24); // Enough to fit an overview action icon
84-
header()->resizeSection(2, 17); // Enough to fit an editing icon
85-
86-
//added by Tim to hide the header - header is unneccessary
87-
// header()->setHidden(1); // morb_au - experiment
72+
setColumnCount(1);
73+
header()->setHidden(1);
8874
setRootIsDecorated(true);
8975

9076
}

src/legend/qgslegendlayerfile.cpp

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

99-
void QgsLegendLayerFile::setOverviewPixmap(const QPixmap& pix)
99+
void QgsLegendLayerFile::setIconAppearance(bool inOverview,
100+
bool editable)
100101
{
101-
QIcon theIcon(pix);
102-
setIcon(1, theIcon);
103-
}
102+
QPixmap newIcon(getOriginalPixmap());
104103

105-
void QgsLegendLayerFile::setEditingPixmap(const QPixmap& pix)
106-
{
107-
QIcon theIcon(pix);
108-
setIcon(2, theIcon);
104+
if (inOverview)
105+
{
106+
// Overlay the overview icon on the default icon
107+
QPixmap myPixmap(QgsApplication::themePath()+"mIconOverview.png");
108+
QPainter p(&newIcon);
109+
p.drawPixmap(0,0,myPixmap);
110+
p.end();
111+
}
112+
113+
if (editable)
114+
{
115+
// Overlay the editable icon on the default icon
116+
QPixmap myPixmap(QgsApplication::themePath()+"mIconEditable.png");
117+
QPainter p(&newIcon);
118+
p.drawPixmap(0,0,myPixmap);
119+
p.end();
120+
}
121+
122+
QIcon theIcon(newIcon);
123+
setIcon(0, theIcon);
109124
}
110125

111126
void QgsLegendLayerFile::toggleCheckBox(bool state)

src/legend/qgslegendlayerfile.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ class QgsLegendLayerFile : public QgsLegendItem
4545

4646
void setLegendPixmap(const QPixmap& pix);
4747

48-
void setOverviewPixmap(const QPixmap& pix);
49-
50-
void setEditingPixmap(const QPixmap& pix);
48+
void setIconAppearance(bool inOverview, bool editable);
5149

5250
/**Sets mVisibilityCheckBox to on/off*/
5351
void toggleCheckBox(bool state);

0 commit comments

Comments
 (0)