Skip to content

Commit 40fe6f6

Browse files
author
g_j_m
committedJul 14, 2006
Save and restore the size and geometry of the edit attribute dialog
box, and always resize the column widths to fit the data. Fixes ticket #97. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5598 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed
 

‎src/gui/qgsattributedialog.cpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818
#include "qgsattributedialog.h"
1919
#include "qgsfeature.h"
2020
#include <QTableWidgetItem>
21+
#include <QSettings>
2122

2223
QgsAttributeDialog::QgsAttributeDialog(const std::vector<QgsFeatureAttribute>* attributes)
23-
: QDialog()
24+
: QDialog(), _settingsPath("/Windows/AttributeDialog/")
2425
{
26+
restorePositionAndColumnWidth();
27+
2528
setupUi(this);
2629
mTable->setRowCount(attributes->size());
2730

@@ -35,11 +38,12 @@ QgsAttributeDialog::QgsAttributeDialog(const std::vector<QgsFeatureAttribute>* a
3538
mTable->setItem(index, 1, myValueItem);
3639
++index;
3740
}
41+
mTable->resizeColumnsToContents();
3842
}
3943

4044
QgsAttributeDialog::~QgsAttributeDialog()
4145
{
42-
46+
savePositionAndColumnWidth();
4347
}
4448

4549
QString QgsAttributeDialog::value(int row)
@@ -64,3 +68,26 @@ bool QgsAttributeDialog::queryAttributes(QgsFeature& f)
6468
return false;
6569
}
6670
}
71+
void QgsAttributeDialog::savePositionAndColumnWidth()
72+
{
73+
QSettings settings;
74+
QPoint p = this->pos();
75+
QSize s = this->size();
76+
settings.writeEntry(_settingsPath+"x", p.x());
77+
settings.writeEntry(_settingsPath+"y", p.y());
78+
settings.writeEntry(_settingsPath+"w", s.width());
79+
settings.writeEntry(_settingsPath+"h", s.height());
80+
81+
}
82+
83+
void QgsAttributeDialog::restorePositionAndColumnWidth()
84+
{
85+
QSettings settings;
86+
int ww = settings.readNumEntry(_settingsPath+"w", 281);
87+
int wh = settings.readNumEntry(_settingsPath+"h", 316);
88+
int wx = settings.readNumEntry(_settingsPath+"x", 100);
89+
int wy = settings.readNumEntry(_settingsPath+"y", 100);
90+
91+
resize(ww,wh);
92+
move(wx,wy);
93+
}

‎src/gui/qgsattributedialog.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ class QgsAttributeDialog: public QDialog, private Ui::QgsAttributeDialogBase
3838
attribute values are set to the feature if the dialog is accepted.
3939
Returns true if accepted and false if canceled*/
4040
static bool queryAttributes(QgsFeature& f);
41+
42+
// Saves and restores the size and position from the last time
43+
// this dialog box was used.
44+
void savePositionAndColumnWidth();
45+
void restorePositionAndColumnWidth();
46+
private:
47+
QString _settingsPath;
4148
};
4249

4350
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.