RetroShare/retroshare-gui/src/gui/common/NewFriendList.h

160 lines
6.5 KiB
C
Raw Normal View History

/*******************************************************************************
* gui/common/NewFriendList.h *
* *
* Copyright (C) 2011, 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/>. *
* *
*******************************************************************************/
#pragma once
#include <set>
#include <QWidget>
#include <QTreeView>
2019-06-28 10:20:26 -04:00
#include "FriendListModel.h"
#include "RsAutoUpdatePage.h"
#include "retroshare/rsstatus.h"
namespace Ui {
2019-06-28 05:27:19 -04:00
class NewFriendList;
}
class RSTreeWidgetItemCompareRole;
class QTreeWidgetItem;
class QToolButton;
class FriendListSortFilterProxyModel;
class NewFriendList: public RsAutoUpdatePage
{
2019-06-28 10:20:26 -04:00
Q_OBJECT
Q_PROPERTY(QColor textColorGroup READ textColorGroup WRITE setTextColorGroup)
Q_PROPERTY(QColor textColorStatusOffline READ textColorStatusOffline WRITE setTextColorStatusOffline)
Q_PROPERTY(QColor textColorStatusAway READ textColorStatusAway WRITE setTextColorStatusAway)
Q_PROPERTY(QColor textColorStatusBusy READ textColorStatusBusy WRITE setTextColorStatusBusy)
Q_PROPERTY(QColor textColorStatusOnline READ textColorStatusOnline WRITE setTextColorStatusOnline)
2019-06-28 10:20:26 -04:00
Q_PROPERTY(QColor textColorStatusInactive READ textColorStatusInactive WRITE setTextColorStatusInactive)
public:
2019-06-28 10:20:26 -04:00
explicit NewFriendList(QWidget *parent = 0);
~NewFriendList();
// Add a tool button to the tool area
void addToolButton(QToolButton *toolButton);
void processSettings(bool load);
void addGroupToExpand(const RsNodeGroupId &groupId);
bool getExpandedGroups(std::set<RsNodeGroupId> &groups) const;
void addPeerToExpand(const RsPgpId &gpgId);
bool getExpandedPeers(std::set<RsPgpId> &peers) const;
2019-08-03 15:07:48 -04:00
void setColumnVisible(int col,bool visible);
bool isColumnVisible(int col) const;
2019-06-28 10:20:26 -04:00
std::string getSelectedGroupId() const;
void updateDisplay() override;
2019-08-06 13:41:18 -04:00
QColor textColorGroup() const { return mModel->mTextColorGroup; }
QColor textColorStatusOffline() const { return mModel->mTextColorStatus[RS_STATUS_OFFLINE ]; }
QColor textColorStatusAway() const { return mModel->mTextColorStatus[RS_STATUS_AWAY ]; }
QColor textColorStatusBusy() const { return mModel->mTextColorStatus[RS_STATUS_BUSY ]; }
QColor textColorStatusOnline() const { return mModel->mTextColorStatus[RS_STATUS_ONLINE ]; }
QColor textColorStatusInactive() const { return mModel->mTextColorStatus[RS_STATUS_INACTIVE]; }
void setTextColorGroup(QColor color) { mModel->mTextColorGroup = color; }
void setTextColorStatusOffline(QColor color) { mModel->mTextColorStatus[RS_STATUS_OFFLINE ] = color; }
void setTextColorStatusAway(QColor color) { mModel->mTextColorStatus[RS_STATUS_AWAY ] = color; }
void setTextColorStatusBusy(QColor color) { mModel->mTextColorStatus[RS_STATUS_BUSY ] = color; }
void setTextColorStatusOnline(QColor color) { mModel->mTextColorStatus[RS_STATUS_ONLINE ] = color; }
void setTextColorStatusInactive(QColor color) { mModel->mTextColorStatus[RS_STATUS_INACTIVE] = color; }
public slots:
2019-06-28 10:20:26 -04:00
void filterItems(const QString &text);
void toggleSortByState(bool sort);
void forceUpdateDisplay();
2019-08-03 15:07:48 -04:00
void toggleColumnVisible();
2019-06-28 10:20:26 -04:00
void setShowGroups(bool show);
void setShowUnconnected(bool hidden);
2019-06-28 10:20:26 -04:00
void setShowState(bool show);
2019-08-03 15:07:48 -04:00
void headerContextMenuRequested(QPoint);
private slots:
void sortColumn(int col,Qt::SortOrder so);
protected:
2019-06-28 10:20:26 -04:00
void changeEvent(QEvent *e);
private:
2019-06-28 10:20:26 -04:00
Ui::NewFriendList *ui;
RsFriendListModel *mModel;
QAction *mActionSortByState;
void recursRestoreExpandedItems(const QModelIndex& index, const QString& parent_path, const std::set<QString>& exp, const std::set<QString> &sel);
void recursSaveExpandedItems(const QModelIndex& index,const QString& parent_path,std::set<QString>& exp, std::set<QString>& sel);
void saveExpandedPathsAndSelection(std::set<QString>& expanded_indexes, std::set<QString>& selected_indexes);
void restoreExpandedPathsAndSelection(const std::set<QString>& expanded_indexes, const std::set<QString>& selected_indexes);
void checkInternalData(bool force);
QModelIndex getCurrentSourceIndex() const;
2019-06-28 10:20:26 -04:00
bool getCurrentNode(RsFriendListModel::RsNodeDetails& prof) const;
bool getCurrentGroup(RsGroupInfo& prof) const;
bool getCurrentProfile(RsFriendListModel::RsProfileDetails& prof) const;
2019-06-28 10:20:26 -04:00
// Settings for peer list display
bool mShowState;
2019-06-28 10:20:26 -04:00
std::set<RsNodeGroupId> openGroups;
std::set<RsPgpId> openPeers;
2019-06-28 10:20:26 -04:00
bool getOrCreateGroup(const std::string& name, uint flag, RsNodeGroupId& id);
bool getGroupIdByName(const std::string& name, RsNodeGroupId& id);
bool importExportFriendlistFileDialog(QString &fileName, bool import);
bool exportFriendlist(QString &fileName);
bool importFriendlist(QString &fileName, bool &errorPeers, bool &errorGroups);
FriendListSortFilterProxyModel *mProxyModel ;
private slots:
2019-06-28 10:20:26 -04:00
void peerTreeWidgetCustomPopupMenu();
void pastePerson();
void connectNode();
void configureNode();
void configureProfile();
void chatNode();
2019-06-28 10:20:26 -04:00
void copyFullCertificate();
void addFriend();
void msgNode();
void msgGroup();
void msgProfile();
void recommendNode();
void removeNode();
void removeProfile();
void createNewGroup() ;
void addToGroup();
void moveToGroup();
void removeFromGroup();
void editGroup();
void removeGroup();
void exportFriendlistClicked();
void importFriendlistClicked();
};