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


C++ QLocale::standaloneMonthName方法代码示例

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


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

示例1: standaloneLongMonthName

void tst_QDate::standaloneLongMonthName() const
{
    if (QLocale::system().language() == QLocale::C) {
        QCOMPARE(QDate::longMonthName(1, QDate::StandaloneFormat), QLatin1String("January"));
        QCOMPARE(QDate::longMonthName(8, QDate::StandaloneFormat), QLatin1String("August"));
    }

    QLocale locale = QLocale::system();
    for(int i = 1; i <= 12; ++i) {
        QCOMPARE(QDate::longMonthName(i, QDate::StandaloneFormat), locale.standaloneMonthName(i, QLocale::LongFormat));
    }
}
开发者ID:maxxant,项目名称:qt,代码行数:12,代码来源:tst_qdate.cpp

示例2: populate

bool QQuickMonthModelPrivate::populate(int m, int y, const QLocale &l, bool force)
{
    Q_Q(QQuickMonthModel);
    if (!force && m == month && y == year && l.firstDayOfWeek() == locale.firstDayOfWeek())
        return false;

    // The actual first (1st) day of the month.
    QDate firstDayOfMonthDate(y, m, 1);
    int difference = ((firstDayOfMonthDate.dayOfWeek() - l.firstDayOfWeek()) + 7) % 7;
    // The first day to display should never be the 1st of the month, as we want some days from
    // the previous month to be visible.
    if (difference == 0)
        difference += 7;
    QDate firstDateToDisplay = firstDayOfMonthDate.addDays(-difference);

    today = QDate::currentDate();
    for (int i = 0; i < daysOnACalendarMonth; ++i)
        dates[i] = firstDateToDisplay.addDays(i);

    q->setTitle(l.standaloneMonthName(m) + QStringLiteral(" ") + QString::number(y));

    return true;
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:23,代码来源:qquickmonthmodel.cpp

示例3: journeyResult

void Parser131500ComAu::parseSearchJourney(QNetworkReply *networkReply)
{
    lastJourneyResultList = new JourneyResultList();

    QBuffer *filebuffer = new QBuffer();
    filebuffer->setData(networkReply->readAll());

    QRegExp regexp = QRegExp("<div class=\"midcolumn3\">(.*)</div>(.*)</div>(.*)<div id=\"righttools\">");
    regexp.setMinimal(true);

    regexp.indexIn(filebuffer->buffer());

    QString element = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><html xmlns=\"http://www.w3.org/1999/xhtml\">\n<body>\n" + regexp.cap(0) + "\n</div></body>\n</html>\n";

    QRegExp imgReg = QRegExp("icon_(.*)_s.gif\" />");
    imgReg.setMinimal(true);
    element.replace(imgReg, "icon_" + QString("\\1") + "_s.gif\" />" + QString("\\1"));
    element.replace("am+", "am");
    element.replace("pm+", "pm");

    //qDebug()<<element;

    QBuffer readBuffer;
    readBuffer.setData(element.toAscii());
    readBuffer.open(QIODevice::ReadOnly);

    QXmlQuery query;
    query.bindVariable("path", &readBuffer);
    query.setQuery("declare default element namespace \"http://www.w3.org/1999/xhtml\"; declare variable $path external; doc($path)/html/body/div/div/table/tbody/tr/td[@id='header2']/string()");

    QStringList departResult;
    if (!query.evaluateTo(&departResult))
    {
        qDebug() << "parser131500ComAu::getJourneyData - Query 1 Failed";
    }

    query.setQuery("declare default element namespace \"http://www.w3.org/1999/xhtml\"; declare variable $path external; doc($path)/html/body/div/div/table/tbody/tr/td[@id='header3']/string()");

    QStringList arriveResult;
    if (!query.evaluateTo(&arriveResult))
    {
        qDebug() << "parser131500ComAu::getJourneyData - Query 2 Failed";
    }

    query.setQuery("declare default element namespace \"http://www.w3.org/1999/xhtml\"; declare variable $path external; doc($path)/html/body/div/div/table/tbody/tr/td[@id='header4']/string()");

    QStringList timeResult;
    if (!query.evaluateTo(&timeResult))
    {
        qDebug() << "parser131500ComAu::getJourneyData - Query 3 Failed";
    }

    query.setQuery("declare default element namespace \"http://www.w3.org/1999/xhtml\"; declare variable $path external; doc($path)/html/body/div/div/table/tbody/tr/td[@id='header5']/string()");

    QStringList trainResult;
    if (!query.evaluateTo(&trainResult))
    {
        qDebug() << "parser131500ComAu::getJourneyData - Query 4 Failed";
    }

    query.setQuery("declare default element namespace \"http://www.w3.org/1999/xhtml\"; declare variable $path external; doc($path)/html/body/div/div/div/string()");

    QStringList headerResult;
    if (!query.evaluateTo(&headerResult))
    {
        qDebug() << "parser131500ComAu::getJourneyData - Query 5 Failed";
    }

    for (int i = 0; i < headerResult.count(); i++) {
        QRegExp regexp = QRegExp("(From:|To:|When:)(.*)$");
        regexp.setMinimal(true);
        regexp.indexIn(headerResult[i].trimmed());
        if (regexp.cap(1) == "From:") {
            lastJourneyResultList->setDepartureStation(regexp.cap(2).trimmed());
        }
        if (regexp.cap(1) == "To:") {
            lastJourneyResultList->setArrivalStation(regexp.cap(2).trimmed());
        }
        if (regexp.cap(1) == "When:") {
            lastJourneyResultList->setTimeInfo(regexp.cap(2).trimmed());
        }
    }

    QRegExp regexp2 = QRegExp("(.*), (\\d\\d) (.*) (\\d\\d\\d\\d)");
    regexp2.setMinimal(true);
    regexp2.indexIn(lastJourneyResultList->timeInfo().trimmed());
    QLocale enLocale = QLocale(QLocale::English, QLocale::UnitedStates);
    int month = 1;
    for (month = 1; month < 10; month++) {
        if (regexp2.cap(3).trimmed() == enLocale.standaloneMonthName(month)) {
            break;
        }
    }

    QDate journeydate = QDate::fromString(regexp2.cap(2).trimmed() + " " + QString::number(month) + " " + regexp2.cap(4).trimmed(), "dd M yyyy");

    //Generate Details search results

    QStringList detailsResult;

//.........这里部分代码省略.........
开发者ID:shentok,项目名称:fahrplan,代码行数:101,代码来源:parser_131500comau.cpp

示例4: localeChanged

void DateFormatsWidget::localeChanged(QLocale locale)
{
    setLocale(locale);
    QDateTime now = QDateTime::currentDateTime();
    shortDateFormat->setText(locale.toString(now.date(), QLocale::ShortFormat));
    shortDateFormat->setToolTip(locale.dateFormat(QLocale::ShortFormat));
    longDateFormat->setText(locale.toString(now.date(), QLocale::LongFormat));
    longDateFormat->setToolTip(locale.dateFormat(QLocale::LongFormat));
    shortTimeFormat->setText(locale.toString(now.time(), QLocale::ShortFormat));
    shortTimeFormat->setToolTip(locale.timeFormat(QLocale::ShortFormat));
    longTimeFormat->setText(locale.toString(now.time(), QLocale::LongFormat));
    longTimeFormat->setToolTip(locale.timeFormat(QLocale::LongFormat));
    shortDateTimeFormat->setText(locale.toString(now, QLocale::ShortFormat));
    shortDateTimeFormat->setToolTip(locale.dateTimeFormat(QLocale::ShortFormat));
    longDateTimeFormat->setText(locale.toString(now, QLocale::LongFormat));
    longDateTimeFormat->setToolTip(locale.dateTimeFormat(QLocale::LongFormat));
    amText->setText(locale.amText());
    pmText->setText(locale.pmText());
    firstDayOfWeek->setText(toString(locale.firstDayOfWeek()));

    int mns = monthNamesShort->currentIndex();
    int mnl = monthNamesLong->currentIndex();
    int smns = standaloneMonthNamesShort->currentIndex();
    int smnl = standaloneMonthNamesLong->currentIndex();
    int dnl = dayNamesLong->currentIndex();
    int dns = dayNamesShort->currentIndex();
    int sdnl = standaloneDayNamesLong->currentIndex();
    int sdns = standaloneDayNamesShort->currentIndex();

    monthNamesShort->clear();
    monthNamesLong->clear();
    standaloneMonthNamesShort->clear();
    standaloneMonthNamesLong->clear();
    dayNamesLong->clear();
    dayNamesShort->clear();
    standaloneDayNamesLong->clear();
    standaloneDayNamesShort->clear();

    for (int i = 1; i <= 12; ++i)
        monthNamesShort->addItem(locale.monthName(i, QLocale::ShortFormat));
    monthNamesShort->setCurrentIndex(mns >= 0 ? mns : 0);
    for (int i = 1; i <= 12; ++i)
        monthNamesLong->addItem(locale.monthName(i, QLocale::LongFormat));
    monthNamesLong->setCurrentIndex(mnl >= 0 ? mnl : 0);

    for (int i = 1; i <= 12; ++i)
        standaloneMonthNamesShort->addItem(locale.standaloneMonthName(i, QLocale::ShortFormat));
    standaloneMonthNamesShort->setCurrentIndex(smns >= 0 ? smns : 0);
    for (int i = 1; i <= 12; ++i)
        standaloneMonthNamesLong->addItem(locale.standaloneMonthName(i, QLocale::LongFormat));
    standaloneMonthNamesLong->setCurrentIndex(smnl >= 0 ? smnl : 0);

    for (int i = 1; i <= 7; ++i)
        dayNamesLong->addItem(locale.dayName(i, QLocale::LongFormat));
    dayNamesLong->setCurrentIndex(dnl >= 0 ? dnl : 0);
    for (int i = 1; i <= 7; ++i)
        dayNamesShort->addItem(locale.dayName(i, QLocale::ShortFormat));
    dayNamesShort->setCurrentIndex(dns >= 0 ? dns : 0);

    for (int i = 1; i <= 7; ++i)
        standaloneDayNamesLong->addItem(locale.standaloneDayName(i, QLocale::LongFormat));
    standaloneDayNamesLong->setCurrentIndex(sdnl >= 0 ? sdnl : 0);
    for (int i = 1; i <= 7; ++i)
        standaloneDayNamesShort->addItem(locale.standaloneDayName(i, QLocale::ShortFormat));
    standaloneDayNamesShort->setCurrentIndex(sdns >= 0 ? sdns : 0);
}
开发者ID:,项目名称:,代码行数:66,代码来源:


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