File: search.hh

package info (click to toggle)
linuxdcpp 1.0.3-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,388 kB
  • ctags: 5,088
  • sloc: cpp: 33,725; makefile: 15
file content (153 lines) | stat: -rw-r--r-- 6,526 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
 * Copyright © 2004-2008 Jens Oknelid, paskharen@gmail.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * In addition, as a special exception, compiling, linking, and/or
 * using OpenSSL with this program is allowed.
 */

#ifndef WULFOR_SEARCH_HH
#define WULFOR_SEARCH_HH

#include <client/stdinc.h>
#include <client/DCPlusPlus.h>
#include <client/ClientManager.h>
#include <client/SearchManager.h>

#include "bookentry.hh"
#include "treeview.hh"

class UserCommandMenu;

class Search:
	public BookEntry,
	public SearchManagerListener,
	public ClientManagerListener
{
	public:
		Search();
		virtual ~Search();
		virtual void show();

		void putValue_gui(const std::string &str, int64_t size, SearchManager::SizeModes mode, SearchManager::TypeModes type);

	private:
		// Keep these and the items in .glade file in same order, otherwise it will break
		typedef enum
		{
			NOGROUPING = 0,
			FILENAME,
			FILEPATH,
			SIZE,
			CONNECTION,
			TTH,
			NICK,
			HUB,
			TYPE
		} GroupType;

		// GUI functions
		void initHubs_gui();
		void addHub_gui(std::string name, std::string url, bool op);
		void modifyHub_gui(std::string name, std::string url, bool op);
		void removeHub_gui(std::string url);
		void popupMenu_gui();
		void setStatus_gui(std::string statusBar, std::string text);
		void search_gui();
		void parseSearchResult(SearchResult *result, StringMap &resultMap, GdkPixbuf **icon, int *actualSlots);
		void addResult_gui(SearchResult *result, bool inShare);
		void clearList_gui();
		void updateParentRow_gui(GtkTreeIter *parent, GtkTreeIter *child = NULL);
		void ungroup_gui();
		void regroup_gui();
		std::string getGroupingColumn(GroupType groupBy);
		static gboolean getNextIter_gui(GtkTreeModel *model, GtkTreeIter *iter, bool children = TRUE, bool parent = TRUE);
		GtkTreeIter copyRow_gui(GtkTreeIter *fromIter, GtkTreeIter *parent = NULL, int position = -1);
		void copyValue_gui(GtkTreeIter *fromIter, GtkTreeIter *toIter, const std::string &column);
		void copyValue_gui(GtkTreeIter *fromIter, GtkTreeIter *toIter, int position);

		// GUI callbacks
		static gboolean onFocusIn_gui(GtkWidget *widget, GdkEventFocus *event, gpointer data);
		static gboolean onButtonPressed_gui(GtkWidget *widget, GdkEventButton *event, gpointer data);
		static gboolean onButtonReleased_gui(GtkWidget *widget, GdkEventButton *event, gpointer data);
		static gboolean onKeyReleased_gui(GtkWidget *widget, GdkEventKey *event, gpointer data);
		static gboolean onSearchEntryKeyPressed_gui(GtkWidget *widget, GdkEventKey *event, gpointer data);
		static gboolean searchFilterFunc_gui(GtkTreeModel *model, GtkTreeIter *iter, gpointer data);
		static void onComboBoxChanged_gui(GtkWidget *widget, gpointer data);
		static void onGroupByComboBoxChanged_gui(GtkWidget* widget, gpointer data);
		static void onSearchButtonClicked_gui(GtkWidget *widget, gpointer data);
		static void onFilterButtonToggled_gui(GtkToggleButton *button, gpointer data);
		static void onSlotsButtonToggled_gui(GtkToggleButton *button, gpointer data);
		static void onOpButtonToggled_gui(GtkToggleButton *button, gpointer data);
		static void onSharedButtonToggled_gui(GtkToggleButton *button, gpointer data);
		static void onToggledClicked_gui(GtkCellRendererToggle *cell, gchar *path, gpointer data);
		static void onDownloadClicked_gui(GtkMenuItem *item, gpointer data);
		static void onDownloadFavoriteClicked_gui(GtkMenuItem *item, gpointer data);
		static void onDownloadToClicked_gui(GtkMenuItem *item, gpointer data);
		static void onDownloadToMatchClicked_gui(GtkMenuItem *item, gpointer data);
		static void onDownloadDirClicked_gui(GtkMenuItem *item, gpointer data);
		static void onDownloadFavoriteDirClicked_gui(GtkMenuItem *item, gpointer data);
		static void onDownloadDirToClicked_gui(GtkMenuItem *item, gpointer data);
		static void onSearchByTTHClicked_gui(GtkMenuItem *item, gpointer data);
		static void onCopyMagnetClicked_gui(GtkMenuItem *item, gpointer data);
		static void onGetFileListClicked_gui(GtkMenuItem *item, gpointer data);
		static void onMatchQueueClicked_gui(GtkMenuItem *item, gpointer data);
		static void onPrivateMessageClicked_gui(GtkMenuItem *item, gpointer data);
		static void onAddFavoriteUserClicked_gui(GtkMenuItem *item, gpointer data);
		static void onGrantExtraSlotClicked_gui(GtkMenuItem *item, gpointer data);
		static void onRemoveUserFromQueueClicked_gui(GtkMenuItem *item, gpointer data);
		static void onRemoveClicked_gui(GtkMenuItem *item, gpointer data);

		// Client functions
		void download_client(std::string target, SearchResult *result);
		void downloadDir_client(std::string target, SearchResult *result);
		void addSource_client(std::string source, SearchResult *result);
		void getFileList_client(std::string cid, std::string dir, bool match);
		void addFavUser_client(std::string cid);
		void grantSlot_client(std::string cid);
		void removeSource_client(std::string cid);

		// Client callbacks
		virtual void on(ClientManagerListener::ClientConnected, Client *client) throw();
	 	virtual void on(ClientManagerListener::ClientUpdated, Client *client) throw();
		virtual void on(ClientManagerListener::ClientDisconnected, Client *client) throw();
		virtual void on(SearchManagerListener::SR, SearchResult *result) throw();

		TreeView hubView, resultView;
		GtkListStore *hubStore;
		GtkTreeStore *resultStore;
		GtkTreeModel *searchFilterModel;
		GtkTreeModel *sortedFilterModel;
		GtkTreeSelection *selection;
		GdkEventType oldEventType;
		GtkWidget *searchEntry;
		TStringList searchlist;
		static GtkTreeModel *searchEntriesModel;
		GdkPixbuf *iconFile;
		GdkPixbuf *iconDirectory;
		GdkPixbuf *iconGroup;
		int droppedResult;
		int searchHits;
		bool isHash;
		bool onlyFree;
		static bool onlyOp;
		UserCommandMenu *userCommandMenu;
		GroupType previousGrouping;
};

#else
class Search;
#endif