QList<Message> HistorySqlStorage::sms(const QString &recipient, const QDate &date, int limit) { kdebugf(); DatabaseMutex.lock(); QSqlQuery query(Database); QString queryString = "SELECT content, send_time FROM kadu_sms WHERE receipient = :receipient"; if (!date.isNull()) queryString += " AND date(send_time) = date(:date)"; queryString += " ORDER BY send_time ASC"; if (0 != limit) queryString += " LIMIT :limit"; query.prepare(queryString); query.bindValue(":receipient", recipient); if (!date.isNull()) query.bindValue(":date", date.toString(Qt::ISODate)); if (limit != 0) query.bindValue(":limit", limit); executeQuery(query); QList<Message> result = smsFromQuery(query); DatabaseMutex.unlock(); return result; }
QList<Message> HistorySqlStorage::messages(const Chat &chat, const QDate &date, int limit) { kdebugf(); DatabaseMutex.lock(); QSqlQuery query(Database); QString queryString = "SELECT chat, sender, content, send_time, receive_time, attributes FROM kadu_messages WHERE " + chatWhere(chat); if (!date.isNull()) queryString += " AND date(receive_time) = date(:date)"; queryString += " ORDER BY receive_time ASC, rowid ASC"; if (0 != limit) queryString += " LIMIT :limit"; QList<Message> messages; query.prepare(queryString); if (!date.isNull()) query.bindValue(":date", date.toString(Qt::ISODate)); if (limit != 0) query.bindValue(":limit", limit); executeQuery(query); messages = messagesFromQuery(query); DatabaseMutex.unlock(); return messages; }
void MultipleFilterProxy::setDateRangeFilter(qint32 col, const QDate& minDate, const QDate& maxDate, qint32 role) { if (col < 0 || col >= m_dateRangeFilter.size()) return; if (minDate.isNull() && maxDate.isNull()) return removeFilterFromColumn(col, role); m_regExpFilter[col].remove(role); m_boolFilter[col].remove(role); m_dateRangeFilter[col][role] = std::make_pair(minDate, maxDate); invalidateFilter(); }
void MainWindow::DateRangeUpdated(QDate s, QDate e) { Range<QDate> r( m_sdr->GetDateRange() ); lbl_dateStart->setText(QString("Start Date: %1").arg(r.LowerBound().Value().toString("ddd MMMM d yyyy"))); lbl_dateEnd->setText(QString("End Date: %1").arg(r.UpperBound().Value().toString("ddd MMMM d yyyy"))); lbl_updateCount->setText(QString("Update Count: %1").arg(++m_updateCount)); GASSERT(s.isNull() || s == r.LowerBound().Value()); GASSERT(e.isNull() || e == r.UpperBound().Value()); }
void itemPricingSchedule::populate() { XSqlQuery pop; pop.prepare( "SELECT ipshead_name, ipshead_descrip," " ipshead_effective, ipshead_expires, " " ipshead_curr_id, ipshead_updated " "FROM ipshead " "WHERE (ipshead_id=:ipshead_id);" ); pop.bindValue(":ipshead_id", _ipsheadid); pop.exec(); if (pop.first()) { if (_mode != cCopy) { _name->setText(pop.value("ipshead_name").toString()); _descrip->setText(pop.value("ipshead_descrip").toString()); } _dates->setStartDate(pop.value("ipshead_effective").toDate()); _dates->setEndDate(pop.value("ipshead_expires").toDate()); _currency->setId(pop.value("ipshead_curr_id").toInt()); _currency->setEnabled(FALSE); QDate tmpDate = pop.value("ipshead_updated").toDate(); if (tmpDate.isValid() && ! tmpDate.isNull()) _updated = tmpDate; sFillList(-1); } }
static DATE QDateTimeToDATE(const QDateTime &dt) { if (!dt.isValid() || dt.isNull()) return 949998; SYSTEMTIME stime; memset(&stime, 0, sizeof(stime)); QDate date = dt.date(); QTime time = dt.time(); if (date.isValid() && !date.isNull()) { stime.wDay = date.day(); stime.wMonth = date.month(); stime.wYear = date.year(); } if (time.isValid() && !time.isNull()) { stime.wMilliseconds = time.msec(); stime.wSecond = time.second(); stime.wMinute = time.minute(); stime.wHour = time.hour(); } double vtime; SystemTimeToVariantTime(&stime, &vtime); return vtime; }
void itemPricingSchedule::populate() { XSqlQuery itempopulate; XSqlQuery pop; pop.prepare( "SELECT ipshead_name, ipshead_descrip," " ipshead_effective, ipshead_expires, " " ipshead_curr_id, ipshead_updated " "FROM ipshead " "WHERE (ipshead_id=:ipshead_id);" ); pop.bindValue(":ipshead_id", _ipsheadid); pop.exec(); if (pop.first()) { _name->setText(pop.value("ipshead_name").toString()); _descrip->setText(pop.value("ipshead_descrip").toString()); _dates->setStartDate(pop.value("ipshead_effective").toDate()); _dates->setEndDate(pop.value("ipshead_expires").toDate()); _currency->setId(pop.value("ipshead_curr_id").toInt()); _currency->setEnabled(FALSE); QDate tmpDate = pop.value("ipshead_updated").toDate(); if (tmpDate.isValid() && ! tmpDate.isNull()) _updated = tmpDate; sFillList(-1); } else if (itempopulate.lastError().type() != QSqlError::NoError) { systemError(this, _rejectedMsg.arg(itempopulate.lastError().databaseText()), __FILE__, __LINE__); reject(); } }
QList<Message> HistorySqlStorage::messagesSince(const Chat &chat, const QDate &date) { kdebugf(); DatabaseMutex.lock(); QList<Message> messages; if (date.isNull()) return messages; QSqlQuery query(Database); QString queryString = "SELECT chat, sender, content, send_time, receive_time, attributes FROM kadu_messages WHERE " + chatWhere(chat) + " AND date(receive_time) >= date(:date) ORDER BY receive_time ASC, rowid ASC"; query.prepare(queryString); query.bindValue(":chat", chat.uuid().toString()); query.bindValue(":date", date.toString(Qt::ISODate)); executeQuery(query); messages = messagesFromQuery(query); DatabaseMutex.unlock(); return messages; }
void GenericCashFlow::SetFlow(QDate Dte, double Amt, qint32 FlowTpe) { Q_D(GenericCashFlow); if (Dte.isNull()) return; if (d->m_AdjustHolidays) { while (IsHoliday(Dte)) Dte = Dte.addDays(1); } if (qAbs(Amt) < 0.01) Amt = 0.0; auto index = d->m_CashFlows.begin(); for (; index != d->m_CashFlows.end(); ++index) { if (d->SamePeriod(Dte, index.key(), d->m_AggregationLevel)) break; } if (index != d->m_CashFlows.end()) { if (index.value()->contains(FlowTpe)) { if (Amt == 0.0 && !d->m_Stocks.contains(FlowTpe)) index.value()->remove(FlowTpe); else index.value()->operator[](FlowTpe) = Amt; } else { if (qAbs(Amt) > 0.0 || d->m_Stocks.contains(FlowTpe)) { index.value()->insert(FlowTpe, Amt); } } } else { d->m_CashFlows.insert(Dte, std::make_shared<QHash<qint32, double> >()); if (qAbs(Amt) > 0.0 || d->m_Stocks.contains(FlowTpe)) { d->m_CashFlows[Dte]->insert(FlowTpe, Amt); } } }
int CalendarBox::Context::daysShiftForMonth(QDate month) { Assert(!month.isNull()); constexpr auto kMaxRows = 6; auto inMonthIndex = month.day() - 1; auto inWeekIndex = month.dayOfWeek() - 1; return ((kMaxRows * kDaysInWeek) + inWeekIndex - inMonthIndex) % kDaysInWeek; }
bool KCalendarSystem::isValid( const QDate &date ) const { if ( date.isNull() || date < earliestValidDate() || date > latestValidDate() ) { return false; } return true; }
void LogTraceListener::removeFile(QDir& dir, const string& fileName, int days) { string name = fileName; if (strcmp(_fullFileName.c_str(), name.c_str()) != 0) { const QDateTime now = QDateTime::currentDateTime(); if (!_prefix.empty()) { Convert::replaceStr(name, _prefix, ""); } if (!_suffix.empty()) { Convert::replaceStr(name, _suffix, ""); } Convert::replaceStr(name, ".log", ""); QDate date = Convert::parseDate(name); int sec = now.secsTo(date); if (!date.isNull() && date.isValid() && sec < 0 && (-sec > days * 24 * 3600)) { bool result = dir.remove(fileName.c_str()); if(result) { Trace::WriteFormatLine(Resources::RemoveLogFilesSuccessfullyStr, fileName.c_str()); } else { Trace::WriteFormatLine(Resources::FailedtoRemoveLogFilesStr, fileName.c_str()); } } } }
void KOTodoView::setNewDate( QDate date ) { if ( !mActiveItem || !mChanger ) return; Todo *todo = mActiveItem->todo(); if ( !todo ) return; if ( !todo->isReadOnly() && mChanger->beginChange( todo ) ) { Todo *oldTodo = todo->clone(); QDateTime dt; dt.setDate( date ); if ( !todo->doesFloat() ) dt.setTime( todo->dtDue().time() ); if ( date.isNull() ) todo->setHasDueDate( false ); else if ( !todo->hasDueDate() ) todo->setHasDueDate( true ); todo->setDtDue( dt ); mActiveItem->construct(); mChanger->changeIncidence( oldTodo, todo, KOGlobals::COMPLETION_MODIFIED ); mChanger->endChange( todo ); delete oldTodo; } else { kdDebug(5850) << "No active item, active item is read-only, or locking failed" << endl; } }
void TenderAdjustment::setDate(QDate date) { if (date.isNull()) date = QDate::currentDate(); _gltxFrame->date->setDate(date); }
// insert a new range starting at the given date extending to the end of the zone currently // containing that date. If the start date of that zone is prior to the specified start // date, then that zone range is shorted. int Zones::insertRangeAtDate(QDate date, int cp) { assert(date.isValid()); int rnum; if (ranges.empty()) { addZoneRange(cp); fprintf( stderr, "Generating first range with CP = %d\n", cp ); rnum = 0; } else { rnum = whichRange(date); assert(rnum >= 0); QDate date1 = getStartDate(rnum); fprintf(stderr, "insertRangeAtDate(%s, %d):\n", date.toString().toAscii().constData(), cp); // if the old range has dates before the specified, then truncate the old range // and shift up the existing ranges if (date > date1) { QDate endDate = getEndDate(rnum); setEndDate(rnum, date); fprintf( stderr, "Inserting range\n" "old range %d: from %s to %s\n" "new range %d: from %s to %s\n" "added range %d: from %s to %s\n", rnum + 1, getStartDateString(rnum).toAscii().constData(), getEndDateString(rnum).toAscii().constData(), rnum + 1, getStartDateString(rnum).toAscii().constData(), (date.isNull() ? "END" : date.toString().toAscii().constData()), rnum + 2, (date.isNull() ? "BEGIN" : date.toString().toAscii().constData()), getEndDateString(rnum).toAscii().constData() ); ranges.insert(++ rnum, new ZoneRange(date, endDate)); } } if (cp > 0) { setCP(rnum, cp); setZonesFromCP(rnum); } return rnum; }
QString Settings::BirthdayPage::textForDate(const QDate& date) const { if (date.isNull()) { return m_noDateString; } else { return KGlobal::locale()->formatDate(date, KLocale::ShortDate); } }
int CalendarBox::Context::rowsCountForMonth(QDate month) { Assert(!month.isNull()); auto daysShift = daysShiftForMonth(month); auto daysCount = month.daysInMonth(); auto cellsCount = daysShift + daysCount; auto result = (cellsCount / kDaysInWeek); if (cellsCount % kDaysInWeek) ++result; return result; }
void HistorySqlStorage::clearChatHistory(const Chat &chat, const QDate &date) { DatabaseMutex.lock(); QSqlQuery query(Database); QString queryString = "DELETE FROM kadu_messages WHERE " + chatWhere(chat); if (!date.isNull()) queryString += " AND date(receive_time) = date(:date)"; query.prepare(queryString); if (!date.isNull()) query.bindValue(":date", date.toString(Qt::ISODate)); executeQuery(query); DatabaseMutex.unlock(); }
void HistorySqlStorage::clearStatusHistory(const Buddy &buddy, const QDate &date) { DatabaseMutex.lock(); QSqlQuery query(Database); QString queryString = "DELETE FROM kadu_statuses WHERE " + buddyContactsWhere(buddy); if (!date.isNull()) queryString += " AND date(set_time) = date(:date)"; query.prepare(queryString); if (!date.isNull()) query.bindValue(":date", date.toString(Qt::ISODate)); executeQuery(query); DatabaseMutex.unlock(); }
wxDateTime wxQtConvertDate(const QDate& date) { if ( !date.isNull() ) return wxDateTime(date.day(), static_cast<wxDateTime::Month>(date.month() - 1), date.year(), 0, 0, 0, 0); else return wxDateTime(); }
void HistorySqlStorage::clearSmsHistory(const QString &recipient, const QDate &date) { DatabaseMutex.lock(); QSqlQuery query(Database); QString queryString = "DELETE FROM kadu_sms WHERE receipient = :receipient"; if (!date.isNull()) queryString += " AND date(send_time) = date(:date)"; query.prepare(queryString); query.bindValue(":receipient", recipient); if (!date.isNull()) query.bindValue(":date", date.toString(Qt::ISODate)); executeQuery(query); DatabaseMutex.unlock(); }
void RecipeExtrasWidget::updateDate(const QDate& date) { if( recipe == 0 ) return; if ( date.isNull() ) recipe->setDate( dateEdit_date->date() ); else recipe->setDate( date ); }
// Select based on a given card id. Returns just the base Gltx data //sorted by date and number. Used for inquiry window. void QuasarDB::selectCard(Id card_id, Id store_id, QDate start, QDate end, vector<Gltx>& gltxs, vector<fixed>& amounts) { gltxs.clear(); amounts.clear(); QString table = "gltx join gltx_card on gltx.gltx_id = " "gltx_card.gltx_id"; QString cmd = selectCmd(table, "gltx.gltx_id", "gltx.number," "reference_str,post_date,post_time," "gltx.memo,station_id,employee_id," "gltx.card_id,store_id,shift_id,link_id," "printed,paid,gltx.amount,data_type," "gltx_card.amount", Select()); cmd += " where gltx_card.card_id = ?"; if (store_id != INVALID_ID) cmd += " and store_id = ?"; if (!start.isNull() && !end.isNull()) cmd += " and post_date between ? and ?"; else if (!start.isNull()) cmd += " and post_date >= ?"; else if (!end.isNull()) cmd += " and post_date <= ?"; cmd += " order by post_date, gltx.number"; Stmt stmt(_connection, cmd); stmtSetId(stmt, card_id); if (store_id != INVALID_ID) stmtSetId(stmt, store_id); if (!start.isNull() && !end.isNull()) { stmtSetDate(stmt, start); stmtSetDate(stmt, end); } else if (!start.isNull()) { stmtSetDate(stmt, start); } else if (!end.isNull()) { stmtSetDate(stmt, end); } if (!execute(stmt)) return; while (stmt.next()) { Gltx gltx; int next = 1; selectData(gltx, stmt, next); selectGltx(gltx, stmt, next); gltx.setDataType(DataObject::DataType(stmtGetInt(stmt, next++))); gltxs.push_back(gltx); amounts.push_back(stmtGetFixed(stmt, next++)); } commit(); }
QValidator::State KDateValidator::date(const QString& text, QDate& d) const { QDate tmp = KGlobal::locale()->readDate(text); if (!tmp.isNull()) { d = tmp; return Acceptable; } else return Valid; }
/*! \fn void OContact::setAnniversary( const QDate &date ) Sets the anniversary of the contact to \a date. If date is null, the current stored date will be removed. */ void OContact::setAnniversary( const QDate &v ) { if ( v.isNull() ){ qWarning( "Remove Anniversary"); replace( Qtopia::Anniversary, QString::null ); return; } if ( v.isValid() ) replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); }
//------------------------------------------------------------------------------ void EstimateDetailsForm::populate(const QModelIndex& index) { Estimate* estimate = static_cast<Estimate*>(index.internalPointer()); // Populate fields with selected estimate's values nameField->setText(estimate->estimateName()); descriptionField->setText(estimate->estimateDescription()); typeField->setCurrentIndex(typeField->findData(estimate->estimateType())); amountField->setValue(estimate->estimatedAmount()); finishedField->setChecked(estimate->isActivityFinished()); int offset = estimate->activityDueDateOffset(); QDate dueDate = period->startDate().addDays(offset); if (dueDate.isNull()) { clearDueDate(); } else { dueDateField->setDate(dueDate); } // Enable fields that are applicable for all non-root estimates nameField->setEnabled(estimate->parentEstimate()); descriptionField->setEnabled(estimate->parentEstimate()); // Disable fields that aren't applicable for parents amountField->setEnabled(estimate->childCount() == 0); dueDateField->setEnabled(estimate->childCount() == 0); clearDueDateButton->setEnabled(estimate->childCount() == 0); finishedField->setEnabled(estimate->childCount() == 0); // Type can only be changed at top-level estimates Estimate* parent = estimate->parentEstimate(); if ( ! parent) // Parent is root { typeField->setEnabled(false); } else if ( ! parent->parentEstimate()) // Parent of parent is root { typeField->setEnabled(true); } else // Not top-level { typeField->setEnabled(false); } // Clear fields that aren't applicable for parents if (estimate->childCount() != 0) { amountField->clear(); clearDueDate(); finishedField->setChecked(false); } }
/*! \fn void OPimContact::setAnniversary( const QDate &date ) Sets the anniversary of the contact to \a date. If date is null, the current stored date will be removed. */ void OPimContact::setAnniversary( const QDate &v ) { if ( v.isNull() ) { replace( Qtopia::Anniversary, QString::null ); return ; } if ( v.isValid() ) replace( Qtopia::Anniversary, OPimDateConversion::dateToString( v ) ); }
void DatePicker::setDate(int day, int month, int year) { QString text; QDate d; if (day && month && year) d.setYMD(year, month, day); if (!d.isNull()) text.sprintf("%02u/%02u/%04u", day, month, year); m_edit->setText(text); emit changed(); }
void FirebirdParam::setDate(QDate value) { clear(); if (value.isNull()) { setNull(); } else { _var->sqltype = SQL_TYPE_DATE; _var->sqllen = sizeof(ISC_DATE); _procs->isc_encode_sql_date(makeTM(value), (ISC_DATE*)_buffer); } }
void XDateEdit::showCalendar() { if (DEBUG) qDebug("%s::showCalendar()", qPrintable(parent() ? parent()->objectName() : objectName())); QDate d = date(); if(d.isNull() || d == _nullDate) d = QDate::currentDate(); DCalendarPopup *cal = new DCalendarPopup(d, this); connect(cal, SIGNAL(newDate(const QDate &)), this, SIGNAL(newDate(const QDate &))); cal->show(); }