SVN_SILENT made messages (.desktop file)
[kdepim.git] / ktnef / messagepropertydialog.cpp
blob8d31f1bc276b0741423c1d257e33b5a9675afa45
1 /*
2 This file is part of KTnef.
4 Copyright (C) 2003 Michael Goffioul <kdeprint@swing.be>
5 Copyright (c) 2012 Allen Winter <winter@kde.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software Foundation,
14 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 #include "messagepropertydialog.h"
18 #include "attachpropertydialog.h"
20 #include <KTNEF/KTNEFMessage>
22 #include <KLocalizedString>
23 #include <KStandardGuiItem>
25 #include <QTreeWidget>
26 #include <KConfigGroup>
27 #include <KGuiItem>
28 #include <QDialogButtonBox>
29 #include <QPushButton>
30 #include <KSharedConfig>
31 #include <QHeaderView>
33 MessagePropertyDialog::MessagePropertyDialog(QWidget *parent, KTNEFMessage *msg)
34 : QDialog(parent)
36 mMessage = msg;
38 QVBoxLayout *mainLayout = new QVBoxLayout;
39 setLayout(mainLayout);
40 setWindowTitle(i18n("Message Properties"));
41 mListView = new QTreeWidget(this);
42 mainLayout->addWidget(mListView);
43 QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
44 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
45 okButton->setDefault(true);
46 okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
47 connect(buttonBox, &QDialogButtonBox::accepted, this, &MessagePropertyDialog::accept);
48 connect(buttonBox, &QDialogButtonBox::rejected, this, &MessagePropertyDialog::reject);
49 mainLayout->addWidget(buttonBox);
50 QPushButton *user1Button = new QPushButton;
51 buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole);
52 connect(user1Button, &QPushButton::clicked, this, &MessagePropertyDialog::slotSaveProperty);
54 const QStringList headerLabels =
55 (QStringList(i18nc("@title:column property name", "Name"))
56 << i18nc("@title:column property value", "Value"));
57 mListView->setHeaderLabels(headerLabels);
58 mListView->setAllColumnsShowFocus(true);
59 mListView->setWordWrap(true);
60 mListView->setAllColumnsShowFocus(true);
61 mListView->setRootIsDecorated(false);
63 KGuiItem::assign(user1Button, KStandardGuiItem::save());
64 AttachPropertyDialog::formatPropertySet(mMessage, mListView);
65 readConfig();
69 MessagePropertyDialog::~MessagePropertyDialog()
71 writeConfig();
74 void MessagePropertyDialog::slotSaveProperty()
76 AttachPropertyDialog::saveProperty(mListView, mMessage, this);
79 void MessagePropertyDialog::readConfig()
81 KConfigGroup group(KSharedConfig::openConfig(), "MessagePropertyDialog");
82 const QSize size = group.readEntry("Size", QSize(600, 400));
83 if (size.isValid()) {
84 resize(size);
86 const QByteArray headerState = group.readEntry("HeaderState", QByteArray());
87 if (!headerState.isEmpty()) {
88 mListView->header()->restoreState(headerState);
92 void MessagePropertyDialog::writeConfig()
94 KConfigGroup group(KSharedConfig::openConfig(), "MessagePropertyDialog");
95 group.writeEntry("Size", size());
96 group.writeEntry("HeaderState", mListView->header()->saveState());
97 group.sync();