コード例 #1
0
ファイル: DataManager.cpp プロジェクト: raphaelrpl/terrama2
void terrama2::services::alert::core::DataManager::removeJSon(const QJsonObject& obj)
{
  try
  {
    auto alerts = obj["Alerts"].toArray();
    for(auto json : alerts)
    {
      auto dataId = json.toInt();
      removeAlert(dataId);
    }

    terrama2::core::DataManager::DataManager::removeJSon(obj);
  }
  catch(const terrama2::Exception& /*e*/)
  {
    // loggend on throw...
  }
  catch(boost::exception& e)
  {
    TERRAMA2_LOG_ERROR() << boost::diagnostic_information(e);
  }
  catch(std::exception& e)
  {
    TERRAMA2_LOG_ERROR() << e.what();
  }
  catch(...)
  {
    TERRAMA2_LOG_ERROR() << QObject::tr("Unknown error...");
  }
}
コード例 #2
0
ファイル: QtChatWindow.cpp プロジェクト: jyhong836/swift
void QtChatWindow::beginCorrection() {
	boost::optional<AlertID> newCorrectingAlert;
	if (correctionEnabled_ == Maybe) {
		newCorrectingAlert = addAlert(Q2PSTRING(tr("This chat may not support message correction. If you send a correction anyway, it may appear as a duplicate message")));
	}
	else if (correctionEnabled_ == No) {
		newCorrectingAlert = addAlert(Q2PSTRING(tr("This chat does not support message correction.  If you send a correction anyway, it will appear as a duplicate message")));
	}

	if (newCorrectingAlert) {
		if (correctingAlert_) {
			removeAlert(*correctingAlert_);
		}
		correctingAlert_ = newCorrectingAlert;
	}

	QTextCursor cursor = input_->textCursor();
	cursor.select(QTextCursor::Document);
	cursor.beginEditBlock();
	cursor.insertText(QString(lastSentMessage_));
	cursor.endEditBlock();
	isCorrection_ = true;
	correctingLabel_->show();
	input_->setStyleSheet(alertStyleSheet_);
	labelsWidget_->setEnabled(false);
}
コード例 #3
0
ファイル: QtChatWindow.cpp プロジェクト: jyhong836/swift
void QtChatWindow::handleAlertButtonClicked() {
	const QObject* alertWidget = QObject::sender()->parent();
	std::map<AlertID, QWidget*>::const_iterator i = alertWidgets_.begin();
	for ( ; i != alertWidgets_.end(); ++i) {
		if (i->second == alertWidget) {
			removeAlert(i->first);
			break;
		}
	}
}
コード例 #4
0
ファイル: DataManager.cpp プロジェクト: raphaelrpl/terrama2
void terrama2::services::alert::core::DataManager::update(terrama2::services::alert::core::AlertPtr alert)
{
  {
    std::lock_guard<std::recursive_mutex> lock(mtx_);
    blockSignals(true);
    removeAlert(alert->id);
    add(alert);
    blockSignals(false);
  }

  emit alertUpdated(alert);
}
コード例 #5
0
ファイル: QtChatWindow.cpp プロジェクト: jyhong836/swift
void QtChatWindow::cancelCorrection() {
	if (correctingAlert_) {
		removeAlert(*correctingAlert_);
		correctingAlert_.reset();
	}
	QTextCursor cursor = input_->textCursor();
	cursor.select(QTextCursor::Document);
	cursor.removeSelectedText();
	isCorrection_ = false;
	correctingLabel_->hide();
	input_->setStyleSheet(qApp->styleSheet());
	labelsWidget_->setEnabled(true);
}
コード例 #6
0
void ArpListener::waitForResponse(const std::string &ip, const timespec &timeout)
{
  MutexLocker lock( alertMutex_ );
  if(!( cache_->lookup(ip) == MACAddress( std::vector< uint8_t  >( 6, 0 ) ) ) )
    return; //there is a mac in the cache
  setAlert(ip);
  std::map< std::string, std::pair< Semaphore*, Condition* > >::iterator itr = alerts_.lower_bound(ip);

  if( itr != alerts_.end() && !(alerts_.key_comp()(ip, itr->first) ) )
  { //exist
    itr->second.second->timeWait(alertMutex_, timeout );
  }
  removeAlert(ip);
  //else the alert either already happend or didn't exists
}