]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/filemetadataconfigurationdialog.cpp
Port Dolphin to Baloo
[dolphin.git] / src / panels / information / filemetadataconfigurationdialog.cpp
1 /***************************************************************************
2 * Copyright (C) 2010 by Peter Penz <peter.penz19@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #include "filemetadataconfigurationdialog.h"
21
22 #ifndef HAVE_BALOO
23 #include <kfilemetadataconfigurationwidget.h>
24 #else
25 #include <baloo/filemetadataconfigwidget.h>
26 #endif
27
28 #include <KLocale>
29 #include <QLabel>
30 #include <QVBoxLayout>
31
32 FileMetaDataConfigurationDialog::FileMetaDataConfigurationDialog(QWidget* parent) :
33 KDialog(parent),
34 m_descriptionLabel(0),
35 m_configWidget(0)
36
37 {
38 setCaption(i18nc("@title:window", "Configure Shown Data"));
39 setButtons(KDialog::Ok | KDialog::Cancel);
40 setDefaultButton(KDialog::Ok);
41
42 m_descriptionLabel = new QLabel(i18nc("@label::textbox",
43 "Select which data should "
44 "be shown:"), this);
45 m_descriptionLabel->setWordWrap(true);
46
47 #ifndef HAVE_BALOO
48 m_configWidget = new KFileMetaDataConfigurationWidget(this);
49 #else
50 m_configWidget = new Baloo::FileMetaDataConfigWidget(this);
51 #endif
52
53
54 QWidget* mainWidget = new QWidget(this);
55 QVBoxLayout* topLayout = new QVBoxLayout(mainWidget);
56 topLayout->addWidget(m_descriptionLabel);
57 topLayout->addWidget(m_configWidget);
58 setMainWidget(mainWidget);
59
60 const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
61 "FileMetaDataConfigurationDialog");
62 restoreDialogSize(dialogConfig);
63 }
64
65 FileMetaDataConfigurationDialog::~FileMetaDataConfigurationDialog()
66 {
67 KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
68 "FileMetaDataConfigurationDialog");
69 saveDialogSize(dialogConfig, KConfigBase::Persistent);
70 }
71
72 void FileMetaDataConfigurationDialog::setItems(const KFileItemList& items)
73 {
74 m_configWidget->setItems(items);
75 }
76
77 KFileItemList FileMetaDataConfigurationDialog::items() const
78 {
79 return m_configWidget->items();
80 }
81
82 void FileMetaDataConfigurationDialog::slotButtonClicked(int button)
83 {
84 if (button == KDialog::Ok) {
85 m_configWidget->save();
86 accept();
87 } else {
88 KDialog::slotButtonClicked(button);
89 }
90 }
91
92 void FileMetaDataConfigurationDialog::setDescription(const QString& description)
93 {
94 m_descriptionLabel->setText(description);
95 }
96
97 QString FileMetaDataConfigurationDialog::description() const
98 {
99 return m_descriptionLabel->text();
100 }
101
102 #include "filemetadataconfigurationdialog.moc"