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

KIO

  • sources
  • kde-4.12
  • kdelibs
  • kio
  • kfile
kmetaprops.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2001,2002 Rolf Magnus <ramagnus@kde.org>
3 
4  library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17  */
18 
19 #include "kmetaprops.h"
20 #include "kpropertiesdialog_p.h"
21 
22 #include <kdialog.h>
23 #include <kfileitem.h>
24 #include <kfilemetadatawidget.h>
25 #include <kfilemetadataconfigurationwidget.h>
26 #include <klocale.h>
27 
28 #include <QtCore/QPointer>
29 #include <QtGui/QLabel>
30 #include <QtGui/QScrollArea>
31 #include <QtGui/QVBoxLayout>
32 
33 using namespace KDEPrivate;
34 
35 class KFileMetaPropsPlugin::KFileMetaPropsPluginPrivate
36 {
37 public:
38  KFileMetaPropsPluginPrivate();
39  ~KFileMetaPropsPluginPrivate();
40  void configureShownMetaData();
41 
42  KFileMetaDataWidget* m_fileMetaDataWidget;
43 };
44 
45 KFileMetaPropsPlugin::KFileMetaPropsPluginPrivate::KFileMetaPropsPluginPrivate() :
46  m_fileMetaDataWidget(0)
47 {
48 }
49 
50 KFileMetaPropsPlugin::KFileMetaPropsPluginPrivate::~KFileMetaPropsPluginPrivate()
51 {
52 }
53 
54 void KFileMetaPropsPlugin::KFileMetaPropsPluginPrivate::configureShownMetaData()
55 {
56  QPointer<KDialog> dialog = new KDialog();
57  dialog->setCaption(i18nc("@title:window", "Configure Shown Data"));
58  dialog->setButtons(KDialog::Ok | KDialog::Cancel);
59  dialog->setDefaultButton(KDialog::Ok);
60 
61  QLabel* descriptionLabel = new QLabel(i18nc("@label::textbox",
62  "Select which data should "
63  "be shown:"));
64  descriptionLabel->setWordWrap(true);
65 
66  KFileMetaDataConfigurationWidget* configWidget = new KFileMetaDataConfigurationWidget();
67  const KFileItemList items = m_fileMetaDataWidget->items();
68  configWidget->setItems(items);
69 
70  QWidget* mainWidget = new QWidget(dialog);
71  QVBoxLayout* topLayout = new QVBoxLayout(mainWidget);
72  topLayout->addWidget(descriptionLabel);
73  topLayout->addWidget(configWidget);
74  dialog->setMainWidget(mainWidget);
75 
76  KConfigGroup dialogConfig(KGlobal::config(), "KFileMetaPropsPlugin");
77  dialog->restoreDialogSize(dialogConfig);
78 
79  if ((dialog->exec() == QDialog::Accepted) && (dialog != 0)) {
80  configWidget->save();
81 
82  // TODO: Check whether a kind of refresh() method might make sense
83  // for KFileMetaDataWidget or whether the widget can verify internally
84  // whether a change has been done
85  m_fileMetaDataWidget->setItems(KFileItemList());
86  m_fileMetaDataWidget->setItems(items);
87  }
88 
89  if (dialog != 0) {
90  dialog->saveDialogSize(dialogConfig);
91  delete dialog;
92  dialog = 0;
93  }
94 }
95 
96 KFileMetaPropsPlugin::KFileMetaPropsPlugin(KPropertiesDialog* props)
97  : KPropertiesDialogPlugin(props),d(new KFileMetaPropsPluginPrivate)
98 {
99  d->m_fileMetaDataWidget = new KFileMetaDataWidget();
100  d->m_fileMetaDataWidget->setItems(properties->items());
101 
102  // Embed the FileMetaDataWidget inside a container that has a dummy widget
103  // at the bottom. This prevents that the file meta data widget gets vertically stretched.
104  QWidget* metaDataWidgetContainer = new QWidget();
105  QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer);
106  containerLayout->addWidget(d->m_fileMetaDataWidget);
107  QWidget* stretchWidget = new QWidget(metaDataWidgetContainer);
108  stretchWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
109  containerLayout->addWidget(stretchWidget);
110 
111  // The height of FileMetaDataWidget can get very large, so it is embedded
112  // into a scrollarea
113  QScrollArea* metaDataArea = new QScrollArea();
114  metaDataArea->setWidget(metaDataWidgetContainer);
115  metaDataArea->setWidgetResizable(true);
116  metaDataArea->setFrameShape(QFrame::NoFrame);
117 
118  // Add label 'Configure...' to be able to adjust which meta data should be shown
119  QLabel* configureLabel = new QLabel("<a href=\"configure\">" +
120  i18nc("@action:button", "Configure...") +
121  "</a>");
122  connect(configureLabel, SIGNAL(linkActivated(QString)),
123  this, SLOT(configureShownMetaData()));
124 
125  QWidget* mainWidget = new QWidget();
126  QVBoxLayout* mainLayout = new QVBoxLayout(mainWidget);
127  mainLayout->addWidget(metaDataArea);
128  mainLayout->addWidget(configureLabel, 0, Qt::AlignRight);
129 
130  properties->addPage(mainWidget, i18nc("@title:tab", "Information"));
131 }
132 
133 KFileMetaPropsPlugin::~KFileMetaPropsPlugin()
134 {
135  delete d;
136 }
137 
138 bool KFileMetaPropsPlugin::supports( const KFileItemList& _items )
139 {
140  Q_UNUSED(_items);
141  return true;
142 }
143 
144 void KFileMetaPropsPlugin::applyChanges()
145 {
146 }
147 
148 #include "kmetaprops.moc"
KFileMetaPropsPlugin::applyChanges
virtual void applyChanges()
Applies all changes to the file.
Definition: kmetaprops.cpp:144
kdialog.h
KFileMetaPropsPlugin::KFileMetaPropsPlugin
KFileMetaPropsPlugin(KPropertiesDialog *_props)
Definition: kmetaprops.cpp:96
kmetaprops.h
KPropertiesDialog::items
KFileItemList items() const
Definition: kpropertiesdialog.cpp:404
KFileMetaDataConfigurationWidget::save
void save()
Saves the modified configuration.
Definition: kfilemetadataconfigurationwidget.cpp:187
QWidget
KFileMetaPropsPlugin::~KFileMetaPropsPlugin
virtual ~KFileMetaPropsPlugin()
Definition: kmetaprops.cpp:133
KFileMetaDataConfigurationWidget
Widget which allows to configure which meta data should be shown in the KFileMetaDataWidget.
Definition: kfilemetadataconfigurationwidget.h:46
KDialog
QString
KPropertiesDialogPlugin::properties
KPropertiesDialog * properties
Pointer to the dialog.
Definition: kpropertiesdialog.h:393
klocale.h
i18nc
QString i18nc(const char *ctxt, const char *text)
KGlobal::config
KSharedConfigPtr config()
KPropertiesDialogPlugin
A Plugin in the Properties dialog This is an abstract class.
Definition: kpropertiesdialog.h:347
KFileMetaPropsPlugin::supports
static bool supports(const KFileItemList &_items)
Tests whether the file specified by _items has a 'MetaInfo' plugin.
Definition: kmetaprops.cpp:138
KFileMetaDataWidget
Shows the meta data of one or more file items.
Definition: kfilemetadatawidget.h:46
KFileItemList
List of KFileItems, which adds a few helper methods to QList.
Definition: kfileitem.h:674
kpropertiesdialog_p.h
kfilemetadataconfigurationwidget.h
KPropertiesDialog
The main properties dialog class.
Definition: kpropertiesdialog.h:57
KConfigGroup
QLabel
KFileMetaDataConfigurationWidget::setItems
void setItems(const KFileItemList &items)
Sets the items, for which the visibility of the meta data should be configured.
Definition: kfilemetadataconfigurationwidget.cpp:177
kfileitem.h
kfilemetadatawidget.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:50:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal