Carbon, QFontDialog::getFont() ignore the "initial" parameter
[qt-netbsd.git] / demos / browser / cookiejar.h
blobffcd4c189e29eb1434f332b575d47542b73bac2e
1 /****************************************************************************
2 **
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: Qt Software Information (qt-info@nokia.com)
5 **
6 ** This file is part of the demonstration applications of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** No Commercial Usage
10 ** This file contains pre-release code and may not be distributed.
11 ** You may use this file in accordance with the terms and conditions
12 ** contained in the either Technology Preview License Agreement or the
13 ** Beta Release License Agreement.
15 ** GNU Lesser General Public License Usage
16 ** Alternatively, this file may be used under the terms of the GNU Lesser
17 ** General Public License version 2.1 as published by the Free Software
18 ** Foundation and appearing in the file LICENSE.LGPL included in the
19 ** packaging of this file. Please review the following information to
20 ** ensure the GNU Lesser General Public License version 2.1 requirements
21 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23 ** In addition, as a special exception, Nokia gives you certain
24 ** additional rights. These rights are described in the Nokia Qt LGPL
25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26 ** package.
28 ** GNU General Public License Usage
29 ** Alternatively, this file may be used under the terms of the GNU
30 ** General Public License version 3.0 as published by the Free Software
31 ** Foundation and appearing in the file LICENSE.GPL included in the
32 ** packaging of this file. Please review the following information to
33 ** ensure the GNU General Public License version 3.0 requirements will be
34 ** met: http://www.gnu.org/copyleft/gpl.html.
36 ** If you are unsure which license is appropriate for your use, please
37 ** contact the sales department at qt-sales@nokia.com.
38 ** $QT_END_LICENSE$
40 ****************************************************************************/
42 #ifndef COOKIEJAR_H
43 #define COOKIEJAR_H
45 #include <QtNetwork/QNetworkCookieJar>
47 #include <QtCore/QAbstractItemModel>
48 #include <QtCore/QStringList>
50 #include <QtGui/QDialog>
51 #include <QtGui/QTableView>
53 QT_BEGIN_NAMESPACE
54 class QSortFilterProxyModel;
55 class QKeyEvent;
56 QT_END_NAMESPACE
58 class AutoSaver;
60 class CookieJar : public QNetworkCookieJar
62 friend class CookieModel;
63 Q_OBJECT
64 Q_PROPERTY(AcceptPolicy acceptPolicy READ acceptPolicy WRITE setAcceptPolicy)
65 Q_PROPERTY(KeepPolicy keepPolicy READ keepPolicy WRITE setKeepPolicy)
66 Q_PROPERTY(QStringList blockedCookies READ blockedCookies WRITE setBlockedCookies)
67 Q_PROPERTY(QStringList allowedCookies READ allowedCookies WRITE setAllowedCookies)
68 Q_PROPERTY(QStringList allowForSessionCookies READ allowForSessionCookies WRITE setAllowForSessionCookies)
69 Q_ENUMS(KeepPolicy)
70 Q_ENUMS(AcceptPolicy)
72 signals:
73 void cookiesChanged();
75 public:
76 enum AcceptPolicy {
77 AcceptAlways,
78 AcceptNever,
79 AcceptOnlyFromSitesNavigatedTo
82 enum KeepPolicy {
83 KeepUntilExpire,
84 KeepUntilExit,
85 KeepUntilTimeLimit
88 CookieJar(QObject *parent = 0);
89 ~CookieJar();
91 QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const;
92 bool setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url);
94 AcceptPolicy acceptPolicy() const;
95 void setAcceptPolicy(AcceptPolicy policy);
97 KeepPolicy keepPolicy() const;
98 void setKeepPolicy(KeepPolicy policy);
100 QStringList blockedCookies() const;
101 QStringList allowedCookies() const;
102 QStringList allowForSessionCookies() const;
104 void setBlockedCookies(const QStringList &list);
105 void setAllowedCookies(const QStringList &list);
106 void setAllowForSessionCookies(const QStringList &list);
108 public slots:
109 void clear();
110 void loadSettings();
112 private slots:
113 void save();
115 private:
116 void purgeOldCookies();
117 void load();
118 bool m_loaded;
119 AutoSaver *m_saveTimer;
121 AcceptPolicy m_acceptCookies;
122 KeepPolicy m_keepCookies;
124 QStringList m_exceptions_block;
125 QStringList m_exceptions_allow;
126 QStringList m_exceptions_allowForSession;
129 class CookieModel : public QAbstractTableModel
131 Q_OBJECT
133 public:
134 CookieModel(CookieJar *jar, QObject *parent = 0);
135 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
136 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
137 int columnCount(const QModelIndex &parent = QModelIndex()) const;
138 int rowCount(const QModelIndex &parent = QModelIndex()) const;
139 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
141 private slots:
142 void cookiesChanged();
144 private:
145 CookieJar *m_cookieJar;
148 #include "ui_cookies.h"
149 #include "ui_cookiesexceptions.h"
151 class CookiesDialog : public QDialog, public Ui_CookiesDialog
153 Q_OBJECT
155 public:
156 CookiesDialog(CookieJar *cookieJar, QWidget *parent = 0);
158 private:
159 QSortFilterProxyModel *m_proxyModel;
162 class CookieExceptionsModel : public QAbstractTableModel
164 Q_OBJECT
165 friend class CookiesExceptionsDialog;
167 public:
168 CookieExceptionsModel(CookieJar *cookieJar, QObject *parent = 0);
169 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
170 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
171 int columnCount(const QModelIndex &parent = QModelIndex()) const;
172 int rowCount(const QModelIndex &parent = QModelIndex()) const;
173 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
175 private:
176 CookieJar *m_cookieJar;
178 // Domains we allow, Domains we block, Domains we allow for this session
179 QStringList m_allowedCookies;
180 QStringList m_blockedCookies;
181 QStringList m_sessionCookies;
184 class CookiesExceptionsDialog : public QDialog, public Ui_CookiesExceptionsDialog
186 Q_OBJECT
188 public:
189 CookiesExceptionsDialog(CookieJar *cookieJar, QWidget *parent = 0);
191 private slots:
192 void block();
193 void allow();
194 void allowForSession();
195 void textChanged(const QString &text);
197 private:
198 CookieExceptionsModel *m_exceptionsModel;
199 QSortFilterProxyModel *m_proxyModel;
200 CookieJar *m_cookieJar;
203 #endif // COOKIEJAR_H