]> cloud.milkyroute.net Git - dolphin.git/blob - src/additionalinfodialog.cpp
allow to configure the additional information of the view inside the viewproperties...
[dolphin.git] / src / additionalinfodialog.cpp
1 /***************************************************************************
2 * Copyright (C) 2007 by Peter Penz (peter.penz@gmx.at) *
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 "additionalinfodialog.h"
21
22 #include <klocale.h>
23 #include <kvbox.h>
24
25 #include <QCheckBox>
26
27 AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
28 KFileItemDelegate::InformationList info) :
29 KDialog(parent),
30 m_info(info),
31 m_size(0),
32 m_date(0),
33 m_permissions(0),
34 m_owner(0),
35 m_group(0),
36 m_type(0)
37 {
38 setCaption(i18nc("@title:window", "Additional Information"));
39 setButtons(Ok | Cancel);
40 setDefaultButton(Ok);
41
42 KVBox* box = new KVBox(this);
43
44 m_size = new QCheckBox(i18nc("@option:check Additional Information", "Size"), box);
45 m_date = new QCheckBox(i18nc("@option:check Additional Information", "Date"), box);
46 m_permissions = new QCheckBox(i18nc("@option:check Additional Information", "Permissions"), box);
47 m_owner = new QCheckBox(i18nc("@option:check Additional Information", "Owner"), box);
48 m_group = new QCheckBox(i18nc("@option:check Additional Information", "Group"), box);
49 m_type = new QCheckBox(i18nc("@option:check Additional Information", "Type"), box);
50 connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
51
52 m_size->setChecked(info.contains(KFileItemDelegate::Size));
53 m_date->setChecked(info.contains(KFileItemDelegate::ModificationTime));
54 m_permissions->setChecked(info.contains(KFileItemDelegate::Permissions));
55 m_owner->setChecked(info.contains(KFileItemDelegate::Owner));
56 m_group->setChecked(info.contains(KFileItemDelegate::OwnerAndGroup));
57 m_type->setChecked(info.contains(KFileItemDelegate::FriendlyMimeType));
58
59 setMainWidget(box);
60
61 const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
62 "AdditionalInfoDialog");
63 restoreDialogSize(dialogConfig);
64
65 }
66
67 AdditionalInfoDialog::~AdditionalInfoDialog()
68 {
69 KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
70 "AdditionalInfoDialog");
71 saveDialogSize(dialogConfig, KConfigBase::Persistent);
72
73 }
74
75 KFileItemDelegate::InformationList AdditionalInfoDialog::additionalInfo() const
76 {
77 return m_info;
78 }
79
80 void AdditionalInfoDialog::slotOk()
81 {
82 m_info.clear();
83
84 if (m_size->isChecked()) {
85 m_info.append(KFileItemDelegate::Size);
86 }
87 if (m_date->isChecked()) {
88 m_info.append(KFileItemDelegate::ModificationTime);
89 }
90 if (m_permissions->isChecked()) {
91 m_info.append(KFileItemDelegate::Permissions);
92 }
93 if (m_owner->isChecked()) {
94 m_info.append(KFileItemDelegate::Owner);
95 }
96 if (m_group->isChecked()) {
97 m_info.append(KFileItemDelegate::OwnerAndGroup);
98 }
99 if (m_type->isChecked()) {
100 m_info.append(KFileItemDelegate::FriendlyMimeType);
101 }
102 }
103
104 #include "additionalinfodialog.moc"