File indexing completed on 2024-05-19 04:59:18

0001 /* ============================================================
0002 * Personal Information Manager plugin for Falkon
0003 * Copyright (C) 2012-2014  David Rosca <nowrep@gmail.com>
0004 * Copyright (C) 2012-2014  Mladen Pejaković <pejakm@autistici.org>
0005 *
0006 * This program is free software: you can redistribute it and/or modify
0007 * it under the terms of the GNU General Public License as published by
0008 * the Free Software Foundation, either version 3 of the License, or
0009 * (at your option) any later version.
0010 *
0011 * This program is distributed in the hope that it will be useful,
0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 * GNU General Public License for more details.
0015 *
0016 * You should have received a copy of the GNU General Public License
0017 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018 * ============================================================ */
0019 #ifndef PIM_HANDLER_H
0020 #define PIM_HANDLER_H
0021 
0022 #include <QObject>
0023 #include <QMessageBox>
0024 #include <QMenu>
0025 #include <QPointer>
0026 #include <QHash>
0027 
0028 class WebView;
0029 class WebPage;
0030 class WebHitTestResult;
0031 
0032 class PIM_Settings;
0033 
0034 class PIM_Handler : public QObject
0035 {
0036     Q_OBJECT
0037 public:
0038     explicit PIM_Handler(const QString &sPath, QObject* parent = nullptr);
0039 
0040     void populateWebViewMenu(QMenu* menu, WebView* view, const WebHitTestResult &hitTest);
0041     bool keyPress(WebView* view, QKeyEvent* event);
0042 
0043     void unloadPlugin();
0044 
0045 public Q_SLOTS:
0046     void webPageCreated(WebPage* page);
0047     void showSettings(QWidget* parent = nullptr);
0048 
0049 private Q_SLOTS:
0050     void loadSettings();
0051     void pimInsert();
0052 
0053     void pageLoadFinished();
0054 
0055 private:
0056     enum PI_Type {
0057         PI_LastName = 0,
0058         PI_FirstName = 1,
0059         PI_Email = 2,
0060         PI_Mobile = 3,
0061         PI_Phone = 4,
0062         PI_Address = 5,
0063         PI_City = 6,
0064         PI_Zip = 7,
0065         PI_State = 8,
0066         PI_Country = 9,
0067         PI_HomePage = 10,
0068         PI_Special1 = 11,
0069         PI_Special2 = 12,
0070         PI_Special3 = 13,
0071         PI_Max = 14,
0072         PI_Invalid = 128
0073     };
0074 
0075     QString matchingJsTable() const;
0076 
0077     QHash<PI_Type, QString> m_allInfo;
0078     QHash<PI_Type, QStringList> m_infoMatches;
0079     QHash<PI_Type, QString> m_translations;
0080 
0081     QPointer<PIM_Settings> m_settings;
0082     QPointer<WebView> m_view;
0083     QPoint m_clickedPos;
0084 
0085     QString m_settingsFile;
0086     bool m_loaded;
0087 };
0088 
0089 #endif // PIM_HANDLER_H