00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <qstringlist.h>
00023 #include <qsettings.h>
00024
00025 #include "RcFile.h"
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 RcFile::RcFile ()
00038 {
00039 Key[Home] = "Home";
00040 Def[Home] = "";
00041 Key[DataPath] = "DataPath";
00042 Def[DataPath] = "";
00043 Key[Pixelspace] = "Pixelspace";
00044 Def[Pixelspace] = "6";
00045 Key[BarLength] = "BarLength";
00046 Def[BarLength] = "6";
00047 Key[Grid] = "Grid";
00048 Def[Grid] = "TRUE";
00049 Key[BarsToLoad] = "BarsToLoad";
00050 Def[BarsToLoad] = "475";
00051 Key[BackgroundColor] = "BackgroundColor";
00052 Def[BackgroundColor] = "#000000";
00053 Key[BorderColor] = "BorderColor";
00054 Def[BorderColor] = "#ffffff";
00055 Key[GridColor] = "GridColor";
00056 Def[GridColor] = "#555555";
00057 Key[PaperTradeMode] = "PaperTradeMode";
00058 Def[PaperTradeMode] = "FALSE";
00059 Key[IndicatorPath] = "IndicatorPath";
00060 Def[IndicatorPath] = "";
00061 Key[Crosshairs] = "Crosshairs";
00062 Def[Crosshairs] = "FALSE";
00063 Key[DrawMode] = "DrawMode";
00064 Def[DrawMode] = "TRUE";
00065 Key[DataPanelSize] = "DataPanelSize";
00066 Def[DataPanelSize] = "338,322";
00067 Key[ScaleToScreen] = "ScaleToScreen";
00068 Def[ScaleToScreen] = "TRUE";
00069 Key[QuotePluginPath] = "QuotePluginPath";
00070 Def[QuotePluginPath] = "/usr/local/lib/qtstalker/quote";
00071 Key[GroupPath] = "GroupPath";
00072 Def[GroupPath] = "";
00073 Key[PortfolioPath] = "PortfolioPath";
00074 Def[PortfolioPath] = "";
00075 Key[TestPath] = "TestPath";
00076 Def[TestPath] = "";
00077 Key[PlotFont] = "PlotFont";
00078 Def[PlotFont] = "DejaVu Sans,9,50,0,0";
00079 Key[AppFont] = "AppFont";
00080 Def[AppFont] = "DejaVu Sans,9,50,0,0";
00081 Key[NavAreaSize] = "NavAreaSize";
00082 Def[NavAreaSize] = "780,109";
00083 Key[LogScale] = "LogScalex";
00084 Def[LogScale] = "FALSE";
00085 Key[IndexPath] = "IndexPath";
00086 Def[IndexPath] = "";
00087 Key[HelpFilePath] = "HelpFilePath";
00088 Def[HelpFilePath] = "/usr/local/share/doc/qtstalker/html";
00089 Key[UserDocsPath] = "UserDocsPath";
00090 Def[UserDocsPath] = "";
00091 Key[LastQuotePlugin] = "LastQuotePlugin";
00092 Def[LastQuotePlugin] = "Yahoo";
00093 Key[MainWindowSize] = "/WindowSizes/Main";
00094 Def[MainWindowSize] = "950,600";
00095 Key[MainWindowPos] = "/WindowSizes/MainPos";
00096 Def[MainWindowPos] = "30,30";
00097 Key[PrefDlgWindowSize] = "/WindowSizes/PrefDialog";
00098 Def[PrefDlgWindowSize] = "400,270";
00099 Key[EditStockWindowSize] = "/WindowSizes/EditStock";
00100 Def[EditStockWindowSize] = "350,250";
00101 Key[HelpWindowSize] = "/WindowSizes/HelpWindow";
00102 Def[HelpWindowSize] = "350,350";
00103 Key[BackTesterWindowSize] = "/WindowSizes/BackTester";
00104 Def[BackTesterWindowSize] = "";
00105 Key[ScannerWindowSize] = "/WindowSizes/Scanner";
00106 Def[ScannerWindowSize] = "";
00107 Key[ScannerPath] = "ScannerPath";
00108 Def[ScannerPath] = "";
00109 Key[Version] = "Version";
00110 Def[Version] = "";
00111 Key[PlotSizes] = "/PlotSizes/";
00112 Def[PlotSizes] = "339,85,85";
00113 Key[ShowMenuBar] = "Preferences/ShowMenuBar";
00114 Def[ShowMenuBar] = "TRUE";
00115 Key[ShowExtraToolbar] = "Preferences/ShowExtraToolbar";
00116 Def[ShowExtraToolbar] = "FALSE";
00117 Key[COPath] = "COPath";
00118 Def[COPath] = "";
00119 Key[LocalIndicatorsPath] = "LocalIndicatorsPath";
00120 Def[LocalIndicatorsPath] = "";
00121 Key[FundamentalsPath] = "FundamentalsPath";
00122 Def[FundamentalsPath] = "";
00123 Key[CurrentChart] = "CurrentChart";
00124 Def[CurrentChart] = "";
00125 Key[IndicatorGroup] = "IndicatorGroup";
00126 Def[IndicatorGroup] = "Indicators";
00127 Key[QuotePluginStorage] = "QuotePluginStorage";
00128 Def[QuotePluginStorage] = "";
00129 Key[LastNewIndicator] = "LastNewIndicator";
00130 Def[LastNewIndicator] = "";
00131 Key[PSButtonCount] = "Preferences/PSButtonCount";
00132 Def[PSButtonCount] = "3";
00133 Key[PSButton] = "Preferences/PSButton";
00134 Def[PSButton] = "6";
00135 Key[ShowSidePanel] = "ShowSidePanel";
00136 Def[ShowSidePanel] = "TRUE";
00137 Key[ShowQuitBtn] = "Preferences/ShowQuitBtn";
00138 Def[ShowQuitBtn] = "TRUE";
00139 Key[ShowPrefBtn] = "Preferences/ShowPrefBtn";
00140 Def[ShowPrefBtn] = "TRUE";
00141 Key[ShowSidePanelBtn] = "Preferences/ShowSidePanelBtn";
00142 Def[ShowSidePanelBtn] = "TRUE";
00143 Key[ShowGridBtn] = "Preferences/ShowGridBtn";
00144 Def[ShowGridBtn] = "TRUE";
00145 Key[ShowScaleToScreenBtn] = "Preferences/ShowScaleToScreenBtn";
00146 Def[ShowScaleToScreenBtn] = "TRUE";
00147 Key[ShowCrosshairBtn] = "Preferences/ShowCrosshairBtn";
00148 Def[ShowCrosshairBtn] = "TRUE";
00149 Key[ShowPaperTradeBtn] = "Preferences/ShowPaperTradeBtn";
00150 Def[ShowPaperTradeBtn] = "TRUE";
00151 Key[ShowDrawModeBtn] = "Preferences/ShowDrawModeBtn";
00152 Def[ShowDrawModeBtn] = "TRUE";
00153 Key[ShowNewIndicatorBtn] = "Preferences/ShowNewIndicatorBtn";
00154 Def[ShowNewIndicatorBtn] = "TRUE";
00155 Key[ShowDataWindowBtn] = "Preferences/ShowDataWindowBtn";
00156 Def[ShowDataWindowBtn] = "TRUE";
00157 Key[ShowMainQuoteBtn] = "Preferences/ShowMainQuoteBtn";
00158 Def[ShowMainQuoteBtn] = "TRUE";
00159 Key[ShowHelpButton] = "Preferences/ShowHelpButton";
00160 Def[ShowHelpButton] = "TRUE";
00161 Key[ShowSlider] = "Preferences/ShowSlider";
00162 Def[ShowSlider] = "TRUE";
00163 Key[ShowBarsToLoadField] = "Preferences/ShowBarsToLoadField";
00164 Def[ShowBarsToLoadField] = "TRUE";
00165 Key[ShowBarSpSpinbox] = "Preferences/ShowBarSpSpinbox";
00166 Def[ShowBarSpSpinbox] = "TRUE";
00167 Key[ShowCmps15Btn] = "Preferences/ShowCmps15Btn";
00168 Def[ShowCmps15Btn] = "FALSE";
00169 Key[ShowCmpsDayBtn] = "Preferences/ShowCmpsDayBtn";
00170 Def[ShowCmpsDayBtn] = "TRUE";
00171 Key[ShowCmpsWkyBtn] = "Preferences/ShowCmpsWkyBtn";
00172 Def[ShowCmpsWkyBtn] = "TRUE";
00173 Key[ShowCmpsMtyBtn] = "Preferences/ShowCmpsMtyBtn";
00174 Def[ShowCmpsMtyBtn] = "TRUE";
00175 Key[ShowCmpsComboBox] = "Preferences/ShowCmpsComboBox";
00176 Def[ShowCmpsComboBox] = "TRUE";
00177 Key[PrefColorCount] = "Preferences/PrefColorCount";
00178 Def[PrefColorCount] = "5";
00179 Key[PrefColor] = "Preferences/PrefColor";
00180 Def[PrefColor] = "#ffffff";
00181 Key[ShowRecentCharts] = "Preferences/ShowRecentCharts";
00182 Def[ShowRecentCharts] = "TRUE";
00183 Key[LastAktiveNav] = "LastAktiveNav";
00184 Def[LastAktiveNav] = "";
00185 Key[LastGroupUsed] = "LastGroupUsed";
00186 Def[LastGroupUsed] = "";
00187 Key[LastChartDir] = "LastChartDir";
00188 Def[LastChartDir] = "";
00189 Key[LastIndicatorUsed] = "LastIndicatorUsed";
00190 Def[LastIndicatorUsed] = "";
00191 Key[LastDateTimeCOAdded] = "LastDateTimeCOAdded";
00192 Def[LastDateTimeCOAdded] = "";
00193 Key[MainToolBarPos] = "MainToolBarPos";
00194 Def[MainToolBarPos] = "";
00195 Key[ChartToolBarPos] = "ChartToolBarPos";
00196 Def[ChartToolBarPos] = "";
00197 Key[NavigatorPosition] = "NavigatorPosition";
00198 Def[NavigatorPosition] = "1";
00199 Key[NavigatorActiveButton] = "NavigatorActiveButton";
00200 Def[NavigatorActiveButton] = "0";
00201 Key[RecentChartsList] = "RecentChartsList";
00202 Def[RecentChartsList] = "";
00203
00204
00205
00206
00207
00208
00209 }
00210
00211 RcFile::~RcFile ()
00212 {
00213 }
00214
00215
00216
00217
00218
00219
00220 void RcFile::loadData (Parm name, QString &value, const QString &s)
00221 {
00222 QString k;
00223 k.append("/Qtstalker/");
00224 k.append(Key[name]);
00225 k.append(s);
00226
00227 value = Def[name];
00228
00229 QSettings settings;
00230 value = settings.readEntry(k, value);
00231 }
00232
00233 void RcFile::loadData (Parm name, QString &value, const int n)
00234 {
00235 QString s;
00236 if (n > -1) s.append(QString::number(n));
00237 loadData(name, value, s);
00238 }
00239
00240 void RcFile::loadData (Parm name, int &value, const int n)
00241 {
00242 QString k;
00243 k.append("/Qtstalker/");
00244 k.append(Key[name]);
00245 if (n > -1) k.append(QString::number(n));
00246
00247 QString v = Def[name];
00248 value = v.toInt();
00249
00250 QSettings settings;
00251 value = settings.readNumEntry(k, value);
00252 }
00253
00254 void RcFile::loadData (Parm name, bool &value)
00255 {
00256 QString k;
00257 k.append("/Qtstalker/");
00258 k.append(Key[name]);
00259
00260 if (Def[name] == "TRUE") value = TRUE;
00261 else value = FALSE;
00262
00263 QSettings settings;
00264 value = settings.readBoolEntry(k, value);
00265 }
00266
00267 void RcFile::saveData (Parm name, QString &value, const QString &s)
00268 {
00269 QString k;
00270 k.append("/Qtstalker/");
00271 k.append(Key[name]);
00272 k.append(s);
00273
00274 QSettings settings;
00275 settings.writeEntry(k, value);
00276 }
00277
00278 void RcFile::saveData (Parm name, QString &value, const int n)
00279 {
00280 QString s;
00281 if (n > -1) s.append(QString::number(n));
00282 saveData(name, value, s);
00283 }
00284
00285 void RcFile::saveData (Parm name, int value, const int n)
00286 {
00287 QString k;
00288 k.append("/Qtstalker/");
00289 k.append(Key[name]);
00290 if (n > -1) k.append(QString::number(n));
00291
00292 QSettings settings;
00293 settings.writeEntry(k, value);
00294 }
00295
00296 void RcFile::saveData (Parm name, const bool value)
00297 {
00298 QString k;
00299 k.append("/Qtstalker/");
00300 k.append(Key[name]);
00301
00302 QSettings settings;
00303 settings.writeEntry(k, value);
00304 }
00305
00306
00307
00308
00309 void RcFile::loadColor (Parm name, QColor &color)
00310 {
00311 QString c;
00312 loadData(name, c);
00313 color.setNamedColor(c);
00314 }
00315
00316 void RcFile::loadColor (Parm name, QColor &color, const int n)
00317 {
00318 QString c;
00319 loadData(name, c, n);
00320 color.setNamedColor(c);
00321 }
00322
00323 void RcFile::saveColor (Parm name, QColor &color)
00324 {
00325 QString c = color.name();
00326 saveData(name, c);
00327 }
00328
00329 void RcFile::saveColor (Parm name, QColor &color, const int n)
00330 {
00331 QString c = color.name();
00332 saveData(name, c, n);
00333 }
00334
00335 void RcFile::loadFont (Parm name, QFont &font)
00336 {
00337 QString f;
00338
00339 loadData(name, f);
00340
00341 QStringList l = QStringList::split(",", f, FALSE);
00342
00343 font.setFamily(l[0]);
00344 font.setPointSize(l[1].toInt());
00345 font.setWeight(l[2].toInt());
00346 font.setItalic(l[3].toInt());
00347 font.setBold(l[4].toInt());
00348 }
00349
00350 void RcFile::saveFont (Parm name, QFont &font)
00351 {
00352 QString f =font.family() + "," +
00353 QString::number(font.pointSize()) + "," +
00354 QString::number(font.weight()) + "," +
00355 QString::number(font.italic ()) + "," +
00356 QString::number(font.bold ());
00357
00358 saveData(name, f);
00359 }
00360
00361 void RcFile::loadSplitterSize (Parm name, QSplitter *sp, const QString &n)
00362 {
00363 QString s;
00364 loadData(name, s, n);
00365
00366 QStringList stringList = QStringList::split(",", s, FALSE);
00367 QValueList<int> sizeList = sp->sizes();
00368
00369 int loop;
00370 for (loop = 0; loop < (int) stringList.count(); loop++)
00371 sizeList[loop] = stringList[loop].toInt();
00372
00373 sp->setSizes(sizeList);
00374 }
00375
00376 void RcFile::saveSplitterSize (Parm name, QSplitter *sp, const QString &n)
00377 {
00378 QStringList stringList;
00379 QValueList<int> sizeList = sp->sizes();
00380
00381 int loop;
00382 for (loop = 0; loop < (int) sizeList.count(); loop++)
00383 stringList.append(QString::number(sizeList[loop]));
00384
00385 QString s(stringList.join(","));
00386 saveData(name, s, n);
00387 }
00388
00389 void RcFile::loadPoint (Parm name, QPoint &p, const int n)
00390 {
00391 QString s;
00392 loadData(name, s, n);
00393
00394 QStringList l = QStringList::split(",", s, FALSE);
00395 p.setX(l[0].toInt());
00396 p.setY(l[1].toInt());
00397 }
00398
00399 void RcFile::savePoint (Parm name, const QPoint &p, const int n)
00400 {
00401 QString s = QString::number(p.x()) + "," + QString::number(p.y());
00402
00403 saveData(name, s, n);
00404 }
00405
00406 void RcFile::loadSize (Parm name, QSize &sz, const int n)
00407 {
00408 QString s;
00409 loadData(name, s, n);
00410
00411 QStringList l = QStringList::split(",", s, FALSE);
00412 sz.setWidth (l[0].toInt());
00413 sz.setHeight(l[1].toInt());
00414 }
00415
00416 void RcFile::saveSize (Parm name, const QSize &sz, const int n)
00417 {
00418 QString s = QString::number(sz.width()) + "," + QString::number(sz.height());
00419
00420 saveData(name, s, n);
00421 }