Skip to content
Permalink
Browse files

[GRASS] import icon

  • Loading branch information
blazek committed May 25, 2015
1 parent d40d481 commit b91e43af23d56e2c33cb726e062dd9a94e78ef1c
@@ -326,6 +326,7 @@
<file>themes/default/mIconFirst.png</file>
<file>themes/default/mIconGeometryLayer.png</file>
<file>themes/default/mIconInfo.png</file>
<file>themes/default/mIconImport.gif</file>
<file>themes/default/mIconLabelQuadrantCenter.svg</file>
<file>themes/default/mIconLabelQuadrantOffset.svg</file>
<file>themes/default/mIconLast.png</file>
Binary file not shown.
@@ -678,15 +678,56 @@ QIcon QgsGrassRasterItem::icon()
return QgsDataItem::icon();
}


//----------------------- QgsGrassImportItem ------------------------------
QgsGrassImportItemIcon::QgsGrassImportItemIcon()
: QObject()
, mCount( 0 )
, mMovie( 0 )
{
// QApplication as parent to ensure that it is deleted before QApplication
mMovie = new QMovie( QApplication::instance() );
mMovie->setFileName( QgsApplication::iconPath( "/mIconImport.gif" ) );
mMovie->setCacheMode( QMovie::CacheAll );
connect( mMovie, SIGNAL( frameChanged( int ) ), SLOT( onFrameChanged() ) );
}

void QgsGrassImportItemIcon::onFrameChanged()
{
mIcon = QIcon( mMovie->currentPixmap() );
}

void QgsGrassImportItemIcon::addListener()
{
mCount++;
mMovie->setPaused( mCount == 0 );
}

void QgsGrassImportItemIcon::removeListener()
{
mCount++;
mMovie->setPaused( mCount == 0 );
}

//----------------------- QgsGrassImportItem ------------------------------

QgsGrassImportItemIcon QgsGrassImportItem::mImportIcon;

QgsGrassImportItem::QgsGrassImportItem( QgsDataItem* parent, const QString& name, const QString& path, QgsGrassImport* import )
: QgsDataItem( QgsDataItem::Layer, parent, name, path )
, QgsGrassObjectItemBase( import->grassObject() )
, mImport( import )
{
setCapabilities( QgsDataItem::NoCapabilities ); // disable fertility
setState( Populating );

connect( &mImportIcon, SIGNAL( frameChanged( int ) ), SLOT( emitDataChanged() ) );
mImportIcon.addListener();
}

QgsGrassImportItem::~QgsGrassImportItem()
{
mImportIcon.removeListener();
}

QList<QAction*> QgsGrassImportItem::actions()
@@ -710,6 +751,11 @@ void QgsGrassImportItem::cancel()
mImport->cancel();
}

QIcon QgsGrassImportItem::icon()
{
return mImportIcon.icon();
}

//-------------------------------------------------------------------------

QGISEXTERN int dataCapabilities()
@@ -157,17 +157,42 @@ class QgsGrassRasterItem : public QgsGrassObjectItem
bool mExternal;
};

// icon movie
class QgsGrassImportItemIcon : public QObject
{
Q_OBJECT
public:
QgsGrassImportItemIcon();

QIcon icon() { return mIcon; }
void addListener();
void removeListener();

public slots:
void onFrameChanged();

signals:
void frameChanged();

private:
void resetMovie();
int mCount;
QMovie * mMovie;
QIcon mIcon;
};

// item representing a layer being imported
class QgsGrassImportItem : public QgsDataItem, public QgsGrassObjectItemBase
{
Q_OBJECT
public:
QgsGrassImportItem( QgsDataItem* parent, const QString& name, const QString& path, QgsGrassImport* import );

~QgsGrassImportItem();
//virtual void setState( State state ) override {
// QgsDataItem::setState(state);
//} // do nothing to keep Populating
virtual QList<QAction*> actions() override;
virtual QIcon icon() override;

public slots:
virtual void refresh() override {}
@@ -178,6 +203,9 @@ class QgsGrassImportItem : public QgsDataItem, public QgsGrassObjectItemBase
virtual void refresh( QVector<QgsDataItem*> children ) override { Q_UNUSED( children )};
//bool mDeleteAction;
QgsGrassImport* mImport;

private:
static QgsGrassImportItemIcon mImportIcon;
};

#endif // QGSGRASSPROVIDERMODULE_H

0 comments on commit b91e43a

Please sign in to comment.