closes #84
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QList>
|
||||
#include <QtGui/QLineEdit>
|
||||
|
||||
#include <cassert>
|
||||
#include <QtCore/QDebug>
|
||||
@@ -113,6 +114,11 @@ class Settings: public QDialog, protected Ui::Settings {
|
||||
return _checkboxes[name].second;
|
||||
}
|
||||
|
||||
const QString& text(const QString& name) {
|
||||
assert(_lineedits.find(name)!=_lineedits.end());
|
||||
return _lineedits[name].second;
|
||||
}
|
||||
|
||||
const MimeTypes& mimetypes() const {
|
||||
return _mimetypes;
|
||||
}
|
||||
@@ -155,6 +161,11 @@ class Settings: public QDialog, protected Ui::Settings {
|
||||
it!=_checkboxes.end(); ++it)
|
||||
_settings->setValue
|
||||
(QString("Flags/%1").arg(it->first), it->second.second);
|
||||
// LineEdits
|
||||
for (LineEdits::iterator it(_lineedits.begin());
|
||||
it!=_lineedits.end(); ++it)
|
||||
_settings->setValue
|
||||
(QString("Texts/%1").arg(it->first), it->second.second);
|
||||
// MimeTypes
|
||||
_settings->setValue("QWebSettings/MimeTypes", _mimetypes);
|
||||
// Search Engines
|
||||
@@ -186,6 +197,17 @@ class Settings: public QDialog, protected Ui::Settings {
|
||||
it->second.second = val.toBool();
|
||||
}
|
||||
}
|
||||
// LineEdits
|
||||
for (LineEdits::iterator it(_lineedits.begin());
|
||||
it!=_lineedits.end(); ++it) {
|
||||
QVariant val
|
||||
(_settings->value
|
||||
(QString("Texts/%1").arg(it->first), it->second.second));
|
||||
if (val.isValid() && val.canConvert(QVariant::String)) {
|
||||
it->second.first->setText(val.toString());
|
||||
it->second.second = val.toString();
|
||||
}
|
||||
}
|
||||
// MimeTypes
|
||||
if (overwriteMimeTypes) {
|
||||
QVariant val(_settings->value("QWebSettings/MimeTypes"));
|
||||
@@ -212,6 +234,10 @@ class Settings: public QDialog, protected Ui::Settings {
|
||||
for (CheckBoxes::iterator it(_checkboxes.begin());
|
||||
it!=_checkboxes.end(); ++it)
|
||||
it->second.second = it->second.first->isChecked();
|
||||
// LineEdits
|
||||
for (LineEdits::iterator it(_lineedits.begin());
|
||||
it!=_lineedits.end(); ++it)
|
||||
it->second.second = it->second.first->text();
|
||||
// MimeTypes
|
||||
_mimetypes.clear();
|
||||
for (int row(_mimeTypeTable->rowCount()); row--;)
|
||||
@@ -239,6 +265,10 @@ class Settings: public QDialog, protected Ui::Settings {
|
||||
for (CheckBoxes::iterator it(_checkboxes.begin());
|
||||
it!=_checkboxes.end(); ++it)
|
||||
it->second.first->setChecked(it->second.second);
|
||||
// LineEdits
|
||||
for (LineEdits::iterator it(_lineedits.begin());
|
||||
it!=_lineedits.end(); ++it)
|
||||
it->second.first->setText(it->second.second);
|
||||
// MimeTypes
|
||||
_mimeTypeTable->setRowCount(_mimetypes.size());
|
||||
_mimeTypeTable->verticalHeader()->show();
|
||||
@@ -315,6 +345,8 @@ class Settings: public QDialog, protected Ui::Settings {
|
||||
Attributes _attributes;
|
||||
typedef std::map<QString, std::pair<QCheckBox*, bool> > CheckBoxes;
|
||||
CheckBoxes _checkboxes;
|
||||
typedef std::map<QString, std::pair<QLineEdit*, QString> > LineEdits;
|
||||
LineEdits _lineedits;
|
||||
QSettings* _settings;
|
||||
bool _autoWrite;
|
||||
MimeTypes _mimetypes;
|
||||
|
Reference in New Issue
Block a user