Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
g_j_m committed Jul 14, 2006
1 parent d325253 commit f71e6c9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
31 changes: 29 additions & 2 deletions src/gui/qgsattributedialog.cpp
Expand Up @@ -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());

Expand All @@ -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)
Expand All @@ -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);
}
7 changes: 7 additions & 0 deletions src/gui/qgsattributedialog.h
Expand Up @@ -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 f71e6c9

Please sign in to comment.