┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/additionalinfodialog.cpp
blob: 2f735fffec6afd20b5661b2f7bc446ac2486b0e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/***************************************************************************
 *   Copyright (C) 2007 by Peter Penz ([email protected])                  *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
 ***************************************************************************/

#include "additionalinfodialog.h"

#include <klocale.h>
#include <kvbox.h>

#include <QCheckBox>

AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
                                           KFileItemDelegate::InformationList info) :
    KDialog(parent),
    m_info(info),
    m_size(0),
    m_date(0),
    m_permissions(0),
    m_owner(0),
    m_group(0),
    m_type(0)
{
    setCaption(i18nc("@title:window", "Additional Information"));
    setButtons(Ok | Cancel);
    setDefaultButton(Ok);

    KVBox* box = new KVBox(this);

    m_size = new QCheckBox(i18nc("@option:check Additional Information", "Size"), box);
    m_date = new QCheckBox(i18nc("@option:check Additional Information", "Date"), box);
    m_permissions = new QCheckBox(i18nc("@option:check Additional Information", "Permissions"), box);
    m_owner = new QCheckBox(i18nc("@option:check Additional Information", "Owner"), box);
    m_group = new QCheckBox(i18nc("@option:check Additional Information", "Group"), box);
    m_type = new QCheckBox(i18nc("@option:check Additional Information", "Type"), box);
    connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));

    m_size->setChecked(info.contains(KFileItemDelegate::Size));
    m_date->setChecked(info.contains(KFileItemDelegate::ModificationTime));
    m_permissions->setChecked(info.contains(KFileItemDelegate::Permissions));
    m_owner->setChecked(info.contains(KFileItemDelegate::Owner));
    m_group->setChecked(info.contains(KFileItemDelegate::OwnerAndGroup));
    m_type->setChecked(info.contains(KFileItemDelegate::FriendlyMimeType));

    setMainWidget(box);

    const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
                                    "AdditionalInfoDialog");
    restoreDialogSize(dialogConfig);
}

AdditionalInfoDialog::~AdditionalInfoDialog()
{
    KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
                              "AdditionalInfoDialog");
    saveDialogSize(dialogConfig, KConfigBase::Persistent);
}

KFileItemDelegate::InformationList AdditionalInfoDialog::additionalInfo() const
{
    return m_info;
}

void AdditionalInfoDialog::slotOk()
{
    m_info.clear();

    if (m_size->isChecked()) {
        m_info.append(KFileItemDelegate::Size);
    }
    if (m_date->isChecked()) {
        m_info.append(KFileItemDelegate::ModificationTime);
    }
    if (m_permissions->isChecked()) {
        m_info.append(KFileItemDelegate::Permissions);
    }
    if (m_owner->isChecked()) {
        m_info.append(KFileItemDelegate::Owner);
    }
    if (m_group->isChecked()) {
        m_info.append(KFileItemDelegate::OwnerAndGroup);
    }
    if (m_type->isChecked()) {
        m_info.append(KFileItemDelegate::FriendlyMimeType);
    }
}

#include "additionalinfodialog.moc"