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


C++ QListViewItem类代码示例

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


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

示例1: setIcon

void SetupDialog::iconChanged()
{
    setIcon(Pict("configure"));
    for (QListViewItem *item = lstBars->firstChild(); item != NULL; item = item->nextSibling())
        iconChanged(item);
}
开发者ID:,项目名称:,代码行数:6,代码来源:

示例2: setTabLabel

void AnnotationOutput::readAnnotations()
{
  if (!Project::ref()->hasProject())
  {
    m_allAnnotations->clear();
    m_yourAnnotations->clear();
    m_yourAnnotationsNum = 0;
    setTabLabel(m_yourAnnotations, i18n("For You"));
    return;
  }

  KURL baseURL = Project::ref()->projectBaseURL();
  QStringList openedItems;
  QListViewItem *item = m_allAnnotations->firstChild();
  while (item)
  {
    if (item->isOpen())
        openedItems += item->text(0);
    item = item->nextSibling();
  }
  m_allAnnotations->clear();
  m_annotatedFileItems.clear();
  m_fileNames.clear();
  m_lines.clear();

  QStringList yourOpenedItems;
  item = m_yourAnnotations->firstChild();
  while (item)
  {
    if (item->isOpen())
        yourOpenedItems += item->text(0);
    item = item->nextSibling();
  }

  m_yourAnnotations->clear();
  m_yourFileItems.clear();
  m_yourFileNames.clear();
  m_yourLines.clear();
  m_yourAnnotationsNum = 0;

  QDomElement annotationElement = Project::ref()->dom()->firstChild().firstChild().namedItem("annotations").toElement();
  if (annotationElement.isNull())
    return;
  QString yourself = Project::ref()->yourself().lower();
  QStringList roles = Project::ref()->yourRoles();
  QDomNodeList nodes = annotationElement.childNodes();
  int count = nodes.count();
  for (int i = 0; i < count; i++)
  {
    QDomElement el = nodes.item(i).toElement();
    QString fileName = el.attribute("url");
    KURL u = baseURL;
    QuantaCommon::setUrl(u, fileName);
    u = QExtFileInfo::toAbsolute(u, baseURL);
    if (Project::ref()->contains(u))
    {
      bool ok;
      int line = el.attribute("line").toInt(&ok, 10);
      QString text = el.attribute("text");
      QString receiver = el.attribute("receiver");
      text.replace('\n',' ');
      QString lineText = QString("%1").arg(line);
      if (lineText.length() < 20)
      {
        QString s;
        s.fill('0', 20 - lineText.length());
        lineText.prepend(s);
      }
      KListViewItem *fileIt = m_annotatedFileItems[fileName];
      if (!fileIt)
      {
        fileIt = new KListViewItem(m_allAnnotations, fileName);
        m_annotatedFileItems.insert(fileName, fileIt);
        m_fileNames[fileIt] = u.url();
      }
      KListViewItem *it = new KListViewItem(fileIt, fileIt, text, lineText);
      if (openedItems.contains(fileName))
        fileIt->setOpen(true);
      m_fileNames[it] = u.url();
      m_lines[it] = line;
   
      if (!yourself.isEmpty() && (receiver == yourself || roles.contains(receiver)))
      {
        m_yourAnnotationsNum++;
        KListViewItem *fileIt = m_yourFileItems[fileName];
        if (!fileIt)
        {
          fileIt = new KListViewItem(m_yourAnnotations, fileName);
          m_yourFileItems.insert(fileName, fileIt);
          m_yourFileNames[fileIt] = u.url();
        }
        KListViewItem *it = new KListViewItem(fileIt, fileIt, text, lineText);
        if (yourOpenedItems.contains(fileName))
          fileIt->setOpen(true);
        m_yourFileNames[it] = u.url();
        m_yourLines[it] = line;
      }
    } else
    {
      annotationElement.removeChild(el);
//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde3-kdewebdev,代码行数:101,代码来源:annotationoutput.cpp

示例3: ServerListItem

    QListViewItem* ServerListDialog::insertServerGroup(ServerGroupSettingsPtr serverGroup)
    {
        // Produce a list of this server group's channels
        QString channels;

        Konversation::ChannelList channelList = serverGroup->channelList();
        Konversation::ChannelList::iterator channelIt;
        Konversation::ChannelList::iterator begin = channelList.begin();

        for(channelIt = begin; channelIt != channelList.end(); ++channelIt)
        {
            if (channelIt != begin)
                channels += ", ";

            channels += (*channelIt).name();
        }

        QListViewItem* networkItem = 0;

        // Insert the server group into the list
        networkItem = new ServerListItem(m_serverList,
                                  serverGroup->id(),
                                  serverGroup->sortIndex(),
                                  serverGroup->name(),
                                  serverGroup->identity()->getName(),
                                  channels);

        // Recreate expanded/collapsed state
        if (serverGroup->expanded())
            networkItem->setOpen(true);

        // Produce a list of this server group's servers and iterate over it
        Konversation::ServerList serverList = serverGroup->serverList();
        Konversation::ServerList::iterator serverIt;

        QListViewItem* serverItem = 0;
        int i = 0;

        for (serverIt = serverList.begin(); serverIt != serverList.end(); ++serverIt)
        {
            // Produce a string representation of the server object
            QString name = (*serverIt).host();

            if ((*serverIt).port() != 6667)
                name += ':' + QString::number((*serverIt).port());

            if ((*serverIt).SSLEnabled())
                name += + " (SSL)";

            // Insert the server into the list, as child of the server group list item
            serverItem = new ServerListItem(networkItem,
                                            serverGroup->id(),
                                            i,
                                            name,
                                            (*serverIt));

            // The listview shouldn't allow this to be dragged
            serverItem->setDragEnabled(false);

            // Initialize a pointer to the new location of the last edited server
            if (m_selectedItem && m_selectedServer==(*serverIt))
                m_selectedItemPtr = serverItem;

            ++i;
        }

        return networkItem;
    }
开发者ID:,项目名称:,代码行数:68,代码来源:

示例4: getContacts

void MainInfo::fill()
{
    Contact *contact = m_contact;
    if (contact == NULL)
        contact = getContacts()->owner();

    QString firstName = contact->getFirstName();
    firstName = getToken(firstName, '/');
    edtFirstName->setText(firstName);
    QString lastName = contact->getLastName();
    lastName = getToken(lastName, '/');
    edtLastName->setText(lastName);

    cmbDisplay->clear();
    QString name = contact->getName();
    if (name.length())
        cmbDisplay->insertItem(name);
    if (firstName.length() && lastName.length()){
        cmbDisplay->insertItem(firstName + " " + lastName);
        cmbDisplay->insertItem(lastName + " " + firstName);
    }
    if (firstName.length())
        cmbDisplay->insertItem(firstName);
    if (lastName.length())
        cmbDisplay->insertItem(lastName);
    cmbDisplay->lineEdit()->setText(contact->getName());

    edtNotes->setText(contact->getNotes());
    QString mails = contact->getEMails();
    lstMails->clear();
    while (mails.length()){
        QString mailItem = getToken(mails, ';', false);
        QString mail = getToken(mailItem, '/');
        QListViewItem *item = new QListViewItem(lstMails);
        item->setText(MAIL_ADDRESS, mail);
        item->setText(MAIL_PROTO, mailItem);
        item->setPixmap(MAIL_ADDRESS, Pict("mail_generic"));
        if ((m_contact == NULL) && mailItem.isEmpty())
            item->setText(MAIL_PUBLISH, i18n("Yes"));
    }
    mailSelectionChanged();
    QString phones = contact->getPhones();
    lstPhones->clear();
    unsigned n = 1;
    cmbCurrent->clear();
    cmbCurrent->insertItem("");
    while (phones.length()){
        QString number;
        QString type;
        unsigned icon = 0;
        QString proto;
        QString phone = getToken(phones, ';', false);
        QString phoneItem = getToken(phone, '/', false);
        proto = phone;
        number = getToken(phoneItem, ',');
        type = getToken(phoneItem, ',');
        if (!phoneItem.isEmpty())
            icon = atol(getToken(phoneItem, ',').latin1());
        QListViewItem *item = new QListViewItem(lstPhones);
        fillPhoneItem(item, number, type, icon, proto);
        cmbCurrent->insertItem(number);
        if (!phoneItem.isEmpty()){
            item->setText(PHONE_ACTIVE, "1");
            cmbCurrent->setCurrentItem(n);
        }
        n++;
    }
    connect(lstPhones, SIGNAL(selectionChanged()), this, SLOT(phoneSelectionChanged()));
    phoneSelectionChanged();
}
开发者ID:,项目名称:,代码行数:70,代码来源:

示例5: MainInfoItem

void UserConfig::fill()
{
    ConfigItem::curIndex = 1;
    lstBox->clear();
    QListViewItem *parentItem;
    if (m_contact){
        parentItem = new MainInfoItem(lstBox, CmdInfo);
        ClientDataIterator it(m_contact->clientData);
        void *data;
        while ((data = ++it) != NULL){
            Client *client = m_contact->clientData.activeClient(data, it.client());
            if (client == NULL)
                continue;
            CommandDef *cmds = client->infoWindows(m_contact, data);
            if (cmds){
                parentItem = NULL;
                for (; !cmds->text.isEmpty(); cmds++){
                    if (parentItem){
                        new ClientItem(parentItem, it.client(), data, cmds);
                    }else{
                        parentItem = new ClientItem(lstBox, it.client(), data, cmds);
                        parentItem->setOpen(true);
                    }
                }
            }
        }
    }

    parentItem = NULL;
    ClientUserData* data;
    if (m_contact) {
        data = &m_contact->clientData;
    } else {
        data = &m_group->clientData;
    }
    ClientDataIterator it(*data);
    list<unsigned> st;
    while (++it){
        if ((it.client()->protocol()->description()->flags & PROTOCOL_AR_USER) == 0)
            continue;
        if (parentItem == NULL){
            parentItem = new ConfigItem(lstBox, 0);
            parentItem->setText(0, i18n("Autoreply"));
            parentItem->setOpen(true);
        }
        for (const CommandDef *d = it.client()->protocol()->statusList(); !d->text.isEmpty(); d++){
            if ((d->id == STATUS_ONLINE) || (d->id == STATUS_OFFLINE))
                continue;
            list<unsigned>::iterator it;
            for (it = st.begin(); it != st.end(); ++it)
                if ((*it) == d->id)
                    break;
            if (it != st.end())
                continue;
            st.push_back(d->id);
            new ARItem(parentItem, d);
        }
    }

    parentItem = new ConfigItem(lstBox, 0);
    parentItem->setText(0, i18n("Settings"));
    parentItem->setPixmap(0, Pict("configure", lstBox->colorGroup().base()));
    parentItem->setOpen(true);
    CommandDef *cmd;
    CommandsMapIterator itc(CorePlugin::m_plugin->preferences);
    m_defaultPage = 0;
    while ((cmd = ++itc) != NULL){
        new PrefItem(parentItem, cmd);
        if (m_defaultPage == 0)
            m_defaultPage = cmd->id;
    }

    QFontMetrics fm(lstBox->font());
    unsigned w = 0;
    for (QListViewItem *item = lstBox->firstChild(); item; item = item->nextSibling()){
        w = QMAX(w, itemWidth(item, fm));
    }
    lstBox->setFixedWidth(w);
    lstBox->setColumnWidth(0, w - 2);
}
开发者ID:BackupTheBerlios,项目名称:sim-im-svn,代码行数:80,代码来源:usercfg.cpp

示例6: i18n


//.........这里部分代码省略.........
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != this)
            return NULL;
        if (cmd->menu_id != MenuBrowser)
            return NULL;
        cmd->flags &= ~COMMAND_CHECKED;
        switch (cmd->id){
        case CmdOneLevel:
            if (!m_client->getAllLevels())
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdAllLevels:
            if (m_client->getAllLevels())
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdModeDisco:
            if (m_client->getBrowseType() & BROWSE_DISCO)
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdModeBrowse:
            if (m_client->getBrowseType() & BROWSE_BROWSE)
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdModeAgents:
            if (m_client->getBrowseType() & BROWSE_AGENTS)
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        }
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != this)
            return NULL;
        QListViewItem *item = m_list->currentItem();
        if (cmd->menu_id == MenuBrowser){
            cmd->flags &= ~COMMAND_CHECKED;
            unsigned mode = m_client->getBrowseType();
            switch (cmd->id){
            case CmdOneLevel:
                m_client->setAllLevels(false);
				changeMode();
                return e->param();
            case CmdAllLevels:
                m_client->setAllLevels(true);
				changeMode();
                return e->param();
            case CmdModeDisco:
				mode ^= BROWSE_DISCO;
                m_client->setBrowseType(mode);
				changeMode();
                return e->param();
            case CmdModeBrowse:
				mode ^= BROWSE_BROWSE;
                m_client->setBrowseType(mode);
				changeMode();
                return e->param();
            case CmdModeAgents:
				mode ^= BROWSE_AGENTS;
                m_client->setBrowseType(mode);
				changeMode();
                return e->param();
            }
            return NULL;
        }
        if (item){
            if (cmd->id == CmdBrowseSearch){
开发者ID:,项目名称:,代码行数:67,代码来源:

示例7: optionsDlg


//.........这里部分代码省略.........
    optionsPage.viewCombo->insertStringList(list);
    for (uint i = 0; i < list.count(); i++)
    {
      if (list[i] == defaultView)
      {
        optionsPage.viewCombo->setCurrentItem(i);
        break;
      }
    }
  } else
  {
    optionsPage.viewCombo->insertItem(i18n("No view was saved yet."));
    optionsPage.viewCombo->setEnabled(false);
  }

  optionsPage.checkPrefix->setChecked(d->usePreviewPrefix);
  optionsPage.checkPersistentBookmarks->setChecked(d->m_persistentBookmarks);

//add upload profiles page
  page = optionsDlg.addPage(i18n("Up&load Profiles"));
  UploadProfilesPage uploadProfilesPage(page);
  topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() );
  topLayout->addWidget(&uploadProfilesPage);
  QDomElement uploadEl = d->m_sessionDom.firstChild().firstChild().namedItem("uploadprofiles").toElement();
  uploadProfilesPage.profileLabel->setText(uploadEl.attribute("defaultProfile"));
  uploadProfilesPage.checkShowUploadTreeviews->setChecked(d->m_showUploadTreeviews);

//add the team members page
  page = optionsDlg.addPage(i18n("Team Configuration"));
  TeamMembersDlg membersPage(page);
  topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() );
  topLayout->addWidget(&membersPage);

  QListViewItem *item;
  if (!teamLeader().name.isEmpty())
  {
    TeamMember member = teamLeader();
    item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Team Leader"), member.task);
    membersPage.membersListView->insertItem(item);
  }
  for (QMap<QString, TeamMember>::ConstIterator it = d->m_subprojectLeaders.constBegin(); it != d->m_subprojectLeaders.constEnd(); ++it)
  {
    TeamMember member = it.data();
    item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Subproject Leader"), member.task, it.key());
  }
  for (QMap<QString, TeamMember>::ConstIterator it = d->m_taskLeaders.constBegin(); it != d->m_taskLeaders.constEnd(); ++it)
  {
    TeamMember member = it.data();
    item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Task Leader"), it.key());
  }
  for (QValueList<TeamMember>::ConstIterator it = d->m_simpleMembers.constBegin(); it != d->m_simpleMembers.constEnd(); ++it)
  {
    TeamMember member = *it;
    item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Simple Member"), member.task);
  }
  membersPage.mailingListEdit->setText(d->m_mailingList);
  membersPage.setYourself(d->m_yourself);

//add the event configuration page
  page = optionsDlg.addPage(i18n("Event Configuration"));
  EventConfigurationDlg eventsPage(d->m_mainWindow->actionCollection(), page);
  topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() );
  topLayout->addWidget(&eventsPage);
  eventsPage.initEvents(d->m_events);
  eventsPage.enableEventsBox->setChecked(d->m_eventsEnabled);
开发者ID:serghei,项目名称:kde3-kdewebdev,代码行数:66,代码来源:project.cpp

示例8: QListViewItem

/**
 * Create a channel entry to the given parent listview
 */
QListViewItem* VCXYPadProperties::createChannelEntry(QListView* parent,
        t_device_id deviceID,
        t_channel channel,
        t_value lo,
        t_value hi,
        bool reverse)
{
    Device* device;
    LogicalChannel* log_ch;
    QListViewItem* item;
    QString s;

    device = _app->doc()->device(deviceID);
    if (device == NULL)
    {
        return NULL;
    }

    item = new QListViewItem(parent);

    // Device name
    item->setText(KColumnDeviceName, device->name());

    // Channel name
    log_ch = device->deviceClass()->channels()->at(channel);
    if (log_ch)
    {
        s.sprintf("%.3d: ", channel + 1);
        s += log_ch->name();
        item->setText(KColumnChannelName, s);
    }
    else
    {
        delete item;
        return NULL;
    }

    // High limit
    s.sprintf("%.3d", hi);
    item->setText(KColumnHi, s);

    // Low limit
    s.sprintf("%.3d", lo);
    item->setText(KColumnLo, s);

    // Reverse
    if (reverse)
    {
        item->setText(KColumnReverse, Settings::trueValue());
    }
    else
    {
        item->setText(KColumnReverse, Settings::falseValue());
    }

    // Device ID
    s.setNum(deviceID);
    item->setText(KColumnDeviceID, s);

    // Channel number
    s.sprintf("%.3d", channel);
    item->setText(KColumnChannelNumber, s);

    return item;
}
开发者ID:speakman,项目名称:qlc,代码行数:68,代码来源:vcxypadproperties.cpp

示例9: switch

void KstObjectItem::update(bool recursive) {
  switch (_rtti) {
    case RTTI_OBJ_DATA_VECTOR:
      {
        KstVectorPtr px = *KST::vectorList.findTag(_name);
        assert(px.data());
        assert(dynamic_cast<KstRVector*>(px.data()));
        KstRVectorPtr x = static_cast<KstRVector*>(px.data());
        setText(2, QString::number(x->getUsage() - 3)); // caller has a ptr
        setText(3, QString::number(x->sampleCount()));
        setText(4, i18n("%3: %4 [%1..%2]").arg(x->reqStartFrame())
            .arg(x->reqStartFrame() + x->reqNumFrames())
            .arg(x->getFilename())
            .arg(x->getField()));
        _removable = x->getUsage() == 3;
        break;
      }
    case RTTI_OBJ_VECTOR:
      {
        KstVectorPtr x = *KST::vectorList.findTag(_name);
        assert(x.data());
        setText(2, QString::number(x->getUsage() - 2)); //caller also points
        setText(3, QString::number(x->sampleCount()));
        setText(4, i18n("[%1..%2]").arg(x->min()).arg(x->max()));
        _removable = false;
        break;
      }
    case RTTI_OBJ_OBJECT:
      {
        KstDataObjectPtr x = *KST::dataObjectList.findTag(_name);
        assert(x.data());
        setText(1, x->typeString());
        setText(2, QString::number(x->getUsage() - 1)); // our pointer
        setText(3, QString::number(x->sampleCount()));
        setText(4, x->propertyString());
        if (recursive) {
          QPtrStack<QListViewItem> trash;

          for (QListViewItem *i = firstChild(); i; i = i->nextSibling()) {
            KstObjectItem *oi = static_cast<KstObjectItem*>(i);
            if (x->outputVectors().findTag(oi->tagName()) == x->outputVectors().end()) {
              trash.push(i);
            }
          }
          trash.setAutoDelete(true);
          trash.clear();

          for (KstVectorMap::Iterator p = x->outputVectors().begin();
              p != x->outputVectors().end();
              ++p) {
            bool found = false;
            for (QListViewItem *i = firstChild(); i; i = i->nextSibling()) {
              KstObjectItem *oi = static_cast<KstObjectItem*>(i);
              if (oi->tagName() == p.data()->tagName()) {
                oi->update();
                found = true;
                break;
              }
            }
            if (!found) {
              new KstObjectItem(this, p.data(), _dm);
            }
          }
        }
        _removable = x->getUsage() == 1;
        break;
      }
    default:
      assert(0);
  }
}
开发者ID:,项目名称:,代码行数:71,代码来源:

示例10: manager

void DistributionListDialog::slotUser1()
{
  bool isEmpty = true;

  KABC::AddressBook *ab = KABC::StdAddressBook::self( true );

  QListViewItem *i = mRecipientsList->firstChild();
  while( i ) {
    DistributionListItem *item = static_cast<DistributionListItem *>( i );
    if ( item->isOn() ) {
      isEmpty = false;
      break;
    }
    i = i->nextSibling();
  }

  if ( isEmpty ) {
    KMessageBox::information( this,
                              i18n("There are no recipients in your list. "
                                   "First select some recipients, "
                                   "then try again.") );
    return;
  }

#ifndef KDEPIM_NEW_DISTRLISTS
  KABC::DistributionListManager manager( ab );
  manager.load();
#endif

  QString name = mTitleEdit->text();

  if ( name.isEmpty() ) {
    bool ok = false;
    name = KInputDialog::getText( i18n("New Distribution List"),
      i18n("Please enter name:"), QString::null, &ok, this );
    if ( !ok || name.isEmpty() )
      return;
  }

#ifdef KDEPIM_NEW_DISTRLISTS
  if ( !KPIM::DistributionList::findByName( ab, name ).isEmpty() ) {
#else
  if ( manager.list( name ) ) {
#endif
    KMessageBox::information( this,
      i18n( "<qt>Distribution list with the given name <b>%1</b> "
        "already exists. Please select a different name.</qt>" ).arg( name ) );
    return;
  }

#ifdef KDEPIM_NEW_DISTRLISTS
  KPIM::DistributionList dlist;
  dlist.setName( name );

  i = mRecipientsList->firstChild();
  while( i ) {
    DistributionListItem *item = static_cast<DistributionListItem *>( i );
    if ( item->isOn() ) {
      kdDebug() << "  " << item->addressee().fullEmail() << endl;
      if ( item->isTransient() ) {
        ab->insertAddressee( item->addressee() );
      }
      if ( item->email() == item->addressee().preferredEmail() ) {
        dlist.insertEntry( item->addressee() );
      } else {
        dlist.insertEntry( item->addressee(), item->email() );
      }
    }
    i = i->nextSibling();
  }

  ab->insertAddressee( dlist );
#else
  KABC::DistributionList *dlist = new KABC::DistributionList( &manager, name );
  i = mRecipientsList->firstChild();
  while( i ) {
    DistributionListItem *item = static_cast<DistributionListItem *>( i );
    if ( item->isOn() ) {
      kdDebug() << "  " << item->addressee().fullEmail() << endl;
      if ( item->isTransient() ) {
        ab->insertAddressee( item->addressee() );
      }
      if ( item->email() == item->addressee().preferredEmail() ) {
        dlist->insertEntry( item->addressee() );
      } else {
        dlist->insertEntry( item->addressee(), item->email() );
      }
    }
    i = i->nextSibling();
  }
#endif

  // FIXME: Ask the user which resource to save to instead of the default
  bool saveError = true;
  KABC::Ticket *ticket = ab->requestSaveTicket( 0 /*default resource */ );
  if ( ticket )
    if ( ab->save( ticket ) )
      saveError = false;
    else
      ab->releaseSaveTicket( ticket );
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例11: KstObjectItem

void KstDataManagerI::update() {
if (!isShown()) {
  return;
}

QPtrStack<QListViewItem> trash;

  // Garbage collect first
  for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
    KstObjectItem *oi = static_cast<KstObjectItem*>(i);
    if (i->rtti() == RTTI_OBJ_OBJECT) {
      if (KST::dataObjectList.findTag(oi->tagName()) == KST::dataObjectList.end()) {
        trash.push(i);
      }
    } else {
      if (KST::vectorList.findTag(oi->tagName()) == KST::vectorList.end()) {
        trash.push(i);
      }
    }
  }

  trash.setAutoDelete(true);
  trash.clear();

  for (KstDataObjectList::iterator it = KST::dataObjectList.begin();
                                    it != KST::dataObjectList.end();
                                                               ++it) {
    bool found = false;
    for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
      KstObjectItem *oi = static_cast<KstObjectItem*>(i);
      if (oi->rtti() == RTTI_OBJ_OBJECT && oi->tagName() == (*it)->tagName()) {
        oi->update();
        found = true;
        break;
      }
    }
    if (!found) {
        KstObjectItem *i = new KstObjectItem(DataView, *it, this);
        connect(i, SIGNAL(updated()), this, SLOT(doUpdates()));
    }
  }

  KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
  for (KstRVectorList::iterator it = rvl.begin(); it != rvl.end(); ++it) {
    bool found = false;
    for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
      KstObjectItem *oi = static_cast<KstObjectItem*>(i);
      if (oi->rtti() == RTTI_OBJ_DATA_VECTOR && oi->tagName() == (*it)->tagName()) {
        oi->update();
        found = true;
        break;
      }
    }
    if (!found) {
        KstObjectItem *i = new KstObjectItem(DataView, *it, this);
        connect(i, SIGNAL(updated()), this, SLOT(doUpdates()));
    }
  }

  if (DataView->selectedItem()) {
    static_cast<KstObjectItem*>(DataView->currentItem())->updateButtons();
  } else {
    Edit->setEnabled(false);
    Delete->setEnabled(false);
  }
}
开发者ID:,项目名称:,代码行数:66,代码来源:

示例12: saveResults

void KfindWindow::saveResults()
{
    QListViewItem *item;

    KFileDialog *dlg = new KFileDialog(QString::null, QString::null, this, "filedialog", true);
    dlg->setOperationMode(KFileDialog::Saving);

    dlg->setCaption(i18n("Save Results As"));

    QStringList list;

    list << "text/plain"
         << "text/html";

    dlg->setOperationMode(KFileDialog::Saving);

    dlg->setMimeFilter(list, QString("text/plain"));

    dlg->exec();

    KURL u = dlg->selectedURL();
    KMimeType::Ptr mimeType = dlg->currentFilterMimeType();
    delete dlg;

    if(!u.isValid() || !u.isLocalFile())
        return;

    QString filename = u.path();

    QFile file(filename);

    if(!file.open(IO_WriteOnly))
        KMessageBox::error(parentWidget(), i18n("Unable to save results."));
    else
    {
        QTextStream stream(&file);
        stream.setEncoding(QTextStream::Locale);

        if(mimeType->name() == "text/html")
        {
            stream << QString::fromLatin1(
                          "<HTML><HEAD>\n"
                          "<!DOCTYPE %1>\n"
                          "<TITLE>%2</TITLE></HEAD>\n"
                          "<BODY><H1>%3</H1>"
                          "<DL><p>\n")
                          .arg(i18n("KFind Results File"))
                          .arg(i18n("KFind Results File"))
                          .arg(i18n("KFind Results File"));

            item = firstChild();
            while(item != NULL)
            {
                QString path = ((KfFileLVI *)item)->fileitem.url().url();
                QString pretty = ((KfFileLVI *)item)->fileitem.url().htmlURL();
                stream << QString::fromLatin1("<DT><A HREF=\"") << path << QString::fromLatin1("\">") << pretty << QString::fromLatin1("</A>\n");

                item = item->nextSibling();
            }
            stream << QString::fromLatin1("</DL><P></BODY></HTML>\n");
        }
        else
        {
            item = firstChild();
            while(item != NULL)
            {
                QString path = ((KfFileLVI *)item)->fileitem.url().url();
                stream << path << endl;
                item = item->nextSibling();
            }
        }

        file.close();
        KMessageBox::information(parentWidget(), i18n("Results were saved to file\n") + filename);
    }
}
开发者ID:serghei,项目名称:kde3-kdebase,代码行数:76,代码来源:kfwin.cpp

示例13: raiseWidget

void SetupDialog::raiseWidget(int id)
{
    for (QListViewItem *item = lstBars->firstChild(); item != NULL; item = item->nextSibling())
        if (raiseWidget(item, id)) break;
}
开发者ID:,项目名称:,代码行数:5,代码来源:

示例14: findNetworkRoot

/**
 * Refresh the nicklistview for a single server.
 * @param server            The server to be refreshed.
 */
void NicksOnline::updateServerOnlineList(Server* servr)
{
    bool newNetworkRoot = false;
    QString serverName = servr->getServerName();
    QString networkName = servr->getDisplayName();
    QListViewItem* networkRoot = findNetworkRoot(networkName);
    // If network is not in our list, add it.
    if (!networkRoot)
    {
        networkRoot = new NicksOnlineItem(NicksOnlineItem::NetworkRootItem,m_nickListView,networkName);
        newNetworkRoot = true;
    }
    // Store server name in hidden column.
    // Note that there could be more than one server in the network connected,
    // but it doesn't matter because all the servers in a network have the same
    // watch list.
    networkRoot->setText(nlvcServerName, serverName);
    // Update list of servers in the network that are connected.
    QStringList serverList = QStringList::split(",", networkRoot->text(nlvcAdditionalInfo));
    if (!serverList.contains(serverName)) serverList.append(serverName);
    networkRoot->setText(nlvcAdditionalInfo, serverList.join(","));
    // Get item in nicklistview for the Offline branch.
    QListViewItem* offlineRoot = findItemType(networkRoot, NicksOnlineItem::OfflineItem);
    if (!offlineRoot)
    {
        offlineRoot = new NicksOnlineItem(NicksOnlineItem::OfflineItem,networkRoot,i18n("Offline"));
        offlineRoot->setText(nlvcServerName, serverName);
    }

    // Get watch list.
    QStringList watchList = servr->getWatchList();
    QStringList::iterator itEnd = watchList.end();
    QString nickname;

    for (QStringList::iterator it = watchList.begin(); it != itEnd; ++it)
    {
        nickname = (*it);
        NickInfoPtr nickInfo = getOnlineNickInfo(networkName, nickname);

        if (nickInfo && nickInfo->getPrintedOnline())
        {
            // Nick is online.
            // Which server did NickInfo come from?
            Server* server=nickInfo->getServer();
            // Get addressbook entry (if any) for the nick.
            KABC::Addressee addressee = nickInfo->getAddressee();
            // Construct additional information string for nick.
            bool needWhois = false;
            QString nickAdditionalInfo = getNickAdditionalInfo(nickInfo, addressee, needWhois);
            // Remove from offline branch if present.
            QListViewItem* item = findItemChild(offlineRoot, nickname, NicksOnlineItem::NicknameItem);
            if (item) delete item;
            // Add to network if not already added.
            QListViewItem* nickRoot = findItemChild(networkRoot, nickname, NicksOnlineItem::NicknameItem);
            if (!nickRoot) nickRoot = new NicksOnlineItem(NicksOnlineItem::NicknameItem,networkRoot, nickname, nickAdditionalInfo);
            nickRoot->setText(nlvcAdditionalInfo, nickAdditionalInfo);
            nickRoot->setText(nlvcServerName, serverName);
            // If no additional info available, request a WHOIS on the nick.
            if (!m_whoisRequested)
            {
                if (needWhois)
                {
                    requestWhois(networkName, nickname);
                    m_whoisRequested = true;
                }
            }
            // Set Kabc icon if the nick is associated with an addressbook entry.
            if (!addressee.isEmpty())
                nickRoot->setPixmap(nlvcKabc, m_kabcIconSet.pixmap(
                                        QIconSet::Small, QIconSet::Normal, QIconSet::On));
            else
                nickRoot->setPixmap(nlvcKabc, m_kabcIconSet.pixmap(
                                        QIconSet::Small, QIconSet::Disabled, QIconSet::Off));

            QStringList channelList = server->getNickChannels(nickname);
            QStringList::iterator itEnd2 = channelList.end();

            for (QStringList::iterator it2 = channelList.begin(); it2 != itEnd2; ++it2)
            {
                // Known channels where nickname is online and mode in each channel.
                // FIXME: If user connects to multiple servers in same network, the
                // channel info will differ between the servers, resulting in inaccurate
                // mode and led info displayed.

                QString channelName = (*it2);

                ChannelNickPtr channelNick = server->getChannelNick(channelName, nickname);
                QString nickMode;
                if (channelNick->hasVoice()) nickMode = nickMode + i18n(" Voice");
                if (channelNick->isHalfOp()) nickMode = nickMode + i18n(" HalfOp");
                if (channelNick->isOp()) nickMode = nickMode + i18n(" Operator");
                if (channelNick->isOwner()) nickMode = nickMode + i18n(" Owner");
                if (channelNick->isAdmin()) nickMode = nickMode + i18n(" Admin");
                QListViewItem* channelItem = findItemChild(nickRoot, channelName, NicksOnlineItem::ChannelItem);
                if (!channelItem) channelItem = new NicksOnlineItem(NicksOnlineItem::ChannelItem,nickRoot,
                            channelName, nickMode);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例15: if

void ProcAttachPS::pushLine()
{
    if (m_line.size() < 3)	// we need the PID, PPID, and COMMAND columns
	return;

    if (m_pidCol < 0)
    {
	// create columns if we don't have them yet
	bool allocate =	processList->columns() == 3;

	// we assume that the last column is the command
	m_line.pop_back();

	for (uint i = 0; i < m_line.size(); i++) {
	    // we don't allocate the PID and PPID columns,
	    // but we need to know where in the ps output they are
	    if (m_line[i] == "PID") {
		m_pidCol = i;
	    } else if (m_line[i] == "PPID") {
		m_ppidCol = i;
	    } else if (allocate) {
		processList->addColumn(m_line[i]);
		// these columns are normally numbers
		processList->setColumnAlignment(processList->columns()-1,
						Qt::AlignRight);
	    }
	}
    }
    else
    {
	// insert a line
	// find the parent process
	QListViewItem* parent = 0;
	if (m_ppidCol >= 0 && m_ppidCol < int(m_line.size())) {
	    parent = processList->findItem(m_line[m_ppidCol], 1);
	}

	// we assume that the last column is the command
	QListViewItem* item;
	if (parent == 0) {
	    item = new QListViewItem(processList, m_line.back());
	} else {
	    item = new QListViewItem(parent, m_line.back());
	}
	item->setOpen(true);
	m_line.pop_back();
	int k = 3;
	for (uint i = 0; i < m_line.size(); i++)
	{
	    // display the pid and ppid columns' contents in columns 1 and 2
	    if (int(i) == m_pidCol)
		item->setText(1, m_line[i]);
	    else if (int(i) == m_ppidCol)
		item->setText(2, m_line[i]);
	    else
		item->setText(k++, m_line[i]);
	}

	if (m_ppidCol >= 0 && m_pidCol >= 0) {	// need PID & PPID for this
	    /*
	     * It could have happened that a process was earlier inserted,
	     * whose parent process is the current process. Such processes
	     * were placed at the root. Here we go through all root items
	     * and check whether we must reparent them.
	     */
	    QListViewItem* i = processList->firstChild();
	    while (i != 0)
	    {
		// advance before we reparent the item
		QListViewItem* it = i;
		i = i->nextSibling();
		if (it->text(2) == m_line[m_pidCol]) {
		    processList->takeItem(it);
		    item->insertItem(it);
		}
	    }
	}
    }
}
开发者ID:,项目名称:,代码行数:79,代码来源:


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