lib/RcFile.h

Go to the documentation of this file.
00001 /*
00002  *  Qtstalker stock charter
00003  * 
00004  *  Copyright (C) 2001-2007 Stefan S. Stratigakos
00005  * 
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
00019  *  USA.
00020  */
00021 
00022 
00023 #ifndef RCFILE_HPP
00024 #define RCFILE_HPP
00025 
00026 #include <qstring.h>
00027 #include <qcolor.h>
00028 #include <qfont.h>
00029 #include <qsplitter.h>
00030 #include <qpoint.h>
00031 #include <qsize.h>
00032 
00033 /**
00034 * @brief Handle the storage and retrieval of configuration information and
00035 * application settings.
00036 *
00037 * <p>On most platforms they are stored in the ~/.qt/qtstalkerrc plain-text file.
00038 * On "Mac OS X" they are stored in a binary plist.</p>
00039 *
00040 * <p>See the Trolltech QSettings documentation and Qtstalker <a href="../dev.html">developer</a> documentation.</p>
00041 *
00042 * \todo
00043 * It is intended to replace the according functions 
00044 * located in the Config class. Because Config do more than
00045 * only read/write stettings to and from the rc-file.
00046 * But Config is often used/included to do only this.
00047 */
00048 class RcFile
00049 {
00050   public:
00051     
00052      /** Constructor. */
00053      RcFile ();
00054      /** Destructor. */
00055     ~RcFile ();
00056  
00057     /** Available parameters. */
00058     enum Parm
00059     {
00060       Home,
00061       DataPath,
00062       Pixelspace,
00063       BarLength,
00064       Grid,
00065       BarsToLoad,
00066       BackgroundColor,
00067       BorderColor,
00068       GridColor,
00069       PaperTradeMode,
00070       IndicatorPath,
00071       Crosshairs,
00072       DrawMode,
00073       DataPanelSize,
00074       ScaleToScreen,
00075       QuotePluginPath,
00076       GroupPath,
00077       PortfolioPath,
00078       TestPath,
00079       PlotFont,
00080       AppFont,
00081       NavAreaSize,
00082       LogScale,
00083  /*     PS1Button, // deprecated
00084       PS2Button, //  "
00085       PS3Button, //  "
00086    */   IndexPath,
00087       HelpFilePath,
00088       UserDocsPath,
00089       LastQuotePlugin,
00090       MainWindowSize,
00091       MainWindowPos,
00092       PrefDlgWindowSize,
00093       EditStockWindowSize,
00094       HelpWindowSize,
00095       BackTesterWindowSize,
00096       ScannerWindowSize,
00097       ScannerPath,
00098       Version,
00099       PlotSizes,
00100       ShowMenuBar,
00101       ShowExtraToolbar,
00102       COPath,
00103       LocalIndicatorsPath,
00104       FundamentalsPath,
00105       CurrentChart,
00106       IndicatorGroup,
00107       QuotePluginStorage,
00108       LastNewIndicator,
00109       PSButtonCount,  // not yet used
00110       PSButton,
00111       ShowSidePanel,
00112       ShowQuitBtn,
00113       ShowPrefBtn,
00114       ShowSidePanelBtn,
00115       ShowGridBtn,
00116       ShowScaleToScreenBtn,
00117       ShowCrosshairBtn,
00118       ShowPaperTradeBtn,
00119       ShowDrawModeBtn,
00120       ShowNewIndicatorBtn,
00121       ShowDataWindowBtn,
00122       ShowMainQuoteBtn,
00123       ShowHelpButton,
00124       ShowSlider,
00125       ShowBarsToLoadField,
00126       ShowBarSpSpinbox,
00127       ShowCmps15Btn,
00128       ShowCmpsDayBtn,
00129       ShowCmpsWkyBtn,
00130       ShowCmpsMtyBtn,
00131       ShowCmpsComboBox,
00132       PrefColorCount,
00133       PrefColor,
00134       ShowRecentCharts,
00135       LastAktiveNav,
00136       LastGroupUsed,
00137       LastChartDir,
00138       LastIndicatorUsed,
00139       LastDateTimeCOAdded,
00140       IndiGroupSplitterSize,
00141       MainToolBarPos,
00142       ChartToolBarPos,
00143       NavigatorPosition,
00144       NavigatorActiveButton,
00145       RecentChartsList,
00146       MAX_PARM  // keep this at the end
00147     };
00148   
00149   private:
00150     char *Key[MAX_PARM];
00151     char *Def[MAX_PARM]; // default values
00152     
00153   public:
00154    
00155     // public functions, no string as "Parm" allowed
00156     // to prevent mismatch in the rc-file
00157     
00158     // for any kind of data
00159     void loadData (Parm, QString &, const QString & = 0);
00160     void loadData (Parm, QString &, const int);
00161     void loadData (Parm, int &, const int = -1);
00162     void loadData (Parm, bool &);
00163     
00164     void saveData (Parm, QString &, const QString & = 0);
00165     void saveData (Parm, QString &, const int);
00166     void saveData (Parm, int, const int = -1);
00167     void saveData (Parm, const bool);
00168     
00169     // for special purposes
00170     void loadColor (Parm, QColor &);
00171     void loadColor (Parm, QColor &, const int);
00172     
00173     void saveColor (Parm, QColor &);
00174     void saveColor (Parm, QColor &, const int);
00175     
00176     void loadFont (Parm, QFont &);
00177     void saveFont (Parm, QFont &);
00178     
00179     void loadSplitterSize (Parm, QSplitter *, const QString & = 0);
00180     void saveSplitterSize (Parm, QSplitter *, const QString & = 0);
00181     
00182     void loadPoint (Parm, QPoint &, const int = -1);
00183     void savePoint (Parm, const QPoint &, const int = -1);
00184     
00185     void loadSize (Parm, QSize &, const int = -1);
00186     void saveSize (Parm, const QSize &, const int = -1);
00187     
00188   private:
00189     // DON'T WORK! runs in strange trouble
00190     // in case of interlaced use
00191     // QSettings settings;
00192 };
00193 
00194 #endif
00195