• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.12
  • kdepim
  • messageviewer
  • scamdetection
scamdetectiondetailsdialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "scamdetectiondetailsdialog.h"
19 #include "settings/globalsettings.h"
20 #include "utils/autoqpointer.h"
21 #include "pimcommon/texteditor/richtexteditor/richtexteditorwidget.h"
22 
23 #include <KLocale>
24 
25 #include <KTextEdit>
26 #include <KFileDialog>
27 #include <KStandardGuiItem>
28 
29 #include <QTextStream>
30 
31 using namespace MessageViewer;
32 
33 ScamDetectionDetailsDialog::ScamDetectionDetailsDialog(QWidget *parent)
34  : KDialog(parent)
35 {
36  setCaption( i18n("Details") );
37  setAttribute( Qt::WA_DeleteOnClose );
38  setButtons( User1|Close );
39  setButtonGuiItem( User1, KStandardGuiItem::saveAs() );
40  setModal( false );
41  mDetails = new PimCommon::RichTextEditorWidget;
42  mDetails->setReadOnly(true);
43  setMainWidget(mDetails);
44  connect(this, SIGNAL(user1Clicked()), SLOT(slotSaveAs()));
45  readConfig();
46 }
47 
48 ScamDetectionDetailsDialog::~ScamDetectionDetailsDialog()
49 {
50  writeConfig();
51 }
52 
53 void ScamDetectionDetailsDialog::slotSaveAs()
54 {
55  KUrl url;
56  MessageViewer::AutoQPointer<KFileDialog> fdlg( new KFileDialog( url, QString(), this) );
57 
58  fdlg->setMode( KFile::File );
59  fdlg->setSelection( QLatin1String("scam-detection.html") );
60  fdlg->setOperationMode( KFileDialog::Saving );
61  fdlg->setConfirmOverwrite(true);
62  if ( fdlg->exec() == QDialog::Accepted ) {
63  const QString fileName = fdlg->selectedFile();
64  if ( !fileName.isEmpty() ) {
65  QFile file(fileName);
66  if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) ) {
67  kDebug()<<"We can't save in file :"<<fileName;
68  return;
69  }
70  QTextStream ts( &file );
71  ts.setCodec("UTF-8");
72  QString htmlStr = mDetails->toHtml();
73  htmlStr.replace(QLatin1String("meta name=\"qrichtext\" content=\"1\""), QLatin1String("meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\""));
74  ts << htmlStr;
75  file.close();
76  }
77  }
78 }
79 
80 void ScamDetectionDetailsDialog::setDetails(const QString &details)
81 {
82  mDetails->setHtml(details);
83 }
84 
85 void ScamDetectionDetailsDialog::readConfig()
86 {
87  KConfigGroup group( MessageViewer::GlobalSettings::self()->config(), "ScamDetectionDetailsDialog" );
88  const QSize size = group.readEntry( "Size", QSize(600, 400) );
89  if ( size.isValid() ) {
90  resize( size );
91  }
92 }
93 
94 void ScamDetectionDetailsDialog::writeConfig()
95 {
96  KConfigGroup group( MessageViewer::GlobalSettings::self()->config(), "ScamDetectionDetailsDialog" );
97  group.writeEntry( "Size", size() );
98  group.sync();
99 }
100 
101 #include "scamdetectiondetailsdialog.moc"
globalsettings.h
scamdetectiondetailsdialog.h
QWidget
KDialog
MessageViewer::AutoQPointer
A QPointer which when destructed, deletes the object it points to.
Definition: autoqpointer.h:38
autoqpointer.h
MessageViewer::GlobalSettings::self
static GlobalSettings * self()
Definition: globalsettings.cpp:34
MessageViewer::ScamDetectionDetailsDialog::~ScamDetectionDetailsDialog
~ScamDetectionDetailsDialog()
Definition: scamdetectiondetailsdialog.cpp:48
MessageViewer::ScamDetectionDetailsDialog::ScamDetectionDetailsDialog
ScamDetectionDetailsDialog(QWidget *parent=0)
Definition: scamdetectiondetailsdialog.cpp:33
MessageViewer::ScamDetectionDetailsDialog::setDetails
void setDetails(const QString &details)
Definition: scamdetectiondetailsdialog.cpp:80
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal