• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kmobiletools

picksmscenter.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002    Copyright (C) 2007
00003    by Marco Gulino <marco@kmobiletools.org>
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 2 of the License, or
00008    (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the
00017    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019  ***************************************************************************/
00020 #include "picksmscenter.h"
00021 #include "kmobiletoolshelper.h"
00022 
00023 #include <qlayout.h>
00024 #include <klocale.h>
00025 #include <kconfig.h>
00026 #include <k3listviewsearchline.h>
00027 #include <k3listview.h>
00028 #include <kglobal.h>
00029 #include <kstandarddirs.h>
00030 #include <kmessagebox.h>
00031 
00032 using namespace KMobileTools;
00033 
00034 namespace KMobileTools {
00035 
00036 class PickSMSCenterPrivate {
00037     public:
00038         PickSMSCenterPrivate()
00039     : listview(NULL), config(NULL) {}
00040 
00041     K3ListView *listview;
00042     QString s_smsCenter;
00043     KConfig *config;
00044 };
00045 
00046 
00047 PickSMSCenter::PickSMSCenter(QWidget *parent)
00048     : KDialog(parent), d(new PickSMSCenterPrivate)
00049 {
00050     setCaption( i18nc( "Pick SMS Center from list", "Choose Your Operator SMS Center") );
00051     setButtons( Ok | Cancel );
00052     enableButtonOk (false);
00053     QVBoxLayout *lay=new QVBoxLayout(mainWidget());
00054     K3ListViewSearchLineWidget *slwidget=new K3ListViewSearchLineWidget( 0, this);
00055     lay->addWidget(slwidget);
00056     d->listview=new K3ListView(this);
00057     lay->addWidget(d->listview);
00058     d->listview->addColumn( i18nc("Network name for SMS Center", "Network Name") );
00059     d->listview->addColumn( i18nc("SMS Center number", "Number") );
00060     connect(d->listview, SIGNAL(clicked( Q3ListViewItem* )), this, SLOT(clicked( Q3ListViewItem* ) ) );
00061     connect(d->listview, SIGNAL(doubleClicked( Q3ListViewItem*, const QPoint&, int ) ), this, SLOT(doubleClicked( Q3ListViewItem*, const QPoint&, int )) );
00062     slwidget->createSearchLine(d->listview);
00063     resize(400,500);
00064     initList();
00065 }
00066 
00067 
00068 PickSMSCenter::~PickSMSCenter()
00069 {
00070     delete d;
00071 }
00072 
00073 
00074 #include "picksmscenter.moc"
00075 
00076 
00080 void PickSMSCenter::initList()
00081 {
00082     QString file=KGlobal::dirs()->findResource( "data", "kmobiletools/operatorsdata" );
00083     if(file.isNull() )
00084     {
00085         KMessageBox::error( this, i18n("Operators data not found.") );
00086         return;
00087     }
00088 
00089     d->config=new KConfig( file, KConfig::NoGlobals );
00090     QStringList operators=d->config->groupList();
00091     for(QStringList::Iterator it=operators.begin(); it!=operators.end(); ++it)
00092     {
00093         const KConfigGroup cg( d->config, *it );
00094         if(cg.readEntry( "smscenter").isNull() ) continue;
00095         new K3ListViewItem(d->listview, *it, cg.readEntry( "smscenter") );
00096     }
00097     delete d->config;
00098 }
00099 
00100 
00104 void PickSMSCenter::clicked ( Q3ListViewItem * item )
00105 {
00106     if(!item )
00107     {
00108         enableButtonOk(false);
00109         d->s_smsCenter.clear();
00110         return;
00111     }
00112     enableButtonOk( true );
00113     d->s_smsCenter=item->text(1);
00114 }
00115 
00116 
00120 void PickSMSCenter::doubleClicked( Q3ListViewItem *item, const QPoint &, int )
00121 {
00122     clicked(item);
00123     if(!item)return;
00124     done(Accepted);
00125 }
00126 
00127 const QString PickSMSCenter::smsCenter() { return d->s_smsCenter;}
00128 
00129 
00133 QString PickSMSCenter::smsCenterName(const QString &smsCenter)
00134 {
00135     QString file=KGlobal::dirs()->findResource( "data", "kmobiletools/operatorsdata" );
00136 //     if(file.isNull() ) return smsCenter;
00137 
00138     KConfig *config=new KConfig( file, KConfig::NoGlobals );
00139     QStringList operators=config->groupList();
00140     for(QStringList::Iterator it=operators.begin(); it!=operators.end(); ++it)
00141     {
00142         const KConfigGroup cg( config, *it );
00143         if( KMobileTools::KMobiletoolsHelper::compareNumbers( cg.readEntry( "smscenter"), smsCenter ) )
00144         {
00145             delete config;
00146             return *it;
00147         }
00148     }
00149     delete config;
00150     return smsCenter;
00151 }
00152 
00153 }

kmobiletools

Skip menu "kmobiletools"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal