Example #1
0
void MainWindow::Time()
{




            QDate date = QDate::currentDate();
            QString dateString = date.toString();



            QTime time = QTime::currentTime();
            QString timeString = time.toString();

            ui->statusBar->showMessage(dateString + " " + timeString + ", " + "Gotowy do Pracy");


}
Example #2
0
QString CueSheetModel::indexToString(const double index) const
{
	if(!_finite(index) || (index < 0.0) || (index > 86400.0))
	{
		return QString("??:??.???");
	}
	
	QTime time = QTime().addMSecs(static_cast<int>(floor(0.5 + (index * 1000.0))));

	if(time.minute() < 100)
	{
		return time.toString("mm:ss.zzz");
	}
	else
	{
		return QString("99:99.999");
	}
}
Example #3
0
void LoginDialog::qtimeSlot()
{
    QTime qtimeObj = QTime::currentTime();

    QString strTime = qtimeObj.toString("hh:mm:ss");
    strTime.prepend("时间:");
    QDate qdateObj = QDate::currentDate();
    QString strDate = qdateObj.toString("yyyy年M月d日 dddd  "); //星期、月份、天、年
    strDate.prepend("今天是:");

    strDate.append(strTime);
    ui->timeLabel->setText (strDate);

    //qDebug() << strTime;
    //qDebug() << strDate;


}
void Widget::pressedSend()
{
    if(ui->lineEdit->text() != "")
    {
        QString text, temp;
        QTime time;
        text = ui->lineEdit->text();
        ui->lineEdit->clear();
        time = time.currentTime();
        temp = time.toString("HH:mm:ss") + ":  " + text;
        temp.push_front("<b>");
        temp.append("</b>");
        ui->textBrowser->append(temp);

        // Send the message to all threads
        emit message(temp);
    }
}
Example #5
0
int FenetreProgression::copyDirIm()
{
	m_progressBar->setValue(5);
	
    // Creation de la copie du dossier
	CDirCopy copy;
	
	m_progressBar->setValue(10);
	
	// recuperation de l'heure toussa
	QTime curTime = QTime::currentTime();
	QString strCurTime = curTime.toString("hhmmss");
	
	m_progressBar->setValue(15);
	
	// SetSource
	copy.setSource(m_source);
	
	m_progressBar->setValue(20);
	
	// setTarget
	if (m_logiciel == "Thunderbird")
		copy.setTarget(QDir::homePath() + "/Application Data/Thunderbird/Profiles");
    else if(m_logiciel == "Outlook Express")
        copy.setTarget(QDir::homePath() + "/Local Settings/Application Data/Identities");
	else if(m_logiciel == "Outlook Express")
        copy.setTarget(QDir::homePath() + "/Local Settings/Application Data/Microsoft/Outlook");
	
	m_progressBar->setValue(30);
	
	// lancement de la copie
	if (m_logiciel == "Thunderbird" || m_logiciel == "Outlook Express")
		copy.launch();
	else 
		copy.launch2007();
	
	m_progressBar->setValue(100);

	QMessageBox::information(this, "Copie...", "La copie est terminee, vous retrouverez votre messagerie comme à l'époque de la sauvegarde");

	m_bouton->setEnabled(true);
	
	return true;
}
Example #6
0
void Receive :: ReceiveSlot(int ID,int DLC,QString DATA,QTime time)
{
    k++;
    RecClearButton->setEnabled(true);
    RecSaveButton->setEnabled(true);

    RecTab->insertRow(0);
    RecTab->setRowHeight(0,15);
    QString text;

    int count=RecTab->rowCount();
    if(count>MAX_TABLE_SIZE)
    {
       RecTab->removeRow(count-1);
    }
    
    text=time.toString("hh:mm:ss.zzz");

    QTableWidgetItem *T_Item1 = new QTableWidgetItem;
    T_Item1->setText(text);
    RecTab->setItem(0,0,T_Item1);
    RecTab->item(0,0)->setTextAlignment(Qt::AlignCenter);

    text = QVariant(ID).toString();
    QTableWidgetItem *T_Item2 = new QTableWidgetItem;
    T_Item2->setText(text);
    RecTab->setItem(0,1,T_Item2);
    RecTab->item(0,1)->setTextAlignment(Qt::AlignCenter);

    text = QVariant(DLC).toString();
    QTableWidgetItem *T_Item3 = new QTableWidgetItem
            (QString::fromLocal8Bit(""));
    T_Item3->setText(text);
    RecTab->setItem(0,2,T_Item3);
    RecTab->item(0,2)->setTextAlignment(Qt::AlignCenter);

    QTableWidgetItem *T_Item4 = new QTableWidgetItem
            (QString::fromLocal8Bit(""));

    T_Item4->setText(DATA);
    RecTab->setItem(0,3,T_Item4);
    RecTab->item(0,3)->setTextAlignment(Qt::AlignCenter);

}
Example #7
0
void cutterDialog::on_pushButtonStop_clicked()
{if (mp) 
    {ui->lineEditStop->setText(mp->tcurpos().toString());
        stopPos=mp->curpos();
        QTime t;
        t = t.addSecs(stopPos-startPos);
        ui->lineEditLen->setText( t.toString());
    }

    if(stopPos-startPos>0)
    {
        ui->pushButtonStart->setEnabled(false);
        ui->pushButtonStop->setEnabled(false);
        ui->pushButtonCut->setEnabled(true);
        ui->pushButtonpre->setEnabled(true);
    }


}
Example #8
0
static void DbgHelper_output(int color, int indent,
                             const QString &prefix, const QString &funcName) {
  QString text = QString(4*indent, QLatin1Char(' ')) + QString(prefix + QLatin1Char(' ') + funcName);
  if (color >= 0)
  {
    text.prepend(QLatin1String("\x1b[3") + QString::number(1 + color) + QStringLiteral("m"));
//    QString colorNum = QString::number(1 + color);
//    text.prepend(QLatin1String("\x1b[3") + colorNum + QStringLiteral("m;3") + colorNum + QStringLiteral(";3") + colorNum + QStringLiteral("m"));
    text.append(QLatin1String("\x1b[39m"));
  }

  QTime currTime = QTime::currentTime();

#ifndef DBGHELPER_USES_PRINTF
  qDebug() << currTime.toString(QStringLiteral("hh:mm:ss:zzz")) << " " << text;
#else
  fprintf(stderr, "%s\n", qPrintable(text));
#endif
}
Example #9
0
/// formats an amount of milliseconds to be displayed on the ui
static QString formatLabelTime(qint64 milliseconds)
{
    const qint64 one_hour = 1000 * 60 * 60;

    QString format;
    if (milliseconds >= one_hour)
    {
        format = "H:mm:ss";
    }
    else
    {
        format = "m:ss";
    }

    QTime timeValue(0, 0);
    QTime resultTime = timeValue.addMSecs(milliseconds);
    QString result = resultTime.toString(format);
    return result;
}
Example #10
0
void RPCConsole::message(int category, const QString &message, bool html)
{
    QTime time = QTime::currentTime();
    QString timeString = time.toString();
    QString out;
    out += "<table><tr><td class=\"time\" width=\"65\">" + timeString + "</td>";
    out += "<td class=\"icon\" width=\"32\"><img src=\"" + categoryClass(category) + "\"></td>";
    out += "<td class=\"message " + categoryClass(category) + "\" valign=\"middle\">";
    if (html)
    {
        out += message;
    }
    else
    {
        out += GUIUtil::HtmlEscape(message, true);
    }
    out += "</td></tr></table>";
    ui->messagesWidget->append(out);
}
Example #11
0
/**
 * @brief VolumetricHelicoidWidget::saveParameters
 */
void VolumetricHelicoidWidget::saveParameters()
{
    QString filename = QFileDialog::getSaveFileName(this,"Save parameter file",QDir::currentPath());
    ofstream outputfile;
    try
    {
        outputfile.open(filename.toStdString().c_str());
    }
    catch ( std::exception &e )
    {
        QMessageBox::warning(this,"Warning I/O error!",e.what());
        return;
    }

    QDate date = QDate::currentDate();
    QTime time = QTime::currentTime();
    QString timeString = time.toString();

    outputfile << "# Parameters experiment " << date.toString("dd.MM.yyyy").toStdString() << " - " << timeString.toStdString() << endl;
    outputfile << "# Mesh Parameters" << endl;
    outputfile << "MeshRadius: " << volume->meshStruct.radius << endl;
    outputfile << "MeshHeight: " << volume->meshStruct.height << endl;
    outputfile << "MeshRotation: " << volume->meshStruct.rotationAngle << endl;
    outputfile << "MeshThickness: " << volume->meshStruct.thickness << endl;
    outputfile << "MeshOffsetX: " << volume->meshStruct.offsetX << endl;
    outputfile << "MeshOffsetY: " << volume->meshStruct.offsetY << endl;
    outputfile << "MeshOffsetZ: " << volume->meshStruct.offsetZ << endl;
    outputfile << "MeshCenterX: " << volume->meshStruct.x << endl;
    outputfile << "MeshCenterY: " << volume->meshStruct.y << endl;
    outputfile << "MeshCenterZ: " << volume->meshStruct.z << endl;
    outputfile << "TextureSizeX: " << volume->getTextureSizeX() << endl;
    outputfile << "TextureSizeY: " << volume->getTextureSizeY() << endl;
    outputfile << "TextureSizeZ: " << volume->getTextureSizeZ() << endl;
    outputfile << "NSpheres: " << volume->getNSpheres() << endl;
    outputfile << "SphereRadiusMin: " << volume->getSphereRadiusMin() << endl;
    outputfile << "SphereRadiusMax: " << volume->getSphereRadiusMax() << endl;
    outputfile << "# Camera Parameters" << endl;
    outputfile << "EyeZ: " << this->eyeZ << endl;
    outputfile << "FOV: " << this->FOV << endl;
    outputfile << "zNear: " << this->zNear << endl;
    outputfile << "zFar: " << this->zFar << endl;

}
Example #12
0
ClipProperty::ClipProperty( Clip* clip, QWidget *parent ) :
    QDialog( parent ),
    ui( new Ui::ClipProperty ),
    m_clip( clip )
{
    QTime   duration;
    duration = duration.addSecs( m_clip->lengthSecond() );

    ui->setupUi(this);
    connect( this, SIGNAL( accepted() ), this, SLOT( deleteLater() ) );
    connect( this, SIGNAL( rejected() ), this, SLOT( deleteLater() ) );
    //Duration
    ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) );
    //Filename || title
    ui->nameValueLabel->setText( m_clip->getParent()->fileInfo()->fileName() );
    setWindowTitle( m_clip->getParent()->fileInfo()->fileName() + " " + tr( "properties" ) );
    //Resolution
    ui->resolutionValueLabel->setText( QString::number( m_clip->getParent()->width() )
                                       + " x " + QString::number( m_clip->getParent()->height() ) );
    //FPS
    ui->fpsValueLabel->setText( QString::number( m_clip->getParent()->fps() ) );
    //Snapshot
    ui->snapshotLabel->setPixmap( m_clip->getParent()->snapshot().scaled( 128, 128, Qt::KeepAspectRatio ) );
    //nb tracks :
    ui->nbVideoTracksValueLabel->setText(
            QString::number( m_clip->getParent()->nbVideoTracks() ) );
    ui->nbAudioTracksValueLabel->setText(
            QString::number( m_clip->getParent()->nbAudioTracks() ) );
    //Metatags
    const QPushButton* button = ui->buttonBox->button( QDialogButtonBox::Apply );
    Q_ASSERT( button != NULL);
    connect( button, SIGNAL( clicked() ), this, SLOT( apply() ) );

    m_model = new QStringListModel( m_clip->metaTags(), this );
    ui->metaTagsView->setModel( m_model );

    //Notes:
    ui->annotationInput->setPlainText( m_clip->notes() );

    connect( ui->addTagsButton, SIGNAL( clicked() ), this, SLOT( addTagsRequired() ) );
    connect( ui->deleteTagsButton, SIGNAL( clicked() ), this, SLOT( removeTagsRequired() ) );
}
Example #13
0
void TSLogging::Error(QString message, uint64 serverConnectionHandlerID, unsigned int error, bool isSoundSilent)
{

    if (error != NULL)
    {
        char* errorMsg;
        if(ts3Functions.getErrorMessage(error, &errorMsg) == ERROR_ok)
        {
            QTextStream(&message) << ": " << errorMsg;
            ts3Functions.freeMemory(errorMsg);
        }
    }

    Log(message,serverConnectionHandlerID,LogLevel_ERROR);
    if (!isSoundSilent)
        PlayErrorSound(serverConnectionHandlerID);

    // Format and print the error message
    if ((serverConnectionHandlerID == NULL) || (serverConnectionHandlerID == 0))
        serverConnectionHandlerID = ts3Functions.getCurrentServerConnectionHandlerID();
    if ((serverConnectionHandlerID == NULL) || (serverConnectionHandlerID == 0))
        return;

    // Use a transparent underscore because a double space will be collapsed
    QString styledQstr;

    QString infoIcon;
    if (!(GetInfoIcon(infoIcon)))
    {
        //Get Error
        QString msg = "TSLogging::Error:GetInfoIcon:" + TSSettings::instance()->GetLastError().text();
        ts3Functions.logMessage(msg.toLocal8Bit().constData(), LogLevel_ERROR, ts3plugin_name(), 0);
    }
    else
        QTextStream(&styledQstr) << "[img]" << infoIcon << "[/img]";

    QTime time = QTime::currentTime ();
    QString time_qstr = time.toString(Qt::TextDate);

    QTextStream(&styledQstr) << "[color=red]" << time_qstr << "[/color][color=transparent]_[/color]" << ": "  << ts3plugin_name() << ": " << message;
    ts3Functions.printMessage(serverConnectionHandlerID, styledQstr.toLocal8Bit().constData(), PLUGIN_MESSAGE_TARGET_SERVER);
}
Example #14
0
void DigitalClock::showTime()
{
	QTime time = QTime::currentTime();	
//	QDateTime time = QDateTime::currentDateTime();
//	QString text = time.toString("hh:mm");
	QString text = time.toString("mm:ss");
//	QString text = time.toString("hh:mm:ss");

//	QMessageBox bm;
//	bm.setText(text);
//	bm.show();

//	if ((time.second() % 2) == 0) {
//		text[2] = ' ';
//		text[5] = ' ';
//	}

	display(text);

}
Example #15
0
void CCustomTreeView::mouseReleaseEvent(QMouseEvent *event)
{
    LOG_MODEL_DEBUG("Roster", "CTreeUserList::mouseReleaseEvent");
#ifdef ANDROID
    //模拟右键菜单  
    QTime cur = QTime::currentTime();
    int sec = m_MousePressTime.secsTo(cur);
    LOG_MODEL_DEBUG("Roster", "m_MousePressTime:%s;currentTime:%s;sect:%d",
                    qPrintable(m_MousePressTime.toString("hh:mm:ss.zzz")),
                    qPrintable(cur.toString("hh:mm:ss.zzz")),
                    sec);
    if(sec >= 2)
    {
        emit customContextMenuRequested(QCursor::pos());
        return;
    }
#endif

    QTreeView::mouseReleaseEvent(event);
}
Example #16
0
void ChessClock::setTime(int totalTime)
{
	if (m_infiniteTime)
		return;

	QTime timeLeft = QTime(0, 0).addMSecs(abs(totalTime + 500));

	QString format;
	if (timeLeft.hour() > 0)
		format = "hh:mm:ss";
	else
		format = "mm:ss";

	QString str;
	if (totalTime <= -500)
		str.append("-");
	str.append(timeLeft.toString(format));

	m_timeLabel->setText(QString("<h1>%1</h1>").arg(str));
}
void IncidenceIO::setStartDateTime(const QDate startDateVal, const QTime startTimeVal, QString tzName)
{
    qDebug()<<"Inside IncidenceIO::setStartDateTime, startDateVal="<<startDateVal.toString("dd MMM yyyy");

    qDebug()<<"Inside IncidenceIO::setStartDateTime, startTimeVal="<<startTimeVal.toString("hh:mm");

    if(tzName.isNull()||tzName.isEmpty()) {
        //KDateTime::Spec tzSpec(KDateTime::LocalZone);
        //this->setStartDateTime(KDateTime(startDateVal,startTimeVal,tzSpec));
        KDateTime::Spec tzSpec(KSystemTimeZones::local());
        this->setStartDateTime(KDateTime(startDateVal,startTimeVal,tzSpec));
    } else {
        //KDateTime::Spec tzSpec(KDateTime::LocalZone,gmtOffset);
        //this->setStartDateTime(KDateTime(startDateVal,startTimeVal,tzSpec));
        KDateTime::Spec tzSpec(KSystemTimeZones::zone(tzName));
        this->setStartDateTime(KDateTime(startDateVal,startTimeVal,tzSpec));
    }

    qDebug()<<"*****************Inside overloaded setStartDateTime startDateTime="<<startDateTime.toString()<<"\n";
}
Example #18
0
LogClass::LogClass()
{
	m_userLog = new QFile;
	m_engLog = new QFile;
	// copies the file into a text string
	m_userLog->setFileName(PATH_USER_LOG);
	m_engLog->setFileName(PATH_ENG_LOG);
	// check if it exists, create otherwise
	m_userLog->open(QIODevice::Append | QIODevice::Text);
	QTextStream temp_userLogStream(m_userLog);
	temp_userLogStream << "\nSystem Reboot...\n";
	m_userLog->close();
	m_engLog->open(QIODevice::Append | QIODevice::Text);
	QTextStream temp_engLogStream(m_engLog);
	QTime time = QTime::currentTime();
	QDate date = QDate::currentDate();
	temp_engLogStream << "\nSyetem Reboot at " << time.toString() 
		<< ' ' << date.toString() << " (system time)\n";
	m_engLog->close();
}
Example #19
0
void dateTimeTests::test_toString()
{
    dateTime test;
    QDate d = QDate::currentDate();
    QTime t = QTime::currentTime();

    QString cmp;
    cmp=d.toString("dd:MM:yyyy");
    cmp.append(" ");
    cmp.append(t.toString("hh:mm:ss"));

    //test null
    QString tmp = "";
    QCOMPARE(test.toString(),tmp);

    //test proper gettime
    test.setDateTime(dateTime(d,t));
    QCOMPARE(test.toString() == cmp, false);   //this is weird, even though they look the
                                               //same, this test fails.
}
Example #20
0
void VoiceRecorderDialog::on_qtTimer_timeout() {
	if (!g.sh) {
		reset();
		return;
	}

	if (!g.uiSession) {
		reset(false);
		return;
	}

	VoiceRecorderPtr recorder(g.sh->recorder);
	if (!g.sh->recorder) {
		reset();
		return;
	}

	const QTime elapsedTime = QTime(0,0).addMSecs(static_cast<int>(recorder->getElapsedTime() / 1000));
	qlTime->setText(elapsedTime.toString());
}
Example #21
0
void Logic::convertToPDF(const QString &pathToFile, const QString &pdfFileName,
                         bool isPortrait) const
{
    QString mFileName{};
    if (pdfFileName.isEmpty()) {
        QDate date = QDate::currentDate();
        QTime time = QTime::currentTime();
        mFileName = "unnamed_scan_created_" + date.toString("dd-MM-yyyy") +
                    "_" + time.toString("hh:mm:ss") + ".pdf";
    } else {
        mFileName.append(pdfFileName);
        if (!mFileName.endsWith(".pdf")) {
            mFileName.append(".pdf");
        }
    }

    QPixmap pixmap(pathToFile);

    if (isPortrait) {
        QTransform transform;
        QTransform trans = transform.rotate(90);
        pixmap = pixmap.transformed(trans);
    }
    QPdfWriter writer(mFileName);
    // writer.setPageSize(QPagedPaintDevice::A4);
    QPainter painter(&writer);
    painter.drawPixmap(
        QRect(0, 0, writer.logicalDpiX() * 8, writer.logicalDpiY() * 11),
        pixmap);
    painter.end();
    QString newPdfFileName =
        QStandardPaths::displayName(QStandardPaths::DocumentsLocation) + "/" +
        QFileInfo(mFileName).fileName();
    QFile file(mFileName);
    try { file.rename(newPdfFileName); }
    catch (const std::exception &e)
    {
        qWarning("Unable to rename file %s\n%s", qPrintable(mFileName),
                 qPrintable(e.what()));
    }
}
Example #22
0
void PlayerWidget::_updateSourceInitialization()
{
	if ( audioSource_ )
	{
		// enable/disable initialization-dependent controls
		ui_.sliderCurrentSampleOffset->setEnabled( audioSource_->isInitialized() );
	}

	if ( !audioSource_ || !audioSource_->isInitialized() )
	{
		QFontMetrics fontMetrics( ui_.labelTimeCurrent->font() );
		const QString longestTimeString = QTime( 11, 11, 11 ).toString( TimeHourFormat );
		const int minimumSize = fontMetrics.width( longestTimeString );

		ui_.labelTimeCurrent->setFixedWidth( minimumSize );
		ui_.labelTimeTotal->setFixedWidth( minimumSize );

		ui_.labelTimeCurrent->setText( QTime( 0, 0, 0 ).toString( TimeHourFormat ) );
		ui_.labelTimeTotal->setText( QTime( 0, 0, 0 ).toString( TimeHourFormat ) );
	}
	else
	{
		const qint64 totalSamples = playerInfo_->audioSource->totalSamples();
		const float frequency = playerInfo_->audioSource->frequency();

		const QTime totalTime = totalSamples == -1 ? QTime( 11, 11, 11 ) : _samplesToTime( totalSamples, frequency );
		const QString format = _minimalFormatForTime( totalTime );

		QFontMetrics fontMetrics( ui_.labelTimeCurrent->font() );
		const QString longestTimeString = totalTime.toString( format );
		const int minimumSize = fontMetrics.width( longestTimeString );

		ui_.labelTimeCurrent->setFixedWidth( minimumSize );
		ui_.labelTimeTotal->setFixedWidth( minimumSize );

		ui_.sliderCurrentSampleOffset->setEnabled( !playerInfo_->audioSource->isSequential() );
	}

	_updateTrackInfoLabels();
	_updateCurrentSampleOffset();
}
Example #23
0
void VlcWidgetSeek::updateFullTime(const int &time)
{
    if (_lock)
        return;

    QTime fullTime = QTime(0,0,0,0).addMSecs(time);

    QString display = "mm:ss";
    if (fullTime.hour() > 0)
        display = "hh:mm:ss";

    _labelFull->setText(fullTime.toString(display));

    if (!time) {
        _seek->setMaximum(1);
        setVisible(!_autoHide);
    } else {
        _seek->setMaximum(time);
        setVisible(true);
    }
}
Example #24
0
/*! Sets internal time to \e time. */
void TimeComboBox::setTime(const QTime &time)
{
    if (d->time == time)
        return;

    const int index = d->combo->findData(time);
    if (index == -1) {
        // custom time, not found in combo items

        // QTime() is not the same as QTime(0,0)!!
        d->time = time.isNull()? QTime(0, 0) : time;
        d->combo->setEditText(time.toString(QLocale::system().timeFormat(QLocale::ShortFormat)));
        qDebug() << "setEditText" << time;
    } else {
        // given time is one of the combo items
        d->combo->setCurrentIndex(index);
        qDebug() << "setCurrentIndex" << index << d->combo->itemData(index);
    }
    Q_EMIT timeChanged(d->time);
    Q_EMIT dateTimeChanged(QDateTime(QDate(), d->time));
}
Example #25
0
void EventView::slotDeleteEvent()
{
    const TaskTreeItem& taskTreeItem =
        MODEL.charmDataModel()->taskTreeItem( m_event.taskId() );
    const QString name = MODEL.charmDataModel()->fullTaskName( taskTreeItem.task() );
    const QDate date = m_event.startDateTime().date();
    const QTime time = m_event.startDateTime().time();
    const QString dateAndDuration = date.toString( Qt::SystemLocaleDate )
           + ' ' + time.toString( Qt::SystemLocaleDate )
           + ' ' + hoursAndMinutes( m_event.duration() );
    const QString eventDescription = name + ' ' + dateAndDuration;
    if ( MessageBox::question(
             this, tr( "Delete Event?" ),
             tr( "<html>Do you really want to delete the event <b>%1</b>?" ).arg(eventDescription),
             tr( "Delete" ), tr("Cancel") )
         == QMessageBox::Yes ) {
        CommandDeleteEvent* command = new CommandDeleteEvent( m_event, this );
        command->prepare();
        stageCommand( command );
    }
}
Example #26
0
void Client::slotReadyRead() {
    QDataStream in(socket);
    in.setVersion(QDataStream::Qt_5_7);
    for (;;) {
        if (!blockSize) {
            if(socket->bytesAvailable() < sizeof(quint16)) {
                break;
            }
            in >> blockSize;
        }
        if (socket->bytesAvailable() < blockSize) {
            break;
        }
        QTime time;
        QString str;
        in >> time >> str;

        info->append(time.toString() + " " + str);
        blockSize = 0;
    }
}
Example #27
0
void Save::save()
{
	if (img == 0 || img->isNull())
		return;
	QString file = QFileDialog::getSaveFileName(this, "Save image to...", QString(),
						    "PNG image (*.png);;BMP image (*.bmp)");
	if (file.isEmpty())
		return;
	QTime tStart = QTime::currentTime();
	if (!img->save(file)) {
		lwProgess->addItem(tr("Save to image failed!"));
		return;
	}
	QTime tEnd = QTime::currentTime();
	lwProgess->addItem(tr("Image saving finished at %1.").arg(tEnd.toString("hh:mm:ss")));
	lwProgess->addItem(tr("Time elapsed: %1.%2s.").arg(tStart.secsTo(tEnd)).arg(tStart.msecsTo(tEnd) % 1000));
	delete img;
	img = 0;
	lwProgess->addItem(tr("Image memory freed."));
	lwProgess->scrollToBottom();
}
QString Device::entryAsString(void *e) const
{
    const log_entry *entry = (Device::log_entry*) e;
    QTime mstime = QTime(0, 0).addMSecs(entry->time / 1000);
    QString ret;

    ret = mstime.toString("hh:mm:ss.zzz") +
                    QString().sprintf(".%03d\t", entry->time % 1000);
    if (!entry->is_irq) {
        ret += entry->is_write ? "writing" : "reading";
        ret += QString().sprintf("%d 0x%08X ", entry->rw_size,
                            entry->is_write ? entry->new_value : entry->value);
        ret += (entry->is_write ? "to " : "from ");
        ret += get_register_name(*entry);
        ret += QString().sprintf("\tcpu[%d] @0x%08X", entry->cpu_id, entry->cpu_pc);
    } else {
        ret += QString().sprintf("irq %u\tstatus: %u",entry->offset, entry->value);
    }

    return ret;
}
Example #29
0
int insertRecord(QString &md5, QString &filepath, QString &filename,QString type="file", QString sender="source", QString receiver="target")
{
	if (md5.isEmpty()      || 
		filepath.isEmpty() ||
		filename.isEmpty() )
	{
		return -1; //检查输入是否为空
	}

	QString timeString;
	QTime t = QTime::currentTime();
	QDate date = QDate::currentDate();
	timeString = (date.toString("yyyy-MM-dd/")).append(t.toString("hh:mm:ss"));

	QTextCodec::setCodecForCStrings(QTextCodec::codecForName("system"));//这个非常重要,没有这个,下面的filename.toUtf8()就会出错
	char* errMsg;

	QString downloaded ="0";
	QString strsql = QString("insert into http_log values( ");  
							//insert into http_log values("md5", "receiver", "filename", "filepath", "sender", "time")
	strsql.append("\""+ type+ "\", "); //type
	strsql.append("\""+ downloaded+ "\", "); //downloaded
	strsql.append("\""+ md5+ "\", ");
	strsql.append("\""+ receiver+ "\", ");
	strsql.append("\""+ filename.toUtf8()+ "\", ");
	strsql.append("\""+ filepath.toUtf8()+ ("\", "));
	strsql.append("\""+ (sender)+ ("\", "));
	strsql.append(("\"")+ (timeString)+ ("\");"));

	int res = sqlite3_exec(pDB,"begin transaction;",0,0, &errMsg);
	res = sqlite3_exec(pDB,strsql.toStdString().c_str(),0,0, &errMsg); //insert
	if (res != SQLITE_OK)
	{
		std::cout << "insertRecord error." << errMsg << std::endl;
		return -2;//插入出错
	}
	res = sqlite3_exec(pDB,"commit transaction;",0,0, &errMsg);
	std::cout<<"file information of "<<filename.toStdString()<<" is inserted into the database."<< std::endl;
	return 0;
}
Example #30
-1
// writeLog()
//
//  Write data to the HTTP log server
//  Log messages:
//    1 : logged in
//    2 : logged out
//    3 : pedal dn
//    4 : pedal up
//    5 : software terminating normally
//    6 : software terminating abnormally
//    7 : Software error (i.e. Omni connection lost)
//
void ServerNForm::writeLog(QString log_message, QString log_level)
{
	infoText->append( "Wrote to log: " + log_message +"." );

	QTime t; t.start();
	QDate d = QDate::currentDate();
	QString surgeon_name(m_surgeon_name);
	QString time=t.toString("hh:mm:ss.zzz");
	QString date;
	date=d.toString("dd-MMMM-yyyy");
	QString logline(date + "\t"
		 + time + "\t" 
		 + surgeon_name + "\t" 
		 + log_level + "\t" 
		 + log_message );

	QUrl::encode(surgeon_name);
	QUrl::encode(log_message);
	QUrl::encode(time);

	// format log message: time, user, log_level, message
	QString B( "timestamp=" + time + 
		"&user="******"&log_level=" + log_level +
		"&log_message=" + log_message );

	QHttpRequestHeader header("POST", "/log_server/index.php");
	header.setValue("Host", "brl.ee.washington.edu");
	header.setContentType("application/x-www-form-urlencoded");
	http.setHost("brl.ee.washington.edu");
	http.request(header, B.utf8());

	// TODO:  Also write to a text file here
	QStringList lines;
	lines += logline.toLatin1(); 
	QFile file( "logfile.txt" );
    if ( file.open( IO_WriteOnly | IO_Append ) ) {
        QTextStream stream( &file );
        for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it )
			stream << *it << "\n";
		file.close();
    }

}