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

libkonq

konq_popupmenuinformation.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002 
00003    Copyright 2008 David Faure <faure@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU Library General Public License as published
00007    by the Free Software Foundation; either version 2 of the License or
00008    ( at your option ) version 3 or, at the discretion of KDE e.V.
00009    ( which shall act as a proxy as in section 14 of the GPLv3 ), 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., 51 Franklin Street, Fifth Floor,
00019    Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include "konq_popupmenuinformation.h"
00023 #include <kfileitem.h>
00024 
00025 class KonqPopupMenuInformationPrivate : public QSharedData
00026 {
00027 public:
00028     KonqPopupMenuInformationPrivate()
00029         : m_parentWidget(0),
00030       m_isDirectory(false)
00031     {}
00032     QWidget* m_parentWidget;
00033     KFileItemList m_items;
00034     KonqFileItemCapabilities m_capabilities;
00035     KUrl::List m_urlList;
00036     QString m_mimeType;
00037     QString m_mimeGroup;
00038     bool m_isDirectory;
00039 };
00040 
00041 KonqPopupMenuInformation::KonqPopupMenuInformation()
00042     : d(new KonqPopupMenuInformationPrivate)
00043 {
00044 }
00045 
00046 KonqPopupMenuInformation::~KonqPopupMenuInformation()
00047 {
00048 }
00049 
00050 KonqPopupMenuInformation::KonqPopupMenuInformation(const KonqPopupMenuInformation& other)
00051     : d(other.d)
00052 {
00053 }
00054 
00055 KonqPopupMenuInformation & KonqPopupMenuInformation::operator=(const KonqPopupMenuInformation& other)
00056 {
00057     d = other.d;
00058     return *this;
00059 }
00060 
00061 void KonqPopupMenuInformation::setItems(const KFileItemList& items)
00062 {
00063     Q_ASSERT(!items.isEmpty());
00064     d->m_items = items;
00065     d->m_capabilities.setItems(items);
00066     d->m_mimeType = items.first().mimetype();
00067     d->m_mimeGroup = d->m_mimeType.left(d->m_mimeType.indexOf('/'));
00068     d->m_isDirectory = items.first().isDir();
00069     d->m_urlList = items.urlList();
00070     if (items.count() > 1) {
00071         KFileItemList::const_iterator kit = items.begin();
00072         const KFileItemList::const_iterator kend = items.end();
00073         for ( ; kit != kend; ++kit ) {
00074             const QString itemMimeType = (*kit).mimetype();
00075             // Determine if common mimetype among all items
00076             if (d->m_mimeType != itemMimeType) {
00077                 d->m_mimeType.clear();
00078                 if (d->m_mimeGroup != itemMimeType.left(itemMimeType.indexOf('/')))
00079                     d->m_mimeGroup.clear(); // mimetype groups are different as well!
00080             }
00081             if (d->m_isDirectory && !(*kit).isDir())
00082                 d->m_isDirectory = false;
00083         }
00084     }
00085 }
00086 
00087 KFileItemList KonqPopupMenuInformation::items() const
00088 {
00089     return d->m_items;
00090 }
00091 
00092 KUrl::List KonqPopupMenuInformation::urlList() const
00093 {
00094     return d->m_urlList;
00095 }
00096 
00097 bool KonqPopupMenuInformation::isDirectory() const
00098 {
00099     return d->m_isDirectory;
00100 }
00101 
00102 void KonqPopupMenuInformation::setParentWidget(QWidget* parentWidget)
00103 {
00104     d->m_parentWidget = parentWidget;
00105 }
00106 
00107 QWidget* KonqPopupMenuInformation::parentWidget() const
00108 {
00109     return d->m_parentWidget;
00110 }
00111 
00112 QString KonqPopupMenuInformation::mimeType() const
00113 {
00114     return d->m_mimeType;
00115 }
00116 
00117 QString KonqPopupMenuInformation::mimeGroup() const
00118 {
00119     return d->m_mimeGroup;
00120 }
00121 
00122 KonqFileItemCapabilities KonqPopupMenuInformation::capabilities() const
00123 {
00124     return d->m_capabilities;
00125 }

libkonq

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

API Reference

Skip menu "API Reference"
  • Konsole
  • Libraries
  •   libkonq
Generated for API Reference 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