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

167 lines
5.9 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 "retroshare/rsstatus.h"
namespace Ui {
2019-06-28 05:27:19 -04:00
class NewFriendList;
}
class RSTreeWidgetItemCompareRole;
class QTreeWidgetItem;
class QToolButton;
2019-06-28 05:27:19 -04:00
class NewFriendList: public QWidget
{
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)
Q_PROPERTY(QColor textColorStatusInactive READ textColorStatusInactive WRITE setTextColorStatusInactive)
public:
2019-06-28 10:20:26 -04:00
enum Column
{
COLUMN_NAME = 0,
COLUMN_LAST_CONTACT = 1,
COLUMN_IP = 2,
COLUMN_ID = 3
};
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;
std::string getSelectedGroupId() const;
void setColumnVisible(Column column, bool visible);
void sortByColumn(Column column, Qt::SortOrder sortOrder);
bool isSortByState();
QColor textColorGroup() const { return mTextColorGroup; }
QColor textColorStatusOffline() const { return mTextColorStatus[RS_STATUS_OFFLINE]; }
QColor textColorStatusAway() const { return mTextColorStatus[RS_STATUS_AWAY]; }
QColor textColorStatusBusy() const { return mTextColorStatus[RS_STATUS_BUSY]; }
QColor textColorStatusOnline() const { return mTextColorStatus[RS_STATUS_ONLINE]; }
QColor textColorStatusInactive() const { return mTextColorStatus[RS_STATUS_INACTIVE]; }
void setTextColorGroup(QColor color) { mTextColorGroup = color; }
void setTextColorStatusOffline(QColor color) { mTextColorStatus[RS_STATUS_OFFLINE] = color; }
void setTextColorStatusAway(QColor color) { mTextColorStatus[RS_STATUS_AWAY] = color; }
void setTextColorStatusBusy(QColor color) { mTextColorStatus[RS_STATUS_BUSY] = color; }
void setTextColorStatusOnline(QColor color) { mTextColorStatus[RS_STATUS_ONLINE] = color; }
void setTextColorStatusInactive(QColor color) { mTextColorStatus[RS_STATUS_INACTIVE] = color; }
public slots:
2019-06-28 10:20:26 -04:00
void filterItems(const QString &text);
void sortByState(bool sort);
2019-06-28 10:20:26 -04:00
void setShowGroups(bool show);
void setHideUnconnected(bool hidden);
void setShowState(bool show);
private slots:
protected:
2019-06-28 10:20:26 -04:00
void changeEvent(QEvent *e);
void createDisplayMenu();
private:
2019-06-28 10:20:26 -04:00
Ui::NewFriendList *ui;
RsFriendListModel *mModel;
QAction *mActionSortByState;
2019-06-28 10:20:26 -04:00
QModelIndex getCurrentIndex() 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 mShowGroups;
bool mShowState;
bool mHideUnconnected;
2019-06-28 10:20:26 -04:00
QString mFilterText;
2019-06-28 10:20:26 -04:00
bool groupsHasChanged;
std::set<RsNodeGroupId> openGroups;
std::set<RsPgpId> openPeers;
2019-06-28 10:20:26 -04:00
/* Color definitions (for standard see qss.default) */
QColor mTextColorGroup;
QColor mTextColorStatus[RS_STATUS_COUNT];
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);
private slots:
2019-06-28 10:20:26 -04:00
void groupsChanged();
void peerTreeWidgetCustomPopupMenu();
void updateMenu();
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();
};