Find file now shows a directory listing.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@362 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-03-18 21:20:46 +00:00
parent a16a88ebeb
commit 072a38c8fc
10 changed files with 282 additions and 8 deletions
+2
View File
@@ -29,6 +29,8 @@ libsub_display_a_SOURCES = \
window_peer_list.h \
window_statusbar.cc \
window_statusbar.h \
window_string_list.cc \
window_string_list.h \
window_title.cc \
window_title.h \
window_tracker_list.cc \
+67
View File
@@ -0,0 +1,67 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005, Jari Sundell
//
// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#include "config.h"
#include "canvas.h"
#include "utils.h"
#include "window_string_list.h"
namespace display {
WindowStringList::WindowStringList() :
Window(new Canvas, true) {
}
WindowStringList::~WindowStringList() {
}
void
WindowStringList::redraw() {
m_nextDraw = utils::Timer::max();
m_canvas->erase();
size_t ypos = 0;
size_t xpos = 1;
size_t width = 0;
for (iterator itr = m_first; itr != m_last; ++itr) {
if (ypos == (size_t)m_canvas->get_height()) {
ypos = 0;
xpos += width + 2;
if (xpos >= (size_t)m_canvas->get_width())
break;
}
width = std::max(itr->size(), width);
if (xpos + itr->size() <= (size_t)m_canvas->get_width())
m_canvas->print(xpos, ypos++, "%s", itr->c_str());
else
m_canvas->print(xpos, ypos++, "%s", itr->substr(0, m_canvas->get_width() - xpos).c_str());
}
}
}
+51
View File
@@ -0,0 +1,51 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005, Jari Sundell
//
// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#ifndef RTORRENT_DISPLAY_WINDOW_STRING_LIST_H
#define RTORRENT_DISPLAY_WINDOW_STRING_LIST_H
#include <string>
#include <list>
#include "window.h"
namespace display {
class WindowStringList : public Window {
public:
typedef std::list<std::string>::iterator iterator;
WindowStringList();
~WindowStringList();
void set_range(iterator first, iterator last) { m_first = first; m_last = last; }
virtual void redraw();
private:
iterator m_first;
iterator m_last;
};
}
#endif
+1
View File
@@ -71,6 +71,7 @@ PathInput::receive_do_complete() {
set_pos(dirEnd + base.size());
mark_dirty();
m_signalShowRange.emit(r.first, r.second);
}
PathInput::size_type
+8 -1
View File
@@ -23,6 +23,8 @@
#ifndef RTORRENT_INPUT_PATH_INPUT_H
#define RTORRENT_INPUT_PATH_INPUT_H
#include <sigc++/signal.h>
#include "utils/directory.h"
#include "text_input.h"
@@ -31,11 +33,14 @@ namespace input {
class PathInput : public TextInput {
public:
typedef std::pair<utils::Directory::iterator, utils::Directory::iterator> Range;
typedef std::pair<utils::Directory::iterator, utils::Directory::iterator> Range;
typedef sigc::signal2<void, utils::Directory::iterator, utils::Directory::iterator> SignalShowRange;
PathInput();
virtual ~PathInput() {}
SignalShowRange& signal_show_range() { return m_signalShowRange; }
virtual bool pressed(int key);
private:
@@ -43,6 +48,8 @@ private:
size_type find_last_delim();
Range find_incomplete(utils::Directory& d, const std::string& f);
SignalShowRange m_signalShowRange;
};
}
+2
View File
@@ -17,6 +17,8 @@ libsub_ui_a_SOURCES = \
element_peer_info.h \
element_peer_list.cc \
element_peer_list.h \
element_string_list.cc \
element_string_list.h \
element_tracker_list.cc \
element_tracker_list.h \
root.cc \
+20 -6
View File
@@ -25,6 +25,7 @@
#include <stdexcept>
#include <rak/functional.h>
#include <sigc++/bind.h>
#include <sigc++/hide.h>
#include <torrent/torrent.h>
#include "core/download.h"
@@ -43,6 +44,7 @@
#include "download_list.h"
#include "element_download_list.h"
#include "element_log_complete.h"
#include "element_string_list.h"
namespace ui {
@@ -53,7 +55,6 @@ DownloadList::DownloadList(Control* c) :
m_windowTitle(new WTitle("rtorrent " VERSION " - " + torrent::get(torrent::LIBRARY_NAME))),
m_windowStatus(new WStatus(&c->get_core())),
m_windowTextInput(new WInput(new input::PathInput)),
m_windowHttpQueue(new WHttp(&c->get_core().get_http_queue())),
m_taskUpdate(sigc::mem_fun(*this, &DownloadList::task_update)),
@@ -69,9 +70,8 @@ DownloadList::DownloadList(Control* c) :
m_windowLog = new WLog(&m_control->get_core().get_log_important());
bind_keys();
m_windowTextInput->get_input()->slot_dirty(sigc::mem_fun(*m_windowTextInput, &WInput::mark_dirty));
setup_keys();
setup_input();
}
DownloadList::~DownloadList() {
@@ -242,7 +242,6 @@ void
DownloadList::receive_exit_input() {
m_windowStatus->set_active(true);
m_windowTextInput->set_active(false);
m_control->get_display().adjust_layout();
m_control->get_input().set_text_input();
@@ -253,6 +252,8 @@ DownloadList::receive_exit_input() {
m_bindings->erase('\n');
m_bindings->erase(KEY_ENTER);
receive_change(DISPLAY_DOWNLOAD_LIST);
}
void
@@ -272,7 +273,7 @@ DownloadList::task_update() {
}
void
DownloadList::bind_keys() {
DownloadList::setup_keys() {
(*m_bindings)['a'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 1);
(*m_bindings)['z'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), -1);
(*m_bindings)['s'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 5);
@@ -294,4 +295,17 @@ DownloadList::bind_keys() {
m_uiArray[DISPLAY_LOG]->get_bindings()[' '] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change), DISPLAY_DOWNLOAD_LIST);
}
void
DownloadList::setup_input() {
input::PathInput* p = new input::PathInput;
ElementStringList* esl = new ElementStringList();
m_windowTextInput = new WInput(p);
p->slot_dirty(sigc::mem_fun(*m_windowTextInput, &WInput::mark_dirty));
p->signal_show_range().connect(sigc::hide(sigc::hide(sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change), DISPLAY_STRING_LIST))));
p->signal_show_range().connect(sigc::mem_fun(*esl, &ElementStringList::set_range<utils::Directory::iterator>));
m_uiArray[DISPLAY_STRING_LIST] = esl;
}
}
+4 -1
View File
@@ -68,6 +68,7 @@ public:
typedef enum {
DISPLAY_DOWNLOAD_LIST,
DISPLAY_LOG,
DISPLAY_STRING_LIST,
DISPLAY_MAX_SIZE
} Display;
@@ -105,7 +106,9 @@ private:
void receive_change(Display d);
void task_update();
void bind_keys();
void setup_keys();
void setup_input();
Display m_state;
+60
View File
@@ -0,0 +1,60 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005, Jari Sundell
//
// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#include "config.h"
#include <stdexcept>
#include "control.h"
#include "element_string_list.h"
namespace ui {
ElementStringList::ElementStringList() {
m_list.push_back("Test string 1");
m_list.push_back("Test string 2");
}
void
ElementStringList::activate(Control* c, MItr mItr) {
if (m_window != NULL)
throw std::logic_error("ui::ElementStringList::activate(...) called on an object in the wrong state");
c->get_input().push_front(&m_bindings);
*mItr = m_window = new WStringList();
m_window->set_range(m_list.begin(), m_list.end());
}
void
ElementStringList::disable(Control* c) {
if (m_window == NULL)
throw std::logic_error("ui::ElementStringList::disable(...) called on an object in the wrong state");
c->get_input().erase(&m_bindings);
delete m_window;
m_window = NULL;
}
}
+67
View File
@@ -0,0 +1,67 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005, Jari Sundell
//
// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#ifndef RTORRENT_UI_ELEMENT_STRING_LIST_H
#define RTORRENT_UI_ELEMENT_STRING_LIST_H
#include <list>
#include <string>
#include <algorithm>
#include <functional>
#include "element_base.h"
#include "display/window_string_list.h"
namespace ui {
class Control;
class ElementStringList : public ElementBase {
public:
typedef display::WindowStringList WStringList;
typedef std::list<std::string> List;
ElementStringList();
void activate(Control* c, MItr mItr);
void disable(Control* c);
template <typename InputIter>
void set_range(InputIter first, InputIter last) {
m_list.clear();
while (first != last)
m_list.push_back(*(first++));
m_window->set_range(m_list.begin(), m_list.end());
m_window->mark_dirty();
}
private:
WStringList* m_window;
List m_list;
};
}
#endif