Welcome: Store examples search text in settings

in QtCreator.ini under "WelcomePage/ExamplesSearchString".
The installer pre-set that setting, and in that way pre-
select a set of examples.

Change-Id: I8ac5a38ad0bd3f33875ef1997ccbf0352410dcc3
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
Alessandro Portale
2014-04-02 13:42:53 +02:00
parent dc66a01b10
commit 57f11f40d6
3 changed files with 19 additions and 1 deletions

View File

@@ -56,8 +56,13 @@ Rectangle {
anchors.right: parent.right anchors.right: parent.right
anchors.leftMargin: 18 anchors.leftMargin: 18
text: examplesModel.readSearchStringsFromSettings()
placeholderText: qsTr("Search in Examples...") placeholderText: qsTr("Search in Examples...")
onTextChanged: examplesModel.parseSearchString(text) onTextChanged: {
examplesModel.parseSearchString(text);
examplesModel.writeSearchStringToSettings(text);
}
} }
ComboBox { ComboBox {

View File

@@ -54,6 +54,7 @@ static bool debugExamples()
} }
static const char kSelectedExampleSetKey[] = "WelcomePage/SelectedExampleSet"; static const char kSelectedExampleSetKey[] = "WelcomePage/SelectedExampleSet";
static const char kExamplesSearchStringKey[] = "WelcomePage/ExamplesSearchString";
void ExampleSetModel::writeCurrentIdToSettings(int currentIndex) const void ExampleSetModel::writeCurrentIdToSettings(int currentIndex) const
{ {
@@ -841,6 +842,16 @@ void ExamplesListModelFilter::filterForExampleSet(int index)
m_sourceModel->selectExampleSet(index); m_sourceModel->selectExampleSet(index);
} }
void ExamplesListModelFilter::writeSearchStringToSettings(const QString &string)
{
Core::ICore::settings()->setValue(QLatin1String(kExamplesSearchStringKey), string);
}
QString ExamplesListModelFilter::readSearchStringsFromSettings()
{
return Core::ICore::settings()->value(QLatin1String(kExamplesSearchStringKey)).toString();
}
void ExamplesListModelFilter::setShowTutorialsOnly(bool showTutorialsOnly) void ExamplesListModelFilter::setShowTutorialsOnly(bool showTutorialsOnly)
{ {
m_showTutorialsOnly = showTutorialsOnly; m_showTutorialsOnly = showTutorialsOnly;

View File

@@ -185,6 +185,8 @@ public:
QAbstractItemModel* exampleSetModel(); QAbstractItemModel* exampleSetModel();
Q_INVOKABLE void filterForExampleSet(int index); Q_INVOKABLE void filterForExampleSet(int index);
Q_INVOKABLE void writeSearchStringToSettings(const QString &string);
Q_INVOKABLE QString readSearchStringsFromSettings();
public slots: public slots:
void setFilterTags(const QStringList &arg) void setFilterTags(const QStringList &arg)