2010-12-26 19:15:25 -05:00
|
|
|
/****************************************************************
|
|
|
|
* This file is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010, RetroShare Team
|
|
|
|
*
|
|
|
|
* 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 2
|
|
|
|
* 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#ifndef GROUPTREEWIDGET_H
|
|
|
|
#define GROUPTREEWIDGET_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QTreeWidgetItem>
|
|
|
|
#include <QDateTime>
|
|
|
|
|
2012-08-21 09:02:44 -04:00
|
|
|
class QToolButton;
|
2011-01-04 15:19:45 -05:00
|
|
|
class RshareSettings;
|
|
|
|
class RSTreeWidgetItemCompareRole;
|
2013-01-05 21:30:10 -05:00
|
|
|
class RSTreeWidget;
|
2011-01-04 15:19:45 -05:00
|
|
|
|
2012-11-19 11:01:21 -05:00
|
|
|
#define GROUPTREEWIDGET_COLOR_STANDARD -1
|
|
|
|
#define GROUPTREEWIDGET_COLOR_CATEGORY 0
|
|
|
|
#define GROUPTREEWIDGET_COLOR_PRIVATEKEY 1
|
|
|
|
#define GROUPTREEWIDGET_COLOR_COUNT 2
|
|
|
|
|
2010-12-26 19:15:25 -05:00
|
|
|
namespace Ui {
|
|
|
|
class GroupTreeWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
class GroupItemInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GroupItemInfo()
|
2017-08-13 12:47:36 -04:00
|
|
|
: popularity(0), publishKey(false), adminKey(false)
|
|
|
|
, subscribeFlags(0), max_visible_posts(0)
|
|
|
|
{}
|
2010-12-26 19:15:25 -05:00
|
|
|
|
|
|
|
public:
|
|
|
|
QString id;
|
|
|
|
QString name;
|
|
|
|
QString description;
|
|
|
|
int popularity;
|
|
|
|
QDateTime lastpost;
|
|
|
|
QIcon icon;
|
2016-06-16 22:23:27 -04:00
|
|
|
bool publishKey;
|
|
|
|
bool adminKey;
|
2014-12-16 01:54:15 -05:00
|
|
|
quint32 subscribeFlags;
|
|
|
|
quint32 max_visible_posts ;
|
2010-12-26 19:15:25 -05:00
|
|
|
};
|
|
|
|
|
2017-08-13 12:47:36 -04:00
|
|
|
//cppcheck-suppress noConstructor
|
2010-12-26 19:15:25 -05:00
|
|
|
class GroupTreeWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2012-11-19 11:01:21 -05:00
|
|
|
Q_PROPERTY(QColor textColorCategory READ textColorCategory WRITE setTextColorCategory)
|
|
|
|
Q_PROPERTY(QColor textColorPrivateKey READ textColorPrivateKey WRITE setTextColorPrivateKey)
|
|
|
|
|
2010-12-26 19:15:25 -05:00
|
|
|
public:
|
|
|
|
GroupTreeWidget(QWidget *parent = 0);
|
|
|
|
~GroupTreeWidget();
|
|
|
|
|
2013-08-30 08:24:39 -04:00
|
|
|
// Add a tool button to the tool area
|
2013-08-29 16:32:14 -04:00
|
|
|
void addToolButton(QToolButton *toolButton);
|
|
|
|
|
2018-05-08 06:08:08 -04:00
|
|
|
// Load and save settings (group must be started from the caller)
|
|
|
|
void processSettings(bool load);
|
2011-01-04 15:19:45 -05:00
|
|
|
|
2010-12-26 19:15:25 -05:00
|
|
|
// Add a new category item
|
2014-07-26 19:52:45 -04:00
|
|
|
QTreeWidgetItem *addCategoryItem(const QString &name, const QIcon &icon, bool expand);
|
2018-06-20 17:26:37 -04:00
|
|
|
// Add a new search item
|
2018-07-05 08:00:04 -04:00
|
|
|
void setDistSearchVisible(bool) ; // shows/hides distant search UI parts.
|
2018-06-20 17:26:37 -04:00
|
|
|
QTreeWidgetItem *addSearchItem(const QString& search_string, uint32_t id, const QIcon &icon) ;
|
|
|
|
void removeSearchItem(QTreeWidgetItem *item);
|
|
|
|
|
2014-07-26 19:52:45 -04:00
|
|
|
// Get id of item
|
|
|
|
QString itemId(QTreeWidgetItem *item);
|
|
|
|
QString itemIdAt(QPoint &point);
|
|
|
|
// Fill items of a group
|
|
|
|
void fillGroupItems(QTreeWidgetItem *categoryItem, const QList<GroupItemInfo> &itemList);
|
|
|
|
// Set the unread count of an item
|
2010-12-26 19:15:25 -05:00
|
|
|
void setUnreadCount(QTreeWidgetItem *item, int unreadCount);
|
|
|
|
|
2018-06-20 17:26:37 -04:00
|
|
|
bool isSearchRequestItem(QPoint &point,uint32_t& search_req_id);
|
2018-07-05 05:43:55 -04:00
|
|
|
bool isSearchRequestResult(QPoint &point, QString &group_id, uint32_t& search_req_id);
|
2018-06-20 17:26:37 -04:00
|
|
|
|
2011-04-19 15:42:44 -04:00
|
|
|
QTreeWidgetItem *getItemFromId(const QString &id);
|
|
|
|
QTreeWidgetItem *activateId(const QString &id, bool focus);
|
|
|
|
|
2015-03-14 17:13:28 -04:00
|
|
|
bool setWaiting(const QString &id, bool wait);
|
|
|
|
|
2013-01-05 21:30:10 -05:00
|
|
|
RSTreeWidget *treeWidget();
|
|
|
|
|
2012-11-19 11:01:21 -05:00
|
|
|
QColor textColorCategory() const { return mTextColor[GROUPTREEWIDGET_COLOR_CATEGORY]; }
|
|
|
|
QColor textColorPrivateKey() const { return mTextColor[GROUPTREEWIDGET_COLOR_PRIVATEKEY]; }
|
|
|
|
|
|
|
|
void setTextColorCategory(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_CATEGORY] = color; }
|
|
|
|
void setTextColorPrivateKey(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_PRIVATEKEY] = color; }
|
2014-07-26 19:52:45 -04:00
|
|
|
bool getGroupName(QString id, QString& name);
|
2012-11-19 11:01:21 -05:00
|
|
|
|
2012-11-28 07:31:14 -05:00
|
|
|
int subscribeFlags(const QString &id);
|
|
|
|
|
2010-12-26 19:15:25 -05:00
|
|
|
signals:
|
2011-01-04 15:19:45 -05:00
|
|
|
void treeCustomContextMenuRequested(const QPoint &pos);
|
|
|
|
void treeCurrentItemChanged(const QString &id);
|
2012-12-29 21:41:53 -05:00
|
|
|
void treeItemActivated(const QString &id);
|
2018-06-20 16:30:44 -04:00
|
|
|
void distantSearchRequested(const QString&) ;
|
2010-12-26 19:15:25 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void changeEvent(QEvent *e);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void customContextMenuRequested(const QPoint &pos);
|
2011-01-04 15:19:45 -05:00
|
|
|
void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
2012-12-29 21:41:53 -05:00
|
|
|
void itemActivated(QTreeWidgetItem *item, int column);
|
2010-12-26 19:15:25 -05:00
|
|
|
void filterChanged();
|
2018-06-20 16:30:44 -04:00
|
|
|
void distantSearch();
|
2010-12-26 19:15:25 -05:00
|
|
|
|
2011-01-04 15:19:45 -05:00
|
|
|
void sort();
|
|
|
|
|
2010-12-26 19:15:25 -05:00
|
|
|
private:
|
2013-08-29 16:32:14 -04:00
|
|
|
// Initialize the display menu for sorting
|
|
|
|
void initDisplayMenu(QToolButton *toolButton);
|
2012-04-05 17:03:03 -04:00
|
|
|
void calculateScore(QTreeWidgetItem *item, const QString &filterText);
|
2011-01-04 15:19:45 -05:00
|
|
|
void resort(QTreeWidgetItem *categoryItem);
|
2012-11-19 11:01:21 -05:00
|
|
|
void updateColors();
|
2010-12-26 19:15:25 -05:00
|
|
|
|
|
|
|
private:
|
2011-01-04 15:19:45 -05:00
|
|
|
QMenu *displayMenu;
|
|
|
|
QAction *actionSortAscending;
|
2016-12-10 11:59:58 -05:00
|
|
|
QAction *actionSortDescending;
|
2011-01-04 15:19:45 -05:00
|
|
|
QAction *actionSortByName;
|
|
|
|
QAction *actionSortByPopularity;
|
|
|
|
QAction *actionSortByLastPost;
|
2015-12-24 11:46:02 -05:00
|
|
|
QAction *actionSortByPosts;
|
2016-12-10 11:59:58 -05:00
|
|
|
QAction *actionSortByUnread;
|
2011-01-04 15:19:45 -05:00
|
|
|
|
|
|
|
RSTreeWidgetItemCompareRole *compareRole;
|
|
|
|
|
2012-11-19 11:01:21 -05:00
|
|
|
/* Color definitions (for standard see qss.default) */
|
|
|
|
QColor mTextColor[GROUPTREEWIDGET_COLOR_COUNT];
|
|
|
|
|
2010-12-26 19:15:25 -05:00
|
|
|
Ui::GroupTreeWidget *ui;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GROUPTREEWIDGET_H
|