• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KIO

kmetaprops.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2001,2002 Rolf Magnus <ramagnus@kde.org>
00003 
00004     library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License version 2 as published by the Free Software Foundation.
00007 
00008     This library is distributed in the hope that it will be useful,
00009     but WITHOUT ANY WARRANTY; without even the implied warranty of
00010     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011     Library General Public License for more details.
00012 
00013     You should have received a copy of the GNU Library General Public License
00014     along with this library; see the file COPYING.LIB.  If not, write to
00015     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016     Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #include "kmetaprops.h"
00020 #include "kpropertiesdialog_p.h"
00021 
00022 #include <kdialog.h>
00023 #include <kfileitem.h>
00024 #include <kfilemetadatawidget.h>
00025 #include <kfilemetadataconfigurationwidget.h>
00026 #include <klocale.h>
00027 
00028 #include <QtCore/QPointer>
00029 #include <QtGui/QLabel>
00030 #include <QtGui/QScrollArea>
00031 #include <QtGui/QVBoxLayout>
00032 
00033 using namespace KDEPrivate;
00034 
00035 class KFileMetaPropsPlugin::KFileMetaPropsPluginPrivate
00036 {
00037 public:
00038     KFileMetaPropsPluginPrivate();
00039     ~KFileMetaPropsPluginPrivate();
00040     void configureShownMetaData();
00041 
00042     KFileMetaDataWidget* m_fileMetaDataWidget;
00043 };
00044 
00045 KFileMetaPropsPlugin::KFileMetaPropsPluginPrivate::KFileMetaPropsPluginPrivate() :
00046     m_fileMetaDataWidget(0)
00047 {
00048 }
00049 
00050 KFileMetaPropsPlugin::KFileMetaPropsPluginPrivate::~KFileMetaPropsPluginPrivate()
00051 {
00052 }
00053 
00054 void KFileMetaPropsPlugin::KFileMetaPropsPluginPrivate::configureShownMetaData()
00055 {
00056     QPointer<KDialog> dialog = new KDialog();
00057     dialog->setCaption(i18nc("@title:window", "Configure Shown Data"));
00058     dialog->setButtons(KDialog::Ok | KDialog::Cancel);
00059     dialog->setDefaultButton(KDialog::Ok);
00060 
00061     QLabel* descriptionLabel  = new QLabel(i18nc("@label::textbox",
00062                                                  "Select which data should "
00063                                                  "be shown:"));
00064     descriptionLabel->setWordWrap(true);
00065 
00066     KFileMetaDataConfigurationWidget* configWidget = new KFileMetaDataConfigurationWidget();
00067     const KFileItemList items = m_fileMetaDataWidget->items();
00068     configWidget->setItems(items);
00069 
00070     QWidget* mainWidget = new QWidget(dialog);
00071     QVBoxLayout* topLayout = new QVBoxLayout(mainWidget);
00072     topLayout->addWidget(descriptionLabel);
00073     topLayout->addWidget(configWidget);
00074     dialog->setMainWidget(mainWidget);
00075 
00076     KConfigGroup dialogConfig(KGlobal::config(), "KFileMetaPropsPlugin");
00077     dialog->restoreDialogSize(dialogConfig);
00078 
00079     if ((dialog->exec() == QDialog::Accepted) && (dialog != 0)) {
00080         configWidget->save();
00081 
00082         // TODO: Check whether a kind of refresh() method might make sense
00083         // for KFileMetaDataWidget or whether the widget can verify internally
00084         // whether a change has been done
00085         m_fileMetaDataWidget->setItems(KFileItemList());
00086         m_fileMetaDataWidget->setItems(items);
00087     }
00088 
00089     if (dialog != 0) {
00090         dialog->saveDialogSize(dialogConfig);
00091         delete dialog;
00092         dialog = 0;
00093     }
00094 }
00095 
00096 KFileMetaPropsPlugin::KFileMetaPropsPlugin(KPropertiesDialog* props)
00097   : KPropertiesDialogPlugin(props),d(new KFileMetaPropsPluginPrivate)
00098 {
00099     d->m_fileMetaDataWidget = new KFileMetaDataWidget();
00100     d->m_fileMetaDataWidget->setItems(properties->items());
00101 
00102     // Embed the FileMetaDataWidget inside a container that has a dummy widget
00103     // at the bottom. This prevents that the file meta data widget gets vertically stretched.
00104     QWidget* metaDataWidgetContainer = new QWidget();
00105     QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer);
00106     containerLayout->addWidget(d->m_fileMetaDataWidget);
00107     QWidget* stretchWidget = new QWidget(metaDataWidgetContainer);
00108     stretchWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
00109     containerLayout->addWidget(stretchWidget);
00110 
00111     // The height of FileMetaDataWidget can get very large, so it is embedded
00112     // into a scrollarea
00113     QScrollArea* metaDataArea = new QScrollArea();
00114     metaDataArea->setWidget(metaDataWidgetContainer);
00115     metaDataArea->setWidgetResizable(true);
00116     metaDataArea->setFrameShape(QFrame::NoFrame);
00117 
00118     // Add label 'Configure...' to be able to adjust which meta data should be shown
00119     QLabel* configureLabel = new QLabel("<a href=\"configure\">" +
00120                                         i18nc("@action:button", "Configure...") +
00121                                         "</a>");
00122     connect(configureLabel, SIGNAL(linkActivated(const QString&)),
00123             this, SLOT(configureShownMetaData()));
00124 
00125     QWidget* mainWidget = new QWidget();
00126     QVBoxLayout* mainLayout = new QVBoxLayout(mainWidget);
00127     mainLayout->addWidget(metaDataArea);
00128     mainLayout->addWidget(configureLabel, 0, Qt::AlignRight);
00129 
00130     properties->addPage(mainWidget, i18nc("@title:tab", "Information"));
00131 }
00132 
00133 KFileMetaPropsPlugin::~KFileMetaPropsPlugin()
00134 {
00135     delete d;
00136 }
00137 
00138 bool KFileMetaPropsPlugin::supports( const KFileItemList& _items )
00139 {
00140     Q_UNUSED(_items);
00141     return true;
00142 }
00143 
00144 void KFileMetaPropsPlugin::applyChanges()
00145 {
00146 }
00147 
00148 #include "kmetaprops.moc"

KIO

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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