当前位置: 首页>>代码示例>>C++>>正文


C++ ProjectViewItem::url方法代码示例

本文整理汇总了C++中ProjectViewItem::url方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectViewItem::url方法的具体用法?C++ ProjectViewItem::url怎么用?C++ ProjectViewItem::url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectViewItem的用法示例。


在下文中一共展示了ProjectViewItem::url方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: slotClicked

void ProjectView::slotClicked(QTreeWidgetItem *item)
{
	if(!item) {
		item = currentItem();
	}

	ProjectViewItem *itm = static_cast<ProjectViewItem*>(item);
	if(itm) {
		if(itm->type() == KileType::File) {
			emit(fileSelected(itm->url()));
		}
		else if(itm->type() == KileType::ProjectItem) {
			emit(fileSelected(itm->projectItem()));
		}
		else if(itm->type() != KileType::Folder) {
			// don't open project configuration files (*.kilepr)
			if(itm->url().toLocalFile().right(7) != ".kilepr") {
				//determine mimeType and open file with preferred application
				KMimeType::Ptr pMime = KMimeType::findByUrl(itm->url());
				if(pMime->name().startsWith("text/")) {
					emit(fileSelected(itm->url()));
				}
				else {
					KRun::runUrl(itm->url(), pMime->name(), this);
				}
			}
		}
		clearSelection();
	}
}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:30,代码来源:projectview.cpp

示例2: folder

ProjectViewItem* ProjectView::folder(const KileProjectItem *pi, ProjectViewItem *item)
{
	ProjectViewItem *parent = parentFor(pi, item);

	if(!parent) {
		kError() << "no parent for " << pi->url().toLocalFile();
		return NULL;
	}

	// we have already found the parent folder
	if(parent->type() == KileType::Folder) {
		return parent;
	}

	// we are looking at the children, if there is an existing folder for this type
	ProjectViewItem *folder;

	// determine the foldername for this type
	QString foldername;
	switch(pi->type()) {
		case (KileProjectItem::ProjectFile):
			foldername = i18n("projectfile");
		break;
		case (KileProjectItem::Package):
			foldername = i18n("packages");
		break;
		case (KileProjectItem::Image):
			foldername = i18n("images");
		break;
		case (KileProjectItem::Other):
		default :
			foldername = i18n("other");
		break;
	}

	// if there already a folder for this type on this level?
	bool found = false;
	QTreeWidgetItemIterator it(parent);
	++it; // skip 'parent'
	while(*it) {
		folder = dynamic_cast<ProjectViewItem*>(*it);
		if(folder && folder->text(0) == foldername) {
			found = true;
			break;
		}
		++it;
	}
	
	// if no folder was found, we must create a new one
	if(!found) {
		folder = new ProjectViewItem(parent, foldername);
		KILE_DEBUG() << "new folder: parent=" << parent->url().url()
		             << ", foldername=" << foldername;

		folder->setFolder(pi->type());
		folder->setType(KileType::Folder);
	}

	return folder;
}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:60,代码来源:projectview.cpp

示例3: slotRun

void ProjectView::slotRun(int id)
{
	ProjectViewItem *itm = dynamic_cast<ProjectViewItem*>(currentItem());

	if(!itm) {
		return;
	}

	if(id == 0) {
		KRun::displayOpenWithDialog(itm->url(), this);
	}
	else {
		KRun::run(*m_offerList[id-1], itm->url(), this);
	}

	itm->setSelected(false);
}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:17,代码来源:projectview.cpp

示例4: contextMenuEvent

void ProjectView::contextMenuEvent(QContextMenuEvent *event)
{
	QSignalMapper signalMapper, serviceSignalMapper;
	QMenu popup;
	QAction *action = Q_NULLPTR;

	QTreeWidgetItem* treeWidgetItem = itemAt(event->pos());
	if(!treeWidgetItem) {
		return;
	}

	ProjectViewItem *projectViewItem = dynamic_cast<ProjectViewItem*>(treeWidgetItem);
	if(!projectViewItem) {
		return;
	}

	if(projectViewItem->type() == KileType::Folder) {
		return;
	}

	bool insertsep = false;
	bool isKilePrFile = false;
	if(projectViewItem->type() != KileType::Project && projectViewItem->projectItem()
	                                                && projectViewItem->projectItem()->project()) {
		isKilePrFile = projectViewItem->projectItem()->project()->url() == projectViewItem->url();
	}

	if(projectViewItem->type() == KileType::ProjectExtra && !isKilePrFile) {
		QMenu *servicesMenu = popup.addMenu(QIcon::fromTheme("fork"), i18n("&Open With"));
		connect(&serviceSignalMapper, SIGNAL(mapped(int)), this, SLOT(slotRun(int)));
QMimeDatabase db;
		m_offerList = KMimeTypeTrader::self()->query(db.mimeTypeForUrl(projectViewItem->url()).name(), "Application");
		for (int i = 0; i < m_offerList.count(); ++i) {
			action = new QAction(servicesMenu);
			action->setIcon(QIcon::fromTheme(m_offerList[i]->icon()));
			action->setText(m_offerList[i]->name());
			connect(action, SIGNAL(triggered()), &serviceSignalMapper, SLOT(map()));
			serviceSignalMapper.setMapping(action, i + 1);
			servicesMenu->addAction(action);
		}

		servicesMenu->addSeparator();
		action = servicesMenu->addAction(i18n("Other..."), &serviceSignalMapper, SLOT(map()));
		serviceSignalMapper.setMapping(action, 0);
		insertsep = true;
	}
开发者ID:KDE,项目名称:kile,代码行数:46,代码来源:projectview.cpp

示例5: remove

/**
 * Removes a file from the projectview, does not remove project-items. Only files without a project.
 **/
void ProjectView::remove(const KUrl &url)
{
	for(int i = 0; i < topLevelItemCount(); ++i) {
		ProjectViewItem *item = dynamic_cast<ProjectViewItem*>(topLevelItem(i));

		if(item && (item->type() == KileType::File) && (item->url() == url)) {
			item->setParent(NULL);
			delete item;
			break;
		}
	}
}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:15,代码来源:projectview.cpp

示例6: slotProject

void ProjectView::slotProject(int id)
{
	ProjectViewItem *item = dynamic_cast<ProjectViewItem*>(currentItem());
	if(item) {
		if(item->type() == KileType::Project) {
			switch(id) {
				case KPV_ID_BUILDTREE:
					emit(buildProjectTree(item->url()));
				break;
				case KPV_ID_OPTIONS:
					emit(projectOptions(item->url()));
				break;
				case KPV_ID_CLOSE:
					emit(closeProject(item->url()));
				return; //don't access "item" later on
				case KPV_ID_ARCHIVE:
					emit(projectArchive(item->url()));
				break;
				case KPV_ID_ADDFILES:
					emit(addFiles(item->url()));
				break;
				case KPV_ID_OPENALLFILES:
					emit(openAllFiles(item->url()));
				break;
				default:
				break;
			}
		}
	}
}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:30,代码来源:projectview.cpp

示例7: itemFor

ProjectViewItem* ProjectView::itemFor(const KUrl & url)
{
	ProjectViewItem *item = NULL;

	QTreeWidgetItemIterator it(this);
	while(*it) {
		item = static_cast<ProjectViewItem*>(*it);
		if (item->url() == url) {
			break;
		}
		++it;
	}

	return item;
}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:15,代码来源:projectview.cpp

示例8: slotProjectItem

void ProjectView::slotProjectItem(int id)
{
	ProjectViewItem *item = dynamic_cast<ProjectViewItem*>(currentItem());
	if(item) {
		if(item->type() == KileType::ProjectItem || item->type() == KileType::ProjectExtra) {
			switch(id) {
				case KPV_ID_OPEN:
					emit(fileSelected(item->projectItem()));
				break;
				case KPV_ID_SAVE:
					emit(saveURL(item->url()));
				break;
				case KPV_ID_REMOVE:
					emit(removeFromProject(item->projectItem()));
				break;
				case KPV_ID_INCLUDE :
					if(item->text(1) == "*") {
						item->setText(1, "");
					}
					else {
						item->setText(1, "*");
					}
					emit(toggleArchive(item->projectItem()));
				break;
				case KPV_ID_CLOSE:
					emit(closeURL(item->url()));
				break; //we can access "item" later as it isn't deleted
				case KPV_ID_OPENWITH:
					KRun::displayOpenWithDialog(item->url(), this);
				break;
				default:
				break;
			}
		}
	}
}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:36,代码来源:projectview.cpp

示例9: slotFile

void ProjectView::slotFile(int id)
{
	ProjectViewItem *item = dynamic_cast<ProjectViewItem*>(currentItem());
	if(item) {
		if(item->type() == KileType::File) {
			switch(id) {
				case KPV_ID_OPEN: 
					emit(fileSelected(item->url()));
				break;
				case KPV_ID_SAVE:
					emit(saveURL(item->url()));
				break;
				case KPV_ID_ADD:
					emit(addToProject(item->url()));
				break;
				case KPV_ID_CLOSE:
					emit(closeURL(item->url()));
				return; //don't access "item" later on
				default:
				break;
			}
		}
	}
}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:24,代码来源:projectview.cpp

示例10: projectViewItemFor

ProjectViewItem* ProjectView::projectViewItemFor(const KUrl& url)
{
	ProjectViewItem *item = NULL;

	//find project view item
	QTreeWidgetItemIterator it(this);
	while(*it) {
		item = dynamic_cast<ProjectViewItem*>(*it);
		if(item && (item->type() == KileType::Project) && (item->url() == url)) {
			break;
		}
		++it;
	}

	return item;
}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:16,代码来源:projectview.cpp

示例11: add

void ProjectView::add(const KUrl& url)
{
	KILE_DEBUG() << "\tProjectView::adding item " << url.toLocalFile();
	//check if file is already present
	QTreeWidgetItemIterator it(this);
	ProjectViewItem *item;
	while(*it) {
		item = static_cast<ProjectViewItem*>(*it);
		if((item->type() != KileType::Project) && (item->url() == url)) {
			return;
		}
		++it;
	}

	item = new ProjectViewItem(this, url.fileName());
	item->setType(KileType::File);
	item->setURL(url);
	makeTheConnection(item);
}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:19,代码来源:projectview.cpp


注:本文中的ProjectViewItem::url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。