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


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

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


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

示例1: urlFocusedDocument

bool subversionPart::urlFocusedDocument( KURL &url ) {
	KParts::ReadOnlyPart *part = dynamic_cast<KParts::ReadOnlyPart*>( partController()->activePart() );
	if ( part ) {
		if (part->url().isLocalFile() ) {
			url = part->url();
			return true;
		}
	}
	return false;
}
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:10,代码来源:subversion_part.cpp

示例2: slotExecuteShellCommand

void KShellCmdPlugin::slotExecuteShellCommand()
{
    KParts::ReadOnlyPart *part = qobject_cast<KParts::ReadOnlyPart *>(parent());
    if (!part)  {
        KMessageBox::sorry(0L, i18n("KShellCmdPlugin::slotExecuteShellCommand: Program error, please report a bug."));
        return;
    }

    KUrl url = KIO::NetAccess::mostLocalUrl(part->url(), NULL);
    if (!url.isLocalFile()) {
        KMessageBox::sorry(part->widget(), i18n("Executing shell commands works only on local directories."));
        return;
    }

    QString path;
    KParts::FileInfoExtension *ext = KParts::FileInfoExtension::childObject(part);

    if (ext && ext->hasSelection() && (ext->supportedQueryModes() & KParts::FileInfoExtension::SelectedItems)) {
        KFileItemList list = ext->queryFor(KParts::FileInfoExtension::SelectedItems);
        QStringList fileNames;
        Q_FOREACH (const KFileItem &item, list) {
            fileNames << item.name();
        }
        path = KShell::joinArgs(fileNames);
    }
开发者ID:KDE,项目名称:kde-baseapps,代码行数:25,代码来源:kshellcmdplugin.cpp

示例3: slotExecuteShellCommand

void KShellCmdPlugin::slotExecuteShellCommand()
{
    KParts::ReadOnlyPart * part = dynamic_cast<KParts::ReadOnlyPart *>(parent());
    if ( !part )
    {
        KMessageBox::sorry(0L, i18n("KShellCmdPlugin::slotExecuteShellCommand: Program error, please report a bug."));
        return;
    }
    KUrl url = KIO::NetAccess::mostLocalUrl(part->url(),NULL);
    if ( !url.isLocalFile() )
    {
        KMessageBox::sorry(part->widget(),i18n("Executing shell commands works only on local directories."));
        return;
    }
    QString path;
#if 0 // to be ported if still needed
    if ( part->currentItem() )
    {
        // Putting the complete path to the selected file isn't really necessary,
        // since we'll cd to the directory first. But we do need to get the
        // complete relative path.
        path = KUrl::relativePath( url.path(),
                                   part->currentItem()->url().path() );
    }
    else
#endif
    {
        path = url.toLocalFile();
    }
   bool ok;
   QString cmd = KInputDialog::getText( i18nc("@title:window", "Execute Shell Command"),
      i18n( "Execute shell command in current directory:" ),
      KShell::quoteArg( path ), &ok, part->widget() );
   if ( ok )
   {
      QString chDir;
      chDir="cd ";
      chDir+=KShell::quoteArg(part->url().path());
      chDir+="; ";
      chDir+=cmd;

      KShellCommandDialog *shellCmdDialog=new KShellCommandDialog(i18n("Output from command: \"%1\"", cmd),chDir,part->widget(),true);
      shellCmdDialog->resize(500,300);
      shellCmdDialog->executeCommand();
      delete shellCmdDialog;
   }
}
开发者ID:vishesh,项目名称:kde-baseapps,代码行数:47,代码来源:kshellcmdplugin.cpp

示例4: currentFile

QString PerforcePart::currentFile()
{
    KParts::ReadOnlyPart *part = dynamic_cast<KParts::ReadOnlyPart*>( partController()->activePart() );
    if ( part ) {
        KURL url = part->url();
        if ( url.isLocalFile() )
            return url.path();
    }
    return QString::null;
}
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:10,代码来源:perforcepart.cpp

示例5: slotSwitchToView

void RubySupportPart::slotSwitchToView()
{
    KParts::Part *activePart = partController()->activePart();
    if (!activePart)
        return;
    KParts::ReadOnlyPart *ropart = dynamic_cast<KParts::ReadOnlyPart*>(activePart);
    if (!ropart)
        return;
    QFileInfo file(ropart->url().path());
    if (!file.exists())
        return;
    QString ext = file.extension();
    QString name = file.baseName();
    QString switchTo = "";

    if (ext == "rjs" || ext == "rxml" || ext == "rhtml" || ext == "js.rjs" || ext == "xml.builder" || ext == "html.erb")
    {
        //this is a view already, let's show the list of all views for this model
        switchTo = file.dir().dirName();
    }
    else if (ext == "rb")
        switchTo = name.remove(QRegExp("_controller$")).remove(QRegExp("_controller_test$")).remove(QRegExp("_test$"));

    if (switchTo.isEmpty())
        return;

    if (switchTo.endsWith("s"))
        switchTo = switchTo.mid(0, switchTo.length() - 1);

    KURL::List urls;
    QDir viewsDir;
    QDir viewsDirS = QDir(project()->projectDirectory() + "/app/views/" + switchTo);
    QDir viewsDirP = QDir(project()->projectDirectory() + "/app/views/" + switchTo + "s");
    if (viewsDirS.exists())
        viewsDir = viewsDirS;
    else if (viewsDirP.exists())
        viewsDir = viewsDirP;
    else
        return;

    QStringList views = viewsDir.entryList();

    for (QStringList::const_iterator it = views.begin(); it != views.end(); ++it)
    {
        QString viewName = *it;
        if ( !(viewName.endsWith("~") || viewName == "." || viewName == "..") )
            urls << KURL::fromPathOrURL(viewsDir.absPath() + "/" + viewName);
    }
    KDevQuickOpen *qo = extension<KDevQuickOpen>("KDevelop/QuickOpen");
    if (qo)
        qo->quickOpenFile(urls);
}
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:52,代码来源:rubysupport_part.cpp

示例6: slotSwitchToTest

void RubySupportPart::slotSwitchToTest()
{
    KParts::Part *activePart = partController()->activePart();
    if (!activePart)
        return;
    KParts::ReadOnlyPart *ropart = dynamic_cast<KParts::ReadOnlyPart*>(activePart);
    if (!ropart)
        return;
    QFileInfo file(ropart->url().path());
    if (!file.exists())
        return;
    QString ext = file.extension();
    QString name = file.baseName();
    QString switchTo = "";

    if (ext == "rjs" || ext == "rxml" || ext == "rhtml" || ext == "js.rjs" || ext == "xml.builder" || ext == "html.erb")
    {
        //this is a view already, let's show the list of all views for this model
        switchTo = file.dir().dirName();
    }
    else if (ext == "rb")
        switchTo = name.remove(QRegExp("_controller$")).remove(QRegExp("_controller_test$")).remove(QRegExp("_test$"));

    if (switchTo.isEmpty())
        return;

    if (switchTo.endsWith("s"))
        switchTo = switchTo.mid(0, switchTo.length() - 1);

    KURL::List urls;
    QString testDir = project()->projectDirectory() + "/test/";
    QString functionalTestS = testDir + "functional/" + switchTo + "_controller_test.rb";
    QString functionalTestP = testDir + "functional/" + switchTo + "s_controller_test.rb";
    QString integrationTestS = testDir + "integration/" + switchTo + "_test.rb";
    QString integrationTestP = testDir + "integration/" + switchTo + "s_test.rb";
    QString unitTestS = testDir + "unit/" + switchTo + "_test.rb";
    QString unitTestP = testDir + "unit/" + switchTo + "s_test.rb";
    if (QFile::exists(functionalTestP)) urls << KURL::fromPathOrURL(functionalTestP);
    if (QFile::exists(integrationTestP)) urls << KURL::fromPathOrURL(integrationTestP);
    if (QFile::exists(unitTestP)) urls << KURL::fromPathOrURL(unitTestP);
    if (QFile::exists(functionalTestS)) urls << KURL::fromPathOrURL(functionalTestS);
    if (QFile::exists(integrationTestS)) urls << KURL::fromPathOrURL(integrationTestS);
    if (QFile::exists(unitTestS)) urls << KURL::fromPathOrURL(unitTestS);

    KDevQuickOpen *qo = extension<KDevQuickOpen>("KDevelop/QuickOpen");
    if (qo && !urls.isEmpty())
        qo->quickOpenFile(urls);
}
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:48,代码来源:rubysupport_part.cpp

示例7: slotRefresh

void AutoRefresh::slotRefresh()
{
    KParts::ReadOnlyPart *part = qobject_cast< KParts::ReadOnlyPart * >( parent() );
    if ( !part ) {
        QString title = i18nc( "@title:window", "Cannot Refresh Source" );
        QString text = i18n( "<qt>This plugin cannot auto-refresh the current part.</qt>" );

        KMessageBox::error( 0, text, title );
    }
    else
    {
        // Get URL
        KUrl url = part->url();
        part->openUrl( url );
    }
}
开发者ID:blue-shell,项目名称:folderview,代码行数:16,代码来源:autorefresh.cpp

示例8: slotRefresh

void AutoRefresh::slotRefresh()
{
    if ( !parent()->inherits("KParts::ReadOnlyPart") ) {
        QString title = i18n( "Cannot Refresh Source" );
        QString text = i18n( "<qt>This plugin cannot auto-refresh the current part.</qt>" );
 
        QMessageBox::warning( 0, title, text );
    }
    else
    {
        KParts::ReadOnlyPart *part = (KParts::ReadOnlyPart *) parent();

        // Get URL
        KURL url = part->url();
        part->openURL( url );
    }
}
开发者ID:iegor,项目名称:kdesktop,代码行数:17,代码来源:autorefresh.cpp

示例9: slotSwitchToController

void RubySupportPart::slotSwitchToController()
{
    KParts::Part *activePart = partController()->activePart();
    if (!activePart)
        return;
    KParts::ReadOnlyPart *ropart = dynamic_cast<KParts::ReadOnlyPart*>(activePart);
    if (!ropart)
        return;
    QFileInfo file(ropart->url().path());
    if (!file.exists())
        return;
    QString ext = file.extension();
    QString name = file.baseName();
    QString switchTo = "";
    if ((ext == "rb") && !name.endsWith("_controller"))
    {
        if (name.endsWith("_test"))
        {
            switchTo = name.remove(QRegExp("_test$"));  //the file is the test
            switchTo = name.remove(QRegExp("_controller$"));  //remove functional test name parts
        }
        else
            switchTo = name;
    }
    else if (ext == "rjs" || ext == "rxml" || ext == "rhtml" || ext == "js.rjs" || ext == "xml.builder" || ext == "html.erb")
    {
        //this is a view, we need to find the directory of this view and try to find
        //the controller basing on the directory information
        switchTo = file.dir().dirName();
    }
    QString controllersDir = project()->projectDirectory() + "/app/controllers/";
    if (!switchTo.isEmpty())
    {
        if (switchTo.endsWith("s"))
            switchTo = switchTo.mid(0, switchTo.length()-1);
        QString singular = controllersDir + switchTo + "_controller.rb";
        QString plural = controllersDir + switchTo + "s_controller.rb";
        KURL url = KURL::fromPathOrURL(QFile::exists(singular) ? singular : plural);
        partController()->editDocument(url);
    }
}
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:41,代码来源:rubysupport_part.cpp

示例10: slotSwitchToModel

void RubySupportPart::slotSwitchToModel()
{
    KParts::Part *activePart = partController()->activePart();
    if (!activePart)
        return;
    KParts::ReadOnlyPart *ropart = dynamic_cast<KParts::ReadOnlyPart*>(activePart);
    if (!ropart)
        return;
    QFileInfo file(ropart->url().path());
    if (!file.exists())
        return;
    QString ext = file.extension();
    QString name = file.baseName();
    QString switchTo = "";

    if (ext == "rjs" || ext == "rxml" || ext == "rhtml" || ext == "js.rjs" || ext == "xml.builder" || ext == "html.erb")
    {
        //this is a view already, let's show the list of all views for this model
        switchTo = file.dir().dirName();
    }
    else if (ext == "rb" && (name.endsWith("_controller") || name.endsWith("_test")))
    {
        switchTo = name.remove(QRegExp("_controller$")).remove(QRegExp("_controller_test$")).remove(QRegExp("_test$"));
    }

    if (switchTo.isEmpty())
        return;

    if (switchTo.endsWith("s"))
        switchTo = switchTo.mid(0, switchTo.length() - 1);

    QString modelsDir = project()->projectDirectory() + "/app/models/";
    QString singular = modelsDir + switchTo + "_controller.rb";
    QString plural = modelsDir + switchTo + "s_controller.rb";
    KURL url = KURL::fromPathOrURL(QFile::exists(singular) ? singular : plural);

    partController()->editDocument(KURL::fromPathOrURL(modelsDir + switchTo + ".rb"));
}
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:38,代码来源:rubysupport_part.cpp

示例11: saveToFile

//---------------------------------------------------------------------------
bool ProjectSession::saveToFile( const QString & sessionFileName, const QValueList< KDevPlugin * > plugins )
{
  QString section, keyword;
  QDomElement session = domdoc.documentElement();

  int nDocs = 0;
  QString docIdStr;

////  // read the information about the mainframe widget
////  QDomElement mainframeEl = session.namedItem("Mainframe").toElement();
////  if(mainframeEl.isNull()){
////    mainframeEl=domdoc.createElement("Mainframe");
////    session.appendChild( mainframeEl);
////  }
////  bool bMaxMode = ((QextMdiMainFrm*)m_pDocViewMan->parent())->isInMaximizedChildFrmMode();
////  mainframeEl.setAttribute("MaximizeMode", bMaxMode);


  // read the information about the documents
  QDomElement docsAndViewsEl = session.namedItem("DocsAndViews").toElement();
  if (docsAndViewsEl.isNull()) {
    docsAndViewsEl = domdoc.createElement("DocsAndViews");
    session.appendChild( docsAndViewsEl);
  }
  else {
    // we need to remove the old ones before memorizing the current ones (to avoid merging)
    QDomNode n = docsAndViewsEl.firstChild();
    while ( !n.isNull() ) {
      QDomNode toBeRemoved = n;
      n = n.nextSibling();
      docsAndViewsEl.removeChild(toBeRemoved);
    }
  }

	QPtrListIterator<KParts::Part> it( *PartController::getInstance()->parts() );
	for ( ; it.current(); ++it )
	{

		KParts::ReadOnlyPart* pReadOnlyPart = dynamic_cast<KParts::ReadOnlyPart*>(it.current());
		if (!pReadOnlyPart)
			continue;

		QString url = pReadOnlyPart->url().url();

		docIdStr.setNum(nDocs);
		QDomElement docEl = domdoc.createElement("Doc" + docIdStr);
		docEl.setAttribute( "URL", url);
		docsAndViewsEl.appendChild( docEl);
		nDocs++;
		docEl.setAttribute( "NumberOfViews", 1);

		QDomElement viewEl = domdoc.createElement( "View0");
		docEl.appendChild( viewEl);

		if ( dynamic_cast<HTMLDocumentationPart*>(pReadOnlyPart) )
		{
			viewEl.setAttribute("Type", "Documentation");
		}
		else if ( pReadOnlyPart->inherits("KTextEditor::Document") )
		{
			viewEl.setAttribute("Type", "Source");
			KTextEditor::ViewCursorInterface *iface = dynamic_cast<KTextEditor::ViewCursorInterface*>(pReadOnlyPart->widget());
			if (iface) {
				unsigned int line, col;
				iface->cursorPosition(&line, &col);
				viewEl.setAttribute( "line", line );
			}
			if ( KTextEditor::EncodingInterface * ei = dynamic_cast<KTextEditor::EncodingInterface*>( pReadOnlyPart ) )
			{
				QString encoding = ei->encoding();
				if ( !encoding.isNull() )
				{
					viewEl.setAttribute( "Encoding", encoding );
				}
			}
		}
		else
		{
			viewEl.setAttribute("Type", "Other");
		}
	}

/*
  QPtrListIterator<KParts::Part> it( *PartController::getInstance()->parts() );
  for ( ; it.current(); ++it ) {
////    QString partName = it.current()->name();
////    QMessageBox::information(0L,"",partName);

    KParts::ReadOnlyPart* pReadOnlyPart = dynamic_cast<KParts::ReadOnlyPart*>(it.current());
    if (!pReadOnlyPart)
      continue; // note: read-write parts are also a read-only part, they inherit from it

    HTMLDocumentationPart* pDocuPart = dynamic_cast<HTMLDocumentationPart*>(pReadOnlyPart);

    /// @todo Save relative path for project sharing?
    QString url = pReadOnlyPart->url().url();

    docIdStr.setNum(nDocs);
    QDomElement docEl = domdoc.createElement("Doc" + docIdStr);
//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:101,代码来源:projectsession.cpp


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