📄 searchfrm.h
字号:
};
void getList();
void browseList();
void view();
struct Download {
Download(const tstring& aTarget) : tgt(aTarget) { };
void operator()(SearchInfo* si);
const tstring& tgt;
};
struct DownloadWhole {
DownloadWhole(const tstring& aTarget) : tgt(aTarget) { };
void operator()(SearchInfo* si);
const tstring& tgt;
};
struct DownloadTarget {
DownloadTarget(const tstring& aTarget) : tgt(aTarget) { };
void operator()(SearchInfo* si);
const tstring& tgt;
};
struct CheckSize {
CheckSize() : size(-1), op(true), oneHub(true), hasTTH(false), firstTTH(true) { };
void operator()(SearchInfo* si);
tstring ext;
int64_t size;
bool oneHub;
tstring hub;
bool op;
bool hasTTH;
bool firstTTH;
tstring tth;
};
const tstring& getText(int col) const {
switch(col) {
case COLUMN_NICK: return nick;
case COLUMN_FILENAME: return fileName;
case COLUMN_TYPE: return type;
case COLUMN_SIZE: return size;
case COLUMN_PATH: return path;
case COLUMN_SLOTS: return slots;
case COLUMN_CONNECTION: return connection;
case COLUMN_HUB: return hubName;
case COLUMN_EXACT_SIZE: return exactSize;
case COLUMN_IP: return ip;
case COLUMN_TTH: return tth;
default: return Util::emptyStringT;
}
}
static int compareItems(SearchInfo* a, SearchInfo* b, int col) {
switch(col) {
case COLUMN_NICK: return Util::stricmp(a->nick, b->nick);
case COLUMN_FILENAME: return Util::stricmp(a->fileName, b->fileName);
case COLUMN_TYPE:
if(a->sr->getType() == b->sr->getType())
return Util::stricmp(a->type, b->type);
else
return(a->sr->getType() == SearchResult::TYPE_DIRECTORY) ? -1 : 1;
case COLUMN_SIZE: return compare(a->sr->getSize(), b->sr->getSize());
case COLUMN_PATH: return Util::stricmp(a->path, b->path);
case COLUMN_SLOTS:
if(a->sr->getFreeSlots() == b->sr->getFreeSlots())
return compare(a->sr->getSlots(), b->sr->getSlots());
else
return compare(a->sr->getFreeSlots(), b->sr->getFreeSlots());
case COLUMN_CONNECTION: return Util::stricmp(a->connection, b->connection);
case COLUMN_HUB: return Util::stricmp(a->sr->getHubName(), b->sr->getHubName());
case COLUMN_EXACT_SIZE: return compare(a->sr->getSize(), b->sr->getSize());
case COLUMN_IP: return Util::stricmp(a->getIP(), b->getIP());
case COLUMN_TTH: return Util::stricmp(a->getTTH(), b->getTTH());
default: return 0;
}
}
void update() {
if(sr->getType() == SearchResult::TYPE_FILE) {
if(sr->getFile().rfind(_T('\\')) == tstring::npos) {
fileName = Text::toT(sr->getUtf8() ? sr->getFile() : Text::acpToUtf8(sr->getFile()));
} else {
fileName = Text::toT(Util::getFileName(sr->getUtf8() ? sr->getFile() : Text::acpToUtf8(sr->getFile())));
path = Text::toT(Util::getFilePath(sr->getUtf8() ? sr->getFile() : Text::acpToUtf8(sr->getFile())));
}
type = Text::toT(Util::getFileExt(Text::fromT(fileName)));
if(!type.empty() && type[0] == _T('.'))
type.erase(0, 1);
size = Text::toT(Util::formatBytes(sr->getSize()));
exactSize = Text::toT(Util::formatExactSize(sr->getSize()));
} else {
fileName = Text::toT(sr->getUtf8() ? sr->getFileName() : Text::acpToUtf8(sr->getFileName()));
path = Text::toT(sr->getUtf8() ? sr->getFile() : Text::acpToUtf8(sr->getFile()));
type = TSTRING(DIRECTORY);
}
nick = Text::toT(sr->getUser()->getNick());
connection = Text::toT(sr->getUser()->getConnection());
hubName = Text::toT(sr->getHubName());
slots = Text::toT(sr->getSlotString());
ip = Text::toT(sr->getIP());
if(sr->getTTH() != NULL)
setTTH(Text::toT(sr->getTTH()->toBase32()));
}
GETSET(tstring, nick, Nick);
GETSET(tstring, connection, Connection)
GETSET(tstring, fileName, FileName);
GETSET(tstring, path, Path);
GETSET(tstring, type, Type);
GETSET(tstring, hubName, HubName);
GETSET(tstring, size, Size);
GETSET(tstring, slots, Slots);
GETSET(tstring, exactSize, ExactSize);
GETSET(tstring, ip, IP);
GETSET(tstring, tth, TTH);
};
struct HubInfo : public FastAlloc<HubInfo> {
HubInfo(const tstring& aIpPort, const tstring& aName, bool aOp) : ipPort(aIpPort),
name(aName), op(aOp) { };
const tstring& getText(int col) const {
return (col == 0) ? name : Util::emptyStringT;
}
static int compareItems(HubInfo* a, HubInfo* b, int col) {
return (col == 0) ? Util::stricmp(a->name, b->name) : 0;
}
tstring ipPort;
tstring name;
bool op;
};
// WM_SPEAKER
enum Speakers {
ADD_RESULT,
FILTER_RESULT,
HUB_ADDED,
HUB_CHANGED,
HUB_REMOVED,
};
tstring initialString;
int64_t initialSize;
SearchManager::SizeModes initialMode;
SearchManager::TypeModes initialType;
CStatusBarCtrl ctrlStatus;
CEdit ctrlSearch;
CComboBox ctrlSearchBox;
CEdit ctrlSize;
CComboBox ctrlMode;
CComboBox ctrlSizeMode;
CComboBox ctrlFiletype;
CButton ctrlDoSearch;
CButton ctrlPurge;
CContainedWindow searchContainer;
CContainedWindow searchBoxContainer;
CContainedWindow sizeContainer;
CContainedWindow modeContainer;
CContainedWindow sizeModeContainer;
CContainedWindow fileTypeContainer;
CContainedWindow slotsContainer;
CContainedWindow showUIContainer;
CContainedWindow doSearchContainer;
CContainedWindow resultsContainer;
CContainedWindow hubsContainer;
CContainedWindow tthContainer;
CContainedWindow purgeContainer;
CStatic searchLabel, sizeLabel, optionLabel, typeLabel, hubsLabel;
CButton ctrlSlots, ctrlShowUI, ctrlTTH;
bool showUI;
TypedListViewCtrl<SearchInfo, IDC_RESULTS> ctrlResults;
TypedListViewCtrl<HubInfo, IDC_HUB> ctrlHubs;
CMenu resultsMenu;
CMenu targetMenu;
CMenu targetDirMenu;
TStringList search;
StringList targets;
StringList wholeTargets;
/** Parameter map for user commands */
StringMap ucParams;
bool onlyFree;
bool isHash;
bool onlyTTH;
CriticalSection cs;
static TStringList lastSearches;
size_t droppedResults;
bool closed;
static int columnIndexes[];
static int columnSizes[];
// Timer ID, needed to turn off timer
UINT timerID;
void downloadSelected(const tstring& aDir, bool view = false);
void downloadWholeSelected(const tstring& aDir);
void onEnter();
void onTab(bool shift);
void download(SearchResult* aSR, const tstring& aDir, bool view);
virtual void on(SearchManagerListener::SR, SearchResult* aResult) throw();
// ClientManagerListener
virtual void on(ClientConnected, Client* c) throw() { speak(HUB_ADDED, c); }
virtual void on(ClientUpdated, Client* c) throw() { speak(HUB_CHANGED, c); }
virtual void on(ClientDisconnected, Client* c) throw() { speak(HUB_REMOVED, c); }
void initHubs();
void onHubAdded(HubInfo* info);
void onHubChanged(HubInfo* info);
void onHubRemoved(HubInfo* info);
LRESULT onItemChangedHub(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
void speak(Speakers s, Client* aClient) {
HubInfo* hubInfo = new HubInfo(Text::toT(aClient->getIpPort()), Text::toT(aClient->getName()), aClient->getOp());
PostMessage(WM_SPEAKER, WPARAM(s), LPARAM(hubInfo));
};
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CHILDFRM_H__A7078724_FD85_4F39_8463_5A08A5F45E33__INCLUDED_)
/**
* @file
* $Id: SearchFrm.h,v 1.54 2005/03/14 14:04:46 arnetheduck Exp $
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -