c9ca2604ee
And out of the Tab class. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
/*
|
|
* Copyright 2015 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/filter.h>
|
|
#include <gui/queue/window.h>
|
|
|
|
QueueWindow :: QueueWindow(BaseObjectType *cobject,
|
|
const Glib::RefPtr<Gtk::Builder> builder)
|
|
: Gtk::ScrolledWindow(cobject), _builder(builder), _q_search_empty(true)
|
|
{
|
|
_builder->get_widget("q_treeview", q_treeview);
|
|
}
|
|
|
|
QueueWindow :: ~QueueWindow()
|
|
{
|
|
}
|
|
|
|
void QueueWindow :: init(Queue *queue)
|
|
{
|
|
_queue = queue;
|
|
q_model = Glib::RefPtr<QueueModel>(new QueueModel(queue));
|
|
q_filter = Gtk::TreeModelFilter::create(q_model);
|
|
|
|
q_filter->set_visible_func(sigc::mem_fun(*this, &QueueWindow::filter_ids));
|
|
|
|
q_treeview->signal_row_activated().connect(sigc::mem_fun(*this,
|
|
&QueueWindow :: on_row_activated));
|
|
q_treeview->set_model(q_filter);
|
|
}
|
|
|
|
void QueueWindow :: filter(std::string &text)
|
|
{
|
|
_q_search_empty = (text.find_first_not_of(" \t") == std::string::npos);
|
|
if (!_q_search_empty)
|
|
filter :: search(text, _q_search_res);
|
|
q_filter->refilter();
|
|
}
|
|
|
|
bool QueueWindow :: filter_ids(const Gtk::TreeIter &iter)
|
|
{
|
|
unsigned int id;
|
|
std::set<unsigned int>::iterator it;
|
|
|
|
if (_q_search_empty)
|
|
return true;
|
|
|
|
id = q_model->iter_to_id(iter);
|
|
it = _q_search_res.find(_queue->operator[](id)->index());
|
|
return it != _q_search_res.end();
|
|
}
|
|
|
|
void QueueWindow :: on_row_activated(const Gtk::TreePath &path,
|
|
Gtk::TreeViewColumn *col)
|
|
{
|
|
Gtk::TreePath real_path = q_filter->convert_path_to_child_path(path);
|
|
q_model->on_path_selected(real_path);
|
|
}
|