Exemplo n.º 1
0
int reversibly_expand_q_and_rho_to_given_P(np_t np, gl_t *gl, double Pstarc, double *qc, double *rhoc,
           long numsteps, double q_min){
  argfpot_t arg;
  double Tc;
  long error;
  int retval;

  find_w(np,arg.w1);
  arg.R=_R(arg.w1);
  arg.q1=_q(np);
  arg.k1=_k(np);
  arg.h1=_h_from_w_T(arg.w1,_T(np,gl));
  /* if the desired back pressure is more than the flow stagnation pressure,
     it is not possible to integrate; for robustness, first check
     if the stagnation pressure of the flow is greater than the back
     pressure. If not, then neglect this streamline. */
  if (_Pstag(np,gl,numsteps)>Pstarc) {
    *qc=EXM_numerical_differentiation(&_qcnew_funct, &arg, EXM_NUMDIFF_MODIFIEDEULER,
                  numsteps, max(q_min,_q(np)), _Pstar(np,gl), Pstarc, &error);
    Tc=_T_from_w_h(arg.w1, -sqr(*qc)/2.0+arg.h1+sqr(arg.q1)/2.0);
    if (Tc<1.0 || Tc>60000.0) wfprintf(stderr,"big problem here..Tc=%E\n",Tc);
    *rhoc=Pstarc/(arg.R*Tc+2.0/3.0*arg.k1);
    retval=0;
  } else {
    retval=1;
  }
  return(retval);
}
void ShareBrowserSearch::findMatches(FileBrowserItem *item){
    if (!item)
        return;
    
    QModelIndex index = model->createIndexForItem(item);
    
    if (model->canFetchMore(index))  
        model->fetchMore(index);
    
    QString fname = "";

    for (const auto &i : item->childItems){
        if (i->dir){
            findMatches(i);

            DirectoryListing::File::List *files = &i->dir->files;
            DirectoryListing::File::Iter it_file;

            for (it_file = files->begin(); it_file != files->end(); ++it_file){
                fname = _q((*it_file)->getName());
                
                if (fname.indexOf(lineEdit_SEARCHSTR->text(), 0, Qt::CaseInsensitive) >= 0 || fname.indexOf(regexp) >= 0 || regexp.exactMatch(fname))
                    emit gotItem(_q((*it_file)->getName()), i);
            }
        }
    }
}
Exemplo n.º 3
0
void QueuedUsers::on(WaitingRemoveUser, const dcpp::HintedUser &user) noexcept {
    VarMap map;
    map["CID"]  = _q(user.user->getCID().toBase32());
    map["FILE"] = "";
    map["HUB"]  = _q(user.hint);

    emit coreWaitingRemoved(map);
}
Exemplo n.º 4
0
void QueuedUsers::on(WaitingAddFile, const dcpp::HintedUser &user, const std::string &file) noexcept {
    VarMap map;
    map["CID"]  = _q(user.user->getCID().toBase32());
    map["FILE"] = _q(file);
    map["HUB"]  = _q(user.hint);

    emit coreWaitingAddFile(map);
}
Exemplo n.º 5
0
/**
 * Molar weighted segment for the ith molecule in the solution.
 * \f[
 * \theta_i = \frac{x_i q_i}{\sum_{j=1}^n x_j q_j}
 * \f]
 * @param i Molecule ID in the solution.
 * @param s Solution
 * @returns theta_i
 */
double _theta(int i, unifac_solution *s)
{
    int j;
    double numer, denom = 0;
    numer = s->xi[i] * _q(s->m[i]);
    for(j=0; j<s->nsolutes; j++)
        denom += s->xi[j] * _q(s->m[j]);
    return numer/denom;
}
Exemplo n.º 6
0
QAction * CustomPopup::getShowDefinitionEntry(QString iWord)
{
    m_word = iWord;

    QAction *definitionAction = new QAction(_q("Show definition"), m_widget);
    definitionAction->setStatusTip(_q("Show definition of '%1' in an external browser").arg(m_word));
    QObject::connect(definitionAction, SIGNAL(triggered()),
                     this, SLOT(definitionRequested()));

    return definitionAction;
}
Exemplo n.º 7
0
/* the thermally perfect, but calorically imperfect stagnation pressure,
   the way it should be calculated. Note that this becomes the well known
   ideal gas isentropic formula in the case of a calorically
   perfect gas; numsteps is the number of numerical integration intervals taken*/
double _Pstag(np_t np, gl_t *gl, long numsteps){
  argpstag_t arg;
  long error;
  double Pstag;

  find_w(np,arg.w1);
  arg.R=_R(arg.w1);
  arg.q1=_q(np);
  arg.k1=_k(np);
  arg.h1=_h_from_w_T(arg.w1,_T(np,gl));
  Pstag=_Pstar(np,gl)*exp(EXM_numerical_integration(&_Pstag_funct, &arg, EXM_NUMINTEG_POLY2,
                       numsteps, 0.0e0, _q(np), &error));
  return(Pstag);
}
Exemplo n.º 8
0
/**
 * The L_i value is calculated from q, r, and z, where q and r are defined
 * above and z is the coordination number. Here, z is assumed to be equal to
 * ten.
 * \f[
 * L_i = \frac{z}{2}(r_i - q_i) - (r_i -1)
 * \f]
 * @param molec Molecule to calculate the value for
 * @returns L_i
 */
double _L(unifac_molec molec)
{
    double ri, qi;
    ri = _r(molec);
    qi = _q(molec);
    return Z/2*(ri - qi) - (ri - 1);
}
Exemplo n.º 9
0
void TablesDialog::accept()
{
    // Check table numbers uniqueness
    QSet<unsigned> tableNbSet;
    for (int i = 0; i < tablePlayers->rowCount(); ++i)
    {
        unsigned tableNb = tablePlayers->item(i, 1)->data(Qt::DisplayRole).toUInt();
        if (tableNbSet.contains(tableNb))
        {
            emit notifyProblem(_q("The table numbers must be unique, but "
                                  "\"%1\" appears several times.").arg(tableNb));
            return;
        }
        tableNbSet.insert(tableNb);
    }

    // Save data
    for (int i = 0; i < tablePlayers->rowCount(); ++i)
    {
        // Retrieve the player id
        unsigned id = tablePlayers->item(i, 1)->data(Qt::UserRole).toUInt();

        // Update the player name
        QString name = tablePlayers->item(i, 0)->data(Qt::DisplayRole).toString();
        m_game->setPlayerName(id, wfq(name));
        // Update the table number
        unsigned tableNb = tablePlayers->item(i, 1)->data(Qt::DisplayRole).toUInt();
        m_game->setPlayerTableNb(id, tableNb);
    }

    QDialog::accept();
}
Exemplo n.º 10
0
void SearchBlacklist::loadLists() {
    const QString &config = _q(Util::getPath(Util::PATH_USER_CONFIG)) + "searchblacklist";
    QFile f(config);

    if (!(f.exists() && f.open(QIODevice::ReadOnly)))
        return;

    QTextStream stream(&f);
    QString in = "";
    SearchBlacklist::Argument arg = SearchBlacklist::TTH;

    while (!stream.atEnd()) {
        in = stream.readLine();

        in.replace("\n", "");

        if (in.startsWith("TTH:") && in.length() > 4) {
            in.remove(0, 4);

            arg = SearchBlacklist::TTH;
        }
        else if (in.startsWith("NAME:") && in.length() > 5) {
            in.remove(0, 5);

            arg = SearchBlacklist::NAME;
        }
        else
            continue;

        list[arg].push_back(in);
    }

    f.close();
}
Exemplo n.º 11
0
QString HashManagerScript::getTTH(const QString &aFileName) const{
    const dcpp::TTHValue *v = HM->getFileTTHif(_tq(aFileName));

    if (v)
        return _q(v->toBase32());
    else
        return "";
}
Exemplo n.º 12
0
double _ln_gammacElec(int i, unifac_solution *s)
{
    double result;

    result = log(_phiElec(i, s)/s->xi[i]) + 1 - _phiElec(i, s)/s->xi[i]
             + Z/2*_q(s->m[i]) * (1 - _phi(i, s)/_theta(i, s)
                                  + log(_phi(i, s)/_theta(i, s)));

    return result;
}
Exemplo n.º 13
0
	int _q(int t, int l, int r, int ll, int rr) {
		if (ll > rr) return 0;
		if (ll == rr) {
			return sum[t];
		}
		if (sum[t] == 0) return 0;
		
		if (l == ll && r == rr) {
			return sum[t];
		}
		
		push_down(t);
		
		int mi = (ll+rr) / 2;
		if (r <= mi) {
			return _q(lc(t), l, r, ll, mi);
		} else if (l > mi) {
			return _q(rc(t), l, r, mi+1, rr);
		} else {
			return _q(lc(t), l, mi, ll, mi) + _q(rc(t), mi+1, r, mi+1, rr);
		}
	}
Exemplo n.º 14
0
int _read_rc( int val )
{
  ParseUnion _q;
  ParseUnion *q;
  _q.add_value[0][0].next[0] = _f;
  q->add_value[0] = &_f;
  if ( val )
    _q( 0 );
  if ( val )
  {
    ;
  }
  return val;
}
void
SymmAnisotropicElasticityTensor::form_rotational_q_matrix()
{

  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      for (int k = 0; k < 3; ++k)
        for (int l = 0; l < 3; ++l)
          _q(((i * 3) + k), ((j * 3) + l)) = _r(i, j) * _r(k, l);

  /*for (int p = 0; p < 9; ++p)
    for (int q = 0; q < 9; ++q)
    _qt(q,p) = _q(p,q);*/
}
Exemplo n.º 16
0
/**
 * Calculate that natural log of the combinatorial component of the activity coefficient for the ith molecule in the solution.
 * \f[
 * \ln\gamma_i^c = \ln\frac{\phi_i}{x_i}
 *      + \frac{z}{2}q_i\ln\frac{\theta_i}{\phi_i} + L_i
 *      - \frac{\phi_i}{x_i}\sum_{j=1}^n x_j L_j
 * \f]
 * @param i Molecule ID in the solution.
 * @param s Solution
 * @returns ln(gamma_i^c)
 */
double _ln_gammac(int i, unifac_solution *s)
{
    int j;
    double result, sum = 0;

    for(j=0; j<s->nsolutes; j++)
        sum += s->xi[i] * _L(s->m[i]);

    result = log(_phi(i, s)/s->xi[i])
             + Z/2*_q(s->m[i])*log(_theta(i, s)/_phi(i, s))
             + _L(s->m[i])
             - _phi(i, s)/s->xi[i] * sum;

    return result;
}
bool PoseLocalParameterization::Plus(const double *x, const double *delta, double *x_plus_delta) const
{
    Eigen::Map<const Eigen::Vector3d> _p(x);
    Eigen::Map<const Eigen::Quaterniond> _q(x + 3);

    Eigen::Map<const Eigen::Vector3d> dp(delta);

    Eigen::Quaterniond dq = Utility::deltaQ(Eigen::Map<const Eigen::Vector3d>(delta + 3));

    Eigen::Map<Eigen::Vector3d> p(x_plus_delta);
    Eigen::Map<Eigen::Quaterniond> q(x_plus_delta + 3);

    p = _p + dp;
    q = (_q * dq).normalized();

    return true;
}
Exemplo n.º 18
0
void SearchBlacklist::saveLists() {
    const QString &config = _q(Util::getPath(Util::PATH_USER_CONFIG)) + "searchblacklist";
    QFile f(config);

    if (!f.open(QIODevice::WriteOnly))
        return;

    QTextStream stream(&f);

    foreach(const QString &line, list[NAME])
        stream << "NAME:" << line << "\n";

    foreach(const QString &line, list[TTH])
        stream << "TTH:" << line << "\n";

    f.close();
}
Exemplo n.º 19
0
void QuickConnect::slotAccept() {
    QString hub = comboBox_HUB->currentText();
    QString encoding = "";

    hub.replace(" ", "");

    if (hub.isEmpty()){
        accept();

        return;
    }

    if (hub.startsWith("adc://") || hub.startsWith("adcs://"))
        encoding = "UTF-8";
    if (!hub.isEmpty()) {
        if (encoding.isEmpty()){//Has favorite entry for hub?
            FavoriteHubEntry* entry = FavoriteManager::getInstance()->getFavoriteHubEntry(_tq(hub));

            if (entry)
                encoding = WulforUtil::getInstance()->dcEnc2QtEnc(_q(entry->getEncoding()));
        }

        MainWindow::getInstance()->newHubFrame(hub, (encoding.isEmpty())? (WSGET(WS_DEFAULT_LOCALE)) : (encoding));

        QStringList list = WulforSettings::getInstance()->getStr(WS_QCONNECT_HISTORY).split(" ", QString::SkipEmptyParts);

        if (!list.contains(hub))
            list.push_back(hub);
        else{
            accept();

            return;
        }
        QString hist = "";

        foreach (const QString &i, list)
            hist += (i + " ");

        WulforSettings::getInstance()->setStr(WS_QCONNECT_HISTORY, hist);
    }

    accept();
}
QVariant FavoriteUsersModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid())
        return QVariant();

    if (index.column() > columnCount(QModelIndex()))
        return QVariant();

    FavoriteUserItem *item = static_cast<FavoriteUserItem*>(index.internalPointer());

    switch(role) {
        case Qt::DecorationRole: // icon
        {
            if (index.column() == 0){
                FavoriteManager::FavoriteMap ul = FavoriteManager::getInstance()->getFavoriteUsers();

                for(FavoriteManager::FavoriteMap::iterator i = ul.begin(); i != ul.end(); ++i) {
                    const dcpp::FavoriteUser &u = i->second;

                    if (_q(u.getUser()->getCID().toBase32()) == item->cid){
                        if (u.isSet(FavoriteUser::FLAG_GRANTSLOT))
                            return WICON(WulforUtil::eiBALL_GREEN).scaled(16, 16);
                    }
                }
            }

            break;
        }
        case Qt::DisplayRole:
            return item->data(index.column());
        case Qt::TextAlignmentRole:
            break;
        case Qt::ForegroundRole:
            break;
        case Qt::ToolTipRole:
            break;
        case Qt::CheckStateRole:
            break;
    }

    return QVariant();
}
Exemplo n.º 21
0
 Z3_ast_vector Z3_API Z3_polynomial_subresultants(Z3_context c, Z3_ast p, Z3_ast q, Z3_ast x) {
     Z3_TRY;
     LOG_Z3_polynomial_subresultants(c, p, q, x);
     RESET_ERROR_CODE();
     polynomial::manager & pm = mk_c(c)->pm();
     polynomial_ref _p(pm), _q(pm);
     polynomial::scoped_numeral d(pm.m());
     default_expr2polynomial converter(mk_c(c)->m(), pm);
     if (!converter.to_polynomial(to_expr(p), _p, d) ||
         !converter.to_polynomial(to_expr(q), _q, d)) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         return 0;
     }
     Z3_ast_vector_ref* result = alloc(Z3_ast_vector_ref, mk_c(c)->m());
     mk_c(c)->save_object(result);
     if (converter.is_var(to_expr(x))) {
         expr2var const & mapping = converter.get_mapping();
         unsigned v_x = mapping.to_var(to_expr(x));
         polynomial_ref_vector rs(pm);
         polynomial_ref r(pm);
         expr_ref _r(mk_c(c)->m());
         {
             cancel_eh<polynomial::manager> eh(pm);
             api::context::set_interruptable si(*(mk_c(c)), eh);
             scoped_timer timer(mk_c(c)->params().m_timeout, &eh);
             pm.psc_chain(_p, _q, v_x, rs);
         }
         for (unsigned i = 0; i < rs.size(); i++) {
             r = rs.get(i);
             converter.to_expr(r, true, _r);
             result->m_ast_vector.push_back(_r);
         }
     }
     RETURN_Z3(of_ast_vector(result));
     Z3_CATCH_RETURN(0);
 }
Exemplo n.º 22
0
void ChatEdit::dropEvent(QDropEvent *e)
{
    if (e->mimeData()->hasUrls()) {

        e->setDropAction(Qt::IgnoreAction);

        QStringList fileNames;
        for (const auto url : e->mimeData()->urls()) {
            QString urlStr = url.toString();
            if (url.scheme().toLower() == "file") {
                QFileInfo fi( url.toLocalFile() );
                QString str = QDir::toNativeSeparators( fi.absoluteFilePath() );

                if ( fi.exists() && fi.isFile() && !str.isEmpty() ) {
                    const TTHValue *tth = HashManager::getInstance()->getFileTTHif(str.toStdString());
                    if ( !tth ) {
                        str = QDir::toNativeSeparators( fi.canonicalFilePath() ); // try to follow symlinks
                        tth = HashManager::getInstance()->getFileTTHif(str.toStdString());
                    }
                    if (tth)
                        urlStr = WulforUtil::getInstance()->makeMagnet(fi.fileName(), fi.size(), _q(tth->toBase32()));
                }
            };

            if (!urlStr.isEmpty())
                fileNames << urlStr;
        }

        if (!fileNames.isEmpty()) {

            QString dropText = (fileNames.count() == 1) ? fileNames.last() : "\n" + fileNames.join("\n");

            QMimeData mime;
            mime.setText(dropText);
            QDropEvent drop(e->pos(), Qt::CopyAction, &mime, e->mouseButtons(),
                            e->keyboardModifiers(), e->type());

            QTextEdit::dropEvent(&drop);
            return;
        }
    }
    QTextEdit::dropEvent(e);
}
Exemplo n.º 23
0
void LogManagerScript::on(Message, time_t t, const dcpp::string &msg) throw(){
    Q_UNUSED(t);

    emit message(QDateTime::currentDateTime().toString("hh:mm:ss"), _q(msg));
}
Exemplo n.º 24
0
	int query(int t, int l, int r) {
		return _q(t, l, r, 1, n);
	}
Exemplo n.º 25
0
PublicGame * NewGame::createGame() const
{
    // Game parameters
    GameParams params(m_dic);
    if (radioButtonTraining->isChecked())
        params.setMode(GameParams::kTRAINING);
    else if (radioButtonFreeGame->isChecked())
        params.setMode(GameParams::kFREEGAME);
    else if (radioButtonDuplicate->isChecked())
        params.setMode(GameParams::kDUPLICATE);
    else if (radioButtonArbitration->isChecked())
        params.setMode(GameParams::kARBITRATION);
    else
        params.setMode(GameParams::kTOPPING);

    if (checkBoxJoker->isChecked())
        params.addVariant(GameParams::kJOKER);
    if (checkBoxExplosive->isChecked())
        params.addVariant(GameParams::kEXPLOSIVE);
    if (checkBox7Among8->isChecked())
        params.addVariant(GameParams::k7AMONG8);

    // Load the master game if needed
    Game *masterGame = NULL;
    if (checkBoxUseMaster->isChecked())
    {
        const QString &path = lineEditMaster->text();
        try
        {
            masterGame = GameFactory::Instance()->load(lfq(path), m_dic);
        }
        catch (const GameException &e)
        {
            // Should not happen, since we have already done validation.
            // But the user may have changed the file itself after the validation...
            emit notifyProblem("Error loading master game: " + qfl(e.what()));
            // Give up loading the game
            return NULL;
        }
    }

    // Create the game
    Game *tmpGame = GameFactory::Instance()->createGame(params, masterGame);
    PublicGame *game = new PublicGame(*tmpGame);

    // Add the players
    if (!radioButtonTraining->isChecked() &&
        !radioButtonTopping->isChecked())
    {
        const QList<PlayerDef> &players = m_helper->getPlayers(false);
        set<QString> allNames;
        for (int num = 0; num < players.size(); ++num)
        {
            QString name = players.at(num).name;
            if (name == "")
                name = _q("Player %1").arg(num + 1);
            // Ensure uniqueness of the players names
            if (allNames.find(name) != allNames.end())
            {
                int n = 2;
                while (allNames.find(name + QString(" (%1)").arg(n)) != allNames.end())
                {
                    ++n;
                }
                name += QString(" (%1)").arg(n);
            }
            allNames.insert(name);

            QString type = players.at(num).type;
            Player *player;
            if (type == _q(kHUMAN))
                player = new HumanPlayer;
            else
            {
                double level = players.at(num).level.toInt();
                player = new AIPercent(level / 100.);
            }
            player->setName(wfq(name));
            game->addPlayer(player);
        }
    }
    else
    {
        game->addPlayer(new HumanPlayer);
    }

    return game;
}
Exemplo n.º 26
0
QString HashManagerScript::getTTH(const QString &aFileName, quint64 size) const{
    dcpp::TTHValue val = HM->getTTH(_tq(aFileName), size);

    return _q(val.toBase32());
}
Exemplo n.º 27
0
NewGame::NewGame(const Dictionary &iDic, QWidget *iParent)
    : QDialog(iParent), m_dic(iDic)
{
    setupUi(this);

    m_blackPalette = lineEditMaster->palette();
    m_redPalette = lineEditMaster->palette();
    m_redPalette.setColor(QPalette::Text, Qt::red);

    radioButtonDuplicate->setToolTip(_q(
            "In duplicate mode, all the players are always faced with the same board and the same rack,\n"
            "thus eliminating any \"luck\" (and tactics).\n"
            "Each player scores the points of the word (s)he found, but only\n"
            "the best move is played on the board.\n"
            "This mode allows an unlimited number of simultaneous players, and is therefore\n"
            "often used for official tournaments."));
    radioButtonFreeGame->setToolTip(_q(
            "This mode is the classical one, often played in family, where players play in turn,\n"
            "each with his own rack. Players are allowed to change letters, thus passing their turn.\n"
            "With only 2 players, some tactics can often be used, because the best move\n"
            "is not necessarily the one with the best score."));
    radioButtonTraining->setToolTip(_q(
            "In training mode, the player can set the rack freely and can see all the possible moves.\n"
            "There is no opponent, the goal is simply to make some progress."));
    radioButtonArbitration->setToolTip(_q(
            "The arbitration mode allows arbitrating a duplicate game, possibly with many players.\n"
            "The arbitrator can set the master move, and keep track of the players moves easily.\n"
            "This mode is ideal for arbitrating duplicate games in clubs or in tournaments."));
    radioButtonTopping->setToolTip(_q(
            "In topping mode, the goal is to find the top as quickly as possible. The player is allowed\n"
            "to try as many moves as possible until he finds the top, but there are penalties\n"
            "when the player takes too much time to find it (or doesn't fint it at all).\n"
            "This mode can be quite difficult, and is mostly intended for experienced players."));

    checkBoxJoker->setToolTip(_q(
            "In a joker game, each rack contains a joker.\n"
            "When a word containing the joker is played on the grid, the joker is then replaced\n"
            "with the corresponding letter from the bag, and the joker stays in the rack.\n"
            "When the corresponding letter is not present in the bag, the joker is placed on the board.\n"
            "This variant, particularly interesting in Duplicate mode, is good to train using the joker."));
    checkBoxExplosive->setToolTip(_q(
            "An explosive game is a bit like a joker game, except that when the computer chooses the rack\n"
            "(containing a joker), it performs a search and finds the best word possible with the rack.\n"
            "Then, if possible, it replaces the joker in the rack with the letter allowing to play this best word.\n"
            "This variant, unlike the joker game, allows playing with a normal-looking rack, but it usually gives\n"
            "much higher scores than in a normal game."));
    checkBox7Among8->setToolTip(_q(
            "With this variant, the rack contains 8 letters instead of 7,\n"
            "but at most 7 can be played at the same time.\n"
            "This allows for more combinations during the game, and thus higher scores."));

    m_helper = new PlayersTableHelper(this, tablePlayers, pushButtonAdd);
    m_helper->addPopupRemoveAction();
    QAction *addToFavAction = new QAction(_q("Mark the selected player(s) as favorites"), this);
    addToFavAction->setStatusTip(_q("Add the selected player(s) to the list of favorite players"));
    QObject::connect(addToFavAction, SIGNAL(triggered()),
                     this, SLOT(addSelectedToFav()));
    m_helper->addPopupAction(addToFavAction);
    m_helper->setUpDown(buttonUp, buttonDown);

    // Initialize the model of the default players
    QList<PlayerDef> fav = PlayersTableHelper::getFavPlayers();
    Q_FOREACH(const PlayerDef &def, fav)
    {
        if (def.isDefault)
            m_helper->addPlayer(def);
    }

    // Default of the default :)
    if (m_helper->getRowCount() == 0)
    {
        m_helper->addPlayer(PlayerDef(_q("Player %1").arg(1), _q(kHUMAN), "", false));
        m_helper->addPlayer(PlayerDef(_q("Eliot"), _q(kAI), "100", false));
    }

    // Enable the Ok button only if there are enough players for the
    // current mode
    QObject::connect(m_helper, SIGNAL(rowCountChanged()),
                     this, SLOT(enableOkButton()));
    QObject::connect(radioButtonDuplicate, SIGNAL(toggled(bool)),
                     this, SLOT(enableOkButton()));
    QObject::connect(radioButtonFreeGame, SIGNAL(toggled(bool)),
                     this, SLOT(enableOkButton()));
    QObject::connect(radioButtonTraining, SIGNAL(toggled(bool)),
                     this, SLOT(enableOkButton()));
    QObject::connect(checkBoxUseMaster, SIGNAL(toggled(bool)),
                     this, SLOT(enableOkButton()));
    QObject::connect(lineEditMaster, SIGNAL(textChanged(QString)),
                     this, SLOT(enableOkButton()));

    QObject::connect(radioButtonDuplicate, SIGNAL(toggled(bool)),
                     this, SLOT(enablePlayers(bool)));
    QObject::connect(radioButtonFreeGame, SIGNAL(toggled(bool)),
                     this, SLOT(enablePlayers(bool)));
    QObject::connect(radioButtonTraining, SIGNAL(toggled(bool)),
                     this, SLOT(enablePlayers(bool)));
    QObject::connect(radioButtonArbitration, SIGNAL(toggled(bool)),
                     this, SLOT(enablePlayers(bool)));
    QObject::connect(radioButtonTopping, SIGNAL(toggled(bool)),
                     this, SLOT(enablePlayers(bool)));

    QObject::connect(radioButtonFreeGame, SIGNAL(toggled(bool)),
                     this, SLOT(enableMasterControls()));

    QObject::connect(checkBoxJoker, SIGNAL(stateChanged(int)),
                     this, SLOT(onJokerChecked(int)));
    QObject::connect(checkBoxExplosive, SIGNAL(stateChanged(int)),
                     this, SLOT(onExplosiveChecked(int)));

    // Master games
    QObject::connect(checkBoxUseMaster, SIGNAL(toggled(bool)),
                     widgetMasterControls, SLOT(setEnabled(bool)));
    QObject::connect(buttonBrowseMaster, SIGNAL(clicked()),
                     this, SLOT(browseMasterGame()));
    QObject::connect(lineEditMaster, SIGNAL(textChanged(QString)),
                     this, SLOT(validateMasterGame(QString)));

    QObject::connect(buttonAddFav, SIGNAL(clicked()),
                     this, SLOT(addFavoritePlayers()));

    // Auto-completion on the master game path
    QCompleter *completer = new QCompleter(this);
    QFileSystemModel *model = new QFileSystemModel(this);
    model->setRootPath(QDir::currentPath());
    completer->setModel(model);
    lineEditMaster->setCompleter(completer);
}
Exemplo n.º 28
0
void HashManagerScript::on(TTHDone, const dcpp::string &file, const dcpp::TTHValue &val) throw() {
    emit done(_q(file), _q(val.toBase32()));
}
Exemplo n.º 29
0
void SideBarView::slotSideBarDblClicked(const QModelIndex &index){
    if (index.column())
        return;

    SideBarItem *item = reinterpret_cast<SideBarItem*>(index.internalPointer());

    if (!_model->isRootItem(item) || item->childCount() > 0)
        return;

    switch (_model->rootItemRole(item)){
    case ArenaWidget::Search:
        {
            ArenaWidgetFactory().create<SearchFrame>();

            break;
        }
    case ArenaWidget::Hub:
        {
            QuickConnect qc;

            qc.exec();

            break;
        }
    //FIXME: Next code duplicates methods from MainWindow
    case ArenaWidget::ShareBrowser:
        {
           QString file = QFileDialog::getOpenFileName ( this, tr ( "Choose file to open" ),
                       QString::fromStdString ( Util::getPath ( Util::PATH_FILE_LISTS ) ),
                       tr ( "Modern XML Filelists" ) + " (*.xml.bz2);;" +
                       tr ( "Modern XML Filelists uncompressed" ) + " (*.xml);;" +
                       tr ( "All files" ) + " (*)" );

            if ( file.isEmpty() )
                return;

            file = QDir::toNativeSeparators ( file );
            UserPtr user = dcpp::DirectoryListing::getUserFromFilename ( _tq ( file ) );

            if ( user )
                ArenaWidgetFactory().create<ShareBrowser, UserPtr, QString, QString> ( user, file, "" );
            
            break;
        }
    case ArenaWidget::PrivateMessage:
        {
             QString f = QFileDialog::getOpenFileName(this, tr("Open log file"),_q(SETTING(LOG_DIRECTORY)), tr("Log files (*.log);;All files (*.*)"));

            if ( !f.isEmpty() ) {
                f = QDir::toNativeSeparators ( f );

                if ( f.startsWith ( "/" ) )
                    f = "file://" + f;
                else
                    f = "file:///" + f;

                QDesktopServices::openUrl ( QUrl(f) );
            }
            
            break;
        }
    default:
        break;
    }

    setExpanded(index, true);
}