2007-11-14 22:18:48 -05:00
|
|
|
/****************************************************************
|
|
|
|
* RShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006, crypton
|
|
|
|
*
|
|
|
|
* 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.
|
2009-01-22 20:58:56 -05:00
|
|
|
****************************************************************/
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
#ifndef _PEERSDIALOG_H
|
2009-01-22 20:58:56 -05:00
|
|
|
#define _PEERSDIALOG_H
|
|
|
|
|
2010-09-04 10:23:30 -04:00
|
|
|
#include "chat/ChatStyle.h"
|
2009-11-17 07:45:06 -05:00
|
|
|
#include "RsAutoUpdatePage.h"
|
2009-01-22 20:58:56 -05:00
|
|
|
|
|
|
|
#include "mainpage.h"
|
|
|
|
|
2009-03-12 10:14:55 -04:00
|
|
|
#include "im_history/IMHistoryKeeper.h"
|
|
|
|
|
2010-06-17 13:39:32 -04:00
|
|
|
// states for sorting (equal values are possible)
|
|
|
|
// used in BuildSortString - state + name
|
|
|
|
#define PEER_STATE_ONLINE 1
|
2010-12-15 16:32:44 -05:00
|
|
|
#define PEER_STATE_BUSY 2
|
|
|
|
#define PEER_STATE_AWAY 3
|
2010-06-17 13:39:32 -04:00
|
|
|
#define PEER_STATE_AVAILABLE 4
|
|
|
|
#define PEER_STATE_INACTIVE 5
|
|
|
|
#define PEER_STATE_OFFLINE 6
|
|
|
|
|
|
|
|
#define BuildStateSortString(bEnabled,sName,nState) bEnabled ? (QString ("%1").arg(nState) + " " + sName) : sName
|
|
|
|
|
2010-08-31 16:00:49 -04:00
|
|
|
#ifndef MINIMAL_RSGUI
|
|
|
|
#include "ui_PeersDialog.h"
|
|
|
|
|
2008-07-10 06:34:49 -04:00
|
|
|
class QFont;
|
|
|
|
class QAction;
|
|
|
|
class QTextEdit;
|
|
|
|
class QTextCharFormat;
|
2007-11-14 22:18:48 -05:00
|
|
|
class ChatDialog;
|
2010-08-28 15:50:38 -04:00
|
|
|
class AttachFileItem;
|
2010-09-19 20:10:51 -04:00
|
|
|
class RSTreeWidgetItemCompareRole;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-11-17 07:45:06 -05:00
|
|
|
class PeersDialog : public RsAutoUpdatePage
|
2009-01-22 20:58:56 -05:00
|
|
|
{
|
2010-09-22 18:37:57 -04:00
|
|
|
Q_OBJECT
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-01-31 17:29:30 -05:00
|
|
|
public:
|
2010-09-22 18:37:57 -04:00
|
|
|
/** Default Constructor */
|
|
|
|
PeersDialog(QWidget *parent = 0);
|
|
|
|
/** Default Destructor */
|
|
|
|
~PeersDialog ();
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
// void setChatDialog(ChatDialog *cd);
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
virtual void updateDisplay() ; // overloaded from RsAutoUpdatePage
|
|
|
|
// replaced by shortcut
|
|
|
|
// virtual void keyPressEvent(QKeyEvent *) ;
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-01-31 17:29:30 -05:00
|
|
|
public slots:
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
void insertPeers();
|
|
|
|
void publicChatChanged(int type);
|
2010-09-24 07:38:46 -04:00
|
|
|
// void toggleSendItem( QTreeWidgetItem *item, int col );
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
void insertChat();
|
|
|
|
void setChatInfo(QString info, QColor color=QApplication::palette().color(QPalette::WindowText));
|
|
|
|
void resetStatusBar() ;
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
void fileHashingFinished(AttachFileItem* file);
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
void smileyWidgetgroupchat();
|
|
|
|
void addSmileys();
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
void on_actionClearChat_triggered();
|
|
|
|
void on_actionMessageHistory_triggered();
|
2010-09-01 10:15:50 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
// called by notifyQt when another peer is typing (in group chant and private chat)
|
|
|
|
void updatePeerStatusString(const QString& peer_id,const QString& status_string,bool is_private_chat) ;
|
|
|
|
|
|
|
|
void updatePeersAvatar(const QString& peer_id);
|
|
|
|
void updateAvatar(); // called by notifyQt to update the avatar when it gets changed by another component
|
|
|
|
|
|
|
|
void groupsChanged(int type);
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-01-31 17:29:30 -05:00
|
|
|
protected:
|
|
|
|
virtual void dragEnterEvent(QDragEnterEvent *event);
|
|
|
|
virtual void dropEvent(QDropEvent *event);
|
2010-09-04 10:23:30 -04:00
|
|
|
bool eventFilter(QObject *obj, QEvent *ev);
|
|
|
|
void showEvent (QShowEvent *event);
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-01-31 17:29:30 -05:00
|
|
|
private slots:
|
2010-09-22 18:37:57 -04:00
|
|
|
void pasteLink() ;
|
|
|
|
void contextMenu(QPoint) ;
|
|
|
|
|
|
|
|
/** Create the context popup menu and it's submenus */
|
|
|
|
void peertreeWidgetCostumPopupMenu( QPoint point );
|
|
|
|
|
|
|
|
void updateStatusString(const QString& peer_id, const QString& statusString) ; // called when a peer is typing in group chat
|
|
|
|
void updateStatusTyping() ; // called each time a key is hit
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
//void updatePeerStatusString(const QString& peer_id,const QString& chat_status) ;
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
/** Export friend in Friends Dialog */
|
|
|
|
void exportfriend();
|
|
|
|
/** Remove friend */
|
|
|
|
void removefriend();
|
|
|
|
/** start a chat with a friend **/
|
2010-09-29 15:30:59 -04:00
|
|
|
void addFriend();
|
2010-09-22 18:37:57 -04:00
|
|
|
void chatfriend(QTreeWidgetItem* );
|
|
|
|
void chatfriendproxy();
|
|
|
|
void msgfriend();
|
|
|
|
void recommendfriend();
|
|
|
|
void pastePerson();
|
|
|
|
void addToGroup();
|
|
|
|
void moveToGroup();
|
|
|
|
void removeFromGroup();
|
2010-09-23 14:49:52 -04:00
|
|
|
void editGroup();
|
2010-09-22 18:37:57 -04:00
|
|
|
void removeGroup();
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
void configurefriend();
|
|
|
|
void viewprofile();
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
/** RsServer Friend Calls */
|
|
|
|
void connectfriend();
|
2010-07-15 07:25:34 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
void setColor();
|
|
|
|
void insertSendList();
|
|
|
|
void sendMsg();
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
void statusmessage();
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
void setFont();
|
|
|
|
void getFont();
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
void changeAvatarClicked();
|
|
|
|
void getAvatar();
|
2010-11-25 11:45:44 -05:00
|
|
|
void updateOwnStatus(const QString &peer_id, int status);
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
void on_actionAdd_Group_activated();
|
|
|
|
void on_actionCreate_New_Forum_activated();
|
|
|
|
void on_actionCreate_New_Channel_activated();
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
void loadmypersonalstatus();
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
void addExtraFile();
|
|
|
|
void addAttachment(std::string);
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
bool fileSave();
|
|
|
|
bool fileSaveAs();
|
2010-01-31 17:29:30 -05:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
void setCurrentFileName(const QString &fileName);
|
2010-06-18 17:59:33 -04:00
|
|
|
|
2010-12-17 20:45:32 -05:00
|
|
|
void setStateColumn();
|
2010-12-15 16:32:44 -05:00
|
|
|
void sortPeersAscendingOrder();
|
|
|
|
void sortPeersDescendingOrder();
|
2010-12-17 20:45:32 -05:00
|
|
|
void peerSortIndicatorChanged(int,Qt::SortOrder);
|
2009-09-02 18:42:31 -04:00
|
|
|
|
2010-11-10 07:24:36 -05:00
|
|
|
void newsFeedChanged(int count);
|
|
|
|
|
2009-05-15 08:07:37 -04:00
|
|
|
signals:
|
2010-09-22 18:37:57 -04:00
|
|
|
void friendsUpdated() ;
|
|
|
|
void notifyGroupChat(const QString&,const QString&) ;
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-01-31 17:29:30 -05:00
|
|
|
private:
|
2010-09-22 18:37:57 -04:00
|
|
|
void processSettings(bool bLoad);
|
2010-10-03 06:08:58 -04:00
|
|
|
void addChatMsg(bool incoming, bool history, QString &name, QDateTime &recvTime, QString &message);
|
2010-06-08 17:38:36 -04:00
|
|
|
|
2010-10-07 20:07:44 -04:00
|
|
|
void colorChanged(const QColor &c);
|
|
|
|
void fontChanged(const QFont &font);
|
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
class QLabel *iconLabel, *textLabel;
|
|
|
|
class QWidget *widget;
|
|
|
|
class QWidgetAction *widgetAction;
|
|
|
|
class QSpacerItem *spacerItem;
|
2010-05-05 07:47:29 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
RSTreeWidgetItemCompareRole *m_compareRole;
|
2010-09-19 20:10:51 -04:00
|
|
|
|
2010-12-15 16:32:44 -05:00
|
|
|
void displayMenu();
|
2010-09-22 18:37:57 -04:00
|
|
|
///play the sound when recv a message
|
|
|
|
void playsound();
|
2010-05-11 20:17:10 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
QString fileName;
|
|
|
|
bool groupsHasChanged;
|
|
|
|
std::list<std::string> openGroups;
|
2010-05-11 20:17:10 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
/* Worker Functions */
|
|
|
|
/* (1) Update Display */
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
/* (2) Utility Fns */
|
|
|
|
QTreeWidgetItem *getCurrentPeer();
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
IMHistoryKeeper historyKeeper;
|
|
|
|
ChatStyle style;
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-10-07 20:07:44 -04:00
|
|
|
QColor mCurrentColor;
|
2010-09-22 18:37:57 -04:00
|
|
|
time_t last_status_send_time ;
|
2010-05-11 20:17:10 -04:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
QFont mCurrentFont; /* how the text will come out */
|
2009-10-04 18:27:42 -04:00
|
|
|
|
2010-11-10 07:24:36 -05:00
|
|
|
int newsFeedTabIndex;
|
|
|
|
QColor newsFeedTabColor;
|
|
|
|
QString newsFeedText;
|
2010-12-17 20:45:32 -05:00
|
|
|
bool wasStatusColumnHidden;
|
2010-11-10 07:24:36 -05:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
/** Qt Designer generated object */
|
|
|
|
Ui::PeersDialog ui;
|
2009-01-22 20:58:56 -05:00
|
|
|
};
|
|
|
|
|
2010-08-31 16:00:49 -04:00
|
|
|
#endif // MINIMAL_RSGUI
|
2009-01-22 20:58:56 -05:00
|
|
|
|
2010-05-11 20:17:10 -04:00
|
|
|
#endif
|