kitchensync Library API Documentation

desktop.cpp

00001 /* 00002 This file is part of KitchenSync. 00003 00004 Copyright (c) 2002,2003 Holger Freyther <freyther@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library 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 GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. 00020 */ 00021 00022 #include <qregexp.h> 00023 00024 #include "desktop.h" 00025 00026 using namespace OpieHelper; 00027 00028 Desktop::Desktop( CategoryEdit* edit ) 00029 : Base( edit ) { 00030 00031 00032 } 00033 Desktop::~Desktop() { 00034 00035 } 00036 KSync::OpieDesktopSyncee* Desktop::toSyncee( const QString& str) { 00037 KSync::OpieDesktopSyncee* syncee; 00038 syncee = new KSync::OpieDesktopSyncee(); 00039 00040 // convert the string 00041 QString string ( str ); 00042 string.remove(0, 35 ); 00043 string.replace(QRegExp("&amp;"), "&" ); 00044 string.replace(QRegExp("&0x20;"), " "); 00045 string.replace(QRegExp("&0x0d;"), "\n"); 00046 string.replace(QRegExp("&0x0a;"), "\r"); 00047 string.replace(QRegExp("\r\n"), "\n" ); // hell we're on unix 00048 00049 if ( !str.contains("[Desktop Entry]") ) { 00050 kdDebug(5224) <<"Desktop Entry: " << str << endl; 00051 delete syncee; 00052 return 0l; 00053 } 00054 QStringList list = QStringList::split('\n', string ); 00055 QStringList::Iterator it; 00056 it = list.begin(); 00057 list.remove( it ); // remove the [Desktop Entry] 00058 00059 KSync::OpieDesktopSyncEntry *entry; 00060 QString name, type, fileName, size; 00061 QStringList category; 00062 00063 for ( it = list.begin(); it != list.end(); ++it ) { // QAsciiDict? 00064 QString con( (*it).stripWhiteSpace() ); 00065 00066 if (con.startsWith("Categories = ") ) { 00067 con = con.remove(0, 13 ); 00068 //con = con.remove( con.length() -1, 1 ); // remove the last char ; 00069 QStringList catList = QStringList::split(';',con ); // no empty cats 00070 category = edit()->categoriesByIds( catList, QString::null ); 00071 00072 }else if ( con.startsWith("Name = ") ) { 00073 con = con.remove(0, 7 ); 00074 name = con.stripWhiteSpace(); 00075 }else if ( con.startsWith("Type = ") ) { 00076 con = con.remove( 0, 7 ); 00077 type = con.stripWhiteSpace() ; 00078 }else if ( con.startsWith("File = ") ) { 00079 con = con.remove( 0, 7 ); 00080 fileName = con.stripWhiteSpace(); 00081 }else if ( con.startsWith("Size = ") ) { 00082 con = con.remove(0, 7 ); 00083 size = con.stripWhiteSpace(); 00084 }else if ( (*it).stripWhiteSpace() == "[Desktop Entry]" ) { 00085 entry= new KSync::OpieDesktopSyncEntry( category, 00086 fileName, 00087 name, 00088 type, 00089 size, syncee ); 00090 syncee->addEntry( entry ); 00091 } 00092 00093 } 00094 // one is missing 00095 entry = new KSync::OpieDesktopSyncEntry( category, 00096 fileName, 00097 name, 00098 type, 00099 size, syncee ); 00100 syncee->addEntry( entry ); 00101 return syncee; 00102 } 00103
KDE Logo
This file is part of the documentation for kitchensync Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 1 15:18:59 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003