KDECore
kserviceaction.cpp
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 Copyright 2007 David Faure <faure@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 #include "kserviceaction.h" 00020 #include <QVariant> 00021 00022 class KServiceActionPrivate : public QSharedData 00023 { 00024 public: 00025 KServiceActionPrivate(const QString& name, const QString& text, 00026 const QString& icon, const QString& exec, 00027 bool noDisplay) 00028 : m_name(name), m_text(text), m_icon(icon), m_exec(exec), m_noDisplay(noDisplay) {} 00029 QString m_name; 00030 QString m_text; 00031 QString m_icon; 00032 QString m_exec; 00033 QVariant m_data; 00034 bool m_noDisplay; 00035 // warning keep QDataStream operators in sync if adding data here 00036 }; 00037 00038 KServiceAction::KServiceAction() 00039 : d(new KServiceActionPrivate(QString(), QString(), QString(), QString(), false)) 00040 { 00041 } 00042 00043 KServiceAction::KServiceAction(const QString& name, const QString& text, 00044 const QString& icon, const QString& exec, 00045 bool noDisplay) 00046 : d(new KServiceActionPrivate(name, text, icon, exec, noDisplay)) 00047 { 00048 } 00049 00050 KServiceAction::~KServiceAction() 00051 { 00052 } 00053 00054 KServiceAction::KServiceAction(const KServiceAction& other) 00055 : d(other.d) 00056 { 00057 } 00058 00059 KServiceAction& KServiceAction::operator=(const KServiceAction& other) 00060 { 00061 d = other.d; 00062 return *this; 00063 } 00064 00065 QVariant KServiceAction::data() const 00066 { 00067 return d->m_data; 00068 } 00069 00070 void KServiceAction::setData( const QVariant& data ) 00071 { 00072 d->m_data = data; 00073 } 00074 00075 QString KServiceAction::name() const 00076 { 00077 return d->m_name; 00078 } 00079 00080 QString KServiceAction::text() const 00081 { 00082 return d->m_text; 00083 } 00084 00085 QString KServiceAction::icon() const 00086 { 00087 return d->m_icon; 00088 } 00089 00090 QString KServiceAction::exec() const 00091 { 00092 return d->m_exec; 00093 } 00094 00095 bool KServiceAction::noDisplay() const 00096 { 00097 return d->m_noDisplay; 00098 } 00099 00100 bool KServiceAction::isSeparator() const 00101 { 00102 return d->m_name == QLatin1String("_SEPARATOR_"); 00103 } 00104 00105 QDataStream& operator>>( QDataStream& str, KServiceAction& act ) 00106 { 00107 KServiceActionPrivate* d = act.d; 00108 str >> d->m_name; 00109 str >> d->m_text; 00110 str >> d->m_icon; 00111 str >> d->m_exec; 00112 str >> d->m_data; 00113 str >> d->m_noDisplay; 00114 return str; 00115 } 00116 00117 QDataStream& operator<<( QDataStream& str, const KServiceAction& act ) 00118 { 00119 const KServiceActionPrivate* d = act.d; 00120 str << d->m_name; 00121 str << d->m_text; 00122 str << d->m_icon; 00123 str << d->m_exec; 00124 str << d->m_data; 00125 str << d->m_noDisplay; 00126 return str; 00127 }
KDE 4.6 API Reference