Example #1
0
void htCustomScanner::parseMore()
{	
	//std::cout << "ParseMore\n";
	{
		htConnPool::htSession sess = m_conn_pool->get();
		loadMore(sess);
	}
	
	if (cell_buffer.size() == 0)
	{
		return;
	}
	
	htLine cur_line;
	std::string cur_key;
	
	int nline = 0;
	
	for (int i = 0; cell_buffer.size()!=0; i++) {	 
		htCell cell = cell_buffer.front();
		// if need this coll
		if (	m_colls.find(cell.coll) != m_colls.end()) {			
			// if key changed or end
			if ( (i!=0 && cell.key != cur_key) || cell_buffer.size()==0) {
				// end
				if (cell_buffer.size()==0) {
					cur_line.cells[cell.coll] = cell.value;
				}
				// push to line buffer
				cur_line.key = cur_key;
				if (cur_key.size()>=1)
					line_buffer.push(cur_line);
				cur_key = cell.key;
				nline++;
				// end or got enough lines
				if (nline >= m_lines_in_buffer || cell_buffer.size()==0) {
					break;
				}
			}
			if (i==0) { // first key
				cur_key = cell.key;
			}
			cur_line.cells[cell.coll] = cell.value;
		}
		
		cell_buffer.pop();
		
		if (cell_buffer.size() < 255) { // keep enough cells in buffer 
			htConnPool::htSession sess = m_conn_pool->get();
			loadMore(sess);
		}
	}
	
	if (cell_buffer.size()==0) {
		cur_line.key = cur_key;
		if (cur_key.size()>=1)
			line_buffer.push(cur_line);
	}
}
Example #2
0
void htKeyScanner::reset(htConnPool::htSession sess)
{
	m_s = sess.client->open_scanner(m_ns, m_table, m_ss);
	while (buffer.size()!=0)
		buffer.pop();
	loadMore(sess);
}
Example #3
0
void htCustomScanner::loadMore(htConnPool::htSession &_sess)
{
	std::vector<Hypertable::ThriftGen::Cell> cells;
	_sess.client->scanner_get_cells(cells, m_s);
	
	if (cells.size()==0)
		return;
	
	for (int i = 0; i<cells.size(); i++) {
			cell_buffer.push(htCell(cells[i].key.row,
									cells[i].key.column_family,
									cells[i].value));
	}
	cells.clear();
	
	if (cell_buffer.size()<255)
		loadMore(_sess);
}
Example #4
0
std::string htKeyScanner::getNextKey()
{
	if (buffer.size()!=0)
	{
		std::string k = buffer.front();
		buffer.pop();
		if (buffer.size()<4096)
		{
			htConnPool::htSession sess = m_conn_pool->get();
			//for (int i = 0; i<10; i++)
			loadMore(sess);
		}
		return k;
	}
	else
	{
		
		throw std::string("htCollScanner::getNextCell() buffer empty");
	}
}
Example #5
0
void TelegramMessagesModel::init()
{
    if( !p->dialog )
        return;
    if( !p->telegram )
        return;
    if( p->dialog == p->telegram->nullDialog() )
        return;

    p->load_count = 0;
    p->load_limit = LOAD_STEP_COUNT;
    loadMore(true);
    messagesChanged(true);

    if(p->dialog->peer()->userId() != CutegramDialog::cutegramId())
    {
        p->refreshing = true;
        emit refreshingChanged();
    }
}
Example #6
0
Playlist::Playlist(PlaylistWidget::ListTypes listType, QString title, quint64 hash, QObject *parent) :
    QObject(parent)
{
    m_listType = listType;
    m_sTitle = title;
    m_bCustomTitle = false;

    m_Settings = Settings::instance();
    connect(m_Settings, SIGNAL(changed()), SLOT(onSettingsChanged()));

    m_bLoadingState = false;
    m_bShuffleList = m_Settings->getValue("player/shuffle").toInt() > 1 ? true : false;

    m_LastTrack = 0;

    m_bLoadMeta = false;
    m_bUseMeta = false;

    m_bTitleByContent = m_Settings->getValue("playlist/tabs_by_content").toBool();

    m_Auth = Auth::instance();
    connect(m_Auth, SIGNAL(authComplete()), SLOT(update()));


    // Set hash
    if(hash == 0) {
        QDateTime *time = new QDateTime(QDateTime::currentDateTime());
        m_Hash = time->toMSecsSinceEpoch();
        m_bNewly = true;
    } else {
        m_Hash = hash;
        m_bNewly = false;
    }

    // Create playlist widget
    m_listWidget = new PlaylistWidget(m_listType);
    connect(this, SIGNAL(trackAdded()), m_listWidget, SLOT(trackAdded()));
    connect(m_listWidget, SIGNAL(trackActivate(Track*)), SLOT(trackActivate(Track*)));

    // Connect key events
    connect(m_listWidget, SIGNAL(skQueue()), SLOT(addToQueue()));
    connect(m_listWidget, SIGNAL(skRemove()), SLOT(removeTrack()));
    connect(m_listWidget, SIGNAL(skDownload()), SLOT(downloadTrack()));

    // Create object of parser
    m_Parser = new Parser(this);
    connect(m_Parser, SIGNAL(newTrack(Track*)), SLOT(addTrack(Track*)));
    connect(m_Parser, SIGNAL(busy()), SLOT(parserBusy()));
    connect(m_Parser, SIGNAL(free()), SLOT(parserFree()));
    connect(m_Parser, SIGNAL(savePlaylist()), SLOT(save()));
    connect(m_Parser, SIGNAL(busy()), m_listWidget, SLOT(showLoading()));
    connect(m_Parser, SIGNAL(free()), m_listWidget, SLOT(hideLoading()));

    // Create actions parser
    m_vkActions = VkActions::instance();
    connect(m_vkActions, SIGNAL(message(QString,QString)), SIGNAL(message(QString,QString)));

    switch(m_listType) {
        case PlaylistWidget::Search:
            connect(m_listWidget, SIGNAL(searchChanged(QString)), SLOT(searchChanged(QString)));
            connect(m_listWidget, SIGNAL(loadMore()), m_Parser, SLOT(loadMoreResults()));
        break;
        case PlaylistWidget::AudioLib:
            connect(m_listWidget->friendsList(), SIGNAL(friendSelected(QString,QString,QString)), SLOT(librarySelected(QString,QString,QString)));
            connect(m_listWidget, SIGNAL(refresh()), SLOT(refresh()));
        break;
        case PlaylistWidget::Suggestions:
            connect(m_listWidget, SIGNAL(loadMore()), m_Parser, SLOT(loadMoreResults()));
            connect(m_listWidget, SIGNAL(refresh()), SLOT(refresh()));
        break;
        case PlaylistWidget::DbSearch:
            connect(m_listWidget, SIGNAL(searchChanged(QString)), SLOT(searchChanged(QString)));
            connect(m_listWidget, SIGNAL(newTrack(Track*)), SLOT(addTrack(Track*)));
            connect(m_listWidget, SIGNAL(clearList()), SLOT(clearList()));
        break;
    }

    m_Model = new QStandardItemModel(this);

    m_ProxyModel = new QSortFilterProxyModel(this);
    m_ProxyModel->setSourceModel(m_Model);
    m_ProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
    m_ProxyModel->setFilterKeyColumn(2);

    m_listWidget->setModel(m_ProxyModel);

    connect(m_listWidget, SIGNAL(listSearchChanged(QString)), SLOT(setListSearch(QString)));

    createMenus();

    load();

    if(type() == PlaylistWidget::AudioLib &&
       m_bNewly &&
       m_Settings->getValue("playlist/autoload_library").toBool()
       )
        librarySelected(m_Auth->vkId(), "0", tr("My Library"));

    // Actions on newly created plalylists
    if(m_bNewly) {
        switch(m_listType) {
            case PlaylistWidget::Search:
                m_listWidget->focusOnSearch();
            break;
            case PlaylistWidget::AudioLib:
            if(m_Settings->getValue("playlist/autoload_library").toBool())
                librarySelected(m_Auth->vkId(), "0", tr("My Library"));
            break;
            case PlaylistWidget::Suggestions:
                refresh();
            break;
            case PlaylistWidget::DbSearch:
                // Unused
            break;
        }
    }
}
Example #7
0
IngredientComboBox::IngredientComboBox( bool b, QWidget *parent, RecipeDB *db, const QString &specialItem ) : KComboBox( b, parent ),
		database( db ), loading_at(0), load_timer(new QTimer(this)), m_specialItem(specialItem)
{
	connect( load_timer, SIGNAL(timeout()), SLOT(loadMore()) );
	completionObject()->setIgnoreCase(true);
}