summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kamil Kozar <dkk089@gmail.com>2017-09-05 20:42:24 +0200
committerYorhel <git@yorhel.nl>2017-09-06 19:47:31 +0200
commit3f35714e6b14b610fe588079388b930aba900c5d (patch)
treeff64b95633c54617c260a9123d7259a8e60f0621
parent8f52a57208a368a7255a2ba837656da83a0c037a (diff)
Mark queued files with Q and shared with S in search and file list tabs
This is an extension of the already available "S" annotation in file list tabs that was suggested as a TODO in uit_search.c. Now, both tabs will uniformly display "Q" next to the file if it's currently in the download queue, and "S" if it's already in the share.
-rw-r--r--doc/ncdc.pod.in22
-rw-r--r--src/ui.c8
-rw-r--r--src/uit_fl.c15
-rw-r--r--src/uit_search.c8
4 files changed, 44 insertions, 9 deletions
diff --git a/doc/ncdc.pod.in b/doc/ncdc.pod.in
index 505afe2..4f4b049 100644
--- a/doc/ncdc.pod.in
+++ b/doc/ncdc.pod.in
@@ -63,6 +63,28 @@ hit Alt+u. To browse someone's file list, use C</browse> or hit the 'b' key in
the user list. And to monitor your upload and download connections, use
C</connections> or hit Alt+n.
+You may see one-letter flags to the left of file names in search results and
+file list tabs. Their meaning is as follows :
+
+=over
+
+=item H
+
+The file had been added to the file list, but has not been hashed yet and thus
+is not visible to others. This flag can appear only when browsing your own list.
+
+=item S
+
+The file is already in your share. If C<download_shared> is set to C<false>,
+trying to download it will result only in an informational message. This flag
+never appears when browsing your own file list.
+
+=item Q
+
+The file is currently in your download queue. Trying to download it will result
+only in an informational message.
+
+=back
=head1 OPTIONS
diff --git a/src/ui.c b/src/ui.c
index e967a24..02046d2 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -481,6 +481,14 @@ void ui_daychange(const char *day) {
g_free(msg);
}
+// Get the extra flag used to annotate files which are present in the download
+// queue (Q) or already shared (S). Currently used in file list and search tabs.
+char ui_file_flag(const char *tth) {
+ return
+ fl_local_from_tth(tth) ? 'S' :
+ g_hash_table_lookup(dl_queue, tth) ? 'Q' :
+ ' ';
+}
void ui_input(guint64 key) {
ui_tab_t *curtab = ui_tab_cur->data;
diff --git a/src/uit_fl.c b/src/uit_fl.c
index 3e0db83..f017676 100644
--- a/src/uit_fl.c
+++ b/src/uit_fl.c
@@ -91,7 +91,7 @@ static void setdir(tab_t *t, fl_list_t *fl, fl_list_t *sel) {
if(sel == g_ptr_array_index(fl->sub, i))
seli = iter;
}
- t->list = ui_listing_create(seq, NULL, NULL, get_name);
+ t->list = ui_listing_create(seq, NULL, t, get_name);
if(seli)
t->list->sel = seli;
}
@@ -329,19 +329,22 @@ static char *t_title(ui_tab_t *tab) {
static void draw_row(ui_listing_t *list, GSequenceIter *iter, int row, void *dat) {
fl_list_t *fl = g_sequence_get(iter);
+ tab_t *t = dat;
attron(iter == list->sel ? UIC(list_select) : UIC(list_default));
mvhline(row, 0, ' ', wincols);
if(iter == list->sel)
mvaddstr(row, 0, ">");
- mvaddch(row, 2, fl->isfile && !fl->hastth ? 'H' :' ');
- mvaddch(row, 3, fl_local_from_tth(fl->tth) ? 'S' : ' ');
+ if(t->uid) // add shared/queued flags only while browsing others' lists.
+ mvaddch(row, 2, ui_file_flag(fl->tth));
+ else
+ mvaddch(row, 2, fl->isfile && !fl->hastth ? 'H' :' ');
- mvaddstr(row, 5, str_formatsize(fl->size));
+ mvaddstr(row, 4, str_formatsize(fl->size));
if(!fl->isfile)
- mvaddch(row, 18, '/');
- ui_listing_draw_match(list, iter, row, 19, str_offset_from_columns(fl->name, wincols-20));
+ mvaddch(row, 17, '/');
+ ui_listing_draw_match(list, iter, row, 18, str_offset_from_columns(fl->name, wincols-19));
attroff(iter == list->sel ? UIC(list_select) : UIC(list_default));
}
diff --git a/src/uit_search.c b/src/uit_search.c
index 87afc97..5199727 100644
--- a/src/uit_search.c
+++ b/src/uit_search.c
@@ -191,7 +191,6 @@ static char *t_title(ui_tab_t *tab) {
}
-// TODO: mark already shared and queued files?
static void draw_row(ui_listing_t *list, GSequenceIter *iter, int row, void *dat) {
search_r_t *r = g_sequence_get(iter);
tab_t *t = dat;
@@ -221,12 +220,14 @@ static void draw_row(ui_listing_t *list, GSequenceIter *iter, int row, void *dat
else
mvaddstr(row, i+16, " -");
+ mvaddch(row, i+20, ui_file_flag(r->tth));
+
char *fn = strrchr(r->file, '/');
if(fn)
fn++;
else
fn = r->file;
- mvaddnstr(row, i+21, fn, str_offset_from_columns(fn, wincols-i-21));
+ mvaddnstr(row, i+22, fn, str_offset_from_columns(fn, wincols-i-22));
attroff(iter == list->sel ? UIC(list_select) : UIC(list_default));
}
@@ -243,7 +244,8 @@ static void t_draw(ui_tab_t *tab) {
int i = t->hide_hub ? 22 : 36;
mvaddstr(1, i, "Size");
mvaddstr(1, i+12, "Slots");
- mvaddstr(1, i+21, "File");
+ mvaddstr(1, i+20, "F"); // short for "Flags"
+ mvaddstr(1, i+22, "File");
attroff(UIC(list_header));
int bottom = winrows-4;