void DeclarativeTabModel::tabsAvailable(QList<Tab> tabs)
{
    beginResetModel();
    int oldCount = count();
    m_tabs.clear();
    m_tabs = tabs;

    if (m_tabs.count() > 0) {
        loadTabOrder();
        qSort(m_tabs.begin(), m_tabs.end(), DeclarativeTabModel::tabSort);
        m_activeTab = m_tabs.at(0);
        m_tabs.removeAt(0);
    } else {
        m_activeTab = Tab();
        emit tabsCleared();
    }

    endResetModel();

    if (count() != oldCount) {
        emit countChanged();
    }

    int maxTabId = DBManager::instance()->getMaxTabId();
    if (m_nextTabId != maxTabId + 1) {
        m_nextTabId = maxTabId + 1;
        emit nextTabIdChanged();
    }

    // Startup should be synced to this.
    if (!m_loaded) {
        m_loaded = true;
        emit loadedChanged();
    }
}
void DeclarativeTabModel::setUnloaded()
{
    if (m_loaded) {
        m_loaded = false;
        emit loadedChanged();
    }
}
Exemplo n.º 3
0
bool ZimServer::loadZimFile()
{
    Settings* s = Settings::instance();

    s->articleModel->clear();

    QString filePath = s->getZimFile();
    if (filePath.isEmpty()) {
        if (zimfile != Q_NULLPTR) {
            delete zimfile;
            zimfile = Q_NULLPTR;
        }
        emit loadedChanged();
        return false;
    }
    if (!QFile::exists(filePath)) {
        qWarning() << "ZIM file" << filePath << "doesn't exist!";
        if (zimfile != Q_NULLPTR) {
            delete zimfile;
            zimfile = Q_NULLPTR;
        }
        s->setZimFile("");
        emit loadedChanged();
        return false;
    }

    try
    {
        zimfile = new zim::File(filePath.toStdString());
    }
    catch (const std::exception& e)
    {
        qWarning() << "Unable to open ZIM file" << filePath << "!";
        qWarning() << "Details:" << e.what();
        if (zimfile != Q_NULLPTR) {
            delete zimfile;
            zimfile = Q_NULLPTR;
        }
        s->setZimFile("");
        emit loadedChanged();
        return false;
    }

    emit loadedChanged();
    return true;
}
void QDeclarativeAudioSample::init()
{
    if (m_streaming) {
        //TODO

    } else {
        m_soundBuffer =
            qobject_cast<QDeclarativeAudioEngine*>(parent())->engine()->getStaticSoundBuffer(m_url);
        if (m_soundBuffer->state() == QSoundBuffer::Ready) {
            emit loadedChanged();
        } else {
            connect(m_soundBuffer, SIGNAL(ready()), this, SIGNAL(loadedChanged()));
        }
        if (m_preloaded) {
            m_soundBuffer->load();
        }
    }
}
void QSoundEffectPrivate::setStatus(QSoundEffect::Status status)
{
    if (m_status == status)
        return;
    bool oldLoaded = isLoaded();
    m_status = status;
    emit statusChanged();
    if (oldLoaded != isLoaded())
        emit loadedChanged();
}
Exemplo n.º 6
0
void QSoundEffectPrivate::setStatus(QSoundEffect::Status status)
{
#ifdef QT_QAUDIO_DEBUG
    qDebug() << this << "setStatus" << status;
#endif
    if (d->m_status == status)
        return;
    bool oldLoaded = isLoaded();
    d->m_status = status;
    emit statusChanged();
    if (oldLoaded != isLoaded())
        emit loadedChanged();
}
void DeclarativeWebContainer::setTabModel(DeclarativeTabModel *model)
{
    if (m_model != model) {
        if (m_model) {
            disconnect(m_model);
        }

        m_model = model;
        if (m_model) {
            connect(m_model, SIGNAL(activeTabChanged(int,int,bool)), this, SLOT(onActiveTabChanged(int,int,bool)));
            connect(m_model, SIGNAL(loadedChanged()), this, SLOT(initialize()));
            connect(m_model, SIGNAL(tabClosed(int)), this, SLOT(releasePage(int)));
            connect(m_model, SIGNAL(tabsCleared()), this, SLOT(onTabsCleared()));
            connect(m_model, SIGNAL(newTabRequested(QString,QString,int)), this, SLOT(onNewTabRequested(QString,QString,int)));
        }
        emit tabModelChanged();
    }
}
Exemplo n.º 8
0
void Scopes::clear()
{
    timer.stop();
    if (m_scopes.size() > 0) {
        beginRemoveRows(QModelIndex(), 0, m_scopes.count()-1);
        qDeleteAll(m_allScopes);
        m_allScopes.clear();
        m_scopes.clear();
        endRemoveRows();
    }
    delete m_scopesOverview;
    m_scopesOverview = nullptr;

    if (m_loaded) {
        m_loaded = false;
        Q_EMIT loadedChanged();
    }
}
Exemplo n.º 9
0
void PlaylistModel::onQueryFinished()
{
    QSparqlResult *result = static_cast<QSparqlResult*>(sender());

    if (result->size() > 0) {
        result->next();
        QSparqlResultRow row(result->current());

        PlaylistTrack *track = m_tracks.at(result->property("trackIndex").toInt());

        track->title = row.value("title").toString();
        track->duration = row.value("duration").toLongLong();

        QVariant artist(row.value("artist"));
        if (artist.isValid()) {
            track->artist = artist.toString();
        } else {
            track->artist = tr("Unknown artist");
            track->unknownArtist = true;
        }

        QVariant album(row.value("album"));
        if (album.isValid()) {
            track->album = album.toString();
        } else {
            track->album = tr("Unknown album");
            track->unknownAlbum = true;
        }
    }

    m_loadedTracks++;

    if (m_loadedTracks == m_tracks.size()) {
        m_loaded = true;
        emit loadedChanged();

        beginResetModel();
        m_rowCount = m_tracks.size();
        endResetModel();

        qDeleteAll(m_queries);
        m_queries.clear();
    }
}
void DeclarativeTabModel::tabsAvailable(QList<Tab> tabs)
{
    beginResetModel();
    int oldCount = count();
    m_tabs.clear();
    m_tabs = tabs;

    int activeTabId = loadTabOrder();
    if (m_tabs.count() > 0) {
        Tab tab;
        tab.setTabId(activeTabId);

        int index = m_tabs.indexOf(tab);
        if (index == -1) {
            index = 0;
        }
        const Tab &activeTab = m_tabs.at(index);
        m_tabs.removeAt(index);
        m_activeTab = activeTab;
    }

    qSort(m_tabs.begin(), m_tabs.end(), DeclarativeTabModel::tabSort);
    endResetModel();

    if (count() != oldCount) {
        emit countChanged();
    }

    int maxTabId = DBManager::instance()->getMaxTabId();
    if (m_nextTabId != maxTabId + 1) {
        m_nextTabId = maxTabId + 1;
        emit nextTabIdChanged();
    }

    // Startup should be synced to this.
    if (!m_loaded) {
        m_loaded = true;
        emit loadedChanged();
    }
}
Exemplo n.º 11
0
void PlaylistModel::componentComplete()
{
    QStringList tracksList(PlaylistUtils::parsePlaylist(m_url));

    if (tracksList.isEmpty()) {
        m_loaded = true;
        emit loadedChanged();
    } else {
        QSparqlConnection *connection = new QSparqlConnection("QTRACKER_DIRECT", QSparqlConnectionOptions(), this);

        for (int i = 0, max = tracksList.size(); i < max; i++) {
            QString url(tracksList.at(i));
            m_tracks.append(new PlaylistTrack(url));

            QSparqlResult *result = connection->exec(QSparqlQuery(PlaylistUtils::trackSparqlQuery(url),
                                                                  QSparqlQuery::SelectStatement));
            result->setProperty("trackIndex", i);
            connect(result, &QSparqlResult::finished, this, &PlaylistModel::onQueryFinished);
            m_queries.append(result);
        }
    }
}
Exemplo n.º 12
0
void Scopes::updateScopes()
{
    clear();
    addScope(new Scope("MockScope1", "People", true, this));
    addScope(new Scope("MockScope2", "Music", false, this));
    addScope(new Scope("clickscope", "Apps", true, this));
    addScope(new Scope("MockScope5", "Videos this is long ab cd ef gh ij kl", true, this));
    addScope(new Scope("SingleCategoryScope", "Single", true, this, 1));
    addScope(new Scope("MockScope4", "MS4", true, this));
    addScope(new Scope("MockScope6", "MS6", true, this));
    addScope(new Scope("MockScope7", "MS7", false, this));
    addScope(new Scope("MockScope8", "MS8", false, this));
    addScope(new Scope("MockScope9", "MS9", false, this));
    addScope(new Scope("NullPreviewScope", "NPS", false, this, 1, true));
    m_scopesOverview = new ScopesOverview(this);

    if (!m_loaded) {
        m_loaded = true;
        Q_EMIT loadedChanged();
        Q_EMIT overviewScopeChanged();
    }
}
void DeclarativeTabModel::tabsAvailable(QList<Tab> tabs)
{
    beginResetModel();
    int oldCount = count();
    m_activeTab.setTabId(0);
    m_tabs.clear();
    m_tabs = tabs;
    if (m_currentTab) {
        m_currentTab->invalidate();
    }

    int activeTabId = loadTabOrder();
    if (m_tabs.count() > 0) {
        Tab tab;
        tab.setTabId(activeTabId);

        int index = m_tabs.indexOf(tab);
        if (index == -1) {
            index = 0;
        }
        const Tab &activeTab = m_tabs.at(index);
        m_tabs.removeAt(index);
        updateActiveTab(activeTab, true);
    }

    qSort(m_tabs.begin(), m_tabs.end(), DeclarativeTabModel::tabSort);
    endResetModel();

    // Startup should be synced to this.
    if (!m_loaded) {
        m_loaded = true;
        emit loadedChanged();
    }

    if (count() != oldCount) {
        emit countChanged();
    }
}
void QSoundEffectPrivate::setSource(const QUrl &url)
{
    if (url.isEmpty()) {
        m_source = QUrl();
        setStatus(QSoundEffect::Null);
        return;
    }

    if (url.scheme() != QLatin1String("file")) {
        m_source = url;
        setStatus(QSoundEffect::Error);
        return;
    }

    if (m_sound != 0)
        delete m_sound;

    m_source = url;
    m_sound = new QSound(m_source.toLocalFile(), this);
    m_sound->setLoops(m_loopCount);
    m_status = QSoundEffect::Ready;
    emit statusChanged();
    emit loadedChanged();
}
Exemplo n.º 15
0
QT_BEGIN_NAMESPACE

/*!
    \class QSoundEffect
    \brief The QSoundEffect class provides a way to play low latency sound effects.

    \ingroup multimedia
    \ingroup multimedia_audio
    \inmodule QtMultimedia

    This class allows you to play uncompressed audio files (typically WAV files) in
    a generally lower latency way, and is suitable for "feedback" type sounds in
    response to user actions (e.g. virtual keyboard sounds, positive or negative
    feedback for popup dialogs, or game sounds).  If low latency is not important,
    consider using the QMediaPlayer class instead, since it supports a wider
    variety of media formats and is less resource intensive.

    This example shows how a looping, somewhat quiet sound effect
    can be played:

    \snippet multimedia-snippets/qsound.cpp 2

    Typically the sound effect should be reused, which allows all the
    parsing and preparation to be done ahead of time, and only triggered
    when necessary.  This assists with lower latency audio playback.

    \snippet multimedia-snippets/qsound.cpp 3

    Since QSoundEffect requires slightly more resources to achieve lower
    latency playback, the platform may limit the number of simultaneously playing
    sound effects.
*/


/*!
    \qmltype SoundEffect
    \instantiates QSoundEffect
    \brief The SoundEffect type provides a way to play sound effects in QML.

    \inmodule QtMultimedia
    \ingroup multimedia_qml
    \ingroup multimedia_audio_qml
    \inqmlmodule QtMultimedia 5.0

    SoundEffect is part of the \b{QtMultimedia 5.0} module.

    This type allows you to play uncompressed audio files (typically WAV files) in
    a generally lower latency way, and is suitable for "feedback" type sounds in
    response to user actions (e.g. virtual keyboard sounds, positive or negative
    feedback for popup dialogs, or game sounds).  If low latency is not important,
    consider using the MediaPlayer or Audio types instead, since they support a wider
    variety of media formats and are less resource intensive.

    Typically the sound effect should be reused, which allows all the
    parsing and preparation to be done ahead of time, and only triggered
    when necessary.  This is easy to achieve with QML, since you can declare your
    SoundEffect instance and refer to it elsewhere.

    The following example plays a WAV file on mouse click.

    \snippet multimedia-snippets/soundeffect.qml complete snippet

    Since SoundEffect requires slightly more resources to achieve lower
    latency playback, the platform may limit the number of simultaneously playing
    sound effects.
*/

/*!
    Creates a QSoundEffect with the given \a parent.
*/
QSoundEffect::QSoundEffect(QObject *parent) :
    QObject(parent)
{
    d = new QSoundEffectPrivate(this);
    connect(d, SIGNAL(loopsRemainingChanged()), SIGNAL(loopsRemainingChanged()));
    connect(d, SIGNAL(volumeChanged()), SIGNAL(volumeChanged()));
    connect(d, SIGNAL(mutedChanged()), SIGNAL(mutedChanged()));
    connect(d, SIGNAL(loadedChanged()), SIGNAL(loadedChanged()));
    connect(d, SIGNAL(playingChanged()), SIGNAL(playingChanged()));
    connect(d, SIGNAL(statusChanged()), SIGNAL(statusChanged()));
    connect(d, SIGNAL(categoryChanged()), SIGNAL(categoryChanged()));
}