Exemplo n.º 1
0
void Task::init()
{
  L_FUNC("");

  L_INFO("+++ test Logger");
  L_FATAL("L_FATAL");
  L_ERROR("L_ERROR");
  L_WARN("L_WARN");
  L_INFO("L_INFO");
  L_DEBUG("L_DEBUG");
  L_INFO("--- test Logger");

  L_INFO(QString()); // --> "?"
  L_INFO(" \n Trimmed \n\n"); // --> whitespace removed from start and end
  L_INFO("UTF-8 Unicode text: äöü àéè");

  QString formattedOutput1 = "JSON output 1:\n"
    "{\n"
    "  \"firstName\": \"Mario\",\n"
    "  \"age\": 44\n"
    "}"
  ;
  L_INFO(formattedOutput1);

  QString formattedOutput2 = "{<br>  \"firstName\": \"Mario\",<br>  \"age\": 44<br>}";
  L_INFO(formattedOutput2.prepend("JSON output 2:<br>").replace("<br>", "\n"));

  QTimer::singleShot(1000, this, SLOT(slotRun()));
  QTimer::singleShot(1000, this, SLOT(slotRun()));
  QTimer::singleShot(3000, this, SLOT(slotRun()));
  QTimer::singleShot(6000, this, SLOT(theEnd()));
}
Exemplo n.º 2
0
WorkerThread::WorkerThread(const QString &id, QObject *parent)
  : QThread(parent)
  , _id(id)
{
  L_FUNC(QString("_id='%1'").arg(_id));
  qDebug("WorkerThread::WorkerThread"); // TODO comment this
}
Exemplo n.º 3
0
void Task::slotRun()
{
  L_FUNC("");
  static unsigned int id = 0;

  startWorkerThread(QString("%1").arg(++id, 2, 10, QLatin1Char('0')));
}
Exemplo n.º 4
0
void Task::startWorkerThread(const QString &id)
{
  L_FUNC(QString("id='%1'").arg(id));

  WorkerThread *workerThread = new WorkerThread(id, this);
  connect(workerThread, SIGNAL(resultReady(const QString&)), this, SLOT(slotResultReady(const QString&)));
  connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
  workerThread->start();
}
Exemplo n.º 5
0
void WorkerThread::run()
{
  L_FUNC(QString("_id='%1'").arg(_id));
  qDebug("WorkerThread::run"); // TODO comment this

  msleep(500); // [ms]
  QString result = QString("%1: Calculate: 6! = %2").arg(_id).arg(factorial(6));
  L_INFO(result);
  msleep(250); // [ms]
#if TEST_BURST > 0
  burst(10*1000); // queue full at ~49'000 ?!
#endif
  msleep(250); // [ms]

  emit resultReady(result);
}
Exemplo n.º 6
0
Dialog::Dialog(QWidget *parent)
  : QDialog(parent)
  , ui(new Ui::Dialog)
{
  L_FUNC("");
  // qDebug("Dialog::Dialog");
  ui->setupUi(this);

  EventLog *eventLog = new EventLog(this);
  QObject::connect(eventLog, SIGNAL(eventInfo(const QString&)), this, SLOT(eventInfo(const QString&)), Qt::QueuedConnection); // Qt::QueuedConnection: Qt 5.4.x Debian
  installEventFilter(eventLog);

  L_INFO("+++ test Logger");
  L_FATAL("L_FATAL");
  L_ERROR("L_ERROR");
  L_WARN("L_WARN");
  L_NOTE("L_NOTE");
  L_INFO("L_INFO");
  L_DEBUG("L_DEBUG");
  L_INFO("--- test Logger");

  L_NOTE("Start");
}
Exemplo n.º 7
0
void Task::theEnd()
{
  L_FUNC("");
  L_INFO("Bye bye");
  emit finished();
}
Exemplo n.º 8
0
Task::~Task()
{
  L_FUNC("");
  qDebug("Task::~Task"); // TODO comment this
}
Exemplo n.º 9
0
Task::Task(QObject *parent)
  : QObject(parent)
{
  L_FUNC("");
  qDebug("Task::Task"); // TODO comment this
}
Exemplo n.º 10
0
WorkerThread::~WorkerThread()
{
  L_FUNC(QString("_id='%1'").arg(_id));
  qDebug("WorkerThread::~WorkerThread"); // TODO comment this
}
Exemplo n.º 11
0
void Dialog::on_pushButtonQuit_clicked()
{
  L_FUNC("");
  L_NOTE("Bye bye");
  close();
}
Exemplo n.º 12
0
void Dialog::on_pushButtonAboutQt_clicked()
{
  L_FUNC("");
  QMessageBox::aboutQt(this);
}
Exemplo n.º 13
0
Dialog::~Dialog()
{
  L_FUNC("");
  // qDebug("Dialog::~Dialog");
  delete ui;
}