• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ WDate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中WDate的典型用法代码示例。如果您正苦于以下问题:C++ WDate类的具体用法?C++ WDate怎么用?C++ WDate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: InvalidDateException

bool WDate::operator== (const WDate& other) const
{
  if ((!isValid() && !isNull()) || (!other.isValid() && !other.isNull()))
    throw InvalidDateException();

  return (year_ == other.year_ && month_ == other.month_ && day_ == other.day_);
}
开发者ID:bvanhauwaert,项目名称:wt,代码行数:7,代码来源:WDate.C


示例2: validate

WValidator::Result WDateValidator::validate(const WT_USTRING& input) const
{
  if (input.empty())
    return WValidator::validate(input);

  for (unsigned i = 0; i < formats_.size(); ++i) {
    try {
      WDate d = WDate::fromString(input, formats_[i]);

      if (d.isValid()) {
	if (!bottom_.isNull())
	  if (d < bottom_)
	    return Result(Invalid, invalidTooEarlyText());

	if (!top_.isNull())
	  if (d > top_)
	    return Result(Invalid, invalidTooLateText());
    
	return Result(Valid);
      }
    } catch (std::exception& e) {
      LOG_WARN("validate(): " << e.what());
    }
  }

  return Result(Invalid, invalidNotADateText());
}
开发者ID:LifeGo,项目名称:wt,代码行数:27,代码来源:WDateValidator.C


示例3: setDate

void WDateEdit::setDate(const WDate& date)
{
  if (!date.isNull()) {
    setText(date.toString(format()));
    calendar_->select(date);
    calendar_->browseTo(date);
  }
}
开发者ID:NeilNienaber,项目名称:wt,代码行数:8,代码来源:WDateEdit.C


示例4: setFromCalendar

void WDateEdit::setFromCalendar()
{
  if (!calendar_->selection().empty()) {
    WDate calDate = Utils::first(calendar_->selection());
    setText(calDate.toString(format()));
    changed().emit();
  }
}
开发者ID:NeilNienaber,项目名称:wt,代码行数:8,代码来源:WDateEdit.C


示例5: setDate

void WDatePicker::setDate(const WDate& date)
{
  if (!date.isNull()) {
    forEdit_->setText(date.toString(format_));
    calendar_->select(date);
    calendar_->browseTo(date);
  }
}
开发者ID:LifeGo,项目名称:wt,代码行数:8,代码来源:WDatePicker.C


示例6: onSelect

void Calendar::onSelect(std::string date)
{ 
  selection_.clear();

  WDate d = WDate::fromString(date, "dd/MM/yyyy");

  if (d.isValid()) {
    selection_.insert(d);
    selectionChanged_.emit();
    selected_.emit();
  } else
    LOG_ERROR("could not parse date: '" << date << "'");
}
开发者ID:913862627,项目名称:wt,代码行数:13,代码来源:Calendar.C


示例7: clear

void CalendarCell::update(const dbo::ptr<UserAccount>& user, const WDate& date)
{
  date_ = date;
  user_ = user;

  clear();

  dbo::Session& session = PlannerApplication::plannerApplication()->session;
  dbo::Transaction transaction(session);
  
  WString day;
  day += boost::lexical_cast<std::string>(date.day());
  if (date.day() == 1)
    day += " " + WDate::longMonthName(date.month());
  WText* header = new WText(day);
  header->setStyleClass("cell-header");
  addWidget(header);

  typedef dbo::collection< dbo::ptr<Entry> > Entries;
  Entries entries = user->entriesInRange(date, date.addDays(1));

  const unsigned maxEntries = 4;
  unsigned counter = 0;
  for (Entries::const_iterator i = entries.begin();
       i != entries.end(); ++i, ++counter) {
    if (counter == maxEntries) {
      WText* extra = 
	new WText(tr("calendar.cell.extra")
		  .arg((int)(entries.size() - maxEntries)));
      extra->setStyleClass("cell-extra");
      addWidget(extra);

      extra->clicked().preventPropagation();
      extra->clicked().connect(this, &CalendarCell::showAllEntriesDialog);
      
      break;
    }

    WString format = EntryDialog::timeFormat;
    addWidget(new WText((*i)->start.toString(format) +
			"-" + 
			(*i)->stop.toString(format) + 
			": " + (*i)->summary));
  }

  transaction.commit();
}
开发者ID:913862627,项目名称:wt,代码行数:47,代码来源:CalendarCell.C


示例8: select

void Calendar::select(const WDate& date)
{
  selection_.clear();
  selection_.insert(date);

  if (isRendered())
    addUpdateJS(elVar() + ".setValue(Date.parseDate('"
		+ date.toString("dd/MM/yyyy").toUTF8() + "','d/m/Y');");
}
开发者ID:913862627,项目名称:wt,代码行数:9,代码来源:Calendar.C


示例9: setFromLineEdit

void WDatePicker::setFromLineEdit()
{
  WDate d = WDate::fromString(forEdit_->text(), format_);

  if (d.isValid()) {
    if (calendar_->selection().empty()) {
      calendar_->select(d);
      calendar_->selectionChanged().emit();
    } else {
      WDate j = Utils::first(calendar_->selection());
      if (j != d) {
	calendar_->select(d);
	calendar_->selectionChanged().emit();
      }
    }

    calendar_->browseTo(d);
  }
}
开发者ID:LifeGo,项目名称:wt,代码行数:19,代码来源:WDatePicker.C


示例10: browseTo

void WCalendar::browseTo(const WDate& date)
{
  bool rerender = false;

  if (currentYear_ != date.year()) {
    currentYear_ = date.year();
    rerender = true;
  }

  if (currentMonth_ != date.month()) {
    currentMonth_ = date.month();
    rerender = true;
  }

  if (rerender) {
    emitCurrentPageChanged();
    renderMonth();
  }
}
开发者ID:LifeGo,项目名称:wt,代码行数:19,代码来源:WCalendar.C


示例11: daysTo

int WDate::daysTo(const WDate& other) const
{
  if (!isValid() || !other.isValid())
    throw InvalidDateException();

  date dthis(year_, month_, day_);
  date dother(other.year_, other.month_, other.day_);
  date_duration dd = dother - dthis;

  return dd.days();
}
开发者ID:bvanhauwaert,项目名称:wt,代码行数:11,代码来源:WDate.C


示例12: WText

WWidget* WCalendar::renderCell(WWidget* widget, const WDate& date)
{
  WText* t = dynamic_cast<WText*>(widget);

  if (!t) {
    t = new WText();
    t->setInline(false);
    t->setTextFormat(PlainText);
  }

#ifndef WT_TARGET_JAVA
    char buf[30];
#else
    char *buf;
#endif // WT_TARGET_JAVA
  Utils::itoa(date.day(), buf);
  t->setText(WString::fromUTF8(buf));

  std::string styleClass;

  if (isInvalid(date))
    styleClass += " Wt-cal-oor";
  else if (date.month() != currentMonth())
    styleClass += " Wt-cal-oom";

  if (isSelected(date))
    styleClass += " Wt-cal-sel";

  WDate currentDate = WDate::currentDate();
  if (date.day() == currentDate.day() && date.month() == currentDate.month() &&
      date.year() == currentDate.year()) {
    if (!isSelected(date))
      styleClass += " Wt-cal-now";
    t->setToolTip(WString::tr("Wt.WCalendar.today"));
  } else
    t->setToolTip("");

  t->setStyleClass(styleClass.c_str());

  return t;
}
开发者ID:LifeGo,项目名称:wt,代码行数:41,代码来源:WCalendar.C


示例13: selectInCurrentMonth

void WCalendar::selectInCurrentMonth(const WDate& d)
{
  if (d.month() == currentMonth_ && selectionMode_ != NoSelection) {
    if (selectionMode_ == ExtendedSelection) {
      if (isSelected(d))
	selection_.erase(d);
      else
	selection_.insert(d);
    } else {
      selection_.clear();
      selection_.insert(d);
    }

    renderMonth();
    selectionChanged().emit();
  }
}
开发者ID:LifeGo,项目名称:wt,代码行数:17,代码来源:WCalendar.C


示例14: setImplementation

void WCalendar::create()
{
  selectionMode_ = SingleSelection;
  singleClickSelect_ = false;
  horizontalHeaderFormat_ = ShortDayNames;
  firstDayOfWeek_ = 1;
  cellClickMapper_ = 0;
  cellDblClickMapper_ = 0;

  WDate currentDay = WDate::currentDate();

  currentYear_ = currentDay.year();
  currentMonth_ = currentDay.month();

  WStringStream text;

  text <<
    "<table class=\"days ${table-class}\" cellspacing=\"0\" cellpadding=\"0\">"
    """<tr>"
    ""  "<th class=\"caption\">${nav-prev}</th>"
    ""  "<th class=\"caption\"colspan=\"5\">${month} ${year}</th>"
    ""  "<th class=\"caption\">${nav-next}</th>"
    """</tr>"
    """<tr>";

  for (int j = 0; j < 7; ++j)
    text <<
      "<th title=\"${t" << j << "}\" scope=\"col\">${d" << j << "}</th>";

  text << "</tr>";

  for (int i = 0; i < 6; ++i) {
    text << "<tr>";
    for (int j = 0; j < 7; ++j)
      text << "<td>${c" << (i * 7 + j) << "}</td>";
    text << "</tr>";
  }

  text << "</table>";

  setImplementation(impl_ = new WTemplate());
  impl_->setTemplateText(WString::fromUTF8(text.str()), XHTMLUnsafeText);
  impl_->setStyleClass("Wt-cal");

  setSelectable(false);

  WText *prevMonth = new WText(tr("Wt.WCalendar.PrevMonth"));
  prevMonth->setStyleClass("Wt-cal-navbutton");
  prevMonth->clicked().connect(this, &WCalendar::browseToPreviousMonth);

  WText *nextMonth = new WText(tr("Wt.WCalendar.NextMonth"));
  nextMonth->setStyleClass("Wt-cal-navbutton");
  nextMonth->clicked().connect(this, &WCalendar::browseToNextMonth);

  monthEdit_ = new WComboBox();
  monthEdit_->setInline(true);
  for (unsigned i = 0; i < 12; ++i)
    monthEdit_->addItem(WDate::longMonthName(i+1));
  monthEdit_->activated().connect(this, &WCalendar::monthChanged);
  monthEdit_->setDisabled(!WApplication::instance()->environment().ajax());

  yearEdit_ = new WInPlaceEdit("");
  yearEdit_->setButtonsEnabled(false);
  yearEdit_->lineEdit()->setTextSize(4);
  yearEdit_->setStyleClass("Wt-cal-year");
  yearEdit_->valueChanged().connect(this, &WCalendar::yearChanged);

  impl_->bindWidget("nav-prev", prevMonth);
  impl_->bindWidget("nav-next", nextMonth);
  impl_->bindWidget("month", monthEdit_);
  impl_->bindWidget("year", yearEdit_);

  setHorizontalHeaderFormat(horizontalHeaderFormat_);
  setFirstDayOfWeek(firstDayOfWeek_);
}
开发者ID:LifeGo,项目名称:wt,代码行数:75,代码来源:WCalendar.C


示例15: today

void WCalendar::render(WFlags<RenderFlag> flags)
{
  if (needRenderMonth_) {
    bool create = cellClickMapper_ == 0;
#ifndef WT_TARGET_JAVA
    char buf[30];
#else
    char *buf;
#endif // WT_TARGET_JAVA

    if (create) {
      // FIXME catch events only on container, and use 'tid' to identify
      // the cell -- in Ajax mode
      cellClickMapper_ = new WSignalMapper<Coordinate>(this);
      cellClickMapper_->mapped().connect(this, &WCalendar::cellClicked);
      cellDblClickMapper_ = new WSignalMapper<Coordinate>(this);
      cellDblClickMapper_->mapped().connect(this, &WCalendar::cellDblClicked);
    }

    int m = currentMonth_ - 1;
    if (monthEdit_->currentIndex() != m)
      monthEdit_->setCurrentIndex(m);

    int y = currentYear_;
    Utils::itoa(y, buf);
    if (yearEdit_->text().toUTF8() != buf)
      yearEdit_->setText(WString::fromUTF8(buf));

    WDate todayd = WDate::currentDate();
    date today(todayd.year(), todayd.month(), todayd.day());

    // The first line contains the last day of the previous month.
    date d(currentYear_, currentMonth_, 1);
    d -= date_duration(1);
 
    greg_weekday gw = firstDayOfWeek_ % 7;
    d = previous_weekday(d, gw);

    for (unsigned i = 0; i < 6; ++i) {
      for (unsigned j = 0; j < 7; ++j) {
	Utils::itoa(i * 7 + j, buf);
	std::string cell = std::string("c") + buf;
	
	WDate date(d.year(), d.month(), d.day());

	WWidget *w = impl_->resolveWidget(cell);
	WWidget *rw = renderCell(w, date);
	impl_->bindWidget(cell, rw);

	WInteractWidget* iw = dynamic_cast<WInteractWidget*>(rw->webWidget());

	if (iw && iw != w) {
	  if (clicked().isConnected()
	      || (selectionMode_ == ExtendedSelection)
	      || (selectionMode_ != ExtendedSelection && singleClickSelect_
		  && activated().isConnected()))
	    cellClickMapper_
	      ->mapConnect(iw->clicked(), Coordinate(i, j));

	  if ((selectionMode_ != ExtendedSelection && !singleClickSelect_
	       && (activated().isConnected() ||
		   selectionChanged().isConnected())))
	    cellDblClickMapper_
	      ->mapConnect(iw->doubleClicked(), Coordinate(i, j));
	}

	d += date_duration(1);
      }
    }

    needRenderMonth_ = false;
  }

  WCompositeWidget::render(flags);
}
开发者ID:LifeGo,项目名称:wt,代码行数:75,代码来源:WCalendar.C


示例16: WString

void PriceEditDialog::handleFinish(DialogCode result)
{
    if (result == WDialog::Accepted)
    {
        /*
         * Update the model with data from the edit widgets.
         *
         * You will want to do some validation here...
         *
         * Note that we directly update the source model to avoid
         * problems caused by the dynamic sorting of the proxy model,
         * which reorders row numbers, and would cause us to switch to editing
         * the wrong data.
         */

        if(m_chbCostEnabled->isChecked() && m_chbPercentEnabled->isChecked())
        {
            WMessageBox::show("Error", WString(tr("msg.ambiguous.select")), Ok);
            return;
        }


        /*! При выставленном варианте расчета статический Поле цена не доступна
            1) Вариант расчета 0 Динамический  1 Статический
            2) Устанавливается Цена или процент
            3) Процента или Цена

        */
        WAbstractItemModel *m = m_model;
        //int id =
        int modelRow = m_item.row();
        int valueType = 0;
        int modifyStatic = 0;
        //int staticValue = 0;
        double value = 0.00;
        //char number[50];

        WAbstractProxyModel *proxyModel = dynamic_cast<WAbstractProxyModel *>(m);
        if (proxyModel)
        {
            m = proxyModel->sourceModel();
            modelRow = proxyModel->mapToSource(m_item).row();
        }
            //modelRow++;



        if(m_chbPercentEnabled->isChecked())
        {
            valueType = 2;
            //sprintf(number,"%.2f%%",boost::lexical_cast<double>(m_lePercent->text().toUTF8()));
            //m->setData(modelRow, 3, boost::any(std::string("0.00")));
            m->setData(modelRow, 5, boost::any(m_lePercent->text().toUTF8()+"%"));/// Процент
            m->setData(modelRow, 2, boost::any(value = boost::lexical_cast<double>(m_lePercent->text().toUTF8())),UserRole);/// Процент

        }else if(m_chbCostEnabled->isChecked())
        {
            valueType = 1;
            //m->setData(modelRow, 3, boost::any(boost::lexical_cast<double>(m_leCost->text().toUTF8())));/// Цена
            //sprintf(number,"%.2f%%",boost::lexical_cast<double>(m_leCost->text().toUTF8()));
            //m->setData(modelRow, 2, boost::any(std::string("0.00%")));
            m->setData(modelRow, 6, boost::any(m_leCost->text().toUTF8()));/// Цена
            m->setData(modelRow, 2, boost::any(value = boost::lexical_cast<double>(m_leCost->text().toUTF8())),UserRole);/// Цена
        }else{
            if(atof(m_leCost->text().toUTF8().c_str()) || atof(m_lePercent->text().toUTF8().c_str()))
                WMessageBox::show("Error", WString(tr("msg.notselected.valuetype")), Ok);

        }

        if(m_chbModifyStatic->isChecked())
            modifyStatic = 1;
        //log("info")<<" Percetn "<<valueType<<" Dinamic "<<m_rbGroup->checkedId();
        m->setData(modelRow, 3, boost::any(valueType),UserRole); /// Value type Процент / Цена
        m->setData(modelRow, 4, boost::any(m_rbGroup->checkedId()),UserRole); /// PriceType Динамический статический
        m->setData(modelRow, 5, boost::any(modifyStatic),UserRole); /// Изменять фиксированные цены
        m->setData(modelRow, 6, boost::any(m_dpModified->date()),UserRole);
        m->setData(modelRow, 7, boost::any(m_roundingMethod->currentIndex()+1),UserRole);

        int priceType = ((m_rbGroup->checkedId()-1)<<1) | (valueType-1);
        bool changeFixed = false;
        WDate modifiDate = WDate::currentDate();

#ifdef DEBUG
        log("info")<<"updateUserPrice(m_id "<<m_id<<",valueType "<<valueType<<",value "<<value<<",priceType "<<priceType<<",changeFixed "<<changeFixed<<",modifiDate "<<modifiDate.toString()<<" rounding "<<m_roundingMethod->currentIndex()+1<<" ) "<<__LINE__;
#endif

        ((Portal *)WApplication::instance())->getSession()->updateUserPrice(m_id,valueType,value,priceType,changeFixed,modifiDate,m_roundingMethod->currentIndex()+1);
    }

    delete this;
}
开发者ID:ineron,项目名称:fit-zakaz-portal,代码行数:91,代码来源:PriceEditDialog.cpp


示例17: setDate

void DateField::setDate(const WDate& date)
{
  lineEdit()->setText(date.toString(format_));
}
开发者ID:913862627,项目名称:wt,代码行数:4,代码来源:DateField.C



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WERD类代码示例发布时间:2022-05-31
下一篇:
C++ WDT_file类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap