Exemple #1
0
 void set_query() {
     dbo::Transaction t(tApp->session());
     ULP::Q q;
     if (only_blocked_) {
         q = tApp->session().query<UserPtr>(
                 "select U from thechess_message_filter F "
                 "left join thechess_user U on F.bad_id = U.id");
         q.where("F.good_id = ?").bind(tApp->user());
     } else {
         q = tApp->session().find<User>();
     }
     if (not_removed_) {
         q.where("rights != ?").bind(NONE);
         q.where("vacation_until is null");
         q.where("last_online > ?").bind(now() - 10 * WEEK);
     }
     if (only_online_) {
         q.where("last_online >= ?");
         q.bind(now() - Options::instance()->away_timeout());
     }
     if (!name_like_.empty()) {
         q.where("(username like ? or id = ?)");
         q.bind("%" + name_like_ + "%");
         q.bind(Wt::Wc::str2int(name_like_.toUTF8()));
     }
     q.orderBy("games_stat_elo desc");
     setQuery(q, /* keep_columns */ true);
 }
Exemple #2
0
void FormBaseModel::setValid(Field field, const Wt::WString& message)
{
  setValidation(field,
		WValidator::Result(WValidator::Valid,
				   message.empty() ? 
				   WString::tr("Wt.Auth.valid") : message));
}
void MainWindow::sayHi() {
    Wt::WString name = _nameInput->valueText();
    if (name.empty())
        _nameOutput->setText("");
    else
        _nameOutput->setText("Hi there " + name);
}
Exemple #4
0
void PopupChatWidget::setName(const Wt::WString& name)
{
  if (name.empty())
    return;

  if (online_) {
    int tries = 1;
    Wt::WString n = name;
    while (!server().changeName(name_, n))
      n = name + boost::lexical_cast<std::string>(++tries);

    name_ = n;
  } else
    name_ = name;
}
Exemple #5
0
void PopupChatWidget::goOnline()
{
  if (!online_) {
    online_ = true;

    int tries = 1;
    Wt::WString name = name_;
    if (name.empty())
      name = server().suggestGuest();

    while (!startChat(name)) {
      if (name_.empty())
	name = server().suggestGuest();
      else
	name = name_ + boost::lexical_cast<std::string>(++tries);
    }

    name_ = name;
  }

  missedMessages_ = 0;
  bar_->removeStyleClass("alert");
}
sb2->addItem("Green peppers");
sb2->addItem("Ham");
sb2->addItem("Pepperoni");
sb2->addItem("Red peppers");
sb2->addItem("Turkey");
sb2->setSelectionMode(Wt::ExtendedSelection);
std::set<int> selection;    // By default select the items with index 1 and 4.
selection.insert(1);        // Index 1 corresponds to the 2nd item.
selection.insert(4);        // Index 4 corresponds to the 5th item.
sb2->setSelectedIndexes(selection);
sb2->setMargin(10, Wt::Right);

Wt::WText *out = new Wt::WText(container);

sb2->activated().connect(std::bind([=] () {
      Wt::WString selected;

      std::set<int> selection = sb2->selectedIndexes();
      for (std::set<int>::iterator it = selection.begin();
	   it != selection.end(); ++it) {
	if (!selected.empty())
          selected += ", ";

	selected += sb2->itemText(*it);
      }

      out->setText(Wt::WString::fromUTF8("You choose {1}.").arg(selected));
}));

SAMPLE_END(return container)
Exemple #7
0
Wt::WContainerWidget*
Application::instantiateMainTabs() {
    Wt::WContainerWidget *mainTabContainer = new Wt::WContainerWidget;
    Wt::WVBoxLayout *vbox = new Wt::WVBoxLayout;
    mainTabContainer->setLayout(vbox);

    wMainTabs_ = new Wt::WTabWidget;
    wMainTabs_->currentChanged().connect(boost::bind(&Application::changeTab2, this, _1));
    vbox->addWidget(wMainTabs_, 1 /*stretch*/);

    for (size_t i=0; i<NMainTabs; ++i) {
        Wt::WString tabName;
        Wt::WContainerWidget *tabContent = NULL;
        switch ((MainTab)i) {
        case PartitionerTab: {
            tabName = "Partitioner";
            tabContent = wPartitioner_ = new WPartitioner(ctx_);
            wPartitioner_->specimenParsed().connect(boost::bind(&Application::handleSpecimenParsed, this, _1));
            wPartitioner_->specimenLoaded().connect(boost::bind(&Application::handleSpecimenLoaded, this, _1));
            wPartitioner_->specimenPartitioned().connect(boost::bind(&Application::handleSpecimenPartitioned, this, _1));
            break;
        }
        case MemoryMapTab: {
            tabName = "Memory Map";
            tabContent = wMemoryMap_ = new WMemoryMap;
            wMemoryMap_->mapChanged().connect(boost::bind(&Application::memoryMapChanged, this));
            wMemoryMap_->allowDownloads(ctx_.settings.allowDownloads);
            break;
        }
        case FunctionListTab: {
            tabName = "Functions";
            tabContent = wFunctionList_ = new WFunctionList(ctx_);
            wFunctionList_->functionChanged().connect(boost::bind(&Application::changeFunction, this, _1));
            wFunctionList_->functionRowDoubleClicked()
            .connect(boost::bind(&Application::changeFunctionDoubleClick, this, _1));
            break;
        }
        case FunctionSummaryTab: {
            tabName = "Summary";
            tabContent = wFunctionSummary_ = new WFunctionSummary(ctx_);
            break;
        }
        case FunctionCfgTab: {
            tabName = "CFG";
            tabContent = wFunctionCfg_ = new WFunctionCfg(ctx_);
            wFunctionCfg_->functionChanged().connect(boost::bind(&Application::changeFunction, this, _1));
            wFunctionCfg_->functionClicked().connect(boost::bind(&Application::changeFunction, this, _1));
            wFunctionCfg_->addressClicked().connect(boost::bind(&Application::showHexDumpAtAddress, this, _1));
            wFunctionCfg_->basicBlockClicked().connect(boost::bind(&Application::changeBasicBlock, this, _1));
            break;
        }
        case AssemblyTab: {
            tabName = "Assembly";
            tabContent = wAssembly_ = new WAssemblyListing(ctx_);
            break;
        }
        case HexDumpTab: {
            tabName = "Hexdump";
            tabContent = wHexDump_ = new WHexDump;
            wHexDump_->byteClicked().connect(boost::bind(&Application::updateAddressCrossReferences, this, _1));
            break;
        }
        case MagicTab: {
            tabName = "Magic";
            tabContent = wMagic_ = new WMagic;
            break;
        }
        case StringsTab: {
            tabName = "Strings";
            tabContent = wStrings_ = new WStrings;
            wStrings_->stringClicked().connect(boost::bind(&Application::updateStringCrossReferences, this, _1));
            break;
        }
        case StatusTab: {
            tabName = "Status";
            tabContent = wStatus_ = new WStatus(ctx_);
            break;
        }
        default:
            ASSERT_not_reachable("invalid main tab");
        }
        ASSERT_not_null(tabContent);
        ASSERT_forbid(tabName.empty());
        wMainTabs_->addTab(tabContent, tabName);
    }
    return mainTabContainer;
}
Exemple #8
0
void
WHexValueEdit::setError(const Wt::WString &mesg) {
    wError_->setText(mesg);
    wError_->setHidden(mesg.empty());
    wSave_->setEnabled(mesg.empty());
}