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

configdlg.cpp

Go to the documentation of this file.
00001 #include "configdlg.h"
00002 
00003 #include <opie2/odebug.h>
00004 #include <opie2/opimcontact.h>
00005 #include <opie2/opimcontactfields.h>
00006 #include <opie2/oresource.h>
00007 
00008 #include <qcheckbox.h>
00009 #include <qradiobutton.h>
00010 #include <qlistbox.h>
00011 #include <qpushbutton.h>
00012 
00013 ConfigDlg::ConfigDlg( QWidget *parent, const char *name):
00014         ConfigDlg_Base(parent, name, true )
00015 {
00016         contFields = Opie::OPimContactFields::trfields();
00017 
00018         // We add all Fields into the Listbox
00019         for (uint i=0; i < contFields.count(); i++) {
00020                 allFieldListBox->insertItem( contFields[i] );
00021         }
00022 
00023         // Reset Widget Flags: This was not changeable by designer :(
00024         setWFlags ( WStyle_ContextHelp );
00025 
00026         // Set Pics to Buttons and Tabs
00027         m_upButton->setPixmap( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) );
00028         m_downButton->setPixmap( Opie::Core::OResource::loadPixmap( "down", Opie::Core::OResource::SmallIcon ) );
00029         m_addButton->setPixmap( Opie::Core::OResource::loadPixmap( "addressbook/add", Opie::Core::OResource::SmallIcon ) );
00030         m_removeButton->setPixmap( Opie::Core::OResource::loadPixmap( "addressbook/sub", Opie::Core::OResource::SmallIcon ) );
00031 
00032         // Get the translation maps between Field ID and translated strings
00033         m_mapStrToID = Opie::OPimContactFields::trFieldsToId();
00034         m_mapIDToStr = Opie::OPimContactFields::idToTrFields();
00035 
00036         connect ( m_addButton, SIGNAL( clicked() ), this, SLOT( slotItemAdd() ) );
00037         connect ( m_removeButton, SIGNAL( clicked() ), this, SLOT( slotItemRemove() ) );
00038         connect ( m_upButton, SIGNAL( clicked() ), this, SLOT( slotItemUp() ) );
00039         connect ( m_downButton, SIGNAL( clicked() ), this, SLOT( slotItemDown() ) );
00040 }
00041 
00042 void ConfigDlg::slotItemUp()
00043 {
00044         odebug << "void ConfigDlg::slotItemUp()" << oendl;
00045 
00046         int i = fieldListBox->currentItem();
00047         if ( i > 0 ) {
00048                 QString item = fieldListBox->currentText();
00049                 fieldListBox->removeItem( i );
00050                 fieldListBox->insertItem( item, i-1 );
00051                 fieldListBox->setCurrentItem( i-1 );
00052         }
00053 
00054 }
00055 
00056 void ConfigDlg::slotItemDown()
00057 {
00058         odebug << "void ConfigDlg::slotItemDown()" << oendl;
00059 
00060         int i = fieldListBox->currentItem();
00061         if ( i < (int)fieldListBox->count() - 1 ) {
00062                 QString item = fieldListBox->currentText();
00063                 fieldListBox->removeItem( i );
00064                 fieldListBox->insertItem( item, i+1 );
00065                 fieldListBox->setCurrentItem( i+1 );
00066         }
00067 }
00068 
00069 void ConfigDlg::slotItemAdd()
00070 {
00071         odebug << "void ConfigDlg::slotItemAdd()" << oendl;
00072 
00073         int i = allFieldListBox->currentItem();
00074         if ( i > 0 ) {
00075                 QString item = allFieldListBox->currentText();
00076                 odebug << "Adding " << item << oendl;
00077                 fieldListBox->insertItem( item );
00078         }
00079 }
00080 
00081 void ConfigDlg::slotItemRemove()
00082 {
00083         odebug << "void ConfigDlg::slotItemRemove()" << oendl;
00084 
00085         int i = fieldListBox->currentItem();
00086         if ( i > 0 ) {
00087                 fieldListBox->removeItem( i );
00088         }
00089 }
00090 
00091 void ConfigDlg::setConfig( const AbConfig& cnf )
00092 {
00093         m_config = cnf;
00094 
00095         m_useRegExp->setChecked( m_config.useRegExp() );
00096         m_useWildCard->setChecked( m_config.useWildCards() );
00097         m_useQtMail->setChecked( m_config.useQtMail() );
00098         m_useOpieMail->setChecked( m_config.useOpieMail() );
00099         m_useCaseSensitive->setChecked( m_config.beCaseSensitive() );
00100 
00101         switch( m_config.fontSize() ){
00102         case 0:
00103                 m_smallFont->setChecked( true );
00104                 m_normalFont->setChecked( false );
00105                 m_largeFont->setChecked( false );
00106                 break;
00107         case 1:
00108                 m_smallFont->setChecked( false );
00109                 m_normalFont->setChecked( true );
00110                 m_largeFont->setChecked( false );
00111                 break;
00112         case 2:
00113                 m_smallFont->setChecked( false );
00114                 m_normalFont->setChecked( false );
00115                 m_largeFont->setChecked( true );
00116                 break;
00117         }
00118 
00119         for( uint i = 0; i < m_config.orderList().count(); i++ ) {
00120                 fieldListBox -> insertItem ( m_mapIDToStr[ m_config.orderList()[i] ] );
00121         }
00122 
00123         m_fixedBars->setChecked( m_config.fixedBars() );
00124         m_moveBars->setChecked( !m_config.fixedBars() );
00125 }
00126 
00127 AbConfig ConfigDlg::getConfig()
00128 {
00129         m_config.setUseRegExp( m_useRegExp->isOn() );
00130         m_config.setUseWildCards( m_useWildCard->isOn() );
00131         m_config.setUseQtMail( m_useQtMail->isOn() );
00132         m_config.setUseOpieMail( m_useOpieMail->isOn() );
00133         m_config.setBeCaseSensitive( m_useCaseSensitive->isChecked() );
00134 
00135         if ( m_smallFont->isChecked() )
00136                 m_config.setFontSize( 0 );
00137         if ( m_normalFont->isChecked() )
00138                 m_config.setFontSize( 1 );
00139         if ( m_largeFont->isChecked() )
00140                 m_config.setFontSize( 2 );
00141 
00142         QValueList<int> orderlist;
00143         for( int i = 0; i < (int)fieldListBox->count(); i++ ) {
00144                 orderlist.append( m_mapStrToID[ fieldListBox->text(i) ] );
00145         }
00146         m_config.setOrderList( orderlist );
00147 
00148         m_config.setFixedBars( m_fixedBars->isChecked() );
00149 
00150         return m_config;
00151 }
00152 

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