linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #03137
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2405: Users frame column remake
------------------------------------------------------------
revno: 2405
committer: Jacek Sieka <arnetheduck@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Sun 2011-01-30 17:17:57 +0100
message:
Users frame column remake
added:
res/FavoriteUserOff.ico
res/FavoriteUserOn.ico
res/GrantSlotOff.ico
res/GrantSlotOn.ico
modified:
dcpp/SettingsManager.cpp
dwt/include/dwt/widgets/Table.h
dwt/src/widgets/Table.cpp
win32/Appearance2Page.cpp
win32/DCPlusPlus.rc
win32/PropPage.cpp
win32/UsersFrame.cpp
win32/UsersFrame.h
win32/resource.h
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/SettingsManager.cpp'
--- dcpp/SettingsManager.cpp 2011-01-02 17:12:02 +0000
+++ dcpp/SettingsManager.cpp 2011-01-30 16:17:57 +0000
@@ -431,6 +431,12 @@
set(AUTO_DETECT_CONNECTION, false); //Don't touch if it works
}
+ if(v <= 0.781) {
+ // These were remade completely...
+ set(USERSFRAME_ORDER, Util::emptyString);
+ set(USERSFRAME_WIDTHS, Util::emptyString);
+ }
+
if(SETTING(SET_MINISLOT_SIZE) < 64)
set(SET_MINISLOT_SIZE, 64);
if(SETTING(AUTODROP_INTERVAL) < 1)
=== modified file 'dwt/include/dwt/widgets/Table.h'
--- dwt/include/dwt/widgets/Table.h 2011-01-27 22:57:05 +0000
+++ dwt/include/dwt/widgets/Table.h 2011-01-30 16:17:57 +0000
@@ -50,6 +50,7 @@
#include "WidgetListViewEditBox.h"
#include <dwt/Theme.h>
+#include <utility>
#include <vector>
namespace dwt {
@@ -464,7 +465,7 @@
void ensureVisible(int i, bool partial = false);
- int hitTest(const ScreenCoordinate& pt);
+ std::pair<int, int> hitTest(const ScreenCoordinate& pt);
/// Actually creates the Data Grid Control
/** You should call WidgetFactory::createTable if you instantiate class
=== modified file 'dwt/src/widgets/Table.cpp'
--- dwt/src/widgets/Table.cpp 2011-01-30 13:28:11 +0000
+++ dwt/src/widgets/Table.cpp 2011-01-30 16:17:57 +0000
@@ -649,9 +649,9 @@
}
}
-int Table::hitTest(const ScreenCoordinate& pt) {
+std::pair<int, int> Table::hitTest(const ScreenCoordinate& pt) {
LVHITTESTINFO lvi = { ClientCoordinate(pt, this).getPoint() };
- return ListView_HitTest(handle(), &lvi);
+ return ListView_SubItemHitTest(handle(), &lvi) == -1 ? std::make_pair(-1, -1) : std::make_pair(lvi.iItem, lvi.iSubItem);
}
void Table::setTooltips(const TooltipDispatcher::F& f) {
=== added file 'res/FavoriteUserOff.ico'
Binary files res/FavoriteUserOff.ico 1970-01-01 00:00:00 +0000 and res/FavoriteUserOff.ico 2011-01-30 16:17:57 +0000 differ
=== added file 'res/FavoriteUserOn.ico'
Binary files res/FavoriteUserOn.ico 1970-01-01 00:00:00 +0000 and res/FavoriteUserOn.ico 2011-01-30 16:17:57 +0000 differ
=== added file 'res/GrantSlotOff.ico'
Binary files res/GrantSlotOff.ico 1970-01-01 00:00:00 +0000 and res/GrantSlotOff.ico 2011-01-30 16:17:57 +0000 differ
=== added file 'res/GrantSlotOn.ico'
Binary files res/GrantSlotOn.ico 1970-01-01 00:00:00 +0000 and res/GrantSlotOn.ico 2011-01-30 16:17:57 +0000 differ
=== modified file 'win32/Appearance2Page.cpp'
--- win32/Appearance2Page.cpp 2011-01-27 22:57:05 +0000
+++ win32/Appearance2Page.cpp 2011-01-30 16:17:57 +0000
@@ -199,7 +199,7 @@
// same as PropPage::handleListHelp
int item =
isKeyPressed(VK_F1) ? sounds->getSelected() :
- sounds->hitTest(dwt::ScreenCoordinate(dwt::Point::fromLParam(::GetMessagePos())));
+ sounds->hitTest(dwt::ScreenCoordinate(dwt::Point::fromLParam(::GetMessagePos()))).first;
if(item >= 0 && soundOptions[item].helpId)
id = soundOptions[item].helpId;
WinUtil::help(sounds, id);
=== modified file 'win32/DCPlusPlus.rc'
--- win32/DCPlusPlus.rc 2011-01-12 15:19:02 +0000
+++ win32/DCPlusPlus.rc 2011-01-30 16:17:57 +0000
@@ -94,6 +94,10 @@
IDI_UP ICON "res/Up.ico"
IDI_FILE ICON "res/File.ico"
IDI_EXEC ICON "res/Exec.ico"
+IDI_FAVORITE_USER_ON ICON "res/FavoriteUserOn.ico"
+IDI_FAVORITE_USER_OFF ICON "res/FavoriteUserOff.ico"
+IDI_GRANT_SLOT_ON ICON "res/GrantSlotOn.ico"
+IDI_GRANT_SLOT_OFF ICON "res/GrantSlotOff.ico"
/////////////////////////////////////////////////////////////////////////////
//
=== modified file 'win32/PropPage.cpp'
--- win32/PropPage.cpp 2011-01-02 17:12:02 +0000
+++ win32/PropPage.cpp 2011-01-30 16:17:57 +0000
@@ -127,7 +127,7 @@
// we have the help id of the whole list-view; convert to the one of the specific option the user wants help for
int item =
isKeyPressed(VK_F1) ? list->getSelected() :
- list->hitTest(dwt::ScreenCoordinate(dwt::Point::fromLParam(::GetMessagePos())));
+ list->hitTest(dwt::ScreenCoordinate(dwt::Point::fromLParam(::GetMessagePos()))).first;
const ListItem* listItems = lists[list];
if(item >= 0 && listItems[item].helpId)
id = listItems[item].helpId;
=== modified file 'win32/UsersFrame.cpp'
--- win32/UsersFrame.cpp 2011-01-29 14:15:43 +0000
+++ win32/UsersFrame.cpp 2011-01-30 16:17:57 +0000
@@ -26,11 +26,15 @@
#include <dcpp/ClientManager.h>
#include <dcpp/version.h>
-const string UsersFrame::id = "FavUsers";
+const string UsersFrame::id = "Users";
const string& UsersFrame::getId() const { return id; }
+dwt::ImageListPtr UsersFrame::userIcons;
+
static const ColumnInfo usersColumns[] = {
- { N_("Auto grant slot / Nick"), 200, false },
+ { N_("Favorite"), 30, false },
+ { N_("Nick"), 50, false },
+ { N_("Grant slot"), 30, false },
{ N_("Hub (last seen in, if offline)"), 300, false },
{ N_("Time last seen"), 150, false },
{ N_("Description"), 200, false },
@@ -55,9 +59,16 @@
{
splitter = addChild(VSplitter::Seed(0.3));
+ if(!userIcons) {
+ userIcons = dwt::ImageListPtr(new dwt::ImageList(dwt::Point(16, 16)));
+ userIcons->add(dwt::Icon(IDI_FAVORITE_USER_OFF));
+ userIcons->add(dwt::Icon(IDI_FAVORITE_USER_ON));
+ userIcons->add(dwt::Icon(IDI_GRANT_SLOT_OFF));
+ userIcons->add(dwt::Icon(IDI_GRANT_SLOT_ON));
+ }
+
{
WidgetUsers::Seed cs;
- cs.lvStyle |= LVS_EX_CHECKBOXES;
users = addChild(cs);
addWidget(users);
@@ -67,9 +78,10 @@
// TODO check default (browse vs get)
users->onDblClicked(std::bind(&UsersFrame::handleGetList, this));
users->onKeyDown(std::bind(&UsersFrame::handleKeyDown, this, _1));
- users->onRaw(std::bind(&UsersFrame::handleItemChanged, this, _2), dwt::Message(WM_NOTIFY, LVN_ITEMCHANGED));
users->onContextMenu(std::bind(&UsersFrame::handleContextMenu, this, _1));
users->onSelectionChanged(std::bind(&UsersFrame::handleSelectionChanged, this));
+ users->setSmallImageList(userIcons);
+ users->onLeftMouseDown(std::bind(&UsersFrame::handleClick, this, _1));
prepareUserList(users);
splitter->setFirst(users);
@@ -155,6 +167,9 @@
columns[COLUMN_NICK] = WinUtil::getNicks(u, Util::emptyString);
columns[COLUMN_SEEN] = u->isOnline() ? T_("Online") : Text::toT(Util::formatTime("%Y-%m-%d %H:%M", FavoriteManager::getInstance()->getLastSeen(u)));
columns[COLUMN_CID] = Text::toT(u->getCID().toBase32());
+
+ isFavorite = FavoriteManager::getInstance()->isFavoriteUser(u);
+ grantSlot = FavoriteManager::getInstance()->hasSlot(u);
}
void UsersFrame::UserInfo::update(const FavoriteUser& u) {
@@ -170,11 +185,9 @@
if(ui == userInfos.end()) {
auto x = new UserInfo(aUser);
userInfos.insert(std::make_pair(aUser, x));
- int i = users->insert(x);
- //bool b = aUser.isSet(FavoriteUser::FLAG_GRANTSLOT);
- //users->setChecked(i, b);
+ users->insert(x);
} else {
- // update
+ // TODO Update
}
}
@@ -259,14 +272,6 @@
return false;
}
-LRESULT UsersFrame::handleItemChanged(LPARAM lParam) {
- LPNMITEMACTIVATE l = reinterpret_cast<LPNMITEMACTIVATE>(lParam);
- if(!startup && l->iItem != -1 && ((l->uNewState & LVIS_STATEIMAGEMASK) != (l->uOldState & LVIS_STATEIMAGEMASK))) {
- FavoriteManager::getInstance()->setAutoGrant(users->getData(l->iItem)->getUser(), users->isChecked(l->iItem));
- }
- return 0;
-}
-
bool UsersFrame::handleContextMenu(dwt::ScreenCoordinate pt) {
size_t sel = users->countSelected();
if(sel > 0) {
@@ -289,6 +294,38 @@
return false;
}
+bool UsersFrame::handleClick(const dwt::MouseEvent &me) {
+ auto item = users->hitTest(me.pos);
+ if(item.first == -1 || item.second == -1) {
+ return false;
+ }
+
+ auto ui = users->getData(item.first);
+ switch(item.second) {
+ case COLUMN_FAVORITE:
+ if(ui->isFavorite) {
+ FavoriteManager::getInstance()->removeFavoriteUser(ui->getUser());
+ } else {
+ FavoriteManager::getInstance()->addFavoriteUser(ui->getUser());
+ }
+
+ ui->isFavorite = !ui->isFavorite;
+ users->update(item.first);
+ break;
+
+ case COLUMN_SLOT:
+ FavoriteManager::getInstance()->setAutoGrant(ui->getUser(), !ui->grantSlot);
+ ui->grantSlot = !ui->grantSlot;
+ users->update(item.first);
+ break;
+
+ default:
+ return false;
+ }
+
+ return true;
+}
+
UsersFrame::UserInfoList UsersFrame::selectedUsersImpl() const {
return usersFromTable(users);
}
=== modified file 'win32/UsersFrame.h'
--- win32/UsersFrame.h 2011-01-30 13:28:11 +0000
+++ win32/UsersFrame.h 2011-01-30 16:17:57 +0000
@@ -62,7 +62,9 @@
private:
enum {
COLUMN_FIRST,
- COLUMN_NICK = COLUMN_FIRST,
+ COLUMN_FAVORITE = COLUMN_FIRST,
+ COLUMN_NICK,
+ COLUMN_SLOT,
COLUMN_HUB,
COLUMN_SEEN,
COLUMN_DESCRIPTION,
@@ -70,6 +72,13 @@
COLUMN_LAST
};
+ enum {
+ FAVORITE_OFF_ICON,
+ FAVORITE_ON_ICON,
+ GRANT_OFF_ICON,
+ GRANT_ON_ICON
+ };
+
class UserInfo : public UserInfoBase {
public:
UserInfo(const UserPtr& u);
@@ -80,7 +89,11 @@
}
int getImage(int col) const {
- return 0;
+ switch(col) {
+ case COLUMN_FAVORITE: return isFavorite ? FAVORITE_ON_ICON : FAVORITE_OFF_ICON;
+ case COLUMN_SLOT: return grantSlot ? GRANT_ON_ICON : GRANT_OFF_ICON;
+ default: return -1;
+ }
}
static int compareItems(UserInfo* a, UserInfo* b, int col) {
@@ -93,6 +106,9 @@
void update(const FavoriteUser& u);
tstring columns[COLUMN_LAST];
+
+ bool isFavorite;
+ bool grantSlot;
};
typedef TypedTable<UserInfo> WidgetUsers;
@@ -100,6 +116,7 @@
WidgetUsersPtr users;
GridPtr userInfo;
VSplitterPtr splitter;
+ static dwt::ImageListPtr userIcons;
std::unordered_map<UserPtr, UserInfo*, User::Hash> userInfos;
@@ -115,6 +132,7 @@
LRESULT handleItemChanged(LPARAM lParam);
bool handleContextMenu(dwt::ScreenCoordinate pt);
void handleSelectionChanged();
+ bool handleClick(const dwt::MouseEvent &me);
// AspectUserInfo
UserInfoList selectedUsersImpl() const;
=== modified file 'win32/resource.h'
--- win32/resource.h 2011-01-05 20:22:31 +0000
+++ win32/resource.h 2011-01-30 16:17:57 +0000
@@ -60,8 +60,10 @@
#define IDI_UP 152
#define IDI_FILE 153
#define IDI_EXEC 154
-
-#define IDB_FOLDERS 200
+#define IDI_FAVORITE_USER_ON 155
+#define IDI_FAVORITE_USER_OFF 156
+#define IDI_GRANT_SLOT_ON 157
+#define IDI_GRANT_SLOT_OFF 158
// Stuff that uses multiple id's