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


C++ QDate::month方法代码示例

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


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

示例1: QComboBox

DateBox::DateBox(QWidget * parent, int i, int f, QDate dataToSet):QWidget(parent),annoInizio(i),annoFine(f){
    giorno=new QComboBox(parent);
    mese=new QComboBox(parent);
    anno=new QComboBox(parent);
    giorno->setFixedWidth(100);
    mese->setFixedWidth(100);
    anno->setFixedWidth(100);
    generaNumeri(giorno,1,31);
    generaNumeri(mese,1,12);
    generaNumeri(anno,annoInizio,annoFine);

    giorno->setCurrentText(intToQString(dataToSet.day()));
    mese->setCurrentText(intToQString(dataToSet.month()));
    anno->setCurrentText(intToQString(dataToSet.year()));
    QHBoxLayout* lay=new QHBoxLayout;
    lay->setSizeConstraint(QLayout::SetFixedSize);
    lay->addWidget(giorno);
    lay->addWidget(mese);
    lay->addWidget(anno);
    setLayout(lay);
    connect(mese,SIGNAL(activated(int)),this,SLOT(aggiornaGiorni()));
    connect(anno,SIGNAL(activated(int)),this,SLOT(aggiornaGiorni()));
}
开发者ID:oeconti,项目名称:LinQedIn,代码行数:23,代码来源:datebox.cpp

示例2: on_confirmButton_clicked

void TodoList::on_confirmButton_clicked(){
    QString name = ui->nameBox->text();
    if(name.size() == 0){
        warnAniTime = 30;
        return;
    }

    TodoItem item;

    item.SetName(name.toStdString());
    item.SetPlace(ui->placeBox->text().toStdString());
    item.SetContent(ui->contentBox->toPlainText().toStdString());
    item.SetLabel(ui->labelBox->text().toStdString());

    item.SetKind(ui->comboBox->currentIndex());

    QDateTime dateTime = ui->dateTimeEdit->dateTime();
    QDate date = dateTime.date();
    QTime ti = dateTime.time();
    item.SetTime(Date(date.year(),date.month(),date.day(),ti.hour(),ti.minute()));
    item.SetWarnTime(ui->horizontalSlider->value() * 5); //以分为单位

    int level = 0;
    if (ui->radioButton_1->isChecked()) level = 3;
    if (ui->radioButton_2->isChecked()) level = 1;
    if (ui->radioButton_3->isChecked()) level = 2;
    if (ui->radioButton_4->isChecked()) level = 0;
    item.SetLevel(level);

    if(state == WINSTATE::EDIT){
        pa.AddTodo(item);
    }else if(state == WINSTATE::DETAIL){
        pa.ChangeTodo(item,selectID,viewDate.year,viewDate.month);
    }

    ChangeState(WINSTATE::LIST);
}
开发者ID:wkcn,项目名称:TodoList,代码行数:37,代码来源:TodoList.cpp

示例3: qsa_eval_check

void qsa_eval_check()
{
  QSettings settings;
  settings.insertSearchPath(QSettings::Windows, "/Trolltech");
  QString key = QString("/QSA/%1/expdt").arg(QSA_VERSION_STRING);

  bool ok;
  bool showWarning = FALSE;
  QString str = settings.readEntry(key, QString::null, &ok);
  if (ok) {
    QRegExp exp("(\\w\\w\\w\\w)(\\w\\w)(\\w\\w)");
    Q_ASSERT(exp.isValid());
    if (exp.search(str) >= 0) {
      int a = exp.cap(1).toInt(0, 16);
      int b = exp.cap(2).toInt(0, 16);
      int c = exp.cap(3).toInt(0, 16);
      showWarning = (QDate::currentDate() > QDate(a, b, c));
    } else {
      showWarning = TRUE;
    }
  } else {
    QDate date = QDate::currentDate().addMonths(1);
    QString str = QString().sprintf("%.4x%.2x%.2x", date.year(), date.month(), date.day());
    settings.writeEntry(key, str);
  }

  if (showWarning) {
    QMessageBox::warning(0,
                         QObject::tr("End of Evaluation Period"),
                         QObject::tr("The evaluation period of QSA has expired.\n\n"
                                     "Please check http://www.trolltech.com/products/qsa"
                                     "for updates\n"
                                     "or contact [email protected] for further information"),
                         QMessageBox::Ok,
                         QMessageBox::NoButton);
  }
}
开发者ID:gestiweb,项目名称:eneboo,代码行数:37,代码来源:qsinterpreter.cpp

示例4: changeDateTime

QString DateTimePlugin::changeDateTime( const QString & filename, bool bModification, bool bAccess, 
                                        const QDate & date, const QTime & time ) 
{
    // Initialze fields
    struct tm tmp;
    tmp.tm_mday = date.day();
    tmp.tm_mon  = date.month() - 1;
    tmp.tm_year = date.year() - 1900;

    tmp.tm_hour = time.hour();
    tmp.tm_min  = time.minute();
    tmp.tm_sec  = time.second();
    tmp.tm_isdst = -1;

    // Create time
    time_t ti;
    ti = mktime( &tmp );

    if( ti == -1 )
        return QString( i18n("Can't change date of file %1. (Cannot mktime)") ).arg(filename);

    // Get current values 
    struct stat st;
    if( stat( filename.toUtf8().data(), &st ) == -1 )
        return QString( i18n("Can't change date of file %1. (Cannot stat the file)") ).arg(filename);

    // Fill structure;
    struct utimbuf buf;

    buf.actime  = (bAccess ? ti : st.st_atime);
    buf.modtime = (bModification ? ti: st.st_mtime);
    
    if(utime( filename.toUtf8().data(), &buf ) != 0)
        return QString( i18n("Can't change date of file %1. (utime failed)") ).arg(filename);

    return QString::null;
}
开发者ID:inactivist,项目名称:Krename,代码行数:37,代码来源:datetimeplugin.cpp

示例5: data

QVariant QQuickMonthModel::data(const QModelIndex &index, int role) const
{
    Q_D(const QQuickMonthModel);
    if (index.isValid() && index.row() < daysOnACalendarMonth) {
        const QDate date = d->dates.at(index.row());
        switch (role) {
        case DateRole:
            return date;
        case DayRole:
            return date.day();
        case TodayRole:
            return date == d->today;
        case WeekNumberRole:
            return date.weekNumber();
        case MonthRole:
            return date.month() - 1;
        case YearRole:
            return date.year();
        default:
            break;
        }
    }
    return QVariant();
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:24,代码来源:qquickmonthmodel.cpp

示例6: QString

void Exif2GPX::addWaypoint(QDomElement& elt, std::pair<double,double> position,
			   QDateTime time, const QString& prefix, 
			   const QString& name) {
  QDomDocument qdd = elt.ownerDocument();
  QDomElement wptElt = qdd.createElement("wpt");
  wptElt.setAttribute("lat", QString("%1").arg(position.first, 0, 'f'));
  wptElt.setAttribute("lon", QString("%1").arg(position.second, 0, 'f'));
  QDomElement timeElt = qdd.createElement("time");
  char buffer[22];
  std::memset(buffer, 0, 22);
  QDate d = time.date();
  QTime t = time.time();
  std::sprintf(buffer, "%04d-%02d-%02dT%02d:%02d:%02dZ", 
	       d.year(), d.month(), d.day(), t.hour(), t.minute(), t.second());
  timeElt.appendChild(qdd.createTextNode(buffer));
  wptElt.appendChild(timeElt);
  QDomElement urlElt = qdd.createElement("url");
  urlElt.appendChild(qdd.createTextNode(prefix + name));
  wptElt.appendChild(urlElt);
  QDomElement nameElt = qdd.createElement("name");
  nameElt.appendChild(qdd.createTextNode(name));
  wptElt.appendChild(nameElt);
  elt.appendChild(wptElt);
}
开发者ID:alexckp,项目名称:qgis,代码行数:24,代码来源:exif2gpx.cpp

示例7: SetAttr

void wxCalendarCtrl::SetAttr(size_t day, wxCalendarDateAttr *attr)
{
    wxCHECK_RET( day > 0 && day < 32, wxT("invalid day") );

    delete m_attrs[day - 1];
    m_attrs[day - 1] = attr;

    QDate date = m_qtCalendar->selectedDate();
    date.setDate(date.year(), date.month(), day);

    QTextCharFormat format = m_qtCalendar->dateTextFormat(date);
    if ( attr->HasTextColour() )
        format.setForeground(attr->GetTextColour().GetHandle());
    if ( attr->HasBackgroundColour() )
        format.setBackground(attr->GetBackgroundColour().GetHandle());

    wxMISSING_IMPLEMENTATION( "Setting font" );

    // wxFont is not implemented yet
    //if ( attr->HasFont() )
    //    format.setFont(attr->GetFont().GetQFont());
    
    m_qtCalendar->setDateTextFormat(date, format);
}
开发者ID:jfiguinha,项目名称:Regards,代码行数:24,代码来源:calctrl.cpp

示例8: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QTranslator t;
    QDate today = QDate::currentDate();
    if ( today.month() == 4 && today.day() == 1 )
    {
        t.load(":/translations/koi7.qm");
    }
    else
    {
        t.load(":/translations/ru.qm");
    }
    QApplication::installTranslator(&t);

    Settings::instance();
    Logger::logger();

    QPixmap logo(":/resources/logo.png");
    QSplashScreen *splash =
            new QSplashScreen(logo, Qt::FramelessWindowHint | Qt::SplashScreen);

    splash->setMask( logo.mask() );

    splash->show();
    Settings::instance()->updateLocalData();
    splash->close();

    delete splash;

    LauncherWindow w;
    w.show();

    return a.exec();
}
开发者ID:zaitsevyan,项目名称:ttyhlauncher,代码行数:36,代码来源:main.cpp

示例9: data

	QVariant CalendarModel::data(const QModelIndex & index, int role) const {

		if (not index.isValid())
			return QVariant();

		int week = index.row();
		int day = index.column();

		QDate date = m_week_days[week][day];

		switch (role) {
			case Qt::DisplayRole:
				return QVariant(date.day());
			case Qt::ForegroundRole:
				if (date.month() == m_current_month)
					return QVariant(QColor(Qt::black));
				else
					return QVariant(QColor(Qt::lightGray));
			default:
				break;
		}

		return QVariant();
	}
开发者ID:Jellofishi,项目名称:JBLib2,代码行数:24,代码来源:calendar_model.cpp

示例10: SamePeriod

bool GenericCashFlowPrivate::SamePeriod(const QDate& a, const QDate& b, GenericCashFlow::CashFlowAggregation Freq)
{
	int YearA=0, YearB=0;
	bool Result;
	switch (Freq) {
    case GenericCashFlow::TotalAggragate:
		return true;
    case GenericCashFlow::Annually:
		return a.year() == b.year();
    case GenericCashFlow::SemiAnnually:
		return a.year() == b.year() && (a.month() - 1) / 6 == (b.month() - 1) / 6;
    case GenericCashFlow::Quarterly:
		return a.year() == b.year() && (a.month() - 1) / 3 == (b.month() - 1) / 3;
    case GenericCashFlow::Monthly:
		return a.year() == b.year() && a.month() == b.month();
    case GenericCashFlow::Weekly:
		Result = a.weekNumber(&YearA) == b.weekNumber(&YearB);
		return Result && YearA == YearB;
    case GenericCashFlow::NoAggregation:
	default:
		return a==b;
	}
}
开发者ID:VSRonin,项目名称:CLOModel,代码行数:23,代码来源:GenericCashFlow.cpp

示例11: refreshLoginList

void Tab_Logins::refreshLoginList(long)
{
    ADB     DB;
    QString tmpstr = "";
    QString tmpQItemID = "";
    QString tmpQActive = "";
    QString	qds;
    ADB	    DB2;

    bool    showIt = true;
    char    isActive[128];
    char    dateStamp[128];
    QDate   d;
    QTime   t;
    
    list->clear();

    DB.query("select Logins.LoginID, LoginTypes.LoginType, Logins.ContactName, Logins.LastModified, Logins.DiskSpace, Logins.DialupChannels, Logins.Active from Logins, LoginTypes where Logins.CustomerID = %ld and Logins.LoginType = LoginTypes.InternalID", myCustID);
    if (DB.rowCount) while (DB.getrow()) {
        strcpy(isActive, "No");
        if (atoi(DB.curRow["Active"])) strcpy(isActive, "Yes");

        // Get the date stamp.
        strcpy(dateStamp, "Unknown");
        if (strncmp("0000", DB.curRow["LastModified"], 4)) {
            // There is a date in the LastModified field.
            d = DB.curRow.col("LastModified")->toQDateTime().date();
            t = DB.curRow.col("LastModified")->toQDateTime().time();

            sprintf(dateStamp, "%04d-%02d-%02d %2d:%02d", d.year(), d.month(), d.day(), t.hour(), t.minute());
            
        }

        // Count how many custom flags there are.
        QString flagCount = "0";
        DB2.query("select count(LoginFlag) from LoginFlagValues where LoginID = '%s'", DB.curRow["LoginID"]);
        if (DB2.rowCount) {
            DB2.getrow();
            flagCount = DB2.curRow[0];
        }

        showIt = true;
        if (hideWiped->isChecked() && !strncmp("W", DB.curRow["LoginID"], 1)) showIt = false;
        if (showIt) {
            (void) new Q3ListViewItem(list,
              DB.curRow["LoginID"],         // Login ID
              DB.curRow["LoginType"],       // Login Type
              DB.curRow["ContactName"],     // Contact Name
              dateStamp,                    // Last Modified Date
              DB.curRow["DiskSpace"],       // Disk Space
              flagCount,                    // Custom flags
              isActive                      // Active?
            );
        }
    }

    /*
    
	// Fill in the subscriptions ListBox
	if (hideWiped->isChecked()) {
        sprintf(querystr, "select LoginID, LoginType, ContactName, LastModified, DiskSpace, DialupChannels, Active from Logins where CustomerID = %ld and Wiped < '1970-01-01' order by LoginID", myCustID);
    } else {
        sprintf(querystr, "select LoginID, LoginType, ContactName, LastModified, DiskSpace, DialupChannels, Active from Logins where CustomerID = %ld order by LoginID", myCustID);
    }
	DB.query("%s", querystr);
	// subscrIndex = new(int[DB.rowCount + 1]);
	int idxPtr = 0;
	while(DB.getrow()) {
		// subscrIndex[idxPtr] = atoi(DB.curRow[0]);
		idxPtr++;
		tmpQItemID = DB.curRow["ContactName"];
		tmpQItemID.truncate(11);
		strcpy(tmpItemID, tmpQItemID);
		    
		tmpQActive = "No";
		if (atoi(DB.curRow["Active"])) {
			tmpQActive = "Yes";
		}
		strcpy(tmpActive, tmpQActive);
		
		
		DB2.query("select LoginType from LoginTypes where InternalID = %d", atoi(DB.curRow["LoginType"]));
		if (DB2.getrow()) {
            strcpy(loginType, DB2.curRow["LoginID"]);
		} else {
            strcpy(loginType, "Unknown");
		}
		
		// Parse out the time stamp.
		qds = DB.curRow["LastModified"];
		sprintf(tmpDateStamp, "%4s-%2s-%2s %2s:%2s.%2s",
		  (const char *) qds.mid(0,4),
		  (const char *) qds.mid(4,2),
		  (const char *) qds.mid(6,2),
		  (const char *) qds.mid(8,2),
		  (const char *) qds.mid(10,2),
		  (const char *) qds.mid(12,2)
		);
		    
		(void) new QListViewItem(list,
//.........这里部分代码省略.........
开发者ID:gottafixthat,项目名称:tacc,代码行数:101,代码来源:Tab_Logins.cpp

示例12: useStandardRange

void 
DateSettingsEdit::setDateSettings()
{
    if (active) return;

    // first lets disable everything
    active = true;
    fromDateEdit->setEnabled(false);
    toDateEdit->setEnabled(false);
    startDateEdit->setEnabled(false);
    thisperiod->setEnabled(false);
    prevperiod->setEnabled(false);
    lastn->setEnabled(false);
    lastnx->setEnabled(false);

    // the date selection types have changed
    if (radioSelected->isChecked()) {

        // current selection
        emit useStandardRange();

    } else if (radioCustom->isChecked()) {

        // between x and y
        fromDateEdit->setEnabled(true);
        toDateEdit->setEnabled(true);

        // set date range using custom values
        emit useCustomRange(DateRange(fromDateEdit->date(), toDateEdit->date()));

    } else if (radioToday->isChecked()) {

        // current selected thru to today
        emit useThruToday();

    } else if (radioLast->isChecked()) {

        // last n 'weeks etc'
        lastn->setEnabled(true);
        lastnx->setEnabled(true);

        QDate from;
        QDate today = QDate::currentDate();

        // calculate range up to today...
        switch(lastnx->currentIndex()) {
            case 0 : // days
                from = today.addDays(lastn->value() * -1);
                break;

            case 1 :  // weeks
                from = today.addDays(lastn->value() * -7);
                break;

            case 2 :  // months
                from = today.addMonths(lastn->value() * -1);
                break;

            case 3 : // years
                from = today.addYears(lastn->value() * -1);
                break;
        }

        emit useCustomRange(DateRange(from, today));

    } else if (radioFrom->isChecked()) {

        // from date - today
        startDateEdit->setEnabled(true);
        emit useCustomRange(DateRange(startDateEdit->date(), QDate::currentDate()));

    } else if (radioThis->isChecked()) {

        thisperiod->setEnabled(true);
        prevperiod->setEnabled(true);

        QDate today = QDate::currentDate();
        QDate from, to;

        switch(thisperiod->currentIndex()) {

        case 0 : // weeks
            {
                int dow = today.dayOfWeek(); // 1-7, where 1=monday
                from = today.addDays(-1 * (dow-1));
                to = from.addDays(6);
                // prevperiods
                from = from.addDays(prevperiod->value() * -7);
                to = to.addDays(prevperiod->value() * -7);
            }
            break;

        case 1 : // months
            from = QDate(today.year(), today.month(), 1);
            to = from.addMonths(1).addDays(-1);
            from = from.addMonths(prevperiod->value() * -1);
            to = to.addMonths(prevperiod->value() * -1);
            break;

        case 2 : // years
//.........这里部分代码省略.........
开发者ID:ClaFio,项目名称:GoldenCheetah,代码行数:101,代码来源:TimeUtils.cpp

示例13: createBudget

void MyMoneyForecast::createBudget ( MyMoneyBudget& budget, QDate historyStart, QDate historyEnd, QDate budgetStart, QDate budgetEnd, const bool returnBudget )
{
  // clear all data except the id and name
  QString name = budget.name();
  budget = MyMoneyBudget(budget.id(), MyMoneyBudget());
  budget.setName(name);

  //check parameters
  if ( historyStart > historyEnd ||
       budgetStart > budgetEnd ||
       budgetStart <= historyEnd )
  {
    throw new MYMONEYEXCEPTION ( "Illegal parameters when trying to create budget" );
  }

  //get forecast method
  int fMethod = forecastMethod();

  //set start date to 1st of month and end dates to last day of month, since we deal with full months in budget
  historyStart = QDate ( historyStart.year(), historyStart.month(), 1 );
  historyEnd = QDate ( historyEnd.year(), historyEnd.month(), historyEnd.daysInMonth() );
  budgetStart = QDate ( budgetStart.year(), budgetStart.month(), 1 );
  budgetEnd = QDate ( budgetEnd.year(), budgetEnd.month(), budgetEnd.daysInMonth() );

  //set forecast parameters
  setHistoryStartDate ( historyStart );
  setHistoryEndDate ( historyEnd );
  setForecastStartDate ( budgetStart );
  setForecastEndDate ( budgetEnd );
  setForecastDays ( budgetStart.daysTo ( budgetEnd ) + 1 );
  if ( budgetStart.daysTo ( budgetEnd ) > historyStart.daysTo ( historyEnd ) ) { //if history period is shorter than budget, use that one as the trend length
    setAccountsCycle ( historyStart.daysTo ( historyEnd ) ); //we set the accountsCycle to the base timeframe we will use to calculate the average (eg. 180 days, 365, etc)
  } else { //if one timeframe is larger than the other, but not enough to be 1 time larger, we take the lowest value
    setAccountsCycle ( budgetStart.daysTo ( budgetEnd ) );
  }
  setForecastCycles ( ( historyStart.daysTo ( historyEnd ) / accountsCycle() ) );
  if ( forecastCycles() == 0 ) //the cycles must be at least 1
    setForecastCycles ( 1 );

  //do not skip opening date
  setSkipOpeningDate ( false );

  //clear and set accounts list we are going to use. Categories, in this case
  m_nameIdx.clear();
  setBudgetAccountList();

  //calculate budget according to forecast method
  switch(fMethod)
  {
    case eScheduled:
      doFutureScheduledForecast();
      calculateScheduledMonthlyBalances();
      break;
    case eHistoric:
      pastTransactions(); //get all transactions for history period
      calculateAccountTrendList();
      calculateHistoricMonthlyBalances(); //add all balances of each month and put at the 1st day of each month
      break;
    default:
      break;
  }

  //flag the forecast as done
  m_forecastDone = true;

  //only fill the budget if it is going to be used
  if ( returnBudget ) {
    //setup the budget itself
    MyMoneyFile* file = MyMoneyFile::instance();
    budget.setBudgetStart ( budgetStart );

    //go through all the accounts and add them to budget
    QMap<QString, QString>::ConstIterator it_nc;
    for ( it_nc = m_nameIdx.begin(); it_nc != m_nameIdx.end(); ++it_nc ) {
      MyMoneyAccount acc = file->account ( *it_nc );

      MyMoneyBudget::AccountGroup budgetAcc;
      budgetAcc.setId ( acc.id() );
      budgetAcc.setBudgetLevel ( MyMoneyBudget::AccountGroup::eMonthByMonth );

      for ( QDate f_date = forecastStartDate(); f_date <= forecastEndDate(); ) {
        MyMoneyBudget::PeriodGroup period;

        //add period to budget account
        period.setStartDate ( f_date );
        period.setAmount ( forecastBalance ( acc, f_date ) );
        budgetAcc.addPeriod ( f_date, period );

        //next month
        f_date = f_date.addMonths ( 1 );
      }
      //add budget account to budget
      budget.setAccount ( budgetAcc, acc.id() );
    }
  }
}
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:96,代码来源:mymoneyforecast.cpp

示例14: convertTimeDate

QString convertTimeDate(const QString &mac_format, const QDateTime &datetime)
{
    QDate date = datetime.date();
    QTime time = datetime.time();
    QString str;
    if (mac_format.contains('%'))
    {
        const QChar *chars = mac_format.constData();
        bool is_percent = false;
        int length = 0;
        bool error = false;
        while ((*chars).unicode() && !error)
        {
            if (is_percent)
            {
                is_percent = false;
                switch ((*chars).unicode())
                {
                case L'%':
                    str += *chars;
                    break;
                case L'a':
                    appendStr(str, QDate::shortDayName(date.dayOfWeek()), length);
                    break;
                case L'A':
                    appendStr(str, QDate::longDayName(date.dayOfWeek()), length);
                    break;
                case L'b':
                    appendStr(str, QDate::shortMonthName(date.day()), length);
                    break;
                case L'B':
                    appendStr(str, QDate::longMonthName(date.day()), length);
                    break;
                case L'c':
                    appendStr(str, QLocale::system().toString(datetime), length);
                    break;
                case L'd':
                    appendInt(str, date.day(), length > 0 ? length : 2);
                    break;
                case L'e':
                    appendInt(str, date.day(), length);
                    break;
                case L'F':
                    appendInt(str, time.msec(), length > 0 ? length : 3);
                    break;
                case L'H':
                    appendInt(str, time.hour(), length > 0 ? length : 2);
                    break;
                case L'I':
                    appendInt(str, time.hour() % 12, length > 0 ? length : 2);
                    break;
                case L'j':
                    appendInt(str, date.dayOfYear(), length > 0 ? length : 3);
                    break;
                case L'm':
                    appendInt(str, date.month(), length > 0 ? length : 2);
                    break;
                case L'M':
                    appendInt(str, time.minute(), length > 0 ? length : 2);
                    break;
                case L'p':
                    appendStr(str, time.hour() < 12 ? "AM" : "PM", length);
                    break;
                case L'S':
                    appendInt(str, time.second(), length > 0 ? length : 2);
                    break;
                case L'w':
                    appendInt(str, date.dayOfWeek(), length);
                    break;
                case L'x':
                    appendStr(str, QLocale::system().toString(date), length);
                    break;
                case L'X':
                    appendStr(str, QLocale::system().toString(time), length);
                    break;
                case L'y':
                    appendInt(str, date.year() % 100, length > 0 ? length : 2);
                    break;
                case L'Y':
                    appendInt(str, date.year(), length > 0 ? length : 4);
                    break;
                case L'Z':
                    // It should be localized, isn't it?..
                    appendStr(str, SystemInfo::instance()->timezone(), length);
                    break;
                case L'z':
                {
                    int offset = SystemInfo::instance()->timezoneOffset();
                    appendInt(str, (offset/60)*100 + offset%60, length > 0 ? length : 4);
                    break;
                }
                default:
                    if ((*chars).isDigit())
                    {
                        is_percent = true;
                        length *= 10;
                        length += (*chars).digitValue();
                    }
                    else
                        error = true;
//.........这里部分代码省略.........
开发者ID:partition,项目名称:kadu,代码行数:101,代码来源:adium-time-formatter.cpp

示例15: getSetCheck

// Testing get/set functions
void tst_QCalendarWidget::getSetCheck()
{
    QWidget topLevel;
    QCalendarWidget object(&topLevel);

    //horizontal header formats
    object.setHorizontalHeaderFormat(QCalendarWidget::NoHorizontalHeader);
    QCOMPARE(QCalendarWidget::NoHorizontalHeader, object.horizontalHeaderFormat());
    object.setHorizontalHeaderFormat(QCalendarWidget::SingleLetterDayNames);
    QCOMPARE(QCalendarWidget::SingleLetterDayNames, object.horizontalHeaderFormat());
    object.setHorizontalHeaderFormat(QCalendarWidget::ShortDayNames);
    QCOMPARE(QCalendarWidget::ShortDayNames, object.horizontalHeaderFormat());
    object.setHorizontalHeaderFormat(QCalendarWidget::LongDayNames);
    QCOMPARE(QCalendarWidget::LongDayNames, object.horizontalHeaderFormat());
    //vertical header formats
    object.setVerticalHeaderFormat(QCalendarWidget::ISOWeekNumbers);
    QCOMPARE(QCalendarWidget::ISOWeekNumbers, object.verticalHeaderFormat());
    object.setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);
    QCOMPARE(QCalendarWidget::NoVerticalHeader, object.verticalHeaderFormat());
    //maximum Date
    QDate maxDate(2006, 7, 3);
    object.setMaximumDate(maxDate);
    QCOMPARE(maxDate, object.maximumDate());
    //minimum date
    QDate minDate(2004, 7, 3);
    object.setMinimumDate(minDate);
    QCOMPARE(minDate, object.minimumDate());
    //day of week
    object.setFirstDayOfWeek(Qt::Thursday);
    QCOMPARE(Qt::Thursday, object.firstDayOfWeek());
    //grid visible
    object.setGridVisible(true);
    QVERIFY(object.isGridVisible());
    object.setGridVisible(false);
    QVERIFY(!object.isGridVisible());
    //header visible
    object.setNavigationBarVisible(true);
    QVERIFY(object.isNavigationBarVisible());
    object.setNavigationBarVisible(false);
    QVERIFY(!object.isNavigationBarVisible());
    //selection mode
    QCOMPARE(QCalendarWidget::SingleSelection, object.selectionMode());
    object.setSelectionMode(QCalendarWidget::NoSelection);
    QCOMPARE(QCalendarWidget::NoSelection, object.selectionMode());
    object.setSelectionMode(QCalendarWidget::SingleSelection);
    QCOMPARE(QCalendarWidget::SingleSelection, object.selectionMode());
   //selected date
    QDate selectedDate(2005, 7, 3);
    QSignalSpy spy(&object, SIGNAL(selectionChanged()));
    object.setSelectedDate(selectedDate);
    QCOMPARE(spy.count(), 1);
    QCOMPARE(selectedDate, object.selectedDate());
    //month and year
    object.setCurrentPage(2004, 1);
    QCOMPARE(1, object.monthShown());
    QCOMPARE(2004, object.yearShown());
    object.showNextMonth();
    QCOMPARE(2, object.monthShown());
    object.showPreviousMonth();
    QCOMPARE(1, object.monthShown());
    object.showNextYear();
    QCOMPARE(2005, object.yearShown());
    object.showPreviousYear();
    QCOMPARE(2004, object.yearShown());
    //date range
    minDate = QDate(2006,1,1);
    maxDate = QDate(2010,12,31);
    object.setDateRange(minDate, maxDate);
    QCOMPARE(maxDate, object.maximumDate());
    QCOMPARE(minDate, object.minimumDate());

    //date should not go beyond the minimum.
    selectedDate = minDate.addDays(-10);
    object.setSelectedDate(selectedDate);
    QCOMPARE(minDate, object.selectedDate());
    QVERIFY(selectedDate != object.selectedDate());
    //date should not go beyond the maximum.
    selectedDate = maxDate.addDays(10);
    object.setSelectedDate(selectedDate);
    QCOMPARE(maxDate, object.selectedDate());
    QVERIFY(selectedDate != object.selectedDate());
    //show today
    QDate today = QDate::currentDate();
    object.showToday();
    QCOMPARE(today.month(), object.monthShown());
    QCOMPARE(today.year(), object.yearShown());
    //slect a different date and move.
    object.setSelectedDate(minDate);
    object.showSelectedDate();
    QCOMPARE(minDate.month(), object.monthShown());
    QCOMPARE(minDate.year(), object.yearShown());
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:93,代码来源:tst_qcalendarwidget.cpp


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