Skip to content

Commit ed607df

Browse files
author
rblazek
committed
changed attributes window style and recycling existing window
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5202 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 8cd51e9 commit ed607df

File tree

5 files changed

+57
-9
lines changed

5 files changed

+57
-9
lines changed

src/plugins/grass/qgsgrassattributes.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ QgsGrassAttributes::QgsGrassAttributes ( QgsGrassEdit *edit, QgsGrassProvider *p
102102
tabCats->removePage( tabCats->currentPage() );
103103
}
104104

105+
connect ( this, SIGNAL(destroyed()), mEdit, SLOT(attributesClosed()) );
106+
105107
// TODO: does not work:
106108
connect( tabCats, SIGNAL(void currentChanged(QWidget *)), this, SLOT(tabChanged(QWidget *)));
107109

@@ -352,6 +354,21 @@ void QgsGrassAttributes::deleteCat ( )
352354
resetButtons();
353355
}
354356

357+
void QgsGrassAttributes::clear ( )
358+
{
359+
#ifdef QGISDEBUG
360+
std::cerr << "QgsGrassAttributes::clear()" << std::endl;
361+
#endif
362+
363+
while ( tabCats->count() > 0 )
364+
{
365+
Q3Table *tb = (Q3Table *) tabCats->currentPage();
366+
tabCats->removePage( tb );
367+
delete tb;
368+
}
369+
resetButtons();
370+
}
371+
355372
void QgsGrassAttributes::tabChanged ( QWidget *widget )
356373
{
357374
#ifdef QGISDEBUG

src/plugins/grass/qgsgrassattributes.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class QgsGrassAttributes: public QDialog, private Ui::QgsGrassAttributesBase
5757
//! Constructor
5858
QgsGrassAttributes ( QgsGrassEdit *edit, QgsGrassProvider *provider, int line,
5959
QWidget * parent = 0, const char * name = 0,
60-
Qt::WFlags f = Qt::WStyle_Customize | Qt::WStyle_DialogBorder | Qt::WStyle_Title | Qt::WType_Dialog | Qt::WStyle_Tool);
60+
Qt::WFlags f = Qt::Window );
61+
//Qt::WFlags f = Qt::WStyle_Customize | Qt::WStyle_DialogBorder | Qt::WStyle_Title | Qt::WType_Dialog | Qt::WStyle_Tool);
6162

6263
//! Destructor
6364
~QgsGrassAttributes();
@@ -102,6 +103,9 @@ public slots:
102103
//! Column size changed
103104
void columnSizeChanged ( int section, int oldSize, int newSize );
104105

106+
//! Remove all tabs
107+
void clear();
108+
105109
private:
106110
//! Pointer to vector provider
107111
QgsGrassProvider *mProvider;

src/plugins/grass/qgsgrassedit.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1693,3 +1693,8 @@ void QgsGrassEdit::setCanvasPropmt( QString left, QString mid, QString rigth)
16931693
if ( mid.length() > 0 ) mCanvasPrompt.append ( tr("Middle: ") + mid + " " );
16941694
if ( rigth.length() > 0 ) mCanvasPrompt.append ( tr("Rigth: ") + rigth );
16951695
}
1696+
1697+
void QgsGrassEdit::attributesClosed()
1698+
{
1699+
mAttributes = 0;
1700+
}

src/plugins/grass/qgsgrassedit.h

+3
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ public slots:
210210

211211
static bool isEditable ( QgsMapLayer *layer );
212212

213+
//! Window with attributes closed
214+
void attributesClosed();
215+
213216
signals:
214217
void finished();
215218

src/plugins/grass/qgsgrassedittools.cpp

+27-8
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,19 @@ void QgsGrassEditNewPoint::mouseClick(QgsPoint & point, Qt::ButtonState button)
9090
e->updateSymb();
9191
e->displayUpdated();
9292

93-
if ( e->mAttributes ) delete e->mAttributes;
94-
e->mAttributes = new QgsGrassAttributes ( e, e->mProvider, line, e->mQgisApp );
93+
if ( e->mAttributes )
94+
{
95+
e->mAttributes->clear();
96+
}
97+
else
98+
{
99+
e->mAttributes = new QgsGrassAttributes ( e, e->mProvider, line, e->mQgisApp );
100+
}
95101
for ( int i = 0; i < e->mCats->n_cats; i++ ) {
96102
e->addAttributes ( e->mCats->field[i], e->mCats->cat[i] );
97103
}
98104
e->mAttributes->show();
105+
e->mAttributes->raise();
99106
}
100107

101108

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

173-
if ( e->mAttributes ) delete e->mAttributes;
174-
e->mAttributes = new QgsGrassAttributes ( e, e->mProvider, line, e->mQgisApp );
180+
if ( e->mAttributes )
181+
{
182+
e->mAttributes->clear();
183+
}
184+
else
185+
{
186+
e->mAttributes = new QgsGrassAttributes ( e, e->mProvider, line, e->mQgisApp );
187+
}
175188
for ( int i = 0; i < e->mCats->n_cats; i++ ) {
176189
e->addAttributes ( e->mCats->field[i], e->mCats->cat[i] );
177190
}
178191
e->mAttributes->show();
192+
e->mAttributes->raise();
179193
}
180194
Vect_reset_line ( e->mEditPoints );
181195
break;
@@ -756,21 +770,26 @@ void QgsGrassEditAttributes::mouseClick(QgsPoint & point, Qt::ButtonState button
756770
std::cerr << "mSelectedLine = " << e->mSelectedLine << std::endl;
757771
#endif
758772

759-
if ( e->mAttributes ) {
760-
delete e->mAttributes;
761-
e->mAttributes = 0;
773+
if ( e->mAttributes )
774+
{
775+
e->mAttributes->clear();
776+
e->mAttributes->raise();
762777
}
763778

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

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

769-
e->mAttributes = new QgsGrassAttributes ( e, e->mProvider, e->mSelectedLine, e->mQgisApp );
784+
if ( !e->mAttributes )
785+
{
786+
e->mAttributes = new QgsGrassAttributes ( e, e->mProvider, e->mSelectedLine, e->mQgisApp );
787+
}
770788
for ( int i = 0; i < e->mCats->n_cats; i++ ) {
771789
e->addAttributes ( e->mCats->field[i], e->mCats->cat[i] );
772790
}
773791
e->mAttributes->show();
792+
e->mAttributes->raise();
774793
}
775794

776795
}

0 commit comments

Comments
 (0)