2018-11-11 14:41:06 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
* gui/common/RSFeedWidget.h *
|
|
|
|
* *
|
|
|
|
* Copyright (C) 2014, Retroshare Team <retroshare.project@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero 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 Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2014-08-01 10:49:58 -04:00
|
|
|
|
|
|
|
#ifndef _RSFEEDTREEWIDGET_H
|
|
|
|
#define _RSFEEDTREEWIDGET_H
|
|
|
|
|
|
|
|
#include <QAbstractItemView>
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QMap>
|
|
|
|
|
|
|
|
#define FEED_TREEWIDGET_SORTROLE Qt::UserRole
|
|
|
|
|
|
|
|
class FeedItem;
|
|
|
|
class QTreeWidgetItem;
|
|
|
|
class RSTreeWidgetItemCompareRole;
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class RSFeedWidget;
|
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
typedef void (*RSFeedWidgetCallbackFunction)(FeedItem *feedItem, void *data);
|
|
|
|
typedef bool (*RSFeedWidgetFindCallbackFunction)(FeedItem *feedItem, void *data);
|
2014-08-01 10:49:58 -04:00
|
|
|
typedef bool (*RSFeedWidgetFilterCallbackFunction)(FeedItem *feedItem, const QString &text, int filter);
|
|
|
|
|
|
|
|
class RSFeedWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
RSFeedWidget(QWidget *parent = 0);
|
|
|
|
virtual ~RSFeedWidget();
|
|
|
|
|
2015-02-09 16:13:07 -05:00
|
|
|
QString placeholderText();
|
|
|
|
void setPlaceholderText(const QString &placeholderText);
|
|
|
|
|
2014-08-01 10:49:58 -04:00
|
|
|
void addFeedItem(FeedItem *feedItem, Qt::ItemDataRole sortRole, const QVariant &value);
|
|
|
|
void addFeedItem(FeedItem *feedItem, const QMap<Qt::ItemDataRole, QVariant> &sort);
|
|
|
|
|
|
|
|
void setSort(FeedItem *feedItem, Qt::ItemDataRole sortRole, const QVariant &value);
|
|
|
|
void setSort(FeedItem *feedItem, const QMap<Qt::ItemDataRole, QVariant> &sort);
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
int feedItemCount();
|
|
|
|
FeedItem *feedItem(int index);
|
2014-08-01 10:49:58 -04:00
|
|
|
void removeFeedItem(FeedItem *feedItem);
|
|
|
|
|
|
|
|
void setSortRole(Qt::ItemDataRole role, Qt::SortOrder order);
|
|
|
|
void setSortingEnabled(bool enable);
|
|
|
|
void setFilterCallback(RSFeedWidgetFilterCallbackFunction callback);
|
|
|
|
|
|
|
|
void enableRemove(bool enable);
|
2014-11-15 12:24:49 -05:00
|
|
|
void enableCountChangedSignal(bool enable);
|
2014-08-01 10:49:58 -04:00
|
|
|
void setSelectionMode(QAbstractItemView::SelectionMode mode);
|
|
|
|
|
2014-10-25 19:52:33 -04:00
|
|
|
bool scrollTo(FeedItem *feedItem, bool focus);
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void withAll(RSFeedWidgetCallbackFunction callback, void *data);
|
2019-12-21 08:33:53 -05:00
|
|
|
FeedItem *findFeedItem(uint64_t identifier);
|
2014-08-01 10:49:58 -04:00
|
|
|
|
|
|
|
void selectedFeedItems(QList<FeedItem*> &feedItems);
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
signals:
|
|
|
|
void feedCountChanged();
|
|
|
|
|
2014-08-01 10:49:58 -04:00
|
|
|
public slots:
|
2014-11-15 12:24:49 -05:00
|
|
|
void clear();
|
2014-08-01 10:49:58 -04:00
|
|
|
void setFilter(const QString &text, int type);
|
|
|
|
void setFilterText(const QString &text);
|
|
|
|
void setFilterType(int type);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *object, QEvent *event);
|
2015-03-12 09:59:56 -04:00
|
|
|
virtual void feedAdded(FeedItem *feedItem, QTreeWidgetItem *treeItem);
|
|
|
|
virtual void feedsCleared();
|
2014-08-01 10:49:58 -04:00
|
|
|
|
|
|
|
private slots:
|
2020-01-14 15:43:29 -05:00
|
|
|
void feedItemDestroyed(qulonglong id);
|
2014-08-01 10:49:58 -04:00
|
|
|
void feedItemSizeChanged(FeedItem *feedItem);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void connectSignals(FeedItem *feedItem);
|
|
|
|
void disconnectSignals(FeedItem *feedItem);
|
|
|
|
FeedItem *feedItemFromTreeItem(QTreeWidgetItem *treeItem);
|
2019-12-21 08:33:53 -05:00
|
|
|
QTreeWidgetItem *findTreeWidgetItem(uint64_t identifier);
|
2020-01-16 14:33:34 -05:00
|
|
|
QTreeWidgetItem *findTreeWidgetItem(const FeedItem *w);
|
2014-08-01 10:49:58 -04:00
|
|
|
void filterItems();
|
|
|
|
void filterItem(QTreeWidgetItem *treeItem, FeedItem *feedItem);
|
|
|
|
|
|
|
|
private:
|
|
|
|
/* Sort */
|
|
|
|
RSTreeWidgetItemCompareRole *mFeedCompareRole;
|
|
|
|
|
|
|
|
/* Filter */
|
|
|
|
RSFeedWidgetFilterCallbackFunction mFilterCallback;
|
|
|
|
QString mFilterText;
|
|
|
|
int mFilterType;
|
|
|
|
|
|
|
|
/* Remove */
|
|
|
|
bool mEnableRemove;
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
/* Options */
|
|
|
|
int mCountChangedDisabled;
|
|
|
|
|
2014-08-01 10:49:58 -04:00
|
|
|
Ui::RSFeedWidget *ui;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|