void QgsNetworkContentFetcher::fetchContent( const QNetworkRequest &request )
{
  mContentLoaded = false;
  mIsCanceled = false;

  if ( mReply )
  {
    //cancel any in progress requests
    mReply->abort();
    mReply->deleteLater();
    mReply = nullptr;
  }

  mReply = QgsNetworkAccessManager::instance()->get( request );
  connect( mReply, &QNetworkReply::finished, this, [ = ] { contentLoaded(); } );
  connect( mReply, &QNetworkReply::downloadProgress, this, &QgsNetworkContentFetcher::downloadProgress );
}
void QgsNetworkContentFetcher::fetchContent( const QUrl &url )
{
  mContentLoaded = false;

  //get contents
  QNetworkRequest request( url );

  if ( mReply )
  {
    //cancel any in progress requests
    mReply->abort();
    mReply->deleteLater();
    mReply = nullptr;
  }

  mReply = QgsNetworkAccessManager::instance()->get( request );
  connect( mReply, &QNetworkReply::finished, this, [ = ] { contentLoaded(); } );
}
void QgsNetworkContentFetcher::fetchContent( const QUrl url )
{
  QUrl nextUrlToFetch = url;
  mContentLoaded = false;

  //get contents
  QNetworkRequest request( nextUrlToFetch );

  if ( mReply )
  {
    //cancel any in progress requests
    mReply->abort();
    mReply->deleteLater();
    mReply = 0;
  }

  mReply = QgsNetworkAccessManager::instance()->get( request );
  connect( mReply, SIGNAL( finished() ), this, SLOT( contentLoaded() ) );
}
//=============================================================================
// Load the detail communication information of the person.
//=============================================================================
void CCommunication::loadData (QString id, bool readonly)
{
  QString 			DBnull = "?", tip;
  unsigned int      row = 0;
  
  //----------------------------------------------------------------------------
  // Disconnect the slots during data load.
  //----------------------------------------------------------------------------
  removeAllLines();
  slotAddLine();
  disconnectSlots();

  //----------------------------------------------------------------------------
  // Load the communication types.
  //----------------------------------------------------------------------------
  QSqlQuery query ("SELECT comm_id, type, number, created, last_modified "
                   "FROM   contacts_communications "
                   "WHERE  person_id = " + id + " ORDER BY type");

  if (!query.isActive())
  {
    SHOW_DB_ERROR(tr ("Error during database query"), query);
    return;
  }

  while (query.next())
  {
    if (row >= mLine.count())
    {
      slotAddLine();
      disconnectSlots();
    }
    
    mIDs << query.value(0).toString();
    mLine.at(row)->setID      (query.value(0).toString());
    mLine.at(row)->setType    (query.value(1).toInt());
    mLine.at(row)->setValue   (query.value(2).toString());
    mLine.at(row)->setToolTip (tr ("Created:\t\t\t") + 
                               formatDateTime (query.value(3).toString()) +
                               tr ("\nLast Modified:\t\t") + 
                               formatDateTime (query.value(4).toString()));
    mLine.at(row)->setChanged (false);
    
    row++;
  } 
  
  //----------------------------------------------------------------------------
  // Store the ID of the currently loaded person.
  //----------------------------------------------------------------------------
  mCurrent  = id;
  mReadonly = readonly;

  //----------------------------------------------------------------------------
  // Connect the slots after data load is complete.
  //----------------------------------------------------------------------------
  connectSlots();
  setReadonly (readonly);
  
  emit contentLoaded  (true);
  emit contentChanged (false);
}