mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
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@5598 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
d3252533cd
commit
f71e6c997b
@ -18,10 +18,13 @@
|
||||
#include "qgsattributedialog.h"
|
||||
#include "qgsfeature.h"
|
||||
#include <QTableWidgetItem>
|
||||
#include <QSettings>
|
||||
|
||||
QgsAttributeDialog::QgsAttributeDialog(const std::vector<QgsFeatureAttribute>* attributes)
|
||||
: QDialog()
|
||||
: QDialog(), _settingsPath("/Windows/AttributeDialog/")
|
||||
{
|
||||
restorePositionAndColumnWidth();
|
||||
|
||||
setupUi(this);
|
||||
mTable->setRowCount(attributes->size());
|
||||
|
||||
@ -35,11 +38,12 @@ QgsAttributeDialog::QgsAttributeDialog(const std::vector<QgsFeatureAttribute>* a
|
||||
mTable->setItem(index, 1, myValueItem);
|
||||
++index;
|
||||
}
|
||||
mTable->resizeColumnsToContents();
|
||||
}
|
||||
|
||||
QgsAttributeDialog::~QgsAttributeDialog()
|
||||
{
|
||||
|
||||
savePositionAndColumnWidth();
|
||||
}
|
||||
|
||||
QString QgsAttributeDialog::value(int row)
|
||||
@ -64,3 +68,26 @@ bool QgsAttributeDialog::queryAttributes(QgsFeature& f)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
void QgsAttributeDialog::savePositionAndColumnWidth()
|
||||
{
|
||||
QSettings settings;
|
||||
QPoint p = this->pos();
|
||||
QSize s = this->size();
|
||||
settings.writeEntry(_settingsPath+"x", p.x());
|
||||
settings.writeEntry(_settingsPath+"y", p.y());
|
||||
settings.writeEntry(_settingsPath+"w", s.width());
|
||||
settings.writeEntry(_settingsPath+"h", s.height());
|
||||
|
||||
}
|
||||
|
||||
void QgsAttributeDialog::restorePositionAndColumnWidth()
|
||||
{
|
||||
QSettings settings;
|
||||
int ww = settings.readNumEntry(_settingsPath+"w", 281);
|
||||
int wh = settings.readNumEntry(_settingsPath+"h", 316);
|
||||
int wx = settings.readNumEntry(_settingsPath+"x", 100);
|
||||
int wy = settings.readNumEntry(_settingsPath+"y", 100);
|
||||
|
||||
resize(ww,wh);
|
||||
move(wx,wy);
|
||||
}
|
||||
|
@ -38,6 +38,13 @@ class QgsAttributeDialog: public QDialog, private Ui::QgsAttributeDialogBase
|
||||
attribute values are set to the feature if the dialog is accepted.
|
||||
Returns true if accepted and false if canceled*/
|
||||
static bool queryAttributes(QgsFeature& f);
|
||||
|
||||
// Saves and restores the size and position from the last time
|
||||
// this dialog box was used.
|
||||
void savePositionAndColumnWidth();
|
||||
void restorePositionAndColumnWidth();
|
||||
private:
|
||||
QString _settingsPath;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user