Exemple #1
0
void PianorollEditor::timerEvent(QTimerEvent* event)
      {
      killTimer(event->timerId());
      gv->updateNotes();
      updateSelection();
      }
// Move the selection within the parameter tuner tree widget
void Parametertuner::moveSelection(int dir)
{
	// Error checking
	if(dir != UP && dir != DOWN) return;

	// Declare variables
	QTreeWidgetItem* item;
	QTreeWidgetItem* tmpItem;
	QTreeWidgetItem* thisItem;
	QTreeWidgetItem* parentItem;
	int itemIndex;

	// Get the currently selected item
	thisItem = getSelectedItem();

	// If no item is selected then select the first top level item
	if(!thisItem)
	{
		if(dir == DOWN)
			updateSelection(NULL, m_ui.parameter_root_widget->topLevelItem(0));
		else
			updateSelection(NULL, m_ui.parameter_root_widget->topLevelItem(m_ui.parameter_root_widget->topLevelItemCount() - 1));
		return;
	}

	// Handle UP case
	if(dir == UP)
	{
		// Go to the previous item in the tree
		parentItem = itemGetParent(thisItem);
		itemIndex = parentItem->indexOfChild(thisItem);
		tmpItem = parentItem->child(itemIndex + UP);
		if(tmpItem)
		{
			item = tmpItem;
			while(item->childCount() > 0 && item->isExpanded())
				item = item->child(item->childCount() - 1);
			updateSelection(thisItem, item);
			return;
		}
		else if(itemHasParent(thisItem))
		{
			updateSelection(thisItem, parentItem);
			return;
		}
		else return; // <-- This is the case that we are at the very top-most element
	}

	// Handle DOWN case
	if(dir == DOWN)
	{
		// If the item has children and is expanded then go to the first child
		if(thisItem->childCount() > 0 && thisItem->isExpanded())
		{
			updateSelection(thisItem, thisItem->child(0));
			return;
		}

		// Go to the next item in the tree
		item = thisItem;
		while(true)
		{
			parentItem = itemGetParent(item);
			itemIndex = parentItem->indexOfChild(item);
			tmpItem = parentItem->child(itemIndex + DOWN);
			if(tmpItem)
			{
				updateSelection(thisItem, tmpItem);
				return;
			}
			else
			{
				if(itemHasParent(item))
					item = parentItem;
				else return; // <-- This is the case that we are at the very bottom-most element
			}
		}
	}
}
Exemple #3
0
void GLWorld::updateSelection()
{
    updateSelection(mapFromGlobal(QCursor::pos()));
}
EffectSelectDialog::EffectSelectDialog( QWidget * _parent ) :
    QDialog( _parent ),
    ui( new Ui::EffectSelectDialog ),
    m_sourceModel(),
    m_model(),
    m_descriptionWidget( NULL )
{
    ui->setupUi( this );

    setWindowIcon( embed::getIconPixmap( "setup_audio" ) );

    // query effects

    EffectKeyList subPluginEffectKeys;

    for (const Plugin::Descriptor* desc: pluginFactory->descriptors(Plugin::Effect))
    {
        if( desc->subPluginFeatures )
        {
            desc->subPluginFeatures->listSubPluginKeys(
                // as iterators are always stated to be not
                // equal with pointers, we dereference the
                // iterator and take the address of the item,
                // so we're on the safe side and the compiler
                // likely will reduce that to just "it"
                desc,
                subPluginEffectKeys );
        }
        else
        {
            m_effectKeys << EffectKey( desc, desc->name );

        }
    }

    m_effectKeys += subPluginEffectKeys;

    // and fill our source model
    QStringList pluginNames;
    for( EffectKeyList::ConstIterator it = m_effectKeys.begin(); it != m_effectKeys.end(); ++it )
    {
        if( ( *it ).desc->subPluginFeatures )
        {
            pluginNames += QString( "%1: %2" ).arg(  ( *it ).desc->displayName, ( *it ).name );
        }
        else
        {
            pluginNames += ( *it ).desc->displayName;
        }
    }

    int row = 0;
    for( QStringList::ConstIterator it = pluginNames.begin();
            it != pluginNames.end(); ++it )
    {
        m_sourceModel.setItem( row, 0, new QStandardItem( *it ) );
        ++row;
    }

    // setup filtering
    m_model.setSourceModel( &m_sourceModel );
    m_model.setFilterCaseSensitivity( Qt::CaseInsensitive );

    connect( ui->filterEdit, SIGNAL( textChanged( const QString & ) ),
             &m_model, SLOT( setFilterFixedString( const QString & ) ) );
    connect( ui->filterEdit, SIGNAL( textChanged( const QString & ) ),
             this, SLOT( updateSelection() ) );

    ui->pluginList->setModel( &m_model );

    // setup selection model
    QItemSelectionModel * selectionModel = new QItemSelectionModel( &m_model );
    ui->pluginList->setSelectionModel( selectionModel );
    connect( selectionModel, SIGNAL( currentRowChanged( const QModelIndex &,
                                     const QModelIndex & ) ),
             SLOT( rowChanged( const QModelIndex &, const QModelIndex & ) ) );
    connect( ui->pluginList, SIGNAL( doubleClicked( const QModelIndex & ) ),
             SLOT( acceptSelection() ) );

    // try to accept current selection when pressing "OK"
    connect( ui->buttonBox, SIGNAL( accepted() ),
             this, SLOT( acceptSelection() ) );

    updateSelection();
    show();
}
QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWidget *parent, Qt::WindowFlags flags )
    : QDialog( parent, flags ), mDock( 0 ), mLayer( theLayer ), mProgress( 0 ), mWorkaround( false )
{
  setupUi( this );

  setAttribute( Qt::WA_DeleteOnClose );

  QSettings settings;
  restoreGeometry( settings.value( "/Windows/BetterAttributeTable/geometry" ).toByteArray() );

  connect( mView, SIGNAL( progress( int, bool & ) ), this, SLOT( progress( int, bool & ) ) );
  connect( mView, SIGNAL( finished() ), this, SLOT( finished() ) );
  mView->setCanvasAndLayer( QgisApp::instance()->mapCanvas(), mLayer );

  mFilterModel = ( QgsAttributeTableFilterModel * ) mView->model();
  mModel = qobject_cast<QgsAttributeTableModel * >( dynamic_cast<QgsAttributeTableFilterModel *>( mView->model() )->sourceModel() );

  mQuery = query;
  mColumnBox = columnBox;
  columnBoxInit();

  bool myDockFlag = settings.value( "/qgis/dockAttributeTable", false ).toBool();
  if ( myDockFlag )
  {
    mDock = new QgsAttributeTableDock( tr( "Attribute table - %1 (%n Feature(s))", "feature count", mModel->rowCount() ).arg( mLayer->name() ), QgisApp::instance() );
    mDock->setAllowedAreas( Qt::BottomDockWidgetArea | Qt::TopDockWidgetArea );
    mDock->setWidget( this );
    connect( this, SIGNAL( destroyed() ), mDock, SLOT( close() ) );
    QgisApp::instance()->addDockWidget( Qt::BottomDockWidgetArea, mDock );
  }

  updateTitle();

  mRemoveSelectionButton->setIcon( QgisApp::getThemeIcon( "/mActionUnselectAttributes.png" ) );
  mSelectedToTopButton->setIcon( QgisApp::getThemeIcon( "/mActionSelectedToTop.png" ) );
  mCopySelectedRowsButton->setIcon( QgisApp::getThemeIcon( "/mActionCopySelected.png" ) );
  mZoomMapToSelectedRowsButton->setIcon( QgisApp::getThemeIcon( "/mActionZoomToSelected.png" ) );
  mPanMapToSelectedRowsButton->setIcon( QgisApp::getThemeIcon( "/mActionPanToSelected.png" ) );
  mInvertSelectionButton->setIcon( QgisApp::getThemeIcon( "/mActionInvertSelection.png" ) );
  mToggleEditingButton->setIcon( QgisApp::getThemeIcon( "/mActionToggleEditing.png" ) );
  mSaveEditsButton->setIcon( QgisApp::getThemeIcon( "/mActionSaveEdits.png" ) );
  mDeleteSelectedButton->setIcon( QgisApp::getThemeIcon( "/mActionDeleteSelected.png" ) );
  mOpenFieldCalculator->setIcon( QgisApp::getThemeIcon( "/mActionCalculateField.png" ) );
  mAddAttribute->setIcon( QgisApp::getThemeIcon( "/mActionNewAttribute.png" ) );
  mRemoveAttribute->setIcon( QgisApp::getThemeIcon( "/mActionDeleteAttribute.png" ) );

  // toggle editing
  bool canChangeAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
  bool canDeleteFeatures = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteFeatures;
  bool canAddAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes;
  bool canDeleteAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteAttributes;
  bool canAddFeatures = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddFeatures;

  mToggleEditingButton->setCheckable( true );
  mToggleEditingButton->setChecked( mLayer->isEditable() );
  mToggleEditingButton->setEnabled( canChangeAttributes && !mLayer->isReadOnly() );

  mSaveEditsButton->setEnabled( canChangeAttributes && mLayer->isEditable() );
  mOpenFieldCalculator->setEnabled( canChangeAttributes && mLayer->isEditable() );
  mDeleteSelectedButton->setEnabled( canDeleteFeatures && mLayer->isEditable() );
  mAddAttribute->setEnabled( canAddAttributes && mLayer->isEditable() );
  mRemoveAttribute->setEnabled( canDeleteAttributes && mLayer->isEditable() );
  mAddFeature->setEnabled( canAddFeatures && mLayer->isEditable() && mLayer->geometryType() == QGis::NoGeometry );
  mAddFeature->setHidden( !canAddFeatures || mLayer->geometryType() != QGis::NoGeometry );

  // info from table to application
  connect( this, SIGNAL( editingToggled( QgsMapLayer * ) ), QgisApp::instance(), SLOT( toggleEditing( QgsMapLayer * ) ) );
  connect( this, SIGNAL( saveEdits( QgsMapLayer * ) ), QgisApp::instance(), SLOT( saveEdits( QgsMapLayer * ) ) );

  // info from layer to table
  connect( mLayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
  connect( mLayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
  connect( mLayer, SIGNAL( selectionChanged() ), this, SLOT( updateSelectionFromLayer() ) );
  connect( mLayer, SIGNAL( layerDeleted() ), this, SLOT( close() ) );

  connect( searchButton, SIGNAL( clicked() ), this, SLOT( search() ) );
  connect( mAddFeature, SIGNAL( clicked() ), this, SLOT( addFeature() ) );

  connect( mView->verticalHeader(), SIGNAL( sectionClicked( int ) ), this, SLOT( updateRowSelection( int ) ) );
  connect( mView->verticalHeader(), SIGNAL( sectionPressed( int ) ), this, SLOT( updateRowPressed( int ) ) );

  connect( mModel, SIGNAL( modelChanged() ), this, SLOT( updateSelection() ) );

  connect( mView, SIGNAL( willShowContextMenu( QMenu*, QModelIndex ) ), this, SLOT( viewWillShowContextMenu( QMenu*, QModelIndex ) ) );

  mLastClickedHeaderIndex = 0;
  mSelectionModel = new QItemSelectionModel( mFilterModel, this );
  updateSelectionFromLayer();

  //make sure to show all recs on first load
  on_cbxShowSelectedOnly_toggled( false );
}
/* Constructor setups the GUI. */
QucsTranscalc::QucsTranscalc() {
    
  QWidget *centralWidget = new QWidget(this);  
  setCentralWidget(centralWidget);
  
  // set application icon
  setWindowIcon(QPixmap(":/bitmaps/big.qucs.xpm"));
  setWindowTitle("Qucs Transcalc " PACKAGE_VERSION);

  // create file menu
  QMenu *fileMenu = new QMenu(tr("&File"));

  QAction *fileLoad = new QAction(tr("&Load"), this);
  fileLoad->setShortcut(Qt::CTRL+Qt::Key_L);
  fileMenu->addAction(fileLoad);
  connect(fileLoad, SIGNAL(activated()), SLOT(slotFileLoad()));

  QAction *fileSave = new QAction (tr("&Save"), this);
  fileSave->setShortcut(Qt::CTRL+Qt::Key_S);
  fileMenu->addAction(fileSave);
  connect(fileSave, SIGNAL(activated()), SLOT(slotFileSave()));

  fileMenu->addSeparator();

  QAction *fileOption = new QAction (tr("&Options"), this);
  fileOption->setShortcut(Qt::CTRL+Qt::Key_O);
  fileMenu->addAction(fileOption);
  connect(fileOption, SIGNAL(activated()), SLOT(slotOptions()));

  fileMenu->addSeparator();

  QAction *fileQuit = new QAction (tr("&Quit"), this);
  fileQuit->setShortcut(Qt::CTRL+Qt::Key_Q);
  fileMenu->addAction(fileQuit);
  connect(fileQuit, SIGNAL(activated()), SLOT(slotQuit()));

  // create execute menu
  QMenu *execMenu = new QMenu(tr("&Execute"));

  QAction *execCopy = new QAction(tr("&Copy to Clipboard"), this);
  execCopy->setShortcut(Qt::Key_F2);
  execMenu->addAction(execCopy);
  connect(execCopy, SIGNAL(activated()), SLOT(slotCopyToClipBoard()));

  QAction *execAnalyze = new QAction(tr("&Analyze"), this);
  execAnalyze->setShortcut(Qt::Key_F3);
  execMenu->addAction(execAnalyze);
  connect(execAnalyze, SIGNAL(activated()), SLOT(slotAnalyze()));

  QAction *execSynthesize = new QAction (tr("&Synthesize"), this);
  execSynthesize->setShortcut(Qt::Key_F4);
  execMenu->addAction(execSynthesize);
  connect(execSynthesize, SIGNAL(activated()), SLOT(slotSynthesize()));

  // create help menu
  QMenu *helpMenu = new QMenu(tr("&Help"));
  QAction *helpHelp = new QAction(tr("&Help"), this);
  helpHelp->setShortcut(Qt::Key_F1);
  helpMenu->addAction(helpHelp);
  connect(helpHelp, SIGNAL(activated()), SLOT(slotHelpIntro()));

  QAction *helpAbout = new QAction(tr("About"), this);
  helpMenu->addAction(helpAbout);
  connect(helpAbout, SIGNAL(activated()), SLOT(slotAbout()));

  // setup menu bar
  menuBar()->addMenu(fileMenu);
  menuBar()->addMenu(execMenu);
  menuBar()->addSeparator();
  menuBar()->addMenu(helpMenu);

  // === left
  // seletion combo and figure
  QVBoxLayout *vl = new QVBoxLayout();

  // transmission line type choice
  QGroupBox * lineGroup = new QGroupBox (tr("Transmission Line Type"));
  tranType = new QComboBox (lineGroup);
  tranType->insertItem (0, tr("Microstrip Line"));
  tranType->insertItem (1, tr("Coplanar Waveguide"));
  tranType->insertItem (2, tr("Grounded Coplanar"));
  tranType->insertItem (3, tr("Rectangular Waveguide"));
  tranType->insertItem (4, tr("Coaxial Line"));
  tranType->insertItem (5, tr("Coupled Microstrip"));
  connect(tranType, SIGNAL(activated(int)), SLOT(slotSelectType(int)));
  // setup transmission line picture
  pix = new QLabel (lineGroup);
  pix->setPixmap(QPixmap(":/bitmaps/microstrip.png"));

  QVBoxLayout *vfig = new QVBoxLayout();
  vfig->addWidget(tranType);
  vfig->addWidget(pix);
  vfig->setSpacing(3);
  lineGroup->setLayout(vfig);

  vl->addWidget(lineGroup);

  // init additional translations
  setupTranslations ();

  // set current mode
  mode = ModeMicrostrip;

  // === middle
  QVBoxLayout *vm = new QVBoxLayout();
  vm->setSpacing (3);

  // substrate parameter box
  QGroupBox * substrate = new QGroupBox (tr("Substrate Parameters"));
  vm->addWidget(substrate);

  // Pass the GroupBox > create Grid layout > Add widgets > set layout
  createPropItems (substrate, TRANS_SUBSTRATE);

  // component parameter box
  QGroupBox * component = new QGroupBox (tr("Component Parameters"));
  vm->addWidget(component);
  createPropItems (component, TRANS_COMPONENT);


  // === right
  QVBoxLayout *vr = new QVBoxLayout();
  vr->setSpacing (3);

  // physical parameter box
  QGroupBox * physical = new QGroupBox (tr("Physical Parameters"));
  vr->addWidget(physical);
  createPropItems (physical, TRANS_PHYSICAL);

  // analyze/synthesize buttons
  QHBoxLayout * h2 = new QHBoxLayout();
  QPushButton * analyze = new QPushButton (tr("Analyze"));
  h2->addWidget(analyze);
  analyze->setToolTip(tr("Derive Electrical Parameters"));
  connect(analyze, SIGNAL(clicked()), SLOT(slotAnalyze()));

  QPushButton * synthesize = new QPushButton (tr("Synthesize"));
  h2->addWidget(synthesize);
  synthesize->setToolTip(tr("Compute Physical Parameters"));
  connect(synthesize, SIGNAL(clicked()), SLOT(slotSynthesize()));
  vr->addLayout(h2);

  // electrical parameter box
  QGroupBox * electrical = new QGroupBox (tr("Electrical Parameters"));
  vr->addWidget(electrical);
  createPropItems (electrical, TRANS_ELECTRICAL);

  calculated = new QGroupBox (tr("Calculated Results"));
  vr->addWidget(calculated);

  // status line
  //statBar = new QStatusBar (this);
  //QLabel * statText = new QLabel ("Ready.", statBar);
  statusBar()->showMessage (tr("Ready."));
  //statBar->setFixedHeight (statText->height ());
  //delete statText;

  QVBoxLayout *vmain = new QVBoxLayout();

  QHBoxLayout *hmain = new QHBoxLayout();
  hmain->addLayout(vl);
  hmain->addLayout(vm);
  hmain->addLayout(vr);

  vmain->addLayout(hmain);
  //vmain->addWidget(statBar);
  
  centralWidget->setLayout(vmain);
  
  // setup calculated result bix
  createResultItems (calculated);
  updateSelection ();

  // instantiate transmission lines
  TransLineTypes[0].line = new microstrip ();
  TransLineTypes[0].line->setApplication (this);
  TransLineTypes[1].line = new coplanar ();
  TransLineTypes[1].line->setApplication (this);
  TransLineTypes[2].line = new groundedCoplanar ();
  TransLineTypes[2].line->setApplication (this);
  TransLineTypes[3].line = new rectwaveguide ();
  TransLineTypes[3].line->setApplication (this);
  TransLineTypes[4].line = new coax ();
  TransLineTypes[4].line->setApplication (this);
  TransLineTypes[5].line = new c_microstrip ();
  TransLineTypes[5].line->setApplication (this);
}
Exemple #7
0
void EventCanvas::viewMousePressEvent(QMouseEvent* event)/*{{{*/
{
    ///keyState = event->state();
    _keyState = ((QInputEvent*) event)->modifiers();
    _button = event->button();

    //printf("viewMousePressEvent buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button());

    // special events if right button is clicked while operations
    // like moving or drawing lasso is performed.
    if (event->buttons() & Qt::RightButton & ~(event->button()))
    {
        //printf("viewMousePressEvent special buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button());
        switch (_drag)
        {
        case DRAG_LASSO:
            _drag = DRAG_OFF;
            redraw();
            return;
        case DRAG_MOVE:
            _drag = DRAG_OFF;
            endMoveItems(_start, MOVE_MOVE, 0);
            return;
        default:
            break;
        }
    }

    // ignore event if (another) button is already active:
    if (event->buttons() & (Qt::LeftButton | Qt::RightButton | Qt::MidButton) & ~(event->button()))
    {
        //printf("viewMousePressEvent ignoring buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button());
        return;
    }
    bool shift = _keyState & Qt::ShiftModifier;
    bool alt = _keyState & Qt::AltModifier;
    bool ctrl = _keyState & Qt::ControlModifier;
    _start = event->pos();

    //---------------------------------------------------
    //    set curItem to item mouse is pointing
    //    (if any)
    //---------------------------------------------------

    CItemList list = _items;
    if(multiPartSelectionAction && !multiPartSelectionAction->isChecked())
        list = getItemlistForCurrentPart();
    if (virt())
    {
        _curItem = list.find(_start);//_items.find(_start);
    }
    else
    {
        _curItem = 0; //selectAtTick(_start.x());
        iCItem ius;
        bool usfound = false;
        for (iCItem i = list.begin(); i != list.end(); ++i)
        {
            MidiTrack* mtrack = (MidiTrack*)i->second->part()->track();
            int sy = _start.y();
            int p = y2pitch(sy);
            if(editor->isGlobalEdit())
                p += mtrack->getTransposition();
            int p2 = pitch2y(p);
            QPoint lpos(_start.x(), p2);
            QRect box = i->second->bbox();
            int x = rmapxDev(box.x());
            int y = rmapyDev(box.y());
            int w = rmapxDev(box.width());
            int h = rmapyDev(box.height());
            QRect r(x, y, w, h);
            r.translate(i->second->pos().x(), i->second->pos().y());
            if(r.contains(lpos))
            {
                if (i->second->isSelected())
                {
                    _curItem = i->second;
                    break;
                }
                else if (!usfound)
                {
                    ius = i;
                    usfound = true;
                }
            }
        }
        if (!_curItem && usfound)
            _curItem = ius->second;

    }

    if(editor->isGlobalEdit() && _curItem)
    {
        populateMultiSelect(_curItem);
    }

    if (_curItem && (event->button() == Qt::MidButton))
    {
        if (!_curItem->isSelected())
        {
            selectItem(_curItem, true);
            updateSelection();
            redraw();
        }
        startDrag(_curItem, shift);
    }
    else if (event->button() == Qt::RightButton)
    {
        if (_curItem)
        {
            if (shift)
            {
                _drag = DRAG_RESIZE;
                setCursor();
                int dx = _start.x() - _curItem->x();
                _curItem->setWidth(dx);
                _start.setX(_curItem->x());
                deselectAll();
                selectItem(_curItem, true);
                updateSelection();
                redraw();
            }
            else
            {
                _itemPopupMenu = genItemPopup(_curItem);
                if (_itemPopupMenu)
                {
                    QAction *act = _itemPopupMenu->exec(QCursor::pos());
                    if (act)
                        itemPopup(_curItem, act->data().toInt(), _start);
                    delete _itemPopupMenu;
                }
            }
        }
        else
        {
            _canvasPopupMenu = genCanvasPopup(true);
            if (_canvasPopupMenu)
            {
                QAction *act = _canvasPopupMenu->exec(QCursor::pos(), 0);
                if (act)
                {
                    int actnum = act->data().toInt();
                    canvasPopup(actnum);
                    if(actnum >= 20) //Nome of the tools have a higher number than 9
                    {
                        editor->updateCanvas();
                        los->arranger->updateCanvas();
                    }
                }
                delete _canvasPopupMenu;
            }
        }
    }
    else if (event->button() == Qt::LeftButton)
    {
        switch (_tool)
        {
        case PointerTool:
            if (_curItem)
            {
                /*if (_curItem->part() != _curPart)
                {
                    _curPart = _curItem->part();
                    _curPartId = _curPart->sn();
                    curPartChanged();
                }*/
                itemPressed(_curItem);
                if (shift)
                    _drag = DRAG_COPY_START;
                else if (alt)
                {
                    _drag = DRAG_CLONE_START;
                }
                else if (ctrl)
                { //Select all on the same pitch (e.g. same y-value)
                    deselectAll();
                    //printf("Yes, ctrl and press\n");
                    for (iCItem i = _items.begin(); i != _items.end(); ++i)
                    {
                        if (i->second->y() == _curItem->y())
                            selectItem(i->second, true);
                    }
                    updateSelection();
                    redraw();
                }
                else
                    _drag = DRAG_MOVE_START;
            }
            else
                _drag = DRAG_LASSO_START;
            setCursor();
            break;

            case RubberTool:
            deleteItem(_start);
            _drag = DRAG_DELETE;
            setCursor();
            break;

            case PencilTool:
            if (_curItem)
            {
                _drag = DRAG_RESIZE;
                setCursor();
                int dx = _start.x() - _curItem->x();
                _curItem->setWidth(dx);
                _start.setX(_curItem->x());
            }
            else
            {
                _drag = DRAG_NEW;
                setCursor();
                _curItem = newItem(_start, event->modifiers());
                if (_curItem)
                    _items.add(_curItem);
                else
                {
                    _drag = DRAG_OFF;
                    setCursor();
                }
            }
            deselectAll();
            if (_curItem)
            {
                selectItem(_curItem, true);
                // Play the note
                itemPressed(_curItem);
            }
            updateSelection();
            redraw();
            break;

            default:
            break;
        }
    }
    mousePress(event);
}/*}}}*/
/* bShowChannelList default to true, returns new bouquet or -1/-2 */
int CBouquetList::show(bool bShowChannelList)
{
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;
	int res = CHANLIST_CANCEL;
	int icol_w, icol_h;
	int w_max_text = 0;
	int w_max_icon = 0;
	int h_max_icon = 0;
	favonly = !bShowChannelList;

	for (unsigned int count = 0; count < sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]); count++)
	{
		int w_text = g_Font[SNeutrinoSettings::FONT_TYPE_BUTTON_TEXT]->getRenderWidth(g_Locale->getText(CBouquetListButtons[count].locale));
		w_max_text = std::max(w_max_text, w_text);
		frameBuffer->getIconSize(CBouquetListButtons[count].button, &icol_w, &icol_h);
		w_max_icon = std::max(w_max_icon, icol_w);
		h_max_icon = std::max(h_max_icon, icol_h);
	}

	item_height = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight();

	/*
	   We align width to needed footer space,
	   but this manual calculation isn't a good idea.
	   It would be better to get the needed width from
	   CComponententsFooter class.
	*/
	width  = (sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]))*(w_max_icon + w_max_text + 2*OFFSET_INNER_MID);
	height = 16*item_height;

	header_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	footer_height = header_height;
	listmaxshow = (height - header_height - footer_height)/item_height;
	height      = header_height + footer_height + listmaxshow*item_height; // recalc height

	x = getScreenStartX(width);
	y = getScreenStartY(height);

	int lmaxpos= 1;
	int i= Bouquets.size();
	while ((i= i/10)!=0)
		lmaxpos++;

	CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, "");

	COSDFader fader(g_settings.theme.menu_Content_alpha);
	fader.StartFadeIn();

	paintHead();
	paint();
	frameBuffer->blit();

	int oldselected = selected;
	int firstselected = selected+ 1;
	int zapOnExit = false;

	unsigned int chn= 0;
	int pos= lmaxpos;

	uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]);

	bool loop=true;
	while (loop) {
		g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );

		if ( msg <= CRCInput::RC_MaxRC )
			timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]);

		if((msg == NeutrinoMessages::EVT_TIMER) && (data == fader.GetFadeTimer())) {
			if(fader.FadeDone())
				loop = false;
		}
		else if ((msg == CRCInput::RC_timeout                             ) ||
				(msg == (neutrino_msg_t)g_settings.key_channelList_cancel) ||
				((msg == CRCInput::RC_favorites) && (CNeutrinoApp::getInstance()->GetChannelMode() == LIST_MODE_FAV)))
		{
			selected = oldselected;
			if(fader.StartFadeOut()) {
				timeoutEnd = CRCInput::calcTimeoutEnd(1);
				msg = 0;
			} else
				loop=false;
		}
		else if(msg == CRCInput::RC_red || msg == CRCInput::RC_favorites) {
			if (!favonly && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_FAV) {
				CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_FAV);
				hide();
				return CHANLIST_CHANGE_MODE;
			}
		} else if(msg == CRCInput::RC_green) {
			if (!favonly && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_PROV) {
				CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_PROV);
				hide();
				return CHANLIST_CHANGE_MODE;
			}
		} else if(msg == CRCInput::RC_yellow || msg == CRCInput::RC_sat) {
			if(!favonly && bShowChannelList && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_SAT) {
				CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_SAT);
				hide();
				return CHANLIST_CHANGE_MODE;
			}
		} else if(msg == CRCInput::RC_blue) {
			if(!favonly && bShowChannelList && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_ALL) {
				CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_ALL);
				hide();
				return CHANLIST_CHANGE_MODE;
			}
		} else if(msg == CRCInput::RC_www) {
			if(!favonly && bShowChannelList && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_WEBTV) {
				CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_WEBTV);
				hide();
				return CHANLIST_CHANGE_MODE;
			}
		}
		else if ( msg == CRCInput::RC_setup) {
			if (!favonly && !Bouquets.empty()) {
				int ret = doMenu();
				if(ret > 0) {
					res = CHANLIST_NO_RESTORE;
					loop = false;
				} else if(ret < 0) {
					paintHead();
					paint();
				}
			}
		}
		else if ( msg == (neutrino_msg_t) g_settings.key_list_start ) {
			if (!Bouquets.empty())
				updateSelection(0);
		}
		else if ( msg == (neutrino_msg_t) g_settings.key_list_end ) {
			if (!Bouquets.empty())
				updateSelection(Bouquets.size()-1);
		}
		else if (msg == CRCInput::RC_up || (int) msg == g_settings.key_pageup ||
			 msg == CRCInput::RC_down || (int) msg == g_settings.key_pagedown)
		{
			int new_selected = UpDownKey(Bouquets, msg, listmaxshow, selected);
			updateSelection(new_selected);
		}
		else if(msg == (neutrino_msg_t)g_settings.key_bouquet_up || msg == (neutrino_msg_t)g_settings.key_bouquet_down) {
			if(bShowChannelList) {
				int mode = CNeutrinoApp::getInstance()->GetChannelMode();
				mode += (msg == (neutrino_msg_t)g_settings.key_bouquet_down) ? -1 : 1;
				if(mode < 0)
					mode = LIST_MODE_LAST - 1;
				else if(mode >= LIST_MODE_LAST)
					mode = 0;
				CNeutrinoApp::getInstance()->SetChannelMode(mode);
				hide();
				return CHANLIST_CHANGE_MODE;
			}
		}
		else if ( msg == CRCInput::RC_ok ) {
			if(!Bouquets.empty() /* && (!bShowChannelList || !Bouquets[selected]->channelList->isEmpty())*/) {
				zapOnExit = true;
				loop=false;
			}
		}
		else if (CRCInput::isNumeric(msg)) {
			if (!Bouquets.empty()) {
				if (pos == lmaxpos) {
					if (msg == CRCInput::RC_0) {
						chn = firstselected;
						pos = lmaxpos;
					} else {
						chn = CRCInput::getNumericValue(msg);
						pos = 1;
					}
				} else {
					chn = chn*10 + CRCInput::getNumericValue(msg);
					pos++;
				}

				if (chn > Bouquets.size()) {
					chn = firstselected;
					pos = lmaxpos;
				}

				int new_selected = (chn - 1) % Bouquets.size(); // is % necessary (i.e. can firstselected be > Bouquets.size()) ?
				updateSelection(new_selected);
			}
		} else if (msg == NeutrinoMessages::EVT_SERVICESCHANGED || msg == NeutrinoMessages::EVT_BOUQUETSCHANGED) {
			g_RCInput->postMsg(msg, data);
			loop = false;
			res = CHANLIST_CANCEL_ALL;
		} else {
			if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) {
				loop = false;
				res = CHANLIST_CANCEL_ALL;
			}
		}
		frameBuffer->blit();
	}
	hide();

	fader.StopFade();

	CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);

	if (save_bouquets) {
		save_bouquets = false;
#if 0
		if (CNeutrinoApp::getInstance()->GetChannelMode() == LIST_MODE_FAV)
			g_bouquetManager->saveUBouquets();
		else
			g_bouquetManager->saveBouquets();
#endif
		if (g_settings.epg_scan == CEpgScan::SCAN_SEL)
			CEpgScan::getInstance()->Start();
	}

	if (zapOnExit)
		return (selected);

	return (res);
}
Exemple #9
0
	void Active::setPermanentSelection(bool permanentInSelection)
	{
		m_isSelectCopy = permanentInSelection;
		m_isSelect = permanentInSelection;
		updateSelection();
	}
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc) :
    m_buildConfiguration(bc),
    m_configModel(new ConfigModel(this)),
    m_configFilterModel(new Utils::CategorySortFilterModel),
    m_configTextFilterModel(new Utils::CategorySortFilterModel)
{
    QTC_CHECK(bc);

    setDisplayName(tr("CMake"));

    auto vbox = new QVBoxLayout(this);
    vbox->setMargin(0);
    auto container = new Utils::DetailsWidget;
    container->setState(Utils::DetailsWidget::NoSummary);
    vbox->addWidget(container);

    auto details = new QWidget(container);
    container->setWidget(details);

    auto mainLayout = new QGridLayout(details);
    mainLayout->setMargin(0);
    mainLayout->setColumnStretch(1, 10);

    auto project = static_cast<CMakeProject *>(bc->project());

    auto buildDirChooser = new Utils::PathChooser;
    buildDirChooser->setBaseFileName(project->projectDirectory());
    buildDirChooser->setFileName(bc->buildDirectory());
    connect(buildDirChooser, &Utils::PathChooser::rawPathChanged, this,
            [this](const QString &path) {
                m_configModel->flush(); // clear out config cache...
                m_buildConfiguration->setBuildDirectory(Utils::FileName::fromString(path));
            });

    int row = 0;
    mainLayout->addWidget(new QLabel(tr("Build directory:")), row, 0);
    mainLayout->addWidget(buildDirChooser->lineEdit(), row, 1);
    mainLayout->addWidget(buildDirChooser->buttonAtIndex(0), row, 2);

    ++row;
    mainLayout->addItem(new QSpacerItem(20, 10), row, 0);

    ++row;
    m_errorLabel = new QLabel;
    m_errorLabel->setPixmap(Utils::Icons::CRITICAL.pixmap());
    m_errorLabel->setVisible(false);
    m_errorMessageLabel = new QLabel;
    m_errorMessageLabel->setVisible(false);
    auto boxLayout = new QHBoxLayout;
    boxLayout->addWidget(m_errorLabel);
    boxLayout->addWidget(m_errorMessageLabel);
    mainLayout->addLayout(boxLayout, row, 0, 1, 3, Qt::AlignHCenter);

    ++row;
    m_warningLabel = new QLabel;
    m_warningLabel->setPixmap(Utils::Icons::WARNING.pixmap());
    m_warningLabel->setVisible(false);
    m_warningMessageLabel = new QLabel;
    m_warningMessageLabel->setVisible(false);
    auto boxLayout2 = new QHBoxLayout;
    boxLayout2->addWidget(m_warningLabel);
    boxLayout2->addWidget(m_warningMessageLabel);
    mainLayout->addLayout(boxLayout2, row, 0, 1, 3, Qt::AlignHCenter);

    ++row;
    mainLayout->addItem(new QSpacerItem(20, 10), row, 0);

    ++row;
    m_filterEdit = new Utils::FancyLineEdit;
    m_filterEdit->setPlaceholderText(tr("Filter"));
    m_filterEdit->setFiltering(true);
    mainLayout->addWidget(m_filterEdit, row, 0, 1, 2);

    ++row;
    auto tree = new Utils::TreeView;
    connect(tree, &Utils::TreeView::activated,
            tree, [tree](const QModelIndex &idx) { tree->edit(idx); });
    m_configView = tree;

    m_configView->viewport()->installEventFilter(this);

    m_configFilterModel->setSourceModel(m_configModel);
    m_configFilterModel->setFilterKeyColumn(0);
    m_configFilterModel->setFilterRole(ConfigModel::ItemIsAdvancedRole);
    m_configFilterModel->setFilterFixedString("0");

    m_configTextFilterModel->setSourceModel(m_configFilterModel);
    m_configTextFilterModel->setSortRole(Qt::DisplayRole);
    m_configTextFilterModel->setFilterKeyColumn(-1);
    m_configTextFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);

    connect(m_configTextFilterModel, &QAbstractItemModel::layoutChanged, this, [this]() {
        QModelIndex selectedIdx = m_configView->currentIndex();
        if (selectedIdx.isValid())
            m_configView->scrollTo(selectedIdx);
    });

    m_configView->setModel(m_configTextFilterModel);
    m_configView->setMinimumHeight(300);
    m_configView->setUniformRowHeights(true);
    m_configView->setSortingEnabled(true);
    m_configView->sortByColumn(0, Qt::AscendingOrder);
    auto stretcher = new Utils::HeaderViewStretcher(m_configView->header(), 0);
    m_configView->setSelectionMode(QAbstractItemView::SingleSelection);
    m_configView->setSelectionBehavior(QAbstractItemView::SelectItems);
    m_configView->setFrameShape(QFrame::NoFrame);
    m_configView->setItemDelegate(new ConfigModelItemDelegate(m_buildConfiguration->project()->projectDirectory(),
                                                              m_configView));
    QFrame *findWrapper = Core::ItemViewFind::createSearchableWrapper(m_configView, Core::ItemViewFind::LightColored);
    findWrapper->setFrameStyle(QFrame::StyledPanel);

    m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicatorSize::Large, findWrapper);
    m_progressIndicator->attachToWidget(findWrapper);
    m_progressIndicator->raise();
    m_progressIndicator->hide();
    m_showProgressTimer.setSingleShot(true);
    m_showProgressTimer.setInterval(50); // don't show progress for < 50ms tasks
    connect(&m_showProgressTimer, &QTimer::timeout, [this]() { m_progressIndicator->show(); });

    mainLayout->addWidget(findWrapper, row, 0, 1, 2);

    auto buttonLayout = new QVBoxLayout;
    m_addButton = new QPushButton(tr("&Add"));
    m_addButton->setToolTip(tr("Add a new configuration value."));
    buttonLayout->addWidget(m_addButton);
    {
        m_addButtonMenu = new QMenu;
        m_addButtonMenu->addAction(tr("&Boolean"))->setData(
                    QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::BOOLEAN)));
        m_addButtonMenu->addAction(tr("&String"))->setData(
                    QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::STRING)));
        m_addButtonMenu->addAction(tr("&Directory"))->setData(
                    QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::DIRECTORY)));
        m_addButtonMenu->addAction(tr("&File"))->setData(
                    QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::FILE)));
        m_addButton->setMenu(m_addButtonMenu);
    }
    m_editButton = new QPushButton(tr("&Edit"));
    m_editButton->setToolTip(tr("Edit the current CMake configuration value."));
    buttonLayout->addWidget(m_editButton);
    m_unsetButton = new QPushButton(tr("&Unset"));
    m_unsetButton->setToolTip(tr("Unset a value in the CMake configuration."));
    buttonLayout->addWidget(m_unsetButton);
    m_resetButton = new QPushButton(tr("&Reset"));
    m_resetButton->setToolTip(tr("Reset all unapplied changes."));
    m_resetButton->setEnabled(false);
    buttonLayout->addWidget(m_resetButton);
    buttonLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Fixed, QSizePolicy::Fixed));
    m_showAdvancedCheckBox = new QCheckBox(tr("Advanced"));
    buttonLayout->addWidget(m_showAdvancedCheckBox);
    buttonLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding));

    mainLayout->addLayout(buttonLayout, row, 2);

    connect(m_configView->selectionModel(), &QItemSelectionModel::currentChanged,
            this, &CMakeBuildSettingsWidget::updateSelection);

    ++row;
    m_reconfigureButton = new QPushButton(tr("Apply Configuration Changes"));
    m_reconfigureButton->setEnabled(false);
    mainLayout->addWidget(m_reconfigureButton, row, 0, 1, 3);

    updateAdvancedCheckBox();
    setError(bc->error());
    setWarning(bc->warning());

    connect(project, &ProjectExplorer::Project::parsingStarted, this, [this]() {
        updateButtonState();
        m_configView->setEnabled(false);
        m_showProgressTimer.start();
    });

    if (m_buildConfiguration->isParsing())
        m_showProgressTimer.start();
    else {
        m_configModel->setConfiguration(m_buildConfiguration->configurationFromCMake());
        m_configView->expandAll();
    }

    connect(project, &ProjectExplorer::Project::parsingFinished,
            this, [this, buildDirChooser, stretcher]() {
        m_configModel->setConfiguration(m_buildConfiguration->configurationFromCMake());
        m_configView->expandAll();
        m_configView->setEnabled(true);
        stretcher->stretch();
        updateButtonState();
        buildDirChooser->triggerChanged(); // refresh valid state...
        m_showProgressTimer.stop();
        m_progressIndicator->hide();
    });
    connect(m_buildConfiguration, &CMakeBuildConfiguration::errorOccured,
            this, [this]() {
        m_showProgressTimer.stop();
        m_progressIndicator->hide();
    });
    connect(m_configTextFilterModel, &QAbstractItemModel::modelReset, this, [this, stretcher]() {
        m_configView->expandAll();
        stretcher->stretch();
    });

    connect(m_configModel, &QAbstractItemModel::dataChanged,
            this, &CMakeBuildSettingsWidget::updateButtonState);
    connect(m_configModel, &QAbstractItemModel::modelReset,
            this, &CMakeBuildSettingsWidget::updateButtonState);

    connect(m_showAdvancedCheckBox, &QCheckBox::stateChanged,
            this, &CMakeBuildSettingsWidget::updateAdvancedCheckBox);

    connect(m_filterEdit, &QLineEdit::textChanged,
            m_configTextFilterModel, &QSortFilterProxyModel::setFilterFixedString);

    connect(m_resetButton, &QPushButton::clicked, m_configModel, &ConfigModel::resetAllChanges);
    connect(m_reconfigureButton, &QPushButton::clicked, this, [this]() {
        m_buildConfiguration->setConfigurationForCMake(m_configModel->configurationForCMake());
    });
    connect(m_unsetButton, &QPushButton::clicked, this, [this]() {
        m_configModel->toggleUnsetFlag(mapToSource(m_configView, m_configView->currentIndex()));
    });
    connect(m_editButton, &QPushButton::clicked, this, [this]() {
        QModelIndex idx = m_configView->currentIndex();
        if (idx.column() != 1)
            idx = idx.sibling(idx.row(), 1);
        m_configView->setCurrentIndex(idx);
        m_configView->edit(idx);
    });
    connect(m_addButtonMenu, &QMenu::triggered, this, [this](QAction *action) {
        ConfigModel::DataItem::Type type =
                static_cast<ConfigModel::DataItem::Type>(action->data().value<int>());
        QString value = tr("<UNSET>");
        if (type == ConfigModel::DataItem::BOOLEAN)
            value = QString::fromLatin1("OFF");

        m_configModel->appendConfiguration(tr("<UNSET>"), value, type);
        const Utils::TreeItem *item = m_configModel->findNonRootItem([&value, type](Utils::TreeItem *item) {
                ConfigModel::DataItem dataItem = ConfigModel::dataItemFromIndex(item->index());
                return dataItem.key == tr("<UNSET>") && dataItem.type == type && dataItem.value == value;
        });
        QModelIndex idx = m_configModel->indexForItem(item);
        idx = m_configTextFilterModel->mapFromSource(m_configFilterModel->mapFromSource(idx));
        m_configView->scrollTo(idx);
        m_configView->setCurrentIndex(idx);
        m_configView->edit(idx);
    });

    connect(bc, &CMakeBuildConfiguration::errorOccured, this, &CMakeBuildSettingsWidget::setError);
    connect(bc, &CMakeBuildConfiguration::warningOccured, this, &CMakeBuildSettingsWidget::setWarning);

    updateFromKit();
    connect(m_buildConfiguration->target(), &ProjectExplorer::Target::kitChanged,
            this, &CMakeBuildSettingsWidget::updateFromKit);
    connect(m_buildConfiguration, &CMakeBuildConfiguration::enabledChanged,
            this, [this]() {
        setError(m_buildConfiguration->disabledReason());
        setConfigurationForCMake();
    });
    connect(m_buildConfiguration, &CMakeBuildConfiguration::configurationForCMakeChanged,
            this, [this]() { setConfigurationForCMake(); });

    updateSelection(QModelIndex(), QModelIndex());
}
EffectSelectDialog::EffectSelectDialog( QWidget * _parent ) :
	QDialog( _parent ),
	ui( new Ui::EffectSelectDialog ),
	m_sourceModel(),
	m_model(),
	m_descriptionWidget( NULL )
{
	ui->setupUi( this );

	setWindowIcon( embed::getIconPixmap( "setup_audio" ) );

	// query effects

	EffectKeyList subPluginEffectKeys;

	for (const Plugin::Descriptor* desc: pluginFactory->descriptors(Plugin::Effect))
	{
		if( desc->subPluginFeatures )
		{
			desc->subPluginFeatures->listSubPluginKeys(
				// as iterators are always stated to be not
				// equal with pointers, we dereference the
				// iterator and take the address of the item,
				// so we're on the safe side and the compiler
				// likely will reduce that to just "it"
							desc,
							subPluginEffectKeys );
		}
		else
		{
			m_effectKeys << EffectKey( desc, desc->name );

		}
	}

	m_effectKeys += subPluginEffectKeys;

	// and fill our source model
	m_sourceModel.setHorizontalHeaderItem( 0, new QStandardItem( tr( "Name" ) ) );
	m_sourceModel.setHorizontalHeaderItem( 1, new QStandardItem( tr( "Type" ) ) );
	int row = 0;
	for( EffectKeyList::ConstIterator it = m_effectKeys.begin();
						it != m_effectKeys.end(); ++it )
	{
		QString name;
		QString type;
		if( ( *it ).desc->subPluginFeatures )
		{
			name = ( *it ).name;
			type = ( *it ).desc->displayName;
		}
		else
		{
			name = ( *it ).desc->displayName;
			type = "LMMS";
		}
		m_sourceModel.setItem( row, 0, new QStandardItem( name ) );
		m_sourceModel.setItem( row, 1, new QStandardItem( type ) );
		++row;
	}

	// setup filtering
	m_model.setSourceModel( &m_sourceModel );
	m_model.setFilterCaseSensitivity( Qt::CaseInsensitive );

	connect( ui->filterEdit, SIGNAL( textChanged( const QString & ) ),
				&m_model, SLOT( setFilterFixedString( const QString & ) ) );
	connect( ui->filterEdit, SIGNAL( textChanged( const QString & ) ),
					this, SLOT( updateSelection() ) );
	connect( ui->filterEdit, SIGNAL( textChanged( const QString & ) ),
							SLOT( sortAgain() ) );

	ui->pluginList->setModel( &m_model );

	// setup selection model
	QItemSelectionModel * selectionModel = new QItemSelectionModel( &m_model );
	ui->pluginList->setSelectionModel( selectionModel );
	connect( selectionModel, SIGNAL( currentRowChanged( const QModelIndex &,
														const QModelIndex & ) ),
			SLOT( rowChanged( const QModelIndex &, const QModelIndex & ) ) );
	connect( ui->pluginList, SIGNAL( doubleClicked( const QModelIndex & ) ),
				SLOT( acceptSelection() ) );

	// try to accept current selection when pressing "OK"
	connect( ui->buttonBox, SIGNAL( accepted() ),
				this, SLOT( acceptSelection() ) );

#if QT_VERSION >= 0x050000
#define setResizeMode setSectionResizeMode
#endif
	ui->pluginList->verticalHeader()->setResizeMode(
						QHeaderView::ResizeToContents );
	ui->pluginList->verticalHeader()->hide();
	ui->pluginList->horizontalHeader()->setResizeMode( 0,
							QHeaderView::Stretch );
	ui->pluginList->horizontalHeader()->setResizeMode( 1,
						QHeaderView::ResizeToContents );
	ui->pluginList->sortByColumn( 0, Qt::AscendingOrder );
#if QT_VERSION >= 0x050000
#undef setResizeMode
#endif

	updateSelection();
	show();
}
Exemple #12
0
void IdDialog::insertIdList(uint32_t token)
{
	QTreeWidget *tree = ui.treeWidget_IdList;

	tree->clear();

	std::list<std::string> ids;
	std::list<std::string>::iterator it;

	bool acceptAll = ui.radioButton_ListAll->isChecked();
	bool acceptPseudo = ui.radioButton_ListPseudo->isChecked();
	bool acceptYourself = ui.radioButton_ListYourself->isChecked();
	bool acceptFriends = ui.radioButton_ListFriends->isChecked();
	bool acceptOthers = ui.radioButton_ListOthers->isChecked();

	RsGxsIdGroup data;
	std::vector<RsGxsIdGroup> datavector;
	std::vector<RsGxsIdGroup>::iterator vit;
	if (!rsIdentity->getGroupData(token, datavector))
	{
		std::cerr << "IdDialog::insertIdList() Error getting GroupData";
		std::cerr << std::endl;
		return;
	}

	std::string ownPgpId  = rsPeers->getGPGOwnId();

	for(vit = datavector.begin(); vit != datavector.end(); vit++)
	{
		data = (*vit);

		bool isOwnId  = (data.mPgpKnown && (data.mPgpId == ownPgpId)) ||
			(data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);

		/* do filtering */
		bool ok = false;
		if (acceptAll)
		{
			ok = true;
		}
		else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
		{
			if (isOwnId && acceptYourself)
			{
				ok = true;
			}
			else
			{
				if (data.mPgpKnown)
				{
					if (acceptFriends)
					{
						ok = true;
					}
				}
				else 
				{
					if (acceptOthers)
					{
						ok = true;
					}
				}
			}
		}
		else
		{
 			if (acceptPseudo)
			{
				ok = true;
			}

			if (isOwnId && acceptYourself)
			{
				ok = true;
			}
		}

		if (!ok)
		{
			continue;
		}

		QTreeWidgetItem *item = new QTreeWidgetItem();
		item->setText(RSID_COL_NICKNAME, QString::fromStdString(data.mMeta.mGroupName));
		item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId));
		if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
		{
			if (data.mPgpKnown)
			{
				RsPeerDetails details;
				rsPeers->getGPGDetails(data.mPgpId, details);
				item->setText(RSID_COL_IDTYPE, QString::fromStdString(details.name));
			}
			else
			{
				item->setText(RSID_COL_IDTYPE, "PGP Linked Id");
			}
		}
		else
		{
			item->setText(RSID_COL_IDTYPE, "Anon Id");
		}

                tree->addTopLevelItem(item);
	}

	// fix up buttons.
	updateSelection();
}
Exemple #13
0
int CListBox::exec(CMenuTarget* parent, const std::string &)
{
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;

	int res = menu_return::RETURN_REPAINT;
	selected=0;

	if (parent)
	{
		parent->hide();
	}

	paintHead();
	paint();
	paintFoot();

	bool loop=true;
	modified = false;
	while (loop)
	{
		g_RCInput->getMsg(&msg, &data, g_settings.timing[SNeutrinoSettings::TIMING_EPG]);
		neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat;

		if (msg == g_settings.key_channelList_cancel || msg == CRCInput::RC_home)
		{
			loop = false;
		}
		else if (msg_repeatok == CRCInput::RC_up || msg_repeatok == g_settings.key_channelList_pageup)
		{
			int itemCount = getItemCount();
			if (itemCount > 0)
			{
				int step = (msg_repeatok == g_settings.key_channelList_pageup) ? listmaxshow : 1;  // browse or step 1
				int new_selected = selected - step;
				if (new_selected < 0)
					new_selected = itemCount - 1;
				updateSelection(new_selected);
			}
		}
		else if (msg_repeatok == CRCInput::RC_down || msg_repeatok == g_settings.key_channelList_pagedown)
		{
			unsigned int itemCount = getItemCount();
			if (itemCount > 0)
			{
				unsigned int step = (msg_repeatok == g_settings.key_channelList_pagedown) ? listmaxshow : 1;  // browse or step 1
				unsigned int new_selected = selected + step;
				if (new_selected >= itemCount)
				{
					if ((itemCount / listmaxshow + 1) * listmaxshow == itemCount + listmaxshow) // last page has full entries
						new_selected = 0;
					else
						new_selected = ((step == listmaxshow) && (new_selected < ((itemCount / listmaxshow + 1) * listmaxshow))) ? (itemCount - 1) : 0;
				}
				updateSelection(new_selected);
			}
		}
		else if( msg ==CRCInput::RC_ok)
		{
			onOkKeyPressed();
		}
		else if ( msg ==CRCInput::RC_red)
		{
			onRedKeyPressed();
		}
		else if ( msg ==CRCInput::RC_green)
		{
			onGreenKeyPressed();
		}
		else if ( msg ==CRCInput::RC_yellow)
		{
			onYellowKeyPressed();
		}
		else if ( msg ==CRCInput::RC_blue)
		{
			onBlueKeyPressed();
		}
		else
		{
			CNeutrinoApp::getInstance()->handleMsg( msg, data );
			// kein canceling...
		}
	}

	hide();
	return res;
}
void DocumentWidget::mouseMoveEvent ( QMouseEvent * e )
{
#ifdef DEBUG_DOCUMENTWIDGET
  kdDebug(1223) << "DocumentWidget::mouseMoveEvent(...) called" << endl;
#endif


  // pageNr == 0 indicated an invalid page (e.g. page number not yet
  // set)
  if (pageNr == 0)
    return;

  // Get a pointer to the page contents
  RenderedDocumentPage *pageData = documentCache->getPage(pageNr);
  if (pageData == 0) {
    kdDebug(1223) << "DocumentWidget::selectAll() pageData for page #" << pageNr << " is empty" << endl;
    return;
  }

  // If no mouse button pressed
  if (e->state() == 0) {
    // Remember the index of the underlined link.
    int lastUnderlinedLink = indexOfUnderlinedLink;
    // go through hyperlinks
    for(unsigned int i = 0; i < pageData->hyperLinkList.size(); i++) {
      if (pageData->hyperLinkList[i].box.contains(e->pos())) {
        clearStatusBarTimer.stop();
        setCursor(pointingHandCursor);
        QString link = pageData->hyperLinkList[i].linkText;
        if ( link.startsWith("#") )
          link = link.remove(0,1);

        emit setStatusBarText( i18n("Link to %1").arg(link) );

        indexOfUnderlinedLink = i;
        if (KVSPrefs::underlineLinks() == KVSPrefs::EnumUnderlineLinks::OnlyOnHover &&
            indexOfUnderlinedLink != lastUnderlinedLink)
        {
          QRect newUnderline = pageData->hyperLinkList[i].box;
          // Increase Rectangle so that the whole line really lines in it.
          newUnderline.addCoords(0, 0, 0, 2);
          // Redraw widget
          update(newUnderline);

          if (lastUnderlinedLink != -1 && lastUnderlinedLink < pageData->hyperLinkList.size())
          {
            // Erase old underline
            QRect oldUnderline = pageData->hyperLinkList[lastUnderlinedLink].box;
            oldUnderline.addCoords(0, 0, 0, 2);
            update(oldUnderline);
          }
        }
        return;
      }
    }
    // Whenever we reach this the mouse hovers no link.
    indexOfUnderlinedLink = -1;
    if (KVSPrefs::underlineLinks() == KVSPrefs::EnumUnderlineLinks::OnlyOnHover &&
        lastUnderlinedLink != -1 && lastUnderlinedLink < pageData->hyperLinkList.size())
    {
      // Erase old underline
      QRect oldUnderline = pageData->hyperLinkList[lastUnderlinedLink].box;
      // Increase Rectangle so that the whole line really lines in it.
      oldUnderline.addCoords(0, 0, 0, 2);
      // Redraw widget
      update(oldUnderline);
    }
    // Cursor not over hyperlink? Then let the cursor be the usual arrow if we use the move tool, and
    // The textselection cursor if we use the selection tool.
    setStandardCursor();
  }

  if (!clearStatusBarTimer.isActive())
    clearStatusBarTimer.start(200, true); // clear the statusbar after 200 msec.

  // Left mouse button pressed -> Text scroll function
  if ((e->state() & LeftButton) != 0 && moveTool)
  {
    // Pass the mouse event on to the owner of this widget ---under
    // normal circumstances that is the centeringScrollView which will
    // then scroll the scrollview contents
    e->ignore();
  }

  // Right mouse button pressed -> Text copy function
  if ((e->state() & RightButton) != 0 || (!moveTool && (e->state() & LeftButton != 0)))
  {
    if (selectedRectangle.isEmpty()) {
      firstSelectedPoint = e->pos();
      selectedRectangle.setRect(e->pos().x(),e->pos().y(),1,1);
    } else {
      int lx = e->pos().x() < firstSelectedPoint.x() ? e->pos().x() : firstSelectedPoint.x();
      int rx = e->pos().x() > firstSelectedPoint.x() ? e->pos().x() : firstSelectedPoint.x();
      int ty = e->pos().y() < firstSelectedPoint.y() ? e->pos().y() : firstSelectedPoint.y();
      int by = e->pos().y() > firstSelectedPoint.y() ? e->pos().y() : firstSelectedPoint.y();
      selectedRectangle.setCoords(lx,ty,rx,by);
    }

    // Now that we know the rectangle, we have to find out which words
    // intersect it!
    TextSelection newTextSelection = pageData->select(selectedRectangle);

    updateSelection(newTextSelection);
  }
}
Exemple #15
0
void MembersBox::Inner::mouseMoveEvent(QMouseEvent *e) {
	_mouseSelection = true;
	_lastMousePos = e->globalPos();
	updateSelection();
}
Exemple #16
0
void ControlRuler::updateSegment()
{
    // Bring the segment up to date with the ControlRuler's items
    // A number of different actions take place here:
    // 1) m_eventSelection is empty
    // 2) m_eventSelection has events
    //      a) Events in the selection have been modified in value only
    //      b) Events in the selection have moved in time
    //
    // Either run through the ruler's EventSelection, updating from each item
    //  or, if there isn't one, go through m_selectedItems
    timeT start,end;
    // bool segmentModified = false;

    QString commandLabel = "Adjust control/property";

    MacroCommand *macro = new MacroCommand(commandLabel);

    // Find the extent of the selected items
    float xmin=FLT_MAX,xmax=-1.0;

    // EventSelection::addEvent adds timeT(1) to its extentt for zero duration events so need to mimic this here
    timeT durationAdd = 0;

    for (ControlItemList::iterator it = m_selectedItems.begin(); it != m_selectedItems.end(); ++it) {
        if ((*it)->xStart() < xmin) xmin = (*it)->xStart();
        if ((*it)->xEnd() > xmax) {
            xmax = (*it)->xEnd();
            if ((*it)->xEnd() == (*it)->xStart())
                durationAdd = 1;
            else
                durationAdd = 0;
        }
    }

    start = getRulerScale()->getTimeForX(xmin);
    end = getRulerScale()->getTimeForX(xmax)+durationAdd;

    if (m_eventSelection->getAddedEvents() == 0) {
        // We do not have a valid set of selected events to update
        if (m_selectedItems.size() == 0) {
            // There are no selected items, nothing to update
            return;
        }

        // Events will be added by the controlItem->updateSegment methods
        commandLabel = "Add control";
        macro->setName(commandLabel);

        // segmentModified = true;
    } else {
        // Check for movement in time here and delete events if necessary
        if (start != m_eventSelection->getStartTime() || end != m_eventSelection->getEndTime()) {
            commandLabel = "Move control";
            macro->setName(commandLabel);

            // Get the limits of the change for undo
            start = std::min(start,m_eventSelection->getStartTime());
            end = std::max(end,m_eventSelection->getEndTime());

            // segmentModified = true;
        }
    }

    // Add change command to macro
    // ControlChangeCommand calls each selected items updateSegment method
    // Note that updateSegment deletes and renews the event whether it has moved or not
    macro->addCommand(new ControlChangeCommand(m_selectedItems,
                                    *m_segment,
                                    start,
                                    end));

    CommandHistory::getInstance()->addCommand(macro);

    updateSelection();
}
Exemple #17
0
void MembersBox::Inner::clearSel() {
	updateSelectedRow();
	_selected = _kickSelected = -1;
	_lastMousePos = QCursor::pos();
	updateSelection();
}
Exemple #18
0
void FindDialog::setListItemEnabled() {
	SearchList->setSelected (0, true);
	if (!SearchList->isSelected (0))
		updateSelection (0);
}
void MyIconView::focus(){
    is_focused = true;
    setStyleSheet(focused_list_style);
    updateSelection();
}
Exemple #20
0
void IdDialog::insertIdList(uint32_t token)
{
	mStateHelper->setLoading(IDDIALOG_IDLIST, false);

	int accept = ui.filterComboBox->itemData(ui.filterComboBox->currentIndex()).toInt();

	RsGxsIdGroup data;
	std::vector<RsGxsIdGroup> datavector;
	std::vector<RsGxsIdGroup>::iterator vit;
	if (!rsIdentity->getGroupData(token, datavector))
	{
		std::cerr << "IdDialog::insertIdList() Error getting GroupData";
		std::cerr << std::endl;

		mStateHelper->setLoading(IDDIALOG_IDDETAILS, false);
		mStateHelper->setLoading(IDDIALOG_REPLIST, false);
		mStateHelper->setActive(IDDIALOG_IDLIST, false);
		mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
		mStateHelper->setActive(IDDIALOG_REPLIST, false);
		mStateHelper->clear(IDDIALOG_IDLIST);
		mStateHelper->clear(IDDIALOG_IDDETAILS);
		mStateHelper->clear(IDDIALOG_REPLIST);

		return;
}

	mStateHelper->setActive(IDDIALOG_IDLIST, true);

	std::string ownPgpId  = rsPeers->getGPGOwnId();

	/* Update existing and remove not existing items */
	QTreeWidgetItemIterator itemIterator(ui.treeWidget_IdList);
	QTreeWidgetItem *item = NULL;
	while ((item = *itemIterator) != NULL) {
		itemIterator++;

		for (vit = datavector.begin(); vit != datavector.end(); ++vit)
		{
			if (vit->mMeta.mGroupId == item->text(RSID_COL_KEYID).toStdString())
			{
				break;
			}
		}
		if (vit == datavector.end())
		{
			delete(item);
		} else {
			if (!fillIdListItem(*vit, item, ownPgpId, accept))
			{
				delete(item);
			}
			datavector.erase(vit);
		}
	}

	/* Insert new items */
	for (vit = datavector.begin(); vit != datavector.end(); ++vit)
	{
		data = (*vit);

		item = NULL;
		if (fillIdListItem(*vit, item, ownPgpId, accept))
		{
			ui.treeWidget_IdList->addTopLevelItem(item);
		}
	}

	filterIds();

	// fix up buttons.
	updateSelection();
}
Exemple #21
0
void EventCanvas::actionCommand(int action)/*{{{*/
{
    switch(action)
    {
        case LOCATORS_TO_SELECTION:
        {
            int tick_max = 0;
            int tick_min = INT_MAX;
            bool found = false;

            for (iCItem i = _items.begin(); i != _items.end(); i++)
            {
                if (!i->second->isSelected())
                    continue;

                int tick = i->second->x();
                int len = i->second->event().lenTick();
                found = true;
                if (tick + len > tick_max)
                    tick_max = tick + len;
                if (tick < tick_min)
                    tick_min = tick;
            }
            if (found)
            {
                Pos p1(tick_min, true);
                Pos p2(tick_max, true);
                song->setPos(1, p1);
                song->setPos(2, p2);
            }
        }
        break;
        case  SEL_RIGHT ... SEL_RIGHT_ADD:
        {
            if (action == SEL_RIGHT && allItemsAreSelected())
            {
                deselectAll();
                selectAtTick(song->cpos());
                return;
            }

            iCItem i, iRightmost;
            CItem* rightmost = NULL;

            // get a list of items that belong to the current part
            // since multiple parts have populated the _items list
            // we need to filter on the actual current Part!
            CItemList list = _items;
            if(multiPartSelectionAction && !multiPartSelectionAction->isChecked())
                list = getItemlistForCurrentPart();

            //Get the rightmost selected note (if any)
            i = list.begin();
            while (i != list.end())
            {
                if (i->second->isSelected())
                {
                    iRightmost = i;
                    rightmost = i->second;
                }

                ++i;
            }
            if (rightmost)
            {
                iCItem temp = iRightmost;
                temp++;
                //If so, deselect current note and select the one to the right
                if (temp != list.end())
                {
                    if (action != SEL_RIGHT_ADD)
                        deselectAll();

                    iRightmost++;
                    iRightmost->second->setSelected(true);
                    itemPressed(iRightmost->second);
                    m_tempPlayItems.append(iRightmost->second);
                    QTimer::singleShot(NOTE_PLAY_TIME, this, SLOT(playReleaseForItem()));
                    if(editor->isGlobalEdit())
                        populateMultiSelect(iRightmost->second);
                    updateSelection();
                }
            }
            else // there was no item selected at all? Then select nearest to tick if there is any
            {
                selectAtTick(song->cpos());
                updateSelection();
            }
        }
        break;
        case SEL_LEFT ... SEL_LEFT_ADD:
        {
            if (action == SEL_LEFT && allItemsAreSelected())
            {
                deselectAll();
                selectAtTick(song->cpos());
                return;
            }

            iCItem i, iLeftmost;
            CItem* leftmost = NULL;

            // get a list of items that belong to the current part
            // since multiple parts have populated the _items list
            // we need to filter on the actual current Part!
            CItemList list = _items;
            if(multiPartSelectionAction && !multiPartSelectionAction->isChecked())
                list = getItemlistForCurrentPart();

            if (list.size() > 0)
            {
                i = list.end();
                while (i != list.begin())
                {
                    --i;

                    if (i->second->isSelected())
                    {
                        iLeftmost = i;
                        leftmost = i->second;
                    }
                }
                if (leftmost)
                {
                    if (iLeftmost != list.begin())
                    {
                        //Add item
                        if (action != SEL_LEFT_ADD)
                            deselectAll();

                        iLeftmost--;
                        iLeftmost->second->setSelected(true);
                        itemPressed(iLeftmost->second);
                        m_tempPlayItems.append(iLeftmost->second);
                        QTimer::singleShot(NOTE_PLAY_TIME, this, SLOT(playReleaseForItem()));
                        if(editor->isGlobalEdit())
                            populateMultiSelect(iLeftmost->second);
                        updateSelection();
                    } else {
                        leftmost->setSelected(true);
                        itemPressed(leftmost);
                        m_tempPlayItems.append(leftmost);
                        QTimer::singleShot(NOTE_PLAY_TIME, this, SLOT(playReleaseForItem()));
                        if(editor->isGlobalEdit())
                            populateMultiSelect(leftmost);
                        updateSelection();
                    }
                } else // there was no item selected at all? Then select nearest to tick if there is any
                {
                    selectAtTick(song->cpos());
                    updateSelection();
                }
            }
        }
        break;
        case INC_PITCH_OCTAVE:
        {
            modifySelected(NoteInfo::VAL_PITCH, 12);
        }
        break;
        case DEC_PITCH_OCTAVE:
        {
            modifySelected(NoteInfo::VAL_PITCH, -12);
        }
        break;
        case INC_PITCH:
        {
            modifySelected(NoteInfo::VAL_PITCH, 1);
        }
        break;
        case DEC_PITCH:
        {
            modifySelected(NoteInfo::VAL_PITCH, -1);
        }
        break;
        case INC_POS:
        {
            // TODO: Check boundaries
            modifySelected(NoteInfo::VAL_TIME, editor->raster());
        }
        break;
        case DEC_POS:
        {
            // TODO: Check boundaries
            modifySelected(NoteInfo::VAL_TIME, 0 - editor->raster());
        }
        break;
        case INCREASE_LEN:
        {
            // TODO: Check boundaries
            modifySelected(NoteInfo::VAL_LEN, editor->raster());
        }
        break;
        case DECREASE_LEN:
        {
            // TODO: Check boundaries
            modifySelected(NoteInfo::VAL_LEN, 0 - editor->raster());
        }
        break;
        case GOTO_SEL_NOTE:
        {
            CItem* leftmost = getLeftMostSelected();
            if (leftmost)
            {
                unsigned newtick = leftmost->event().tick() + leftmost->part()->tick();
                Pos p1(newtick, true);
                song->setPos(0, p1, true, true, false);
            }
        }
        break;
        case MIDI_PANIC:
        {
            song->panic();
        }
        break;
    }
}/*}}}*/
Exemple #22
0
/** Constructor */
IdDialog::IdDialog(QWidget *parent)
: RsGxsUpdateBroadcastPage(rsIdentity, parent)
{
	ui.setupUi(this);

	mIdQueue = NULL;

	/* Setup UI helper */
	mStateHelper = new UIStateHelper(this);
	mStateHelper->addWidget(IDDIALOG_IDLIST, ui.treeWidget_IdList);
	mStateHelper->addLoadPlaceholder(IDDIALOG_IDLIST, ui.treeWidget_IdList, false);
	mStateHelper->addClear(IDDIALOG_IDLIST, ui.treeWidget_IdList);

	mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_Nickname);
	mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_KeyId);
	mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_GpgHash);
	mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_GpgId);
	mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
	mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.toolButton_Reputation);
	mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.toolButton_Delete);
	mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.toolButton_EditId);
	mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.line_RatingOverall);
	mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.line_RatingImplicit);
	mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.line_RatingOwn);

	mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_Nickname);
	mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
	mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_KeyId);
	mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgHash);
	mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgId);
	mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
	mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.line_RatingOverall);
	mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.line_RatingImplicit);
	mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.line_RatingOwn);

	mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_Nickname);
	mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
	mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_KeyId);
	mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgHash);
	mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgId);
	mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
	mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.line_RatingOverall);
	mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.line_RatingImplicit);
	mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.line_RatingOwn);

	mStateHelper->addWidget(IDDIALOG_REPLIST, ui.treeWidget_RepList);
	mStateHelper->addLoadPlaceholder(IDDIALOG_REPLIST, ui.treeWidget_RepList);
	mStateHelper->addClear(IDDIALOG_REPLIST, ui.treeWidget_RepList);

	/* Connect signals */
	connect(ui.toolButton_NewId, SIGNAL(clicked()), this, SLOT(addIdentity()));
	connect(ui.todoPushButton, SIGNAL(clicked()), this, SLOT(todo()));
	connect(ui.toolButton_EditId, SIGNAL(clicked()), this, SLOT(editIdentity()));
	connect( ui.treeWidget_IdList, SIGNAL(itemSelectionChanged()), this, SLOT(updateSelection()));

	connect(ui.filterComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterComboBoxChanged()));
	connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));

	/* Add filter types */
	ui.filterComboBox->addItem(tr("All"), RSID_FILTER_ALL);
	ui.filterComboBox->addItem(tr("Yourself"), RSID_FILTER_YOURSELF);
	ui.filterComboBox->addItem(tr("Friends / Friends of Friends"), RSID_FILTER_FRIENDS);
	ui.filterComboBox->addItem(tr("Others"), RSID_FILTER_OTHERS);
	ui.filterComboBox->addItem(tr("Pseudonyms"), RSID_FILTER_PSEUDONYMS);
	ui.filterComboBox->setCurrentIndex(0);

	/* Add filter actions */
	QTreeWidgetItem *headerItem = ui.treeWidget_IdList->headerItem();
	QString headerText = headerItem->text(RSID_COL_NICKNAME);
	ui.filterLineEdit->addFilter(QIcon(), headerText, RSID_COL_NICKNAME, QString("%1 %2").arg(tr("Search"), headerText));
	headerText = headerItem->text(RSID_COL_KEYID);
	ui.filterLineEdit->addFilter(QIcon(), headerItem->text(RSID_COL_KEYID), RSID_COL_KEYID, QString("%1 %2").arg(tr("Search"), headerText));

	/* Setup tree */
	ui.treeWidget_IdList->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder);

	mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);

	mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
	mStateHelper->setActive(IDDIALOG_REPLIST, false);
}
void QgsAttributeTableDialog::updateRowSelection( int first, int last, int clickType )
{
  // clickType= 0:Single click, 1:Shift, 2:Ctrl, 3: Dragged click
  disconnect( mLayer, SIGNAL( selectionChanged() ), this, SLOT( updateSelectionFromLayer() ) );

  // Id must be mapped to table/view row
  QModelIndex index = mFilterModel->mapToSource( mFilterModel->index( first, 0 ) );
  QgsFeatureId fid = mModel->rowToId( index.row() );
  bool wasSelected = mSelectedFeatures.contains( fid );

  // new selection should be created
  if ( clickType == 0 ) // Single click
  {
    if ( mSelectedFeatures.size() == 1 && wasSelected ) // One item selected
      return; // Click over a selected item doesn't do anything

    mView->setCurrentIndex( mFilterModel->index( first, 0 ) );
    mView->selectRow( first );

    mSelectedFeatures.clear();
    mSelectedFeatures.insert( fid );
    mLayer->removeSelection();
    mLayer->select( fid );
    connect( mLayer, SIGNAL( selectionChanged() ), this, SLOT( updateSelectionFromLayer() ) );
    return;
  }
  else if ( clickType == 1 ) // Shift
  {
    QgsFeatureIds newSelection;

    for ( int i = first; i <= last; ++i )
    {
      if ( i >= first )
      {
        // Id must be mapped to table/view row
        index = mFilterModel->mapToSource( mFilterModel->index( i, 0 ) );
        fid = mModel->rowToId( index.row() );
      }
      newSelection.insert( fid );
    }

    // Remove items in mSelectedFeatures if they aren't in mNewSelection
    QgsFeatureIds::Iterator it = mSelectedFeatures.begin();
    while ( it != mSelectedFeatures.end() )
    {
      if ( !newSelection.contains( *it ) )
      {
        it = mSelectedFeatures.erase( it );
      }
      else
      {
        ++it;
      }
    }

    // Append the other fids in range first-last to mSelectedFeatures
    QgsFeatureIds::Iterator itNew = newSelection.begin();
    for ( ; itNew != newSelection.end(); ++itNew )
    {
      if ( !mSelectedFeatures.contains( *itNew ) )
      {
        mSelectedFeatures.insert( *itNew );
      }
    }
  }
  else if ( clickType == 2 ) // Ctrl
  {
    // existing selection should be updated
    if ( wasSelected )
      mSelectedFeatures.remove( fid );
    else
      mSelectedFeatures.insert( fid );
  }
  else if ( clickType == 3 ) // Dragged click
  {
    QgsFeatureIds newSelection;

    for ( int i = first; i <= last; ++i )
    {
      if ( i >= first )
      {
        // Id must be mapped to table/view row
        index = mFilterModel->mapToSource( mFilterModel->index( i, 0 ) );
        fid = mModel->rowToId( index.row() );
      }
      newSelection.insert( fid );
    }

    // Remove items in mSelectedFeatures if they aren't in mNewSelection
    QgsFeatureIds::Iterator it = mSelectedFeatures.begin();
    while ( it != mSelectedFeatures.end() )
    {
      if ( !newSelection.contains( *it ) )
      {
        it = mSelectedFeatures.erase( it );
      }
      else
      {
        ++it;
      }
    }

    // Append the other fids in range first-last to mSelectedFeatures
    QgsFeatureIds::Iterator itNew = newSelection.begin();
    for ( ; itNew != newSelection.end(); ++itNew )
    {
      if ( !mSelectedFeatures.contains( *itNew ) )
      {
        mSelectedFeatures.insert( *itNew );
      }
    }
  }

  updateSelection();
  mLayer->setSelectedFeatures( mSelectedFeatures );
  connect( mLayer, SIGNAL( selectionChanged() ), this, SLOT( updateSelectionFromLayer() ) );
}
void DIALOG_CHOOSE_COMPONENT::OnTreeSelect( wxTreeEvent& aEvent )
{
    updateSelection();
}
Exemple #25
0
NewAccountDialog::NewAccountDialog(const QList<QString>& allKeychains, const QList<QString>& selectedKeychains, QWidget* parent)
    : QDialog(parent)
{
    if (allKeychains.isEmpty()) {
        throw std::runtime_error(tr("You must first create at least one keychain.").toStdString());
    }

    keychainSet = selectedKeychains.toSet();

    QList<QString> keychains = allKeychains;
    qSort(keychains.begin(), keychains.end());

    // Buttons
    QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
                                     | QDialogButtonBox::Cancel);
    okButton = buttonBox->button(QDialogButtonBox::Ok);
    okButton->setEnabled(false);

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    // Account Name
    QLabel* nameLabel = new QLabel();
    nameLabel->setText(tr("Account Name:"));
    nameEdit = new QLineEdit();
    connect(nameEdit, &QLineEdit::textChanged, [this](const QString& /*text*/) { updateEnabled(); });

    QHBoxLayout* nameLayout = new QHBoxLayout();
    nameLayout->setSizeConstraint(QLayout::SetNoConstraint);
    nameLayout->addWidget(nameLabel);
    nameLayout->addWidget(nameEdit);

    // Keychain List Widget
    QLabel* selectionLabel = new QLabel(tr("Select keychains:"));
    keychainListWidget = new QListWidget();
    for (auto& keychain: keychains)
    {
        QCheckBox* checkBox = new QCheckBox(keychain);
        checkBox->setCheckState(selectedKeychains.count(keychain) ? Qt::Checked : Qt::Unchecked);
        connect(checkBox, &QCheckBox::stateChanged, [=](int state) { updateSelection(keychain, state); });
        QListWidgetItem* item = new QListWidgetItem();
        keychainListWidget->addItem(item);
        keychainListWidget->setItemWidget(item, checkBox);
    }

    // Minimum Signatures
    QLabel *minSigLabel = new QLabel();
    minSigLabel->setText(tr("Minimum Signatures:"));

    minSigComboBox = new QComboBox();
    minSigLineEdit = new QLineEdit();
    minSigLineEdit->setAlignment(Qt::AlignRight);
    minSigComboBox->setLineEdit(minSigLineEdit);

    QHBoxLayout* minSigLayout = new QHBoxLayout();
    minSigLayout->setSizeConstraint(QLayout::SetNoConstraint);
    minSigLayout->addWidget(minSigLabel);
    minSigLayout->addWidget(minSigComboBox);
    updateMinSigs();

    // Creation Time
    QDateTime localDateTime = QDateTime::currentDateTime();
    QLabel* creationTimeLabel = new QLabel(tr("Creation Time ") + "(" + localDateTime.timeZoneAbbreviation() + "):");
    creationTimeEdit = new QDateTimeEdit(QDateTime::currentDateTime());
    creationTimeEdit->setDisplayFormat("yyyy.MM.dd hh:mm:ss");
    creationTimeEdit->setCalendarPopup(true);
    calendarWidget = new QCalendarWidget(this);
    creationTimeEdit->setCalendarWidget(calendarWidget);

    QHBoxLayout* creationTimeLayout = new QHBoxLayout();
    creationTimeLayout->setSizeConstraint(QLayout::SetNoConstraint);
    creationTimeLayout->addWidget(creationTimeLabel);
    creationTimeLayout->addWidget(creationTimeEdit);

    // Main Layout 
    QVBoxLayout *mainLayout = new QVBoxLayout();
    mainLayout->setSizeConstraint(QLayout::SetNoConstraint);
    mainLayout->addLayout(nameLayout);
    mainLayout->addWidget(selectionLabel);
    mainLayout->addWidget(keychainListWidget);
    mainLayout->addLayout(minSigLayout);
    mainLayout->addLayout(creationTimeLayout);
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);
}
Exemple #26
0
void LLComboBox::onTextEntry(LLLineEditor* line_editor)
{
	if (mTextEntryCallback != NULL)
	{
		(mTextEntryCallback)(line_editor, LLSD());
	}

	KEY key = gKeyboard->currentKey();
	if (key == KEY_BACKSPACE || 
		key == KEY_DELETE)
	{
		if (mList->selectItemByLabel(line_editor->getText(), FALSE))
		{
			line_editor->setTentative(FALSE);
			mLastSelectedIndex = mList->getFirstSelectedIndex();
		}
		else
		{
			line_editor->setTentative(mTextEntryTentative);
			mList->deselectAllItems();
			mLastSelectedIndex = -1;
		}
		if (mTextChangedCallback != NULL)
		{
			(mTextChangedCallback)(line_editor, LLSD());
		}
		return;
	}

	if (key == KEY_LEFT || 
		key == KEY_RIGHT)
	{
		return;
	}

	if (key == KEY_DOWN)
	{
		setCurrentByIndex(llmin(getItemCount() - 1, getCurrentIndex() + 1));
		if (!mList->getVisible())
		{
			prearrangeList();

			if (mList->getItemCount() != 0)
			{
				showList();
			}
		}
		line_editor->selectAll();
		line_editor->setTentative(FALSE);
	}
	else if (key == KEY_UP)
	{
		setCurrentByIndex(llmax(0, getCurrentIndex() - 1));
		if (!mList->getVisible())
		{
			prearrangeList();

			if (mList->getItemCount() != 0)
			{
				showList();
			}
		}
		line_editor->selectAll();
		line_editor->setTentative(FALSE);
	}
	else
	{
		// RN: presumably text entry
		updateSelection();
	}
	if (mTextChangedCallback != NULL)
	{
		(mTextChangedCallback)(line_editor, LLSD());
	}
}
Exemple #27
0
void GLWorld::mousePressEvent(QMouseEvent *event)
{
    last_pos = event->pos();

    if(!(event->buttons() & Qt::RightButton && current_selection.type != TYPE_NOTHING && editable))
        return;

    WorldObject &here = getObject(current_selection.coords);
    bool steve_is_here = current_selection.coords == steve;
    QPoint pos = mapToGlobal(event->pos());

    QMenu menu;
    QAction steve_here(trUtf8("Steve hierher teleportieren"), &menu);
    steve_here.setDisabled(here.has_cube || steve_is_here);
    menu.addAction(&steve_here);

    QAction cube_here(trUtf8("Würfel"), &menu);
    cube_here.setCheckable(true);
    cube_here.setChecked(here.has_cube);
    cube_here.setDisabled(steve_is_here); //No cube into steve
    menu.addAction(&cube_here);

    QAction stack_here(trUtf8("Stapel"), &menu);
    stack_here.setCheckable(true);
    if(here.stack_size > 0)
    {
        stack_here.setChecked(true);
        stack_here.setText(trUtf8("Stapel (%1)").arg(here.stack_size));
    }
    menu.addAction(&stack_here);

    QAction mark_here(trUtf8("Markierung"), &menu);
    mark_here.setCheckable(true);
    mark_here.setChecked(here.has_mark);
    menu.addAction(&mark_here);

    QAction *selected = menu.exec(pos);
    if(selected == &steve_here)
    {
        steve = current_selection.coords;

        //The user can't be really fast, so animations always on
        setSpeed(2000);

        setAnimation(ANIM_STEP);
        updateAnimationTarget();
        updateFront();

        fbo_dirty = true;
    }
    else if(selected == &cube_here)
    {
        here.has_cube = !here.has_cube;
        here.stack_size = 0;
        here.has_mark = false;

        fbo_dirty = true;

        emit changed();
    }
    else if(selected == &stack_here)
    {
        bool ok;
        int s = QInputDialog::getInt(this, trUtf8("Stapelhöhe"), trUtf8("Stapelhöhe auswählen:"), here.stack_size, 0, World::max_height, 1, &ok);
        if(ok)
        {
            if(s > 0)
                here.has_cube = false;

            here.stack_size = s;

            if(steve == current_selection.coords)
            {
                setAnimation(ANIM_STEP);
                updateAnimationTarget();
            }

            fbo_dirty = true;

            emit changed();
        }
    }
    else if(selected == &mark_here)
    {
        here.has_mark = !here.has_mark;
        here.has_cube = false;

        fbo_dirty = true;

        emit changed();
    }

    updateSelection();
}
MainWindow::MainWindow(RInside &r, QWidget *parent) :
    QMainWindow(parent),
    m_r(r),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    dataModel = new DataModel(r);
    dlg = NULL;
    localdlg = NULL;


    //relationView = new ModelRelationView(this,ui->modelRelationContainer);
    //mrvLayout = new QHBoxLayout(ui->modelRelationContainer);
    //ui->modelRelationContainer->layout()->setMargin(0);
    //mrvLayout->addWidget(this->relationView);


    modelView = new ModelView(this,ui->modelContainer);
    containerLayout = new QHBoxLayout(ui->modelContainer);
    ui->modelContainer->layout()->setMargin(0);
    containerLayout->addWidget(this->modelView);

    /*scrollArea = new QScrollArea();
    containerLayout->addWidget(scrollArea);
    scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    scrollArea->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    scrollArea->setWidgetResizable(true);
    scrollArea->setWidget(modelView);
    scrollArea->show();*/

    ui->listView_selected->setMouseTracking(true);

    //localView = new LocalModelView(this,ui->LocalModelContainer);
    //localLayout = new QHBoxLayout(ui->LocalModelContainer);
    //ui->LocalModelContainer->layout()->setMargin(0);
    //localLayout->addWidget(localView);

    timeLineView = new TimeHeatmapView(this,ui->modelMetric);
    metricLayout = new QHBoxLayout(ui->modelMetric);
    ui->modelMetric->layout()->setMargin(0);
    metricLayout->addWidget(timeLineView);

    concesusView = new ConsensusView(this,ui->rightWidget);
    concesusLayout = new QHBoxLayout(ui->rightWidget);
    ui->rightWidget->layout()->setMargin(0);
    concesusLayout->addWidget(concesusView);

    // double link interaction between model view and model eval view;
    /*connect(metricView,SIGNAL(hopoverGlyph(int)),
            modelView,SLOT(highlightProfile(int)));
    connect(modelView,SIGNAL(modelProfileHopover(int)),
            metricView,SLOT(highlightGlyph(int)));
*/

    connect(this, SIGNAL(timeLineChanged()),
            dataModel,SLOT(normalize()));

    //connect(this, SIGNAL(timeLineChanged()),
            //timeLineView, SLOT(updateTimeHeatmapView()));

    connect(dataModel, SIGNAL(dataSelectionChanged()),
            timeLineView, SLOT(updateTimeHeatmapView()));

    connect(ui->binSlider,SIGNAL(valueChanged(int)),
            timeLineView,SLOT(updateBins(int)));

    connect(ui->intvlSlider,SIGNAL(valueChanged(int)),
            timeLineView,SLOT(updateIntvls(int)));

    connect(ui->btnAddModel, SIGNAL(clicked()),
            dataModel,SLOT(updateModelProfile()));

    connect(dataModel, SIGNAL(timelinemodelChanged()),
                modelView, SLOT(updateModelView()));

    connect(this->modelView, SIGNAL(timelineSelectionChanged()),
            this->timeLineView,SLOT(updateSelection()));

    connect(this->timeLineView,SIGNAL(colorRangeChanged(int)),
            this, SLOT(updateColorSliderRange(int)));

    connect(this->ui->colorSlider,SIGNAL(valueChanged(int)),
            this->timeLineView,SLOT(updateColors(int)));

    connect(this->ui->binModSlidr,SIGNAL(valueChanged(int)),
            modelView,SLOT(updateBinSize(int)));

    connect(this->ui->intvlModSlider,SIGNAL(valueChanged(int)),
            dataModel,SLOT(updateWinNum(int)));

    connect(this->ui->colorModSlider,SIGNAL(valueChanged(int)),
            modelView,SLOT(updateColors(int)));

    connect(modelView,SIGNAL(colorRangeChanged(int)),
            this,SLOT(updateModelColorSliderRange(int)));

    connect(this->ui->binModSlidr,SIGNAL(valueChanged(int)),
            this->ui->lblModBins,SLOT(setNum(int)));

    connect(this->ui->intvlModSlider,SIGNAL(valueChanged(int)),
            this->ui->lblModIntvls,SLOT(setNum(int)));

    connect(this->ui->colorModSlider,SIGNAL(valueChanged(int)),
            this->ui->lblModColorRange,SLOT(setNum(int)));

    connect(this->ui->cBoxConf,SIGNAL(toggled(bool)),
            modelView,SLOT(updateBoxPlot(bool)));

    connect(this->modelView,SIGNAL(clusterAdded()),
            this->concesusView,SLOT(updateGlyphs()));

    connect(this,SIGNAL(simThresChanged(double)),
            this->concesusView,SLOT(updateThreshold(double)));

    connect(this->concesusView,SIGNAL(indexAggregated(QSet<int>)),
            this->modelView,SLOT());
    connect(this->concesusView,SIGNAL(),
            this->timeLineView,SLOT());
}
bool SourceViewerWidget::findText(const QString &text, WebWidget::FindFlags flags)
{
	const bool isTheSame = (text == m_findText);

	m_findText = text;
	m_findFlags = flags;

	if (!text.isEmpty())
	{
		QTextDocument::FindFlags nativeFlags;

		if (flags.testFlag(WebWidget::BackwardFind))
		{
			nativeFlags |= QTextDocument::FindBackward;
		}

		if (flags.testFlag(WebWidget::CaseSensitiveFind))
		{
			nativeFlags |= QTextDocument::FindCaseSensitively;
		}

		QTextCursor findTextCursor = m_findTextAnchor;

		if (!isTheSame)
		{
			findTextCursor = textCursor();
		}
		else if (!flags.testFlag(WebWidget::BackwardFind))
		{
			findTextCursor.setPosition(findTextCursor.selectionEnd(), QTextCursor::MoveAnchor);
		}

		m_findTextAnchor = document()->find(text, findTextCursor, nativeFlags);

		if (m_findTextAnchor.isNull())
		{
			m_findTextAnchor = textCursor();
			m_findTextAnchor.setPosition((flags.testFlag(WebWidget::BackwardFind) ? (document()->characterCount() - 1) : 0), QTextCursor::MoveAnchor);
			m_findTextAnchor = document()->find(text, m_findTextAnchor, nativeFlags);
		}

		if (!m_findTextAnchor.isNull())
		{
			const QTextCursor currentTextCursor = textCursor();

			disconnect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateTextCursor()));

			setTextCursor(m_findTextAnchor);
			ensureCursorVisible();

			const QPoint position(horizontalScrollBar()->value(), verticalScrollBar()->value());

			setTextCursor(currentTextCursor);

			horizontalScrollBar()->setValue(position.x());
			verticalScrollBar()->setValue(position.y());

			connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateTextCursor()));
		}
	}

	m_findTextSelection = m_findTextAnchor;

	updateSelection();

	return !m_findTextAnchor.isNull();
}
Exemple #30
0
void ClipboardMonitor::checkClipboard(QClipboard::Mode mode)
{
#ifdef COPYQ_WS_X11
    if ( m_x11->isSynchronizing() )
        return;
    m_x11->synchronizeNone();
#endif

    // Check clipboard after interval because someone is updating it very quickly.
    bool needToWait = m_updateTimer->isActive();
    if (mode == QClipboard::Clipboard)
        m_needCheckClipboard = needToWait;
#ifdef COPYQ_WS_X11
    else if (mode == QClipboard::Selection)
        m_needCheckSelection = needToWait;
#endif

    m_updateTimer->start();
    if (needToWait)
        return;

    COPYQ_LOG( QString("Checking for new %1 content.")
               .arg(mode == QClipboard::Clipboard ? "clipboard" : "selection") );
#ifdef COPYQ_WS_X11
    if (mode == QClipboard::Clipboard) {
        if ( QApplication::clipboard()->ownsClipboard() )
            return;
    } else if (mode == QClipboard::Selection) {
        if ( (!m_checksel && !m_copysel) ||
             QApplication::clipboard()->ownsSelection() ||
             !updateSelection(false) )
        {
            return;
        }
    } else {
        return;
    }
#else /* !COPYQ_WS_X11 */
    // check if clipboard data are needed
    if (mode != QClipboard::Clipboard || QApplication::clipboard()->ownsClipboard())
        return;
#endif

    // get clipboard data
    const QMimeData *data = clipboardData(mode);

    // data retrieved?
    if (!data) {
        log( tr("Cannot access clipboard data!"), LogError );
        return;
    }

    // clone only mime types defined by user
    QMimeData *data2 = cloneData(*data, &m_formats);
    // any data found?
    if ( data2->formats().isEmpty() ) {
        delete data2;
        return;
    }

    // add window title of clipboard owner
    PlatformPtr platform = createPlatformNativeInterface();
    data2->setData( QString(mimeWindowTitle),
                    platform->getWindowTitle(platform->getCurrentWindow()).toUtf8() );

#ifdef COPYQ_WS_X11
    if (mode == QClipboard::Clipboard) {
        if (m_copyclip)
            m_x11->synchronize(data2, QClipboard::Selection);
        clipboardChanged(mode, data2);
    } else {
        if (m_copysel)
            m_x11->synchronize(data2, QClipboard::Clipboard);
        if (m_checksel)
            clipboardChanged(mode, data2);
        else
            delete data2;
    }
#else /* !COPYQ_WS_X11 */
    clipboardChanged(mode, data2);
#endif
}