Skip to content

Commit

Permalink
Use icon overlays for the editable and overview status of a layer
Browse files Browse the repository at this point in the history
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@5616 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Jul 20, 2006
1 parent 536daae commit 443e85b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 51 deletions.
Binary file added images/themes/default/mIconOverview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 3 additions & 24 deletions src/gui/qgsmaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,29 +452,8 @@ void QgsMapLayer::updateItemPixmap()
{
if (mLegendLayerFile)
{
QPixmap originalPix=mLegendLayerFile->getOriginalPixmap();

if(mShowInOverview)
{
//add overview glasses to the pixmap
mLegendLayerFile->setOverviewPixmap(mInOverviewPixmap);
}
else
{
mLegendLayerFile->setOverviewPixmap( QPixmap() );
}

if(isEditable())
{
//add editing icon to the pixmap
mLegendLayerFile->setEditingPixmap(mEditablePixmap);
}
else
{
mLegendLayerFile->setEditingPixmap( QPixmap() );
}

mLegendLayerFile->setLegendPixmap(originalPix);
mLegendLayerFile->setIconAppearance(mShowInOverview,
isEditable());
}
}

Expand All @@ -490,7 +469,7 @@ void QgsMapLayer::invalidTransformInput()
QPainter p(&pix);
p.drawPixmap(60,0,mProjectionErrorPixmap);
}
mLegendLayerFile->setLegendPixmap(pix);
mLegendLayerFile->setLegendPixmap(pix);
}
}

Expand Down
18 changes: 2 additions & 16 deletions src/legend/qgslegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,8 @@ QgsLegend::QgsLegend(QgisApp* app, QWidget * parent, const char *name)
setFont(f);
setBackgroundColor(QColor(192, 192, 192));

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); // morb_au - experiment
setColumnCount(1);
header()->setHidden(1);
setRootIsDecorated(true);

}
Expand Down
31 changes: 23 additions & 8 deletions src/legend/qgslegendlayerfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,31 @@ void QgsLegendLayerFile::setLegendPixmap(const QPixmap& pix)
setIcon(0, theIcon);
}

void QgsLegendLayerFile::setOverviewPixmap(const QPixmap& pix)
void QgsLegendLayerFile::setIconAppearance(bool inOverview,
bool editable)
{
QIcon theIcon(pix);
setIcon(1, theIcon);
}
QPixmap newIcon(getOriginalPixmap());

void QgsLegendLayerFile::setEditingPixmap(const QPixmap& pix)
{
QIcon theIcon(pix);
setIcon(2, theIcon);
if (inOverview)
{
// Overlay the overview icon on the default icon
QPixmap myPixmap(QgsApplication::themePath()+"mIconOverview.png");
QPainter p(&newIcon);
p.drawPixmap(0,0,myPixmap);
p.end();
}

if (editable)
{
// Overlay the editable icon on the default icon
QPixmap myPixmap(QgsApplication::themePath()+"mIconEditable.png");
QPainter p(&newIcon);
p.drawPixmap(0,0,myPixmap);
p.end();
}

QIcon theIcon(newIcon);
setIcon(0, theIcon);
}

void QgsLegendLayerFile::toggleCheckBox(bool state)
Expand Down
4 changes: 1 addition & 3 deletions src/legend/qgslegendlayerfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ class QgsLegendLayerFile : public QgsLegendItem

void setLegendPixmap(const QPixmap& pix);

void setOverviewPixmap(const QPixmap& pix);

void setEditingPixmap(const QPixmap& pix);
void setIconAppearance(bool inOverview, bool editable);

/**Sets mVisibilityCheckBox to on/off*/
void toggleCheckBox(bool state);
Expand Down

0 comments on commit 443e85b

Please sign in to comment.