Hello community,
here is the log from the commit of package orion for openSUSE:Factory checked in at 2017-05-31 12:18:11
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/orion (Old)
and /work/SRC/openSUSE:Factory/.orion.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "orion"
Wed May 31 12:18:11 2017 rev:5 rq:498619 version:1.5.1+git~20170519
Changes:
--------
--- /work/SRC/openSUSE:Factory/orion/orion.changes 2017-05-20 10:14:34.376171570 +0200
+++ /work/SRC/openSUSE:Factory/.orion.new/orion.changes 2017-05-31 12:19:23.295398204 +0200
@@ -1,0 +2,6 @@
+Sat May 20 12:07:13 UTC 2017 - pousaduarte@gmail.com
+
+- Update to version 1.5.1+git~20170519:
+ * ChannelListModel improvements (#162)
+
+-------------------------------------------------------------------
Old:
----
orion-1.5.1+git~20170518.tar.xz
New:
----
orion-1.5.1+git~20170519.tar.xz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ orion.spec ++++++
--- /var/tmp/diff_new_pack.z6J8Lz/_old 2017-05-31 12:19:25.379104060 +0200
+++ /var/tmp/diff_new_pack.z6J8Lz/_new 2017-05-31 12:19:25.379104060 +0200
@@ -17,7 +17,7 @@
Name: orion
-Version: 1.5.1+git~20170518
+Version: 1.5.1+git~20170519
Release: 0
Summary: Twitch stream client using Qt
License: GPL-3.0
++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.z6J8Lz/_old 2017-05-31 12:19:25.431096720 +0200
+++ /var/tmp/diff_new_pack.z6J8Lz/_new 2017-05-31 12:19:25.435096156 +0200
@@ -1,4 +1,4 @@
<servicedata>
<service name="tar_scm">
<param name="url">https://github.com/alamminsalo/orion.git</param>
- <param name="changesrevision">f16fb3a246e777eb162dd66cff453959d606d905</param></service></servicedata>
\ No newline at end of file
+ <param name="changesrevision">0f79a6bb5132c97ba1602b59596eeb669a4977f0</param></service></servicedata>
\ No newline at end of file
++++++ orion-1.5.1+git~20170518.tar.xz -> orion-1.5.1+git~20170519.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/orion-1.5.1+git~20170518/src/model/channel.cpp new/orion-1.5.1+git~20170519/src/model/channel.cpp
--- old/orion-1.5.1+git~20170518/src/model/channel.cpp 2017-05-18 07:55:24.000000000 +0200
+++ new/orion-1.5.1+git~20170519/src/model/channel.cpp 2017-05-19 14:24:40.000000000 +0200
@@ -146,7 +146,7 @@
timestamp = QDateTime::currentDateTime().toMSecsSinceEpoch();
}
-qint64 Channel::getTime(){
+qint64 Channel::getTime() const{
return timestamp;
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/orion-1.5.1+git~20170518/src/model/channel.h new/orion-1.5.1+git~20170519/src/model/channel.h
--- old/orion-1.5.1+git~20170518/src/model/channel.h 2017-05-18 07:55:24.000000000 +0200
+++ new/orion-1.5.1+git~20170519/src/model/channel.h 2017-05-19 14:24:40.000000000 +0200
@@ -57,7 +57,7 @@
void setLastSeen(time_t);
const QString lastOnline();
void updateTime();
- qint64 getTime();
+ qint64 getTime() const;
const QString getName() const;
const QString getServiceName() const;
const QString getFullUri() const;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/orion-1.5.1+git~20170518/src/model/channellistmodel.cpp new/orion-1.5.1+git~20170519/src/model/channellistmodel.cpp
--- old/orion-1.5.1+git~20170518/src/model/channellistmodel.cpp 2017-05-18 07:55:24.000000000 +0200
+++ new/orion-1.5.1+git~20170519/src/model/channellistmodel.cpp 2017-05-19 14:24:40.000000000 +0200
@@ -94,23 +94,84 @@
return channels.size();
}
+void debugChannel(const QString prefix, const Channel * c) {
+ qDebug() << prefix << ":" << c->getId() << c->getName() << "game" << c->getGame() << "serviceName" << c->getServiceName() << "time" << c->getTime() << "viewers" << c->getViewers();
+}
+
+void ChannelListModel::addChannelInternal(Channel *channel) {
+ channels.append(channel);
+ auto id = channel->getId();
+ if (id == 0) {
+ qDebug() << "inserting new channel with 0 id";
+ }
+ else {
+ channelIdIndex.insert(id, channel);
+ }
+}
+
void ChannelListModel::addChannel(Channel *channel)
{
- beginInsertRows(QModelIndex(), channels.size(), channels.size());
- channels.append(channel);
- endInsertRows();
+ if (updateChannelIfExisting(channel)) {
+ qDebug() << "ChannelListModel::addChannel got existing channel" << channel->getId() << channel->getName();
+ }
+ else {
+ beginInsertRows(QModelIndex(), channels.size(), channels.size());
+ addChannelInternal(channel);
+ endInsertRows();
+ }
+}
+
+bool ChannelListModel::updateChannelIfExisting(const Channel * channel) {
+ const auto id = channel->getId();
+
+ const auto existingChannelEntry = channelIdIndex.find(id);
+ if (existingChannelEntry != channelIdIndex.end()) {
+ Channel * existingChannel = existingChannelEntry.value();
+ debugChannel("existingChannel", existingChannel);
+ debugChannel("addedChannel", channel);
+
+ if (channel->getTime() < existingChannel->getTime()) {
+ qDebug() << "added item was older; skipping update";
+ }
+ else {
+ existingChannel->updateWith(*channel);
+ updateChannelForView(existingChannel);
+ }
+ return true;
+ }
+ else {
+ return false;
+ }
+
}
-void ChannelListModel::addAll(const QList &list)
+int ChannelListModel::addAll(const QList &list)
{
- if (!list.isEmpty()){
- beginInsertRows(QModelIndex(), channels.size(), channels.size() + list.size() - 1);
- foreach (Channel* channel, list){
- channels.append(new Channel(*channel));
+ // prefilter the list to catch duplicates and update them
+ QList filteredList;
+ filteredList.reserve(list.size());
+
+ for (Channel * channel : list) {
+ if (updateChannelIfExisting(channel)) {
+ qDebug() << "ChannelListModel::addAll got existing channel" << channel->getId() << channel->getName();
+ }
+ else {
+ filteredList.append(channel);
}
+ }
+ if (!filteredList.isEmpty()){
+ int newSize = channels.size() + filteredList.size();
+ channels.reserve(newSize);
+ channelIdIndex.reserve(newSize);
+ beginInsertRows(QModelIndex(), channels.size(), channels.size() + filteredList.size() - 1);
+ for (const Channel* channel : filteredList){
+ addChannelInternal(new Channel(*channel));
+ }
endInsertRows();
}
+
+ return filteredList.length();
}
void ChannelListModel::mergeAll(const QList &list)
@@ -132,27 +193,20 @@
int index = channels.indexOf(channel);
if (index > -1){
beginRemoveRows(QModelIndex(), index, index);
+ auto indexEntry = channelIdIndex.find(channel->getId());
+ if (indexEntry != channelIdIndex.end() && indexEntry.value() == channel) {
+ channelIdIndex.erase(indexEntry);
+ }
delete channels.takeAt(index);
endRemoveRows();
}
}
-Channel *ChannelListModel::find(const QString &q)
-{
- foreach(Channel *channel, channels){
- if (channel->getServiceName() == q){
- return channel;
- }
- }
- return nullptr;
-}
-
Channel *ChannelListModel::find(const quint32 &id)
{
- foreach(Channel *channel, channels){
- if (channel->getId() == id){
- return channel;
- }
+ auto indexEntry = channelIdIndex.find(id);
+ if (indexEntry != channelIdIndex.end()) {
+ return indexEntry.value();
}
return nullptr;
}
@@ -170,6 +224,7 @@
beginRemoveRows(QModelIndex(), 0, channels.size());
qDeleteAll(channels);
channels.clear();
+ channelIdIndex.clear();
endRemoveRows();
}
}
@@ -214,9 +269,13 @@
void ChannelListModel::updateChannel(Channel *item)
{
- if (item && !item->getServiceName().isEmpty()){
+ if (item){
+ if (item->getId() == 0) {
+ qDebug() << "updateChannel with id==0 item";
+ return;
+ }
- if (Channel *channel = find(item->getServiceName())){
+ if (Channel *channel = find(item->getId())){
channel->updateWith(*item);
updateChannelForView(channel);
}
@@ -276,12 +335,15 @@
void ChannelListModel::setAllChannelsOffline()
{
+ int i = 0;
foreach(Channel *channel, channels) {
if (channel->isOnline()) {
channel->setOnline(false);
- updateChannelForView(channel);
+ //updateChannelForView(channel);
+ emit dataChanged(index(i), index(i));
emit channelOnlineStateChanged(channel);
}
+ i++;
}
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/orion-1.5.1+git~20170518/src/model/channellistmodel.h new/orion-1.5.1+git~20170519/src/model/channellistmodel.h
--- old/orion-1.5.1+git~20170518/src/model/channellistmodel.h 2017-05-18 07:55:24.000000000 +0200
+++ new/orion-1.5.1+git~20170519/src/model/channellistmodel.h 2017-05-19 14:24:40.000000000 +0200
@@ -42,11 +42,10 @@
void setAllChannelsOffline();
void addChannel(Channel*);
- void addAll(const QList &);
+ int addAll(const QList &);
void mergeAll(const QList &);
void removeChannel(Channel*);
- Channel* find(const QString&);
Channel* find(const quint32&);
void clearView();
void clear();
@@ -77,7 +76,9 @@
private:
Q_DISABLE_COPY(ChannelListModel)
QList channels;
-
+ QHash channelIdIndex;
+ void addChannelInternal(Channel *);
+ bool updateChannelIfExisting(const Channel *);
};
#endif // CHANNELCOLLECTION_H
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/orion-1.5.1+git~20170518/src/model/channelmanager.cpp new/orion-1.5.1+git~20170519/src/model/channelmanager.cpp
--- old/orion-1.5.1+git~20170518/src/model/channelmanager.cpp 2017-05-18 07:55:24.000000000 +0200
+++ new/orion-1.5.1+git~20170519/src/model/channelmanager.cpp 2017-05-19 14:24:40.000000000 +0200
@@ -498,10 +498,6 @@
}
}
-Channel* ChannelManager::findFavourite(const QString &q){
- return favouritesModel->find(q);
-}
-
void ChannelManager::removeFromFavourites(const quint32 &id){
Channel *chan = favouritesModel->find(id);
@@ -597,14 +593,14 @@
needsStreamCheck = true;
}
- resultsModel->addAll(list);
+ int numAdded = resultsModel->addAll(list);
if (needsStreamCheck)
checkStreams(list);
qDeleteAll(list);
- emit resultsUpdated();
+ emit resultsUpdated(numAdded);
}
void ChannelManager::getFeatured()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/orion-1.5.1+git~20170518/src/model/channelmanager.h new/orion-1.5.1+git~20170519/src/model/channelmanager.h
--- old/orion-1.5.1+git~20170518/src/model/channelmanager.h 2017-05-18 07:55:24.000000000 +0200
+++ new/orion-1.5.1+git~20170519/src/model/channelmanager.h 2017-05-19 14:24:40.000000000 +0200
@@ -132,7 +132,6 @@
void load();
void save();
- Channel *findFavourite(const QString&);
Q_INVOKABLE bool containsFavourite(const quint32&);
void checkStreams(const QList&);
@@ -270,7 +269,7 @@
signals:
void pushNotification(const QString &title, const QString &message, const QString &imgUrl);
- void resultsUpdated();
+ void resultsUpdated(int numAdded);
void featuredUpdated();
void searchingStarted();
void foundPlaybackStream(const QVariantMap &streams);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/orion-1.5.1+git~20170518/src/qml/SearchView.qml new/orion-1.5.1+git~20170519/src/qml/SearchView.qml
--- old/orion-1.5.1+git~20170518/src/qml/SearchView.qml 2017-05-18 07:55:24.000000000 +0200
+++ new/orion-1.5.1+git~20170519/src/qml/SearchView.qml 2017-05-19 14:24:40.000000000 +0200
@@ -61,6 +61,8 @@
Connections {
target: g_cman
onResultsUpdated: {
+ channels.adjustItemCount(numAdded);
+
_spinner.visible = false
_button.visible = true
channels.checkScrolled()
@@ -196,6 +198,14 @@
}
}
+ function adjustItemCount(numAdded) {
+ // we pre-increased itemCount by the expected size of the result but it's possible that
+ // some results were not included due to duplicates filtering
+ if (numAdded !== 25) {
+ itemCount += numAdded - 25;
+ }
+ }
+
onAtYEndChanged: {
if (visible)
checkScrolled()