本文整理汇总了C++中QDate函数的典型用法代码示例。如果您正苦于以下问题:C++ QDate函数的具体用法?C++ QDate怎么用?C++ QDate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QDate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addDateFormat
void LXQtClockConfiguration::createDateFormats()
{
ui->dateFormatCOB->clear();
QString systemDateLocale = QLocale::system().dateFormat(QLocale::ShortFormat).toUpper();
if (systemDateLocale.indexOf("Y") < systemDateLocale.indexOf("D"))
// Big-endian (year, month, day) -> in some Asia countires like China or Japan
{
addDateFormat("MMM d");
addDateFormat("MMMM d");
addDateFormat("MMM d, ddd");
addDateFormat("MMMM d, dddd");
addDateFormat("yyyy MMM d");
addDateFormat("yyyy MMMM d");
addDateFormat("yyyy MMM d, ddd");
addDateFormat("yyyy MMMM d, dddd");
addDateFormat("MMM dd");
addDateFormat("MMMM dd");
addDateFormat("MMM dd, ddd");
addDateFormat("MMMM dd, dddd");
addDateFormat("yyyy MMM dd");
addDateFormat("yyyy MMMM dd");
addDateFormat("yyyy MMM dd, ddd");
addDateFormat("yyyy MMMM dd, dddd");
}
else if (systemDateLocale.indexOf("M") < systemDateLocale.indexOf("D"))
// Middle-endian (month, day, year) -> USA
{
addDateFormat("MMM d");
addDateFormat("MMMM d");
addDateFormat("ddd, MMM d");
addDateFormat("dddd, MMMM d");
addDateFormat("MMM d yyyy");
addDateFormat("MMMM d yyyy");
addDateFormat("ddd, MMM d yyyy");
addDateFormat("dddd, MMMM d yyyy");
addDateFormat("MMM dd");
addDateFormat("MMMM dd");
addDateFormat("ddd, MMM dd");
addDateFormat("dddd, MMMM dd");
addDateFormat("MMM dd yyyy");
addDateFormat("MMMM dd yyyy");
addDateFormat("ddd, MMM dd yyyy");
addDateFormat("dddd, MMMM dd yyyy");
}
else
// Little-endian (day, month, year) -> most of Europe
{
addDateFormat("d MMM");
addDateFormat("d MMMM");
addDateFormat("ddd, d MMM");
addDateFormat("dddd, d MMMM");
addDateFormat("d MMM yyyy");
addDateFormat("d MMMM yyyy");
addDateFormat("ddd, d MMM yyyy");
addDateFormat("dddd, d MMMM yyyy");
addDateFormat("dd MMM");
addDateFormat("dd MMMM");
addDateFormat("ddd, dd MMM");
addDateFormat("dddd, dd MMMM");
addDateFormat("dd MMM yyyy");
addDateFormat("dd MMMM yyyy");
addDateFormat("ddd, dd MMM yyyy");
addDateFormat("dddd, dd MMMM yyyy");
}
addDateFormat(QLocale::system().dateFormat(QLocale::ShortFormat));
addDateFormat(QLocale::system().dateFormat(QLocale::LongFormat));
addDateFormat("yyyy-MM-dd"); // ISO
if (mCustomDateFormat.isEmpty())
ui->dateFormatCOB->addItem("Custom ...", QVariant(mCustomDateFormat));
else
ui->dateFormatCOB->addItem(QString("Custom (%1) ...").arg(QDate(currentYear, 1, 1).toString(mCustomDateFormat)), QVariant(mCustomDateFormat));
}
示例2: SECIM_KERNELI
FAT_IRSALIYE_SATIR_SECIMI::FAT_IRSALIYE_SATIR_SECIMI ( QString p_fatura_tarihi, int p_cari_hesap_id, int p_fatura_turu, QWidget * p_parent ) : SECIM_KERNELI ( p_parent )
{
SQL_QUERY sql_query ( DB );
SET_HELP_PAGE ( "fat_irsaliye_satir_secimi.html" );
SET_PAGE_TITLE ( "FAT - İRSALİYE SATIRI SEÇİMİ " );
m_irsaliye_tarihi_bitis = p_fatura_tarihi;
m_cari_hesap_id = p_cari_hesap_id;
switch ( p_fatura_turu ) {
case ENUM_FAT_ELLE_IRSALIYE_FATURALASTIRMA_ALIS :
m_irsaliye_turu = ENUM_IRS_NORMAL_GIRIS;
break;
case ENUM_FAT_ELLE_IRSALIYE_FATURALASTIRMA_SATIS :
m_irsaliye_turu = ENUM_IRS_NORMAL_CIKIS;
break;
case ENUM_FAT_ELLE_IRSALIYE_FATURALASTIRMA_KONSINYE_ALIS :
m_irsaliye_turu = ENUM_IRS_KONSINYE_GIRIS;
break;
case ENUM_FAT_ELLE_IRSALIYE_FATURALASTIRMA_KONSINYE_SATIS:
m_irsaliye_turu = ENUM_IRS_KONSINYE_CIKIS;
break;
default :
m_irsaliye_turu = -1;
break;
}
sql_query.PREPARE_SELECT ( "e9_sabit_degerler","irs_faturalandirilacak_gun" ,"sabit_deger_id = :sabit_deger_id");
sql_query.SET_VALUE(":sabit_deger_id" , 1);
if ( sql_query.SELECT() EQ 0 ) {
return;
}
sql_query.NEXT();
int faturandirilacak_gun = sql_query.VALUE(0).toInt();
QDate irsaliye_tarihi_bitis = QDate::fromString ( m_irsaliye_tarihi_bitis, "yyyy.MM.dd" );
int irsaliye_tarihi_bitis_month = irsaliye_tarihi_bitis.month();
QDate irsaliye_tarihi_baslangic = irsaliye_tarihi_bitis.addDays ( -1 * faturandirilacak_gun );
int irsaliye_tarihi_baslangic_month = irsaliye_tarihi_baslangic.month();
if ( irsaliye_tarihi_baslangic_month NE irsaliye_tarihi_bitis_month ) {
m_irsaliye_tarihi_baslangic = QDate( irsaliye_tarihi_bitis.year(), irsaliye_tarihi_bitis_month, 01 ).toString("yyyy.MM.dd");
}
else {
m_irsaliye_tarihi_baslangic = irsaliye_tarihi_baslangic.toString("yyyy.MM.dd");
}
SET_SORTING ( false );
SET_WINDOW_SIZE ( 600, 1100 );
SET_HEADERS ( QStringList () <<tr("irsaliye_satiri_id")<<tr("İrs. No")<<tr("İrs. S. No")<<tr("İrsaliye Tarihi")
<<tr("Ürün Kodu")<<tr("Ürün Adı")<<tr("S. No/P. Kodu")<<tr("Kalan Miktar")
<<tr("Birimi")<<tr("Birim Fiyat")<<tr("KDV")<<tr("KDV %")<<tr("ÖTV %")
<<tr("Fiyatı")<<tr("Para Brm")<< DVZ_GET_TEMEL_PARA_BIRIMI_KODU() + tr(" Tutarı"));
INIT_KERNEL ( DB );
QTableWidget * tableWidget = GET_TABLE_WIDGET();
tableWidget->setColumnWidth ( IRSALIYE_NO_COLUMN , 45 );
tableWidget->setColumnWidth ( IRSALIYE_BELGE_SERI_NO_COLUMN , 58 );
tableWidget->setColumnWidth ( IRSALIYE_TARIHI_COLUMN , 103 );
tableWidget->setColumnWidth ( URUN_KODU_COLUMN , 70 );
tableWidget->setColumnWidth ( URUN_ADI_COLUMN , 100 );
tableWidget->setColumnWidth ( SERI_NO_PARTI_KODU_COLUMN , 80 );
tableWidget->setColumnWidth ( KALAN_MIKTAR_COLUMN , 80 );
tableWidget->setColumnWidth ( URUN_BIRIMI_COLUMN , 60 );
tableWidget->setColumnWidth ( BIRIM_FIYAT_COLUMN , 75 );
tableWidget->setColumnWidth ( KDV_DAHIL_MI_COLUMN , 50 );
tableWidget->setColumnWidth ( KDV_ORANI_COLUMN , 47 );
tableWidget->setColumnWidth ( OTV_ORANI_COLUMN , 47 );
tableWidget->setColumnWidth ( FIYAT_COLUMN , 80 );
tableWidget->setColumnWidth ( PARA_BIRIMI_COLUMN , 60 );
tableWidget->setColumnWidth ( TEMEL_PARA_BIRIMI_TUTARI_COLUMN , 80 );
SET_SETTING_NAME ( "FAT_IRSALIYE_SATIR_SECIMI" );
QFont tableWidget_font = tableWidget->font();
int font_point_size = tableWidget_font.pointSize();
tableWidget_font.setPointSize ( font_point_size -1 );
tableWidget->setFont ( tableWidget_font );
tableWidget->hideColumn( IRSALIYE_SATIRI_ID_COLUMN );
}
示例3: some_lengthy_task
QTime::isValid(21, 10, 30); // returns true
QTime::isValid(22, 5, 62); // returns false
//! [9]
//! [10]
QTime t;
t.start();
some_lengthy_task();
qDebug("Time elapsed: %d ms", t.elapsed());
//! [10]
//! [11]
QDateTime now = QDateTime::currentDateTime();
QDateTime xmas(QDate(now.date().year(), 12, 25), QTime(0, 0));
qDebug("There are %d seconds to Christmas", now.secsTo(xmas));
//! [11]
//! [12]
QTime time1 = QTime::fromString("131", "HHh");
// time1 is 13:00:00
QTime time1 = QTime::fromString("1apA", "1amAM");
// time1 is 01:00:00
QDateTime dateTime2 = QDateTime::fromString("M1d1y9800:01:02",
"'M'M'd'd'y'yyhh:mm:ss");
// dateTime is 1 January 1998 00:01:02
//! [12]
示例4: if
QDate YearlyRecurrence::nextOccurrence(const QDate &date, bool include_equals) const {
const KCalendarSystem *calSys = KGlobal::locale()->calendar();
if(!include_equals) {
if(date < startDate()) return firstOccurrence();
} else {
if(date <= startDate()) return firstOccurrence();
}
QDate nextdate = date;
if(!include_equals) nextdate = calSys->addDays(nextdate, 1);
if(!endDate().isNull() && nextdate > endDate()) return QDate();
if(calSys->year(nextdate) == calSys->year(startDate())) {
nextdate = calSys->addYears(nextdate, i_frequency);
calSys->setYMD(nextdate, calSys->year(nextdate), 1, 1);
} else if(i_frequency != 1) {
int i = (calSys->year(nextdate) - calSys->year(startDate())) % i_frequency;
if(i != 0) {
nextdate = calSys->addYears(nextdate, i_frequency - i);
calSys->setYMD(nextdate, calSys->year(nextdate), 1, 1);
}
}
if(i_dayofyear > 0) {
if(calSys->dayOfYear(nextdate) > i_dayofyear) {
nextdate = calSys->addYears(nextdate, i_frequency);
}
if(i_dayofyear > calSys->daysInYear(nextdate)) {
int i = 10;
do {
if(i == 0) return QDate();
nextdate = calSys->addYears(nextdate, i_frequency);
i--;
} while(i_dayofyear > calSys->daysInYear(nextdate));
}
nextdate = calSys->addDays(nextdate, i_dayofyear - calSys->dayOfYear(nextdate));
} else {
int day = i_dayofmonth;
if(i_dayofweek > 0) day = get_day_in_month(calSys->year(nextdate), i_month, i_week, i_dayofweek);
if(day == 0 || calSys->month(nextdate) > i_month || (calSys->month(nextdate) == i_month && calSys->day(nextdate) > day)) {
do {
nextdate = calSys->addYears(nextdate, i_frequency);
day = get_day_in_month(calSys->year(nextdate), i_month, i_week, i_dayofweek);
if(!endDate().isNull() && calSys->year(nextdate) > calSys->year(endDate())) return QDate();
} while(day == 0);
}
if(i_dayofweek <= 0) {
calSys->setYMD(nextdate, calSys->year(nextdate), i_month, 1);
if(day > calSys->daysInMonth(nextdate)) {
int i = 10;
do {
if(i == 0) return QDate();
nextdate = calSys->addYears(nextdate, i_frequency);
calSys->setYMD(nextdate, calSys->year(nextdate), i_month, 1);
i--;
} while(day > calSys->daysInMonth(nextdate));
}
}
calSys->setYMD(nextdate, calSys->year(nextdate), i_month, day);
}
if(!endDate().isNull() && nextdate > endDate()) return QDate();
if(hasException(nextdate)) return nextOccurrence(nextdate);
return nextdate;
}
示例5: text
void XDateEdit::parseDate()
{
QString dateString = text().trimmed();
bool isNumeric;
if (DEBUG)
qDebug("%s::parseDate() with dateString %s, _currentDate %s, _allowNull %d",
qPrintable(parent() ? parent()->objectName() : objectName()),
qPrintable(dateString),
qPrintable(_currentDate.toString()), _allowNull);
#ifdef GUIClient_h
QDate today = ofmgThis->dbDate();
#else
QDate today = QDate::currentDate();
#endif
if (_parsed)
{
if (DEBUG)
qDebug("%s::parseDate() looks like we've already parsed this string",
qPrintable(parent() ? parent()->objectName() : objectName()));
return;
}
_valid = false;
if (dateString.contains(QRegExp("[0-9]+[-][0-9]+"))) //user enters hyphens instead of slashes
{
dateString.replace("-", "/");
}
if (dateString == _nullString || dateString.isEmpty())
setNull();
else if (dateString == "0") // today
checkDate(today);
else if (dateString.contains(QRegExp("^[+-][0-9]+"))) // offset from today
{
int offset = dateString.toInt(&isNumeric);
if (isNumeric)
checkDate(today.addDays(offset));
}
else if (dateString[0] == '#') // julian day
{
int offset = dateString.right(dateString.length() - 1).toInt(&isNumeric);
if (isNumeric) {
if (offset < 0)
checkDate(QDate(today.year(), 12, 31).addDays(offset + 1));
else
checkDate(QDate(today.year(), 1, 1).addDays(offset - 1));
}
}
else if (dateString.contains(QRegExp("^[0-9][0-9]?$"))) // date in month
{
int offset = dateString.toInt(&isNumeric, 10);
if (isNumeric)
{
if (offset > today.daysInMonth())
offset = today.daysInMonth();
checkDate(QDate(today.year(), today.month(), 1).addDays(offset - 1));
}
}
else // interpret with locale
{
QString dateFormatStr = QLocale().dateFormat(QLocale::ShortFormat);
if (DEBUG)
qDebug("%s::parseDate() trying to parse with %s",
qPrintable(parent() ? parent()->objectName() : objectName()),
qPrintable(dateFormatStr));
QDate tmp = QDate::fromString(dateString, dateFormatStr);
bool twodigitformat = !(dateFormatStr.indexOf(QRegExp("y{4}")) >= 0);
if (tmp.isValid())
{
if (twodigitformat && tmp.year() < 1950) // Qt docs say 2-digit years are 1900-based so
{
qDebug("%s::parseDate() found valid 2-digit year %d",
qPrintable(parent() ? parent()->objectName() : objectName()),
tmp.year());
tmp = tmp.addYears(100); // add backwards-compat with pre-3.0 DLineEdit
qDebug("%s::parseDate() altered year to %d",
qPrintable(parent() ? parent()->objectName() : objectName()),
tmp.year());
}
}
else if (twodigitformat)
{
// try 4 digits, ignoring the possibility of '-literals in the format str
dateFormatStr.replace(QRegExp("y{2}"), "yyyy");
if (DEBUG)
qDebug("%s::parseDate() rewriting 2-digit year format string to %s",
qPrintable(parent() ? parent()->objectName() : objectName()),
qPrintable(dateFormatStr));
tmp = QDate::fromString(dateString, dateFormatStr);
//.........这里部分代码省略.........
示例6: addTagToMap
QT_BEGIN_NAMESPACE
//internal
static void addTagToMap(const GstTagList *list,
const gchar *tag,
gpointer user_data)
{
QMap<QByteArray, QVariant> *map = reinterpret_cast<QMap<QByteArray, QVariant>* >(user_data);
GValue val;
val.g_type = 0;
gst_tag_list_copy_value(&val,list,tag);
switch( G_VALUE_TYPE(&val) ) {
case G_TYPE_STRING:
{
const gchar *str_value = g_value_get_string(&val);
map->insert(QByteArray(tag), QString::fromUtf8(str_value));
break;
}
case G_TYPE_INT:
map->insert(QByteArray(tag), g_value_get_int(&val));
break;
case G_TYPE_UINT:
map->insert(QByteArray(tag), g_value_get_uint(&val));
break;
case G_TYPE_LONG:
map->insert(QByteArray(tag), qint64(g_value_get_long(&val)));
break;
case G_TYPE_BOOLEAN:
map->insert(QByteArray(tag), g_value_get_boolean(&val));
break;
case G_TYPE_CHAR:
#if GLIB_CHECK_VERSION(2,32,0)
map->insert(QByteArray(tag), g_value_get_schar(&val));
#else
map->insert(QByteArray(tag), g_value_get_char(&val));
#endif
break;
case G_TYPE_DOUBLE:
map->insert(QByteArray(tag), g_value_get_double(&val));
break;
default:
// GST_TYPE_DATE is a function, not a constant, so pull it out of the switch
#if GST_CHECK_VERSION(1,0,0)
if (G_VALUE_TYPE(&val) == G_TYPE_DATE) {
const GDate *date = (const GDate *)g_value_get_boxed(&val);
#else
if (G_VALUE_TYPE(&val) == GST_TYPE_DATE) {
const GDate *date = gst_value_get_date(&val);
#endif
if (g_date_valid(date)) {
int year = g_date_get_year(date);
int month = g_date_get_month(date);
int day = g_date_get_day(date);
map->insert(QByteArray(tag), QDate(year,month,day));
if (!map->contains("year"))
map->insert("year", year);
}
} else if (G_VALUE_TYPE(&val) == GST_TYPE_FRACTION) {
int nom = gst_value_get_fraction_numerator(&val);
int denom = gst_value_get_fraction_denominator(&val);
if (denom > 0) {
map->insert(QByteArray(tag), double(nom)/denom);
}
}
break;
}
g_value_unset(&val);
}
/*!
Convert GstTagList structure to QMap<QByteArray, QVariant>.
Mapping to int, bool, char, string, fractions and date are supported.
Fraction values are converted to doubles.
*/
QMap<QByteArray, QVariant> QGstUtils::gstTagListToMap(const GstTagList *tags)
{
QMap<QByteArray, QVariant> res;
gst_tag_list_foreach(tags, addTagToMap, &res);
return res;
}
示例7: QDate
void ClearPrivateData::dialogAccepted()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
if (ui->history->isChecked()) {
qint64 start = QDateTime::currentMSecsSinceEpoch();
qint64 end = 0;
const QDate today = QDate::currentDate();
const QDate week = today.addDays(1 - today.dayOfWeek());
const QDate month = QDate(today.year(), today.month(), 1);
switch (ui->historyLength->currentIndex()) {
case 0: //Later Today
end = QDateTime(today).toMSecsSinceEpoch();
break;
case 1: //Week
end = QDateTime(week).toMSecsSinceEpoch();
break;
case 2: //Month
end = QDateTime(month).toMSecsSinceEpoch();
break;
case 3: //All
break;
}
if (end == 0) {
mApp->history()->clearHistory();
}
else {
const QList<int> &indexes = mApp->history()->indexesFromTimeRange(start, end);
mApp->history()->deleteHistoryEntry(indexes);
}
}
if (ui->cookies->isChecked()) {
mApp->cookieJar()->setAllCookies(QList<QNetworkCookie>());
}
if (ui->cache->isChecked()) {
clearCache();
}
if (ui->databases->isChecked()) {
clearWebDatabases();
}
if (ui->localStorage->isChecked()) {
clearLocalStorage();
}
if (ui->icons->isChecked()) {
clearIcons();
}
QApplication::restoreOverrideCursor();
ui->clear->setEnabled(false);
ui->clear->setText(tr("Done"));
QTimer::singleShot(1000, this, SLOT(close()));
}
示例8: QDate
bool MGenerarCuotas::calcularComprobantes()
{
_cant = 0;
_total = 0.0;
// Fecha del mes actual - Inicio del mes
QDate inicio_mes = QDate( QDate::currentDate().year(), _mes_busqueda, 1 );
QDate fin_mes = inicio_mes;
fin_mes = fin_mes.addMonths( 1 );
// Busco el próximo número de recibo
//NumeroComprobante *num = new NumeroComprobante( 0, -1, -1 );
NumeroComprobante num = MPagos::proximoSerieNumeroRecibo();
QSqlQuery cola;
if( cola.exec( QString( " SELECT ic.id_item_cuota, ic.id_plan_cuota, ic.num_cuota, pc.cantidad_cuotas, ic.monto, pc.id_factura, pc.tipo_comprobante "
" FROM item_cuota AS ic "
" INNER JOIN plan_cuota AS pc ON ic.id_plan_cuota = pc.id_plan_cuota "
" WHERE ic.fecha_pago IS NULL "
" AND ic.id_recibo IS NULL " // Cuando se emite el recibo de la cuota este campo no debe estar vacío
" AND ic.fecha_vencimiento <= \"%1\" "
" AND ic.fecha_vencimiento >= \"%2\" "
" GROUP BY ic.id_plan_cuota "
" HAVING MIN( ic.num_cuota ) "
" ORDER BY ic.id_plan_cuota, ic.num_cuota " )
.arg( fin_mes.toString( Qt::ISODate ) )
.arg( inicio_mes.toString( Qt::ISODate ) ) ) ) {
while( cola.next() ) {
beginInsertRows( QModelIndex(), _cant, _cant );
_numeros ->insert( _cant, cola.record().value( "id_item_cuota" ).toInt() );
_planes ->insert( _cant, cola.record().value( "id_plan_cuota" ).toInt() );
_cuotas ->insert( _cant, QString( "%2/%1" )
.arg( cola.record().value( "cantidad_cuotas" ).toInt() )
.arg( cola.record().value( "num_cuota" ).toInt() ) );
if( cola.record().value( "tipo_comprobante" ).toInt() == MPlanCuota::Factura ) {
int id_factura = cola.record().value("id_factura").toInt();
int id_cliente = MFactura::obtenerIdCliente( id_factura );
_clientes_id->insert( _cant, id_cliente );
_clientes->insert( _cant, MClientes::getRazonSocial( id_cliente ) );
} else if( cola.record().value( "tipo_comprobante" ).toInt() == MPlanCuota::Remito ) {
int id_remito = cola.record().value("id_factura").toInt();
int id_cliente = MRemito::obtenerIdCliente( id_remito );
_clientes_id->insert( _cant, id_cliente );
_clientes->insert( _cant, MClientes::getRazonSocial( id_cliente ) );
} else {
qDebug() << "Tipo de comprobante desconocido";
}
double monto = cola.record().value( "monto" ).toDouble();
_total += monto;
_importes->insert( _cant, monto );
_comprobantes->insert( _cant, new NumeroComprobante( num ) );
endInsertRows();
_cant++;
num.siguienteNumero();
}
if( _cant > 0 ) {
emit cambioTotal( _total );
emit cambioCantidad( _cant );
emit dataChanged( index( 0, 0 ), index( _cant, 5 ) );
return true;
} else {
emit cambioTotal( 0.0 );
emit cambioCantidad( 0 );
return false;
}
} else {
qDebug() << "Error al ejecutar la cola de averiguamiento de los datos de las cuotas a pagar";
qDebug() << cola.lastError().text();
qDebug() << cola.lastQuery();
}
return false;
}
示例9: QDate
void Manager::add(const QDate & date, const bool & forced)
{
// Init
bool ok = true;
QString error = "";
QString tableName;
QString filePath;
// Valid date ?
if(ok
&& !(date <= QDate::currentDate().addDays(1)
&& date >= QDate(2010, 1, 1)))
{
ok = false;
error = "invalid date";
}
// Connected ?
if(ok && !connected)
{
ok = false;
error = "not connected to any database";
}
// starting message
if(ok)
{
Util::addMessage("Adding : " + date.toString("yyyy-MM-dd"));
}
//
if(ok)
{
tableName = "day" + date.toString("yyyyMMdd");
filePath = Util::getLineFromConf("pathToRawData")
+ "/" + tableName + ".csv";
}
// Drop table if asked
if(ok && forced)
{
QSqlQuery query;
QString statement = "DROP TABLE IF EXISTS " + tableName + ";";
query.prepare(statement);
if(!query.exec())
{
ok = false;
error = "couldn't drop table (" + tableName + ") "
+ database.lastError().text() + query.lastError().text();
}
}
// Create table
if(ok)
{
QSqlQuery query;
QString statement = "";
QStringList columns;
QFile file(Util::getLineFromConf("pathToColumn") + "/columns.txt");
if(!file.open(QIODevice::ReadOnly)) {
ok = false;
error = Util::getLineFromConf("pathToColumn")
+ "/columns.txt " + file.errorString();
}
if(ok)
{
QTextStream in(&file);
while(!in.atEnd())
{
columns.append(in.readLine());
}
file.close();
statement = " CREATE TABLE ";
statement += tableName + " ( ";
for(int i = 0 ; i < columns.size() - 1 ; i++)
{
statement += " " + columns[i] + " text, ";
}
statement += " " + columns[columns.size() - 1] + " text );";
query.prepare(statement);
if(ok && !query.exec())
{
ok = false;
error = "couldn't create table '" + tableName + "' : "
+ database.lastError().text()
+ query.lastError().text();
}
}
}
// Fill table
if(ok)
{
QSqlQuery query;
QString statement = "";
QFile file(filePath);
if(!file.open(QIODevice::ReadOnly)) {
ok = false;
error = filePath +" "+ file.errorString();
}
QTextStream in(&file);
in.setCodec("UTF-8");
int lineNumber = 0;
while(!in.atEnd())
{
lineNumber++;
QString line = in.readLine();
//.........这里部分代码省略.........
示例10: QObject
TransactionHistory::TransactionHistory(Monero::TransactionHistory *pimpl, QObject *parent)
: QObject(parent), m_pimpl(pimpl), m_minutesToUnlock(0), m_locked(false)
{
m_firstDateTime = QDateTime(QDate(2014, 4, 18)); // the genesis block
m_lastDateTime = QDateTime::currentDateTime().addDays(1); // tomorrow (guard against jitter and timezones)
}
示例11: qDebug
void MainWindow::createCase(QString classification)
{
qDebug()<<classification;
QSqlQuery query;
QString tempTable = "tempClass" + classification.simplified().remove(" ");
query.exec("DROP TEMPORARY TABLE IF EXISTS " + tempTable);
// the temprary table is created as below to ensure that the index is also created
query.clear();
query.exec("CREATE TEMPORARY TABLE " + tempTable + " LIKE SensorVector");
query.clear();
query.exec("INSERT INTO " + tempTable + " select * from SensorVector limit 1");
query.clear();
query.exec(" select lastUpdate, sensorId, status from Sensors where sensorId < 61 order by sensorId");
QDateTime start(QDate(2010,1,1),QTime(0,0,1));
QString lastSensorId = "-1";
QDateTime currentUpdate;
// qDebug()<<".sensor loop";
while (query.next())
{
QDateTime sensorLastUpdate = query.value(0).toDateTime();
QString sensorId = query.value(1).toString();
QString sensorStatus = query.value(2).toString();
if (sensorLastUpdate > start) // this gets the last update
{
start = sensorLastUpdate;
lastSensorId = sensorId;
}
QSqlQuery updateQuery;
QString seq;
seq = "update " + tempTable + " set sensor" + sensorId + " = '" + sensorStatus + "'";
// qDebug()<<seq;
// qDebug()<<"...update temp loop";
updateQuery.exec(seq);
}
query.clear();
//// Sensor location
QSqlQuery locnQuery;
QString qry;
qry = "select";
qry+= " CASE WHEN L1.where = 0 and L2.where = 0 and L3.where = 0 THEN L1.name";
qry+= " WHEN L3.where = 0 and L2.where = 0 THEN L2.name";
qry+= " ELSE L3.name END,";
qry+= " CASE WHEN L1.where = 0 and L2.where = 0 and L3.where = 0 THEN L1.locationId";
qry+= " WHEN L3.where = 0 and L2.where = 0 THEN L2.locationId";
qry+= " ELSE L3.locationId END";
qry+= " FROM Locations L1, Locations L2, Locations L3";
qry+= " WHERE L2.locationId = L1.where";
qry+= " AND L3.locationId = L2.where";
qry+= " AND L1.locationId = (";
qry+= "select L.locationId from Sensors S, Locations L where S.sensorId = ";
qry+= lastSensorId + " and L.locationId = S.locationId LIMIT 1)";
// qDebug()<<qry;
// qDebug()<<"..locn query";
if (!locnQuery.exec(qry))
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText("Cannot select from location or sensor tables!");
msgBox.exec();
msgBox.setText(locnQuery.lastError().text());
msgBox.exec();
qDebug()<<locnQuery.lastError();
qDebug()<<locnQuery.executedQuery();
return;
}
if (!locnQuery.next())
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText("Cannot select row from location query!");
//.........这里部分代码省略.........
示例12: setTimeStamp
void HouseNumber::setTimeStamp(const int y, const int m, const int d) {
timeStamp_=QDate(y,m,d);
}
示例13: QByteArray
void tst_QQmlMetaObject::property_data()
{
QTest::addColumn<QString>("testFile");
QTest::addColumn<QByteArray>("cppTypeName");
QTest::addColumn<int>("cppType");
QTest::addColumn<bool>("isDefault");
QTest::addColumn<QVariant>("expectedValue");
QTest::addColumn<bool>("isWritable");
QTest::addColumn<QVariant>("newValue");
QTest::newRow("int") << "property.int.qml"
<< QByteArray("int") << int(QMetaType::Int)
<< false // default
<< QVariant(19) << true << QVariant(42);
QTest::newRow("bool") << "property.bool.qml"
<< QByteArray("bool") << int(QMetaType::Bool)
<< true // default
<< QVariant(true) << true << QVariant(false);
QTest::newRow("double") << "property.double.qml"
<< QByteArray("double") << int(QMetaType::Double)
<< false // default
<< QVariant(double(1234567890.))
<< true // writable
<< QVariant(double(1.23456789));
QTest::newRow("real") << "property.real.qml"
<< QByteArray("double") << int(QMetaType::Double)
<< false // default
<< QVariant(double(1234567890.))
<< true // writable
<< QVariant(double(1.23456789));
QTest::newRow("string") << "property.string.qml"
<< QByteArray("QString") << int(QMetaType::QString)
<< true // default
<< QVariant(QString::fromLatin1("dog"))
<< true // writable
<< QVariant(QString::fromLatin1("food"));
QTest::newRow("url") << "property.url.qml"
<< QByteArray("QUrl") << int(QMetaType::QUrl)
<< false // default
<< QVariant(QUrl("http://foo.bar"))
<< true //writable
<< QVariant(QUrl("http://bar.baz"));
QTest::newRow("color") << "property.color.qml"
<< QByteArray("QColor") << int(QMetaType::QColor)
<< true // default
<< QVariant(QColor("#ff0000"))
<< true // writable
<< QVariant(QColor("#00ff00"));
QTest::newRow("date") << "property.date.qml"
<< QByteArray("QDateTime") << int(QMetaType::QDateTime)
<< false // default
<< QVariant(QDateTime(QDate(2012, 2, 7)))
<< true // writable
<< QVariant(QDateTime(QDate(2010, 7, 2)));
QTest::newRow("variant") << "property.variant.qml"
<< QByteArray("QVariant") << int(QMetaType::QVariant)
<< true // default
<< QVariant(QPointF(12, 34))
<< true // writable
<< QVariant(QSizeF(45, 67));
QTest::newRow("var") << "property.var.qml"
<< QByteArray("QVariant") << int(QMetaType::QVariant)
<< false // default
<< QVariant(QVariantList() << 5 << true << "ciao")
<< true // writable
<< QVariant(QVariantList() << 17.0);
QTest::newRow("QtObject") << "property.QtObject.qml"
<< QByteArray("QObject*") << int(QMetaType::QObjectStar)
<< false // default
<< QVariant()
<< true // writable
<< QVariant::fromValue(static_cast<QObject*>(this));
QTest::newRow("list<QtObject>") << "property.list.QtObject.qml"
<< QByteArray("QQmlListProperty<QObject>")
<< qMetaTypeId<QQmlListProperty<QObject> >()
<< false // default
<< QVariant()
<< false // writable
<< QVariant();
QTest::newRow("MyQmlObject") << "property.MyQmlObject.qml"
<< QByteArray("MyQmlObject*") << qMetaTypeId<MyQmlObject*>()
<< false // default
<< QVariant()
<< true // writable
<< QVariant::fromValue(&myQmlObject);
QTest::newRow("list<MyQmlObject>") << "property.list.MyQmlObject.qml"
<< QByteArray("QQmlListProperty<MyQmlObject>")
<< qMetaTypeId<QQmlListProperty<MyQmlObject> >()
<< false // default
<< QVariant()
<< false // writable
<< QVariant();
QTest::newRow("alias") << "property.alias.qml"
<< QByteArray("QString") << int(QMetaType::QString)
<< false // default
<< QVariant(QString::fromLatin1("Joe"))
<< true // writable
<< QVariant(QString::fromLatin1("Bob"));
QTest::newRow("alias-2") << "property.alias.2.qml"
<< QByteArray("QObject*") << int(QMetaType::QObjectStar)
//.........这里部分代码省略.........
示例14: QByteArray
/**
* @brief Clears contents of the movie based on a list
* @param infos List of infos which should be cleared
*/
void Movie::clear(QList<int> infos)
{
if (infos.contains(MovieScraperInfos::Actors))
m_actors.clear();
if (infos.contains(MovieScraperInfos::Backdrop)) {
m_backdrops.clear();
m_images.insert(ImageType::MovieBackdrop, QByteArray());
m_hasImageChanged.insert(ImageType::MovieBackdrop, false);
m_imagesToRemove.removeOne(ImageType::MovieBackdrop);
}
if (infos.contains(MovieScraperInfos::CdArt)) {
m_discArts.clear();
m_images.insert(ImageType::MovieCdArt, QByteArray());
m_hasImageChanged.insert(ImageType::MovieCdArt, false);
m_imagesToRemove.removeOne(ImageType::MovieCdArt);
}
if (infos.contains(MovieScraperInfos::Countries))
m_countries.clear();
if (infos.contains(MovieScraperInfos::Genres))
m_genres.clear();
if (infos.contains(MovieScraperInfos::Poster)){
m_posters.clear();
m_images.insert(ImageType::MoviePoster, QByteArray());
m_hasImageChanged.insert(ImageType::MoviePoster, false);
m_numPrimaryLangPosters = 0;
m_imagesToRemove.removeOne(ImageType::MoviePoster);
}
if (infos.contains(MovieScraperInfos::Studios))
m_studios.clear();
if (infos.contains(MovieScraperInfos::Title))
m_originalName = "";
if (infos.contains(MovieScraperInfos::Set))
m_set = "";
if (infos.contains(MovieScraperInfos::Overview)) {
m_overview = "";
m_outline = "";
}
if (infos.contains(MovieScraperInfos::Rating)) {
m_rating = 0;
m_votes = 0;
}
if (infos.contains(MovieScraperInfos::Released))
m_released = QDate(2000, 02, 30); // invalid date
if (infos.contains(MovieScraperInfos::Tagline))
m_tagline = "";
if (infos.contains(MovieScraperInfos::Runtime))
m_runtime = 0;
if (infos.contains(MovieScraperInfos::Trailer))
m_trailer = "";
if (infos.contains(MovieScraperInfos::Certification))
m_certification = "";
if (infos.contains(MovieScraperInfos::Writer))
m_writer = "";
if (infos.contains(MovieScraperInfos::Director))
m_director = "";
if (infos.contains(MovieScraperInfos::Tags))
m_tags.clear();
if (infos.contains(MovieScraperInfos::Logo)) {
m_images.insert(ImageType::MovieLogo, QByteArray());
m_hasImageChanged.insert(ImageType::MovieLogo, false);
m_imagesToRemove.removeOne(ImageType::MovieLogo);
}
if (infos.contains(MovieScraperInfos::ClearArt)) {
m_images.insert(ImageType::MovieClearArt, QByteArray());
m_hasImageChanged.insert(ImageType::MovieClearArt, false);
m_imagesToRemove.removeOne(ImageType::MovieClearArt);
}
if (infos.contains(MovieScraperInfos::Banner)) {
m_images.insert(ImageType::MovieBanner, QByteArray());
m_hasImageChanged.insert(ImageType::MovieBanner, false);
m_imagesToRemove.removeOne(ImageType::MovieBanner);
}
if (infos.contains(MovieScraperInfos::Thumb)) {
m_images.insert(ImageType::MovieThumb, QByteArray());
m_hasImageChanged.insert(ImageType::MovieThumb, false);
m_imagesToRemove.removeOne(ImageType::MovieThumb);
}
if (infos.contains(MovieScraperInfos::ExtraFanarts)) {
m_extraFanartsToRemove.clear();
m_extraFanartImagesToAdd.clear();
m_extraFanarts.clear();
}
}
示例15: getDevice
void CDeviceGarmin::slotTimeout()
{
Garmin::IDevice * dev = getDevice();
if(dev == 0) return;
Garmin::Pvt_t pvt;
try
{
dev->getRealTimePos(pvt);
}
catch(int)
{
timer->stop();
log.fix = CLiveLog::eOff;
emit sigLiveLog(log);
QMessageBox::warning(0,tr("Device Link Error"),dev->getLastError().c_str(),QMessageBox::Ok,QMessageBox::NoButton);
return;
}
log.fix = pvt.fix == 3 || pvt.fix == 5 ? CLiveLog::e3DFix : pvt.fix == 2 || pvt.fix == 4 ? CLiveLog::e2DFix : CLiveLog::eNoFix;
if(log.fix != CLiveLog::eNoFix)
{
log.lon = pvt.lon;
log.lat = pvt.lat;
log.ele = pvt.alt + pvt.msl_hght;
QDateTime t(QDate(1989,12,31), QTime(0,0), Qt::UTC);
t = t.addDays(pvt.wn_days).addSecs((int)(pvt.tow + 0.5)).addSecs(-pvt.leap_scnds);
log.timestamp = t.toLocalTime().toTime_t();
// multiply by 100 to avoid leaving the float range.
float heading = fabsf((100.0 * pvt.east) / (100.0 * pvt.north));
heading = atanf(heading) / (2*M_PI) * 360.0;
if( (pvt.north > 0.0) & (pvt.east > 0.0) )
{
// 1st quadrant
heading = heading;
}
else if( (pvt.north > 0.0) & (pvt.east < 0.0) )
{
// 2nd quadrant
heading = 360.0 - heading;
}
else if( (pvt.north < 0.0) & (pvt.east < 0.0) )
{
// 3rd quadrant
heading = 180.0 + heading;
}
else if( (pvt.north < 0.0) & (pvt.east > 0.0) )
{
// 4th quadrant
heading = 180.0 - heading;
}
else
{
heading = std::numeric_limits<float>::quiet_NaN();
}
log.heading = heading;
log.velocity = sqrtf( pvt.north * pvt.north + pvt.east * pvt.east );
//HS: moved division by 2 from CLiveLogDB.cpp
log.error_horz = pvt.eph/2.0;
//HS: moved division by 2 from CLiveLogDB.cpp
log.error_vert = pvt.epv/2.0;
}
emit sigLiveLog(log);
}