Diffstat (limited to 'kabc/plugins/qtopia/qtopiaconverter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/plugins/qtopia/qtopiaconverter.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp index 106596f..39d366b 100644 --- a/kabc/plugins/qtopia/qtopiaconverter.cpp +++ b/kabc/plugins/qtopia/qtopiaconverter.cpp @@ -1,170 +1,168 @@ /* This file is part of libkabc. Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ //US #include "kglobal.h" #include "klocale.h" #include "qtopiaconverter.h" #include <qfile.h> #include <qdir.h> #include <qtextstream.h> //#include <.h> -//#include <qpe/categories.h> #include <libkdepim/ksyncprofile.h> -//US #include <qpe/categoryselect.h> using namespace KABC; QtopiaConverter::QtopiaConverter() { m_edit = 0; } QtopiaConverter::~QtopiaConverter() { deinit(); } bool QtopiaConverter::init() { QString fn = QDir::homeDirPath() +"/Settings/Categories.xml"; m_edit = new CategoryEdit( fn); return true; } void QtopiaConverter::deinit() { if (m_edit) { delete m_edit; m_edit = 0; } } QString QtopiaConverter::categoriesToNumber( const QStringList &list, const QString &app ) { startover: QStringList dummy; QValueList<OpieCategories>::ConstIterator catIt; QValueList<OpieCategories> categories = m_edit->categories(); bool found = false; for ( QStringList::ConstIterator listIt = list.begin(); listIt != list.end(); ++listIt ) { /* skip empty category name */ if ( (*listIt).isEmpty() ) continue; found = false; for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { /* * We currently do not take app into account * if name matches and the id isn't already in dummy we'll add it */ if ( (*catIt).name() == (*listIt) && !dummy.contains(( *catIt).id() ) ) { // the same name found= true; dummy << (*catIt).id(); } } /* if not found and the category is not empty * * generate a new category and start over again * ugly goto to reiterate */ if ( !found && !(*listIt).isEmpty() ){ m_edit->addCategory( app, (*listIt) ); // generate a new category goto startover; } } return dummy.join(";"); } // FROM TT timeconversion.cpp GPLed QDate QtopiaConverter::fromString( const QString &datestr ) { if (datestr.isEmpty() ) return QDate(); int monthPos = datestr.find('.'); int yearPos = datestr.find('.', monthPos+1 ); if ( monthPos == -1 || yearPos == -1 ) { return QDate(); } int d = datestr.left( monthPos ).toInt(); int m = datestr.mid( monthPos+1, yearPos - monthPos - 1 ).toInt(); int y = datestr.mid( yearPos+1 ).toInt(); QDate date ( y,m,d ); return date; } QDate QtopiaConverter::dateFromString( const QString& s ) { QDate date; if ( s.isEmpty() ) return date; // Be backward compatible to old Opie format: // Try to load old format. If it fails, try new ISO-Format! date = fromString ( s ); if ( date.isValid() ) return date; // Read ISO-Format (YYYYMMDD) int year = s.mid(0, 4).toInt(); int month = s.mid(4,2).toInt(); int day = s.mid(6,2).toInt(); // do some quick sanity checking if ( year < 1900 || year > 3000 ) return date; if ( month < 0 || month > 12 ) return date; if ( day < 0 || day > 31 ) return date; date.setYMD( year, month, day ); if ( !date.isValid() ) return QDate(); return date; } QString QtopiaConverter::dateToString( const QDate &d ) { if ( d.isNull() || !d.isValid() ) return QString::null; |