Example #1
0
void StrokeSelection::copy() {
  if (m_indexes.empty()) return;
  QClipboard *clipboard = QApplication::clipboard();
  QMimeData *oldData    = cloneData(clipboard->mimeData());
  copyStrokesWithoutUndo(m_vi, m_indexes);
  QMimeData *newData = cloneData(clipboard->mimeData());

  // TUndoManager::manager()->add(new CopyStrokesUndo(oldData, newData));
}
Example #2
0
 void synchronize(QMimeData *data, QClipboard::Mode modeSyncTo)
 {
     delete m_syncData;
     m_syncData = cloneData(*data);
     m_syncTo = modeSyncTo;
     m_syncTimer.start();
 }
Example #3
0
ClipboardDialog::ClipboardDialog(QWidget *parent)
    : QDialog(parent)
{
    init();

    const QMimeData *clipData = clipboardData();
    if (clipData)
        setData( cloneData(*clipData) );
}
Example #4
0
QByteArray ScriptableProxyHelper::getClipboardData(const QString &mime, QClipboard::Mode mode)
{
    INVOKE(getClipboardData(mime, mode));
    const QMimeData *data = clipboardData(mode);
    if (!data)
        return QByteArray();

    if (mime == "?")
        return data->formats().join("\n").toUtf8() + '\n';

    return cloneData(*data, QStringList(mime)).value(mime).toByteArray();
}
Example #5
0
QVariantMap cloneData(const QMimeData &data)
{
    QStringList formats;

    for ( const auto &mime : data.formats() ) {
        // ignore uppercase mimetypes (e.g. UTF8_STRING, TARGETS, TIMESTAMP)
        // and internal type to check clipboard owner
        if ( !mime.isEmpty() && mime[0].isLower() )
            formats.append(mime);
    }

    return cloneData(data, formats);
}
Example #6
0
/*clone the given node
and also its data*/
listNode* cloneNode(listNode* node){
	listNode* clone = (listNode*)malloc(sizeof(listNode));
	if (clone == NULL)
	{
		print_message("Error: standard function malloc has failed");
		print_message("Terminating program");
		exit(1);
	}
	char* data = cloneData(node->data, node->size);
	clone->data = data;
	clone->next = NULL;
	return clone;
}
Example #7
0
void ActionDialog::setInputData(const QMimeData &data)
{
    delete m_data;
    m_data = cloneData(data);

    QString defaultFormat = ui->comboBoxInputFormat->currentText();
    ui->comboBoxInputFormat->clear();
    QStringList formats = QStringList() << standardFormats << data.formats();
    formats.removeDuplicates();
    ui->comboBoxInputFormat->addItems(formats);
    const int index = qMax(0, ui->comboBoxInputFormat->findText(defaultFormat));
    ui->comboBoxInputFormat->setCurrentIndex(index);

}
Example #8
0
	void DataUtility::cloneData(DataPtr _target, DataPtr _prototype)
	{
		MYGUI_ASSERT(_target != _prototype, "Error clone self");
		MYGUI_ASSERT(_target->getType() == _prototype->getType(), "Error clone different types");
		MYGUI_ASSERT(_target->getChilds().size() == 0, "Target not empty");

		copyProperty(_target, _prototype);
		
		for (Data::VectorData::const_iterator child = _prototype->getChilds().begin(); child != _prototype->getChilds().end(); child ++)
		{
			DataPtr data = Data::CreateInstance();
			data->setType((*child)->getType());

			_target->addChild(data);

			cloneData(data, *child);
		}
	}
Example #9
0
    void synchronize()
    {
        if (m_syncTimer.isActive())
            return;

        if ( m_syncTo == QClipboard::Selection && isSelectionIncomplete() ) {
            m_syncTimer.start();
            return;
        }

        const QVariantMap &sourceData =
                (m_syncTo == QClipboard::Clipboard) ? m_selectionData : m_clipboardData;
        if ( !sourceData.isEmpty() ) {
            const QMimeData *data = clipboardData(m_syncTo);
            if  ( !data || sourceData != cloneData(*data, sourceData.keys()) )
                setClipboardData(sourceData, m_syncTo);
        }

    }
Example #10
0
ClipboardDialog::ClipboardDialog(const ClipboardItemPtr &item, QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::ClipboardDialog)
    , m_item(item)
{
    ui->setupUi(this);

    setWindowIcon( ConfigurationManager::instance()->iconFactory()->appIcon() );

    QVariantMap data;
    if ( m_item.isNull() ) {
        const QMimeData *clipData = clipboardData();
        if (clipData)
            data = cloneData(*clipData);
    } else {
        setWindowTitle( tr("CopyQ Item Content") );
        data = item->data();
    }

    // Show only data that can be displayed.
    foreach ( const QString &mime, data.keys() ) {
        if ( data[mime].canConvert<QByteArray>() && mime != mimeOwner ) {
            m_data.insert(mime, data[mime]);
            ui->listWidgetFormats->addItem(mime);
        }
    }

    ui->horizontalLayout->setStretchFactor(1, 1);
    ui->listWidgetFormats->setCurrentRow(0);

    ConfigurationManager::instance()->registerWindowGeometry(this);

    ui->actionRemove_Format->setIcon( getIcon("list-remove", IconRemove) );
    ui->actionRemove_Format->setShortcut(shortcutToRemove());
    ui->listWidgetFormats->addAction(ui->actionRemove_Format);
}
Example #11
0
SharedPtr<Model> Model::Clone(const String& cloneName) const
{
    SharedPtr<Model> ret(new Model(context_));

    ret->SetName(cloneName);
    ret->boundingBox_ = boundingBox_;
    ret->skeleton_ = skeleton_;
    ret->geometryBoneMappings_ = geometryBoneMappings_;
    ret->geometryCenters_ = geometryCenters_;
    ret->morphs_ = morphs_;
    ret->morphRangeStarts_ = morphRangeStarts_;
    ret->morphRangeCounts_ = morphRangeCounts_;

    // Deep copy vertex/index buffers
    HashMap<VertexBuffer*, VertexBuffer*> vbMapping;
    for (Vector<SharedPtr<VertexBuffer> >::ConstIterator i = vertexBuffers_.Begin(); i != vertexBuffers_.End(); ++i)
    {
        VertexBuffer* origBuffer = *i;
        SharedPtr<VertexBuffer> cloneBuffer;

        if (origBuffer)
        {
            cloneBuffer = new VertexBuffer(context_);
            cloneBuffer->SetSize(origBuffer->GetVertexCount(), origBuffer->GetElementMask(), origBuffer->IsDynamic());
            cloneBuffer->SetShadowed(origBuffer->IsShadowed());
            if (origBuffer->IsShadowed())
                cloneBuffer->SetData(origBuffer->GetShadowData());
            else
            {
                void* origData = origBuffer->Lock(0, origBuffer->GetVertexCount());
                if (origData)
                    cloneBuffer->SetData(origData);
                else
                    URHO3D_LOGERROR("Failed to lock original vertex buffer for copying");
            }
            vbMapping[origBuffer] = cloneBuffer;
        }

        ret->vertexBuffers_.Push(cloneBuffer);
    }

    HashMap<IndexBuffer*, IndexBuffer*> ibMapping;
    for (Vector<SharedPtr<IndexBuffer> >::ConstIterator i = indexBuffers_.Begin(); i != indexBuffers_.End(); ++i)
    {
        IndexBuffer* origBuffer = *i;
        SharedPtr<IndexBuffer> cloneBuffer;

        if (origBuffer)
        {
            cloneBuffer = new IndexBuffer(context_);
            cloneBuffer->SetSize(origBuffer->GetIndexCount(), origBuffer->GetIndexSize() == sizeof(unsigned),
                origBuffer->IsDynamic());
            cloneBuffer->SetShadowed(origBuffer->IsShadowed());
            if (origBuffer->IsShadowed())
                cloneBuffer->SetData(origBuffer->GetShadowData());
            else
            {
                void* origData = origBuffer->Lock(0, origBuffer->GetIndexCount());
                if (origData)
                    cloneBuffer->SetData(origData);
                else
                    URHO3D_LOGERROR("Failed to lock original index buffer for copying");
            }
            ibMapping[origBuffer] = cloneBuffer;
        }

        ret->indexBuffers_.Push(cloneBuffer);
    }

    // Deep copy all the geometry LOD levels and refer to the copied vertex/index buffers
    ret->geometries_.Resize(geometries_.Size());
    for (unsigned i = 0; i < geometries_.Size(); ++i)
    {
        ret->geometries_[i].Resize(geometries_[i].Size());
        for (unsigned j = 0; j < geometries_[i].Size(); ++j)
        {
            SharedPtr<Geometry> cloneGeometry;
            Geometry* origGeometry = geometries_[i][j];

            if (origGeometry)
            {
                cloneGeometry = new Geometry(context_);
                cloneGeometry->SetIndexBuffer(ibMapping[origGeometry->GetIndexBuffer()]);
                unsigned numVbs = origGeometry->GetNumVertexBuffers();
                for (unsigned k = 0; k < numVbs; ++k)
                {
                    cloneGeometry->SetVertexBuffer(k, vbMapping[origGeometry->GetVertexBuffer(k)]);
                }
                cloneGeometry->SetDrawRange(origGeometry->GetPrimitiveType(), origGeometry->GetIndexStart(),
                    origGeometry->GetIndexCount(), origGeometry->GetVertexStart(), origGeometry->GetVertexCount(), false);
                cloneGeometry->SetLodDistance(origGeometry->GetLodDistance());
            }

            ret->geometries_[i][j] = cloneGeometry;
        }
    }


    // Deep copy the morph data (if any) to allow modifying it
    for (Vector<ModelMorph>::Iterator i = ret->morphs_.Begin(); i != ret->morphs_.End(); ++i)
    {
        ModelMorph& morph = *i;
        for (HashMap<unsigned, VertexBufferMorph>::Iterator j = morph.buffers_.Begin(); j != morph.buffers_.End(); ++j)
        {
            VertexBufferMorph& vbMorph = j->second_;
            if (vbMorph.dataSize_)
            {
                SharedArrayPtr<unsigned char> cloneData(new unsigned char[vbMorph.dataSize_]);
                memcpy(cloneData.Get(), vbMorph.morphData_.Get(), vbMorph.dataSize_);
                vbMorph.morphData_ = cloneData;
            }
        }
    }

    ret->SetMemoryUse(GetMemoryUse());

    return ret;
}
Example #12
0
QVariantMap DummyClipboard::data(ClipboardMode mode, const QStringList &formats) const
{
    const QMimeData *data = clipboardData(mode);
    return data ? cloneData(*data, formats) : QVariantMap();
}
Example #13
0
EditClock::EditClock(QString clockname,bool new_clock,
		     std::vector<QString> *new_clocks,QWidget *parent)
  : QDialog(parent,"",true)
{
  QString str;

  str=QString(tr("Edit Clock:"));
  setCaption(QString().sprintf("%s %s",(const char *)str,
			       (const char *)clockname));
  edit_name=clockname;
  edit_new_clock=new_clock;
  edit_new_clocks=new_clocks;

  //
  // Fix the Window Size
  //
  setMinimumWidth(sizeHint().width());
  setMaximumWidth(sizeHint().width());
  setMinimumHeight(sizeHint().height());
  setMaximumHeight(sizeHint().height());

  //
  // Create Fonts
  //
  QFont bold_font=QFont("Helvetica",12,QFont::Bold);
  bold_font.setPixelSize(12);
  QFont font=QFont("Helvetica",12,QFont::Normal);
  font.setPixelSize(12);
  edit_title_font=new QFont("Helvetica",24,QFont::Bold);
  edit_title_font->setPixelSize(24);
  edit_title_metrics=new QFontMetrics(*edit_title_font);

  //
  // Clock Names
  //
  edit_clockname_label=new QLabel(clockname,this);
  edit_clockname_label->setGeometry(10,10,280,20);
  edit_clockname_label->setFont(bold_font);
  edit_shortname_edit=new QLineEdit(this);
  edit_shortname_edit->setGeometry(350,10,40,20);
  edit_shortname_edit->setMaxLength(3);
  QLabel *label=new QLabel(edit_shortname_edit,tr("Code:"),this);
  label->setGeometry(295,10,50,20);
  label->setFont(bold_font);
  label->setAlignment(AlignRight|AlignVCenter);

  //
  // Clock List
  //
  edit_clocks_list=new ClockListView(this);
  edit_clocks_list->setGeometry(10,35,CENTER_LINE-20,sizeHint().height()-250);
  edit_clocks_list->setAllColumnsShowFocus(true);
  edit_clocks_list->setItemMargin(5);
  edit_clocks_list->addColumn(tr("Start"));
  edit_clocks_list->addColumn(tr("End"));
  edit_clocks_list->addColumn(tr("Event"));
  edit_clocks_list->addColumn(tr("Length"));
  edit_clocks_list->setColumnAlignment(3,AlignRight);
  edit_clocks_list->addColumn(tr("Count"));
  edit_clocks_list->setColumnAlignment(4,AlignCenter);
  connect(edit_clocks_list,
	  SIGNAL(doubleClicked(QListViewItem *,const QPoint &,int)),
	  this,SLOT(doubleClickedData(QListViewItem *,const QPoint &,int)));
  connect(edit_clocks_list,SIGNAL(selectionChanged(QListViewItem *)),
	  this,SLOT(selectionChangedData(QListViewItem *)));
  connect(edit_clocks_list,SIGNAL(editLine(int)),
	  this,SLOT(editEventData(int)));

  //
  //  Add Button
  //
  QPushButton *button=new QPushButton(this);
  button->setGeometry(10,sizeHint().height()-210,80,50);
  button->setFont(bold_font);
  button->setText(tr("&Add"));
  connect(button,SIGNAL(clicked()),this,SLOT(addData()));

  //
  //  Clone Button
  //
  button=new QPushButton(this);
  button->setGeometry(110,sizeHint().height()-210,80,50);
  button->setFont(bold_font);
  button->setText(tr("&Clone"));
  connect(button,SIGNAL(clicked()),this,SLOT(cloneData()));
  
  //
  //  Edit Button
  //
  button=new QPushButton(this);
  button->setGeometry(210,sizeHint().height()-210,80,50);
  button->setFont(bold_font);
  button->setText(tr("&Edit"));
  connect(button,SIGNAL(clicked()),this,SLOT(editData()));

  //
  //  Delete Button
  //
  button=new QPushButton(this);
  button->setGeometry(310,sizeHint().height()-210,80,50);
  button->setFont(bold_font);
  button->setText(tr("&Delete"));
  connect(button,SIGNAL(clicked()),this,SLOT(deleteData()));

  //
  // Remarks
  //
  edit_remarks_edit=new QTextEdit(this);
  edit_remarks_edit->setGeometry(10,sizeHint().height()-140,CENTER_LINE-20,130);
  edit_remarks_edit->setTextFormat(QTextEdit::PlainText);
  label=new QLabel(edit_remarks_edit,tr("Remarks"),this);
  label->setGeometry(15,sizeHint().height()-155,CENTER_LINE-20,15);
  label->setFont(bold_font);
  label->setAlignment(AlignLeft|AlignVCenter);

  //
  //  Scheduler-Rules button
  //
  button=new QPushButton(this);
  button->setGeometry(CENTER_LINE+20,sizeHint().height()-60,70,50);
  button->setFont(bold_font);
  button->setText(tr("Scheduler\nRules"));
  connect(button,SIGNAL(clicked()),this,SLOT(schedRules()));

  //
  //  Save Button
  //
  button=new QPushButton(this);
  button->setGeometry(CENTER_LINE+110,sizeHint().height()-60,70,50);
  button->setFont(bold_font);
  button->setText(tr("&Save"));
  connect(button,SIGNAL(clicked()),this,SLOT(saveData()));

  //
  //  Save As Button
  //
  button=new QPushButton(this);
  button->setGeometry(CENTER_LINE+190,sizeHint().height()-60,70,50);
  button->setFont(bold_font);
  button->setText(tr("Save &As"));
  connect(button,SIGNAL(clicked()),this,SLOT(saveAsData()));

  //
  //  Service Associations Button
  //
  button=new QPushButton(this);
  button->setGeometry(CENTER_LINE+(sizeHint().width()-CENTER_LINE)/2-25,
		      sizeHint().height()-60,70,50);
  button->setFont(bold_font);
  button->setText(tr("&Services\nList"));
  connect(button,SIGNAL(clicked()),this,SLOT(svcData()));

  //
  //  Color Button
  //
  edit_color_button=new QPushButton(this);
  edit_color_button->
    setGeometry(CENTER_LINE+(sizeHint().width()-CENTER_LINE)/2+55,
		sizeHint().height()-60,70,50);
  edit_color_button->setFont(bold_font);
  edit_color_button->setText(tr("Colo&r"));
  connect(edit_color_button,SIGNAL(clicked()),this,SLOT(colorData()));

  //
  // Clock Display
  //
  edit_clock_label=new QLabel(this);
  edit_clock_label->
    setGeometry(CENTER_LINE+10,10,
		sizeHint().width()-CENTER_LINE-20,sizeHint().height()-80);

  //
  //  OK Button
  //
  button=new QPushButton(this);
  button->setGeometry(sizeHint().width()-160,sizeHint().height()-60,70,50);
  button->setDefault(true);
  button->setFont(bold_font);
  button->setText(tr("&OK"));
  connect(button,SIGNAL(clicked()),this,SLOT(okData()));

  //
  //  Cancel Button
  //
  button=new QPushButton(this);
  button->setGeometry(sizeHint().width()-80,sizeHint().height()-60,70,50);
  button->setFont(bold_font);
  button->setText(tr("&Cancel"));
  connect(button,SIGNAL(clicked()),this,SLOT(cancelData()));

  //
  // Populate Data
  //
  sched_rules_list = new SchedRulesList(clockname);
  edit_clock=new RDClock();
  edit_clock->setName(clockname);
  edit_clock->load();
  edit_shortname_edit->setText(edit_clock->shortName());
  if(edit_clock->color().isValid()) {
    edit_color_button->
      setPalette(QPalette(edit_clock->color(),backgroundColor()));
  }
  edit_remarks_edit->setText(edit_clock->remarks());
  edit_modified=false;
  RefreshList();
}
Example #14
0
void ClipboardMonitor::checkClipboard(QClipboard::Mode mode)
{
#ifdef COPYQ_WS_X11
    m_x11->cancelSynchronization();
#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
    else
        return;

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

#ifdef COPYQ_WS_X11
    if ( mode == QClipboard::Selection && m_x11->isSelectionIncomplete() )
        return;
    if ( m_x11->maybeResetClipboard(mode) )
        return;
#endif

    COPYQ_LOG( QString("Checking for new %1 content.")
               .arg(mode == QClipboard::Clipboard ? "clipboard" : "selection") );

    // 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
#if defined(Q_OS_MAC)
    //  On OS X, when you copy files in Finder, etc. you get:
    //  - The file name(s) (not paths) as plain text
    //  - The file URI(s)
    //  - The icon (not thumbnail) for the type of item you have in various image formants
    // We really only want the URI list, so throw the rest away
    QStringList formats = m_formats;
    if (data->formats().contains(mimeUriList) && formats.contains(mimeUriList)) {
        formats = QStringList() << mimeUriList;
    }
    QVariantMap data2( cloneData(*data, formats) );
#else
    QVariantMap data2( cloneData(*data, m_formats) );
#endif

    // add window title of clipboard owner
    if ( !data2.contains(mimeOwner) && !data2.contains(mimeWindowTitle) ) {
        PlatformPtr platform = createPlatformNativeInterface();
        PlatformWindowPtr currentWindow = platform->getCurrentWindow();
        if (currentWindow)
            data2.insert( mimeWindowTitle, currentWindow->getTitle().toUtf8() );
    }

#ifdef COPYQ_WS_X11
    m_x11->setData(mode, data2);

    if (mode == QClipboard::Clipboard) {
        if ( !ownsClipboardData(data2) && m_x11->synchronize(QClipboard::Selection) )
            m_needCheckSelection = false;
        clipboardChanged(data2);
    } else {
        data2.insert(mimeClipboardMode, "selection");
        if ( !ownsClipboardData(data2) && m_x11->synchronize(QClipboard::Clipboard) )
            m_needCheckClipboard = false;
        if ( m_x11->hasCheckSelection() )
            clipboardChanged(data2);
    }
#else /* !COPYQ_WS_X11 */
    clipboardChanged(data2);
#endif
}
Example #15
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
}
Example #16
0
                m_copysel = settings["copy_selection"].toBool();
            if ( settings.contains("check_selection") )
                m_checksel = settings["check_selection"].toBool();
#endif

            connect( QApplication::clipboard(), SIGNAL(changed(QClipboard::Mode)),
                     this, SLOT(checkClipboard(QClipboard::Mode)) );

#ifdef COPYQ_WS_X11
            checkClipboard(QClipboard::Selection);
#endif
            checkClipboard(QClipboard::Clipboard);

            COPYQ_LOG("Configured");
        } else {
            updateClipboard( cloneData(*item.data()) );
        }
    }

    m_socket->blockSignals(false);
}

void ClipboardMonitor::updateClipboard(QMimeData *data)
{
    if (data != NULL)
        m_newdata.reset(data);
    if ( m_updateTimer->isActive() )
        return;

    COPYQ_LOG("Updating clipboard");