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


C++ QDate类代码示例

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


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

示例1: GetCurrentDate

QString UT::GetCurrentDate()
{
	QDate date = QDate::currentDate();
	QString dateString = date.toString();
	return dateString;
}	
开发者ID:bazzinotti,项目名称:art-core,代码行数:6,代码来源:UT.cpp

示例2: i18np

void KMyMoneyBriefSchedule::loadSchedule()
{
    try {
        if (m_index < m_scheduleList.count()) {
            MyMoneySchedule sched = m_scheduleList[m_index];

            m_indexLabel->setText(i18n("%1 of %2", m_index + 1, m_scheduleList.count()));
            m_name->setText(sched.name());
            m_type->setText(KMyMoneyUtils::scheduleTypeToString(sched.type()));
            m_account->setText(sched.account().name());
            QString text;
            MyMoneyMoney amount = sched.transaction().splitByAccount(sched.account().id()).value();
            amount = amount.abs();

            if (sched.willEnd()) {
                int transactions = sched.paymentDates(m_date, sched.endDate()).count() - 1;
                text = i18np("Payment on %2 for %3 with %1 transaction remaining occurring %4.",
                             "Payment on %2 for %3 with %1 transactions remaining occurring %4.",
                             transactions,
                             KGlobal::locale()->formatDate(m_date),
                             amount.formatMoney(sched.account().fraction()),
                             i18n(sched.occurrenceToString().toLatin1()));
            } else {
                text = i18n("Payment on %1 for %2 occurring %3.",
                            KGlobal::locale()->formatDate(m_date),
                            amount.formatMoney(sched.account().fraction()),
                            i18n(sched.occurrenceToString().toLatin1()));
            }

            if (m_date < QDate::currentDate()) {
                if (sched.isOverdue()) {
                    QDate startD = (sched.lastPayment().isValid()) ?
                                   sched.lastPayment() :
                                   sched.startDate();

                    if (m_date.isValid())
                        startD = m_date;

                    int days = startD.daysTo(QDate::currentDate());
                    int transactions = sched.paymentDates(startD, QDate::currentDate()).count();

                    text += "<br><font color=red>";
                    text += i18np("%1 day overdue", "%1 days overdue", days);
                    text += QString(" ");
                    text += i18np("(%1 occurrence.)", "(%1 occurrences.)", transactions);
                    text += "</color>";
                }
            }

            m_details->setText(text);

            m_prevButton->setEnabled(true);
            m_nextButton->setEnabled(true);
            m_skipButton->setEnabled(sched.occurrencePeriod() != MyMoneySchedule::OCCUR_ONCE);

            if (m_index == 0)
                m_prevButton->setEnabled(false);
            if (m_index == (m_scheduleList.count() - 1))
                m_nextButton->setEnabled(false);
        }
    } catch (const MyMoneyException &) {
    }
}
开发者ID:mageddo,项目名称:kmymoney,代码行数:63,代码来源:kmymoneybriefschedule.cpp

示例3: assert

QString Zones::getStartDateString(int rnum) const
{
    assert(rnum >= 0);
    QDate d = ranges[rnum].begin;
    return (d.isNull() ? "BEGIN" : d.toString());
}
开发者ID:gregf83,项目名称:GoldenCheetah,代码行数:6,代码来源:Zones.cpp

示例4: document

void FrmInformacionFarmaco::finishedSlotBuscarMedicamento(QNetworkReply* reply)
{
    //qDebug()<<reply->readAll();
    QString data=(QString)reply->readAll();
    QString cXML = data;

    // Extract values from XML
    QDomDocument document("XmlDoc");
    document.setContent(cXML);

    QDomElement root = document.documentElement();
    if (root .tagName() != "object")
        qDebug("Bad root element.");

    QDomNode drugList = root.firstChild();

    QDomNode n = drugList.firstChild();
    QDomNode n2 = n.firstChild();
    QDomNode n3 = n2.firstChild();
    while (!n.isNull()) {
        if (n.isElement()) {
            QDomNodeList attributes = n.childNodes();

            for (int i = 0; i < attributes.count(); i ++) {
                QDomElement e = attributes.at(i).toElement();

                if (e.tagName() == "name_speciality") {
                    ui->txtNombre->setText(e.text());
                }
                if (e.tagName() == "dosage_form") {
                    ui->txtDosificacion->setText(e.text());
                }
                if (e.tagName() == "national_code") {
                    ui->txtcodigo_nacional->setText(e.text());
                }
                if (e.tagName() == "name_laboratory") {
                    ui->txtLaboratorio->setText(e.text());
                }
                if (e.tagName() == "name_atc") {
                    ui->txtNombreATC->setText(e.text());
                }
                if (e.tagName() == "drug_type") {
                    ui->txtTipoMedicamento->setText(e.text());
                }
                if (e.tagName() == "package") {
                    ui->txtCaja->setText(e.text());
                }
                if (e.tagName() == "price") {
                    ui->txtPVP->setText(e.text());
                }
                if (e.tagName() == "laboratory_price") {
                    ui->txtPVC->setText(e.text());
                }
                if (e.tagName() == "TLD") {
                    ui->txtTLD->setText(e.text());
                }
                if (e.tagName() == "RECETA") {
                    ui->txtReceta->setText(e.text());
                }
                if (e.tagName() == "FINAN") {
                    ui->txtFinanciado->setText(e.text());
                }
                if (e.tagName() == "fecha_alta") {
                    QDate alta;
                    int ano,mes,dia;
                    ano = e.text().left(4).toInt();
                    mes = e.text().mid(5,2).toInt();
                    dia = e.text().mid(8,2).toInt();
                    alta.setDate(ano,mes,dia);
                    ui->txtfecha_alta->setDate(alta);
                }
                if (e.tagName() == "fecha_baja") {
                    if (e.text()!="0" && !e.text().isEmpty()) {
                        QDate baja;
                        int ano,mes,dia;
                        ano = e.text().left(4).toInt();
                        mes = e.text().mid(5,2).toInt();
                        dia = e.text().mid(8,2).toInt();
                        baja.setDate(ano,mes,dia);
                        ui->txtFechaBaja->setVisible(true);
                        ui->lblfechabaja->setVisible(true);
                        ui->txtFechaBaja->setDate(baja);
                    } else {
                        ui->txtFechaBaja->setVisible(false);
                        ui->lblfechabaja->setVisible(false);
                    }
                }
                if (e.tagName() == "baja") {
                    if(e.text()=="1")
                        ui->lblDadodeBaja->setVisible(true);
                    else
                        ui->lblDadodeBaja->setVisible(false);
                }

                if (e.tagName() == "id_laboratory") {
                    QUrl  uUrl;
                    QString cUrl = "http://svadcf.es/documentos/image/fotos/laboratorio/"+e.text().trimmed()+".gif";
                    uUrl.setUrl(cUrl);
                    ui->webLogoLaboratorio->load(uUrl);
                }
//.........这里部分代码省略.........
开发者ID:arcnexus,项目名称:RedFoX,代码行数:101,代码来源:frminformacionfarmaco.cpp

示例5: add

TaskQueries::TaskResult::Ptr TaskQueries::findWorkdayTopLevel() const
{
    if (!m_findWorkdayTopLevel) {
        {
            TaskQueries *self = const_cast<TaskQueries*>(this);
            self->m_findWorkdayTopLevel = self->createTaskQuery();
        }

        m_findWorkdayTopLevel->setFetchFunction([this] (const TaskQuery::AddFunction &add) {
            CollectionFetchJobInterface *job = m_storage->fetchCollections(Akonadi::Collection::root(),
                                                                           StorageInterface::Recursive,
                                                                           StorageInterface::Tasks);
            Utils::JobHandler::install(job->kjob(), [this, job, add] {
                if (job->kjob()->error() != KJob::NoError)
                    return;

                for (auto collection : job->collections()) {
                    ItemFetchJobInterface *job = m_storage->fetchItems(collection);
                    Utils::JobHandler::install(job->kjob(), [this, job, add] {
                        if (job->kjob()->error() != KJob::NoError)
                            return;

                        for (auto item : job->items()) {
                            add(item);
                        }
                    });
                }
            });
        });

        m_findWorkdayTopLevel->setConvertFunction([this] (const Akonadi::Item &item) {
            return m_serializer->createTaskFromItem(item);
        });
        m_findWorkdayTopLevel->setUpdateFunction([this] (const Akonadi::Item &item, Domain::Task::Ptr &task) {
            m_serializer->updateTaskFromItem(task, item);
        });
        m_findWorkdayTopLevel->setPredicateFunction([this] (const Akonadi::Item &item) {
            if (!m_serializer->isTaskItem(item))
                return false;

            const Domain::Task::Ptr task = m_serializer->createTaskFromItem(item);

            const QDate doneDate = task->doneDate().date();
            const QDate startDate = task->startDate().date();
            const QDate dueDate = task->dueDate().date();
            const QDate today = Utils::DateTime::currentDateTime().date();

            const bool pastStartDate = startDate.isValid() && startDate <= today;
            const bool pastDueDate = dueDate.isValid() && dueDate <= today;
            const bool todayDoneDate = doneDate == today;

            if (task->isDone())
                return todayDoneDate;
            else
                return pastStartDate || pastDueDate;

        });
        m_findWorkdayTopLevel->setRepresentsFunction([this] (const Akonadi::Item &item, const Domain::Task::Ptr &task) {
            return m_serializer->representsItem(task, item);
        });
    }

    return m_findWorkdayTopLevel->result();
}
开发者ID:sandsmark,项目名称:zanshin,代码行数:64,代码来源:akonaditaskqueries.cpp

示例6: LOG

bool MythTimeInputDialog::Create()
{
    if (!CopyWindowFromBase("MythTimeInputDialog", this))
        return false;

    MythUIText *messageText = NULL;
    MythUIButton *okButton = NULL;

    bool err = false;
    UIUtilE::Assign(this, messageText, "message", &err);
    UIUtilE::Assign(this, m_dateList, "dates", &err);
    UIUtilE::Assign(this, m_timeList, "times", &err);
    UIUtilE::Assign(this, okButton, "ok", &err);

    if (err)
    {
        LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythTimeInputDialog'");
        return false;
    }

    m_dateList->SetVisible(false);
    m_timeList->SetVisible(false);

    MythUIButtonListItem *item;
    // Date
    if (kNoDate != (m_resolution & 0xF))
    {
        const QDate startdate(m_startTime.toLocalTime().date());
        QDate date(startdate);

        int limit = 0;
        if (m_resolution & kFutureDates)
        {
            limit += m_rangeLimit;
        }
        if (m_resolution & kPastDates)
        {
            limit += m_rangeLimit;
            date = date.addDays(0-m_rangeLimit);
        }

        QString text;
        int flags;
        bool selected = false;
        for (int x = 0; x <= limit; x++)
        {
            selected = false;
            if (m_resolution & kDay)
            {
                date = date.addDays(1);
                flags = MythDate::kDateFull | MythDate::kSimplify;
                if (m_rangeLimit >= 356)
                    flags |= MythDate::kAddYear;
                text = MythDate::toString(date, flags);

                if (date == startdate)
                    selected = true;
            }
            else if (m_resolution & kMonth)
            {
                date = date.addMonths(1);
                text = date.toString("MMM yyyy");

                if ((date.month() == startdate.month()) &&
                    (date.year() == startdate.year()))
                    selected = true;
            }
            else if (m_resolution & kYear)
            {
                date = date.addYears(1);
                text = date.toString("yyyy");
                if (date.year() == startdate.year())
                    selected = true;
            }

            item = new MythUIButtonListItem(m_dateList, text, NULL, false);
            item->SetData(QVariant(date));

            if (selected)
                m_dateList->SetItemCurrent(item);
        }
        m_dateList->SetVisible(true);
    }

    // Time
    if (kNoTime != (m_resolution & 0xF0))
    {
        QDate startdate(m_startTime.toLocalTime().date());
        QTime starttime(m_startTime.toLocalTime().time());
        QTime time(0,0,0);
        QString text;
        bool selected = false;

        int limit = (m_resolution & kMinutes) ? (60 * 24) : 24;

        for (int x = 0; x < limit; x++)
        {
            selected = false;
            if (m_resolution & kMinutes)
            {
//.........这里部分代码省略.........
开发者ID:JGunning,项目名称:OpenAOL-TV,代码行数:101,代码来源:mythdialogbox.cpp

示例7: QDate

QList<int> tradeDateCalendar::computeFrequencyTradeMonthly(int date_, int minimumDate_, int maximumDate_)
{
    QList<int> tradeDates;

    QDate monthDayCounter = QDate::fromJulianDay(minimumDate_);
    int dayOfMonth = QDate::fromJulianDay(date_).day();

    forever
    {
        QDate monthDayComputation = monthDayCounter;
        if (monthDayComputation.day() > dayOfMonth)
            monthDayComputation = monthDayComputation.addMonths(1);

        if (dayOfMonth > monthDayComputation.daysInMonth())
        {
            monthDayComputation = monthDayComputation.addMonths(1);
            monthDayComputation = QDate(monthDayComputation.year(), monthDayComputation.month(), 1);
        }
        else
            monthDayComputation = QDate(monthDayComputation.year(), monthDayComputation.month(), dayOfMonth);

        date_ = checkTradeDate(monthDayComputation.toJulianDay(), direction_ascending);
        if (date_ > maximumDate_)
            break;

        tradeDates.append(date_);
        monthDayCounter = monthDayCounter.addMonths(1);
    }

    return tradeDates;
}
开发者ID:choff97,项目名称:mypersonalindex,代码行数:31,代码来源:tradeDateCalendar.cpp

示例8: QDate

//! [17]
void MainWindow::setYear(QDate date)
{
    selectedDate = QDate(date.year(), selectedDate.month(), selectedDate.day());
    insertCalendar();
}
开发者ID:RobertoMalatesta,项目名称:emscripten-qt,代码行数:6,代码来源:mainwindow.cpp

示例9: setExpirationDate

//! Change the map expiration date
void AdditionalMap::setExpirationDate(QDate date)
{
  _data.expirationYear  = date.year();
  _data.expirationMonth = date.month();
  _data.expirationDay   = date.day();
}
开发者ID:gqueiroz,项目名称:terrama2,代码行数:7,代码来源:AdditionalMap.cpp

示例10: GenLedger

void MakeDeposits::processSelections()
{
    if (selTotal <= 0.00) return;

    GenLedger   *GL = new GenLedger();
    int         srcAcct, dstAcct = 0;
    ADB         DB;
    QDate       selDate = transDate->date();
    char        tDate[1024];

    strcpy(tDate, selDate.toString("yyyy-MM-dd").ascii());

    // Setup the base GL transaction
    GL->BaseDesc = "Deposit";

    // Get the source and destination accounts.
    // The source will be our Undeposited Funds account.
    srcAcct = atol(cfgVal("UndepositedFundsAcct"));
    dstAcct = accountIDX[targetAccountList->currentItem()];

    // Now, setup the transaction.
    // Start by walking through each of the undeposited items and
    // then adding a split item for it.
    Q3ListViewItem   *curItem;
    //int nameCol  = 2;
    //int numCol   = 3;
    int amtCol   = 4;
    int intIDCol = 5;
    char tmpStr[1024];
    selTotal = 0.00;
    curItem = paymentList->firstChild();
    while (curItem != NULL) {
        if (curItem->isSelected()) {
            selTotal += atof(curItem->key(amtCol,0));
        }
        curItem = curItem->itemBelow();
    }
    // Add the first half of our split
    GL->AddSplit();
    GL->CurrentSplit->IntAccountNo.setNum(srcAcct);
    GL->CurrentSplit->Amount.setNum(selTotal * -1.0);
    GL->CurrentSplit->TransType.setNum(TRANSTYPE_DEPOSIT);
    GL->CurrentSplit->TransTypeLink.setNum(0);
    GL->CurrentSplit->TransDate = selDate.toString("yyyy-MM-dd");
    GL->CurrentSplit->BilledDate = selDate.toString("yyyy-MM-dd");
    GL->CurrentSplit->DueDate = selDate.toString("yyyy-MM-dd");
    GL->CurrentSplit->Cleared.setNum(0);
    GL->CurrentSplit->Number.setNum(0);
    GL->CurrentSplit->NumberStr = "";
    GL->CurrentSplit->ItemID.setNum(0);
    GL->CurrentSplit->Quantity.setNum(1);
    GL->CurrentSplit->Price.setNum(selTotal);
    sprintf(tmpStr, "Deposit of $%.2f on %s", selTotal, selDate.toString("yyyy-MM-dd").ascii());
    GL->CurrentSplit->Memo = tmpStr;

    // Now, setup the other "half" of our transaction.
    GL->AddSplit();
    GL->CurrentSplit->IntAccountNo.setNum(dstAcct);
    GL->CurrentSplit->Amount.setNum(selTotal);
    GL->CurrentSplit->TransType.setNum(TRANSTYPE_DEPOSIT);
    GL->CurrentSplit->TransTypeLink.setNum(0);
    GL->CurrentSplit->TransDate = selDate.toString("yyyy-MM-dd").ascii();
    GL->CurrentSplit->BilledDate = selDate.toString("yyyy-MM-dd").ascii();
    GL->CurrentSplit->DueDate = selDate.toString("yyyy-MM-dd").ascii();
    GL->CurrentSplit->Cleared.setNum(0);
    GL->CurrentSplit->Number.setNum(0);
    GL->CurrentSplit->NumberStr = "0";
    GL->CurrentSplit->ItemID.setNum(0);
    GL->CurrentSplit->Quantity.setNum(1);
    GL->CurrentSplit->Price.setNum(selTotal);
    sprintf(tmpStr, "Deposit of $%.2f on %s", selTotal, selDate.toString("yyyy-MM-dd").ascii());
    GL->CurrentSplit->Memo = tmpStr;

    // Finally, save the entire transaction.
    GL->SaveTrans();

    // Now, walk throught the list one more time and update the 
    // undeposited funds with the linked transaction and set them to be
    // cleared.

    curItem = paymentList->firstChild();
    while (curItem != NULL) {
        if (curItem->isSelected()) {
            DB.dbcmd("update GL set LinkedTrans = %ld, Cleared = 1 where InternalID = %ld", GL->TransID, atol(curItem->key(intIDCol, 0)));
        }
        curItem = curItem->itemBelow();
    }

    // All done, close the window.
    close();

}
开发者ID:gottafixthat,项目名称:tacc,代码行数:92,代码来源:MakeDeposits.cpp

示例11: listInvoicesToTable

/**
	Affiche les factures
	@param filter, filtre a appliquer
	@param field, champ ou appliquer le filtre
*/
void DialogInvoiceList::listInvoicesToTable(QDate mdate) {
	invoice::InvoicesBook ilist;

	//Clear les items, attention tjs utiliser la fonction clear()
	ui->tableWidget_Invoices->clear();
	for (int i=ui->tableWidget_Invoices->rowCount()-1; i >= 0; --i)
		ui->tableWidget_Invoices->removeRow(i);
	for (int i=ui->tableWidget_Invoices->columnCount()-1; i>=0; --i)
		ui->tableWidget_Invoices->removeColumn(i);

	ui->tableWidget_Invoices->setSortingEnabled(false);
	//Style de la table de facture
	ui->tableWidget_Invoices->setColumnCount( COL_COUNT );
	ui->tableWidget_Invoices->setColumnWidth( COL_DESCRIPTION, 250 );
#ifdef QT_NO_DEBUG
	ui->tableWidget_Invoices->setColumnHidden(COL_ID , true); //cache la colonne ID ou DEBUG
#endif
	ui->tableWidget_Invoices->setSelectionBehavior(QAbstractItemView::SelectRows);
	ui->tableWidget_Invoices->setSelectionMode(QAbstractItemView::SingleSelection);
	ui->tableWidget_Invoices->setEditTriggers(QAbstractItemView::NoEditTriggers);
	QStringList titles;
	titles  << tr("Id") << tr("sélection") << tr("Date") << tr("Code Facture") << tr("Client") << tr("Description")  << tr("Montant") << tr("TTC") << QLatin1String("Règlement");
	ui->tableWidget_Invoices->setHorizontalHeaderLabels( titles );
	if(!m_data->getIsTax()) {
		ui->tableWidget_Invoices->setColumnHidden(COL_PRICE_TAX , true);
	}
	//Recuperation des donnees presentent dans la bdd
	m_invoice->getInvoices(ilist, QString::number(mdate.year()), QString::number(mdate.month()));

	// list all customers
	QString typeP;
	for(int i=0; i<ilist.code.count(); i++){

		ItemOfTable *item_ID           = new ItemOfTable();
		ItemOfTable *item_State        = new ItemOfTable();
		ItemOfTable *item_DATE         = new ItemOfTable();
		ItemOfTable *item_CODE         = new ItemOfTable();
		ItemOfTable *item_CUSTOMER     = new ItemOfTable();
		ItemOfTable *item_DESCRIPTION  = new ItemOfTable();
		ItemOfTable *item_PRICE        = new ItemOfTable();
		ItemOfTable *item_PRICE_TAX    = new ItemOfTable();
		ItemOfTable *item_TYPE_PAYMENT = new ItemOfTable();
		
		item_ID->setData(Qt::DisplayRole, ilist.id.at(i));
		item_State -> setData(Qt::CheckStateRole, Qt::Checked);
		item_DATE->setData(Qt::DisplayRole, ilist.userDate.at(i)/*.toString(tr("dd/MM/yyyy"))*/);
		item_CODE->setData(Qt::DisplayRole, ilist.code.at(i));
		if(ilist.customerFirstName.at(i).isEmpty())
			item_CUSTOMER->setData(Qt::DisplayRole, ilist.customerLastName.at(i));
		else
			item_CUSTOMER->setData(Qt::DisplayRole, ilist.customerFirstName.at(i) +" "+ilist.customerLastName.at(i));

		item_DESCRIPTION->setData(Qt::DisplayRole, ilist.description.at(i));
		item_PRICE->setData(Qt::DisplayRole, ilist.price.at(i) - ilist.part_payment.at(i));
		item_PRICE_TAX->setData(Qt::DisplayRole, ilist.priceTax.at(i) - ilist.part_paymentTax.at(i));

		typeP="";
		if( ilist.typePayment.at(i) == MCERCLE::CASH)         typeP = tr("Espece");
		if( ilist.typePayment.at(i) == MCERCLE::CHECK)        typeP = tr("Cheque");
		if( ilist.typePayment.at(i) == MCERCLE::CREDIT_CARD)  typeP = tr("CB");
		if( ilist.typePayment.at(i) == MCERCLE::INTERBANK)    typeP = tr("TIP");
		if( ilist.typePayment.at(i) == MCERCLE::TRANSFER)     typeP = tr("Virement");
		if( ilist.typePayment.at(i) == MCERCLE::DEBIT)        typeP = tr("Prelevement");
		if( ilist.typePayment.at(i) == MCERCLE::OTHER)        typeP = tr("Autre");

		item_TYPE_PAYMENT->setData(Qt::DisplayRole, typeP);

		//definir le tableau
		ui->tableWidget_Invoices->setRowCount(i+1);

		//remplir les champs
		ui->tableWidget_Invoices->setItem(i, COL_ID, item_ID);
		ui->tableWidget_Invoices->setItem(i, COL_STATE, item_State);
		ui->tableWidget_Invoices->setItem(i, COL_DATE, item_DATE);
		ui->tableWidget_Invoices->setItem(i, COL_CODE, item_CODE);
		ui->tableWidget_Invoices->setItem(i, COL_CUSTOMER, item_CUSTOMER);
		ui->tableWidget_Invoices->setItem(i, COL_DESCRIPTION, item_DESCRIPTION);
		ui->tableWidget_Invoices->setItem(i, COL_PRICE, item_PRICE);
		ui->tableWidget_Invoices->setItem(i, COL_PRICE_TAX, item_PRICE_TAX);
		ui->tableWidget_Invoices->setItem(i, COL_TYPE_PAYMENT, item_TYPE_PAYMENT);
	}
	ui->tableWidget_Invoices->setSortingEnabled(true);
	ui->tableWidget_Invoices->selectRow(0);
}
开发者ID:cfdev,项目名称:mcercle,代码行数:89,代码来源:dialoginvoicelist.cpp

示例12: QRegExp

int CSVOldFormatConverter::getTroopId(
    QString troopName, QString graduatedFromMilitaryDepartmentDate,
    QString degreeEnrollmentNumber,
    QString graduatedFromMilitaryDepartmentInYear) {
  // TODO: refactor this stuff
  QString enteredAtMilitaryDepartmentDate;
  QString troopNamePrefix;
  QString troopNamePostfix;
  QRegExp shortPostfix = QRegExp("\\d\\d");
  QRegExp longPostfix = QRegExp("\\d\\d/\\d\\d");
  QRegExp degreeSplitter = QRegExp("№ ?\\d{1,4} ?(от)? ?");
  QDate dateEnteredAt;
  QDate dateGraduatedFrom;
  QString queryString;
  QSqlQuery query;
  QString formattedTroopName;
  int separatorPosition;
  int difference;
  troopName = troopName.toUpper().simplified();
  if (troopName == "АШ32") {
    troopName = "АШ-32";
  } else if (troopName.isEmpty()) {
    qDebug() << graduatedFromMilitaryDepartmentDate << degreeEnrollmentNumber <<
                graduatedFromMilitaryDepartmentInYear;
    return 0;
  }
  if (!graduatedFromMilitaryDepartmentDate.simplified().isEmpty()) {
    graduatedFromMilitaryDepartmentDate =
        graduatedFromMilitaryDepartmentDate.split(" ").at(0);
    dateGraduatedFrom = QDate::fromString(graduatedFromMilitaryDepartmentDate,
                                          "dd.MM.yyyy");
  } else if (!graduatedFromMilitaryDepartmentInYear.isEmpty()) {
    if (graduatedFromMilitaryDepartmentInYear != "0") {
      dateGraduatedFrom.setDate(
            graduatedFromMilitaryDepartmentInYear.toInt(), 9, 17);
    }
  }
  if (!degreeEnrollmentNumber.isEmpty()) {
    enteredAtMilitaryDepartmentDate = degreeEnrollmentNumber
        .split(degreeSplitter).last().replace("ю", ".").replace(" ", ".");
    if (enteredAtMilitaryDepartmentDate.endsWith("г.")) {
      enteredAtMilitaryDepartmentDate.chop(2);
    } else if (enteredAtMilitaryDepartmentDate.endsWith("г")) {
      enteredAtMilitaryDepartmentDate.chop(1);
    } else if (enteredAtMilitaryDepartmentDate.endsWith(".")) {
      enteredAtMilitaryDepartmentDate.chop(1);
    }
    if (enteredAtMilitaryDepartmentDate.split(".").last().length() == 2) {
      enteredAtMilitaryDepartmentDate = enteredAtMilitaryDepartmentDate.insert(
            enteredAtMilitaryDepartmentDate.length() - 2, "20");
    }
    dateEnteredAt = QDate::fromString(enteredAtMilitaryDepartmentDate,
                                      "d.MM.yyyy");
  }
  if (!dateGraduatedFrom.isValid() && !dateEnteredAt.isValid()) {
    qDebug() << "invalid dates" << dateEnteredAt << dateGraduatedFrom;
    return 0;
  } else if (dateGraduatedFrom.isValid()) {
    // guessing about entered date
    dateEnteredAt.setDate(dateGraduatedFrom.year() - 3, 6, 29);
  } else { // if (dateEnteredAt.isValid())
    dateGraduatedFrom.setDate(dateEnteredAt.year() + 3, 9, 17);
//    qDebug() << "invalid graduation date";
//    return 0;
  }
  int cyear = QDate::currentDate().year();
  if (cyear > dateGraduatedFrom.year()) {
    cyear = dateGraduatedFrom.year();
  }
  difference = cyear - dateEnteredAt.year() - 1;
  separatorPosition = troopName.indexOf('-');
  troopNamePrefix = troopName.left(separatorPosition);
  troopNamePostfix = troopName.mid(separatorPosition + 1);
  formattedTroopName = troopNamePrefix + "-";
  if (shortPostfix.exactMatch(troopNamePostfix)) {
    // TODO: make that more cleaner and optimized
    formattedTroopName +=
        "<N:" +
        QString::number(QString(troopNamePostfix.at(0)).toInt() - difference) +
        ">" + troopNamePostfix.at(1);
  } else if (longPostfix.exactMatch(troopNamePostfix)) {
    formattedTroopName +=
        "<N:" +
        QString::number(QString(troopNamePostfix.at(0)).toInt() - difference) +
        ">" + troopNamePostfix.at(1) + "/" + "<N:" +
        QString::number(QString(troopNamePostfix.at(3)).toInt() - difference) +
        ">" + troopNamePostfix.at(4);
  } else {
    qDebug() << "asshole" << troopNamePostfix << troopName;
    return 0;
  }
  troopName = formattedTroopName;
  queryString = "SELECT id FROM troop WHERE name = ? AND"
      " entered_at_military_department_date = ?";
  query.prepare(queryString);
  query.addBindValue(troopName);
  query.addBindValue(dateEnteredAt);
  if (!query.exec()) {
    qDebug() << query.lastError().text();
    return 0;
//.........这里部分代码省略.........
开发者ID:39dotyt,项目名称:military-department-journal,代码行数:101,代码来源:csvoldformatconverter.cpp

示例13: kil

void KOWhatsNextView::updateView()
{
    KIconLoader kil("kdepim");
    QString *ipath = new QString();
    kil.loadIcon("kdepim", KIcon::NoGroup, 32, KIcon::DefaultState, ipath);

    mText = "<table width=\"100%\">\n";
    mText += "<tr bgcolor=\"#3679AD\"><td><h1>";
    mText += "<img src=\"";
    mText += *ipath;
    mText += "\">";
    mText += "<font color=\"white\"> ";
    mText += i18n("What's Next?") + "</font></h1>";
    mText += "</td></tr>\n<tr><td>";

    mText += "<h2>";
    if(mStartDate.daysTo(mEndDate) < 1)
    {
        mText += KGlobal::locale()->formatDate(mStartDate);
    }
    else
    {
        mText += i18n("Date from - to", "%1 - %2")
                 .arg(KGlobal::locale()->formatDate(mStartDate))
                 .arg(KGlobal::locale()->formatDate(mEndDate));
    }
    mText += "</h2>\n";

    Event::List events;
    for(QDate date = mStartDate; date <= mEndDate; date = date.addDays(1))
        events += calendar()->events(date, EventSortStartDate, SortDirectionAscending);

    if(events.count() > 0)
    {
        mText += "<p></p>";
        kil.loadIcon("appointment", KIcon::NoGroup, 22, KIcon::DefaultState, ipath);
        mText += "<h2><img src=\"";
        mText += *ipath;
        mText += "\">";
        mText += i18n("Events:") + "</h2>\n";
        mText += "<table>\n";
        Event::List::ConstIterator it;
        for(it = events.begin(); it != events.end(); ++it)
        {
            Event *ev = *it;
            if(!ev->doesRecur())
            {
                appendEvent(ev);
            }
            else
            {
                // FIXME: This should actually be cleaned up. Libkcal should
                // provide a method to return a list of all recurrences in a
                // given time span.
                Recurrence *recur = ev->recurrence();
                int duration = ev->dtStart().secsTo(ev->dtEnd());
                QDateTime start = recur->getPreviousDateTime(
                                      QDateTime(mStartDate, QTime()));
                QDateTime end = start.addSecs(duration);
                if(end.date() >= mStartDate)
                {
                    appendEvent(ev, start, end);
                }
                start = recur->getNextDateTime(start);
                while(start.isValid() && start.date() <= mEndDate)
                {
                    appendEvent(ev, start);
                    start = recur->getNextDateTime(start);
                }
            }
        }
        mText += "</table>\n";
    }

    mTodos.clear();
    Todo::List todos = calendar()->todos(TodoSortDueDate, SortDirectionAscending);
    if(todos.count() > 0)
    {
        kil.loadIcon("todo", KIcon::NoGroup, 22, KIcon::DefaultState, ipath);
        mText += "<h2><img src=\"";
        mText += *ipath;
        mText += "\">";
        mText += i18n("To-do:") + "</h2>\n";
        mText += "<ul>\n";
        Todo::List::ConstIterator it;
        for(it = todos.begin(); it != todos.end(); ++it)
        {
            Todo *todo = *it;
            if(!todo->isCompleted() && todo->hasDueDate() && todo->dtDue().date() <= mEndDate)
                appendTodo(todo);
        }
        bool gotone = false;
        int priority = 1;
        while(!gotone && priority <= 9)
        {
            for(it = todos.begin(); it != todos.end(); ++it)
            {
                Todo *todo = *it;
                if(!todo->isCompleted() && (todo->priority() == priority))
                {
//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:101,代码来源:kowhatsnextview.cpp

示例14: alignDate

/*!
  Align a date/time value for a step size

  For Qt::Day alignments there is no "natural day 0" -
  instead the first day of the year is used to avoid jumping
  major ticks positions when panning a scale. For other alignments
  ( f.e according to the first day of the month ) alignDate()
  has to be overloaded.

  \param dateTime Date/time value
  \param stepSize Step size
  \param intervalType Interval type
  \param up When true dateTime is ceiled - otherwise it is floored

  \return Aligned date/time value
 */
QDateTime QwtDateScaleEngine::alignDate(
    const QDateTime &dateTime, double stepSize,
    QwtDate::IntervalType intervalType, bool up ) const
{
    // what about: (year == 1582 && month == 10 && day > 4 && day < 15) ??

    QDateTime dt = dateTime;

    if ( dateTime.timeSpec() == Qt::OffsetFromUTC )
    {
        dt.setUtcOffset( 0 );
    }

    switch( intervalType )
    {
        case QwtDate::Millisecond:
        {
            const int ms = qwtAlignValue(
                dt.time().msec(), stepSize, up ) ;

            dt = QwtDate::floor( dateTime, QwtDate::Second );
            dt = dt.addMSecs( ms );

            break;
        }
        case QwtDate::Second:
        {
            int second = dt.time().second();
            if ( up )
            {
                if ( dt.time().msec() > 0 )
                    second++;
            }

            const int s = qwtAlignValue( second, stepSize, up );

            dt = QwtDate::floor( dt, QwtDate::Minute );
            dt = dt.addSecs( s );

            break;
        }
        case QwtDate::Minute:
        {
            int minute = dt.time().minute();
            if ( up )
            {
                if ( dt.time().msec() > 0 || dt.time().second() > 0 )
                    minute++;
            }

            const int m = qwtAlignValue( minute, stepSize, up );

            dt = QwtDate::floor( dt, QwtDate::Hour );
            dt = dt.addSecs( m * 60 );

            break;
        }
        case QwtDate::Hour:
        {
            int hour = dt.time().hour();
            if ( up )
            {
                if ( dt.time().msec() > 0 || dt.time().second() > 0
                    || dt.time().minute() > 0 )
                {
                    hour++;
                }
            }
            const int h = qwtAlignValue( hour, stepSize, up );

            dt = QwtDate::floor( dt, QwtDate::Day );
            dt = dt.addSecs( h * 3600 );

            break;
        }
        case QwtDate::Day:
        {
            // What date do we expect f.e. from an alignment of 5 days ??
            // Aligning them to the beginning of the year avoids at least
            // jumping major ticks when panning

            int day = dt.date().dayOfYear();
            if ( up )
            {
//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:Qwt_trunk,代码行数:101,代码来源:qwt_date_scale_engine.cpp

示例15: timeToMSecs

// Converts a date/time value into msecs
static inline qint64 timeToMSecs(const QDate &date, const QTime &time)
{
    return ((date.toJulianDay() - JULIAN_DAY_FOR_EPOCH) * MSECS_PER_DAY)
           + time.msecsSinceStartOfDay();
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:6,代码来源:qtimezoneprivate_win.cpp


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