2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2012-01-01 15:29:55 +01:00
|
|
|
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
2011-03-03 18:29:20 +01:00
|
|
|
*
|
|
|
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
2011-03-02 16:57:41 +01:00
|
|
|
#include "clearprivatedata.h"
|
|
|
|
#include "qupzilla.h"
|
2012-01-21 23:19:38 +01:00
|
|
|
#include "tabwidget.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
#include "cookiejar.h"
|
|
|
|
#include "mainapplication.h"
|
|
|
|
#include "networkmanager.h"
|
|
|
|
#include "clickablelabel.h"
|
2011-03-18 16:08:24 +01:00
|
|
|
#include "ui_clearprivatedata.h"
|
2011-04-28 18:31:48 +02:00
|
|
|
#include "iconprovider.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-10-26 19:23:50 +02:00
|
|
|
ClearPrivateData::ClearPrivateData(QupZilla* mainClass, QWidget* parent)
|
|
|
|
: QDialog(parent)
|
|
|
|
, p_QupZilla(mainClass)
|
|
|
|
, ui(new Ui::ClearPrivateData)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2011-03-18 18:35:09 +01:00
|
|
|
ui->setupUi(this);
|
|
|
|
ui->buttonBox->setFocus();
|
|
|
|
connect(ui->clearAdobeCookies, SIGNAL(clicked(QPoint)), this, SLOT(clearFlash()));
|
|
|
|
connect(ui->history, SIGNAL(clicked(bool)), this, SLOT(historyClicked(bool)));
|
|
|
|
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(dialogAccepted()));
|
2011-10-26 19:23:50 +02:00
|
|
|
|
|
|
|
//Resizing +2 of sizeHint to get visible underlined link
|
|
|
|
resize(sizeHint().width(), sizeHint().height() + 2);
|
2011-03-18 18:35:09 +01:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-03-18 18:35:09 +01:00
|
|
|
void ClearPrivateData::historyClicked(bool state)
|
|
|
|
{
|
|
|
|
ui->historyLength->setEnabled(state);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClearPrivateData::clearFlash()
|
|
|
|
{
|
2011-03-18 18:35:09 +01:00
|
|
|
p_QupZilla->tabWidget()->addView(QUrl("http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager07.html"));
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClearPrivateData::dialogAccepted()
|
|
|
|
{
|
2011-07-30 17:57:14 +02:00
|
|
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
2011-03-18 18:35:09 +01:00
|
|
|
if (ui->history->isChecked()) {
|
|
|
|
QDateTime dateTime = QDateTime::currentDateTime();
|
|
|
|
qint64 nowMS = QDateTime::currentMSecsSinceEpoch();
|
2011-03-19 18:39:03 +01:00
|
|
|
qint64 date = 0;
|
2011-03-18 18:35:09 +01:00
|
|
|
|
|
|
|
switch (ui->historyLength->currentIndex()) {
|
|
|
|
case 0: //Later Today
|
2011-11-06 17:01:23 +01:00
|
|
|
dateTime.setTime(QTime(0, 0));
|
2011-03-18 18:35:09 +01:00
|
|
|
date = dateTime.toMSecsSinceEpoch();
|
|
|
|
break;
|
|
|
|
case 1: //Week
|
|
|
|
date = nowMS - 60u * 60u * 24u * 7u * 1000u;
|
|
|
|
break;
|
|
|
|
case 2: //Month
|
|
|
|
date = nowMS - 60u * 60u * 24u * 30u * 1000u;
|
|
|
|
break;
|
|
|
|
case 3: //All
|
|
|
|
date = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
QSqlQuery query;
|
2011-11-06 17:01:23 +01:00
|
|
|
query.exec("DELETE FROM history WHERE date > " + QString::number(date));
|
2011-03-02 16:57:41 +01:00
|
|
|
query.exec("VACUUM");
|
|
|
|
}
|
2011-03-18 18:35:09 +01:00
|
|
|
if (ui->cookies->isChecked()) {
|
2011-03-02 16:57:41 +01:00
|
|
|
QList<QNetworkCookie> cookies;
|
2011-03-04 13:59:07 +01:00
|
|
|
mApp->cookieJar()->setAllCookies(cookies);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-03-18 18:35:09 +01:00
|
|
|
if (ui->cache->isChecked()) {
|
2011-03-04 13:59:07 +01:00
|
|
|
mApp->webSettings()->clearMemoryCaches();
|
|
|
|
mApp->networkManager()->cache()->clear();
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-03-18 18:35:09 +01:00
|
|
|
if (ui->icons->isChecked()) {
|
2011-03-04 13:59:07 +01:00
|
|
|
mApp->webSettings()->clearIconDatabase();
|
2011-04-28 18:31:48 +02:00
|
|
|
mApp->iconProvider()->clearIconDatabase();
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-07-30 17:57:14 +02:00
|
|
|
QApplication::restoreOverrideCursor();
|
2011-03-02 16:57:41 +01:00
|
|
|
close();
|
|
|
|
}
|