当前位置: 首页>>代码示例>>C++>>正文


C++ QDateTime类代码示例

本文整理汇总了C++中QDateTime的典型用法代码示例。如果您正苦于以下问题:C++ QDateTime类的具体用法?C++ QDateTime怎么用?C++ QDateTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QDateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createBirthday

vCardProperty vCardProperty::createBirthday(const QDateTime& birthday, const vCardParamList& params)
{
    return vCardProperty(VC_BIRTHDAY, birthday.toString("yyyy-MM-ddThh:mm:ssZ"), params);
}
开发者ID:sevenbitbyte,项目名称:libvcard,代码行数:4,代码来源:vcardproperty.cpp

示例2: fromDateTime

DateTime::Ptr DateTime::fromDateTime(const QDateTime &dt)
{
    Q_ASSERT(dt.isValid());
    return DateTime::Ptr(new DateTime(dt));
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:5,代码来源:qschemadatetime.cpp

示例3: block

void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
{
    // don't show / hide progressBar and it's label if we have no connection(s) to the network
    if (!clientModel || clientModel->getNumConnections() == 0)
    {
        progressBarLabel->setVisible(false);
        progressBar->setVisible(false);

        return;
    }

    QString tooltip;

    if(count < nTotalBlocks)
    {
        int nRemainingBlocks = nTotalBlocks - count;
        float nPercentageDone = count / (nTotalBlocks * 0.01f);

        if (clientModel->getStatusBarWarnings() == "")
        {
            progressBarLabel->setText(tr("Synchronizing with network..."));
            progressBarLabel->setVisible(true);
            progressBar->setFormat(tr("~%n block(s) remaining", "", nRemainingBlocks));
            progressBar->setMaximum(nTotalBlocks);
            progressBar->setValue(count);
            progressBar->setVisible(true);
        }
        else
        {
            progressBarLabel->setText(clientModel->getStatusBarWarnings());
            progressBarLabel->setVisible(true);
            progressBar->setVisible(false);
        }
        tooltip = tr("Downloaded %1 of %2 blocks of transaction history (%3% done).").arg(count).arg(nTotalBlocks).arg(nPercentageDone, 0, 'f', 2);
    }
    else
    {
        if (clientModel->getStatusBarWarnings() == "")
            progressBarLabel->setVisible(false);
        else
        {
            progressBarLabel->setText(clientModel->getStatusBarWarnings());
            progressBarLabel->setVisible(true);
        }
        progressBar->setVisible(false);
        tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count);
    }

    tooltip = tr("Current difficult %1.").arg(clientModel->GetDifficulty()) + QString("<br>") + tooltip;

    QDateTime now = QDateTime::currentDateTime();
    QDateTime lastBlockDate = clientModel->getLastBlockDate();
    int secs = lastBlockDate.secsTo(now);
    QString text;

    // Represent time from last generated block in human readable text
    if(secs <= 0)
    {
        // Fully up to date. Leave text empty.
    }
    else if(secs < 60)
    {
        text = tr("%n second(s) ago","",secs);
    }
    else if(secs < 60*60)
    {
        text = tr("%n minute(s) ago","",secs/60);
    }
    else if(secs < 24*60*60)
    {
        text = tr("%n hour(s) ago","",secs/(60*60));
    }
    else
    {
        text = tr("%n day(s) ago","",secs/(60*60*24));
    }

    // Set icon state: spinning if catching up, tick otherwise
    if(secs < 90*60 && count >= nTotalBlocks)
    {
        tooltip = tr("Up to date") + QString(".<br>") + tooltip;
        labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));

        overviewPage->showOutOfSyncWarning(false);
    }
    else
    {
        tooltip = tr("Catching up...") + QString("<br>") + tooltip;
        labelBlocksIcon->setMovie(syncIconMovie);
        syncIconMovie->start();

        overviewPage->showOutOfSyncWarning(true);
    }

    if(!text.isEmpty())
    {
        tooltip += QString("<br>");
        tooltip += tr("Last received block was generated %1.").arg(text);
    }

//.........这里部分代码省略.........
开发者ID:dyljp,项目名称:rosecoin,代码行数:101,代码来源:bitcoingui.cpp

示例4: getCurrentNeighbour

/* get the list of Neighbours from the RsIface.  */
void NetworkDialog::insertConnect()
{
	if (!rsPeers)
	{
		return;
	}

	std::list<std::string> neighs;
	std::list<std::string>::iterator it;
	rsPeers->getOthersList(neighs);

	/* get a link to the table */
        QTreeWidget *connectWidget = ui.connecttreeWidget;
	QTreeWidgetItem *oldSelect = getCurrentNeighbour();
	QTreeWidgetItem *newSelect = NULL;
	std::string oldId;
	if (oldSelect)
	{
		oldId = (oldSelect -> text(9)).toStdString();
	}

        QList<QTreeWidgetItem *> items;
	for(it = neighs.begin(); it != neighs.end(); it++)
	{
		RsPeerDetails detail;
		if (!rsPeers->getPeerDetails(*it, detail))
		{
			continue; /* BAD */
		}

		/* make a widget per friend */
           	QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);

		/* add all the labels */
		
	        /* (0) Status Icon */
		item -> setText(0, "");

		/* (1) Accept/Deny */
		if (detail.state & RS_PEER_STATE_FRIEND)
			item -> setText(1, tr("Trusted"));
		else
			item -> setText(1, tr("Denied"));

		if (rsPeers->isTrustingMe(detail.id) || detail.lastConnect>0)
			item -> setText(2, tr("Is trusting me"));
		else
			item -> setText(2, tr("Unknown"));

		/* (3) Last Connect */
		{
			std::ostringstream out;
			// Show anouncement if a friend never was connected.
			if (detail.lastConnect==0 ) 
				item -> setText(3, tr("Never seen"));
			else 
			{
				// Dont Show a timestamp in RS calculate the day
				QDateTime datum = QDateTime::fromTime_t(detail.lastConnect);
				// out << datum.toString(Qt::LocalDate);
				QString stime = datum.toString(Qt::LocalDate);
				item -> setText(3, stime);
			}
		}
		
        	/* (4) Person */
		item -> setText(4, QString::fromStdString(detail.name));
		
		/* (5) Peer Address */
		{
			std::ostringstream out;
			if(detail.state & RS_PEER_STATE_FRIEND) {
				out << detail.localAddr << ":";
				out << detail.localPort << "/";
				out << detail.extAddr << ":";
				out << detail.extPort;
			} else {
				// No Trust => no IP Information
				out << "0.0.0.0:0/0.0.0.0:0";
			}
                	item -> setText(5, QString::fromStdString(out.str()));
		}

		/* Others */
		item -> setText(6, QString::fromStdString(detail.org));
		item -> setText(7, QString::fromStdString(detail.location));
		item -> setText(8, QString::fromStdString(detail.email));

		{
			item -> setText(9, QString::fromStdString(detail.id));
			if ((oldSelect) && (oldId == detail.id))
			{
				newSelect = item;
			}
		}

		//item -> setText(10, QString::fromStdString(detail.authcode));

		/**
//.........这里部分代码省略.........
开发者ID:autoscatto,项目名称:retroshare,代码行数:101,代码来源:NetworkDialog.cpp

示例5: max

void MainWindow::fillSensorStateTable()
{
    if (!checkDates()) return;

    QString seqQuery;

    // get the latest row from the existing sensorStateHistory into a temporary table

    seqQuery  = "DROP TEMPORARY TABLE IF EXISTS tempState";

 //   qDebug() << seqQuery;

    query.clear();

    if (!query.exec(seqQuery))
    {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Warning);

        msgBox.setText("Cannot drop temporary table tempState!");
        msgBox.exec();
        return;
    }

    seqQuery  = "select max(lastUpdate) from SensorStateHistory";

 //   qDebug() << seqQuery;

    query.clear();

    if (!query.exec(seqQuery))
    {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Warning);

        msgBox.setText("Cannot select from sensorStateHistory!");
        msgBox.exec();
        return;
    }

    // insert the lateset row from sensorStateHistory to temp table

    QDateTime lastDate;

    while (query.next())
    {
        lastDate = query.value(0).toDateTime();

    }


    qDebug()<<"Latest date on sensorStateHistory is: " << lastDate.toString("yyyy-MM-dd hh:mm:ss");

    seqQuery  = "CREATE TEMPORARY TABLE tempState ( select * from SensorStateHistory where lastUpdate =  '";
    seqQuery += lastDate.toString("yyyy-MM-dd hh:mm:ss") + "')";


 //   qDebug() << seqQuery;

    query.clear();

    if (!query.exec(seqQuery))
    {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Warning);

        msgBox.setText("Cannot create temporary table tempState!");
        msgBox.exec();

        qDebug()<<query.lastError();
        qDebug()<<query.executedQuery();


        return;
    }


    // get the current values from behaviourLog


    if (lv == "BATCH" || "BATCHNORM")
    {
        seqQuery  = "select timestamp,sensorId,status,trainingNumber from " + behTable + " where sensorID < 61 ORDER BY trainingNumber, timestamp";
    }
    else
    {
        seqQuery  = "select timestamp,sensorId,status,trainingNumber from " + behTable + " where sensorID < 61 and timestamp between '";
        seqQuery += ui->dateFrom->dateTime().toString("yyyy-MM-dd hh:mm:ss");
        seqQuery += "' and '";
        seqQuery += ui->dateTo->dateTime().toString("yyyy-MM-dd hh:mm:ss") + "' ORDER BY timestamp";
    }
    qDebug() << seqQuery;


    query.clear();

    if (!query.exec(seqQuery))
    {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Warning);
//.........这里部分代码省略.........
开发者ID:uh-adapsys,项目名称:accompany,代码行数:101,代码来源:mainwindow.cpp

示例6: parseVObject

static Event parseVObject( VObject *obj )
{
    Event e;

    bool haveAlarm = FALSE;
    bool haveStart = FALSE;
    bool haveEnd = FALSE;
    QDateTime alarmTime;
    Event::SoundTypeChoice soundType = Event::Silent;

    VObjectIterator it;
    initPropIterator( &it, obj );
    while( moreIteration( &it ) ) {
        VObject *o = nextVObject( &it );
        QCString name = vObjectName( o );
        QCString value = vObjectStringZValue( o );
        if ( name == VCDTstartProp ) {
            e.setStart( TimeConversion::fromISO8601( value ) );
            haveStart = TRUE;
        }
        else if ( name == VCDTendProp ) {
            e.setEnd( TimeConversion::fromISO8601( value ) );
            haveEnd = TRUE;
        }
        else if ( name == "X-Qtopia-NOTES" ) {
            e.setNotes( value );
        }
        else if ( name == VCDescriptionProp ) {
            e.setDescription( value );
        }
        else if ( name == VCLocationProp ) {
            e.setLocation( value );
        }
        else if ( name == VCAudioContentProp ) {
            haveAlarm = TRUE;
            VObjectIterator nit;
            initPropIterator( &nit, o );
            while( moreIteration( &nit ) ) {
                VObject *o = nextVObject( &nit );
                QCString name = vObjectName( o );
                QCString value = vObjectStringZValue( o );
                if ( name == VCRunTimeProp )
                    alarmTime = TimeConversion::fromISO8601( value );
                else if ( name == VCAudioContentProp ) {
                    if ( value == "silent" )
                        soundType = Event::Silent;
                    else
                        soundType = Event::Loud;
                }
            }
        }
        else if ( name == "X-Qtopia-TIMEZONE") {
            e.setTimeZone( value );
        }
        else if ( name == "X-Qtopia-AllDay" ) {
            e.setType( Event::AllDay );
        }
#if 0
        else {
            printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
            VObjectIterator nit;
            initPropIterator( &nit, o );
            while( moreIteration( &nit ) ) {
                VObject *o = nextVObject( &nit );
                QCString name = vObjectName( o );
                QString value = vObjectStringZValue( o );
                printf(" subprop: %s = %s\n", name.data(), value.latin1() );
            }
        }
#endif
    }

    if ( !haveStart && !haveEnd )
        e.setStart( QDateTime::currentDateTime() );

    if ( !haveEnd ) {
        e.setType( Event::AllDay );
        e.setEnd( e.start() );
    }

    if ( haveAlarm ) {
        int minutes = alarmTime.secsTo( e.start() ) / 60;
        e.setAlarm( TRUE, minutes, soundType );
    }
    return e;
}
开发者ID:opieproject,项目名称:opie,代码行数:86,代码来源:event.cpp

示例7: settings

void OptionsDialog::reaSettings()
{
#ifdef Q_OS_WIN32
	QSettings settings(QDir::homePath()+tr("/Application Data/")+qApp->applicationName()+".ini", QSettings::IniFormat);
#else

	QSettings settings;
#endif

	QDateTime today = QDateTime::currentDateTime();
	QString todaytext = today.toString("yyyyMMdd");
	QStringList fontS;
	QFont font;
	QFont defaultFont;

	fontS << settings.value("Font/FileName_Settings", ui.statusbarFontComboBox->currentFont() ).toString()
		<< settings.value("Font/Statistics_Settings", ui.statusbarFontComboBox->currentFont() ).toString()
		<< settings.value("Font/DefaultFont", ui.fontComboBox->currentFont() ).toString();
	
	font.fromString(fontS.at(0));
	ui.statusbarFontComboBox->setCurrentFont( font );
	ui.statusbarBoldCheckBox->setChecked( font.bold() );
	ui.statusbarItalicCheckBox->setChecked( font.italic() );
	ui.statusbarSpinBox->setValue( font.pointSize() );
	
	defaultFont.fromString(fontS.at(2));
	ui.fontComboBox->setCurrentFont( defaultFont );
	ui.fontSizeSpinBox->setValue( defaultFont.pointSize() );
	
	ui.loadOnStartCheckBox->setChecked( settings.value( "RecentFiles/OpenLastFile", true ).toBool() );
	ui.saveCursorCheckBox->setChecked( settings.value( "RecentFiles/SavePosition", true ).toBool() );
	if ( !ui.loadOnStartCheckBox->isChecked() )
		ui.saveCursorCheckBox->setEnabled( false );
	
	ui.editorWidthSpinBox->setMaximum( settings.value("MaxEditorWidth", 1024).toInt());
	ui.editorTopSpaceSpinBox->setMaximum(settings.value("MaxEditorTopSpace", 768).toInt());
	ui.editorBottomSpaceSpinBox->setMaximum(settings.value("MaxEditorBottomSpace", 1000).toInt());
	ui.wordCountSpinBox->setValue( settings.value("WordCount", 0).toInt());
	ui.pageCountSpinBox->setValue( settings.value("PageCountFormula", 250).toInt());
	ui.fullScreenCheckBox->setChecked( settings.value("WindowState/ShowFullScreen", true).toBool() );
	ui.splashScreenCheckBox->setChecked( settings.value("WindowState/ShowSplashScreen", true).toBool() );
	ui.autoSaveCheckBox->setChecked( settings.value("AutoSave", false).toBool() );
	ui.flowModeCheckBox->setChecked( settings.value("FlowMode", false).toBool() );
	ui.scrollBarCheckBox->setChecked( settings.value("ScrollBar", true).toBool() );
	ui.pageCountCheckBox->setChecked( settings.value("PageCount", false).toBool() );
	ui.soundCheckBox->setChecked( settings.value("Sound", true).toBool() );
	QString datetext = settings.value("Deadline", todaytext).toString();
	QDate date;
	QDate dateselected = date.fromString(datetext, "yyyyMMdd");
	ui.calendarWidget->setSelectedDate(dateselected);
	ui.editorWidthSpinBox->setValue( settings.value	("EditorWidth", 800).toInt());  
	ui.editorTopSpaceSpinBox->setValue( settings.value("EditorTopSpace", 0).toInt());
	ui.editorBottomSpaceSpinBox->setValue( settings.value("EditorBottomSpace", 0).toInt());
	ui.spinBox->setValue( settings.value("TimedWriting", 0 ).toInt());
	ui.dateFormat->setText( settings.value("DateFormat", "dd MMMM yyyy dddd").toString());
	ui.timeFormat->setText( settings.value("TimeFormat", "HH:MM").toString());
	
	QPalette palette;
	
	palette.setColor(ui.pbFontColor->backgroundRole(),
		fcolor = settings.value("Colors/FontColor", "#808080" ).toString());
	ui.pbFontColor->setPalette(palette);	

	palette.setColor(ui.pbStatusBarColor->backgroundRole(),
		scolor = settings.value("Colors/StatusColor", "#202020" ).toString());
	ui.pbStatusBarColor->setPalette(palette);

	
	palette.setColor(ui.pbEditorBackColor->backgroundRole(),
		bgcolor = settings.value("Colors/Background", "black" ).toString());
	ui.pbEditorBackColor->setPalette(palette);
	
	palette.setColor(ui.pbStatusBarBgColor->backgroundRole(),
		sbcolor = settings.value("Colors/StatusBg", "#808080").toString());
	ui.pbStatusBarBgColor->setPalette(palette);


}
开发者ID:ShadowIce,项目名称:textroom,代码行数:78,代码来源:optionsdialog.cpp

示例8: operator

bool ZipDirSortItemComparator::operator()(const ZipDirSortItem &n1, const ZipDirSortItem &n2) const
{
    const ZipDirSortItem* f1 = &n1;
    const ZipDirSortItem* f2 = &n2;

    qint64 r = 0;

    if ( options.testFlag( AbZip::SortByTime ) )
    {
        QDateTime firstModified = f1->item.lastModifiedDate;
        QDateTime secondModified = f2->item.lastModifiedDate;

        // QDateTime by default will do all sorts of conversions on these to
        // find timezones, which is incredibly expensive. As we aren't
        // presenting these to the user, we don't care (at all) about the
        // local timezone, so force them to UTC to avoid that conversion.
        firstModified.setTimeSpec(Qt::UTC);
        secondModified.setTimeSpec(Qt::UTC);

        r = firstModified.msecsTo(secondModified);
    }
    else if ( options.testFlag( AbZip::SortByCompressedSize ) )
    {
        r = f2->item.compressedSize - f1->item.compressedSize;
    }
    else if ( options.testFlag( AbZip::SortByUncompressedSize ) )
    {
        r = f2->item.uncompressedSize - f1->item.uncompressedSize;
    }
    else if ( options.testFlag( AbZip::SortByType ) )
    {
        if ( options.testFlag( AbZip::CaseSensitive ) )
        {
            f1->suffix = ZipUtils::getFileSuffix( f1->item.filePath );
            f2->suffix = ZipUtils::getFileSuffix( f2->item.filePath );
        }
        else
        {
            f1->suffix = ZipUtils::getFileSuffix( f1->item.filePath ).toLower();
            f2->suffix = ZipUtils::getFileSuffix( f2->item.filePath ).toLower();
        }
        r = f1->suffix.compare(f2->suffix);
    }
    else
    {
        if ( options.testFlag( AbZip::CaseSensitive ) )
        {
            f1->filename = ZipUtils::getFileName( f1->item.filePath );
            f2->filename = ZipUtils::getFileName( f2->item.filePath );
        }
        else
        {
            f1->filename = ZipUtils::getFileName( f1->item.filePath ).toLower();
            f2->filename = ZipUtils::getFileName( f2->item.filePath ).toLower();
        }

        r = f1->filename.compare(f2->filename);
    }

    if ( options.testFlag( AbZip::SortReversed) )
        return r > 0;

    return r < 0;
}
开发者ID:abelayer,项目名称:AbZip,代码行数:64,代码来源:ZipDirIterator.cpp

示例9: addSystemMessage

void Message::addSystemMessage( const QString &msg, const QDateTime &dt )
{
	message->setText( "<font color=\"#ff0000\" size=\"5\">" + tr( "System message" ) + "</font>" + msg );
	datetimeEdit->setText( dt.toString( "dd.MM.yyyy hh:mm:ss" ) );
}
开发者ID:BackupTheBerlios,项目名称:qtlen,代码行数:5,代码来源:message.cpp

示例10: addMessage

void Message::addMessage( const QString &msg, const QDateTime &dt )
{
	message->setText( msg );
	datetimeEdit->setText( dt.toString( "dd.MM.yyyy hh:mm:ss" ) );
}
开发者ID:BackupTheBerlios,项目名称:qtlen,代码行数:5,代码来源:message.cpp

示例11: cleared

void GuildShell::guildMemberList(const uint8_t* data, size_t len)
{
    // clear out any existing member data
    emit cleared();
    m_members.clear();

    m_maxNameLength = 0;

    // construct a netstream object on the data
    NetStream gml(data, len);

    // read the player name from the front of the stream
    QString player = gml.readText();

    // read the player count from the stream
    uint32_t count;
    count = gml.readUInt32();

#ifdef GUILDSHELL_DIAG
    seqDebug("Guild has %d members:", count);
#endif

    GuildMember* member;

#ifdef GUILDSHELL_DIAG
    QDateTime dt;
#endif // GUILDSHELL_DIAG

    // iterate over the data until we reach the end of it
    while (!gml.end())
    {
        // create a new guildmember initializing it from the NetStream
        member = new GuildMember(gml);

        // insert the new member into the dictionary
        m_members.insert(member->name(), member);

        // check for new longest member name
        if (member->name().length() > m_maxNameLength)
            m_maxNameLength = member->name().length();

        emit added(member);

#ifdef GUILDSHELL_DIAG
        dt.setTime_t(member->lastOn());
        seqDebug("%-64s\t%d\t%s\t%d\t%s\t'%s'\t%s:%d",
                 (const char*)member->name(),
                 member->level(),
                 (const char*)classString(member->classVal()),
                 member->guildRank(),
                 (const char*)dt.toString(),
                 (const char*)member->publicNote(),
                 (const char*)m_zoneMgr->zoneNameFromID(member->zoneId()),
                 member->zoneInstance());
#endif
    }

    emit loaded();

#ifdef GUILDSHELL_DIAG
    seqDebug("Finished processing %d guildmates. %d chars in longest name.",
             m_members.count(), m_maxNameLength);
#endif // 
}
开发者ID:xbackupx,项目名称:showeqx,代码行数:64,代码来源:guildshell.cpp

示例12: restartTimer

void LxQtClock::restartTimer(const QDateTime &now)
{
    if (mClockTimer->isActive())
        mClockTimer->stop();
    int updateInterval = mClockTimer->interval();
    int delay = static_cast<int>((updateInterval + 100 /* ms after time change */ - ((now.time().msec() + now.time().second() * 1000) % updateInterval)) % updateInterval);
    QTimer::singleShot(delay, this, SLOT(updateTime()));
    QTimer::singleShot(delay, mClockTimer, SLOT(start()));
}
开发者ID:MoonLightDE,项目名称:lxqt-panel,代码行数:9,代码来源:lxqtclock.cpp

示例13: statusBar

void CryptotargetGUI::setNumBlocks(int count)
{
    // Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text)
    statusBar()->clearMessage();

    // Acquire current block source
    enum BlockSource blockSource = clientModel->getBlockSource();
    switch (blockSource) {
        case BLOCK_SOURCE_NETWORK:
            progressBarLabel->setText(tr("Synchronizing with network..."));
            break;
        case BLOCK_SOURCE_DISK:
            progressBarLabel->setText(tr("Importing blocks from disk..."));
            break;
        case BLOCK_SOURCE_REINDEX:
            progressBarLabel->setText(tr("Reindexing blocks on disk..."));
            break;
        case BLOCK_SOURCE_NONE:
            // Case: not Importing, not Reindexing and no network connection
            progressBarLabel->setText(tr("No block source available..."));
            break;
    }

    QString tooltip;

    QDateTime lastBlockDate = clientModel->getLastBlockDate();
    QDateTime currentDate = QDateTime::currentDateTime();
    int secs = lastBlockDate.secsTo(currentDate);

    tooltip = tr("Processed %1 blocks of transaction history.").arg(count);

    // Set icon state: spinning if catching up, tick otherwise
    if(secs < 90*60)
    {
        tooltip = tr("Up to date") + QString(".<br>") + tooltip;
        labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));

#ifdef ENABLE_WALLET
        if(walletFrame)
            walletFrame->showOutOfSyncWarning(false);
#endif

        progressBarLabel->setVisible(false);
        progressBar->setVisible(false);
    }
    else
    {
        // Represent time from last generated block in human readable text
        QString timeBehindText;
        const int HOUR_IN_SECONDS = 60*60;
        const int DAY_IN_SECONDS = 24*60*60;
        const int WEEK_IN_SECONDS = 7*24*60*60;
        const int YEAR_IN_SECONDS = 31556952; // Average length of year in Gregorian calendar
        if(secs < 2*DAY_IN_SECONDS)
        {
            timeBehindText = tr("%n hour(s)","",secs/HOUR_IN_SECONDS);
        }
        else if(secs < 2*WEEK_IN_SECONDS)
        {
            timeBehindText = tr("%n day(s)","",secs/DAY_IN_SECONDS);
        }
        else if(secs < YEAR_IN_SECONDS)
        {
            timeBehindText = tr("%n week(s)","",secs/WEEK_IN_SECONDS);
        }
        else
        {
            int years = secs / YEAR_IN_SECONDS;
            int remainder = secs % YEAR_IN_SECONDS;
            timeBehindText = tr("%1 and %2").arg(tr("%n year(s)", "", years)).arg(tr("%n week(s)","", remainder/WEEK_IN_SECONDS));
        }

        progressBarLabel->setVisible(true);
        progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
        progressBar->setMaximum(1000000000);
        progressBar->setValue(clientModel->getVerificationProgress() * 1000000000.0 + 0.5);
        progressBar->setVisible(true);

        tooltip = tr("Catching up...") + QString("<br>") + tooltip;
        if(count != prevBlocks)
        {
            labelBlocksIcon->setPixmap(QIcon(QString(
                ":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
                .pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
            spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
        }
        prevBlocks = count;

#ifdef ENABLE_WALLET
        if(walletFrame)
            walletFrame->showOutOfSyncWarning(true);
#endif

        tooltip += QString("<br>");
        tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
        tooltip += QString("<br>");
        tooltip += tr("Transactions after this will not yet be visible.");
    }

    // Don't word-wrap this (fixed-width) tooltip
//.........这里部分代码省略.........
开发者ID:KendrickBitz,项目名称:cryptotarget,代码行数:101,代码来源:cryptotargetgui.cpp

示例14: statStart

void StatisticWindow::rebuild(QDate from, QDate to)
{
    QDateTime statStart(from);
    QDateTime statEnd(to.addDays(1));

    //prepare containers
    m_Uncategorized.TotalTime = 0;
    m_Uncategorized.NormalValue = 0;
    m_Uncategorized.Name = tr("Uncategorized");
    m_Uncategorized.Color = Qt::gray;
    m_Categories.resize(m_DataManager->categoriesCount());
    for (int i = 0; i<m_Categories.size(); i++){
        m_Categories[i].TotalTime = 0;
        m_Categories[i].NormalValue = 0;
        m_Categories[i].Name = m_DataManager->categories(i)->name;
        m_Categories[i].Color = m_DataManager->categories(i)->color;
    }

    m_Applications.resize(m_DataManager->applicationsCount());
    for (int i = 0; i<m_Applications.size(); i++){
        m_Applications[i].TotalTime = 0;
        m_Applications[i].NormalValue = 0;
        m_Applications[i].Name = m_DataManager->applications(i)->name;
        m_Applications[i].Color = Qt::white;
    }

    //calculation
    int TotalTime = 0;
    for (int i = 0; i<m_Applications.size(); i++){
        const sAppInfo* app = m_DataManager->applications(i);
        for (int j = 0; j<app->periods.size(); j++){
            QDateTime start = app->periods[j].start;
            QDateTime end = app->periods[j].start.addSecs(app->periods[j].length);
            if (end>statStart && start<statEnd){
                if (start<statStart)
                    start = statStart;
                if (end>statEnd)
                    end = statEnd;
                int duration = start.secsTo(end);
                TotalTime+=duration;
                m_Applications[i].TotalTime+=duration;
                int cat = app->categories[app->periods[j].profileIndex];
                if (cat==-1)
                    m_Uncategorized.TotalTime+=duration;
                else
                    m_Categories[cat].TotalTime+=duration;
            }
            if (start>statEnd || end>statEnd)
                break;
        }
    }

    //calculate normalized values
    if (TotalTime>0){
        m_Uncategorized.NormalValue = (float)m_Uncategorized.TotalTime/TotalTime;
        for (int i = 0; i<m_Categories.size(); i++)
            m_Categories[i].NormalValue = (float)m_Categories[i].TotalTime/TotalTime;

        for (int i = 0; i<m_Applications.size(); i++)
            m_Applications[i].NormalValue = (float)m_Applications[i].TotalTime/TotalTime;
    }

    qSort( m_Categories.begin(), m_Categories.end(), lessThan );

    ui->widgetDiagram->setTotalTime(TotalTime);
    ui->widgetDiagram->update();


    //fill applications widget
    ui->treeWidgetApplications->setSortingEnabled(false);
    ui->treeWidgetApplications->clear();
    for (int i = 0; i<m_Applications.size(); i++){
        QTreeWidgetItem* item = new QTreeWidgetItem();
        item->setText(0,m_Applications[i].Name);
        item->setData(0,Qt::UserRole,i);
        item->setText(1,DurationToString(m_Applications[i].TotalTime));
        item->setText(2,fixSize(QString::number(m_Applications[i].NormalValue*100,'f',2),5)+"%");
        ui->treeWidgetApplications->addTopLevelItem(item);
    }
    ui->treeWidgetApplications->setSortingEnabled(true);
}
开发者ID:vasilenkomike,项目名称:TrackYourTime,代码行数:81,代码来源:statisticwindow.cpp

示例15: qDebug

void MainWindow::on_inflatePushButton_clicked()
{


     QSqlQuery delQuery;
     delQuery.exec("delete from NormBehaviourLog");


    QString seqQuery;

    if (lv == "BATCHNORM" || lv == "BATCH")
    {
        seqQuery  = "select timestamp,sensorId,status,trainingNumber from BehaviourLog where sensorID < 61 ORDER BY trainingNumber, timestamp";
    }
    else
    {
       seqQuery  = "select timestamp,sensorId,status,trainingNumber from BehaviourLog where sensorID < 61 and timestamp between '";
       seqQuery += ui->dateFrom->dateTime().toString("yyyy-MM-dd hh:mm:ss");
       seqQuery += "' and '";
       seqQuery += ui->dateTo->dateTime().toString("yyyy-MM-dd hh:mm:ss") + "' ORDER BY timestamp";
    }
    qDebug() << seqQuery;


    query.clear();

    if (!query.exec(seqQuery))
    {
        qDebug() << seqQuery;

        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Warning);


        msgBox.setText("Cannot select from BehaviourLog table!");
        msgBox.exec();
        return;

    }

    numRowsRead = query.numRowsAffected();
    numRowsProcessed = 0;
    numRowsInserted = 0;

    bool first = true;


    processed = false;

    currentDate = QDateTime(QDate(2000,01,01),QTime(0,0,1));

    readRow();

    while (!processed)
    {

      if (first)
      {
          first = false;
          insertNewRow(currentDate,currentSensorId,currentSensorValue,currentTrainingNumber);

       }
       else
       {

            if ((currentDate > prevDate.addSecs(1))  &&  (currentTrainingNumber == prevTrainingNumber))   // write n copies of current row 1 sec apart
            {
                int n = prevDate.time().msecsTo(currentDate.time()) / 1000;

                n--;

                QDateTime insDate = prevDate;

                for (int i=0;i<n;i++)
                {
                    insDate = insDate.addSecs(1);

                    insertNewRow(insDate,prevSensorId,prevSensorValue,prevTrainingNumber);

                }

                insertNewRow(currentDate,currentSensorId,currentSensorValue, currentTrainingNumber);


            }
            else   // same dates for two events
            {
                insertNewRow(currentDate,currentSensorId,currentSensorValue, currentTrainingNumber);
            }


         }

         readRow();

    }

    qDebug()<< "Rows read   : " << numRowsRead;
    qDebug()<< "Rows processed   : " << numRowsProcessed;
    qDebug()<< "Rows written: " << numRowsInserted;
//.........这里部分代码省略.........
开发者ID:uh-adapsys,项目名称:accompany,代码行数:101,代码来源:mainwindow.cpp


注:本文中的QDateTime类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。