]>
cloud.milkyroute.net Git - dolphin.git/blob - src/settings/additionalinfodialog.cpp
1 /***************************************************************************
2 * Copyright (C) 2007-2012 by Peter Penz <peter.penz19@gmail.com> *
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. *
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. *
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 ***************************************************************************/
20 #include "additionalinfodialog.h"
23 #include "kitemviews/kfileitemmodel.h"
26 #include <QVBoxLayout>
28 AdditionalInfoDialog::AdditionalInfoDialog(QWidget
* parent
,
29 const QList
<QByteArray
>& visibleRoles
) :
31 m_visibleRoles(visibleRoles
),
34 setCaption(i18nc("@title:window", "Additional Information"));
35 setButtons(Ok
| Cancel
);
38 QWidget
* mainWidget
= new QWidget(this);
39 mainWidget
->setSizePolicy(QSizePolicy::Preferred
, QSizePolicy::Minimum
);
42 QLabel
* header
= new QLabel(mainWidget
);
43 header
->setText(i18nc("@label", "Select which additional information should be shown:"));
44 header
->setWordWrap(true);
47 m_listWidget
= new QListWidget(mainWidget
);
48 m_listWidget
->setSelectionMode(QAbstractItemView::NoSelection
);
49 const QList
<KFileItemModel::RoleInfo
> rolesInfo
= KFileItemModel::rolesInformation();
50 foreach (const KFileItemModel::RoleInfo
& info
, rolesInfo
) {
51 QListWidgetItem
* item
= new QListWidgetItem(info
.translation
, m_listWidget
);
52 item
->setCheckState(visibleRoles
.contains(info
.role
) ? Qt::Checked
: Qt::Unchecked
);
55 QVBoxLayout
* layout
= new QVBoxLayout(mainWidget
);
56 layout
->addWidget(header
);
57 layout
->addWidget(m_listWidget
);
58 layout
->addStretch(1);
60 setMainWidget(mainWidget
);
62 const KConfigGroup
dialogConfig(KSharedConfig::openConfig("dolphinrc"), "AdditionalInfoDialog");
63 restoreDialogSize(dialogConfig
);
65 connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
68 AdditionalInfoDialog::~AdditionalInfoDialog()
70 KConfigGroup
dialogConfig(KSharedConfig::openConfig("dolphinrc"), "AdditionalInfoDialog");
71 saveDialogSize(dialogConfig
, KConfigBase::Persistent
);
74 QList
<QByteArray
> AdditionalInfoDialog::visibleRoles() const
76 return m_visibleRoles
;
79 void AdditionalInfoDialog::slotOk()
81 m_visibleRoles
.clear();
84 const QList
<KFileItemModel::RoleInfo
> rolesInfo
= KFileItemModel::rolesInformation();
85 foreach (const KFileItemModel::RoleInfo
& info
, rolesInfo
) {
86 const QListWidgetItem
* item
= m_listWidget
->item(index
);
87 if (item
->checkState() == Qt::Checked
) {
88 m_visibleRoles
.append(info
.role
);
94 #include "additionalinfodialog.moc"