KIO
kfileitemactions_p.h
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 Copyright (C) 1998-2009 David Faure <faure@kde.org> 00003 00004 This library is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU Library General Public License as published 00006 by the Free Software Foundation; either version 2 of the License or 00007 ( at your option ) version 3 or, at the discretion of KDE e.V. 00008 ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. 00009 00010 This library 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 GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KFILEITEMACTIONS_P_H 00022 #define KFILEITEMACTIONS_P_H 00023 00024 #include <kfileitemlistproperties.h> 00025 #include <kfileitem.h> 00026 #include <kactioncollection.h> 00027 #include <kserviceaction.h> 00028 #include <kservice.h> 00029 #include <QActionGroup> 00030 #include <QObject> 00031 00032 typedef QList<KServiceAction> ServiceList; 00033 00034 class KFileItemActionsPrivate : public QObject 00035 { 00036 Q_OBJECT 00037 public: 00038 KFileItemActionsPrivate(); 00039 ~KFileItemActionsPrivate(); 00040 00041 int insertServicesSubmenus(const QMap<QString, ServiceList>& list, QMenu* menu, bool isBuiltin); 00042 int insertServices(const ServiceList& list, QMenu* menu, bool isBuiltin); 00043 00044 // For "open with" 00045 KService::List associatedApplications(const QString& traderConstraint); 00046 KAction* createAppAction(const KService::Ptr& service, bool singleOffer); 00047 00048 struct ServiceRank 00049 { 00050 int score; 00051 KService::Ptr service; 00052 }; 00053 00054 // Inline function for sorting lists of ServiceRank 00055 static bool lessRank(const ServiceRank& id1, const ServiceRank& id2) 00056 { 00057 return id1.score < id2.score; 00058 } 00059 00060 QStringList listMimeTypes(const KFileItemList& items); 00061 QStringList listPreferredServiceIds(const QStringList& mimeTypeList, const QString& traderConstraint); 00062 00063 public Q_SLOTS: 00064 void slotRunPreferredApplications(); 00065 00066 private: 00067 void openWithByMime(const KFileItemList& fileItems); 00068 00069 private Q_SLOTS: 00070 // For servicemenus 00071 void slotExecuteService(QAction* act); 00072 // For "open with" applications 00073 void slotRunApplication(QAction* act); 00074 void slotOpenWithDialog(); 00075 00076 public: 00077 KFileItemListProperties m_props; 00078 QStringList m_mimeTypeList; 00079 QString m_traderConstraint; 00080 KFileItemList m_fileOpenList; 00081 QActionGroup m_executeServiceActionGroup; 00082 QActionGroup m_runApplicationActionGroup; 00083 QList<KAction*> m_ownActions; 00084 QWidget* m_parentWidget; 00085 }; 00086 00087 Q_DECLARE_METATYPE(KService::Ptr) 00088 Q_DECLARE_METATYPE(KServiceAction) 00089 00090 #endif /* KFILEITEMACTIONS_P_H */ 00091
KDE 4.6 API Reference