void JsonDbSortingListModelPrivate::createOrUpdateNotification(int index)
{
    Q_Q(JsonDbSortingListModel);
    if (index >= partitionObjects.count())
        return;
    clearNotification(index);
    QJsonDbWatcher *watcher = new QJsonDbWatcher();
    watcher->setQuery(query);
    watcher->setWatchedActions(QJsonDbWatcher::Created | QJsonDbWatcher::Updated |QJsonDbWatcher::Removed);
    watcher->setPartition(partitionObjects[index]->name());
    QVariantMap::ConstIterator i = queryBindings.constBegin();
    while (i != queryBindings.constEnd()) {
        watcher->bindValue(i.key(), QJsonValue::fromVariant(i.value()));
        ++i;
    }
    QObject::connect(watcher, SIGNAL(notificationsAvailable(int)),
                     q, SLOT(_q_notificationsAvailable()));
    QObject::connect(watcher, SIGNAL(error(QtJsonDb::QJsonDbWatcher::ErrorCode,QString)),
                     q, SLOT(_q_notificationError(QtJsonDb::QJsonDbWatcher::ErrorCode,QString)));
    JsonDatabase::sharedConnection().addWatcher(watcher);
    partitionObjectDetails[index].watcher = watcher;
}
Example #2
0
void QuickFindMux::registerSearchable( QObject* searchable )
{
    LOG(logDEBUG) << "QuickFindMux::registerSearchable";

    // The searchable can change our qf pattern
    connect( searchable,
             SIGNAL( changeQuickFind( const QString&, QuickFindMux::QFDirection ) ),
             this, SLOT( changeQuickFind( const QString&, QuickFindMux::QFDirection ) ) );
    // Send us notifications
    connect( searchable, SIGNAL( notifyQuickFind( const QFNotification& ) ),
             this, SIGNAL( notify( const QFNotification& ) ) );

    // And clear them
    connect( searchable, SIGNAL( clearQuickFindNotification() ),
             this, SIGNAL( clearNotification() ) );
    // Search can be initiated by the view itself
    connect( searchable, SIGNAL( searchNext() ),
             this, SLOT( searchNext() ) );
    connect( searchable, SIGNAL( searchPrevious() ),
             this, SLOT( searchPrevious() ) );

    registeredSearchables_.push_back( searchable );
}
void JsonDbSortingListModelPrivate::clearNotifications()
{
    for (int i = 0; i<partitionObjects.count(); i++)
        clearNotification(i);
}
Example #4
0
int QuickFind::searchBackward()
{
    bool found = false;
    int line;
    int column;
    int start_col;
    int end_col;

    if ( ! quickFindPattern_->isActive() )
        return -1;

    // Position where we start the search from
    selection_->getPreviousPosition( &line, &column );

    // Optimisation: if we are already before the first match,
    // we don't do any search at all.
    if ( firstMatch_.isSooner( line, column ) ) {
        // Send a notification
        emit notify( "Reached beginning of file, no occurence found." );

        return -1;
    }

    LOG( logDEBUG ) << "Start searching.";

    // We look at the beginning of the first line
    if ( ( column > 0 ) &&  ( quickFindPattern_->isLineMatchingBackward(
                logData_->getExpandedLineString( line ), column ) ) ) {
        quickFindPattern_->getLastMatch( &start_col, &end_col );
        found = true;
    }
    else {
        searchingNotifier_.reset();
        // And then the rest of the file
        line--;
        while ( line >= 0 ) {
            if ( quickFindPattern_->isLineMatchingBackward(
                        logData_->getExpandedLineString( line ) ) ) {
                quickFindPattern_->getLastMatch( &start_col, &end_col );
                found = true;
                break;
            }
            line--;

            // See if we need to notify of the ongoing search
            searchingNotifier_.ping();
        }
    }

    if ( found )
    {
        selection_->selectPortion( line, start_col, end_col );

        // Clear any notification
        emit clearNotification();

        return line;
    }
    else {
        // Update the position of the first match
        int first_match_line;
        int first_match_column;
        selection_->getNextPosition( &first_match_line, &first_match_column );
        firstMatch_.set( first_match_line, first_match_column );

        // Send a notification
        emit notify( "Reached beginning of file, no occurence found." );

        return -1;
    }
}