TreeWidget::TreeWidget(QWidget *parent) : QTreeWidget(parent) { qRegisterMetaType<QList<QTreeWidgetItem *>>("QTreeWidgetItem"); connect(this, SIGNAL(itemDropped(QList<QTreeWidgetItem*>)), SLOT(selectItems(QList<QTreeWidgetItem*>)), Qt::QueuedConnection); }
void ossimQtVceCanvasWidget::contentsMouseReleaseEvent(QMouseEvent * e ) { theMouseButtonState = e->button(); switch(e->button()) { case Qt::LeftButton: { if(theSelectionRect) { QCanvasItemList collisionList = theSelectionRect->collisions(true); selectItems(collisionList); deleteSelectionRect(); } else if(theLineObject) { ossimQtVceShapeRect startRect(QRect(theLineObject->startPoint().x(), theLineObject->startPoint().y(), 1, 1), canvas()); ossimQtVceShapeRect endRect(QRect(theLineObject->endPoint().x(), theLineObject->endPoint().y(), 1, 1), canvas()); // make sure that the selection rect is in front of everything // startRect.setZ(1); endRect.setZ(1); QCanvasItemList startList = startRect.collisions(true); QCanvasItemList endList = endRect.collisions(true); QPoint startPt = theLineObject->startPoint(); QPoint endPt = theLineObject->endPoint(); ossimQtVceConnectableObject* startObj = getObjectWhereConnectableSlotIntersectsPoint(startList, startPt); ossimQtVceConnectableObject* endObj = getObjectWhereConnectableSlotIntersectsPoint(endList, endPt); if(startObj&&endObj) { makeConnection(startObj, startPt, endObj, endPt); } delete theLineObject; theLineObject = NULL; } break; } default: { break; } } theMouseButtonState = Qt::NoButton; emit canvasWidgetMouseReleaseEvent(e); }
bool ScriptableProxyHelper::selectItems(const QList<int> &items) { INVOKE(selectItems(items)); ClipboardBrowser *c = fetchBrowser(); if (!c) return false; c->clearSelection(); if ( !items.isEmpty() ) { c->setCurrent(items.last()); foreach (int i, items) { const QModelIndex index = c->index(i); if (index.isValid()) c->selectionModel()->select(index, QItemSelectionModel::Select); } }
void UIListView::selectItemsDialog() { QString text = tr( "Please enter text or regular expression to match:" ); QString name = ""; bool accept = false; QString data = KLineEditDlg::getText( text, name, &accept, 0 ); if ( accept == false ) return ; if ( data.isEmpty() ) return ; QRegExp regex = QRegExp( data, false ); QString count = QString::number( selectItems( 0, regex ) ); QMessageBox::information( this, tr( "Selection results" ), tr( "Selected %1 files" ).arg( count ), QMessageBox::Ok ); }
/** * Re-do the style on all widgets. */ void WidgetEngine::refreshStylesheet() { // Expected behaviour here is get every node that's in the tree std::vector< std::shared_ptr< Node > > allNodes = root->getByName( "*" ); // Clear ALL matching queries for( std::shared_ptr< Node > node : allNodes ) { node->getStyle().clearMatchingQueries(); } // Match each stylesheet query's rules to the nodes its query matches for( const StylesheetQuery& sQuery : styleSheet ) { std::set< std::shared_ptr< Node > > matches = { root }; // Tokenise the selector with some ass-ugly C stuff std::vector< std::string > tokens; char* copy = strdup( sQuery.query.c_str() ); char* token = std::strtok( copy, " \t" ); while( token != NULL ) { tokens.emplace_back( token ); token = std::strtok( NULL, " \t" ); } free( copy ); // "selector" = an entire query ("div#id.class .class2") // "selector component" = a part of that query separated by whitespace ("div#id.class", or ".class2") // Refine the list of matches by taking the previous matches and applying the current selector component to that set of nodes for( const std::string& selectorComponent : tokens ) { matches = selectItems( toSelector( selectorComponent ), matches ); } // In the list of all matches for this selector, spray sQuery.rules across them for( std::shared_ptr< Node > match : matches ) { match->getStyle().pushMatchingQuery( &sQuery.rules ); } } // After styles are reapplied, recompute all computed styles //root->positionChildren(); }
/** * Display inventory items. */ void AgiEngine::inventory() { int oldFg, oldBg; int n; // screen is white with black text oldFg = _game.colorFg; oldBg = _game.colorBg; _game.colorFg = 0; _game.colorBg = 15; _gfx->clearScreen(_game.colorBg); switch (getLanguage()) { case Common::RU_RUS: printText(YOUHAVE_MSG_RU, 0, YOUHAVE_X_RU, YOUHAVE_Y_RU, 40, STATUS_FG, STATUS_BG); break; default: printText(YOUHAVE_MSG, 0, YOUHAVE_X, YOUHAVE_Y, 40, STATUS_FG, STATUS_BG); break; } // FIXME: doesn't check if objects overflow off screen... _intobj = (uint8 *)malloc(4 + _game.numObjects); memset(_intobj, 0, (4 + _game.numObjects)); n = showItems(); switch (getLanguage()) { case Common::RU_RUS: if (getflag(fStatusSelectsItems)) { printText(SELECT_MSG_RU, 0, SELECT_X_RU, SELECT_Y_RU, 40, STATUS_FG, STATUS_BG); } else { printText(ANY_KEY_MSG_RU, 0, ANY_KEY_X_RU, ANY_KEY_Y_RU, 40, STATUS_FG, STATUS_BG); } break; default: if (getflag(fStatusSelectsItems)) { printText(SELECT_MSG, 0, SELECT_X, SELECT_Y, 40, STATUS_FG, STATUS_BG); } else { printText(ANY_KEY_MSG, 0, ANY_KEY_X, ANY_KEY_Y, 40, STATUS_FG, STATUS_BG); } break; } _gfx->flushScreen(); // If flag 13 is set, we want to highlight & select an item. // opon selection, put objnum in var 25. Then on esc put in // var 25 = 0xff. if (getflag(fStatusSelectsItems)) selectItems(n); free(_intobj); if (!getflag(fStatusSelectsItems)) waitAnyKey(); _gfx->clearScreen(0); writeStatus(); _picture->showPic(); _game.colorFg = oldFg; _game.colorBg = oldBg; _game.hasPrompt = 0; flushLines(_game.lineUserInput, 24); }
void ossimQtVceCanvasWidget::selectAll() { unselectItems(); QCanvasItemList canvasItemList = canvas()->allItems(); selectItems(canvasItemList); }