Esempio n. 1
0
///
//  Constructor
//
ResultsPage::ResultsPage(const MRIBrowser *mriBrowser, WContainerWidget *parent) :
    mMRIBrowser(mriBrowser),
    WContainerWidget(parent)
{
    setStyleClass("tabdiv");

    mResultsTable = new ResultsTable();

    WContainerWidget *browserContainer = new WContainerWidget();
    WContainerWidget *resultsContainer = new WContainerWidget;

    WText *showText = new WText("Show Results by User:"******"<user>");
    mUserComboBox->addItem("All");

    mSearchLineEdit = new WLineEdit("");
    mSearchLineEdit->setMinimumSize(150, WLength::Auto);
    mSearchLineEdit->resize(150, WLength::Auto);

    mSearchPushButton = new WPushButton("GO");
    WPushButton *clearButton = new WPushButton("Clear");
    WPushButton *refreshButton = new WPushButton("Refresh");

    userBox->addWidget(new WText("Search:"), 0, 2, AlignRight | AlignMiddle);
    userBox->addWidget(mSearchLineEdit, 0, 3, AlignLeft| AlignMiddle);
    userBox->addWidget(mSearchPushButton, 0, 4, AlignLeft | AlignMiddle);
    userBox->addWidget(clearButton, 0, 5, AlignLeft | AlignMiddle);
    userBox->addWidget(refreshButton, 0, 6, AlignRight | AlignMiddle);
    userBox->setColumnStretch(2, 1);
    userBox->setColumnStretch(6, 1);
    userBox->setColumnStretch(7, 3);

    mPipelineArgTable = new PipelineArgTable();
    mPipelineArgTable->resize(WLength::Auto, 150);
    mPipelineArgTable->setMinimumSize(WLength::Auto,
                                      WLength(150, WLength::Pixel));
    mPipelineArgTable->setMaximumSize(WLength::Auto,
                                      WLength(150, WLength::Pixel));

    mJobStatus = new JobStatus();
    WHBoxLayout *bottomLayout = new WHBoxLayout();
    bottomLayout->addWidget(mPipelineArgTable);
    bottomLayout->addWidget(mJobStatus);



    WGridLayout *browserLayout = new WGridLayout();
    browserLayout->addLayout(userBox, 0, 0);
    browserLayout->addWidget(mResultsTable, 1, 0);
    browserLayout->addLayout(bottomLayout, 2, 0);
    browserLayout->setRowStretch(0, -1);
    browserLayout->setRowStretch(1, 1);
    browserLayout->setRowStretch(2, -1);
    browserContainer->setLayout(browserLayout);


    mBackButton = new WPushButton("<- Back");

    WTabWidget *tabWidget = new WTabWidget();
    tabWidget->setStyleClass("toptabdiv");
    mMonitorLogTab = new MonitorLogTab(mriBrowser);
    mMonitorResultsTab = new MonitorResultsTab(mriBrowser);
    tabWidget->addTab(mMonitorResultsTab, "Results");
    tabWidget->addTab(mMonitorLogTab, "Logs");

    WGridLayout *resultsLayout = new WGridLayout();
    resultsLayout->addWidget(mBackButton, 0, 0, AlignLeft | AlignMiddle);
    resultsLayout->addWidget(tabWidget, 1, 0);
    resultsLayout->setRowStretch(0, -1);
    resultsLayout->setRowStretch(1, 1);
    resultsContainer->setLayout(resultsLayout);

    mStackedWidget = new WStackedWidget();
    mStackedWidget->addWidget(browserContainer);
    mStackedWidget->addWidget(resultsContainer);

    WGridLayout *layout = new WGridLayout();
    layout->addWidget(mStackedWidget, 0, 0);
    layout->setRowStretch(0, -1);
    setLayout(layout);

    mUserComboBox->activated().connect(SLOT(this, ResultsPage::userChanged));
    mSearchPushButton->clicked().connect(SLOT(this, ResultsPage::searchPushed));
    clearButton->clicked().connect(SLOT(this, ResultsPage::clearPushed));
    mResultsTable->resultSelected().connect(SLOT(this, ResultsPage::resultSelected));
    mResultsTable->resultClicked().connect(SLOT(this, ResultsPage::resultClicked));
    mBackButton->clicked().connect(SLOT(this, ResultsPage::backPushed));
    refreshButton->clicked().connect(SLOT(this, ResultsPage::refreshClicked));

    // All items in the tabbed widget need to be resized to 100% to
    // fill the contents.  This trick came from the Wt WTabWidget
    // documentation and took me a good half a day to figure out.
    mMonitorLogTab->resize(WLength(100, WLength::Percentage),
                           WLength(100, WLength::Percentage));
    mMonitorResultsTab->resize(WLength(100, WLength::Percentage),
                               WLength(100, WLength::Percentage));
}
Esempio n. 2
0
WWidget *WItemDelegate::update(WWidget *widget, const WModelIndex& index,
			       WFlags<ViewItemRenderFlag> flags)
{
  bool editing = widget && widget->find("t") == 0;

  if (flags & RenderEditing) {
    if (!editing) {
      widget = createEditor(index, flags);
      WInteractWidget *iw = dynamic_cast<WInteractWidget *>(widget);
      if (iw) {
	// Disable drag & drop and selection behaviour
	iw->mouseWentDown().preventPropagation();
	iw->clicked().preventPropagation();
      }
    }
  } else {
    if (editing)
      widget = 0;
  }

  WidgetRef widgetRef(widget);

  bool isNew = false;

  if (!(flags & RenderEditing)) {
    if (!widgetRef.w) {
      isNew = true;
      WText *t = new WText();
      t->setObjectName("t");
      if (index.isValid() && !(index.flags() & ItemIsXHTMLText))
	t->setTextFormat(PlainText);
      t->setWordWrap(true);
      widgetRef.w = t;
    }

    if (!index.isValid())
      return widgetRef.w;

    bool haveCheckBox = false;

    if (index.flags() & ItemIsUserCheckable) {
      boost::any checkedData = index.data(CheckStateRole);
      CheckState state = checkedData.empty() ? Unchecked
	: (checkedData.type() == typeid(bool) ?
	   (boost::any_cast<bool>(checkedData) ? Checked : Unchecked)
	   : (checkedData.type() == typeid(CheckState) ?
	      boost::any_cast<CheckState>(checkedData) : Unchecked));
      checkBox(widgetRef, index, true, index.flags() & ItemIsTristate)
	->setCheckState(state);
      haveCheckBox = true;
    } else if (!isNew)
      delete checkBox(widgetRef, index, false);

    boost::any linkData = index.data(LinkRole);
    if (!linkData.empty()) {
      WLink link = boost::any_cast<WLink>(linkData);
      WAnchor *a = anchorWidget(widgetRef);
      a->setLink(link);
      if (link.type() == WLink::Resource)
	a->setTarget(TargetNewWindow);
    }

    WText *t = textWidget(widgetRef);

    WString label = asString(index.data(), textFormat_);
    if (label.empty() && haveCheckBox)
      label = WString::fromUTF8(" ");
    t->setText(label);

    std::string iconUrl = asString(index.data(DecorationRole)).toUTF8();
    if (!iconUrl.empty()) {
      iconWidget(widgetRef, true)->setImageLink(WLink(iconUrl));
    } else if (!isNew)
      delete iconWidget(widgetRef, false);
  }

  WString tooltip = asString(index.data(ToolTipRole));
  if (!tooltip.empty() || !isNew)
    widgetRef.w->setToolTip(tooltip);

  WT_USTRING sc = asString(index.data(StyleClassRole));

  if (flags & RenderSelected)
    sc += WT_USTRING::fromUTF8
      (" " + WApplication::instance()->theme()->activeClass());

  if (flags & RenderEditing)
    sc += WT_USTRING::fromUTF8(" Wt-delegate-edit");

  widgetRef.w->setStyleClass(sc);

  if (index.flags() & ItemIsDropEnabled)
    widgetRef.w->setAttributeValue("drop", WString::fromUTF8("true"));
  else
    if (!widgetRef.w->attributeValue("drop").empty())
      widgetRef.w->setAttributeValue("drop", WString::fromUTF8("f"));

  return widgetRef.w;
}