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


C++ KActionCollection::count方法代码示例

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


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

示例1: setupShourtcutTips

void Core::setupShourtcutTips(KXMLGUIClient * client)
{
  QPtrList<KXMLGUIClient> clients;
  if (client != 0)
    clients.append(client);
  else
    clients = TopLevel::getInstance()->main()->guiFactory()->clients();
  
  for( QPtrListIterator<KXMLGUIClient> it(clients); it.current(); ++it ) {
    KActionCollection *actionCollection = (*it)->actionCollection();
    for (int i = 0; i < actionCollection->count(); i++) {
      KAction *action = actionCollection->action(i);
            
      QString tooltip = action->toolTip();
      if (tooltip.isEmpty())
        tooltip = action->text().remove('&');
      else {
        int i = tooltip.findRev('(');
        if (i > 0) tooltip = tooltip.left(i).stripWhiteSpace();
      }

      QString shortcut = action->shortcutText();
      if (!shortcut.isEmpty())
        tooltip += " (" + shortcut + ")";
        action->setToolTip(tooltip);
      }
  }
}
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:28,代码来源:core.cpp

示例2: initContextMenu

void MainWindow::initContextMenu() {
    m_contextMenu->clear();
    //load helper actions (copied from kdetraystatus.cpp, with slight modification)
    //TODO: add a new function in m_defaultActionCollection to handle this?
    KActionCollection * helperActioncol = m_defaultActionCollection->helperActionCollection();
    if ( helperActioncol->count() ) {
        for(size_t i=0; i<helperActioncol->count();i++) {
            helperActioncol->action(i)->plug(m_contextMenu);
        }
        m_contextMenu->insertSeparator();
    }

    m_toggleDockingAction->plug(m_contextMenu);

    KAction* configureaction = m_defaultActionCollection->action( "configure" );
    if(configureaction)
        configureaction->plug(m_contextMenu);

    KAction* helpAction = m_defaultActionCollection->action( "help" );
    if(helpAction)
        helpAction->plug(m_contextMenu);
}
开发者ID:scim-im,项目名称:skim,代码行数:22,代码来源:mainwindow.cpp

示例3: slotShortcutCaptured

void ActionConfigDialog::slotShortcutCaptured(const KShortcut &shortcut)
{
  QString shortcutText = shortcut.toString();
  QString shortcutText2;
  int pos = shortcutText.find(';');
  if (pos != -1)
  {
    shortcutText2 = shortcutText.mid(pos + 1);
    shortcutText = shortcutText.left(pos);
  }
  QString s = shortcutText;
  s.replace('+', "\\+");
  QRegExp shortcutRx("\\(" + s + "\\)|" + s + "$|" + s + ";");
  s = shortcutText2;
  s.replace('+', "\\+");
  QRegExp shortcutRx2("\\(" + s + "\\)|" + s + "$|" + s + ";");
  QString global;
//check for conflicting global shortcuts
  QMap<QString, QString>::Iterator it;
  for ( it = globalShortcuts.begin(); it != globalShortcuts.end(); ++it )
  {
    if (it.data().contains(shortcutRx))
    {
      global = it.key();
      break;
    }
    if (!shortcutText2.isEmpty() && it.data().contains(shortcutRx2))
    {
      shortcutText = shortcutText2;
      global = it.key();
      break;
    }
  }

  if (global.isEmpty())
  {
    QPtrList<KXMLGUIClient> clients = m_mainWindow->guiFactory()->clients();
    for( QPtrListIterator<KXMLGUIClient> it( clients ); it.current(); ++it )
    {
        KActionCollection *ac = (*it)->actionCollection();
        for (uint i = 0; i < ac->count(); i++)
        {
          KAction *action = ac->action(i);
          if (action != currentAction && action->shortcut().toString().contains(shortcutRx))
          {
            global = action->text();
            break;
          }
          if (!shortcutText2.isEmpty() && action != currentAction &&  action->shortcut().toString().contains(shortcutRx))
          {
            shortcutText = shortcutText2;
            global = action->text();
            break;
          }
        }
         if (!global.isEmpty())
           break;
      }
  }

  if (global.isEmpty())
  {
    shortcutKeyButton->setText(shortcutText);
    buttonApply->setEnabled(true);
    selectedShortcut = shortcut;
  } else
  {
    global.replace('&',"");
    QString s =  i18n("The '%1' key combination has already been allocated "
                "to the \"%2\" action.\n"
                "Please choose a unique key combination.").
                arg(shortcutText).arg(global);
    KMessageBox::sorry( this, s, i18n("Conflicting Shortcuts"));
  }
}
开发者ID:serghei,项目名称:kde3-kdewebdev,代码行数:75,代码来源:actionconfigdialog.cpp

示例4: r

ActionConfigDialog::ActionConfigDialog(const QDict<ToolbarEntry> &toolbarList, KMainWindow* parent, const char* name, bool modal, WFlags fl, const QString& defaultAction )
    :ActionConfigDialogS( parent, name, modal, fl )
{
  m_mainWindow = parent;
  m_toolbarList = toolbarList;
  buttonOk->setIconSet(SmallIconSet("button_ok"));
  buttonCancel->setIconSet(SmallIconSet("button_cancel"));
  buttonApply->setIconSet(SmallIconSet("apply"));
  //buttonHelp->setIconSet(SmallIconSet("help"));

  currentAction = 0L;
  m_toolbarItem = 0L;

  connect(actionTreeView, SIGNAL(contextMenu(KListView *,QListViewItem *,const QPoint &)),
                          SLOT(slotContextMenu(KListView *,QListViewItem *,const QPoint &)));
  connect(actionTreeView, SIGNAL(selectionChanged(QListViewItem *)),
                          SLOT(slotSelectionChanged(QListViewItem *)));
  connect(shortcutKeyButton, SIGNAL(capturedShortcut(const KShortcut &)),
                             SLOT(slotShortcutCaptured(const KShortcut &)));
  connect(scriptPath, SIGNAL(activated(const QString&)),
                      SLOT(slotTextChanged(const QString&)));
  connect(this, SIGNAL(addToolbar()), m_mainWindow, SLOT(slotAddToolbar()));
  connect(this, SIGNAL(removeToolbar(const QString&)), m_mainWindow, SLOT(slotRemoveToolbar(const QString&)));
  connect(this, SIGNAL(deleteUserAction(KAction*)), m_mainWindow, SLOT(slotDeleteAction(KAction*)));
  connect(this, SIGNAL(configureToolbars(const QString&)), m_mainWindow, SLOT(slotConfigureToolbars(const QString&)));
//fill up the tree view with the toolbars and actions
  actionTreeView->setSorting(-1);
  allActionsItem = new KListViewItem(actionTreeView, i18n("All"));
  actionTreeView->insertItem(allActionsItem);
  QListViewItem *item, *oldItem = allActionsItem;
  KAction *action;
  QString toolbarName;
  QString toolbarId;
  ToolbarTabWidget *tb = ToolbarTabWidget::ref();
  QRegExp r("\\&(?!\\&)");
  KActionCollection *ac = m_mainWindow->actionCollection();
  for (int i = 0; i < tb->count(); i++)
  {
    toolbarName = tb->label(i);
    toolbarName.replace(r, "");
    item = new KListViewItem(actionTreeView, oldItem, i18n(toolbarName.utf8()));
    actionTreeView->insertItem(item);

    toolbarId = tb->id(i);
    QListViewItem *oldActionItem = 0L;
    ToolbarEntry *p_toolbar = m_toolbarList[toolbarId];
    if (p_toolbar)
    {
      QDomNode node = p_toolbar->guiClient->domDocument().firstChild().firstChild().firstChild();
      while (!node.isNull())
      {
        if (node.nodeName() == "Action")
        {
          action = ac->action(node.toElement().attribute("name"));
          if (action)
          {
            oldActionItem = new KListViewItem(item, oldActionItem, action->text().replace(r,""), action->shortcut().toString(), action->name());
            oldActionItem->setPixmap(0, SmallIcon(action->icon()) );
          }
        }
        node = node.nextSibling();
      }
      if (tb->label(tb->currentPageIndex()).replace(r, "") == toolbarName)
      {
         item->setOpen(true);
         if (item->firstChild())
         {
           if (defaultAction.isEmpty())
           {
             actionTreeView->setCurrentItem(item->firstChild());
           } else
           {
             QListViewItem *actionItem = item->firstChild();
             while (actionItem && actionItem->depth() > 0)
             {
                if (actionItem->text(0) == defaultAction || actionItem->text(0) == defaultAction + "...")
                {
                  actionTreeView->setCurrentItem(actionItem);
                  break;
                }
                actionItem = actionItem->nextSibling();
             }
           }
         }
      }
    }
    oldItem = item;
  }
  uint acCount = ac->count();
  for (uint i = 0; i < acCount; i++)
  {
    action = ac->action(i);
    item = new KListViewItem(allActionsItem, action->text().replace(r, ""),  action->shortcut().toString(), action->name());
    item->setPixmap(0, SmallIcon(action->icon()) );
  }
  allActionsItem->sortChildItems(0, true);

  treeMenu = new KPopupMenu(actionTreeView);
  treeMenu->insertItem(i18n("&Add New Toolbar"), this, SLOT(slotAddToolbar()));
  treeMenu->insertItem(i18n("&Remove Toolbar"), this, SLOT(slotRemoveToolbar()));
//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde3-kdewebdev,代码行数:101,代码来源:actionconfigdialog.cpp

示例5: slotSelectionChanged

void ActionConfigDialog::slotSelectionChanged(QListViewItem *item)
{
  if (currentAction && currentAction->inherits("TagAction"))
  {
    if ( buttonApply->isEnabled() &&
         KMessageBox::questionYesNo(this, i18n("Do you want to save the changes made to this action?"), QString::null, KStdGuiItem::save(), KStdGuiItem::discard()) == KMessageBox::Yes )
    {
      saveCurrentAction();
    }
    buttonApply->setEnabled(false);
    currentAction = 0L;
  }
  if (item && item->depth() > 0)
  {
    TagAction *action = 0L;
    KActionCollection *ac = m_mainWindow->actionCollection();
    uint acCount = ac->count();
//find the corresponding action
    for (uint i = 0; i < acCount; i++)
    {
      KAction *a = ac->action(i);
      QString actionName = a->name();
      if (a && actionName == item->text(2) && a->inherits("TagAction"))
      {
        action = static_cast<TagAction*>(a);
        actionProperties->setEnabled(true);
        deleteAction->setEnabled(true);
        break;
      } else
      {
        actionProperties->setEnabled(false);
        deleteAction->setEnabled(false);
      }
    }

    //if we found the action, load the action details
    if (action)
    {
      currentAction = action;
      QDomElement el = action->data();
      if ( el.hasAttribute("icon") )
      {
        QString s = el.attribute("icon");
        if (!QFileInfo(s).exists())
          s = QFileInfo(s).fileName();
        actionIcon->setIcon(s);
      }
      QString actionText = el.attribute("text");
      actionText.replace(QRegExp("\\&(?!\\&)"),"");
      lineText->setText(actionText);
      lineToolTip->setText( el.attribute("tooltip") );
      selectedShortcut = action->shortcut();
      QString shortcutText = action->shortcut().toString();
      if (shortcutText.isEmpty())
      {
        noShortcut->setChecked(true);
        shortcutKeyButton->setText(i18n("None"));
      } else
      {
        customShortcut->setChecked(true);
        shortcutKeyButton->setShortcut(action->shortcut(), false);
        shortcutKeyButton->setText(shortcutText);
      }

//find the container toolbars of this action and add them to the container listbox
      toolbarListBox->clear();
      int current = 0;
      int count = 0;
      ToolbarTabWidget *tb = ToolbarTabWidget::ref();
      for (int i = 0; i < tb->count(); i++)
      {
        QString toolbarName = tb->label(i);
        QString toolbarId = tb->id(i);
        ToolbarEntry *p_toolbar = m_toolbarList[toolbarId];
        if (p_toolbar)
        {
          QDomNode node = p_toolbar->guiClient->domDocument().firstChild().firstChild().firstChild();
          while (!node.isNull())
          {
            if (node.nodeName() == "Action" &&
                node.toElement().attribute("name") == el.attribute("name"))
            {
              toolbarListBox->insertItem(toolbarName);
              if (item->parent()->text(0) == toolbarName)
                current = count;
              count++;
            }
            node = node.nextSibling();
          }
        }
      }
      toolbarListBox->setCurrentItem(current);
      toolbarListBox->setSelected(current, true);
      toolbarListBox->sort();

//set the detailed settings pages to their defaults
      lineTag->clear();
      lineClosingTag->clear();
      useClosingTag->setChecked(false);
      useActionDialog->setChecked(false);
//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde3-kdewebdev,代码行数:101,代码来源:actionconfigdialog.cpp


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