?? friendmodel.java
字號:
/*
* LumaQQ - Java QQ Client
*
* Copyright (C) 2004 luma <stubma@163.com>
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package edu.tsinghua.lumaqq.models;
import java.util.Iterator;
import org.eclipse.swt.graphics.Image;
import edu.tsinghua.swt.models.AbstractNode;
/**
* <pre>
* 代表一個好友,擴展自AbstractGeneralNode,位于Group之下的元素
* 好友有一下屬性
* qq: qq號,Integer類型
* name: 顯示名,這個名稱可能是昵稱,也可能是備注中的真實姓名,name和image
* 是Shutter組件的兩個缺省屬性,那么用于顯示名稱,image用于顯示圖像
* nick: 好友昵稱
* realName: 真實姓名
* image: 好友頭像,Image類型
* face: 好友頭像序號,Integer類型
* contact: ContactInfo類,包含了好友的通訊信息
* member: 是否是QQ會員,true或者false
* status: 在線狀態,online,offline,away,或者hidden
* ip:是ip地址,byte[]類型
* port: 端口號
* loginTime: 登陸時間
* talkMode: 當前是否是聊天模式,true或者false
* locationX: 好友消息窗口的X坐標,Integer類型,為-1表示使用缺省值
* locationY: 好友消息窗口的Y坐標,Integer類型,為-1表示使用缺省值
* temp: 臨時屬性,可以放任何東西,目前用在了消息提示中,在其他情況下,這個屬性保留給程序員內部使用
*
* 以下屬性只在組是一個群組時才會存在
* parent: 表示了這個friend model的父model,為ClusterModel類型,目前還沒有用到這個屬性
* </pre>
*
* @author 馬若劼
*/
public class FriendModel extends AbstractNode {
/**
* 構造函數
* @param qq
*/
public FriendModel(Integer qq) {
super();
addProperty("name", qq.toString());
addProperty("nick", qq.toString());
addProperty("qq", qq);
}
/**
* @param qq
*/
public FriendModel(int qq) {
super();
addProperty("name", String.valueOf(qq));
addProperty("nick", String.valueOf(qq));
addProperty("qq", new Integer(qq));
}
/**
* @param qq
*/
public FriendModel(String qq) {
super();
addProperty("name", qq);
addProperty("nick", qq);
addProperty("qq", new Integer(qq));
}
/**
* 構造函數
*/
public FriendModel(String name, Image image) {
super();
addProperty("name", name);
addProperty("nick", name);
addProperty("image", image);
addProperty("qq", new Integer(-1));
}
/**
* 私有構造函數,用于克隆中
*/
private FriendModel() {
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
if(obj instanceof FriendModel)
return ((Integer)getProperty("qq")).equals(((FriendModel)obj).getProperty("qq"));
else if(obj instanceof Integer)
return ((Integer)getProperty("qq")).equals(obj);
else
return false;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return getQQ();
}
/**
* 復制所有properties到一個新創建的FriendModel中
*/
public FriendModel cloneProperties() {
FriendModel f = new FriendModel();
Iterator iter = properties.keySet().iterator();
while(iter.hasNext()) {
String key = (String)iter.next();
f.addProperty(key, properties.get(key));
}
return f;
}
/**
* @return 頭像ID,如果沒有,返回一個缺省值
*/
public int getFaceId() {
if(hasProperty("face"))
return ((Integer)getProperty("face")).intValue();
else
return 0;
}
/**
* @return 用戶的QQ號
*/
public int getQQ() {
return ((Integer)getProperty("qq")).intValue();
}
/**
* @return true表示正處于聊天模式
*/
public boolean isTalkMode() {
if(hasProperty("talkMode"))
return "true".equals(getProperty("talkMode"));
else
return false;
}
/**
* @return true表示是會員
*/
public boolean isMember() {
if(hasProperty("member"))
return "true".equals(getProperty("member"));
else
return false;
}
/**
* @return 發送消息框的X位置
*/
public int getLocationX() {
if(hasProperty("locationX"))
return ((Integer)getProperty("locationX")).intValue();
else
return -1;
}
/**
* @return 發送消息框的Y位置
*/
public int getLocationY() {
if(hasProperty("locationY"))
return ((Integer)getProperty("locationY")).intValue();
else
return -1;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -