2019-06-25 17:08:31 -04:00
|
|
|
/*******************************************************************************
|
|
|
|
* 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/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
|
|
|
|
2019-06-28 05:12:44 -04:00
|
|
|
#pragma once
|
2019-06-25 17:08:31 -04:00
|
|
|
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
#include <QWidget>
|
2019-06-28 05:12:44 -04:00
|
|
|
#include <QTreeView>
|
2019-06-25 17:08:31 -04:00
|
|
|
|
2019-06-28 10:20:26 -04:00
|
|
|
#include "FriendListModel.h"
|
2019-08-21 16:39:07 -04:00
|
|
|
#include "RsAutoUpdatePage.h"
|
2019-06-25 17:08:31 -04:00
|
|
|
#include "retroshare/rsstatus.h"
|
|
|
|
|
|
|
|
namespace Ui {
|
2019-06-28 05:27:19 -04:00
|
|
|
class NewFriendList;
|
2019-06-25 17:08:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
class RSTreeWidgetItemCompareRole;
|
|
|
|
class QTreeWidgetItem;
|
|
|
|
class QToolButton;
|
2019-08-06 16:52:07 -04:00
|
|
|
class FriendListSortFilterProxyModel;
|
2019-06-25 17:08:31 -04:00
|
|
|
|
2019-08-21 16:39:07 -04:00
|
|
|
class NewFriendList: public RsAutoUpdatePage
|
2019-06-25 17:08:31 -04:00
|
|
|
{
|
2019-06-28 10:20:26 -04:00
|
|
|
Q_OBJECT
|
|
|
|
|
2019-08-06 16:52:07 -04:00
|
|
|
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)
|
2019-06-25 17:08:31 -04:00
|
|
|
|
|
|
|
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);
|
2019-08-15 09:49:20 -04:00
|
|
|
bool isColumnVisible(int col) const;
|
2019-06-28 10:20:26 -04:00
|
|
|
|
|
|
|
std::string getSelectedGroupId() const;
|
|
|
|
|
2019-08-21 16:39:07 -04:00
|
|
|
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; }
|
2019-06-25 17:08:31 -04:00
|
|
|
|
|
|
|
public slots:
|
2019-06-28 10:20:26 -04:00
|
|
|
void filterItems(const QString &text);
|
2019-08-06 16:52:07 -04:00
|
|
|
void toggleSortByState(bool sort);
|
2019-08-21 16:39:07 -04:00
|
|
|
void forceUpdateDisplay();
|
2019-06-25 17:08:31 -04:00
|
|
|
|
2019-08-03 15:07:48 -04:00
|
|
|
void toggleColumnVisible();
|
2019-06-28 10:20:26 -04:00
|
|
|
void setShowGroups(bool show);
|
2019-08-15 09:49:20 -04:00
|
|
|
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);
|
2019-06-25 17:08:31 -04:00
|
|
|
|
|
|
|
private slots:
|
2019-08-06 16:52:07 -04:00
|
|
|
void sortColumn(int col,Qt::SortOrder so);
|
2019-06-25 17:08:31 -04:00
|
|
|
|
|
|
|
protected:
|
2019-06-28 10:20:26 -04:00
|
|
|
void changeEvent(QEvent *e);
|
2019-06-25 17:08:31 -04:00
|
|
|
|
|
|
|
private:
|
2019-06-28 10:20:26 -04:00
|
|
|
Ui::NewFriendList *ui;
|
|
|
|
RsFriendListModel *mModel;
|
|
|
|
QAction *mActionSortByState;
|
2019-06-25 17:08:31 -04:00
|
|
|
|
2019-08-22 07:13:04 -04:00
|
|
|
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);
|
|
|
|
|
2019-08-06 16:52:07 -04:00
|
|
|
QModelIndex getCurrentSourceIndex() const;
|
2019-06-25 17:08:31 -04:00
|
|
|
|
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-25 17:08:31 -04:00
|
|
|
|
2019-06-28 10:20:26 -04:00
|
|
|
// Settings for peer list display
|
|
|
|
bool mShowState;
|
2019-06-25 17:08:31 -04:00
|
|
|
|
2019-06-28 10:20:26 -04:00
|
|
|
std::set<RsNodeGroupId> openGroups;
|
|
|
|
std::set<RsPgpId> openPeers;
|
2019-06-25 17:08:31 -04:00
|
|
|
|
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);
|
2019-06-25 17:08:31 -04:00
|
|
|
|
2019-08-06 16:52:07 -04:00
|
|
|
FriendListSortFilterProxyModel *mProxyModel ;
|
2019-06-25 17:08:31 -04:00
|
|
|
private slots:
|
2019-06-28 10:20:26 -04:00
|
|
|
void peerTreeWidgetCustomPopupMenu();
|
|
|
|
void pastePerson();
|
|
|
|
void connectNode();
|
|
|
|
void configureNode();
|
|
|
|
void configureProfile();
|
2019-06-28 16:36:19 -04:00
|
|
|
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();
|
2019-06-25 17:08:31 -04:00
|
|
|
};
|