diff -r 753e33780645 -r 453d490c84a5 stifui/qt/src/uisetting.cpp --- a/stifui/qt/src/uisetting.cpp Fri Sep 03 07:53:25 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * under the terms of "Eclipse Public License v1.0" - * which accompanies this distribution, and is available - * at the URL "http://www.eclipse.org/legal/epl-v10.html". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: QT C++ based Class. - * - */ - -#include -#include -#include -#include "uisetting.h" -const QString SETTINGFILE = "c:\\TestFramework\\StfQtUISetting.ini"; - -UiSetting::UiSetting() - { - if(!load()) - { - loadDefault(); - } - } - -UiSetting::~UiSetting() - { - } - -QString UiSetting::ReadSetting(const QString& item) - { - QString value = ""; - if(settingList.contains(item)) - { - value = settingList.value(item); - } - else - { - value = getDefaultValue(item); - settingList.insert(item, value); - } - return value; - } - - -void UiSetting::SetSetting(const QString& item, const QString& value) - { - if(settingList.contains(item)) - { - settingList.remove(item); - } - settingList.insert(item, value); - save(); - } - - -void UiSetting::loadDefault() - { - settingList.clear(); - settingList.insert(KShowOutput, getDefaultValue(KShowOutput)); - settingList.insert(KStyleSheet, getDefaultValue(KStyleSheet)); - settingList.insert(KFilter, getDefaultValue(KFilter)); - settingList.insert(KFilterCaseSens, getDefaultValue(KFilterCaseSens)); - //add mor default setting here. - } - -QString UiSetting::getDefaultValue(const QString& item) - { - QString result = ""; - if(item == KShowOutput) - { - result = "true"; - } - else if(item == KStyleSheet) - { - result = ":/qss/coffee.qss"; - } - else if(item == KFilter) - { - result = ""; - } - else if(item == KFilterCaseSens) - { - result = "false"; - } - return result; - } - -bool UiSetting::load() - { - QFile file(SETTINGFILE); - if(!file.open(QIODevice::ReadOnly)) - { - return false; - } - QTextStream in(&file); - QString line, item, value; - int index; - while(!in.atEnd()) - { - line = in.readLine().trimmed(); - if(!line.startsWith("//")) - { - index = line.indexOf("="); - if(index > 0 && index < line.length() - 1) - { - item = line.left(index).trimmed(); - value = line.right(line.length() - index -1); - if(item == KFilter) //For filter do not care about stored value - value = ""; - settingList.insert(item, value); - } - } - //end while. - } - return true; - } - -bool UiSetting::save() - { - QFile file(SETTINGFILE); - if(!file.open(QIODevice::WriteOnly)) - { - return false; - } - QTextStream in(&file); - in << "//STFQtUI Setting.\r\n"; - in << "//Created at: " + QDateTime::currentDateTime().toString("yyyy.mm.dd hh:mm::ss"); - in << "\r\n"; - for(int i=0;i< settingList.size();i++) - { - in << settingList.keys()[i]; - in << "="; - in << settingList.value(settingList.keys()[i]); - in << "\r\n"; - } - return true; - } - -// End of File