void CFolderView::OnFileActionRenamedNewName(TCHAR *szFileName)
{
	if(g_bNewFileRenamed)
	{
		/* The file that was previously added was renamed before
		it could be added. Add the file now. */
		OnFileActionAdded(szFileName);

		g_bNewFileRenamed = FALSE;
	}
	else
	{
		RenameItem(iRenamedItem,szFileName);
	}
}
Beispiel #2
0
void InventoryWindow::AddFolder()
{
    QModelIndex index = treeView_->selectionModel()->currentIndex();
    QAbstractItemModel *model = treeView_->model();

    inventoryItemModel_->Open(index);

    if (!inventoryItemModel_->InsertFolder(index.row(), index, "New Folder"))
        return;

    treeView_->selectionModel()->setCurrentIndex(model->index(0, 0, index), QItemSelectionModel::ClearAndSelect);
    UpdateActions();

    RenameItem();

    inventoryItemModel_->CheckTreeForDirtys();
}
Beispiel #3
0
	void Syncer::handleGotChanges (const QList<Change>& changes)
	{
		for (const auto& change : changes)
		{
			const auto& item = change.Item_;
			if (item.IsTrashed_)
				continue;

			const auto& id = change.ItemID_;
			const auto& parentId = change.Item_.ParentID_;

			if (change.Deleted_)
			{
				Id2Item_.remove (id);
				Id2Path_.left.erase (id);
			}
			else if (item.IsValid ())
			{
				QString path = (Id2Item_.contains (parentId) ?
					(Id2Path_.left.at (parentId) + "/") :
					QString ())
						+ item.Name_;
				if (Id2Path_.left.count (id))
				{
					if (Id2Item_ [id].Name_ != item.Name_)
						RenameItem (item, path);
				}
				else
					Id2Path_.insert ({ id, path });
				Id2Item_ [id] = item;
			}
		}

		if (!CallsQueue_.isEmpty ())
			CallsQueue_.dequeue () ();
	}
Beispiel #4
0
void InventoryWindow::CreateActions()
{
    /*
        itemMenu_ = new QMenu(this);
        fileTransferMenu_ = new QMenu(this);
        connect(actionMenu_, SIGNAL(aboutToShow()), this, SLOT(UpdateActions()));
    */
    // File transfer actions
    InventoryAction  *actionUpload= new InventoryAction(tr("&Upload"), treeView_);
    actionUpload->setObjectName("Upload");
    actionUpload->setStatusTip(tr("Upload file to your inventory"));
    connect(actionUpload, SIGNAL(triggered()), this, SLOT(Upload()));
    treeView_->addAction(actionUpload);

    InventoryAction *actionDownload = new InventoryAction(tr("&Download"), treeView_);
    actionDownload->setObjectName("Download");
    actionDownload->setStatusTip(tr("Download assets to your hard drive"));
    connect(actionDownload, SIGNAL(triggered()), this, SLOT(Download()));
    treeView_->addAction(actionDownload);

    // Add separator
    InventoryAction *actionSeparator = new InventoryAction(treeView_);
    actionSeparator->setSeparator(true);
    treeView_->addAction(actionSeparator);

    // Inventory item actions.
    InventoryAction  *actionDelete = new InventoryAction(tr("&Delete"), treeView_);
    actionDelete->setObjectName("Delete");
    //actionDelete_->setShortcuts(QKeySequence::Delete);
    actionDelete->setStatusTip(tr("Delete this item"));
    connect(actionDelete, SIGNAL(triggered()), this, SLOT(DeleteItem()));
    treeView_->addAction(actionDelete);

    InventoryAction *actionRename = new InventoryAction(tr("&Rename"), treeView_);
    actionRename->setObjectName("Rename");
    //actionRename_->setShortcuts();
    actionRename->setStatusTip(tr("Rename this item"));
    connect(actionRename, SIGNAL(triggered()), this, SLOT(RenameItem()));
    treeView_->addAction(actionRename);

    /*
        InventoryAction  *actionCut_ = new InventoryAction(tr("&Cut"), treeView_);
        actionDelete_->setShortcuts(QKeySequence::Cut);
        actionDelete_->setStatusTip(tr("Cut this item"));
        connect(actionCut_, SIGNAL(triggered()), this, SLOT(Test()));
        treeView_->addAction(actionCut_);

        InventoryAction  *actionPaste_ = new InventoryAction(tr("&Paste"), treeView_);
        actionDelete_->setShortcuts(QKeySequence::Paste);
        actionDelete_->setStatusTip(tr("Paste this item"));
        connect(actionPaste_, SIGNAL(triggered()), this, SLOT(Test()));
        treeView_->addAction(actionPaste_);
    */

    InventoryAction  *actionNewFolder = new InventoryAction(tr("&New folder"), treeView_);
    actionNewFolder->setObjectName("NewFolder");
    //actionDelete_->setShortcuts(QKeySequence::Delete);
    actionNewFolder->setStatusTip(tr("Create new folder"));
    connect(actionNewFolder, SIGNAL(triggered()), this, SLOT(AddFolder()));
    treeView_->addAction(actionNewFolder);

    InventoryAction *actionOpen = new InventoryAction(tr("&Open"), treeView_);
    actionOpen->setObjectName("Open");
    //actionDelete_->setShortcuts(QKeySequence::Delete);
    actionOpen->setStatusTip(tr("Open this item"));
    connect(actionOpen, SIGNAL(triggered()), this, SLOT(OpenItem()));
    treeView_->addAction(actionOpen);

    InventoryAction  *actionProperties= new InventoryAction(tr("&Properties"), treeView_);
    actionProperties->setObjectName("Properties");
    //actionProperties_->setShortcuts(QKeySequence::Delete);
    actionProperties->setStatusTip(tr("View item properties"));
    connect(actionProperties, SIGNAL(triggered()), this, SLOT(OpenItemProperties()));
    treeView_->addAction(actionProperties);

    InventoryAction *actionCopyAssetReference = new InventoryAction(tr("&Copy asset reference"), treeView_);
    actionCopyAssetReference->setObjectName("CopyAssetReference");
    //actionDelete_->setShortcuts(QKeySequence::Delete);
    actionCopyAssetReference->setStatusTip(tr("Copies asset reference to clipboard"));
    connect(actionCopyAssetReference, SIGNAL(triggered()), this, SLOT(CopyAssetReference()));
    treeView_->addAction(actionCopyAssetReference);
}
void CMyTreeView::DirectoryAlteredRenameFile(const TCHAR *szFullFileName)
{
	HTREEITEM hItem;
	HTREEITEM hDeskItem;

	/* If the item is on the desktop, it is a special case.
	   We need to update the treeview in two places:
	   1) the root item
	   2) the user's desktop folder if the tree is expanded to that folder
		  (i.e. c:\users\'username'\Desktop) */
	hDeskItem = LocateItemOnDesktopTree(m_szAlteredOldFileName);  

	if(hDeskItem != NULL)
	{
		// Update root item
		RenameItem(hDeskItem,szFullFileName);
	}

	/* Check if the file currently exists in the treeview. */
	hItem = LocateItemByPath(m_szAlteredOldFileName,FALSE);

	if(hItem != NULL)
	{
		RenameItem(hItem,szFullFileName);

		/* Notify the parent that the selected item (or one of its ancestors)
		has been renamed. */
		HTREEITEM hSelection = TreeView_GetSelection(m_hTreeView);
		HTREEITEM hAncestor = hSelection;

		while(hAncestor != hItem && hAncestor != NULL) 
		{
			hAncestor = TreeView_GetParent(m_hTreeView,hAncestor);
		} 

		if(hAncestor == hItem)
		{
			TVITEM tvSelected;

			tvSelected.mask		= TVIF_PARAM;
			tvSelected.hItem	= hSelection;
			BOOL bRes = TreeView_GetItem(m_hTreeView,&tvSelected);

			HWND hParent = GetParent(m_hTreeView);

			if(bRes && hParent != NULL)
			{
				NMTREEVIEW nmtv;

				nmtv.hdr.code	= TVN_SELCHANGED;
				nmtv.action		= TVC_UNKNOWN;
				nmtv.itemNew	= tvSelected;

				/* TODO: Switch to custom notification. */
				SendMessage(hParent,WM_NOTIFY,0,reinterpret_cast<LPARAM>(&nmtv));
			}
		}
	}

	if(!hDeskItem && !hItem)
	{
		BOOL bFound = FALSE;

		/* Search through the queue of file additions
		and modifications for this file. */
		for(auto itr = m_AlteredTrackingList.begin();itr != m_AlteredTrackingList.end();itr++)
		{
			if(lstrcmp(m_szAlteredOldFileName,itr->szFileName) == 0)
			{
				/* Item has been found. Change the name on the
				notification and push it back into the list.
				Note: The item must be pushed directly after the current item. */
				StringCchCopy(itr->szFileName,SIZEOF_ARRAY(itr->szFileName),
					szFullFileName);

				for(auto itrAltered = m_AlteredList.begin();itrAltered != m_AlteredList.end();itrAltered++)
				{
					if(itrAltered->dwAction == FILE_ACTION_RENAMED_NEW_NAME &&
						lstrcmp(itrAltered->szFileName,szFullFileName) == 0)
					{
						m_AlteredList.insert(++itrAltered,*itr);
						break;
					}
				}

				m_AlteredTrackingList.erase(itr);

				bFound = TRUE;
				break;
			}
		}

		/* This may happen if a file has been
		renamed twice in a row, or renamed then deleted.
		e.g.
		1.txt (Existing file) -> 2.txt
		2.txt -> 3.txt
		
		Notifications:
		old name/new name - 1.txt/2.txt
		old name/new name - 2.txt/3.txt
		Need to remember the original filename.
		e.g. Need to be able to go from 1.txt to 3.txt. */
		if(!bFound)
		{
			/* TODO: Change the filename on the renamed action and push it
			back into the queue. */
		}
	}
}