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

sweeper

  • sources
  • kde-4.12
  • kdeutils
  • sweeper
sweeper.cpp
Go to the documentation of this file.
1 
19 #include "sweeper.h"
20 
21 #include "privacyaction.h"
22 #include "privacyfunctions.h"
23 #include "sweeperadaptor.h"
24 
25 #include <kaction.h>
26 #include <kstandardaction.h>
27 #include <kconfig.h>
28 #include <kdebug.h>
29 #include <klocale.h>
30 #include <kmessagebox.h>
31 #include <QtDBus/QtDBus>
32 #include <kactioncollection.h>
33 
34 Sweeper::Sweeper(bool automatic)
35  : KXmlGuiWindow(0)
36  , m_privacyConfGroup(KSharedConfig::openConfig(QLatin1String( "kprivacyrc" ), KConfig::NoGlobals), "Cleaning")
37  , m_automatic(automatic)
38 {
39  QWidget *mainWidget = new QWidget(this);
40  ui.setupUi(mainWidget);
41  setCentralWidget(mainWidget);
42 
43  QTreeWidget *sw = ui.privacyListView;
44 
45  KStandardAction::quit(this, SLOT(close()), actionCollection());
46 
47  createGUI(QLatin1String( "sweeperui.rc" ));
48 
49  setAutoSaveSettings();
50 
51  generalCLI = new QTreeWidgetItem(QStringList() << i18nc("General system content", "General"));
52  sw->addTopLevelItem(generalCLI);
53  webbrowsingCLI = new QTreeWidgetItem(QStringList() << i18nc("Web browsing content", "Web Browsing"));
54  sw->addTopLevelItem(webbrowsingCLI);
55 
56  generalCLI->setExpanded(true);
57  webbrowsingCLI->setExpanded(true);
58 
59  this->InitActions();
60 
61 
62  connect(ui.cleanupButton, SIGNAL(clicked()), SLOT(cleanup()));
63  connect(ui.selectAllButton, SIGNAL(clicked()), SLOT(selectAll()));
64  connect(ui.selectNoneButton, SIGNAL(clicked()), SLOT(selectNone()));
65 
66  new KsweeperAdaptor(this);
67  QDBusConnection::sessionBus().registerObject(QLatin1String( "/ksweeper" ), this);
68 
69  load();
70 
71  if(automatic) {
72  cleanup();
73  close();
74  }
75 }
76 
77 
78 Sweeper::~Sweeper()
79 {
80  save();
81 }
82 
83 
84 void Sweeper::load()
85 {
86  QLinkedList<PrivacyAction*>::iterator itr;
87 
88  for (itr = checklist.begin(); itr != checklist.end(); ++itr) {
89  (*itr)->setCheckState(0, m_privacyConfGroup.readEntry((*itr)->configKey(), true) ? Qt::Checked : Qt::Unchecked);
90  }
91 }
92 
93 void Sweeper::save()
94 {
95  QLinkedList<PrivacyAction*>::iterator itr;
96 
97  for (itr = checklist.begin(); itr != checklist.end(); ++itr) {
98  m_privacyConfGroup.writeEntry((*itr)->configKey(), (*itr)->checkState(0) == Qt::Checked);
99  }
100 
101  m_privacyConfGroup.sync();
102 }
103 
104 void Sweeper::selectAll()
105 {
106  QLinkedList<PrivacyAction*>::iterator itr;
107 
108  for (itr = checklist.begin(); itr != checklist.end(); ++itr) {
109  (*itr)->setCheckState(0, Qt::Checked);
110  }
111 
112 }
113 
114 void Sweeper::selectNone()
115 {
116  QLinkedList<PrivacyAction*>::iterator itr;
117 
118  for (itr = checklist.begin(); itr != checklist.end(); ++itr) {
119  (*itr)->setCheckState(0, Qt::Unchecked);
120  }
121 
122 }
123 
124 
125 void Sweeper::cleanup()
126 {
127  if (!m_automatic) {
128  if (KMessageBox::warningContinueCancel(this, i18n("You are deleting data that is potentially valuable to you. Are you sure?")) != KMessageBox::Continue) {
129  return;
130  }
131  }
132 
133  ui.statusTextEdit->clear();
134  ui.statusTextEdit->setText(i18n("Starting cleanup..."));
135 
136  QLinkedList<PrivacyAction*>::iterator itr;
137 
138  for (itr = checklist.begin(); itr != checklist.end(); ++itr) {
139  if((*itr)->checkState(0) == Qt::Checked) {
140  QString statusText = i18n("Clearing %1...", (*itr)->text(0));
141  ui.statusTextEdit->append(statusText);
142 
143  // actions return whether they were successful
144  if(!(*itr)->action()) {
145  QString errorText = i18n("Clearing of %1 failed: %2", (*itr)->text(0), (*itr)->getErrMsg());
146  ui.statusTextEdit->append(errorText);
147  }
148  }
149  }
150 
151  ui.statusTextEdit->append(i18n("Clean up finished."));
152 }
153 
154 void Sweeper::InitActions() {
155  // store all entries in a list for easy access later on
156  checklist.append(new ClearSavedClipboardContentsAction(generalCLI));
157  checklist.append(new ClearRecentDocumentsAction(generalCLI));
158 #ifdef Q_WS_X11
159  checklist.append(new ClearRunCommandHistoryAction(generalCLI));
160  checklist.append( new ClearRecentApplicationAction( generalCLI ) );
161 #endif
162  checklist.append(new ClearThumbnailsAction(generalCLI));
163 
164  checklist.append(new ClearAllCookiesAction(webbrowsingCLI));
165  checklist.append(new ClearFaviconsAction(webbrowsingCLI));
166  checklist.append(new ClearWebHistoryAction(webbrowsingCLI));
167  checklist.append(new ClearWebCacheAction(webbrowsingCLI));
168  checklist.append(new ClearFormCompletionAction(webbrowsingCLI));
169  checklist.append(new ClearAllCookiesPoliciesAction(webbrowsingCLI));
170 
171  ui.privacyListView->resizeColumnToContents(0);
172 }
173 
174 #include "sweeper.moc"
175 
176 // kate: tab-width 3; indent-mode cstyle; replace-tabs true;
ClearAllCookiesPoliciesAction
Definition: privacyfunctions.h:43
ClearRunCommandHistoryAction
Definition: privacyfunctions.h:73
privacyfunctions.h
ClearFormCompletionAction
Definition: privacyfunctions.h:83
KXmlGuiWindow
ClearThumbnailsAction
Definition: privacyfunctions.h:63
Sweeper::Sweeper
Sweeper(bool automatic)
Copyright (c) 2003-2005 Ralf Hoelzer ralf@well.com
Definition: sweeper.cpp:34
ClearWebHistoryAction
Definition: privacyfunctions.h:93
ClearSavedClipboardContentsAction
Definition: privacyfunctions.h:53
QTreeWidgetItem
ClearWebCacheAction
Definition: privacyfunctions.h:103
Sweeper::~Sweeper
~Sweeper()
Definition: sweeper.cpp:78
sweeper.h
ClearFaviconsAction
Definition: privacyfunctions.h:123
ClearRecentDocumentsAction
Definition: privacyfunctions.h:113
privacyaction.h
ClearRecentApplicationAction
Definition: privacyfunctions.h:133
Sweeper::cleanup
void cleanup()
Definition: sweeper.cpp:125
ClearAllCookiesAction
kprivacymanager.h
Definition: privacyfunctions.h:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

sweeper

Skip menu "sweeper"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

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