15 #define GETTEXT_DOMAIN "wesnoth-lib"
22 #ifdef GUI2_EXPERIMENTAL_LISTBOX
42 #include <boost/shared_ptr.hpp>
45 #define DBG_CHAT_LOG LOG_STREAM(debug, log_chat_log)
46 #define LOG_CHAT_LOG LOG_STREAM(info, log_chat_log)
47 #define WRN_CHAT_LOG LOG_STREAM(warn, log_chat_log)
48 #define ERR_CHAT_LOG LOG_STREAM(err, log_chat_log)
74 , chat_log_history(r->build_chat_log())
91 static const int COUNT_PER_PAGE = 100;
106 int size = chat_log_history.size();
107 return (size % COUNT_PER_PAGE == 0) ? (size / COUNT_PER_PAGE)
108 : (size / COUNT_PER_PAGE) + 1;
121 LOG_CHAT_LOG <<
"entering tchat_log::model::stream_log\n";
123 for(
const auto &
t : make_pair(chat_log_history.begin() +
first,
124 chat_log_history.begin() + last))
129 if(!lcfilter.empty()) {
134 if(lcsample.find(lcfilter) == std::string::npos) {
140 const bool is_me =
t.text().compare(0, me_prefix.size(),
146 nick_prefix =
"<span color=\"" +
t.color() +
"\">";
147 nick_suffix =
"</span> ";
162 s << nick_prefix << lbracket;
176 s <<
t.text().substr(3);
178 s << rbracket << nick_suffix;
181 s << rbracket << nick_suffix;
195 std::ostringstream
s;
196 stream_log(s, first, last);
202 std::ostringstream
s;
203 stream_log(s, first, last,
true);
216 LOG_CHAT_LOG <<
"Entering tchat_log::controller" << std::endl;
217 LOG_CHAT_LOG <<
"Exiting tchat_log::controller" << std::endl;
222 LOG_CHAT_LOG <<
"Entering tchat_log::controller::next_page"
230 LOG_CHAT_LOG <<
"Exiting tchat_log::controller::next_page" << std::endl;
235 LOG_CHAT_LOG <<
"Entering tchat_log::controller::previous_page"
243 LOG_CHAT_LOG <<
"Exiting tchat_log::controller::previous_page"
249 LOG_CHAT_LOG <<
"Entering tchat_log::controller::filter" << std::endl;
251 LOG_CHAT_LOG <<
"Exiting tchat_log::controller::filter" << std::endl;
257 <<
"Entering tchat_log::controller::handle_page_number_changed"
263 <<
"Exiting tchat_log::controller::handle_page_number_changed"
275 LOG_CHAT_LOG <<
"Page: " << page + 1 <<
" of " << count_of_pages
278 const int first = page * page_size;
279 const int last = page < (count_of_pages - 1)
283 LOG_CHAT_LOG <<
"First " << first <<
", last " << last <<
'\n';
285 return std::make_pair(first, last);
290 LOG_CHAT_LOG <<
"Entering tchat_log::controller::update_view_from_model"
294 LOG_CHAT_LOG <<
"Number of chat messages: " << size << std::endl;
297 if(select_last_page) {
304 const int first = range.first;
305 const int last = range.second;
307 bool has_next = page + 1 < count_of_pages;
308 bool has_previous = page > 0;
316 << count_of_pages << std::endl;
319 std::ostringstream cur_page_text;
320 cur_page_text << (page + 1) <<
'/' << std::max(1, count_of_pages);
323 LOG_CHAT_LOG <<
"Exiting tchat_log::controller::update_view_from_model"
349 LOG_CHAT_LOG <<
"Entering tchat_log::view::pre_show" << std::endl;
352 LOG_CHAT_LOG <<
"Exiting tchat_log::view::pre_show" << std::endl;
386 LOG_CHAT_LOG <<
"Entering tchat_log::view::bind" << std::endl;
389 = &find_widget<tslider>(&window,
"page_number",
false);
397 = &find_widget<tbutton>(&window,
"previous_page",
false);
405 model_.
filter = &find_widget<ttext_box>(&window,
"filter",
false);
423 LOG_CHAT_LOG <<
"Exiting tchat_log::view::bind" << std::endl;
434 LOG_CHAT_LOG <<
"Entering tchat_log::tchat_log" << std::endl;
436 LOG_CHAT_LOG <<
"Exiting tchat_log::tchat_log" << std::endl;
451 LOG_CHAT_LOG <<
"Entering tchat_log::pre_show" << std::endl;
453 view_->pre_show(window);
454 LOG_CHAT_LOG <<
"Exiting tchat_log::pre_show" << std::endl;
view(const vconfig &cfg, replay *r)
model(const vconfig &c, replay *r)
void bind(twindow &window)
boost::shared_ptr< view > get_view()
this class memorizes a chat session.
bool available()
Whether wesnoth was compiled with support for a clipboard.
twindow * build(CVideo &video, const twindow_builder::tresolution *definition)
Builds a window.
void next_page(twindow &window)
void filter(twindow &window)
void connect_signal_notify_modified(tdispatcher &dispatcher, const tsignal_notification_function &signal)
Connects a signal handler for getting a notification upon modification.
void handle_page_number_changed(twindow &window)
void handle_page_number_changed()
REGISTER_DIALOG(label_settings)
void set_minimum_value(const int minimum_value)
Inherited from tinteger_selector_.
virtual void set_label(const t_string &label)
utf8::string lowercase(const utf8::string &s)
Returns a lowercased version of the string.
void connect_signal_mouse_left_click(tdispatcher &dispatcher, const tsignal_function &signal)
Connects a signal handler for a left mouse button click.
void set_maximum_value(const int maximum_value)
Inherited from tinteger_selector_.
void set_value(const int value)
Inherited from tinteger_selector_.
static lg::log_domain log_chat_log("chat_log")
Class for a single line text area.
boost::shared_ptr< view > view_
std::string get_value() const
base class of top level items, the only item which needs to store the final canvases to draw on ...
A class inherited from ttext_box that displays its input as stars.
virtual void set_use_markup(bool use_markup)
static UNUSEDNOWARN std::string _(const char *str)
int get_value() const
Inherited from tinteger_selector_.
void clear_chat_msg_list()
static const int COUNT_PER_PAGE
void set_tooltip(const t_string &tooltip)
virtual const std::string & window_id() const
Inherited from tdialog, implemented by REGISTER_DIALOG.
twindow * build_window(CVideo &video)
Inherited from tdialog.
std::string escape_text(const std::string &text)
Escapes the markup characters in a text.
void update_view_from_model(bool select_last_page=false)
void stream_log(std::ostringstream &s, int first, int last, bool raw=false)
void populate_chat_message_list(int first, int last)
GLdouble GLdouble GLdouble r
Base class for all visible items.
void handle_copy_button_clicked()
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
void pre_show(twindow &window)
Inherited from tdialog.
void copy_to_clipboard(const std::string &text, const bool)
Copies text to the clipboard.
std::string get_chat_timestamp(const time_t &t)
A variable-expanding proxy for the config class.
Standard logging facilities (interface).
std::pair< int, int > calculate_log_line_range()
void handle_copy_button_clicked(twindow &)
void chat_message_list_to_clipboard(int first, int last)
tchat_log(const vconfig &cfg, replay *replay)
void previous_page(twindow &window)
GLsizei const GLcharARB ** string
void invalidate_layout()
Updates the size of the window.
void pre_show(twindow &window)
const std::vector< chat_msg > & chat_log_history
void set_text_changed_callback(std::function< void(ttext_ *textbox, const std::string text)> cb)
Set the text_changed callback.