示例#1
0
void BrowserView::active_view(VIEW::Id m, QString f, QVariant d)
{
    BrowserParam param = BrowserParam(m, f, d);

    add_history_entry( param );
    switch_view(param);
}
示例#2
0
/* slot used by FileScene to load a directory inside view */
void BrowserView::slot_on_load_new_data(const QString& data)
{
    Debug::debug() << "  [BrowserView] slot_on_load_new_data data" << data;

    BrowserParam param = BrowserParam(
          VIEW::Id(SETTINGS()->_viewMode),
          CentralToolBar::instance()->explorerFilter(),
          QVariant( data ));
    
    add_history_entry( param );
       
    switch_view(param);
}
示例#3
0
/* slot triggered when action from menu is activated */
void BrowserView::slot_on_menu_index_changed(QModelIndex idx)
{
    if(!idx.isValid()) return;
   
    VIEW::Id m_mode    = VIEW::Id (idx.data(ViewModeRole).toInt());
    QVariant       m_data    = idx.data(FileRole);   
    QString        m_filter  = CentralToolBar::instance()->explorerFilter();

    BrowserParam param = BrowserParam(m_mode,m_filter,m_data);
    
    add_history_entry(param);

    switch_view(param);
}
示例#4
0
/* slot triggered when use enter the search field */
void BrowserView::slot_on_search_changed(const QString& filter)
{           
    Debug::debug() << "  [BrowserView] slot_on_search_changed  " << filter;

    BrowserParam current_param;
    if(m_browser_params_idx != -1)
      current_param = m_browser_params.at(m_browser_params_idx);

  
    BrowserParam param = BrowserParam(
           VIEW::Id(SETTINGS()->_viewMode),
           filter,
           current_param.data);
    
    add_history_entry(param);

    switch_view(param);
}
示例#5
0
/*******************************************************************************
   Save / Restore settings
*******************************************************************************/
void BrowserView::restore_view()
{
   Debug::debug() << "  [BrowserView] restore_view";
  
   BrowserParam param;

   param.mode   = VIEW::Id(SETTINGS()->_viewMode);
   param.filter = QString();
   
   if(param.mode == VIEW::ViewFileSystem)
     param.data   = QVariant( SETTINGS()->_filesystem_path );
   else
     param.data   = QVariant();

   add_history_entry(param);

   switch_view(param);   
  
   is_started = true;
}
	void bandwidth_manager::hand_out_bandwidth() try
	{
		INVARIANT_CHECK;
#if defined TORRENT_LOGGING || defined TORRENT_VERBOSE_LOGGING
//		(*m_ses->m_logger) << "hand out bw [" << m_channel << "]\n";
#endif

		ptime now(time_now());

		mutex_t::scoped_lock l(m_mutex);
		int limit = m_limit;
		l.unlock();

		// available bandwidth to hand out
		int amount = limit - m_current_quota;

		int bandwidth_block_size_limit = max_bandwidth_block_size;
		if (m_queue.size() > 3 && bandwidth_block_size_limit > limit / int(m_queue.size()))
			bandwidth_block_size_limit = std::max(max_bandwidth_block_size / int(m_queue.size() - 3)
				, min_bandwidth_block_size);

		while (!m_queue.empty() && amount > 0)
		{
			assert(amount == limit - m_current_quota);
			bw_queue_entry qe = m_queue.front();
			m_queue.pop_front();

			shared_ptr<torrent> t = qe.peer->associated_torrent().lock();
			if (!t) continue;
			if (qe.peer->is_disconnecting())
			{
				t->expire_bandwidth(m_channel, -1);
				continue;
			}

			// at this point, max_assignable may actually be zero. Since
			// the bandwidth quota is subtracted once the data has been
			// send. If the peer was added to the queue while the data was
			// still being sent, max_assignable may have been > 0 at that time.
			int max_assignable = qe.peer->max_assignable_bandwidth(m_channel);
			if (max_assignable == 0)
			{
				t->expire_bandwidth(m_channel, -1);
				continue;
			}
			// don't hand out chunks larger than the throttle
			// per second on the torrent
			if (max_assignable > t->bandwidth_throttle(m_channel))
				max_assignable = t->bandwidth_throttle(m_channel);

			// so, hand out max_assignable, but no more than
			// the available bandwidth (amount) and no more
			// than the max_bandwidth_block_size
			int single_amount = std::min(amount
				, std::min(bandwidth_block_size_limit
					, max_assignable));
			assert(single_amount > 0);
			amount -= single_amount;
			qe.peer->assign_bandwidth(m_channel, single_amount);
			t->assign_bandwidth(m_channel, single_amount);
			add_history_entry(history_entry(qe.peer, t, single_amount, now + window_size));
		}
	}
	catch (std::exception& e)
	{ assert(false); };