// take a new game from parser void ClientWindow::slot_game(Game* g) { // insert into ListView QListViewItemIterator lv(ListView_games); if (g->running) { bool found = false; GamesTableItem *lvi_mem = NULL; // check if game already exists if (!playerListEmpty) { QListViewItemIterator lvii = lv; for (GamesTableItem *lvi; (lvi = static_cast<GamesTableItem*>(lvii.current())) && !found;) { lvii++; // compare game id if (lvi->text(0) == g->nr) { found = true; lvi_mem = lvi; } } } else if (!g->H && !myAccount->num_games) { // skip games until initial table has loaded qDebug("game skipped because no init table"); return; } QString excludeMark = ""; QString myMark = "B"; // check if exclude entry is done later if (g->H) //g->status.length() > 1) { QString emw; QString emb; // no: do it now emw = getPlayerExcludeListEntry(g->wname); emb = getPlayerExcludeListEntry(g->bname); // ensure that my game is listed first if (emw && emw == "M" || emb && emb == "M") { myMark = "A"; excludeMark = "M"; // I'm playing, thus I'm open, except teaching games if (emw && emw && (emw != "M" || emb != "M")) { // checkbox open slot_checkbox(0, true); } } else if (emw && emw == "W" || emb && emb == "W") { excludeMark = "W"; } } if (found) { // supersede entry //lvi_mem->setText(0, g->nr); lvi_mem->setText(1, g->wname); lvi_mem->setText(2, g->wrank); lvi_mem->setText(3, g->bname); lvi_mem->setText(4, g->brank); lvi_mem->setText(5, g->mv); lvi_mem->setText(6, g->Sz); lvi_mem->setText(7, g->H); lvi_mem->setText(8, g->K); lvi_mem->setText(9, g->By); lvi_mem->setText(10, g->FR); lvi_mem->setText(11, g->ob); // lvi_mem->setText(6, g->status + " (" + g->ob + ")"); lvi_mem->setText(12, myMark + rkToKey(g->wrank) + g->wname.lower() + ":" + excludeMark); lvi_mem->ownRepaint(); } else { // from GAMES command or game info{...} if (g->H) { lv = new GamesTableItem(ListView_games, g->nr, " " + g->wname, g->wrank, " " + g->bname, g->brank, g->mv, g->Sz, g->H, g->K, g->By, g->FR, g->ob); } else { lv = new GamesTableItem(ListView_games, g->nr, " " + g->wname, g->wrank, " " + g->bname, g->brank, g->mv, g->Sz); } lv.current()->setText(12, myMark + rkToKey(g->wrank) + g->wname.lower() + ":" + excludeMark); static_cast<GamesTableItem*>(lv.current())->ownRepaint(); // increase number of games myAccount->num_games++; statusGames->setText(" G: " + QString::number(myAccount->num_games) + " / " + QString::number(myAccount->num_observedgames) + " "); } // update player info if this is not a 'who'-result or if it's me if (!g->H || myMark == "A") //g->status.length() < 2) { QListViewItemIterator lvp(ListView_players); QListViewItem *lvpi; int found = 0; // look for players in playerlist for (; (lvpi = lvp.current()) && found < 2;) { // check if names are identical if (lvpi->text(1) == g->wname || lvpi->text(1) == g->bname) { lvpi->setText(3, g->nr); found++; // check if players has a rank if (g->wrank == "??" || g->brank == "??") { // no rank given in case of continued game -> set rank in games table if (lvpi->text(1) == g->wname) { lv.current()->setText(2, lvpi->text(2)); // correct sorting of col 2 -> set col 12 lv.current()->setText(12, myMark + rkToKey(lvpi->text(2)) + lvpi->text(1).lower() + ":" + excludeMark); } // no else case! bplayer could be identical to wplayer! if (lvpi->text(1) == g->bname) lv.current()->setText(4, lvpi->text(2)); static_cast<GamesTableItem*>(lv.current())->ownRepaint(); } } lvp++; } ListView_games->sort(); } } else { // from game info {...} bool found = false; QString game_id; if (g->nr != "@") { for (QListViewItem *lvi; (lvi = lv.current()) && !found;) { lv++; // compare game id if (lvi->text(0) == g->nr) { lv++; delete lvi; found = true;; } } // used for player update below game_id = g->nr; } else { for (QListViewItem *lvi; (lvi = lv.current()) && !found;) { lv++; // look for name if (lvi->text(1) == myAccount->acc_name || lvi->text(3) == myAccount->acc_name) { // used for player update below game_id = lvi->text(0); lv++; delete lvi; found = true;; } } } if (!found) qWarning("game not found"); else { // decrease number of games myAccount->num_games--; statusGames->setText(" G: " + QString::number(myAccount->num_games) + " / " + QString::number(myAccount->num_observedgames) + " "); QListViewItemIterator lvp(ListView_players); QListViewItem *lvpi; int found = 0; // look for players in playerlist for (; (lvpi = lvp.current()) && found < 2;) { // check if numbers are identical if (lvpi->text(3) == game_id) { lvpi->setText(3, "-"); found++; } lvp++; } } } }
//===================================== // XKeyboard apply keyboard //------------------------------------- bool XKeyboard::apply ( void ) { // log(L_INFO,"XKeyboard::apply() called\n"); // ... // apply the keyboard to the X-Server for immediate // usage. This call will use the XKB extension // --- XWrapPointer< QDict<char> > mText (mTextPtr); QString* XkbModel = NULL; QString* XkbLayout = NULL; QString* XkbVariant = NULL; QString* XkbOptions = NULL; // 1) primary XKB model QDictIterator<char> itModel (mModelHash); for (; itModel.current(); ++itModel) { if (QString::fromLocal8Bit (itModel.current()) == mType->currentText()) { XkbModel = new QString (itModel.currentKey()); } } // 2) primary XKB layout QDictIterator<char> itLayout (mLayoutHash); for (; itLayout.current(); ++itLayout) { if (QString::fromLocal8Bit(itLayout.current()) == mLayout->currentText()) { XkbLayout = new QString (itLayout.currentKey()); } } // 3) variant for primary XKB layout XkbVariant = new QString(); if (mVariant->currentText()) { *XkbVariant = mVariant->currentText(); } // 4) additional layout and variant QListViewItemIterator itAdd (mAddView); for ( ; itAdd.current(); ++itAdd ) { QCheckListItem* item = (QCheckListItem*)itAdd.current(); if (item->isOn()) { QString layout = itAdd.current()->text(2); QString variant = ""; XkbLayout->sprintf("%s,%s", XkbLayout->ascii(),layout.ascii() ); if (itAdd.current()->text(3)) { variant = itAdd.current()->text(3); } XkbVariant->sprintf("%s,%s", XkbVariant->ascii(),variant.ascii() ); } } // 5) options if (mKeyboardOptions["XkbOptions"]) { if (! QString(mKeyboardOptions["XkbOptions"]).isEmpty()) { XkbOptions = new QString (mKeyboardOptions["XkbOptions"]); } } QString optm ("-model"); QString optl ("-layout"); QString opto ("-option"); QString optv ("-variant"); if ((XkbVariant) && (XkbOptions)) { #if 0 printf("%s %s %s %s %s %s %s %s\n", optm.ascii(),XkbModel->ascii(),optl.ascii(),XkbLayout->ascii(), opto.ascii(),XkbOptions->ascii(),optv.ascii(),XkbVariant->ascii() ); #endif #if 1 qx ( SETXKBMAP,STDNONE,8,"%s %s %s %s %s %s %s %s", optm.ascii(),XkbModel->ascii(),optl.ascii(),XkbLayout->ascii(), opto.ascii(),XkbOptions->ascii(),optv.ascii(),XkbVariant->ascii() ); #endif } else if (XkbVariant) { #if 0 printf("%s %s %s %s %s %s\n", optm.ascii(),XkbModel->ascii(),optl.ascii(),XkbLayout->ascii(), optv.ascii(),XkbVariant->ascii() ); #endif #if 1 qx ( SETXKBMAP,STDNONE,8,"%s %s %s %s %s %s", optm.ascii(),XkbModel->ascii(),optl.ascii(),XkbLayout->ascii(), optv.ascii(),XkbVariant->ascii() ); #endif } else if (XkbOptions) { #if 0 printf("%s %s %s %s %s %s\n", optm.ascii(),XkbModel->ascii(),optl.ascii(),XkbLayout->ascii(), opto.ascii(),XkbOptions->ascii() ); #endif #if 1 qx ( SETXKBMAP,STDNONE,8,"%s %s %s %s %s %s", optm.ascii(),XkbModel->ascii(),optl.ascii(),XkbLayout->ascii(), opto.ascii(),XkbOptions->ascii() ); #endif } else { #if 0 printf("%s %s %s %s\n", optm.ascii(),XkbModel->ascii(),optl.ascii(),XkbLayout->ascii() ); #endif #if 1 qx ( SETXKBMAP,STDNONE,8,"%s %s %s %s", optm.ascii(),XkbModel->ascii(),optl.ascii(),XkbLayout->ascii() ); #endif } return (true); }
//===================================== // XKeyboard reset and switch to Intro //------------------------------------- void XKeyboard::resetPage (int reload) { // ... // this function is called if the keyboard dialog is finished or canceled // The changes are serialized and re-imported if the user want // to conclude the dialog. Otherwhise the original file is imported // and the changes will be lost. // --- QString update = "sys_KEYBOARD"; //======================================= // save primary and secondary keyboard(s) //--------------------------------------- if (reload == PAGE_RELOAD) { QString* XkbLayout = NULL; QString* XkbModel = NULL; QString* XkbVariant = NULL; XWrapFile < QDict<XFile> > mFiles (mFilePtr); XWrapPointer<XData> workingKeyboard ( mFiles["sys_KEYBOARD"]->getDevice (0) ); // 1) primary XKB model QDictIterator<char> itModel (mModelHash); for (; itModel.current(); ++itModel) { if (QString::fromLocal8Bit(itModel.current()) == mType->currentText()) { XkbModel = new QString (itModel.currentKey()); } } // 2) primary XKB layout QDictIterator<char> itLayout (mLayoutHash); for (; itLayout.current(); ++itLayout) { if ( QString::fromLocal8Bit(itLayout.current()) == mLayout->currentText() ) { XkbLayout = new QString (itLayout.currentKey()); } } // 3) variant for primary XKB layout XkbVariant = new QString(); if ((mVariant->currentText()) && (mVariant->currentText() != "basic")) { *XkbVariant = mVariant->currentText(); } // 4) additional layout and variant QListViewItemIterator itAdd (mAddView); for ( ; itAdd.current(); ++itAdd ) { QCheckListItem* item = (QCheckListItem*)itAdd.current(); if (item->isOn()) { QString layout = itAdd.current()->text(2); QString variant = "!"; XkbLayout->sprintf("%s,%s", XkbLayout->ascii(),layout.ascii() ); if (itAdd.current()->text(3)) { variant = itAdd.current()->text(3); } XkbVariant->sprintf("%s,%s", XkbVariant->ascii(),variant.ascii() ); } } if (XkbLayout) { workingKeyboard.setPair ("XkbLayout", XkbLayout->ascii() ); } if (XkbModel) { workingKeyboard.setPair ("XkbModel", XkbModel->ascii() ); } if ((XkbVariant) && (! XkbVariant->isEmpty())) { workingKeyboard.setPair ("XkbVariant", XkbVariant->ascii() ); } else { workingKeyboard.setPair ("XkbVariant", ""); } // 5) XkbOptions LeftAlt RightAlt ScrollLock RightCtl if (mKeyboardOptions["XkbOptions"]) { workingKeyboard.setPair ( "XkbOptions", mKeyboardOptions["XkbOptions"] ); } if (mKeyboardOptions["LeftAlt"]) { workingKeyboard.setPair ( "LeftAlt", mKeyboardOptions["LeftAlt"] ); } if (mKeyboardOptions["RightAlt"]) { workingKeyboard.setPair ( "RightAlt", mKeyboardOptions["RightAlt"] ); } if (mKeyboardOptions["ScrollLock"]) { workingKeyboard.setPair ( "ScrollLock", mKeyboardOptions["ScrollLock"] ); } if (mKeyboardOptions["RightCtl"]) { workingKeyboard.setPair ( "RightCtl", mKeyboardOptions["RightCtl"] ); } } mStatus -> clear(); if (reload == PAGE_RELOAD) { mFilePtr = mIntro->getFiles(); XWrapFile < QDict<XFile> > mFiles (mFilePtr); if (mFiles [update] -> sysSerialize()) { mFiles [update] -> isModified ( mFrame ); } } mIntro -> importFile (update); slotIntro (mIndex); XTemplate::resetPage (); mStack -> raiseWidget (Intro); }
//===================================== // XKeyboard virtual slots... //------------------------------------- bool XKeyboard::slotRun (int index) { if (XTemplate::slotRun (index)) { // log(L_INFO,"XKeyboard::slotRun() called: %d\n",index); // ... // this function is called if the keyboard page is activated. // use this function to init the dialog with the current // setup of the keyboard // --- XWrapPointer< QDict<char> > mText (mTextPtr); mStatus -> message (mText["RunXKeyboard"]); mFrame -> nextButton() -> setText (mText["finish"]); // ... // get the mFiles pointer wrapper from the Intro // object which has read all the data files. Than // lookup the keyboard XData object // --- QDict<XFile>* mFilePtr = mIntro->getFiles(); XWrapFile < QDict<XFile> > mFiles (mFilePtr); XData* sysData = mFiles["sys_KEYBOARD"] -> getDevice(0); if (! sysData) { return (FALSE); } QDict<char> keyboardInfo = sysData -> getData(); QString XKBLayouts = keyboardInfo["XkbLayout"]; QString XKBVariants = keyboardInfo["XkbVariant"]; QString XKBModel = keyboardInfo["XkbModel"]; //===================================== // clean QListView data fields //------------------------------------- mAddView -> clearSelection(); QListViewItemIterator itAdd (mAddView); for ( ; itAdd.current(); ++itAdd ) { QCheckListItem* item = (QCheckListItem*)itAdd.current(); item -> setOn ( false ); item -> setText ( 3 , "" ); } //===================================== // select base keyboard model //------------------------------------- QDictIterator<char> itModel (mModelHash); for (; itModel.current(); ++itModel) { if (itModel.currentKey() == XKBModel) { mType -> setCurrentText (QString::fromLocal8Bit (itModel.current())); } } //===================================== // get layout/variant lists //------------------------------------- XStringList completeLayout (XKBLayouts); completeLayout.setSeperator (","); QList<char> layoutList = completeLayout.getList(); QString baseLayout = layoutList.getFirst(); layoutList.removeFirst(); QStringList completeVariant = QStringList::split (",", XKBVariants,True); QList<char> variantList; QStringList::Iterator in; for (in = completeVariant.begin(); in != completeVariant.end(); ++in) { if (QString (*in).isEmpty()) { variantList.append ("!"); } else { variantList.append (*in); } } QString baseVariant = variantList.getFirst(); variantList.removeFirst(); int varCount = 0; //===================================== // select base/secondary layout(s) //------------------------------------- // 1) QDictIterator<char> itLayout (mLayoutHash); for (; itLayout.current(); ++itLayout) { if (itLayout.currentKey() == baseLayout) { mLayout -> setCurrentText (QString::fromLocal8Bit (itLayout.current())); } } // 2) QListIterator<char> it (layoutList); for (; it.current(); ++it) { QListViewItemIterator itAdd (mAddView); for ( ; itAdd.current(); ++itAdd ) { QCheckListItem* item = (QCheckListItem*)itAdd.current(); QString layout = itAdd.current()->text(2); if (layout == it.current()) { item -> setOn (true); if (QString(variantList.at(varCount)) != "!") { item -> setText ( 3 , variantList.at(varCount) ); } mAddView -> setSelected (itAdd.current(), true); mAddView -> ensureItemVisible (item); varCount++; } } } updateVariants(); //===================================== // select base/secondary variant(s) //------------------------------------- for (int n=0;n<mVariant->count();n++) { QString item = mVariant->text (n); if (item == baseVariant) { mVariant -> setCurrentText (baseVariant); } } } return (TRUE); }
void EntryWidgetKeyword::readListView() { m_usedKeywords.clear(); for ( QListViewItemIterator it = QListViewItemIterator( m_listviewKeywords, QListViewItemIterator::Checked ); it.current() != NULL; ++it ) m_usedKeywords.append(( *it ) ->text( 0 ) ); }