/*!\en * Delets group with child elements and groups. * \param idg (in) - id deleted group. * \param listDelId (in,out) - list of id deleted elements and groups. \_en \ru * Физически удаляет группу со всеми ее дочерними элементами и группами. * \param idg (in) - идентификационный номер выделенной для удаления группы. * \param listDelId (in,out) - список идентификационных номеров выделенных для удаления элементов и групп. *\_ru */ qulonglong aCatalogue::delGroup(qulonglong idg, Q3ValueList<qulonglong> &listDelId) { aSQLTable * tg = table ( md_group ); if ( !tg ) return 0; //if ( !selected( md_group ) ) return err_notselected; qulonglong tmp;// idg = tg->sysValue("id").toULongLong(); groupSelect(idg); if ( idg ) { aLog::print(aLog::Info,tr("aCatalogue delete group with id=%1").arg(idg)); // printf("idg=" LLU_SPEC "\n",idg); // delete elements in group; while(selectByGroup(idg)==err_noerror) { listDelId << delElement(); } while (groupByParent(idg)==err_noerror) { delGroup(GroupSysValue("id").toULongLong(), listDelId); //printf(">>>idg=%lu\n",tmp); } } tg->select(QString("id=%1").arg(idg),false); if(tg->first()) { tg->primeDelete(); tg->del(); listDelId << idg; setSelected( false, md_group ); } return idg; }
/*!\en * Inserts new group in groups table * \param parentId (in) - id parent group, or 0 if no parent. \_en \ru * Вставляет новую группу в таблицу групп * \param parentId (in) - идентификационный номер группы предка или 0 если нет предка. *\_ru */ ERR_Code aCatalogue::newGroup(qulonglong parentId ) { aSQLTable *tg = table( md_group ); if (!tg ) return err_notable; setSelected(true, md_group); tg->select(parentId); setSelected(true,md_group); qulonglong level, idg; if(tg->first()) { level = tg->sysValue("level").toULongLong()+1; } else level=0; QSqlRecord* rec = tg->primeInsert(); // get edit buffer for table groups idg = rec->value("id").toULongLong(); aLog::print(aLog::Info,tr("aCatalogue new group with id=%1").arg(idg) ); rec->setValue("id",idg ); rec->setValue("idp",parentId); rec->setValue("level",level); rec->setValue("df","0"); tg->insert(); // insert record tg->select(QString("id=%1").arg(idg),false); // set cursor to inserted record tg->first(); setSelected(true,md_group); //tg->update(); return groupSelect(idg); }
qulonglong aCatalogue::setMarkDeletedGroup(qulonglong id_gr, bool del) { groupSelect(id_gr); SetMarkDeleted(del, md_group); GroupUpdate(); return table()->sysValue("id").toULongLong(); }
ERR_Code aCatalogue::groupSelect () { aSQLTable * t = table(md_group); if ( !t ) return err_notable; qulonglong idg = t->sysValue("id").toULongLong(); return groupSelect( idg ); }
/*! *\~english * Select group. * Get group id from current element and select group table * with this id. *\~russian *\~ * \return \~english Error code \~russian \~ */ int aCatalogue::GroupSelect() { aSQLTable * t = table(); if(!t) return err_notable; if ( !selected() ) return err_notselected;; qulonglong idg = t->sysValue("idg").toULongLong(); return groupSelect(idg); }
ERR_Code aCatalogue::New( bool child ) { qulonglong group = getGroup(), parent = getUid(); ERR_Code err = aObject::New(); if ( err ) return err; aSQLTable * t = table(); t->setSysValue( "idg", group ); if ( child ) t->setSysValue( "ido", parent ); t->primeUpdate(); t->update(); if ( group ) groupSelect(); setSelected(true); return err_noerror; }
ERR_Code aCatalogue::Select( bool grouponly ) { aSQLTable * t = table(); if ( !t ) return err_notable; // setSelected(true,md_group); // setSelected(true); qulonglong idg = getGroup(); QString flt = ""; // groupSelect(); if ( grouponly ) flt = QString("idg=%1").arg( idg ); if ( t->select( flt ) ) if ( t->first() ) { setSelected(true); qulonglong newidg = t->sysValue("idg").toULongLong(); aLog::print(aLog::Debug, tr("aCatalogue select group id=%1").arg(idg)); if ( newidg != idg ) groupSelect( newidg ); return err_noerror; } else return err_notselected; else return err_selecterror; }
/* * groupHandleEvent * */ void groupHandleEvent (XEvent *event) { CompWindow *w; CompScreen *s; GROUP_DISPLAY (&display); switch (event->type) { case KeyPress: if (isKeyPressEvent (event, &gd->select_single_key)) groupSelectSingle (display.activeWindow); else if (isKeyPressEvent (event, &gd->group_key)) groupGroupWindows (event->xkey.root); else if (isKeyPressEvent (event, &gd->ungroup_key)) groupUnGroupWindows (event->xkey.root); else if (isKeyPressEvent (event, &gd->remove_key)) groupRemoveWindow (display.activeWindow); else if (isKeyPressEvent (event, &gd->close_key)) groupCloseWindows (display.activeWindow); else if (isKeyPressEvent (event, &gd->ignore_key)) groupSetIgnore (); else if (isKeyPressEvent (event, &gd->tabmode_key)) groupInitTab (display.activeWindow); else if (isKeyPressEvent (event, &gd->change_tab_left_key)) groupChangeTabLeft (display.activeWindow); else if (isKeyPressEvent (event, &gd->change_tab_right_key)) groupChangeTabRight (display.activeWindow); else if (isKeyPressEvent (event, &gd->change_color_key)) groupChangeColor (display.activeWindow); break; case KeyRelease: if (gd->ignore_key.keycode == event->xkey.keycode) groupUnsetIgnore (); break; case MotionNotify: s = findScreenAtDisplay (event->xmotion.root); if (s) groupHandleMotionEvent (s, pointerX, pointerY); break; case ButtonPress: if (isButtonPressEvent (event, &gd->select_button)) groupSelect (event->xbutton.window); s = findScreenAtDisplay (event->xbutton.root); if (s) groupHandleButtonPressEvent (s, event); break; case ButtonRelease: if (gd->select_button.button == event->xbutton.button) groupSelectTerminate (event->xbutton.root); s = findScreenAtDisplay (event->xbutton.root); if (s) groupHandleButtonReleaseEvent (s, event); break; case MapNotify: w = findWindowAtDisplay (event->xmap.window); if (w) { CompWindow *cw; for (cw = w->screen->windows; cw; cw = cw->next) { if (w->id == cw->frame) { GROUP_WINDOW (cw); if (gw->windowHideInfo) XUnmapWindow (display.display, cw->frame); } } } break; case UnmapNotify: w = findWindowAtDisplay (event->xunmap.window); if (w) { GROUP_WINDOW (w); if (w->pendingUnmaps) { if (w->shaded) { gw->windowState = WindowShaded; const BananaValue * option_shade_all = bananaGetOption (bananaIndex, "shade_all", w->screen->screenNum); if (gw->group && option_shade_all->b) groupShadeWindows (w, gw->group, TRUE); } else if (w->minimized) { gw->windowState = WindowMinimized; const BananaValue * option_minimize_all = bananaGetOption (bananaIndex, "minimize_all", w->screen->screenNum); if (gw->group && option_minimize_all->b) groupMinimizeWindows (w, gw->group, TRUE); } } if (gw->group) { if (gw->group->tabBar && IS_TOP_TAB (w, gw->group)) { /* on unmap of the top tab, hide the tab bar and the input prevention window */ groupTabSetVisibility (gw->group, FALSE, PERMANENT); } if (!w->pendingUnmaps) { /* close event */ if (!(gw->animateState & IS_UNGROUPING)) { groupDeleteGroupWindow (w); damageScreen (w->screen); } } } } break; case ClientMessage: if (event->xclient.message_type == display.winActiveAtom) { w = findWindowAtDisplay (event->xclient.window); if (w) { GROUP_WINDOW (w); if (gw->group && gw->group->tabBar && !IS_TOP_TAB (w, gw->group)) { gw->group->checkFocusAfterTabChange = TRUE; groupChangeTab (gw->slot, RotateUncertain); } } } else if (event->xclient.message_type == gd->resizeNotifyAtom) { CompWindow *w; w = findWindowAtDisplay (event->xclient.window); if (w && gd->resizeInfo && (w == gd->resizeInfo->resizedWindow)) { GROUP_WINDOW (w); GROUP_SCREEN (w->screen); if (gw->group) { int i; XRectangle rect; rect.x = event->xclient.data.l[0]; rect.y = event->xclient.data.l[1]; rect.width = event->xclient.data.l[2]; rect.height = event->xclient.data.l[3]; for (i = 0; i < gw->group->nWins; i++) { CompWindow *cw = gw->group->windows[i]; GroupWindow *gcw; gcw = GET_GROUP_WINDOW (cw, gs); if (gcw->resizeGeometry) { if (groupUpdateResizeRectangle (cw, &rect, TRUE)) addWindowDamage (cw); } } } } } break; default: if (event->type == display.shapeEvent + ShapeNotify) { XShapeEvent *se = (XShapeEvent *) event; if (se->kind == ShapeInput) { CompWindow *w; w = findWindowAtDisplay (se->window); if (w) { GROUP_WINDOW (w); if (gw->windowHideInfo) groupClearWindowInputShape (w, gw->windowHideInfo); } } } break; } UNWRAP (gd, &display, handleEvent); (*display.handleEvent)(event); WRAP (gd, &display, handleEvent, groupHandleEvent); switch (event->type) { case PropertyNotify: if (event->xproperty.atom == display.wmNameAtom) { CompWindow *w; w = findWindowAtDisplay (event->xproperty.window); if (w) { GROUP_WINDOW (w); if (gw->group && gw->group->tabBar && gw->group->tabBar->textSlot && gw->group->tabBar->textSlot->window == w) { /* make sure we are using the updated name */ groupRenderWindowTitle (gw->group); groupDamageTabBarRegion (gw->group); } } } break; case EnterNotify: { CompWindow *w; w = findWindowAtDisplay (event->xcrossing.window); if (w) { GROUP_WINDOW (w); GROUP_SCREEN (w->screen); if (gs->showDelayTimeoutHandle) compRemoveTimeout (gs->showDelayTimeoutHandle); if (w->id != w->screen->grabWindow) groupUpdateTabBars (w->screen, w->id); if (gw->group) { if (gs->draggedSlot && gs->dragged && IS_TOP_TAB (w, gw->group)) { int hoverTime; const BananaValue * option_drag_hover_time = bananaGetOption (bananaIndex, "drag_hover_time", w->screen->screenNum); hoverTime = option_drag_hover_time->f * 1000; if (gs->dragHoverTimeoutHandle) compRemoveTimeout (gs->dragHoverTimeoutHandle); if (hoverTime > 0) gs->dragHoverTimeoutHandle = compAddTimeout (hoverTime, (float) hoverTime * 1.2, groupDragHoverTimeout, w); } } } } break; case ConfigureNotify: { CompWindow *w; w = findWindowAtDisplay (event->xconfigure.window); if (w) { GROUP_WINDOW (w); if (gw->group && gw->group->tabBar && IS_TOP_TAB (w, gw->group) && gw->group->inputPrevention && gw->group->ipwMapped) { XWindowChanges xwc; xwc.stack_mode = Above; xwc.sibling = w->id; XConfigureWindow (display.display, gw->group->inputPrevention, CWSibling | CWStackMode, &xwc); } if (event->xconfigure.above != None) { if (gw->group && !gw->group->tabBar && (gw->group != gd->lastRestackedGroup)) { const BananaValue * option_raise_all = bananaGetOption (bananaIndex, "raise_all", w->screen->screenNum); if (option_raise_all->b) groupRaiseWindows (w, gw->group); } if (w->managed && !w->attrib.override_redirect) gd->lastRestackedGroup = gw->group; } } } break; default: break; } }