1 /************************************************************************** 2 * Otter Browser: Web browser controlled by the user, not vice-versa. 3 * Copyright (C) 2016 - 2019 Michal Dutkiewicz aka Emdek <michal@emdek.pl> 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 **************************************************************************/ 19 20 #ifndef OTTER_PASSWORDSCONTENTSWIDGET_H 21 #define OTTER_PASSWORDSCONTENTSWIDGET_H 22 23 #include "../../../ui/ContentsWidget.h" 24 25 #include <QtGui/QStandardItemModel> 26 27 namespace Otter 28 { 29 30 namespace Ui 31 { 32 class PasswordsContentsWidget; 33 } 34 35 class Window; 36 37 class PasswordsContentsWidget final : public ContentsWidget 38 { 39 Q_OBJECT 40 41 public: 42 enum DataRole 43 { 44 HostRole = Qt::UserRole, 45 UrlRole, 46 AuthTypeRole, 47 FieldTypeRole 48 }; 49 50 explicit PasswordsContentsWidget(const QVariantMap ¶meters, Window *window, QWidget *parent); 51 ~PasswordsContentsWidget(); 52 53 void print(QPrinter *printer) override; 54 QString getTitle() const override; 55 QLatin1String getType() const override; 56 QUrl getUrl() const override; 57 QIcon getIcon() const override; 58 ActionsManager::ActionDefinition::State getActionState(int identifier, const QVariantMap ¶meters = {}) const override; 59 WebWidget::LoadingState getLoadingState() const override; 60 bool eventFilter(QObject *object, QEvent *event) override; 61 62 public slots: 63 void triggerAction(int identifier, const QVariantMap ¶meters = {}, ActionsManager::TriggerType trigger = ActionsManager::UnknownTrigger) override; 64 65 protected: 66 void changeEvent(QEvent *event) override; 67 PasswordsManager::PasswordInformation getPassword(const QModelIndex &index) const; 68 69 protected slots: 70 void populatePasswords(); 71 void filterPasswords(const QString &filter); 72 void removePasswords(); 73 void removeHostPasswords(); 74 void removeAllPasswords(); 75 void showContextMenu(const QPoint &position); 76 77 private: 78 QStandardItemModel *m_model; 79 bool m_isLoading; 80 Ui::PasswordsContentsWidget *m_ui; 81 }; 82 83 } 84 85 #endif 86