예제 #1
0
void XFE_ComposeAttachFolderView::processHistoryDrop(fe_dnd_Source *source)
{
    XFE_HistoryView *historyView = (XFE_HistoryView*)source->closure;
    if (!historyView)
        return;

    MWContext *context=historyView->getContext();
    XFE_Outliner *outliner=historyView->getOutliner();
    const int *selectedList;
    int numSelected;

    if (outliner->getSelection(&selectedList, &numSelected)) {
        char **items=new char*[numSelected];
        int numItems=0;
        int i;
        
        for (i=0; i<numSelected; i++) {
            gh_HistEntry *entry=historyView->getEntry(selectedList[i]);
            if (entry && entry->address) {
                XDEBUG(printf("    %d:%s\n",selectedList[i],entry->address));
                items[numItems++]=XP_STRDUP(entry->address);
            }
        } 
        if (numItems>0)
            addAttachments((const char **) items,numItems);
        
        for (i=0; i<numItems; i++)
            XP_FREE(items[i]);
        delete items;
    }
}
예제 #2
0
void XFE_ComposeAttachFolderView::processBookmarkDrop(fe_dnd_Source *source)
{
    XFE_BookmarkView* bookmarkView=( XFE_BookmarkView*)source->closure;
    if (!bookmarkView)
        return;

    MWContext *context=bookmarkView->getContext();
    XFE_Outliner *outliner=bookmarkView->getOutliner();
    const int *selectedList;
    int numSelected;

    if (outliner->getSelection(&selectedList, &numSelected)) {
        char **items=new char*[numSelected];
        int numItems=0;
        int i;
        
        for (i=0; i<numSelected; i++) {
            BM_Entry* entry=BM_AtIndex(context,selectedList[i]+1);
            if (BM_GetType(entry)==BM_TYPE_URL ||
                BM_GetType(entry)==BM_TYPE_ALIAS) {
                const char *address=BM_GetAddress(entry);
                if (address) {
                    XDEBUG(printf("    %d:%s\n",selectedList[i],address));
                    items[numItems++]=XP_STRDUP(address);
                }
            }
        } 
        if (numItems>0)
            addAttachments((const char **) items,numItems);
        
        for (i=0; i<numItems; i++)
            XP_FREE(items[i]);
        delete items;
    }
}
예제 #3
0
void XFE_ComposeAttachFolderView::processMessageDrop(fe_dnd_Source *source)
{
    XFE_ThreadView *threadView=(XFE_ThreadView*)source->closure;
    XFE_Outliner *outliner=threadView->getOutliner();
    const int *selectedList;
    int numSelected;
    if (outliner->getSelection(&selectedList, &numSelected)) {
        char **items=new char*[numSelected];
        int numItems=0;
        int i;
        
        for (i=0; i<numSelected; i++) {
            MessageKey key=MSG_GetMessageKey(threadView->getPane(),selectedList[i]);
            URL_Struct *messageURL=MSG_ConstructUrlForMessage(threadView->getPane(),key);
            if (messageURL && messageURL->address) {
                XDEBUG(printf("    %d:%s\n",selectedList[i],messageURL->address));
                items[numItems++]=XP_STRDUP(messageURL->address);
            }
            if (messageURL)
                NET_FreeURLStruct(messageURL);
        }
        
        if (numItems>0)
            addAttachments((const char **) items,numItems);
        
        for (i=0; i<numItems; i++)
            XP_FREE(items[i]);
        delete items;
    }
}
	void CModelWriter_3MF_Native::writePackageToStream(_In_ PExportStream pStream)
	{
		if (pStream.get() == nullptr)
			throw CNMRException(NMR_ERROR_INVALIDPARAM);
		if (m_pModel == nullptr)
			throw CNMRException(NMR_ERROR_NOMODELTOWRITE);

		// Write Model Stream
		POpcPackageWriter pPackageWriter = std::make_shared<COpcPackageWriter>(pStream);
		POpcPackagePart pModelPart = pPackageWriter->addPart(PACKAGE_3D_MODEL_URI);
		PXmlWriter_Native pXMLWriter = std::make_shared<CXmlWriter_Native>(pModelPart->getExportStream());
		writeModelStream(pXMLWriter.get(), m_pModel);

		// add Root relationships
		pPackageWriter->addRootRelationship(generateRelationShipID(), PACKAGE_START_PART_RELATIONSHIP_TYPE, pModelPart.get());

		PModelAttachment pPackageThumbnail = m_pModel->getPackageThumbnail();
		if (pPackageThumbnail.get() != nullptr)
		{
			// create Package Thumbnail Part
			POpcPackagePart pThumbnailPart = pPackageWriter->addPart(pPackageThumbnail->getPathURI());
			PExportStream pExportStream = pThumbnailPart->getExportStream();
			// Copy data
			PImportStream pPackageThumbnailStream = pPackageThumbnail->getStream();
			pPackageThumbnailStream->seekPosition(0, true);
			pExportStream->copyFrom(pPackageThumbnailStream.get(), pPackageThumbnailStream->retrieveSize(), MODELWRITER_NATIVE_BUFFERSIZE);
			// add root relationship
			pPackageWriter->addRootRelationship(generateRelationShipID(), pPackageThumbnail->getRelationShipType(), pThumbnailPart.get());
		}

		// add slicestacks that reference other files
		addSlicerefAttachments(m_pModel);
		
		// add Attachments
		addAttachments(m_pModel, pPackageWriter, pModelPart);

		// add Content Types
		pPackageWriter->addContentType(PACKAGE_3D_RELS_EXTENSION, PACKAGE_3D_RELS_CONTENT_TYPE);
		pPackageWriter->addContentType(PACKAGE_3D_MODEL_EXTENSION, PACKAGE_3D_MODEL_CONTENT_TYPE);
		pPackageWriter->addContentType(PACKAGE_3D_TEXTURE_EXTENSION, PACKAGE_TEXTURE_CONTENT_TYPE);
		pPackageWriter->addContentType(PACKAGE_3D_PNG_EXTENSION, PACKAGE_PNG_CONTENT_TYPE);
		pPackageWriter->addContentType(PACKAGE_3D_JPEG_EXTENSION, PACKAGE_JPG_CONTENT_TYPE);
		pPackageWriter->addContentType(PACKAGE_3D_JPG_EXTENSION, PACKAGE_JPG_CONTENT_TYPE);

		std::map<std::wstring, std::wstring> CustomContentTypes = m_pModel->getCustomContentTypes();
		std::map<std::wstring, std::wstring>::iterator iContentTypeIterator;

		for (iContentTypeIterator = CustomContentTypes.begin(); iContentTypeIterator != CustomContentTypes.end(); iContentTypeIterator++) {
			if (!m_pModel->contentTypeIsDefault(iContentTypeIterator->first)) {
				pPackageWriter->addContentType(iContentTypeIterator->first, iContentTypeIterator->second);
			}
		}

			
	}
예제 #5
0
void TMessageEdit::insertFromMimeData(const QMimeData *source)
{
  MimeDataChecker mime( source );
  QStringList files = mime.getFilesPath();
  if (files.size())
  {
    emit addAttachments(files);
  }
  else
    QTextEdit::insertFromMimeData(source);
}
예제 #6
0
void
QFCItem::expand(void)
{
    if(childCount() != 0)
        return;

    FieldContainer *pFCAsp = getFC().getAspectCPtr(getAspect());

    if(!pFCAsp)
        return;

    FieldContainerType &fcType      = pFCAsp->getType();
    UInt32              uiNumFields = fcType.getNumFieldDescs();

    for(UInt32 fieldId = 1; fieldId <= uiNumFields; ++fieldId)
    {
        FieldDescription *pFieldDesc = fcType.getFieldDescription(fieldId);
        Field            *pField     = pFCAsp->getField          (fieldId);
        
        //add Items for all referenced containers (except parents)
        if(isSFFieldContainerPtr(pField))
        {
            if(stringcmp(pFieldDesc->getCName(), "parent" ) == 0)
                continue;

            addRefedContainer(
                reinterpret_cast<SFFieldContainerPtr *>(pField));
        }
        else if(isMFFieldContainerPtr(pField))
        {
            if(stringcmp(pFieldDesc->getCName(), "parents") == 0)
            {
                addParents(
                    reinterpret_cast<MFFieldContainerPtr *>(pField));
            }
            else
            {
                addRefedContainer(
                    reinterpret_cast<MFFieldContainerPtr *>(pField), 
                    pFieldDesc   );
            }
        }

        //add attachments
        if(stringcmp(pFieldDesc->getCName(), "attachments") == 0)
        {
            addAttachments(dynamic_cast<SFAttachmentMap *>(pField));
        }
    }

    PNOTICE << endLog;
}
예제 #7
0
int XFE_ComposeAttachFolderView::addAttachment(const char *itemData,int pre_existing,Boolean attach_binary)
{
    // abort if attachment adding or delivery is in progress
    // (and not adding a pre_exisiting attachment)
    if (!pre_existing && !verifySafeToAttach())
        return FALSE;

    int addStatus=FALSE;
    const char **items=new const char*[1];
    items[0]=itemData;
    addStatus=addAttachments(items,1,pre_existing,attach_binary);
    delete items;
    
    return addStatus;
}
예제 #8
0
void VAttachmentList::addAttachment()
{
    if (!m_file) {
        return;
    }

    static QString lastPath = QDir::homePath();
    QStringList files = QFileDialog::getOpenFileNames(g_mainWin,
                                                      tr("Select Files As Attachments"),
                                                      lastPath);
    if (files.isEmpty()) {
        return;
    }

    // Update lastPath
    lastPath = QFileInfo(files[0]).path();

    addAttachments(files);

    updateButtonState();

    updateContent();
}
예제 #9
0
bool VAttachmentList::handleDropEvent(QDropEvent *p_event)
{
    if (!m_file) {
        return false;
    }

    init();

    const QMimeData *mime = p_event->mimeData();
    if (mime->hasFormat("text/uri-list") && mime->hasUrls()) {
        // Add attachments.
        QStringList files;
        QList<QUrl> urls = mime->urls();
        for (int i = 0; i < urls.size(); ++i) {
            QString file;
            if (urls[i].isLocalFile()) {
                file = urls[i].toLocalFile();
                QFileInfo fi(file);
                if (fi.exists() && fi.isFile()) {
                    file = QDir::cleanPath(fi.absoluteFilePath());
                    files.append(file);
                }
            }
        }

        if (!files.isEmpty()) {
            addAttachments(files);

            updateButtonState();
        }

        p_event->acceptProposedAction();
        return true;
    }

    return false;
}
예제 #10
0
bool HashBox::eventFilter(QObject* object, QEvent* event)
{
	if (object == dropWidget) {
		if (event->type() == QEvent::DragEnter) {
			QDragEnterEvent* dragEnterEvent = static_cast<QDragEnterEvent*>(event);
			if (dragEnterEvent) {
				/* print out mimeType */
				showFormats("HashBox::dragEnterEvent", dragEnterEvent->mimeData()->formats());

				if (dragEnterEvent->mimeData()->hasUrls()) {
					std::cerr << "HashBox::dragEnterEvent() Accepting Urls" << std::endl;
					dragEnterEvent->acceptProposedAction();
				} else {
					std::cerr << "HashBox::dragEnterEvent() No Urls" << std::endl;
				}
			}
		} else if (event->type() == QEvent::Drop) {
			QDropEvent* dropEvent = static_cast<QDropEvent*>(event);
			if (dropEvent) {
				if (Qt::CopyAction & dropEvent->possibleActions()) {
					/* print out mimeType */
					showFormats("HashBox::dropEvent", dropEvent->mimeData()->formats());

					QStringList files;

					if (dropEvent->mimeData()->hasUrls()) {
						std::cerr << "HashBox::dropEvent() Urls:" << std::endl;

						QList<QUrl> urls = dropEvent->mimeData()->urls();
						QList<QUrl>::iterator uit;
						for (uit = urls.begin(); uit != urls.end(); ++uit) {
							QString localpath = uit->toLocalFile();
							std::cerr << "Whole URL: " << uit->toString().toStdString() << std::endl;
							std::cerr << "or As Local File: " << localpath.toStdString() << std::endl;

							if (localpath.isEmpty() == false) {
								//Check that the file does exist and is not a directory
								QDir dir(localpath);
								if (dir.exists()) {
									std::cerr << "HashBox::dropEvent() directory not accepted." << std::endl;
									QMessageBox mb(tr("Drop file error."), tr("Directory can't be dropped, only files are accepted."), QMessageBox::Information, QMessageBox::Ok, 0, 0, this);
									mb.exec();
								} else if (QFile::exists(localpath)) {
									files.push_back(localpath);
								} else {
									std::cerr << "HashBox::dropEvent() file does not exists."<< std::endl;
									QMessageBox mb(tr("Drop file error."), tr("File not found or file name not accepted."), QMessageBox::Information, QMessageBox::Ok, 0, 0, this);
									mb.exec();
								}
							}
						}
					}

					addAttachments(files,mDefaultTransferFlags);

					dropEvent->setDropAction(Qt::CopyAction);
					dropEvent->accept();
				} else {
					std::cerr << "HashBox::dropEvent() Rejecting uncopyable DropAction" << std::endl;
				}
			}
		}
	}
	// pass the event on to the parent class
	return QScrollArea::eventFilter(object, event);
}
예제 #11
0
MailEditorMainWindow::MailEditorMainWindow(ATopLevelWindowsContainer* parent, AddressBookModel& abModel,
  IMailProcessor& mailProcessor, bool editMode) :
  ATopLevelWindow(parent),
  ui(new Ui::MailEditorWindow()),
  ABModel(abModel),
  MailProcessor(mailProcessor),
  FontCombo(nullptr),
  EditMode(editMode)
  {
  ui->setupUi(this);

  /** Disable these toolbars by default. They should be showed up on demand, when given action will
      be trigerred.
  */
  ui->fileAttachementToolBar->hide();
  ui->moneyAttachementToolBar->hide();
  ui->editToolBar->hide();
  ui->adjustToolbar->hide();
  ui->formatToolBar->hide();

  MoneyAttachement = new TMoneyAttachementWidget(ui->moneyAttachementToolBar);
  ui->moneyAttachementToolBar->addWidget(MoneyAttachement);

  FileAttachment = new TFileAttachmentWidget(ui->fileAttachementToolBar, editMode);
  ui->fileAttachementToolBar->addWidget(FileAttachment);

  MailFields = new MailFieldsWidget(*this, *ui->actionSend, abModel, editMode);

  /// Initially only basic mail fields (To: and Subject:) should be visible
  MailFields->showCcControls(false);
  MailFields->showBccControls(false);

  ui->mailFieldsToolBar->addWidget(MailFields);

  connect(MailFields, SIGNAL(subjectChanged(QString)), this, SLOT(onSubjectChanged(QString)));
  connect(MailFields, SIGNAL(recipientListChanged()), this, SLOT(onRecipientListChanged()));
  connect(FileAttachment, SIGNAL(attachmentListChanged()), this, SLOT(onAttachmentListChanged()));

  if(editMode)
    {
    /** Supplement definition of mailFieldSelectorToolbar since Qt Creator doesn't support putting
        into its context dedicated controls (like preconfigured toolbutton).

        Setup local menu for 'actionMailFields' toolButton (used to enable/disable additional mail
        field selection).
    */
    QMenu* mailFieldsMenu = new QMenu(this);
    mailFieldsMenu->addAction(ui->actionFrom);
    mailFieldsMenu->addAction(ui->actionCC);
    mailFieldsMenu->addAction(ui->actionBCC);

    /// Update state of sub-menu commands.
    ui->actionBCC->setChecked(MailFields->isFieldVisible(MailFieldsWidget::BCC_FIELDS));
    ui->actionCC->setChecked(MailFields->isFieldVisible(MailFieldsWidget::CC_FIELD));
    ui->actionFrom->setChecked(MailFields->isFieldVisible(MailFieldsWidget::FROM_FIELD));

    ui->actionMailFields->setMenu(mailFieldsMenu);
    ui->mainToolBar->insertAction(ui->actionShowFormatOptions, ui->actionMailFields);
    }

  setupEditorCommands();

  ui->messageEdit->setFocus();
  fontChanged(ui->messageEdit->font());
  colorChanged(ui->messageEdit->textColor());
  alignmentChanged(ui->messageEdit->alignment());

  QString subject = MailFields->getSubject();
  onSubjectChanged(subject);
  
  /// Clear modified flag
  ui->messageEdit->document()->setModified(false);
  setWindowModified(ui->messageEdit->document()->isModified());
  
  ui->actionSave->setEnabled(ui->messageEdit->document()->isModified());
  ui->actionUndo->setEnabled(ui->messageEdit->document()->isUndoAvailable());
  ui->actionRedo->setEnabled(ui->messageEdit->document()->isRedoAvailable());

  /// Setup command update ui related to 'save' option activity control and window modify marker.
  connect(ui->messageEdit->document(), SIGNAL(modificationChanged(bool)), ui->actionSave,
    SLOT(setEnabled(bool)));
  connect(ui->messageEdit->document(), SIGNAL(modificationChanged(bool)), this,
    SLOT(setWindowModified(bool)));
  connect(ui->messageEdit, SIGNAL(addAttachments(QStringList)), this, SLOT(onAddAttachments(QStringList)));

#ifndef QT_NO_CLIPBOARD
  connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(onClipboardDataChanged()));
#endif

  toggleReadOnlyMode();
  }
예제 #12
0
void
AttachmentModel::replaceAttachments(QList<AttachmentPtr> const &newAttachments) {
  reset();
  addAttachments(newAttachments);
}
예제 #13
0
void
Tab::onAddAttachments() {
  auto fileNames = selectAttachmentsToAdd();
  if (!fileNames.isEmpty())
    addAttachments(fileNames);
}