Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
changed attributes window style and recycling existing window
git-svn-id: http://svn.osgeo.org/qgis/trunk@5202 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Apr 6, 2006
1 parent 41fbc9d commit 354edca
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 9 deletions.
17 changes: 17 additions & 0 deletions src/plugins/grass/qgsgrassattributes.cpp
Expand Up @@ -102,6 +102,8 @@ QgsGrassAttributes::QgsGrassAttributes ( QgsGrassEdit *edit, QgsGrassProvider *p
tabCats->removePage( tabCats->currentPage() );
}

connect ( this, SIGNAL(destroyed()), mEdit, SLOT(attributesClosed()) );

// TODO: does not work:
connect( tabCats, SIGNAL(void currentChanged(QWidget *)), this, SLOT(tabChanged(QWidget *)));

Expand Down Expand Up @@ -352,6 +354,21 @@ void QgsGrassAttributes::deleteCat ( )
resetButtons();
}

void QgsGrassAttributes::clear ( )
{
#ifdef QGISDEBUG
std::cerr << "QgsGrassAttributes::clear()" << std::endl;
#endif

while ( tabCats->count() > 0 )
{
Q3Table *tb = (Q3Table *) tabCats->currentPage();
tabCats->removePage( tb );
delete tb;
}
resetButtons();
}

void QgsGrassAttributes::tabChanged ( QWidget *widget )
{
#ifdef QGISDEBUG
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/grass/qgsgrassattributes.h
Expand Up @@ -57,7 +57,8 @@ class QgsGrassAttributes: public QDialog, private Ui::QgsGrassAttributesBase
//! Constructor
QgsGrassAttributes ( QgsGrassEdit *edit, QgsGrassProvider *provider, int line,
QWidget * parent = 0, const char * name = 0,
Qt::WFlags f = Qt::WStyle_Customize | Qt::WStyle_DialogBorder | Qt::WStyle_Title | Qt::WType_Dialog | Qt::WStyle_Tool);
Qt::WFlags f = Qt::Window );
//Qt::WFlags f = Qt::WStyle_Customize | Qt::WStyle_DialogBorder | Qt::WStyle_Title | Qt::WType_Dialog | Qt::WStyle_Tool);

//! Destructor
~QgsGrassAttributes();
Expand Down Expand Up @@ -102,6 +103,9 @@ public slots:
//! Column size changed
void columnSizeChanged ( int section, int oldSize, int newSize );

//! Remove all tabs
void clear();

private:
//! Pointer to vector provider
QgsGrassProvider *mProvider;
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/grass/qgsgrassedit.cpp
Expand Up @@ -1693,3 +1693,8 @@ void QgsGrassEdit::setCanvasPropmt( QString left, QString mid, QString rigth)
if ( mid.length() > 0 ) mCanvasPrompt.append ( tr("Middle: ") + mid + " " );
if ( rigth.length() > 0 ) mCanvasPrompt.append ( tr("Rigth: ") + rigth );
}

void QgsGrassEdit::attributesClosed()
{
mAttributes = 0;
}
3 changes: 3 additions & 0 deletions src/plugins/grass/qgsgrassedit.h
Expand Up @@ -210,6 +210,9 @@ public slots:

static bool isEditable ( QgsMapLayer *layer );

//! Window with attributes closed
void attributesClosed();

signals:
void finished();

Expand Down
35 changes: 27 additions & 8 deletions src/plugins/grass/qgsgrassedittools.cpp
Expand Up @@ -90,12 +90,19 @@ void QgsGrassEditNewPoint::mouseClick(QgsPoint & point, Qt::ButtonState button)
e->updateSymb();
e->displayUpdated();

if ( e->mAttributes ) delete e->mAttributes;
e->mAttributes = new QgsGrassAttributes ( e, e->mProvider, line, e->mQgisApp );
if ( e->mAttributes )
{
e->mAttributes->clear();
}
else
{
e->mAttributes = new QgsGrassAttributes ( e, e->mProvider, line, e->mQgisApp );
}
for ( int i = 0; i < e->mCats->n_cats; i++ ) {
e->addAttributes ( e->mCats->field[i], e->mCats->cat[i] );
}
e->mAttributes->show();
e->mAttributes->raise();
}


Expand Down Expand Up @@ -170,12 +177,19 @@ void QgsGrassEditNewLine::mouseClick(QgsPoint & point, Qt::ButtonState button)
e->updateSymb();
e->displayUpdated();

if ( e->mAttributes ) delete e->mAttributes;
e->mAttributes = new QgsGrassAttributes ( e, e->mProvider, line, e->mQgisApp );
if ( e->mAttributes )
{
e->mAttributes->clear();
}
else
{
e->mAttributes = new QgsGrassAttributes ( e, e->mProvider, line, e->mQgisApp );
}
for ( int i = 0; i < e->mCats->n_cats; i++ ) {
e->addAttributes ( e->mCats->field[i], e->mCats->cat[i] );
}
e->mAttributes->show();
e->mAttributes->raise();
}
Vect_reset_line ( e->mEditPoints );
break;
Expand Down Expand Up @@ -756,21 +770,26 @@ void QgsGrassEditAttributes::mouseClick(QgsPoint & point, Qt::ButtonState button
std::cerr << "mSelectedLine = " << e->mSelectedLine << std::endl;
#endif

if ( e->mAttributes ) {
delete e->mAttributes;
e->mAttributes = 0;
if ( e->mAttributes )
{
e->mAttributes->clear();
e->mAttributes->raise();
}

if ( e->mSelectedLine ) { // highlite
e->displayElement ( e->mSelectedLine, e->mSymb[QgsGrassEdit::SYMB_HIGHLIGHT], e->mSize );

e->mProvider->readLine ( NULL, e->mCats, e->mSelectedLine );

e->mAttributes = new QgsGrassAttributes ( e, e->mProvider, e->mSelectedLine, e->mQgisApp );
if ( !e->mAttributes )
{
e->mAttributes = new QgsGrassAttributes ( e, e->mProvider, e->mSelectedLine, e->mQgisApp );
}
for ( int i = 0; i < e->mCats->n_cats; i++ ) {
e->addAttributes ( e->mCats->field[i], e->mCats->cat[i] );
}
e->mAttributes->show();
e->mAttributes->raise();
}

}

0 comments on commit 354edca

Please sign in to comment.