|
From: <arn...@us...> - 2008-01-19 23:29:09
|
Revision: 970
http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=970&view=rev
Author: arnetheduck
Date: 2008-01-19 15:29:06 -0800 (Sat, 19 Jan 2008)
Log Message:
-----------
Add right-click menu to downloads frame
Modified Paths:
--------------
dcplusplus/trunk/intl/SConscript
dcplusplus/trunk/win32/DirectoryListingFrame.cpp
dcplusplus/trunk/win32/DirectoryListingFrame.h
dcplusplus/trunk/win32/DownloadsFrame.cpp
dcplusplus/trunk/win32/DownloadsFrame.h
dcplusplus/trunk/win32/QueueFrame.cpp
dcplusplus/trunk/win32/QueueFrame.h
dcplusplus/trunk/win32/SearchFrame.cpp
dcplusplus/trunk/win32/SearchFrame.h
dcplusplus/trunk/win32/WinUtil.cpp
dcplusplus/trunk/win32/WinUtil.h
Modified: dcplusplus/trunk/intl/SConscript
===================================================================
--- dcplusplus/trunk/intl/SConscript 2008-01-19 22:19:19 UTC (rev 969)
+++ dcplusplus/trunk/intl/SConscript 2008-01-19 23:29:06 UTC (rev 970)
@@ -3,7 +3,7 @@
ret = None
if dev.is_win32():
- env, target, sources = dev.prepare_build(source_path, 'aintl', '*.c')
+ env, target, sources = dev.prepare_build(source_path, 'aintl', '*.c', in_bin=False)
env.Append(CPPDEFINES=['LOCALEDIR=\\"\\"', 'LOCALE_ALIAS_PATH=\\"\\"', 'INSTALLDIR=\\"\\"', 'LIBDIR=\\"\\"', 'BUILDING_LIBINTL',
'IN_LIBINTL', 'ENABLE_RELOCATABLE=1', 'NO_XMALLOC', 'HAVE_CONFIG_H',
Modified: dcplusplus/trunk/win32/DirectoryListingFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/DirectoryListingFrame.cpp 2008-01-19 22:19:19 UTC (rev 969)
+++ dcplusplus/trunk/win32/DirectoryListingFrame.cpp 2008-01-19 23:29:06 UTC (rev 970)
@@ -317,9 +317,7 @@
menu->appendSeparatorItem();
- menu->appendItem(IDC_SEARCH_ALTERNATES, T_("Search for alternates"), std::tr1::bind(&DirectoryListingFrame::handleSearchAlternates, this));
- menu->appendItem(IDC_BITZI_LOOKUP, T_("Lookup TTH at Bitzi.com"), std::tr1::bind(&DirectoryListingFrame::handleLookupBitzi, this));
- menu->appendItem(IDC_COPY_MAGNET, T_("Copy magnet link to clipboard"), std::tr1::bind(&DirectoryListingFrame::handleCopyMagnet, this));
+ WinUtil::addHashItems(menu, ii->file->getTTH(), Text::toT(ii->file->getName()));
}
if((ii->type == ItemInfo::FILE && ii->file->getAdls()) ||
@@ -469,27 +467,6 @@
}
}
-void DirectoryListingFrame::handleSearchAlternates() {
- ItemInfo* ii = files->getSelectedData();
- if(ii != NULL && ii->type == ItemInfo::FILE) {
- WinUtil::searchHash(ii->file->getTTH());
- }
-}
-
-void DirectoryListingFrame::handleLookupBitzi() {
- ItemInfo* ii = files->getSelectedData();
- if(ii != NULL && ii->type == ItemInfo::FILE) {
- WinUtil::bitziLink(ii->file->getTTH());
- }
-}
-
-void DirectoryListingFrame::handleCopyMagnet() {
- ItemInfo* ii = files->getSelectedData();
- if(ii != NULL && ii->type == ItemInfo::FILE) {
- WinUtil::copyMagnet(ii->file->getTTH(), ii->getText(COLUMN_FILENAME));
- }
-}
-
void DirectoryListingFrame::handleDownload() {
if(usingDirMenu) {
ItemInfo* ii = dirs->getSelectedData();
Modified: dcplusplus/trunk/win32/DirectoryListingFrame.h
===================================================================
--- dcplusplus/trunk/win32/DirectoryListingFrame.h 2008-01-19 22:19:19 UTC (rev 969)
+++ dcplusplus/trunk/win32/DirectoryListingFrame.h 2008-01-19 23:29:06 UTC (rev 970)
@@ -190,9 +190,6 @@
void handleDownload();
void handleViewAsText();
- void handleSearchAlternates();
- void handleLookupBitzi();
- void handleCopyMagnet();
void handleGoToDirectory();
void handleDownloadLastDir(unsigned id);
void handleDownloadTarget(unsigned id);
Modified: dcplusplus/trunk/win32/DownloadsFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/DownloadsFrame.cpp 2008-01-19 22:19:19 UTC (rev 969)
+++ dcplusplus/trunk/win32/DownloadsFrame.cpp 2008-01-19 23:29:06 UTC (rev 970)
@@ -94,7 +94,13 @@
SettingsManager::getInstance()->set(SettingsManager::DOWNLOADSFRAME_WIDTHS, WinUtil::toString(downloads->getColumnWidths()));
}
-DownloadsFrame::DownloadInfo::DownloadInfo(const string& target, int64_t size_) : path(target), done(QueueManager::getInstance()->getPos(target)), size(size_), users(0) {
+DownloadsFrame::DownloadInfo::DownloadInfo(const string& target, int64_t size_, const TTHValue& tth_) :
+ path(target),
+ done(QueueManager::getInstance()->getPos(target)),
+ size(size_),
+ users(0),
+ tth(tth_)
+{
columns[COLUMN_FILE] = Text::toT(Util::getFileName(target));
columns[COLUMN_PATH] = Text::toT(Util::getFilePath(target));
columns[COLUMN_SIZE] = Text::toT(Util::formatBytes(size));
@@ -127,13 +133,14 @@
}
bool DownloadsFrame::handleContextMenu(SmartWin::ScreenCoordinate pt) {
- if (downloads->hasSelection()) {
+ if (downloads->getSelectedCount() == 1) {
if(pt.x() == -1 && pt.y() == -1) {
pt = downloads->getContextMenuPos();
}
WidgetMenuPtr menu = createMenu(true);
-
+ DownloadInfo* di = downloads->getSelectedData();
+ WinUtil::addHashItems(menu, di->tth, di->columns[COLUMN_FILE]);
menu->trackPopupMenu(this, pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
return true;
@@ -160,7 +167,12 @@
if(size == -1) {
return 0;
}
- i = downloads->insert(new DownloadInfo(ti->path, size));
+ TTHValue tth;
+ if(QueueManager::getInstance()->getTTH(ti->path, tth)) {
+ i = downloads->insert(new DownloadInfo(ti->path, size, tth));
+ } else {
+ return 0;
+ }
}
DownloadInfo* di = downloads->getData(i);
di->update(*ti);
Modified: dcplusplus/trunk/win32/DownloadsFrame.h
===================================================================
--- dcplusplus/trunk/win32/DownloadsFrame.h 2008-01-19 22:19:19 UTC (rev 969)
+++ dcplusplus/trunk/win32/DownloadsFrame.h 2008-01-19 23:29:06 UTC (rev 970)
@@ -82,7 +82,7 @@
class DownloadInfo {
public:
- DownloadInfo(const string& filename, int64_t size);
+ DownloadInfo(const string& filename, int64_t size, const TTHValue& tth);
const tstring& getText(int col) const {
return columns[col];
@@ -110,6 +110,7 @@
int64_t size;
double bps;
int users;
+ TTHValue tth;
tstring columns[COLUMN_LAST];
};
Modified: dcplusplus/trunk/win32/QueueFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/QueueFrame.cpp 2008-01-19 22:19:19 UTC (rev 969)
+++ dcplusplus/trunk/win32/QueueFrame.cpp 2008-01-19 23:29:06 UTC (rev 970)
@@ -767,25 +767,6 @@
}
}
-void QueueFrame::handleSearchAlternates() {
- if(files->getSelectedCount() == 1) {
- WinUtil::searchHash(files->getSelectedData()->getTTH());
- }
-}
-
-void QueueFrame::handleBitziLookup() {
- if(files->getSelectedCount() == 1) {
- WinUtil::bitziLink(files->getSelectedData()->getTTH());
- }
-}
-
-void QueueFrame::handleCopyMagnet() {
- if(files->getSelectedCount() == 1) {
- QueueItemInfo* ii = files->getSelectedData();
- WinUtil::copyMagnet(ii->getTTH(), Text::toT(Util::getFileName(ii->getTarget())));
- }
-}
-
void QueueFrame::handleBrowseList(const UserPtr& user) {
if(files->getSelectedCount() == 1) {
@@ -975,9 +956,7 @@
QueueFrame::WidgetMenuPtr QueueFrame::makeSingleMenu(QueueItemInfo* qii) {
WidgetMenuPtr menu = createMenu(true);
- menu->appendItem(IDC_SEARCH_ALTERNATES, T_("Search for alternates"), std::tr1::bind(&QueueFrame::handleSearchAlternates, this));
- menu->appendItem(IDC_BITZI_LOOKUP, T_("Lookup TTH at Bitzi.com"), std::tr1::bind(&QueueFrame::handleBitziLookup, this));
- menu->appendItem(IDC_COPY_MAGNET, T_("Copy magnet link to clipboard"), std::tr1::bind(&QueueFrame::handleCopyMagnet, this));
+ WinUtil::addHashItems(menu, qii->getTTH(), Text::toT(Util::getFileName(qii->getTarget())));
menu->appendItem(IDC_MOVE, T_("Move/Rename"), std::tr1::bind(&QueueFrame::handleMove, this));
addPriorityMenu(menu);
addBrowseMenu(menu, qii);
Modified: dcplusplus/trunk/win32/QueueFrame.h
===================================================================
--- dcplusplus/trunk/win32/QueueFrame.h 2008-01-19 22:19:19 UTC (rev 969)
+++ dcplusplus/trunk/win32/QueueFrame.h 2008-01-19 23:29:06 UTC (rev 970)
@@ -286,9 +286,6 @@
void handleShowTreeClicked();
- void handleSearchAlternates();
- void handleBitziLookup();
- void handleCopyMagnet();
void handleMove();
void handleRemove();
void handlePriority(unsigned id);
Modified: dcplusplus/trunk/win32/SearchFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/SearchFrame.cpp 2008-01-19 22:19:19 UTC (rev 969)
+++ dcplusplus/trunk/win32/SearchFrame.cpp 2008-01-19 23:29:06 UTC (rev 970)
@@ -727,36 +727,6 @@
results->forEachSelected(&SearchInfo::view);
}
-void SearchFrame::handleSearchAlternates() {
- if(results->getSelectedCount() == 1) {
- int i = results->getNext(-1, LVNI_SELECTED);
- SearchResult* sr = results->getData(i)->sr;
- if(sr->getType() == SearchResult::TYPE_FILE) {
- WinUtil::searchHash(sr->getTTH());
- }
- }
-}
-
-void SearchFrame::handleBitziLookup() {
- if(results->getSelectedCount() == 1) {
- int i = results->getNext(-1, LVNI_SELECTED);
- SearchResult* sr = results->getData(i)->sr;
- if(sr->getType() == SearchResult::TYPE_FILE) {
- WinUtil::bitziLink(sr->getTTH());
- }
- }
-}
-
-void SearchFrame::handleCopyMagnet() {
- if(results->getSelectedCount() == 1) {
- int i = results->getNext(-1, LVNI_SELECTED);
- SearchResult* sr = results->getData(i)->sr;
- if(sr->getType() == SearchResult::TYPE_FILE) {
- WinUtil::copyMagnet(sr->getTTH(), Text::toT(sr->getFileName()));
- }
- }
-}
-
void SearchFrame::handleRemove() {
int i = -1;
while((i = results->getNext(-1, LVNI_SELECTED)) != -1) {
@@ -776,9 +746,10 @@
addTargetDirMenu(menu, favoriteDirs);
menu->appendItem(IDC_VIEW_AS_TEXT, T_("View as text"), std::tr1::bind(&SearchFrame::handleViewAsText, this));
menu->appendSeparatorItem();
- menu->appendItem(IDC_SEARCH_ALTERNATES, T_("Search for alternates"), std::tr1::bind(&SearchFrame::handleSearchAlternates, this));
- menu->appendItem(IDC_BITZI_LOOKUP, T_("Lookup TTH at Bitzi.com"), std::tr1::bind(&SearchFrame::handleBitziLookup, this));
- menu->appendItem(IDC_COPY_MAGNET, T_("Copy magnet link to clipboard"), std::tr1::bind(&SearchFrame::handleCopyMagnet, this));
+ if(checkTTH.hasTTH) {
+ SearchInfo* si = results->getSelectedData();
+ WinUtil::addHashItems(menu, TTHValue(Text::fromT(checkTTH.tth)), si->getText(COLUMN_FILENAME));
+ }
menu->appendSeparatorItem();
appendUserItems(getParent(), menu);
menu->appendSeparatorItem();
Modified: dcplusplus/trunk/win32/SearchFrame.h
===================================================================
--- dcplusplus/trunk/win32/SearchFrame.h 2008-01-19 22:19:19 UTC (rev 969)
+++ dcplusplus/trunk/win32/SearchFrame.h 2008-01-19 23:29:06 UTC (rev 970)
@@ -222,9 +222,6 @@
void handleDownloadWholeTarget(unsigned id);
void handleDownloadDirTo();
void handleViewAsText();
- void handleSearchAlternates();
- void handleBitziLookup();
- void handleCopyMagnet();
void handleRemove();
LRESULT handleSpeaker(WPARAM wParam, LPARAM lParam);
bool handleSearchKeyDown(int c);
Modified: dcplusplus/trunk/win32/WinUtil.cpp
===================================================================
--- dcplusplus/trunk/win32/WinUtil.cpp 2008-01-19 22:19:19 UTC (rev 969)
+++ dcplusplus/trunk/win32/WinUtil.cpp 2008-01-19 23:29:06 UTC (rev 970)
@@ -358,6 +358,11 @@
return 2;
}
}
+void WinUtil::addHashItems(const SmartWin::WidgetMenu::ObjectType& menu, const TTHValue& tth, const tstring& filename) {
+ menu->appendItem(IDC_SEARCH_ALTERNATES, T_("Search for alternates"), std::tr1::bind(&WinUtil::searchHash, tth));
+ menu->appendItem(IDC_BITZI_LOOKUP, T_("Lookup TTH at Bitzi.com"), std::tr1::bind(WinUtil::bitziLink, tth));
+ menu->appendItem(IDC_COPY_MAGNET, T_("Copy magnet link to clipboard"), std::tr1::bind(&WinUtil::copyMagnet, tth, filename));
+}
void WinUtil::bitziLink(const TTHValue& aHash) {
// to use this free service by bitzi, we must not hammer or request information from bitzi
Modified: dcplusplus/trunk/win32/WinUtil.h
===================================================================
--- dcplusplus/trunk/win32/WinUtil.h 2008-01-19 22:19:19 UTC (rev 969)
+++ dcplusplus/trunk/win32/WinUtil.h 2008-01-19 23:29:06 UTC (rev 970)
@@ -133,6 +133,7 @@
static pair<tstring, bool> getHubNames(const UserPtr& u);
// Hash related
+ static void addHashItems(const SmartWin::WidgetMenu::ObjectType& menu, const TTHValue& tth, const tstring& filename);
static void bitziLink(const TTHValue& /*aHash*/);
static void copyMagnet(const TTHValue& /*aHash*/, const tstring& /*aFile*/);
static void searchHash(const TTHValue& /*aHash*/);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|