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

KIO

  • 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
33using namespace KDEPrivate;
34
35class KFileMetaPropsPlugin::KFileMetaPropsPluginPrivate
36{
37public:
38 KFileMetaPropsPluginPrivate();
39 ~KFileMetaPropsPluginPrivate();
40 void configureShownMetaData();
41
42 KFileMetaDataWidget* m_fileMetaDataWidget;
43};
44
45KFileMetaPropsPlugin::KFileMetaPropsPluginPrivate::KFileMetaPropsPluginPrivate() :
46 m_fileMetaDataWidget(0)
47{
48}
49
50KFileMetaPropsPlugin::KFileMetaPropsPluginPrivate::~KFileMetaPropsPluginPrivate()
51{
52}
53
54void 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
96KFileMetaPropsPlugin::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
133KFileMetaPropsPlugin::~KFileMetaPropsPlugin()
134{
135 delete d;
136}
137
138bool KFileMetaPropsPlugin::supports( const KFileItemList& _items )
139{
140 Q_UNUSED(_items);
141 return true;
142}
143
144void KFileMetaPropsPlugin::applyChanges()
145{
146}
147
148#include "kmetaprops.moc"
KConfigGroup
KDialog
KDialog::Ok
Ok
KDialog::Cancel
Cancel
KFileItemList
List of KFileItems, which adds a few helper methods to QList<KFileItem>.
Definition: kfileitem.h:675
KFileMetaDataConfigurationWidget
Widget which allows to configure which meta data should be shown in the KFileMetaDataWidget.
Definition: kfilemetadataconfigurationwidget.h:47
KFileMetaDataConfigurationWidget::save
void save()
Saves the modified configuration.
Definition: kfilemetadataconfigurationwidget.cpp:187
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
KFileMetaDataWidget
Shows the meta data of one or more file items.
Definition: kfilemetadatawidget.h:47
KFileMetaPropsPlugin::supports
static bool supports(const KFileItemList &_items)
Tests whether the file specified by _items has a 'MetaInfo' plugin.
Definition: kmetaprops.cpp:138
KFileMetaPropsPlugin::~KFileMetaPropsPlugin
virtual ~KFileMetaPropsPlugin()
Definition: kmetaprops.cpp:133
KFileMetaPropsPlugin::KFileMetaPropsPlugin
KFileMetaPropsPlugin(KPropertiesDialog *_props)
Definition: kmetaprops.cpp:96
KFileMetaPropsPlugin::applyChanges
virtual void applyChanges()
Applies all changes to the file.
Definition: kmetaprops.cpp:144
KPageDialog::addPage
void addPage(KPageWidgetItem *item)
KPropertiesDialogPlugin
A Plugin in the Properties dialog This is an abstract class.
Definition: kpropertiesdialog.h:348
KPropertiesDialogPlugin::properties
KPropertiesDialog * properties
Pointer to the dialog.
Definition: kpropertiesdialog.h:393
KPropertiesDialog
The main properties dialog class.
Definition: kpropertiesdialog.h:58
KPropertiesDialog::items
KFileItemList items() const
Definition: kpropertiesdialog.cpp:404
QLabel
QWidget
kdialog.h
kfileitem.h
kfilemetadataconfigurationwidget.h
kfilemetadatawidget.h
klocale.h
i18nc
QString i18nc(const char *ctxt, const char *text)
kmetaprops.h
kpropertiesdialog_p.h
KDEPrivate
KGlobal::config
KSharedConfigPtr config()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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