2015-01-21 12:59:20 +01:00
|
|
|
/* ============================================================
|
2017-08-25 17:55:52 +02:00
|
|
|
* TabManager plugin for Falkon
|
2017-04-06 18:20:51 +02:00
|
|
|
* Copyright (C) 2013-2017 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
|
2015-01-21 12:59: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/>.
|
|
|
|
* ============================================================ */
|
|
|
|
#ifndef TABMANAGERWIDGET_H
|
|
|
|
#define TABMANAGERWIDGET_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QHash>
|
2017-10-03 12:42:01 +02:00
|
|
|
#include <QTreeWidgetItem>
|
2015-01-21 12:59:20 +01:00
|
|
|
|
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class TabManagerWidget;
|
|
|
|
}
|
|
|
|
class QUrl;
|
|
|
|
class QTreeWidgetItem;
|
|
|
|
class BrowserWindow;
|
|
|
|
class WebPage;
|
|
|
|
class WebTab;
|
2015-05-24 21:53:12 +02:00
|
|
|
class WebView;
|
2015-01-21 12:59:20 +01:00
|
|
|
class TLDExtractor;
|
|
|
|
|
2017-10-03 14:54:43 +02:00
|
|
|
class TabTreeWidget : public QTreeWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
TabTreeWidget(QWidget* parent = 0);
|
|
|
|
|
|
|
|
Qt::DropActions supportedDropActions() const;
|
|
|
|
QStringList mimeTypes() const;
|
|
|
|
QMimeData* mimeData(const QList<QTreeWidgetItem*> items) const;
|
|
|
|
bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action);
|
|
|
|
|
|
|
|
void setEnableDragTabs(bool enable);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void requestRefreshTree();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-01-21 12:59:20 +01:00
|
|
|
class TabManagerWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum GroupType {
|
|
|
|
GroupByWindow = 0,
|
|
|
|
GroupByDomain = 1,
|
|
|
|
GroupByHost = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
explicit TabManagerWidget(BrowserWindow* mainClass, QWidget* parent = 0, bool defaultWidget = false);
|
|
|
|
~TabManagerWidget();
|
|
|
|
|
|
|
|
void closeSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash);
|
|
|
|
void detachSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash);
|
|
|
|
bool bookmarkSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash);
|
2018-01-24 15:10:45 +01:00
|
|
|
void unloadSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash);
|
2015-01-21 12:59:20 +01:00
|
|
|
|
|
|
|
void setGroupType(GroupType type);
|
|
|
|
|
|
|
|
static QString domainFromUrl(const QUrl &url, bool useHostName = false);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void delayedRefreshTree(WebPage* p = 0);
|
|
|
|
void changeGroupType();
|
|
|
|
|
|
|
|
private:
|
2017-10-03 10:39:13 +02:00
|
|
|
QTreeWidgetItem* groupByDomainName(bool useHostName = false);
|
|
|
|
QTreeWidgetItem* groupByWindow();
|
2017-08-25 17:11:29 +02:00
|
|
|
BrowserWindow* getWindow();
|
2015-01-21 12:59:20 +01:00
|
|
|
|
|
|
|
Ui::TabManagerWidget* ui;
|
2017-08-25 17:11:29 +02:00
|
|
|
QPointer<BrowserWindow> m_window;
|
2015-01-21 12:59:20 +01:00
|
|
|
WebPage* m_webPage;
|
|
|
|
|
|
|
|
bool m_isRefreshing;
|
|
|
|
bool m_refreshBlocked;
|
|
|
|
bool m_waitForRefresh;
|
|
|
|
bool m_isDefaultWidget;
|
|
|
|
GroupType m_groupType;
|
|
|
|
|
2016-08-29 10:18:31 +02:00
|
|
|
QString m_filterText;
|
|
|
|
|
2015-01-21 12:59:20 +01:00
|
|
|
static TLDExtractor* s_tldExtractor;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void refreshTree();
|
|
|
|
void processActions();
|
2017-04-06 18:20:51 +02:00
|
|
|
void onItemActivated(QTreeWidgetItem* item, int column);
|
2015-01-21 12:59:20 +01:00
|
|
|
bool isTabSelected();
|
|
|
|
void customContextMenuRequested(const QPoint &pos);
|
2016-08-29 10:18:31 +02:00
|
|
|
void filterChanged(const QString &filter, bool force = false);
|
|
|
|
void filterBarClosed();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject* obj, QEvent* event);
|
2015-01-21 12:59:20 +01:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void showSideBySide();
|
|
|
|
void groupTypeChanged(TabManagerWidget::GroupType);
|
|
|
|
};
|
|
|
|
|
2017-10-03 12:42:01 +02:00
|
|
|
class TabItem : public QObject, public QTreeWidgetItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum StateRole {
|
2017-10-03 13:16:21 +02:00
|
|
|
ActiveOrCaptionRole = Qt::UserRole + 1,
|
|
|
|
SavedRole = Qt::UserRole + 2
|
2017-10-03 12:42:01 +02:00
|
|
|
};
|
|
|
|
|
2017-10-03 14:54:43 +02:00
|
|
|
TabItem(QTreeWidget* treeWidget, bool supportDrag = true, bool isTab = true, QTreeWidgetItem* parent = 0, bool addToTree = true);
|
2017-10-03 12:42:01 +02:00
|
|
|
|
|
|
|
BrowserWindow* window() const;
|
|
|
|
void setBrowserWindow(BrowserWindow* window);
|
|
|
|
|
|
|
|
WebTab* webTab() const;
|
|
|
|
void setWebTab(WebTab* webTab);
|
|
|
|
|
2017-10-03 14:54:43 +02:00
|
|
|
bool isTab() const;
|
|
|
|
|
2017-10-03 12:42:01 +02:00
|
|
|
public slots:
|
|
|
|
void updateIcon();
|
|
|
|
void setTitle(const QString& title);
|
|
|
|
void setIsActiveOrCaption(bool yes);
|
2017-10-03 13:16:21 +02:00
|
|
|
void setIsSavedTab(bool yes);
|
2017-10-03 12:42:01 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
QTreeWidget* m_treeWidget;
|
|
|
|
BrowserWindow* m_window;
|
|
|
|
WebTab* m_webTab;
|
2017-10-03 14:54:43 +02:00
|
|
|
bool m_isTab;
|
2017-10-03 12:42:01 +02:00
|
|
|
};
|
|
|
|
|
2015-01-21 12:59:20 +01:00
|
|
|
#endif // TABMANAGERWIDGET_H
|