Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

abconfig.cpp

Go to the documentation of this file.
00001 #include "abconfig.h"
00002 #include "version.h"
00003 
00004 #include <qpe/config.h>
00005 #include <qpe/recordfields.h>
00006 
00007 AbConfig::AbConfig( ):
00008         m_useQtMail( false ),
00009         m_useOpieMail( true ),
00010         m_useRegExp( false ),
00011         m_beCaseSensitive( false ),
00012         m_fontSize( 1 ),
00013         m_barPos( QMainWindow::Top ),
00014         m_fixedBars( true ),
00015         m_lpSearchMode( LastName ),
00016         m_changed( false )
00017 {
00018 }
00019 
00020 AbConfig::~AbConfig()
00021 {
00022 }
00023 
00024 bool AbConfig::useRegExp() const
00025 {
00026         return m_useRegExp;
00027 }
00028 bool AbConfig::useWildCards() const
00029 {
00030         return !m_useRegExp;
00031 }
00032 bool AbConfig::useQtMail() const
00033 {
00034         return m_useQtMail;
00035 }
00036 bool AbConfig::useOpieMail() const
00037 {
00038         return m_useOpieMail;
00039 }
00040 bool AbConfig::beCaseSensitive() const
00041 {
00042         return m_beCaseSensitive;
00043 }
00044 int AbConfig::fontSize() const
00045 {
00046         return m_fontSize;
00047 }
00048 
00049 QValueList<int> AbConfig::orderList() const
00050 {
00051         return m_ordered;
00052 }
00053 
00054 QMainWindow::ToolBarDock AbConfig::getToolBarPos() const
00055 {
00056         return (QMainWindow::ToolBarDock) m_barPos;
00057 }
00058 
00059 bool AbConfig::fixedBars() const
00060 {
00061         return m_fixedBars;
00062 }
00063 
00064 AbConfig::LPSearchMode AbConfig::letterPickerSearch() const
00065 {
00066         return ( AbConfig::LPSearchMode ) m_lpSearchMode;
00067 }
00068 
00069 const QString &AbConfig::category() const
00070 {
00071     return m_category;
00072 }
00073 
00074 void AbConfig::setUseRegExp( bool v )
00075 {
00076         m_useRegExp = v ;
00077         m_changed = true;
00078 }
00079 void AbConfig::setUseWildCards( bool v )
00080 {
00081         m_useRegExp = !v;
00082         m_changed = true;
00083 }
00084 void AbConfig::setBeCaseSensitive( bool v )
00085 {
00086         m_beCaseSensitive = v;
00087         m_changed = true;
00088 }
00089 void AbConfig::setUseQtMail( bool v )
00090 {
00091         m_useQtMail = v;
00092         m_changed = true;
00093 }
00094 void AbConfig::setUseOpieMail( bool v )
00095 {
00096         m_useOpieMail = v;
00097         m_changed = true;
00098 }
00099 void AbConfig::setFontSize( int v )
00100 {
00101         m_fontSize = v;
00102         m_changed = true;
00103 }
00104 
00105 void AbConfig::setOrderList( const QValueList<int>& list )
00106 {
00107         m_ordered = list;
00108         m_changed = true;
00109 }
00110 
00111 void AbConfig::setToolBarDock( const QMainWindow::ToolBarDock v )
00112 {
00113         m_barPos = v;
00114         m_changed = true;
00115 }
00116 
00117 void AbConfig::setFixedBars( const bool fixed )
00118 {
00119         m_fixedBars = fixed;
00120         m_changed = true;
00121 }
00122 
00123 void AbConfig::setLetterPickerSearch( const AbConfig::LPSearchMode mode )
00124 {
00125         m_lpSearchMode = mode;
00126         m_changed = true;
00127 }
00128 
00129 void AbConfig::setCategory( const QString &cat )
00130 {
00131     m_category = cat;
00132 }
00133 
00134 void AbConfig::load()
00135 {
00136         // Read Config settings
00137         Config cfg("AddressBook");
00138 
00139     cfg.setGroup( "View" );
00140     m_category = cfg.readEntry( "Category", "All" );
00141 
00142         cfg.setGroup("Font");
00143         m_fontSize = cfg.readNumEntry( "fontSize", 1 );
00144 
00145         cfg.setGroup("Search");
00146         m_useRegExp = cfg.readBoolEntry( "useRegExp", false );
00147         m_beCaseSensitive = cfg.readBoolEntry( "caseSensitive", false );
00148         m_lpSearchMode = cfg.readNumEntry( "lpSearchMode", FileAs );
00149 
00150         cfg.setGroup("Mail");
00151         m_useQtMail = cfg.readBoolEntry( "useQtMail", false );
00152         m_useOpieMail = cfg.readBoolEntry( "useOpieMail", true );
00153 
00154         cfg.setGroup("ContactOrder");
00155         int ID = 0;
00156         int i = 0;
00157         ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 );
00158         while ( ID != 0 ){
00159                 m_ordered.append( ID );
00160                 ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 );
00161         }
00162 
00163         // If no contact order is defined, we set the default
00164         if ( m_ordered.count() == 0 ) {
00165                 m_ordered.append( Qtopia::DefaultEmail );
00166                 m_ordered.append( Qtopia::HomePhone);
00167                 m_ordered.append( Qtopia::HomeMobile);
00168                 m_ordered.append( Qtopia::BusinessPhone);
00169         }
00170 
00171         cfg.setGroup("ToolBar");
00172         m_barPos = cfg.readNumEntry( "Position", QMainWindow::Top );
00173         m_fixedBars= cfg.readBoolEntry( "fixedBars", true );
00174 
00175         m_changed = false;
00176 }
00177 
00178 void AbConfig::save()
00179 {
00180         if ( m_changed ){
00181                 Config cfg("AddressBook");
00182         cfg.setGroup( "View" );
00183         cfg.writeEntry( "Category", m_category );
00184 
00185                 cfg.setGroup("Font");
00186                 cfg.writeEntry("fontSize", m_fontSize);
00187 
00188                 cfg.setGroup("Search");
00189                 cfg.writeEntry("useRegExp", m_useRegExp);
00190                 cfg.writeEntry("caseSensitive", m_beCaseSensitive);
00191                 cfg.writeEntry("lpSearchMode", m_lpSearchMode );
00192 
00193                 cfg.setGroup("Mail");
00194                 cfg.writeEntry( "useQtMail", m_useQtMail );
00195                 cfg.writeEntry( "useOpieMail", m_useOpieMail);
00196 
00197                 cfg.setGroup("ContactOrder");
00198                 cfg.clearGroup();
00199                 for ( uint i = 0; i < m_ordered.count(); i++ ){
00200                         cfg.writeEntry( "ContactID_"+QString::number(i), m_ordered[i] );
00201                 }
00202 
00203                 cfg.setGroup("ToolBar");
00204                 cfg.writeEntry( "Position", m_barPos );
00205                 cfg.writeEntry( "fixedBars", m_fixedBars );
00206 
00207                 cfg.setGroup("Version");
00208                 cfg.writeEntry( "AppName", APPNAME + QString(" V" ) + MAINVERSION + QString(".") + SUBVERSION + QString(".") + PATCHVERSION);
00209                 cfg.writeEntry( "Mainversion", MAINVERSION );
00210                 cfg.writeEntry( "SubVersion", SUBVERSION );
00211                 cfg.writeEntry( "PatchVersion", PATCHVERSION );
00212 
00213         }
00214 
00215 }
00216 
00217 void AbConfig::operator= ( const AbConfig& cnf )
00218 {
00219         m_useQtMail = cnf.m_useQtMail;
00220         m_useOpieMail = cnf.m_useOpieMail;
00221         m_useRegExp = cnf.m_useRegExp;
00222         m_beCaseSensitive = cnf.m_beCaseSensitive;
00223         m_fontSize = cnf.m_fontSize;
00224         m_ordered = cnf.m_ordered;
00225         m_barPos = cnf.m_barPos;
00226         m_fixedBars = cnf.m_fixedBars;
00227         m_lpSearchMode = cnf.m_lpSearchMode;
00228 }
00229 

Generated on Sat Nov 5 16:15:45 2005 for OPIE by  doxygen 1.4.2