QgsAppLegendInterface::QgsAppLegendInterface( QgsLegend * legend )
    : mLegend( legend )
{
  connect( legend, SIGNAL( itemAdded( QModelIndex ) ), this, SIGNAL( itemAdded( QModelIndex ) ) );
  connect( legend, SIGNAL( itemMoved( QModelIndex, QModelIndex ) ), this, SLOT( updateIndex( QModelIndex, QModelIndex ) ) );
  connect( legend, SIGNAL( itemMoved( QModelIndex, QModelIndex ) ), this, SIGNAL( groupRelationsChanged( ) ) );
  connect( legend, SIGNAL( itemMovedGroup( QgsLegendItem *, int ) ), this, SIGNAL( groupRelationsChanged() ) );
  // connect( legend, SIGNAL( itemChanged( QTreeWidgetItem*, int ) ), this, SIGNAL( groupRelationsChanged() ) );
  connect( legend, SIGNAL( itemRemoved() ), this, SIGNAL( itemRemoved() ) );
}
void  OgreWidget::mouseReleaseEvent(QMouseEvent * e)
{
  if (e->button() == Qt::MiddleButton || e->button() == Qt::LeftButton)
    {
      m_mouseButtonsPressed &= e->buttons();
      m_oldPos = QPoint(InvalidMousePoint);

      if (m_snapeToGrid)
        {
          Ogre::Vector3 pos = m_selectionManager.getPosition();
          int           gridSpace = DataManager::getSingleton()->getGridSpace();

          pos.x = qFloor((pos.x + gridSpace / 2.f) / gridSpace) * gridSpace;
          pos.y = qFloor((pos.y + gridSpace / 2.f) / gridSpace) * gridSpace;
          pos.z = qFloor((pos.z + gridSpace / 2.f) / gridSpace) * gridSpace;
          m_selectionManager.setPosition(pos.x, pos.y, pos.z);
          emit itemMoved();
        }
      if (m_snapeToAngle)
        {
          Ogre::Quaternion  orientation = m_selectionManager.getOrientation();
          int               snapAngle = DataManager::getSingleton()->getSnapAngle();

          if (m_constraintedX)
            {
              m_selectionManager.pitch(-orientation.getPitch());
              m_selectionManager.pitch(Ogre::Degree(qFloor((orientation.getPitch().valueDegrees() + snapAngle / 2.f) / snapAngle) * snapAngle));
            }
          else if (m_constraintedY)
            {
              m_selectionManager.yaw(-orientation.getYaw());
              m_selectionManager.yaw(Ogre::Degree(qFloor((orientation.getYaw().valueDegrees() + snapAngle / 2.f) / snapAngle) * snapAngle));
            }
          else if (m_constraintedZ)
            {
              m_selectionManager.roll(-orientation.getRoll());
              m_selectionManager.roll(Ogre::Degree(qFloor((orientation.getRoll().valueDegrees() + snapAngle / 2.f) / snapAngle) * snapAngle));
            }
          emit itemMoved();
        }
      update();
      e->accept();
    }
  else
    {
      e->ignore();
    }
}
Ejemplo n.º 3
0
QVariant GraphicsComponent::itemChange(GraphicsItemChange change, const QVariant &value)
{

    switch (change)
    {
    case ItemPositionChange:
        {
            emit itemMoved(this);
            QPoint pos = value.toPoint();
            if (this->parent->getSnapToGrid()){
                pos = this->calculateSnap(pos);
                this->setProperty("x", pos.x());
                this->setProperty("y", pos.y());
                return QGraphicsItem::itemChange(change, QVariant(pos));
            }

            this->setProperty("x", this->x());
            this->setProperty("y", this->y());

        }
        break;
    case ItemSelectedChange:
        break;
    default:
        break;

    }

     return QGraphicsItem::itemChange(change, value);

}
void  OgreWidget::mouseMoveEvent(QMouseEvent * e)
{
  if (m_oldPos != InvalidMousePoint)
    {
      Ogre::Real deltaX = e->pos().x() - m_oldPos.x();
      Ogre::Real deltaY = e->pos().y() - m_oldPos.y();

      if (m_mouseButtonsPressed.testFlag(Qt::MiddleButton))
        {
          if(e->modifiers().testFlag(Qt::ControlModifier))
            m_camera->zoom(-deltaY);
          else if (e->modifiers().testFlag(Qt::ShiftModifier))
            m_camera->rotate(deltaX, -deltaY);
          else
            m_camera->shift(-deltaX, -deltaY);
        }
      else if (m_mouseButtonsPressed.testFlag(Qt::LeftButton) && !m_selectionManager.isEmpty())
        {
          if (m_constraintedX && e->modifiers().testFlag(Qt::ShiftModifier))
            m_selectionManager.pitch(Ogre::Degree(deltaX));
          else if (m_constraintedY && e->modifiers().testFlag(Qt::ShiftModifier))
            m_selectionManager.yaw(Ogre::Degree(deltaX));
          else if (m_constraintedZ && e->modifiers().testFlag(Qt::ShiftModifier))
            m_selectionManager.roll(Ogre::Degree(deltaX));
          else
            {
              Ogre::Plane plane;

              if (m_constraintedX)
                plane.redefine(Ogre::Vector3(1, 0, 0), m_selectionManager.getPosition());
              else if (m_constraintedY)
                plane.redefine(Ogre::Vector3(0, 1, 0), m_selectionManager.getPosition());
              else if (m_constraintedZ)
                plane.redefine(Ogre::Vector3(0, 0, 1), m_selectionManager.getPosition());

              Ogre::Ray                   oldRay = m_camera->getCamera()->getCameraToViewportRay(e->pos().x() / (float)width(), e->pos().y() / (float)height());
              Ogre::Ray                   ray = m_camera->getCamera()->getCameraToViewportRay(m_oldPos.x() / (float)width(), m_oldPos.y() / (float)height());
              std::pair<bool, Ogre::Real> oldResult = oldRay.intersects(plane);
              std::pair<bool, Ogre::Real> result = ray.intersects(plane);

              if (result.first && oldResult.first)
                {
                  Ogre::Vector3 point;

                  point = oldRay.getPoint(oldResult.second) - ray.getPoint(result.second);
                  m_selectionManager.translate(point.x, point.y, point.z);
                }
            }
          emit itemMoved();
        }
      m_oldPos = e->pos();

      update();
      e->accept();
    }
  else
    {
      e->ignore();
    }
}
Ejemplo n.º 5
0
void
SeasonTreeView::dropEvent(QDropEvent* event)
{
    // get the list of the items that are about to be dropped
    QTreeWidgetItem* item = selectedItems()[0];
 
    // row we started on
    int idx1 = indexFromItem(item).row();
 
    // don't move temp 'system generated' date ranges!
    if (context->athlete->seasons->seasons[idx1].type != Season::temporary) {

        // the default implementation takes care of the actual move inside the tree
        QTreeWidget::dropEvent(event);
 
        // moved to !
        int idx2 = indexFromItem(item).row();
 
        // notify subscribers in some useful way
        Q_EMIT itemMoved(item, idx1, idx2);

    } else {

        event->ignore();
    }
}
Ejemplo n.º 6
0
void DockItemController::itemMove(DockItem * const moveItem, DockItem * const replaceItem)
{
    Q_ASSERT(moveItem != replaceItem);

    const DockItem::ItemType moveType = moveItem->itemType();
    const DockItem::ItemType replaceType = replaceItem->itemType();

    // app move
    if (moveType == DockItem::App)
        if (replaceType != DockItem::App && replaceType != DockItem::Stretch)
            return;

    // plugins move
    if (moveType == DockItem::Plugins)
        if (replaceType != DockItem::Plugins)
            return;

    const int moveIndex = m_itemList.indexOf(moveItem);
    const int replaceIndex = replaceType == DockItem::Stretch ?
                                // disable insert after placeholder item
                                m_itemList.indexOf(replaceItem) - 1 :
                                m_itemList.indexOf(replaceItem);

    m_itemList.removeAt(moveIndex);
    m_itemList.insert(replaceIndex, moveItem);
    emit itemMoved(moveItem, replaceIndex);

    // update plugins sort key if order changed
    if (moveType == DockItem::Plugins || replaceType == DockItem::Plugins)
        m_updatePluginsOrderTimer->start();

    // for app move, index 0 is launcher item, need to pass it.
    if (moveType == DockItem::App && replaceType == DockItem::App)
        m_appInter->MoveEntry(moveIndex - 1, replaceIndex - 1);
}
Ejemplo n.º 7
0
void IdentityItem::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
{
  if ( pos() != m_movePos ) {
    emit itemMoved( this, pos() );
  }

  QGraphicsEllipseItem::mouseReleaseEvent( event );
}
Ejemplo n.º 8
0
void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    if (movingItem != 0 && event->button() == Qt::LeftButton) {
        if (oldPos != movingItem->pos())
            emit itemMoved(qgraphicsitem_cast<DiagramItem *>(movingItem),
                           oldPos);
        movingItem = 0;
    }
    QGraphicsScene::mouseReleaseEvent(event);
}
Ejemplo n.º 9
0
void CanvasView::contentsMouseMoveEvent(QMouseEvent* event)
{
    if (moving) {
	QPoint p = inverseWorldMatrix().map(event->pos());
	moving->moveBy(p.x() - moving_start.x(), p.y() - moving_start.y());
	moving_start = p;
	canvas()->update();
        emit itemMoved(moving);
    }
}
Ejemplo n.º 10
0
void MovableTableWidget::dropEvent(QDropEvent *event)
{
  if (event->source() != this)
  {
    event->ignore();
    return;
  }

  int targetRow = dropRow(event->pos());

  QByteArray encoded = event->mimeData()->data("application/x-qabstractitemmodeldatalist");
  QDataStream stream(&encoded, QIODevice::ReadOnly);

  QMap<int, QMap<int, QString> > rows;
  while (!stream.atEnd())
  {
    int row, col;
    QMap<int,  QVariant> roleDataMap;
    stream >> row >> col >> roleDataMap;

    rows[row][col] = roleDataMap[0].toString();
  }

  QList<int> rowkeys = rows.keys();
  qSort(rowkeys);

  for (int row = rowkeys.count()-1; 0 <= row ; row--)
  {
    int rowIndex = rowkeys[row];
    if (rowIndex < targetRow)
    {
      targetRow--;
    }
    removeRow(rowIndex);
  }

  for (int row = 0; row < rowkeys.count(); ++row)
  {
    QMap<int, QString> cols = rows[rowkeys[row]];
    QList<int> colkeys = cols.keys();

    insertRow(targetRow+row);
    for (int col = 0; col < colkeys.count(); ++col)
    {
      QString value = cols[colkeys[col]];
      setItem(targetRow+row, col, new QTableWidgetItem(value));
      setItemSelected(item(targetRow+row, col), true);
    }
    emit(itemMoved(rowkeys[row],targetRow+row));
  }


  m_lineRow = -1;
}
Ejemplo n.º 11
0
void
SeasonTreeView::dropEvent(QDropEvent* event)
{
    // item and original position
    QTreeWidgetItem *item = currentItem();
    int idx1 = invisibleRootItem()->indexOfChild(item);
    int idx2 = indexAt(event->pos()).row();

    // finalise drop event
    QTreeWidget::dropEvent(event);

    // emit the itemMoved signal
    Q_EMIT itemMoved(item, idx1, idx2);
}
Ejemplo n.º 12
0
void CoordinateDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{	
	
	// Boolean to determine corresponding scene of data
	bool scene;
	bool broadcast = true;
	
	// Cast the editor as a double spin box
	QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(editor);
	spinBox->interpretText();

	// Get the value from the editor
	double value = spinBox->value();
	
	// Cast the model as a CoordinateModel and set the data
	CoordinateModel *m = qobject_cast<CoordinateModel*>(model);
	
	// Use the QModelIndex to locate the corresponding QPointF in the data model
	QList<QPointF> refCoords = m->refCoords;
	QList<QPointF> epoCoords = m->epoCoords;

	QPointF oldPosition;
	QPointF newPosition;
	
	switch (index.column()) {
		case 0:
			oldPosition = refCoords.at(index.row());
			newPosition = QPointF(oldPosition);
			newPosition.setX(value);
			scene = true;
			break;
		case 1:
			oldPosition = refCoords.at(index.row());
			newPosition = QPointF(oldPosition);
			newPosition.setY(value);
			scene = true;
			break;
		case 2:
			oldPosition = epoCoords.at(index.row());
			if (oldPosition == QPointF(-1, -1))
				broadcast = false;
			newPosition = QPointF(oldPosition);
			newPosition.setX(value);
			scene = false;
			break;
		case 3:
			oldPosition = epoCoords.at(index.row());
			if (oldPosition == QPointF(-1, -1))
				broadcast = false;
			newPosition = QPointF(oldPosition);
			newPosition.setY(value);
			scene = false;
			break;
	}
	
	// Broadcast change of data
	if (broadcast)
	{
		QModelIndex indx = QModelIndex(index);
		if (scene == true)
			emit itemMoved(fitsScene, newPosition, oldPosition, &indx);
		else
			emit itemMoved(epoScene, newPosition, oldPosition, &indx);
	}
}
Ejemplo n.º 13
0
void PartsBinListView::moveItem(int fromIndex, int toIndex) {
	itemMoved(fromIndex,toIndex);
	emit informItemMoved(fromIndex, toIndex);
}
Ejemplo n.º 14
0
void LiveListWidget::dropEvent(QDropEvent *event)
{
    QListWidget::dropEvent(event);
    emit itemMoved(drag_row,this->row(temp_item),temp_item);
}
Ejemplo n.º 15
0
void GraphView::dragMoveEvent(QDragMoveEvent *event)
{
    m_temp->setPos(mapToScene(event->pos()));
    emit itemMoved(m_tempId);
}
Ejemplo n.º 16
0
void TupItemManager::dropEvent(QDropEvent *event)
{
     bool eventAccept = false;

     if (event->mimeData()->hasFormat("application/x-dnditemdata")) {
         QByteArray itemData = event->mimeData()->data("application/x-dnditemdata");
         QDataStream dataStream(&itemData, QIODevice::ReadOnly);

         QPixmap pixmap;
         QString label;
         QString extension;
         QString key;
         dataStream >> pixmap >> label >> extension >> key;

         QTreeWidgetItem *item;
         QTreeWidgetItem *parent = itemAt(event->pos().x(), event->pos().y());

         if (parent) {
             // If both Target and Origin are directories
             if (parentNode.length() > 0) {
                 if ((parent->text(2).length() == 0) && (extension.length() == 0))
                      return;
             }

             // Ensure Target is a directory
             if (parent->text(2).length() > 0)
                 return;

             // Target is going to the same parent
             int childrenTotal = parent->childCount(); 
             for (int i=0;i < childrenTotal; i++) {
                  QTreeWidgetItem *child = parent->child(i);
                  QString name = child->text(1);
                  if (name.compare(label) == 0 && child->text(2).compare(extension) == 0)
                      return;
             }

             // Make sure node and target are not the same
             if (extension.length() > 0) {
                 if (parentNode.length() > 0) {
                     QList<QTreeWidgetItem *> nodes = findItems(parentNode, Qt::MatchExactly, 1);
                     for (int i = 0; i < nodes.size(); ++i) {
                          QTreeWidgetItem *node = nodes.at(i);
                          if (node->text(1).compare(parentNode) == 0) {
                              int childrenTotal = node->childCount();
                              for (int i=0;i < childrenTotal; i++) {
                                   QTreeWidgetItem *child = node->child(i);
                                   if (child->text(1).compare(label) == 0 && child->text(2).compare(extension) == 0) {
                                       node->removeChild(child);
                                       break;
                                   }
                              }
                              break;
                          }
                     }
                 }

                 item = new QTreeWidgetItem(parent);
                 item->setIcon(0, QIcon(pixmap));
                 item->setText(1, label);
                 item->setText(2, extension);
                 item->setText(3, key);
                 item->setFlags(item->flags() | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
                 setCurrentItem(item);

                 if (key.length() > 0)
                     emit itemMoved(key, parent->text(1));

                 eventAccept = true;

             } else {
                 bool flag = true;
                 if (parent->isExpanded())
                     flag = false;
                 parent->setExpanded(flag);
             }

         } else {

             if (parentNode.length() > 0) {
                 QList<QTreeWidgetItem *> nodes = findItems(parentNode, Qt::MatchExactly, 1);
                 for (int i = 0; i < nodes.size(); ++i) {
                      QTreeWidgetItem *node = nodes.at(i);
                      if (node->text(1).compare(parentNode) == 0) {
                          int childrenTotal = node->childCount();
                          for (int i=0;i < childrenTotal; i++) {
                               QTreeWidgetItem *child = node->child(i);
                               if (child->text(1).compare(label) == 0 && child->text(2).compare(extension) == 0) {
                                   node->removeChild(child); 
                                   break;
                               }
                          }
                          break;
                      }
                 }
             } else {
                 if (extension.length() == 0 && nodeChildren.size() > 0)
                     return;
             }

             item = new QTreeWidgetItem(this);
             item->setIcon(0, QIcon(pixmap));
             item->setText(1, label);
             item->setText(2, extension);
             item->setText(3, key);
             item->setFlags(item->flags() | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
             setCurrentItem(item);

             emit itemMoved(key, "");
             eventAccept = true;
         }

     } else {
Ejemplo n.º 17
0
PrintSetup::PrintSetup(QVector<MyField> avlbFields, QVector<QSqlRecord> newRecords, QWidget *parent) : QDialog(parent)
{

    Fields=avlbFields;
    Fields.append(MyField("Static String","Main_table", DataType::Static));
    QString allTextFields = "";
    for (int i =0; i<avlbFields.count();i++){
        qDebug()<<"Getting Field: "<<i;
        if (avlbFields[i].getType()==DataType::Text || avlbFields[i].getType()==DataType::LongText){
            allTextFields.append(QString("%1;").arg(avlbFields[i].getName()));
        }
    }
    allTextFields.chop(1);
    Fields.append(MyField("Combined",allTextFields, DataType::Combined));

    records=newRecords;

    cmbFields=new QComboBox();
    for(int i=0;i<Fields.size();i++){
        cmbFields->addItem(Fields[i].getName(),QVariant::fromValue(Fields[i]));
    }
    setLayout(mainLayout);
    mainLayout->addWidget(cmbFields,1,1,1,1);

    printItemList = new MyPrintList(newRecords, this);

    savePrinter->setOutputFormat(QPrinter::PdfFormat);

    populateSetup();
    //savePrinter->setPaperSize(avlbPaperSize->value(cmbPageSize->currentText()));
    //previewPrinter->setPaperSize(avlbPaperSize->value(cmbPageSize->currentText()));


    //savePrinter->setResolution(cmbResolution->currentData().toInt());
    //previewPrinter->setResolution(600);

    printPreview = new QPrintPreviewWidget(previewPrinter);
    printPreview->setSinglePageViewMode();
    pageSetupLayout->addWidget(lblPageSize,1,1,1,1);
    pageSetupLayout->addWidget(cmbPageSize,1,2,1,1);
    pageSetupLayout->addWidget(lblResolution,1,3,1,1);
    pageSetupLayout->addWidget(cmbResolution,1,4,1,1);

    mainLayout->addWidget(btnAddField,1,2,1,1);
    mainLayout->addWidget(printItemList,2,1,5,3);
    mainLayout->addWidget(printPreview,1,4,6,6);
    mainLayout->addLayout(pageSetupLayout,7,1,1,4);
    mainLayout->addWidget(btnExport,7,9,1,1);

    connect(btnAddField,SIGNAL(clicked()),this,SLOT(addField()));
    connect(printPreview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(previewPrint(QPrinter*)));
    connect(printItemList, SIGNAL(itemAdded()), this, SLOT(printUpdated()));
    connect(printItemList, SIGNAL(itemModified()), this, SLOT(printUpdated()));
    connect(printItemList, SIGNAL(itemMoved()), this, SLOT(printUpdated()));
    connect(cmbPageSize, SIGNAL(currentIndexChanged(int)), this, SLOT(pageSetupUpdated()));
    connect(cmbResolution, SIGNAL(currentIndexChanged(int)), this, SLOT(pageSetupUpdated()));
    connect(btnExport, SIGNAL(clicked(bool)),this,SLOT(printRecords()));
    resize(1000,1000);
    setMinimumHeight(400);



}
Ejemplo n.º 18
0
QgsAppLegendInterface::QgsAppLegendInterface( QgsLegend * legend )
    : mLegend( legend )
{
  connect( legend, SIGNAL( itemMoved( QModelIndex, QModelIndex ) ), this, SLOT( updateIndex( QModelIndex, QModelIndex ) ) );
}
Ejemplo n.º 19
0
void LinkedListTest::moveItem() {
    LinkedList list;
    Item item;
    Item item2;
    Item item3;
    list.insert(&item);
    list.insert(&item2);
    list.insert(&item3);

    /* Move item in the midde */
    Item item2Moved(std::move(item2));
    CORRADE_VERIFY(item2.list() == nullptr);
    CORRADE_VERIFY(item2.previous() == nullptr);
    CORRADE_VERIFY(item2.next() == nullptr);
    CORRADE_VERIFY(item2Moved.list() == &list);
    CORRADE_VERIFY(item2Moved.previous() == &item);
    CORRADE_VERIFY(item2Moved.next() == &item3);
    CORRADE_VERIFY(item.next() == &item2Moved);
    CORRADE_VERIFY(item3.previous() == &item2Moved);

    /* Move assignment */
    LinkedList list2;
    Item item4;

    list2.insert(&item4);
    CORRADE_VERIFY(!list2.isEmpty());

    item4 = std::move(item2Moved);
    CORRADE_VERIFY(list2.isEmpty());

    CORRADE_VERIFY(item2Moved.list() == nullptr);
    CORRADE_VERIFY(item2Moved.previous() == nullptr);
    CORRADE_VERIFY(item2Moved.next() == nullptr);
    CORRADE_VERIFY(item4.list() == &list);
    CORRADE_VERIFY(item4.previous() == &item);
    CORRADE_VERIFY(item4.next() == &item3);
    CORRADE_VERIFY(item.next() == &item4);
    CORRADE_VERIFY(item3.previous() == &item4);

    /* Remove other items to have only one remaining */
    list.cut(&item4);
    list.cut(&item3);

    /* Move item at the beginning/end */
    Item itemMoved(std::move(item));
    CORRADE_VERIFY(itemMoved.list() == &list);
    CORRADE_VERIFY(list.first() == &itemMoved);
    CORRADE_VERIFY(list.last() == &itemMoved);

    /* Move assignment */
    Item item5;

    list2.insert(&item5);
    CORRADE_VERIFY(!list2.isEmpty());

    item5 = std::move(itemMoved);
    CORRADE_VERIFY(item5.list() == &list);
    CORRADE_VERIFY(list2.isEmpty());

    CORRADE_VERIFY(list.first() == &item5);
    CORRADE_VERIFY(list.last() == &item5);

    list.cut(&item5);
}