Skip to content
Permalink
Browse files
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
  • Loading branch information
g_j_m committed Jul 14, 2006
1 parent a3d1f75 commit 40fe6f6ea7c1025a121626f4a4fe16e451af42b7
Showing with 36 additions and 2 deletions.
  1. +29 −2 src/gui/qgsattributedialog.cpp
  2. +7 −0 src/gui/qgsattributedialog.h
@@ -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

0 comments on commit 40fe6f6

Please sign in to comment.