本文整理汇总了C++中QDate::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ QDate::isValid方法的具体用法?C++ QDate::isValid怎么用?C++ QDate::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDate
的用法示例。
在下文中一共展示了QDate::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintTask
void TaskItemDelegate::paintTask(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex& index) const
{
QRect rect = option.rect;
QFontMetrics fm = QApplication::fontMetrics();
// Painting Order:
// Background wash
// Mouseover highlight
// Priority Tab on left
// Bounding Box
// Task name
// If not small, other task information
painter->save();
if (smallTasks) { // Paint the background for a small task
painter->save();
painter->setOpacity(0.7);
painter->setBrush(itemPriorityColor(index));
painter->setPen(Qt::NoPen);
painter->drawRect(rect.adjusted(leftMargin, MARGIN, -MARGIN, -MARGIN));
painter->restore();
}
else { // Paint the background for a two row task
painter->save();
painter->setOpacity(0.7);
painter->setBrush(Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor));
painter->drawRect(option.rect.adjusted(leftMargin, MARGIN, -MARGIN, -MARGIN));
painter->restore();
painter->drawRect(QRectF(option.rect.topLeft()+QPointF(leftMargin, MARGIN), option.rect.bottomLeft()+QPointF(COLORTAB, -MARGIN)));
}
if (option.state & QStyle::State_MouseOver) {
painter->save();
painter->setBrush(Plasma::Theme::defaultTheme()->color(Plasma::Theme::HighlightColor));
painter->setPen(Qt::NoPen);
if (smallTasks)
painter->drawRect(rect.adjusted(leftMargin, MARGIN, -MARGIN, -MARGIN));
else
painter->drawRect(rect.adjusted(leftMargin, MARGIN, -MARGIN, -MARGIN));
painter->restore();
}
// Draw Task information
painter->setPen(Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor));
QString task = index.data(Qt::RTMNameRole).toString();
QString due = index.data(Qt::RTMDueRole).toDate().toString("MMM d");
QString tags = index.data(Qt::RTMTagsRole).toStringList().join(", ");
if (!tags.isEmpty())
tags.prepend(tagsPrefix);
QFont font = painter->font();
font.setPointSize(font.pointSize());
QFontMetrics largerFM(font);
QDate date = index.data(Qt::RTMDueRole).toDate();
if (smallTasks && date.isValid() && date < QDate::currentDate()) {
// Elide (text with dots like th...) if wider than view and draw
font.setBold(true);
QFontMetrics boldLargerFM(font);
due = due.append(" "); // So that we have a space after the date before the task name
task = largerFM.elidedText(task, Qt::ElideRight, option.rect.width()-COLORTAB-3*MARGIN - boldLargerFM.width(due));
painter->setFont(font);
painter->drawText(option.rect.topLeft()+QPoint(COLORTAB+MARGIN,largerFM.height()),due);
font.setBold(false);
painter->setFont(font);
painter->drawText(option.rect.topLeft()+QPoint(COLORTAB+3*MARGIN + boldLargerFM.width(due),boldLargerFM.height()),task);
}
else {
// Elide (text with dots like th...) if wider than view and draw
task = largerFM.elidedText(task, Qt::ElideRight, option.rect.width()-COLORTAB-3*MARGIN);
painter->setFont(font);
painter->drawText(option.rect.topLeft()+QPoint(COLORTAB+MARGIN,largerFM.height()),task);
}
if (smallTasks) {
painter->restore();
return;
}
// Set our smaller attributes and blue hue for additional text
font.setPointSize(font.pointSize()-1);
font.setItalic(true);
painter->setFont(font);
fm = QFontMetrics(font);
QColor moreText(Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor));
qreal red = moreText.redF();
qreal green = moreText.greenF();
qreal blue = moreText.blueF();
qreal colorChangeMult = 0.85;
if (blue < colorChangeMult)
blue /= colorChangeMult;
else {
red *= colorChangeMult;
green *= colorChangeMult;
}
//.........这里部分代码省略.........
示例2: dateFromString
QDate QQmlStringConverters::dateFromString(const QString &s, bool *ok)
{
QDate d = QDate::fromString(s, Qt::ISODate);
if (ok) *ok = d.isValid();
return d;
}
示例3: readMetadata
void IPTCOrigin::readMetadata(QByteArray& iptcData)
{
blockSignals(true);
KExiv2 exiv2Iface;
exiv2Iface.setIptc(iptcData);
QString data;
QStringList code, list;
QDate date;
QTime time;
QString dateStr, timeStr;
dateStr = exiv2Iface.getIptcTagString("Iptc.Application2.DateCreated", false);
timeStr = exiv2Iface.getIptcTagString("Iptc.Application2.TimeCreated", false);
d->dateCreatedSel->setDate(QDate::currentDate());
d->dateCreatedCheck->setChecked(false);
if (!dateStr.isEmpty())
{
date = QDate::fromString(dateStr, Qt::ISODate);
if (date.isValid())
{
d->dateCreatedSel->setDate(date);
d->dateCreatedCheck->setChecked(true);
}
}
d->dateCreatedSel->setEnabled(d->dateCreatedCheck->isChecked());
d->syncHOSTDateCheck->setEnabled(d->dateCreatedCheck->isChecked());
d->syncEXIFDateCheck->setEnabled(d->dateCreatedCheck->isChecked());
d->timeCreatedSel->setTime(QTime::currentTime());
d->timeCreatedCheck->setChecked(false);
if (!timeStr.isEmpty())
{
time = QTime::fromString(timeStr, Qt::ISODate);
if (time.isValid())
{
d->timeCreatedSel->setTime(time);
d->timeCreatedCheck->setChecked(true);
}
}
d->timeCreatedSel->setEnabled(d->timeCreatedCheck->isChecked());
dateStr = exiv2Iface.getIptcTagString("Iptc.Application2.DigitizationDate", false);
timeStr = exiv2Iface.getIptcTagString("Iptc.Application2.DigitizationTime", false);
d->dateDigitalizedSel->setDate(QDate::currentDate());
d->dateDigitalizedCheck->setChecked(false);
if (!dateStr.isEmpty())
{
date = QDate::fromString(dateStr, Qt::ISODate);
if (date.isValid())
{
d->dateDigitalizedSel->setDate(date);
d->dateDigitalizedCheck->setChecked(true);
}
}
d->dateDigitalizedSel->setEnabled(d->dateDigitalizedCheck->isChecked());
d->timeDigitalizedSel->setTime(QTime::currentTime());
d->timeDigitalizedCheck->setChecked(false);
if (!timeStr.isEmpty())
{
time = QTime::fromString(timeStr, Qt::ISODate);
if (time.isValid())
{
d->timeDigitalizedSel->setTime(time);
d->timeDigitalizedCheck->setChecked(true);
}
}
d->timeDigitalizedSel->setEnabled(d->timeDigitalizedCheck->isChecked());
code = exiv2Iface.getIptcTagsStringList("Iptc.Application2.LocationCode", false);
for (QStringList::Iterator it = code.begin(); it != code.end(); ++it)
{
QStringList data = d->locationEdit->getData();
QStringList::Iterator it2;
for (it2 = data.begin(); it2 != data.end(); ++it2)
{
if ((*it2).left(3) == (*it))
{
list.append(*it2);
break;
}
}
if (it2 == data.end())
d->locationEdit->setValid(false);
}
d->locationEdit->setValues(list);
d->cityEdit->clear();
d->cityCheck->setChecked(false);
data = exiv2Iface.getIptcTagString("Iptc.Application2.City", false);
if (!data.isNull())
{
d->cityEdit->setText(data);
d->cityCheck->setChecked(true);
}
d->cityEdit->setEnabled(d->cityCheck->isChecked());
//.........这里部分代码省略.........
示例4: setEndDate
void RecurrenceWidget::setEndDate(QDate p)
{
_dates->setEndDate(p.isValid() ? p : _eot.date());
_endTime->setTime(QTime(23, 59, 59, 999));
}
示例5: parseXML
//XML
//Parse XML into tasklist form
int TaskList_Main::parseXML(QDomDocument &domTree){
QDomElement set = domTree.namedItem("listset").toElement();
QMessageBox msgBox;
//If tree doesn't exist, stop
if(set.isNull()){
msgBox.setText("No <listset> element at top level");
msgBox.setWindowTitle("Erorr parsing XML");
msgBox.exec();
return -1;
}
//Iterate through all "list" items
QDomElement n = set.firstChildElement("list");
for( ; !n.isNull(); n = n.nextSiblingElement("list")){
emit createList(n.namedItem("list_title").toElement().text());
delListAction->setEnabled(true);
printAction->setEnabled(true);
printAllAction->setEnabled(true);
//Iterate through all "task" items part of "list"
QDomElement o = n.firstChildElement("task");
for( ; !o.isNull(); o = o.nextSiblingElement("task")){
my_listwidget *currList = notePane->listMap[notePane->currList];
QListWidgetItem *currItem;
QString tempStr;
//If task is 'main' (not subtext/subnote)
if(o.attribute("task_type") == "main"){
//Change task name
notePane->addItemAction(o.namedItem("task_title").toElement().text(), false);
currItem = currList->currentItem();
//Change task check state
tempStr = o.namedItem("task_check").toElement().text();
if(tempStr == "unchecked")
currItem->setCheckState(Qt::Unchecked);
else if (tempStr == "checked")
currItem->setCheckState(Qt::Checked);
else if (tempStr == "part_check")
currItem->setCheckState(Qt::PartiallyChecked);
else{
msgBox.setText("Unknown check state");
msgBox.setWindowTitle("Erorr parsing XML");
msgBox.exec();
return -1;
}
//Change task subnote
currItem->setData(32, QVariant(
o.namedItem("task_note").toElement().text()));
//Change if task subnote is displayed
tempStr = o.namedItem("task_display").toElement().text();
if(tempStr == "false"){
currItem->setData(33, QVariant(false));
currItem->setData(35, QVariant(false));
}
else if(tempStr == "true"){
currItem->setData(33, QVariant(true));
currItem->setData(35, QVariant(true));
}
else{
msgBox.setText("Unknown bool type - display");
msgBox.setWindowTitle("Erorr parsing XML");
msgBox.exec();
return -1;
}
//Change the task due date
tempStr = o.namedItem("task_date").toElement().text();
qDebug((const char *)tempStr.toAscii().data());
QDate tempDate;
int year = tempStr.left(4).toInt();
int month = tempStr.mid(5, 2).toInt();
int day = tempStr.right(2).toInt();
tempDate.setDate(year, month, day);
if(!tempDate.isValid()){
msgBox.setText("Unknown date type");
msgBox.setWindowTitle("Erorr parsing XML");
msgBox.exec();
return -1;
}
currItem->setData(34, QVariant(tempDate));
//Change the task font
tempStr = o.namedItem("task_font").toElement().text();
QFont tempFont;
if(!tempFont.fromString(tempStr)){
msgBox.setText("Unknown font");
msgBox.setWindowTitle("Erorr parsing XML");
msgBox.exec();
return -1;
}
currItem->setFont(tempFont);
}
//Else if it is a subtext/subnote for a 'main'
else if (o.attribute("task_type") == "sub"){
//.........这里部分代码省略.........
示例6: main
//.........这里部分代码省略.........
* Show next happening and exit
*/
if (args->isSet("next")) {
qCDebug(KONSOLEKALENDAR_LOG) << "main | parse options |"
<< "Show next incidence only";
variables.setNext(true);
}
/*
* Set incidence unique string identifier
*/
if (args->isSet("uid")) {
option = args->getOption("uid");
qCDebug(KONSOLEKALENDAR_LOG) << "main | parse options |"
<< "incidence UID:"
<< "(" << option << ")";
variables.setUID(option);
}
/*
* Set starting date for calendar
*/
if (args->isSet("date")) {
option = args->getOption("date");
qCDebug(KONSOLEKALENDAR_LOG) << "main | parse options |"
<< "Start date before conversion:"
<< "(" << option << ")";
startdate = QDate::fromString(option, Qt::ISODate);
if (!startdate.isValid()) {
cout << i18n("Invalid Start Date Specified: %1",
option).toLocal8Bit().data()
<< endl;
return 1;
}
qCDebug(KONSOLEKALENDAR_LOG) << "main | parse options |"
<< "Start date after conversion:"
<< "(" << startdate.toString() << ")";
}
/*
* Set starting time
*/
if (args->isSet("time")) {
option = args->getOption("time");
qCDebug(KONSOLEKALENDAR_LOG) << "main | parse options |"
<< "Start time before conversion :"
<< "(" << option << ")";
if (option.toUpper() != QLatin1String("FLOAT")) {
if (option.count(QLatin1Char(':')) < 2) {
// need to append seconds
option.append(QLatin1String(":00"));
}
starttime = QTime::fromString(option, Qt::ISODate);
if (!starttime.isValid()) {
cout << i18n("Invalid Start Time Specified: %1", option).toLocal8Bit().data()
<< endl;
return 1;
}
qCDebug(KONSOLEKALENDAR_LOG) << "main | parse options |"
示例7: setDateRange
void TimeEntryDialog::setDateRange( const QDate & start, const QDate & end )
{
mStartDateEdit->setDate( start );
mEndDateEdit->setDate( (!end.isValid() || end < start) ? start : end );
}
示例8: slotReceivedQuote
void KEquityPriceUpdateDlg::slotReceivedQuote(const QString& _id, const QString& _symbol, const QDate& _date, const double& _price)
{
QList<QTreeWidgetItem*> foundItems = lvEquityList->findItems(_id, Qt::MatchExactly, ID_COL);
QTreeWidgetItem* item = 0;
if (! foundItems.empty())
item = foundItems.at(0);
QTreeWidgetItem* next = 0;
if (item) {
if (_price > 0.0f && _date.isValid()) {
QDate date = _date;
if (date > QDate::currentDate())
date = QDate::currentDate();
double price = _price;
QString id = _id.toUtf8();
MyMoneySecurity sec;
if (_id.contains(" ") == 0) {
MyMoneySecurity security = MyMoneyFile::instance()->security(id);
QString factor = security.value("kmm-online-factor");
if (!factor.isEmpty()) {
price *= MyMoneyMoney(factor).toDouble();
}
try {
sec = MyMoneyFile::instance()->security(id);
sec = MyMoneyFile::instance()->security(sec.tradingCurrency());
} catch (const MyMoneyException &) {
sec = MyMoneySecurity();
}
} else {
QRegExp splitrx("([0-9a-z\\.]+)[^a-z0-9]+([0-9a-z\\.]+)", Qt::CaseInsensitive);
if (splitrx.indexIn(_id) != -1) {
try {
sec = MyMoneyFile::instance()->security(splitrx.cap(2).toUtf8());
} catch (const MyMoneyException &) {
sec = MyMoneySecurity();
}
}
}
item->setText(PRICE_COL, KGlobal::locale()->formatMoney(price, sec.tradingSymbol(), KMyMoneyGlobalSettings::pricePrecision()));
item->setText(DATE_COL, date.toString(Qt::ISODate));
logStatusMessage(i18n("Price for %1 updated (id %2)", _symbol, _id));
// make sure to make OK button available
btnOK->setEnabled(true);
} else {
logErrorMessage(i18n("Received an invalid price for %1, unable to update.", _symbol));
}
prgOnlineProgress->setValue(prgOnlineProgress->value() + 1);
item->setSelected(false);
// launch the NEXT one ... in case of m_fUpdateAll == false, we
// need to parse the list to find the next selected one
next = lvEquityList->invisibleRootItem()->child(lvEquityList->invisibleRootItem()->indexOfChild(item) + 1);
if (!m_fUpdateAll) {
while (next && !next->isSelected()) {
prgOnlineProgress->setValue(prgOnlineProgress->value() + 1);
next = lvEquityList->invisibleRootItem()->child(lvEquityList->invisibleRootItem()->indexOfChild(next) + 1);
}
}
} else {
logErrorMessage(i18n("Received a price for %1 (id %2), but this symbol is not on the list. Aborting entire update.", _symbol, _id));
}
if (next) {
m_webQuote.launch(next->text(SYMBOL_COL), next->text(ID_COL), next->text(SOURCE_COL));
} else {
finishUpdate();
}
}
示例9: get_copyTgt_List
/*
* name : get_copyTgt_List
* desc : Scan whole source list and target path,
* if path has existed and optionOverwrite is off,
* the source path would removed from list
*/
void PicIn_Core::get_copyTgt_List(void)
{
QFile file;
QString tgtName;
QString tgtPath;
QString yearPath;
QString monthPath;
QString dayPath;
QString srcPath;
QDate date;
QDir dir;
QFileInfoList tempSrcList;
tempSrcList.clear();
m_copyTgtList.clear();
for(int i = 0; i < m_fileInfoList_src.size(); i++){
srcPath = m_fileInfoList_src.at(i).absoluteFilePath();
tgtName.clear();
tgtName.append(m_fileInfoList_src.at(i).fileName());
tgtPath.clear();
tgtPath.append(m_pathList_target.at(0)); // Only support 1 target path
//
// Check whether need to separate pics to folders as date
//
if(checkOption(optionExifDate)){
date = getExifDate(srcPath);
}
if(!date.isValid() || !checkOption(optionExifDate)){
date = m_fileInfoList_src.at(i).lastModified().date();
}
yearPath.clear();
monthPath.clear();
dayPath.clear();
if(checkOption(optionDirYear)){
yearPath.sprintf("/%04d/", date.year());
tgtPath.append(yearPath);
}
if(checkOption(optionDirMon)){
monthPath.sprintf("/%02d/", date.month());
tgtPath.append(monthPath);
}
if(checkOption(optionDirDay)){
dayPath.sprintf("/%02d/", date.day());
tgtPath.append(dayPath);
}
//
// Check whether file need to be copied
//
tgtPath.append(tgtName);
if(!file.exists(tgtPath) || checkOption(optionOverwrite)){
m_copyTgtList.append(tgtPath);
tempSrcList.append(m_fileInfoList_src.at(i));
}
}
m_fileInfoList_src = tempSrcList;
return;
}
示例10: saveUsersList
// METODO Database::saveUsersList
void Database::saveUsersList() const {
QString path( "users.xml" );
QFile file( path );
file.open( QFile::WriteOnly );
QXmlStreamWriter xmlWriter( &file );
xmlWriter.setAutoFormatting( true );
xmlWriter.writeStartDocument();
xmlWriter.writeStartElement( "users" );
QMapIterator<QString, SmartUtente> it( database_rapp->users_list );
while( it.hasNext() ) {
Utente* u = it.next().value().operator ->();
// <user>
xmlWriter.writeStartElement( "user" );
xmlWriter.writeAttribute( "login", u->getUsername() );
if( dynamic_cast<UtenteBasic*>( u ) )
xmlWriter.writeAttribute( "type", "basic" );
else if( dynamic_cast<UtenteExecutive*>( u ) )
xmlWriter.writeAttribute( "type", "executive" );
else if( dynamic_cast<UtenteBusiness*>( u ) )
xmlWriter.writeAttribute( "type", "business" );
// <profile>
xmlWriter.writeStartElement( "profile" );
xmlWriter.writeTextElement( "name", u->getName() );
xmlWriter.writeTextElement( "surname", u->getSurname() );
// <birthday>
xmlWriter.writeStartElement( "birthday" );
QDate birthday = u->getBirthday();
if( birthday.isValid() ) {
QStringList list = birthday.toString( "yyyy/MM/dd" ).split( "/" );
xmlWriter.writeTextElement( "year", list[0] );
xmlWriter.writeTextElement( "month", list[1] );
xmlWriter.writeTextElement( "day", list[2] );
}
xmlWriter.writeEndElement();
// </birthday>
xmlWriter.writeTextElement( "maritialStatus", u->getMaritialStatus() );
xmlWriter.writeEndElement();
// </profile>
// <net>
xmlWriter.writeStartElement( "net" );
QVectorIterator<SmartUtente> contacts_it( u->getContactsList() );
while( contacts_it.hasNext() ) {
xmlWriter.writeTextElement( "contact", contacts_it.next()->getUsername() );
}
xmlWriter.writeEndElement();
// </net>
// <educations>
xmlWriter.writeStartElement( "educations" );
Formazione::Iteratore educations_it( u->getEducationsIterator() );
while( educations_it.hasNext() ) {
// <title>
SmartTitolo t = educations_it.next();
xmlWriter.writeStartElement( "title" );
xmlWriter.writeTextElement( "school", t->getSchool());
// <dateAttended>
xmlWriter.writeStartElement( "dateAttended" );
QDate d = t->getDateAttended();
if( d.isValid() ) {
QStringList list = d.toString( "yyyy/MM/dd" ).split( "/" );
xmlWriter.writeTextElement( "year", list[0] );
xmlWriter.writeTextElement( "month", list[1] );
xmlWriter.writeTextElement( "day", list[2] );
}
xmlWriter.writeEndElement();
// </dateAttended>
xmlWriter.writeTextElement( "fieldOfStudy", t->getFieldOfStudy() );
xmlWriter.writeEndElement();
// </title>
}
xmlWriter.writeEndElement();
// </educations>
// <experiences>
xmlWriter.writeStartElement( "experiences" );
Esperienza::Iteratore it_ex( u->getExperiencesIterator() );
while( it_ex.hasNext() ) {
// <job>
SmartLavoro j = it_ex.next();
xmlWriter.writeStartElement( "job" );
xmlWriter.writeTextElement( "companyName", j->getCompanyName() );
xmlWriter.writeTextElement( "title", j->getTitle() );
// <begin>
xmlWriter.writeStartElement( "begin" );
QDate begin = j->getBegin();
if( begin.isValid() ) {
QStringList list = begin.toString( "yyyy/MM/dd" ).split( "/" );
xmlWriter.writeTextElement( "year", list[0] );
xmlWriter.writeTextElement( "month", list[1] );
xmlWriter.writeTextElement( "day", list[2] );
//.........这里部分代码省略.........
示例11: sPostCashrcpt
void arWorkBench::sPostCashrcpt()
{
XSqlQuery arPostCashrcpt;
int journalNumber = -1;
bool changeDate = false;
QDate newDate = QDate();
if (_privileges->check("ChangeCashRecvPostDate"))
{
getGLDistDate newdlg(this, "", TRUE);
newdlg.sSetDefaultLit(tr("Distribution Date"));
if (newdlg.exec() == XDialog::Accepted)
{
newDate = newdlg.date();
changeDate = (newDate.isValid());
}
else
return;
}
arPostCashrcpt.exec("BEGIN;");
arPostCashrcpt.exec("SELECT fetchJournalNumber('C/R') AS journalnumber;");
if (arPostCashrcpt.first())
journalNumber = arPostCashrcpt.value("journalnumber").toInt();
else if (arPostCashrcpt.lastError().type() != QSqlError::NoError)
{
systemError(this, arPostCashrcpt.lastError().databaseText(), __FILE__, __LINE__);
return;
}
XSqlQuery setDate;
setDate.prepare("UPDATE cashrcpt SET cashrcpt_distdate=:distdate,"
" cashrcpt_applydate=CASE WHEN (cashrcpt_applydate < :distdate) THEN :distdate"
" ELSE cashrcpt_applydate END "
"WHERE cashrcpt_id=:cashrcpt_id;");
QList<XTreeWidgetItem*> selected = _cashrcpt->selectedItems();
for (int i = 0; i < selected.size(); i++)
{
int id = ((XTreeWidgetItem*)(selected[i]))->id();
if (changeDate)
{
setDate.bindValue(":distdate", newDate);
setDate.bindValue(":cashrcpt_id", id);
setDate.exec();
ErrorReporter::error(QtCriticalMsg, this, tr("Changing Dist. Date"),
setDate, __FILE__, __LINE__);
}
}
for (int i = 0; i < selected.size(); i++)
{
arPostCashrcpt.prepare("SELECT postCashReceipt(:cashrcpt_id, :journalNumber) AS result;");
arPostCashrcpt.bindValue(":cashrcpt_id", ((XTreeWidgetItem*)(selected[i]))->id());
arPostCashrcpt.bindValue(":journalNumber", journalNumber);
arPostCashrcpt.exec();
if (arPostCashrcpt.first())
{
int result = arPostCashrcpt.value("result").toInt();
if (result < 0)
{
systemError(this, storedProcErrorLookup("postCashReceipt", result),
__FILE__, __LINE__);
arPostCashrcpt.exec("ROLLBACK;");
return;
}
}
else if (arPostCashrcpt.lastError().type() != QSqlError::NoError)
{
systemError(this, arPostCashrcpt.lastError().databaseText(), __FILE__, __LINE__);
arPostCashrcpt.exec("ROLLBACK;");
return;
}
}
arPostCashrcpt.exec("COMMIT;");
sFillList();
}
示例12: retrieveValue
//.........这里部分代码省略.........
QAbstractSlider *slider = qobject_cast<QAbstractSlider *>( widget );
if ( slider )
{
text = QString::number( slider->value() );
}
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox *>( widget );
if ( dsb )
{
text = QString::number( dsb->value() );
}
QCheckBox *ckb = qobject_cast<QCheckBox *>( widget );
if ( ckb )
{
QPair<QString, QString> states = vl->checkedState( idx );
text = ckb->isChecked() ? states.first : states.second;
}
QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( widget );
if ( cw )
{
text = cw->selectedDate().toString();
}
le = widget->findChild<QLineEdit *>();
if ( le )
{
text = le->text();
}
switch ( theField.type() )
{
case QVariant::Int:
{
bool ok;
int myIntValue = text.toInt( &ok );
if ( ok && !text.isEmpty() )
{
value = QVariant( myIntValue );
modified = true;
}
else if ( modified )
{
value = QVariant();
}
}
break;
case QVariant::LongLong:
{
bool ok;
qlonglong myLongValue = text.toLong( &ok );
if ( ok && !text.isEmpty() )
{
value = QVariant( myLongValue );
modified = true;
}
else if ( modified )
{
value = QVariant();
}
}
case QVariant::Double:
{
bool ok;
double myDblValue = text.toDouble( &ok );
if ( ok && !text.isEmpty() )
{
value = QVariant( myDblValue );
modified = true;
}
else if ( modified )
{
value = QVariant();
}
}
break;
case QVariant::Date:
{
QDate myDateValue = QDate::fromString( text, Qt::ISODate );
if ( myDateValue.isValid() && !text.isEmpty() )
{
value = myDateValue;
modified = true;
}
else if ( modified )
{
value = QVariant();
}
}
break;
default: //string
modified = true;
value = QVariant( text );
break;
}
return modified;
}
示例13: updateView
void KODayMatrix::updateView( const QDate &actdate )
{
if ( !actdate.isValid() ) {
return;
}
//flag to indicate if the starting day of the matrix has changed by this call
bool daychanged = false;
// if a new startdate is to be set then apply Cornelius's calculation
// of the first day to be shown
if ( actdate != mStartDate ) {
// reset index of selection according to shift of starting date from
// startdate to actdate.
if ( mSelStart != NOSELECTION ) {
int tmp = actdate.daysTo( mStartDate );
// shift selection if new one would be visible at least partly !
if ( mSelStart + tmp < NUMDAYS && mSelEnd + tmp >= 0 ) {
// nested if required for next X display pushed from a different month
// correction required. otherwise, for month forward and backward,
// it must be avoided.
if ( mSelStart > NUMDAYS || mSelStart < 0 ) {
mSelStart = mSelStart + tmp;
}
if ( mSelEnd > NUMDAYS || mSelEnd < 0 ) {
mSelEnd = mSelEnd + tmp;
}
}
}
mStartDate = actdate;
daychanged = true;
}
if ( daychanged ) {
recalculateToday();
}
// The calendar has not changed in the meantime and the selected range
// is still the same so we can save the expensive updateIncidences() call
if ( !daychanged && !mPendingChanges ) {
return;
}
// TODO_Recurrence: If we just change the selection, but not the data,
// there's no need to update the whole list of incidences... This is just a
// waste of computational power
updateIncidences();
for ( int i = 0; i < NUMDAYS; i++ ) {
//if it is a holy day then draw it red. Sundays are consider holidays, too
QStringList holidays = KOGlobals::self()->holiday( mDays[i] );
QString holiStr;
if ( ( KOGlobals::self()->calendarSystem()->dayOfWeek( mDays[i] ) ==
KOGlobals::self()->calendarSystem()->weekDayOfPray() ) ||
!holidays.isEmpty() ) {
if ( !holidays.isEmpty() ) {
holiStr = holidays.join( i18nc( "delimiter for joining holiday names", "," ) );
}
if ( holiStr.isEmpty() ) {
holiStr = "";
}
}
mHolidays[i] = holiStr;
}
}
示例14: setBegin
inline bool setBegin(const QDate& d){
if (d.isValid() == false)
return false;
begin_ = d;
return true;
}
示例15: setModelData
void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(editor);
if (!lineEdit->isModified())
return;
QString text = lineEdit->text();
const QValidator *validator = lineEdit->validator();
if (validator) {
int pos;
if (validator->validate(text, pos) != QValidator::Acceptable)
return;
}
QVariant originalValue = index.model()->data(index, Qt::UserRole);
QVariant value;
switch (originalValue.type()) {
case QVariant::Char:
value = text.at(0);
break;
case QVariant::Color:
colorExp.exactMatch(text);
value = QColor(qMin(colorExp.cap(1).toInt(), 255),
qMin(colorExp.cap(2).toInt(), 255),
qMin(colorExp.cap(3).toInt(), 255),
qMin(colorExp.cap(4).toInt(), 255));
break;
case QVariant::Date:
{
QDate date = QDate::fromString(text, Qt::ISODate);
if (!date.isValid())
return;
value = date;
}
break;
case QVariant::DateTime:
{
QDateTime dateTime = QDateTime::fromString(text, Qt::ISODate);
if (!dateTime.isValid())
return;
value = dateTime;
}
break;
case QVariant::Point:
pointExp.exactMatch(text);
value = QPoint(pointExp.cap(1).toInt(), pointExp.cap(2).toInt());
break;
case QVariant::Rect:
rectExp.exactMatch(text);
value = QRect(rectExp.cap(1).toInt(), rectExp.cap(2).toInt(),
rectExp.cap(3).toInt(), rectExp.cap(4).toInt());
break;
case QVariant::Size:
sizeExp.exactMatch(text);
value = QSize(sizeExp.cap(1).toInt(), sizeExp.cap(2).toInt());
break;
case QVariant::StringList:
value = text.split(',');
break;
case QVariant::Time:
{
QTime time = QTime::fromString(text, Qt::ISODate);
if (!time.isValid())
return;
value = time;
}
break;
default:
value = text;
value.convert(originalValue.type());
}
model->setData(index, displayText(value), Qt::DisplayRole);
model->setData(index, value, Qt::UserRole);
}