Пример #1
0
void ItemBoxTreeWidget::moveItem(const QString &old_cat_id, const QString &new_cat_id, const QString &item_id)
{

    int old_cat_idx = indexOfCategory(old_cat_id);
    int new_cat_idx = indexOfCategory(new_cat_id);

    moveItem(old_cat_idx, new_cat_idx, item_id);

}
Пример #2
0
int qRemove(Queue** q)
{
        Stack* s = (*q)->s1;
        if(isStackEmpry(s))
        {
                moveItem(q);
        } 
        int val = pop(&s);
        return val;
}
Пример #3
0
QModelIndex TreeModel::moveUp(const QModelIndex &index)
{
    if (!index.isValid() || index.row() <= 0)
        return index;
    TaskItem *item = itemForIndex(index);
    Q_ASSERT(item);
    TaskItem *parent = item->parent();
    Q_ASSERT(parent);
    return moveItem(parent, index.row(), index.row() - 1);
}
Пример #4
0
BrowserNode::BrowserNode(BrowserNode * parent, QString fn)
    : QListViewItem(parent), filename(fn) {
  // move it at end
  QListViewItem * child = parent->firstChild();
  
  while (child->nextSibling())
    child = child->nextSibling();
  
  if (child != this)
    moveItem(child);
}
Пример #5
0
BrowserNode::BrowserNode(BrowserNode * parent, const char * n)
    : TreeItem(parent, n)
{
    // move it at end
    TreeItem * child = parent->firstChild();

    while (child->nextSibling())
        child = child->nextSibling();

    if (child != this)
        moveItem(child);
}
Пример #6
0
QModelIndex TreeModel::moveDown(const QModelIndex &index)
{
    if (!index.isValid())
        return index;
    TaskItem *item = itemForIndex(index);
    Q_ASSERT(item);
    TaskItem *parent = item->parent();
    int newRow = index.row() + 1;
    if (!parent || parent->childCount() <= newRow)
        return index;
    return moveItem(parent, index.row(), newRow);
}
Пример #7
0
void BrowserNode::set_parent(Q3ListViewItem * p) {
  parent()->takeItem(this);
  p->insertItem(this);
  
  // move it at end
  Q3ListViewItem * child = p->firstChild();
  
  while (child->nextSibling())
    child = child->nextSibling();
  
  if (child != this)
    moveItem(child);
}
Пример #8
0
void SymbolDataEditor::mouseMoveEvent(QMouseEvent *event)
{
    if (!(event->buttons() & Qt::MidButton) && !(event->buttons() & Qt::LeftButton))
    {
        calculateSideToChange(event->pos());
        changeCursor();
    }

    if (event->buttons() & Qt::LeftButton)
        moveItem(event->pos());

    QGraphicsView::mouseMoveEvent(event);
}
Пример #9
0
BrowserNode::BrowserNode(QString s, BrowserNode * parent)
    : Q3ListViewItem(parent, s),
      name(s), original_id(0), is_new(TRUE), is_deleted(FALSE),
      is_modified(FALSE), is_read_only(FALSE), is_edited(FALSE),
      is_marked(FALSE), is_defined(FALSE) {
  
  // move it at end
  Q3ListViewItem * child = parent->firstChild();
  
  while (child->nextSibling())
    child = child->nextSibling();
  
  if (child != this)
    moveItem(child);
}
Пример #10
0
BrowserNode::BrowserNode(BrowserNode * parent, QString fn, BrowserView * v)
    : Q3ListViewItem(parent), filename(fn), view(v), state(Unknown)
{
    v->add_node(this);

    // move it at end
    Q3ListViewItem * child = parent->firstChild();

    while (child->nextSibling())
        child = child->nextSibling();

    if (child != this)
        moveItem(child);

    parent->setOpen(TRUE);
}
Пример #11
0
void HistoryLog::addToHistory(QListWidgetItem* item, WorkItem* wi)
{	
	QString text(item->text()+" van: " +listDraggedFrom);
	QListWidget* ql = item->listWidget();
	if(ql == ui->list_doing) text += " naar: doing";
	else if(ql == ui->list_todo) text += " naar: todo";
	else if(ql == ui->list_verify) text += " naar: verify";
	else if(ql == ui->list_done) text += " naar: done";
	else text += " naar : fail";
	if(!(std::find(historyLog.begin(), historyLog.end(), text) != historyLog.end()))
	{
		historyLog.push_back(text);
		ui->HistoryLogList->addItem(text);
		moveItem(wi, true);
	}
}
Пример #12
0
void
QueueList::moveSelectedDown() // SLOT
{
    QPtrList<QListViewItem> list = selectedItems();

    for( QListViewItem *item  = list.last(); item; item = list.prev() )
    {
        QListViewItem *after = item->nextSibling();

        if( !after )
            continue;

        moveItem( item, 0, after );
    }

    ensureItemVisible( list.last() );
}
Пример #13
0
void Engine::dropItemUI()
{
    Item *titem = selectItemFromInventory(m_Player->getInventory(), "Drop what?");

    //no valid item selected to drop
    if(titem == NULL) return;

    //move item from player inventory to map items
    moveItem(titem, m_Player->getInventory(), m_CurrentMap->getMapItems());

    //set item's position to players position
    titem->setPosition( m_Player->getPosition());

    //drop message
    std::stringstream dmsg;
    dmsg << "Dropped " << titem->getName() << ".";
    m_MessageManager->addMessage(dmsg.str());
}
Пример #14
0
void FenPrincipale::on_btn_monter_clicked()
{
    QList<QListWidgetItem *> selection = ui->liste->selectedItems();
    QList<int> rows;
    for (int i = 0; i < m_adresses.size(); i++)
    {
        if (selection.contains(m_adresses[i].item))
            rows << i;
    }

    ui->liste->hide();  //On cache la liste pour améliorer les performances du traitement
    if (!rows.isEmpty() && rows.first() > 0)
    {
        foreach(int row, rows)
        {
            moveItem(row, row - 1);
            ui->liste->setCurrentRow(row - 1, QItemSelectionModel::Select);
        }
Пример #15
0
void KEditListBoxManager::slotRemoved( const QString& name )
{
	//Update prevCount
	_prevCount = this->count();

	if( !_config || !_groupName )
	 	return;
		
	//First: search the item number.
	int number = 0;
	int subnumber = 0;
	while( true )
	{
		if( !_config->hasGroup( _groupName->arg( number ) ) )
		{
			number = -1; //not found
			break;
		}
		_config->setGroup( _groupName->arg( number ) );
		if( name == _config->readEntry( "name", QString::null ) )
			break; //found
		
		++number; //Try next group
	}
	
	if( number < 0 ) //failure
		return; //do nothing
	
	_config->deleteGroup( _groupName->arg( number ), true, false );
	emit elementDeleted( number );
	while( _subGroupName && _config->hasGroup( _subGroupName->arg( number ).arg( subnumber ) ) )
	{
		_config->deleteGroup( _subGroupName->arg( number ).arg( subnumber ) );
		++subnumber;
	}
	
	//rotate groups
	while( _config->hasGroup( _groupName->arg( number + 1 ) ) )
	{
		moveItem( number + 1, number );	
	
		++number;
	}
}
Пример #16
0
bool KActionSelector::eventFilter(QObject *o, QEvent *e)
{
    if(d->keyboardEnabled && e->type() == QEvent::KeyPress)
    {
        if((((QKeyEvent *)e)->state() & Qt::ControlButton))
        {
            switch(((QKeyEvent *)e)->key())
            {
            case Key_Right:
                buttonAddClicked();
                break;
            case Key_Left:
                buttonRemoveClicked();
                break;
            case Key_Up:
                buttonUpClicked();
                break;
            case Key_Down:
                buttonDownClicked();
                break;
            default:
                return QWidget::eventFilter(o, e);
                break;
            }
            return true;
        }
        else if(o->inherits("QListBox"))
        {
            switch(((QKeyEvent *)e)->key())
            {
            case Key_Return:
            case Key_Enter:
                QListBox *lb = (QListBox *)o;
                int index = lb->currentItem();
                if(index < 0)
                    break;
                moveItem(lb->item(index));
                return true;
            }
        }
    }
    return QWidget::eventFilter(o, e);
}
Пример #17
0
t_libraryEditor::t_libraryEditor(void)
{
    setMouseTracking(true);
    mode = MOVE;
    scale = 1;
    incompleteStage = false;
    pinPlacement = false;
    haveComp = false;
    g_color = QColor(200, 100, 100);
    p_color = QColor(100, 200, 100);

    offsetx = 500;
    offsety = 500;
    hintWidth = 4000;
    hintHeight = 4000;

    connect(this, SIGNAL(drawWireSignal(QPoint)), this, SLOT(drawWire(QPoint)));
    connect(this, SIGNAL(drawPinSignal(QPoint)), this, SLOT(drawPin(QPoint)));
    connect(this, SIGNAL(moveItemSignal(QPoint)), this, SLOT(moveItem(QPoint)));
}
Пример #18
0
void PartsBinView::dropEventAux(QDropEvent* event, bool justAppend) {
	bool trustResult;
	int toIndex;

	if(justAppend) {
		toIndex = -1;
		trustResult = true;
	} else {
		toIndex = itemIndexAt(event->pos(), trustResult);
	}

	if(!trustResult) return;

	if(event->source() == dynamic_cast<QWidget*>(this)) {
		int fromIndex = itemIndexAt(m_dragStartPos, trustResult);
		if(trustResult && fromIndex != toIndex) {
			moveItem(fromIndex,toIndex);
		}
	} else {
		QByteArray itemData = event->mimeData()->data("application/x-dnditemdata");
		QDataStream dataStream(&itemData, QIODevice::ReadOnly);

		QString moduleID;
		QPointF offset;
		dataStream >> moduleID >> offset;

		ModelPart * mp = m_refModel->retrieveModelPart(moduleID);
		m_parent->copyFilesToContrib(mp, ItemDrag::originator());
		if(mp) {
			if(m_parent->contains(moduleID)) {
				QMessageBox::information(NULL, QObject::tr("Part already in bin"), QObject::tr("The part that you have just added,\nis already there, we won't add it again, right?"));
			} else {
				m_parent->addPart(mp,toIndex);
				m_parent->setDirty();
			}
		}
	}
	event->acceptProposedAction();
}
Пример #19
0
//-----------------------------------------------------------------------------
// Function: ComponentTreeView::mouseReleaseEvent()
//-----------------------------------------------------------------------------
void ComponentTreeView::mouseReleaseEvent( QMouseEvent* event ) 
{
	// make sure widget is not locked
	if (!locked_) 
    {
		QModelIndex pressedIndex = indexAt(pressedPoint_);

		QModelIndex releaseIndex = indexAt(event->pos());

		// if either index is invalid or indexes are the same
		if (!releaseIndex.isValid() || !pressedIndex.isValid() || 
			(releaseIndex == pressedIndex)) {
			
			// do the normal release event functionality
			QTreeView::mouseReleaseEvent(event);

			// restore the normal cursor
			setCursor(QCursor(Qt::ArrowCursor));
			return;
		}

		QModelIndex parent1 = pressedIndex.model()->parent(pressedIndex);
		QModelIndex parent2 = releaseIndex.model()->parent(releaseIndex);

		if (parent1.isValid() && parent1 == parent2) {
			emit moveItem(pressedIndex, releaseIndex);

			QModelIndex newIndex = indexAt(event->pos());
			setCurrentIndex(newIndex);
			emit activated(newIndex);
		}
	}

	// restore the normal cursor
	setCursor(QCursor(Qt::ArrowCursor));

	QTreeView::mouseReleaseEvent(event);
}
Пример #20
0
void
QueueList::moveSelectedUp() // SLOT
{
    QPtrList<QListViewItem> selected = selectedItems();

    // Whilst it would be substantially faster to do this: ((*it)->itemAbove())->move( *it ),
    // this would only work for sequentially ordered items
    for( QListViewItem *item = selected.first(); item; item = selected.next() )
    {
        if( item == itemAtIndex(0) )
            continue;

        QListViewItem *after;

        item == itemAtIndex(1) ?
        after = 0:
                after = ( item->itemAbove() )->itemAbove();

        moveItem( item, 0, after );
    }

    ensureItemVisible( selected.first() );
}
Пример #21
0
void TDEActionSelector::itemDoubleClicked( TQListBoxItem *item )
{
  if ( d->moveOnDoubleClick )
    moveItem( item );
}
Пример #22
0
void InspectTool::touchEvent(QTouchEvent *event)
{
    QList<QTouchEvent::TouchPoint> touchPoints = event->touchPoints();

    switch (event->type()) {
    case QEvent::TouchBegin:
        if (touchPoints.count() == 1 && (event->touchPointStates() & Qt::TouchPointPressed)) {
            if (!m_pressAndHoldTimer.isActive())
                m_pressAndHoldTimer.start();
            m_mousePosition = touchPoints.first().pos();
            initializeDrag(touchPoints.first().pos());
            m_tapEvent = true;
        } else {
            m_tapEvent = false;
        }
        break;
    case QEvent::TouchUpdate: {
        if (touchPoints.count() > 1)
            m_tapEvent = false;
        if ((touchPoints.count() == 1)
                && (event->touchPointStates() & Qt::TouchPointMoved)) {
            m_mousePosition = touchPoints.first().pos();
            moveItem(true);
        } else if ((touchPoints.count() == 2)
                   && (!(event->touchPointStates() & Qt::TouchPointReleased))) {
            // determine scale factor
            const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
            const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();

            qreal touchScaleFactor =
                    QLineF(touchPoint0.pos(), touchPoint1.pos()).length()
                    / QLineF(touchPoint0.lastPos(), touchPoint1.lastPos()).length();

            QPointF oldcenter = (touchPoint0.lastPos() + touchPoint1.lastPos()) / 2;
            QPointF newcenter = (touchPoint0.pos() + touchPoint1.pos()) / 2;

            m_pinchStarted = true;
            scaleView(touchScaleFactor, newcenter, oldcenter);
        }
        break;
    }
    case QEvent::TouchEnd: {
        m_pressAndHoldTimer.stop();
        if (m_pinchStarted) {
            m_pinchStarted = false;
        }
        if (touchPoints.count() == 1 && !m_dragStarted &&
                !m_didPressAndHold && m_tapEvent) {
            m_tapEvent = false;
            bool doubleTap = event->timestamp() - m_touchTimestamp
                    < static_cast<ulong>(QGuiApplication::styleHints()->mouseDoubleClickInterval());
            if (doubleTap) {
                m_nameDisplayTimer.stop();
                selectNextItem();
            }
            else {
                selectItem();
            }
            m_touchTimestamp = event->timestamp();
        }
        m_didPressAndHold = false;
        break;
    }
    default:
        break;
    }
}
Пример #23
0
void InspectTool::mouseMoveEvent(QMouseEvent *event)
{
    m_mousePosition = event->localPos();
    moveItem(event->buttons() & Qt::LeftButton);
}
Пример #24
0
bool BrowserNode::tool_cmd(ToolCom * com, const char * args) {
  switch ((unsigned char) args[-1]) {
  case applyCmd:
  {
      QLOG_FATAL() << Q_FUNC_INFO << "If this got called then we have a logic flaw going on and BrowserNode needs to have Q_OBJECT in it to properly catch ToolCom::Run execution result";
      Q_ASSERT_X(0, "applyCmd happened", "very bad");
      int runResult = ToolCom::run(args, this, FALSE, FALSE);
      com->write_unsigned(runResult);
      break;
  }
  case createCmd:
    // invalid creation
    com->write_id(0);
    break;
  case parentCmd:
    if (this != BrowserView::get_project())
      ((BrowserNode *) parent())->write_id(com);
    else
      com->write_id(0);
    break;
  case childrenCmd:
    {
      unsigned v = com->api_format();
      unsigned n = 0;
      Q3ListViewItem * child;
      
      for (child = firstChild(); child != 0; child = child->nextSibling())
	if (!((BrowserNode *) child)->deletedp() &&
	    ((BrowserNode *) child)->api_compatible(v))
	  n += 1;
      
      com->write_unsigned(n);
      
      for (child = firstChild(); child != 0; child = child->nextSibling())
	if (!((BrowserNode *) child)->deletedp() &&
	    ((BrowserNode *) child)->api_compatible(v))
	  ((BrowserNode *) child)->write_id(com);
    }
    break;
  case getDefCmd:
  case getUmlDefCmd:
  case getCppDefCmd:
  case getJavaDefCmd:
  case getPhpDefCmd:
  case getPythonDefCmd:
  case getIdlDefCmd:
    get_data()->send_uml_def(com, this, comment);
    break;
  case isWritableCmd:
    com->write_bool(!is_read_only);
    break;
  case supportFileCmd:
    // goes up to the package
    return ((BrowserNode *) parent())->tool_cmd(com, args);
  case isOpenCmd:
    com->write_bool(isOpen());
    break;
  case referencedByCmd:
    {
      BrowserNodeList targetof;
      
      referenced_by(targetof);
      // remove duplicats
      targetof.sort_it();
      
      BrowserNode * bn;
      
      targetof.first();
      while ((bn = targetof.current()) != 0)
	if (bn == targetof.next())
	  targetof.remove();
      
      com->write_unsigned(targetof.count());
      
      for (bn = targetof.first(); bn != 0; bn = targetof.next())
	bn->write_id(com);
    }
    break;
  case setCoupleValueCmd:
    if (is_read_only && !root_permission())
      com->write_ack(FALSE);
    else {
      set_value(args, args + strlen(args) + 1);
      package_modified();
      get_data()->modified();
      com->write_ack(TRUE);
    }
    break;
  case setDescriptionCmd:
    if (is_read_only && !root_permission())
      com->write_ack(FALSE);
    else {
      set_comment(args);
      package_modified();
      com->write_ack(TRUE);
    }
    break;
  case setNameCmd:
    if (is_read_only && !root_permission())
      com->write_ack(FALSE);
    else {
      if (name != args) {
	if (((BrowserNode *) parent())->wrong_child_name(args, get_type(),
							 allow_spaces(),
							 allow_empty())) {
	  com->write_ack(FALSE);
	  return TRUE;
	}
	else {
	  set_name(args);
	  update_stereotype();
	  package_modified();
	  get_data()->modified();
	}
      }
      com->write_ack(TRUE);
    }
    break;
  case setOpenCmd:
    BrowserView::select(this);
    setOpen(*args);
    com->write_ack(TRUE);
    break;
  case setMarkedCmd:
    if (*args) {
      if (this == BrowserView::get_project())
	com->write_ack(FALSE);
      else {
	if (!is_marked)
	  toggle_mark();
	com->write_ack(TRUE);
      }
    }
    else {
      if (is_marked)
	toggle_mark();
      com->write_ack(TRUE);
    }
    break;
  case moveAfterCmd:
    if (is_read_only && !root_permission())
      com->write_ack(FALSE);
    else {
      BrowserNode * p = (BrowserNode *) parent();
      BrowserNode * after = (BrowserNode *) com->get_id(args);
      
      if (after == 0) {
	if (p == 0)
	  com->write_ack(FALSE);
	else {
	  p->takeItem(this);
	  p->insertItem(this);
	  com->write_ack(TRUE);
	  p->package_modified();
	}
      }
      else if ((after->parent() != p) ||
	       (after == this)) {
	com->write_ack(FALSE);
      }
      else {
	moveItem(after);
	com->write_ack(TRUE);
	p->package_modified();
      }
    }
    break;
  case moveInCmd:
    // plug-out upgrade, limited checks
    if (is_read_only && !root_permission())
      com->write_ack(FALSE);
    else {
      BrowserNode * newparent = (BrowserNode *) com->get_id(args);
      BrowserNode * oldparent = (BrowserNode *) parent();
      
      if ((newparent == oldparent) || (newparent == this)) {
	com->write_ack(FALSE);
      }
      else {
	oldparent->takeItem(this);
	newparent->insertItem(this);
	com->write_ack(TRUE);
	oldparent->package_modified();
	newparent->package_modified();
      }
    }
    break;
  case old_deleteCmd:
  case deleteCmd:
    if (is_read_only && !root_permission())
      com->write_ack(FALSE);
    else {
      delete_it();
      ((BrowserNode *) parent())->get_data()->modified();
      package_modified();
      com->write_ack(TRUE);
    }
    break;
  case applyStereotypeCmd:
    if (is_read_only && !root_permission())
      com->write_ack(FALSE);
    else {
      ProfiledStereotypes::applyStereotype(this); // call package_modified() if needed
      com->write_ack(TRUE);
    }
    break;
  default:
    return FALSE;
  }
      
  return TRUE;
}
Пример #25
0
void FileOrganiserWidget::dropEvent(QDropEvent *pEvent)
{
    // Note: the MIME data definitely contains the FileSystemMimeType MIME type
    //       (for objects originating from outside this widget), but it may also
    //       contain the FileOrganiserMimeType MIME type (for objects
    //       originating from within this widget). FileOrganiserMimeType is used
    //       by this widget while FileSystemMimeType by external widgets. So,
    //       this means that we must check for FileOrganiserMimeType first

    // Files have been dropped, so add them to the widget and this at the right
    // place (i.e. above/on/below a folder, above/below a file or on the
    // invisible root folder)

    // First, determine the item above/on/below which objects are to be dropped,
    // as well as the drop position (i.e. above, on or below)

    QStandardItem *dropItem;
    DropIndicatorPosition dropPosition = dropIndicatorPosition();

    if (dropPosition == QAbstractItemView::OnViewport) {
        // We dropped the files on the viewport, so...

        dropItem = mModel->invisibleRootItem();

        // Change the drop position since we know that we want want the objects
        // to be dropped on the root folder

        dropPosition = QAbstractItemView::OnItem;
    } else {
        // We dropped the files above/on/below a folder or above/below a file,
        // so...

        dropItem = mModel->itemFromIndex(indexAt(pEvent->pos()));
    }

    // Check the type of MIME data to be dropped

    if (pEvent->mimeData()->hasFormat(FileOrganiserMimeType)) {
        // The user is dropping folders/files from ourselves, i.e. s/he wants
        // some folders/files to be moved around

        // Retrieve the list of indexes to move around and clean it

        QByteArray data = pEvent->mimeData()->data(FileOrganiserMimeType);
        QModelIndexList indexes = cleanIndexList(mModel->decodeData(data));

        // Convert our list of indexes to a list of items
        // Note: indeed, by moving the item corresponding to a particular index,
        //       we may mess up the other indexes, meaning that we may not be
        //       able to retrieve their corresponding item, so...

        QList<QStandardItem *> items;

        for (int i = 0, iMax = indexes.count(); i < iMax; ++i)
            items << mModel->itemFromIndex(indexes[i]);

        // Move the contents of the list to its final destination

        if (dropPosition != QAbstractItemView::BelowItem)
            // Move the items in the order they were dropped

            for (int i = 0, iMax = items.count(); i < iMax; ++i)
                moveItem(items[i], dropItem, dropPosition);
        else
            // Move the items in a reverse order to that they were dropped since
            // we want them moved below the current item

            for (int i = items.count()-1; i >= 0; --i)
                moveItem(items[i], dropItem, dropPosition);
    } else {
        // The user wants to drop files, so add them to the widget and this at
        // the right place

        QList<QUrl> urls = pEvent->mimeData()->urls();

        if (dropPosition != QAbstractItemView::BelowItem)
            // Add the files in the order they were dropped

            for (int i = 0, iMax = urls.count(); i < iMax; ++i)
                addFile(urls[i].toLocalFile(), dropItem, dropPosition);
        else
            // Add the files in a reverse order to that they were dropped since
            // we want them added below the current item

            for (int i = urls.count()-1; i >= 0; --i)
                addFile(urls[i].toLocalFile(), dropItem, dropPosition);
    }

    // Accept the proposed action for the event

    pEvent->acceptProposedAction();

    // Reset the state of the widget
    // Note: there doesn't seem to be and there shouldn't be a need to reset the
    //       state after the widget (the resetting seems to be done elsewhere),
    //       but if don't reset the state of the widget, then the drop indicator
    //       may, in some cases, remain visible (a bug in Qt?), so...

    setState(QAbstractItemView::NoState);
}
void ApplicationListModel::moveRow(const QModelIndex &sourceParent, int sourceRow, const QModelIndex &destinationParent, int destinationChild)
{
    moveItem(sourceRow, destinationChild);
}