Inform about updates
This commit is contained in:
		
							parent
							
								
									493262876f
								
							
						
					
					
						commit
						3847c8d61b
					
				@ -51,6 +51,10 @@ Manager::Manager()
 | 
			
		||||
                   tray_.get(), [this] {
 | 
			
		||||
                     tray_->showInformation(QObject::tr("Update completed"));
 | 
			
		||||
                   });
 | 
			
		||||
  QObject::connect(updater_.get(), &update::Loader::updatesAvailable,  //
 | 
			
		||||
                   tray_.get(), [this] {
 | 
			
		||||
                     tray_->showInformation(QObject::tr("Updates available"));
 | 
			
		||||
                   });
 | 
			
		||||
#ifdef DEVELOP
 | 
			
		||||
  updater_->checkForUpdates();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -133,6 +133,8 @@ void Loader::handleReply(QNetworkReply *reply)
 | 
			
		||||
  if (isUpdatesReply) {
 | 
			
		||||
    SOFT_ASSERT(model_, return );
 | 
			
		||||
    model_->parse(replyData);
 | 
			
		||||
    if (model_->hasUpdates())
 | 
			
		||||
      emit updatesAvailable();
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -309,6 +311,22 @@ void Model::updateStates()
 | 
			
		||||
  emitColumnsChanged(QModelIndex());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Model::hasUpdates() const
 | 
			
		||||
{
 | 
			
		||||
  if (!root_)
 | 
			
		||||
    return false;
 | 
			
		||||
  return hasUpdates(*root_);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Model::hasUpdates(const Model::Component &component) const
 | 
			
		||||
{
 | 
			
		||||
  for (const auto &i : component.children) {
 | 
			
		||||
    if (i->state == State::UpdateAvailable || hasUpdates(*i))
 | 
			
		||||
      return true;
 | 
			
		||||
  }
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Model::updateState(Model::Component &component)
 | 
			
		||||
{
 | 
			
		||||
  if (!component.files.empty()) {
 | 
			
		||||
 | 
			
		||||
@ -47,6 +47,7 @@ public:
 | 
			
		||||
  void setExpansions(const std::map<QString, QString>& expansions);
 | 
			
		||||
  UserActions userActions() const;
 | 
			
		||||
  void updateStates();
 | 
			
		||||
  bool hasUpdates() const;
 | 
			
		||||
 | 
			
		||||
  QModelIndex index(int row, int column,
 | 
			
		||||
                    const QModelIndex& parent) const override;
 | 
			
		||||
@ -74,6 +75,7 @@ private:
 | 
			
		||||
 | 
			
		||||
  std::unique_ptr<Component> parse(const QJsonObject& json) const;
 | 
			
		||||
  void updateState(Component& component);
 | 
			
		||||
  bool hasUpdates(const Component& component) const;
 | 
			
		||||
  void fillUserActions(UserActions& actions, Component& component) const;
 | 
			
		||||
  State currentState(const File& file) const;
 | 
			
		||||
  QString expanded(const QString& source) const;
 | 
			
		||||
@ -108,6 +110,7 @@ public:
 | 
			
		||||
  Model* model() const;
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
  void updatesAvailable();
 | 
			
		||||
  void updated();
 | 
			
		||||
  void error(const QString& error);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user