QTfrontend/ui/page/pageroomslist.cpp
changeset 10803 df39aa3f6d4d
parent 10750 31c744824dab
child 11046 47a8c19ecb60
equal deleted inserted replaced
10802:089e43d01f74 10803:df39aa3f6d4d
    75     showGamesInLobby->setCheckable(true);
    75     showGamesInLobby->setCheckable(true);
    76     showGamesInLobby->setChecked(true);
    76     showGamesInLobby->setChecked(true);
    77     showGamesInProgress = new QAction(QAction::tr("Show games in-progress"), stateMenu);
    77     showGamesInProgress = new QAction(QAction::tr("Show games in-progress"), stateMenu);
    78     showGamesInProgress->setCheckable(true);
    78     showGamesInProgress->setCheckable(true);
    79     showGamesInProgress->setChecked(true);
    79     showGamesInProgress->setChecked(true);
       
    80     showPassword = new QAction(QAction::tr("Show password protected"), stateMenu);
       
    81     showPassword->setCheckable(true);
       
    82     showPassword->setChecked(true);
       
    83     showJoinRestricted = new QAction(QAction::tr("Show join restricted"), stateMenu);
       
    84     showJoinRestricted->setCheckable(true);
       
    85     showJoinRestricted->setChecked(true);
    80     stateMenu->addAction(showGamesInLobby);
    86     stateMenu->addAction(showGamesInLobby);
    81     stateMenu->addAction(showGamesInProgress);
    87     stateMenu->addAction(showGamesInProgress);
       
    88     stateMenu->addAction(showPassword);
       
    89     stateMenu->addAction(showJoinRestricted);
    82     btnState->setMenu(stateMenu);
    90     btnState->setMenu(stateMenu);
    83 
    91 
    84     // Help/prompt message at top
    92     // Help/prompt message at top
    85     QLabel * lblDesc = new QLabel(tr("Search for a room:"));
    93     QLabel * lblDesc = new QLabel(tr("Search for a room:"));
    86     lblDesc->setObjectName("lblDesc");
    94     lblDesc->setObjectName("lblDesc");
   184     connect(searchText, SIGNAL(returnPressed()), this, SLOT(onJoinClick()));
   192     connect(searchText, SIGNAL(returnPressed()), this, SLOT(onJoinClick()));
   185     connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick()));
   193     connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick()));
   186     connect(roomsList, SIGNAL(clicked (const QModelIndex &)), searchText, SLOT(setFocus()));
   194     connect(roomsList, SIGNAL(clicked (const QModelIndex &)), searchText, SLOT(setFocus()));
   187     connect(showGamesInLobby, SIGNAL(triggered()), this, SLOT(onFilterChanged()));
   195     connect(showGamesInLobby, SIGNAL(triggered()), this, SLOT(onFilterChanged()));
   188     connect(showGamesInProgress, SIGNAL(triggered()), this, SLOT(onFilterChanged()));
   196     connect(showGamesInProgress, SIGNAL(triggered()), this, SLOT(onFilterChanged()));
       
   197     connect(showPassword, SIGNAL(triggered()), this, SLOT(onFilterChanged()));
       
   198     connect(showJoinRestricted, SIGNAL(triggered()), this, SLOT(onFilterChanged()));
   189     connect(searchText, SIGNAL(textChanged (const QString &)), this, SLOT(onFilterChanged()));
   199     connect(searchText, SIGNAL(textChanged (const QString &)), this, SLOT(onFilterChanged()));
   190     connect(this, SIGNAL(askJoinConfirmation (const QString &)), this, SLOT(onJoinConfirmation(const QString &)), Qt::QueuedConnection);
   200     connect(this, SIGNAL(askJoinConfirmation (const QString &)), this, SLOT(onJoinConfirmation(const QString &)), Qt::QueuedConnection);
   191 
   201 
   192     // Set focus on search box
   202     // Set focus on search box
   193     connect(this, SIGNAL(pageEnter()), searchText, SLOT(setFocus()));
   203     connect(this, SIGNAL(pageEnter()), searchText, SLOT(setFocus()));
   628 
   638 
   629     roomsModel->setFilterFixedString(searchText->text());
   639     roomsModel->setFilterFixedString(searchText->text());
   630 
   640 
   631     bool stateLobby = showGamesInLobby->isChecked();
   641     bool stateLobby = showGamesInLobby->isChecked();
   632     bool stateProgress = showGamesInProgress->isChecked();
   642     bool stateProgress = showGamesInProgress->isChecked();
   633 
   643     bool statePassword = showPassword->isChecked();
   634     if (stateLobby && stateProgress)
   644     bool stateJoinRestricted = showJoinRestricted->isChecked();
   635         stateFilteredModel->setFilterFixedString(QString()); // "any"
   645 
   636     else if (stateLobby != stateProgress)
   646     QString filter;
   637         stateFilteredModel->setFilterFixedString(QString(stateProgress));
   647     if (!stateLobby && !stateProgress)
       
   648         filter = "O_o";
       
   649     else if (stateLobby && stateProgress && statePassword && stateJoinRestricted)
       
   650         filter = "";
   638     else
   651     else
   639         stateFilteredModel->setFilterFixedString(QString("none")); // Basically, none.
   652     {
       
   653         QString exclude = "[^";
       
   654         if (!stateProgress) exclude += "g";
       
   655         if (!statePassword) exclude += "p";
       
   656         if (!stateJoinRestricted) exclude += "j";
       
   657         exclude += "]*";
       
   658         if (stateProgress && statePassword && stateJoinRestricted) exclude = ".*";
       
   659         filter = "^" + exclude;
       
   660         if (!stateLobby) filter += "g" + exclude;
       
   661         filter += "$";
       
   662     }
       
   663     //qDebug() << filter;
       
   664 
       
   665     stateFilteredModel->setFilterRegExp(filter);
   640 }
   666 }
   641 
   667 
   642 void PageRoomsList::setSettings(QSettings *settings)
   668 void PageRoomsList::setSettings(QSettings *settings)
   643 {
   669 {
   644     m_gameSettings = settings;
   670     m_gameSettings = settings;