Beispiel #1
0
void ConnectionManager::fill(Client *current)
{
    lstConnection->clear();
    QListViewItem *curItem = NULL;
    for (unsigned i = 0; i < getContacts()->nClients(); i++){
        Client *client = getContacts()->getClient(i);
        Protocol *protocol = client->protocol();
        const CommandDef *descr = protocol->description();
        QString text = CorePlugin::m_plugin->clientName(client);
        QListViewItem *item = new QListViewItem(lstConnection, text);
        if (descr)
            item->setPixmap(0, Pict(descr->icon, lstConnection->colorGroup().base()));
        if (current == client)
            curItem = item;
        QString index = QString::number(i);
        while (index.length() < 6)
            index = QString("0") + index;
        item->setText(1, index);
    }
    if (curItem)
        lstConnection->setCurrentItem(curItem);
    selectionChanged();
}
Beispiel #2
0
/**
 * Associates a root directory with this list.
 * For each file in the list, the part of the path corresponding to the root
 * is replaced with a $ sign.
 * @param	sRoot	The new root path
 */
void FileList::setRoot(const QString& sRoot)
{
	QListViewItem* pItem;
	QString sPath;
	
	// Update all items in the list
	for (pItem = m_pList->firstChild(); pItem != NULL; 
		pItem = pItem->nextSibling()) {
		sPath = pItem->text(2);
		
		// Restore the full path
		sPath.replace("$", m_sRoot);
		
		// Replace the root with a $ sign
		if (sRoot != "/")
			sPath.replace(sRoot, "$");
		
		pItem->setText(2, sPath);
	}
	
	// Store the new root
	m_sRoot = sRoot;
}
void EditFunctions::functionAdd( const QString &access, const QString &type )
{
    QListViewItem *i = new QListViewItem( functionListView );
    i->setPixmap( 0, QPixmap::fromMimeSource( "designer_editslots.png" ) );
    i->setRenameEnabled( 0, TRUE );
    i->setText( 1, "void" );
    i->setText( 2, "virtual" );

    if ( access.isEmpty() )
        i->setText( 3, "public" );
    else
        i->setText( 3, access );

    if( type.isEmpty() ) {
        if ( showOnlySlots->isChecked() )
            i->setText( 4, "slot" );
        else {
            i->setText( 4, lastType );
        }
    } else {
        i->setText( 4, type );
    }

    if ( i->text( 4 ) == "slot" ) {
        i->setText( 0, "newSlot()" );
        if ( MetaDataBase::isSlotUsed( formWindow, "newSlot()" ) )
            i->setText( 5, tr( "Yes" ) );
        else
            i->setText( 5, tr( "No" ) );
    } else {
        i->setText( 0, "newFunction()" );
        i->setText( 5, "---" );
    }

    functionListView->setCurrentItem( i );
    functionListView->setSelected( i, TRUE );
    functionListView->ensureItemVisible( i );
    functionName->setFocus();
    functionName->selectAll();

    FunctItem fui;
    fui.id = id;
    fui.oldName = i->text( 0 );
    fui.newName = fui.oldName;
    fui.oldRetTyp = i->text( 1 );
    fui.retTyp = fui.oldRetTyp;
    fui.oldSpec = i->text ( 2 );
    fui.spec = fui.oldSpec;
    fui.oldAccess = i->text( 3 );
    fui.access = fui.oldAccess;
    fui.oldType = i->text( 4 );
    fui.type = fui.oldType;
    lastType = fui.oldType;
    functList.append( fui );
    functionIds.insert( i, id );
    id++;
}
void JabberBrowser::go(const QString &url, const QString &node)
{
    setNavigation();
    Command cmd;
    m_list->clear();
    cmd->id		= CmdBrowseInfo;
    cmd->flags	= COMMAND_DISABLED;
    cmd->param	= this;
    EventCommandDisabled(cmd).process();

    cmd->id		= CmdBrowseSearch;
    cmd->flags	= COMMAND_DISABLED;
    cmd->param	= this;
    EventCommandDisabled(cmd).process();

    cmd->id		= CmdRegister;
    cmd->flags	= COMMAND_DISABLED;
    cmd->param	= this;
    EventCommandDisabled(cmd).process();

    cmd->id		= CmdBrowseConfigure;
    cmd->flags	= COMMAND_DISABLED;
    cmd->param	= this;
    EventCommandDisabled(cmd).process();

    m_bInProcess = true;
    QListViewItem *item = new QListViewItem(m_list);
    item->setText(COL_JID, url);
    item->setText(COL_NAME, url);
    item->setText(COL_NODE, node);
    m_bError = false;
    unsigned mode = 0;
    if (JabberPlugin::plugin->getBrowseType() & BROWSE_DISCO){
        item->setText(COL_ID_DISCO_ITEMS, m_client->discoItems(url, node));
        item->setText(COL_ID_DISCO_INFO, m_client->discoInfo(url, node));
        mode = BROWSE_DISCO | BROWSE_INFO;
    }
    if (JabberPlugin::plugin->getBrowseType() & BROWSE_BROWSE){
        if (node.isEmpty()){
            item->setText(COL_ID_BROWSE, m_client->browse(url));
            mode |= BROWSE_BROWSE;
        }
    }
    item->setText(COL_MODE, QString::number(mode));
    item->setPixmap(COL_NAME, Pict("empty"));
    cmd->id		= CmdUrl;
    cmd->param	= this;
    EventCommandWidget eWidget(cmd);
    eWidget.process();
    CToolCombo *cmbUrl = dynamic_cast<CToolCombo*>(eWidget.widget());
    if (cmbUrl)
        cmbUrl->setText(url);
    cmd->id		= CmdNode;
    EventCommandWidget eWidget2(cmd);
    eWidget2.process();
    CToolCombo *cmbNode = dynamic_cast<CToolCombo*>(eWidget2.widget());
    if (cmbNode)
        cmbNode->setText(node);
    startProcess();
    if (item->text(COL_ID_DISCO_INFO).isEmpty())
        stop(i18n("Client offline"));
}
Beispiel #5
0
void k9ProcessList::setText(k9Process *_process, const QString &_text,int _col) {
    QListViewItem *it =m_items[_process];
    it->setText(_col,_text);
}
void ActionConfigDialog::saveCurrentAction()
{
  static_cast<TagAction *>(currentAction)->setModified(true);
  QString s;
  QDomElement el = static_cast<TagAction *>(currentAction)->data();
  s = actionIcon->icon();
  el.setAttribute("icon", s);
  currentAction->setIcon(s);
  QString oldText = el.attribute("text");
  s = lineText->text();
  s.replace('&', "&&");
  el.setAttribute("text", s);
  currentAction->setText(s);
  s = lineToolTip->text();
  el.setAttribute("tooltip", s);
  currentAction->setToolTip(s);
  s = "";
  if (customShortcut->isChecked())
  {
    s = selectedShortcut.toString();
    currentAction->setShortcut(selectedShortcut);
  } else
  {
    currentAction->setShortcut(KShortcut());
  }
  el.setAttribute("shortcut", s);


//update the tree view
  QListViewItem *listItem;
  QListViewItemIterator it(actionTreeView);
  while (it.current())
  {
    listItem = it.current();
    if (listItem->depth() > 0 && listItem->text(2) == currentAction->name())
    {
      listItem->setPixmap(0, SmallIcon(actionIcon->icon()));
      listItem->setText(0, lineText->text());
      listItem->setText(1, currentAction->shortcut().toString());
    }
    ++it;
  }

//remove all the detailed settings
  QDomElement item = el.namedItem("tag").toElement();
  if ( !item.isNull() )
      el.removeChild(item);
  item = el.namedItem("tag").toElement();
  if ( !item.isNull() )
      el.removeChild(item);
  item = el.namedItem("xtag").toElement();
  if ( !item.isNull() )
      el.removeChild(item);
  item = el.namedItem("script").toElement();
  if ( !item.isNull() )
      el.removeChild(item);
  item = el.namedItem("text").toElement();
  if ( !item.isNull() )
      el.removeChild(item);
//add the new detailed settings
  QDomDocument document = QDomDocument();
  int type = typeCombo->currentItem();
  switch (type)
  {
    case 1:{
        el.setAttribute("type","script");
        item = document.createElement("script");
        switch (inputBox->currentItem())
        {
          case 1:{ item.setAttribute("input", "current");
                   break;
                 }
          case 2:{ item.setAttribute("input", "selected");
                   break;
                 }
          default:{ item.setAttribute("input", "none");
                    break;
                  }
        }
        switch (outputBox->currentItem())
        {
          case 1:{ item.setAttribute("output", "cursor");
                   break;
                 }
          case 2:{ item.setAttribute("output", "selection");
                   break;
                 }
          case 3:{ item.setAttribute("output", "replace");
                   break;
                 }
          case 4:{ item.setAttribute("output", "new");
                   break;
                 }
          case 5:{ item.setAttribute("output", "message");
                   break;
                 }
          default:{ item.setAttribute("output", "none");
                    break;
                  }
        }
        switch (errorBox->currentItem())
        {
          case 1:{ item.setAttribute("error", "cursor");
                   break;
                 }
          case 2:{ item.setAttribute("error", "selection");
                   break;
                 }
          case 3:{ item.setAttribute("error", "replace");
                   break;
                 }
          case 4:{ item.setAttribute("error", "new");
                   break;
                 }
          case 5:{ item.setAttribute("error", "message");
                   break;
                 }
          default:{ item.setAttribute("error", "none");
                    break;
                  }
        }

        el.appendChild(item);
        item.appendChild(document.createTextNode(scriptPath->text()));
        break;
      }
    case 2:{
        el.setAttribute("type","text");
        item = document.createElement("text");
        el.appendChild(item);
        item.appendChild(document.createTextNode(textEdit->text()));
        break;
      }
    default:{
        el.setAttribute("type","tag");
        item = document.createElement("tag");
        item.setAttribute("useDialog", useActionDialog->isChecked() ? "true" : "false");
        el.appendChild(item);
        item.appendChild(document.createTextNode(lineTag->text()));
        item = document.createElement("xtag");
        item.setAttribute("use", useClosingTag->isChecked() ? "true" : "false");
        el.appendChild(item);
        item.appendChild(document.createTextNode(lineClosingTag->text()));
        break;
      }
  }
  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];
    bool isOnToolbar = false;
    if (p_toolbar)
    {
      QDomNode node = p_toolbar->guiClient->domDocument().firstChild().firstChild().firstChild();
      bool placeOnToolbar = toolbarListBox->findItem(toolbarName, Qt::ExactMatch);
      while (!node.isNull())
      {
        if (node.nodeName() == "Action" &&
            node.toElement().attribute("name") == el.attribute("name"))
        {
          //if it's present in the toolbar, but not in the container list,
          //remove it also from the toolbar
          if (!placeOnToolbar)
          {
            currentAction->unplug(tb->page(i));
            currentAction->unplug(p_toolbar->menu);
            node.parentNode().removeChild(node);
            QListViewItemIterator iter(actionTreeView);
            while (iter.current())
            {
              listItem = iter.current();
              if (listItem->depth() > 0 && listItem->parent()->text(0) == toolbarName
                  && listItem->text(2) == el.attribute("name"))
              {
                delete listItem;
                break;
              }
              ++iter;
            }
          }
          isOnToolbar = true;
          break;
        }
        node = node.nextSibling();
      }
      //it's not on the toolbar, but it should be
      if (!isOnToolbar && placeOnToolbar)
      {
        currentAction->plug(tb->page(i));
        currentAction->plug(p_toolbar->menu);
        item = p_toolbar->guiClient->domDocument().createElement("Action");
        item.setAttribute("name",el.attribute("name"));
        p_toolbar->guiClient->domDocument().firstChild().firstChild().appendChild(item);
      //put it also in the treeview
        listItem = actionTreeView->findItem(toolbarName, 0);
        if (listItem)
        {
          QListViewItem *after = listItem->firstChild();
          while ( after && (!after->nextSibling() || (after->nextSibling() && after->nextSibling()->depth()!=0 ) ))
          {
            if (after->text(2) == currentAction->name())
            {
                placeOnToolbar = false;
                break;
            }
            after = after->nextSibling();
          }
          if (placeOnToolbar)
          {
              listItem = new KListViewItem(listItem, after, lineText->text(), currentAction->shortcut().toString(), currentAction->name());
              listItem->setPixmap(0, SmallIcon(actionIcon->icon()));
          }
        }
      }
      KXMLGUIFactory::saveConfigFile(p_toolbar->guiClient->domDocument(),
        p_toolbar->guiClient->xmlFile(), p_toolbar->guiClient->instance());
    }
    QWidget *toolBar = tb->page(i);
    if (toolBar->minimumSizeHint().height() > 20)
    {
      toolBar->adjustSize();
      toolBar->setGeometry(0,0, tb->width(), toolBar->height());
    } else
    {
      toolBar->setGeometry(0,0, tb->width(), tb->height() - tb->tabHeight());
    }

  }
}
Beispiel #7
0
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();
}
Beispiel #8
0
void *JabberBrowser::processEvent(Event *e)
{
    if (e->type() == EventAgentInfo){
        JabberAgentInfo *data = (JabberAgentInfo*)(e->param());
        if (m_search_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_search_id = "";
                    delete m_search;
                    m_search = NULL;
                    Command cmd;
                    cmd->id		= CmdBrowseSearch;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_search->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showSearch()));
                }
                m_search_id = "";
                return e->param();
            }
            m_search->m_search->addWidget(data);
            return e->param();
        }
        if (m_reg_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_reg_id = "";
                    delete m_reg;
                    m_reg = NULL;
                    Command cmd;
                    cmd->id		= CmdRegister;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_reg->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showReg()));
                }
                m_reg_id = "";
                return e->param();
            }
            m_reg->m_search->addWidget(data);
            return e->param();
        }
        if (m_config_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_config_id = "";
                    delete m_config;
                    m_config = NULL;
                    Command cmd;
                    cmd->id		= CmdBrowseConfigure;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_config->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showConfig()));
                }
                m_config_id = "";
                return e->param();
            }
            m_config->m_search->addWidget(data);
            return e->param();
        }
    }
    if (e->type() == EventCheckState){
        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){
                if (m_search)
                    delete m_search;
                m_search = new JabberWizard(this, i18n("%1 Search") .arg(item->text(COL_NAME).utf8()), "find", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "search");
                m_search_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "search");
                return e->param();
            }
            if (cmd->id == CmdRegister){
                if (m_reg)
                    delete m_reg;
                m_reg = new JabberWizard(this, i18n("%1 Register") .arg(item->text(COL_NAME).utf8()), "reg", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "register");
                m_reg_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "register");
                return e->param();
            }
            if (cmd->id == CmdBrowseConfigure){
                if (m_config)
                    delete m_config;
                m_config = new JabberWizard(this, i18n("%1 Configure") .arg(item->text(COL_NAME).utf8()), "configure", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "data");
                m_config_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "data");
                return e->param();
            }
            if (cmd->id == CmdBrowseInfo){
                if (m_info == NULL)
                    m_info = new DiscoInfo(this, m_list->currentItem()->text(COL_FEATURES), item->text(COL_NAME), item->text(COL_TYPE), item->text(COL_CATEGORY));
                m_info->reset();
                raiseWindow(m_info);
                return e->param();
            }
        }
        if (cmd->id == CmdBack){
            if (m_historyPos){
                m_historyPos--;
                QString url  = QString::fromUtf8(m_history[m_historyPos].c_str());
                QString node;
                if (!m_nodes[m_historyPos].empty())
                    node = QString::fromUtf8(m_nodes[m_historyPos].c_str());
                go(url, node);
            }
        }
        if (cmd->id == CmdForward){
            if (m_historyPos + 1 < (int)(m_history.size())){
                m_historyPos++;
                QString url  = QString::fromUtf8(m_history[m_historyPos].c_str());
                QString node;
                if (!m_nodes[m_historyPos].empty())
                    node = QString::fromUtf8(m_nodes[m_historyPos].c_str());
                go(url, node);
            }
        }
        if (cmd->id == CmdUrl){
            if (m_bInProcess){
                stop("");
                return e->param();
            }
            QString jid;
            QString node;
            Command cmd;
            cmd->id		= CmdUrl;
            cmd->param	= this;
            Event eWidget(EventCommandWidget, cmd);
            CToolCombo *cmbUrl = (CToolCombo*)(eWidget.process());
            if (cmbUrl)
                jid = cmbUrl->lineEdit()->text();
            cmd->id		= CmdNode;
            CToolCombo *cmbNode = (CToolCombo*)(eWidget.process());
            if (cmbNode)
                node = cmbNode->lineEdit()->text();
            if (!jid.isEmpty()){
                addHistory(jid);
                goUrl(jid, node);
            }
            return e->param();
        }
    }
    if (e->type() == EventDiscoItem){
        if (!m_bInProcess)
            return NULL;
        DiscoItem *item = (DiscoItem*)(e->param());
        QListViewItem *it = findItem(COL_ID_DISCO_ITEMS, item->id.c_str());
        if (it){
            if (item->jid.empty()){
                it->setText(COL_ID_DISCO_ITEMS, "");
                if (it != m_list->firstChild()){
                    checkDone();
                    adjustColumn(it);
                    return e->param();
                }
                QString err;
                if (!item->name.empty()){
                    err = QString::fromUtf8(item->name.c_str());
                }else if (!item->node.empty()){
                    err = i18n("Error %1") .arg(atol(item->node.c_str()));
                }
                if (!err.isEmpty()){
					unsigned mode = atol(it->text(COL_MODE).latin1());
					if (((mode & BROWSE_BROWSE) == 0) || (it->text(COL_ID_BROWSE).isEmpty() & m_bError))
                        stop(err);
                    m_bError = true;
                }
                checkDone();
                adjustColumn(it);
                return e->param();
            }
            if (it->firstChild() == NULL){
                it->setExpandable(true);
						if ((it == m_list->firstChild()) || (it == m_list->currentItem()))
							it->setOpen(true);
            }
            QListViewItem *i;
            for (i = it->firstChild(); i; i = i->nextSibling()){
                if ((i->text(COL_JID) == QString::fromUtf8(item->jid.c_str())) &&
                        (i->text(COL_NODE) == QString::fromUtf8(item->node.c_str())))
                    return e->param();
            }
            i = new QListViewItem(it);
            i->setText(COL_JID, QString::fromUtf8(item->jid.c_str()));
            i->setText(COL_NAME, item->name.empty() ? QString::fromUtf8(item->jid.c_str()) : QString::fromUtf8(item->name.c_str()));
            i->setText(COL_NODE, QString::fromUtf8(item->node.c_str()));
            int mode = 0;
            if (m_client->getBrowseType() & BROWSE_DISCO){
                i->setText(COL_ID_DISCO_INFO, m_client->discoInfo(item->jid.c_str(), item->node.c_str()).c_str());
                mode |= BROWSE_INFO;
            }
            i->setText(COL_MODE, QString::number(mode));
			if (m_client->getAllLevels())
				loadItem(i);
            return e->param();
        }
        it = findItem(COL_ID_DISCO_INFO, item->id.c_str());
        if (it){
            if (item->jid.empty()){
                it->setText(COL_ID_DISCO_INFO, "");
                checkDone();
                adjustColumn(it);
                return e->param();
            }
            if (it->text(COL_NAME) == it->text(COL_JID))
                it->setText(COL_NAME, QString::fromUtf8(item->name.c_str()));
            it->setText(COL_CATEGORY, QString::fromUtf8(item->category.c_str()));
            it->setText(COL_TYPE, QString::fromUtf8(item->type.c_str()));
            it->setText(COL_FEATURES, QString::fromUtf8(item->features.c_str()));
            if ((m_client->getAllLevels()) || (it == m_list->currentItem()))
				loadItem(it);
            setItemPict(it);
            if (it == m_list->currentItem())
                currentChanged(it);
            return e->param();
        }
        it = findItem(COL_ID_BROWSE, item->id.c_str());
        if (it){
            if (item->jid.empty()){
                it->setText(COL_ID_BROWSE, "");
                if (it != m_list->firstChild()){
                    checkDone();
                    adjustColumn(it);
                    return e->param();
                }
                    QString err;
                    if (!item->name.empty()){
                        err = QString::fromUtf8(item->name.c_str());
                    }else if (!item->node.empty()){
                        err = i18n("Error %1") .arg(atol(item->node.c_str()));
                    }
                if (!err.isEmpty()){
					unsigned mode = atol(it->text(COL_MODE).latin1());
					if (((mode & BROWSE_DISCO) == 0) || (it->text(COL_ID_DISCO_ITEMS).isEmpty() & m_bError))
                        stop(err);
                    m_bError = true;
                }
                checkDone();
				adjustColumn(it);
                return e->param();
            }
            if (it->text(COL_JID) != QString::fromUtf8(item->jid.c_str())){
                QListViewItem *i;
                for (i = it->firstChild(); i; i = i->nextSibling()){
                    if ((i->text(COL_JID) == QString::fromUtf8(item->jid.c_str())) &&
                            (i->text(COL_NODE) == QString::fromUtf8(item->node.c_str())))
                        break;
                }
                if (i){
                    it = i;
                }else{
					if (it->firstChild() == NULL){
						it->setExpandable(true);
						if ((it == m_list->firstChild()) || (it == m_list->currentItem()))
							it->setOpen(true);
					}
                    it = new QListViewItem(it);
                    it->setText(COL_JID, QString::fromUtf8(item->jid.c_str()));
                    if (m_client->getAllLevels())
						loadItem(it);
                }
            }
            if (it->text(COL_NAME) == it->text(COL_JID))
                it->setText(COL_NAME, QString::fromUtf8(item->name.c_str()));
            it->setText(COL_CATEGORY, QString::fromUtf8(item->category.c_str()));
            it->setText(COL_TYPE, QString::fromUtf8(item->type.c_str()));
            it->setText(COL_FEATURES, QString::fromUtf8(item->features.c_str()));
            if (m_client->getAllLevels() || (it == m_list->currentItem()))
				loadItem(it);
            setItemPict(it);
            return e->param();
        }
    }
    return NULL;
}
Beispiel #9
0
// take a new game from parser
void ClientWindow::slot_game(Game* g)
{
	// insert into ListView
	QListViewItemIterator lv(ListView_games);

	if (g->running)
	{
		bool found = false;
		GamesTableItem *lvi_mem = NULL;

		// check if game already exists
		if (!playerListEmpty)
		{
			QListViewItemIterator lvii = lv;
			for (GamesTableItem *lvi; (lvi = static_cast<GamesTableItem*>(lvii.current())) && !found;)
			{
				lvii++;
				// compare game id
				if (lvi->text(0) == g->nr)
				{
					found = true;
					lvi_mem = lvi;
				}
			}
		}
		else if (!g->H && !myAccount->num_games)
		{
			// skip games until initial table has loaded
			qDebug("game skipped because no init table");
			return;
		}

		QString excludeMark = "";
		QString myMark = "B";
		
		// check if exclude entry is done later
		if (g->H) //g->status.length() > 1)
		{
			QString emw;
			QString emb;

			// no: do it now
			emw = getPlayerExcludeListEntry(g->wname);
			emb = getPlayerExcludeListEntry(g->bname);

			// ensure that my game is listed first
			if (emw && emw == "M" || emb && emb == "M")
			{
				myMark = "A";
				excludeMark = "M";

				// I'm playing, thus I'm open, except teaching games
				if (emw && emw && (emw != "M" || emb != "M"))
				{
					// checkbox open
					slot_checkbox(0, true);
				}
			}
			else if (emw && emw == "W" || emb && emb == "W")
			{
				excludeMark = "W";
			}
		}
		
		if (found)
		{
			// supersede entry
			//lvi_mem->setText(0, g->nr);
			lvi_mem->setText(1, g->wname);
			lvi_mem->setText(2, g->wrank);
			lvi_mem->setText(3, g->bname);
			lvi_mem->setText(4, g->brank);
			lvi_mem->setText(5, g->mv);
			lvi_mem->setText(6, g->Sz);
			lvi_mem->setText(7, g->H);
			lvi_mem->setText(8, g->K);
			lvi_mem->setText(9, g->By);
			lvi_mem->setText(10, g->FR);
			lvi_mem->setText(11, g->ob);
//			lvi_mem->setText(6, g->status + " (" + g->ob + ")");
			lvi_mem->setText(12, myMark + rkToKey(g->wrank) + g->wname.lower() + ":" + excludeMark);

			lvi_mem->ownRepaint();
		}
		else
		{
			// from GAMES command or game info{...}

			if (g->H)
			{
				lv = new GamesTableItem(ListView_games,
					g->nr,
					" " + g->wname,
					g->wrank,
					" " + g->bname,
					g->brank,
					g->mv,
					g->Sz,
					g->H,
					g->K,
					g->By,
					g->FR,
					g->ob);
			}
			else
			{
				lv = new GamesTableItem(ListView_games,
					g->nr,
					" " + g->wname,
					g->wrank,
					" " + g->bname,
					g->brank,
					g->mv,
					g->Sz);
			}

			lv.current()->setText(12, myMark + rkToKey(g->wrank) + g->wname.lower() + ":" + excludeMark);

			static_cast<GamesTableItem*>(lv.current())->ownRepaint();

			// increase number of games
			myAccount->num_games++;
			statusGames->setText(" G: " + QString::number(myAccount->num_games) + " / " + QString::number(myAccount->num_observedgames) + " ");
		}

		// update player info if this is not a 'who'-result or if it's me
		if (!g->H || myMark == "A") //g->status.length() < 2)
		{
			QListViewItemIterator lvp(ListView_players);
			QListViewItem *lvpi;
			int found = 0;

			// look for players in playerlist
			for (; (lvpi = lvp.current()) && found < 2;)
			{
				// check if names are identical
				if (lvpi->text(1) == g->wname || lvpi->text(1) == g->bname)
				{
					lvpi->setText(3, g->nr);
					found++;

					// check if players has a rank
					if (g->wrank == "??" || g->brank == "??")
					{
						// no rank given in case of continued game -> set rank in games table
						if (lvpi->text(1) == g->wname)
						{
							lv.current()->setText(2, lvpi->text(2));
							// correct sorting of col 2 -> set col 12
							lv.current()->setText(12, myMark + rkToKey(lvpi->text(2)) + lvpi->text(1).lower() + ":" + excludeMark);
						}

						// no else case! bplayer could be identical to wplayer!
						if (lvpi->text(1) == g->bname)
							lv.current()->setText(4, lvpi->text(2));

						static_cast<GamesTableItem*>(lv.current())->ownRepaint();
					}
				}

				lvp++;
			}

			ListView_games->sort();
		}
	}
	else
	{
		// from game info {...}
		bool found = false;
		QString game_id;

		if (g->nr != "@")
		{
			for (QListViewItem *lvi; (lvi = lv.current()) && !found;)
			{
				lv++;
				// compare game id
				if (lvi->text(0) == g->nr)
				{
					lv++;
					delete lvi;
					found = true;;
				}
			}

			// used for player update below
			game_id = g->nr;
		}
		else
		{
			for (QListViewItem *lvi; (lvi = lv.current()) && !found;)
			{
				lv++;
				// look for name
				if (lvi->text(1) == myAccount->acc_name ||
				    lvi->text(3) == myAccount->acc_name)
				{
					// used for player update below
					game_id = lvi->text(0);

					lv++;
					delete lvi;
					found = true;;
				}
			}
		}

		if (!found)
			qWarning("game not found");
		else
		{
			// decrease number of games
			myAccount->num_games--;
			statusGames->setText(" G: " + QString::number(myAccount->num_games) + " / " + QString::number(myAccount->num_observedgames) + " ");

			QListViewItemIterator lvp(ListView_players);
			QListViewItem *lvpi;
			int found = 0;

			// look for players in playerlist
			for (; (lvpi = lvp.current()) && found < 2;)
			{
				// check if numbers are identical
				if (lvpi->text(3) == game_id)
				{
					lvpi->setText(3, "-");
					found++;
				}

				lvp++;
			}
		}
	}
}
void EditSettings::okData()
{
  QString sql;
  RDSqlQuery *q;
  RDSqlQuery *q1;
  std::map<unsigned,QString> dups;

  if(edit_duplicate_carts_box->isChecked()!=
     edit_system->allowDuplicateCartTitles()) {
    QLabel *msg=new QLabel(this);
    QProgressDialog *pd=new QProgressDialog(this);
    pd->setLabel(msg);
    pd->setCancelButton(NULL);
    pd->setMinimumDuration(2);
    if(!edit_duplicate_carts_box->isChecked()) {
      //
      // Check for dups
      //
      msg->setText(tr("Checking the Library for duplicates."));
      sql="select NUMBER,TITLE from CART order by NUMBER";
      q=new RDSqlQuery(sql);
      int count=0;
      int step=0;
      int step_size=q->size()/10;
      pd->setProgress(0,10);
      while(q->next()) {
	sql=QString().sprintf("select NUMBER from CART \
                           where (TITLE=\"%s\")&&(NUMBER!=%u)",
			      (const char *)RDEscapeString(q->value(1).toString()),
			      q->value(0).toUInt());
	q1=new RDSqlQuery(sql);
	while(q1->next()) {
	  dups[q1->value(0).toUInt()]=q->value(1).toString();
	}
	delete q1;
	count++;
	if(count>=step_size) {
	  pd->setProgress(++step);
	  count=0;
	  qApp->processEvents();
	}
      }
      delete q;
      pd->reset();
      if(dups.size()>0) {
	QListViewItem *item;
	y_pos=305;
	setMinimumWidth(sizeHint().width());
	setMaximumWidth(sizeHint().width());
	setMinimumHeight(sizeHint().height());
	setMaximumHeight(sizeHint().height());
	edit_duplicate_carts_box->setChecked(true);
	edit_duplicate_label->show();
	edit_duplicate_list->show();
	edit_save_button->show();
	edit_duplicate_list->clear();
	edit_ok_button->setGeometry(sizeHint().width()-180,
				    sizeHint().height()-60,
				    80,50);
	edit_cancel_button->
	  setGeometry(sizeHint().width()-90,sizeHint().height()-60,80,50);
	for(std::map<unsigned,QString>::const_iterator ci=dups.begin();
	    ci!=dups.end();ci++) {
	  item=new QListViewItem(edit_duplicate_list);
	  item->setText(0,QString().sprintf("%06u",ci->first));
	  item->setText(1,ci->second);
	}
	return;
      }

      //
      // All ok -- make the change
      //
      sql="alter table CART drop index TITLE_IDX";
      q=new RDSqlQuery(sql);
      delete q;
      sql="alter table CART modify column TITLE char(255) unique";
      q=new RDSqlQuery(sql);
      delete q;
      edit_system->setAllowDuplicateCartTitles(false);
    }
ActionConfig::ActionConfig(QWidget *parent, struct ActionUserData *data, ActionPlugin *plugin)
        : ActionConfigBase(parent)
{
    m_data   = data;
    m_plugin = plugin;
    m_menu   = NULL;
    setButtonsPict(this);

    lstEvent->addColumn(i18n("Event"));
    lstEvent->addColumn(i18n("Program"));
    lstEvent->setExpandingColumn(1);

    connect(btnHelp, SIGNAL(clicked()), this, SLOT(help()));

    QListViewItem *item = new QListViewItem(lstEvent, i18n("Contact online"));
    item->setText(2, QString::number(CONTACT_ONLINE));
    item->setPixmap(0, makePixmap("ICQ"));
    if (data->OnLine.ptr)
        item->setText(1, QString::fromUtf8(data->OnLine.ptr));

    item = new QListViewItem(lstEvent, i18n("Status changed"));
    item->setText(2, QString::number(CONTACT_STATUS));
    item->setPixmap(0, makePixmap("ICQ"));
    if (data->Status.ptr)
        item->setText(1, QString::fromUtf8(data->Status.ptr));

    CommandDef *cmd;
    CommandsMapIterator it(m_plugin->core->messageTypes);
    while ((cmd = ++it) != NULL){
        MessageDef *def = (MessageDef*)(cmd->param);
        if ((def == NULL) || (cmd->icon == NULL) ||
                (def->flags & (MESSAGE_HIDDEN | MESSAGE_SENDONLY | MESSAGE_CHILD)))
            continue;
        if ((def->singular == NULL) || (def->plural == NULL) ||
                (*def->singular == 0) || (*def->plural == 0))
            continue;
        QString type = i18n(def->singular, def->plural, 1);
        int pos = type.find("1 ");
        if (pos == 0){
            type = type.mid(2);
        }else if (pos > 0){
            type = type.left(pos);
        }
        type = type.left(1).upper() + type.mid(1);
        QListViewItem *item = new QListViewItem(lstEvent, type);
        item->setText(2, QString::number(cmd->id));
        item->setPixmap(0, makePixmap(cmd->icon));
        item->setText(1, QString::fromUtf8(get_str(data->Message, cmd->id)));
    }
    m_edit = NULL;
    m_editItem = NULL;
    connect(lstEvent, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(selectionChanged(QListViewItem*)));

    for (QObject *p = parent; p != NULL; p = p->parent()){
        if (!p->inherits("QTabWidget"))
            continue;
        QTabWidget *tab = static_cast<QTabWidget*>(p);
        m_menu = new MenuConfig(tab, data);
        tab->addTab(m_menu, i18n("Menu"));
        tab->adjustSize();
        break;
    }
    lstEvent->adjustColumn();
    setMinimumSize(sizeHint());
}
Beispiel #12
0
ListGpis::ListGpis(RDMatrix *matrix,RDMatrix::GpioType type,
		   QWidget *parent,const char *name)
  : QDialog(parent,name,true)
{
  QString sql;
  RDSqlQuery *q;
  QListViewItem *l;
  QString list_label;

  list_matrix=matrix;
  list_type=type;
  switch(type) {
    case RDMatrix::GpioInput:
      list_tablename="GPIS";
      list_size=list_matrix->gpis();
      list_label=tr("GPI Lines");
      setCaption(tr("List GPIs"));
      break;

    case RDMatrix::GpioOutput:
      list_tablename="GPOS";
      list_size=list_matrix->gpos();
      list_label=tr("GPO Lines");
      setCaption(tr("List GPOs"));
      break;
  }

  //
  // Fix the Window Size
  //
  setMinimumWidth(sizeHint().width());
  setMinimumHeight(sizeHint().height());

  //
  // Create Fonts
  //
  QFont bold_font=QFont("Helvetica",12,QFont::Bold);
  bold_font.setPixelSize(12);
  QFont font=QFont("Helvetica",12,QFont::Normal);
  font.setPixelSize(12);

  //
  // Gpis List Box
  //
  list_list_view=new QListView(this,"list_box");
  list_list_label=
    new QLabel(list_list_view,list_label,this,"list_view_label");
  list_list_label->setFont(bold_font);
  list_list_view->setAllColumnsShowFocus(true);
  list_list_view->setItemMargin(5);
  connect(list_list_view,
	  SIGNAL(doubleClicked(QListViewItem *,const QPoint &,int)),
	  this,
	  SLOT(doubleClickedData(QListViewItem *,const QPoint &,int)));

  switch(list_type) {
    case RDMatrix::GpioInput:
      list_list_view->addColumn(tr("GPI"));
      break;

    case RDMatrix::GpioOutput:
      list_list_view->addColumn(tr("GPO"));
      break;
  }
  list_list_view->setColumnAlignment(0,Qt::AlignHCenter);

  list_list_view->addColumn(tr("ON MACRO CART"));
  list_list_view->setColumnAlignment(1,Qt::AlignHCenter);

  list_list_view->addColumn(tr("ON DESCRIPTION"));
  list_list_view->setColumnAlignment(2,Qt::AlignLeft);

  list_list_view->addColumn(tr("OFF MACRO CART"));
  list_list_view->setColumnAlignment(3,Qt::AlignHCenter);

  list_list_view->addColumn(tr("OFF DESCRIPTION"));
  list_list_view->setColumnAlignment(4,Qt::AlignLeft);

  //
  //  Edit Button
  //
  list_edit_button=new QPushButton(this,"list_edit_button");
  list_edit_button->setFont(bold_font);
  list_edit_button->setText(tr("&Edit"));
  connect(list_edit_button,SIGNAL(clicked()),this,SLOT(editData()));

  //
  //  Ok Button
  //
  list_ok_button=new QPushButton(this,"list_ok_button");
  list_ok_button->setDefault(true);
  list_ok_button->setFont(bold_font);
  list_ok_button->setText(tr("&OK"));
  connect(list_ok_button,SIGNAL(clicked()),this,SLOT(okData()));

  //
  //  Cancel Button
  //
  list_cancel_button=new QPushButton(this,"list_cancel_button");
  list_cancel_button->setFont(bold_font);
  list_cancel_button->setText(tr("&Cancel"));
  connect(list_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));

  //
  // Load Values
  //
  sql=QString().sprintf("select %s.NUMBER,%s.MACRO_CART,%s.OFF_MACRO_CART,\
                         CART.TITLE \
                         from %s left join CART \
                         on %s.MACRO_CART=CART.NUMBER \
                         where (%s.STATION_NAME=\"%s\")&&(%s.MATRIX=%d)\
                         order by %s.NUMBER",
			(const char *)list_tablename,
			(const char *)list_tablename,
			(const char *)list_tablename,
			(const char *)list_tablename,
			(const char *)list_tablename,
			(const char *)list_tablename,
			(const char *)list_matrix->station(),
			(const char *)list_tablename,
			list_matrix->matrix(),
			(const char *)list_tablename);
  q=new RDSqlQuery(sql);
  if(list_matrix->type()==RDMatrix::LiveWireLwrpAudio) {
    while(q->next()) {
      l=new QListViewItem(list_list_view);
      l->setText(0,QString().sprintf("%05d",q->value(0).toInt()));
      if(q->value(1).toInt()>0) {
	l->setText(1,QString().sprintf("%06d",q->value(1).toInt()));
      }
      if(q->value(2).toInt()>0) {
	l->setText(3,QString().sprintf("%06d",q->value(2).toInt()));
      }
      if(q->value(1).toInt()>0) {
	l->setText(2,q->value(3).toString());
      }
      else {
	l->setText(2,tr("[unassigned]"));
      }
    }
  }
  else {
    q->first();
    for(int i=0;i<list_size;i++) {
      l=new QListViewItem(list_list_view); 
      l->setText(0,QString().sprintf("%03d",i+1));
      if(q->isValid()&&(q->value(0).toInt()==(i+1))){
	if(q->value(1).toInt()>0) {
	  l->setText(1,QString().sprintf("%06d",q->value(1).toInt()));
	}
	if(q->value(2).toInt()>0) {
	  l->setText(3,QString().sprintf("%06d",q->value(2).toInt()));
	}
	if(q->value(1).toInt()>0) {
	  l->setText(2,q->value(3).toString());
	}
	else {
	  l->setText(2,tr("[unassigned]"));
	}
	q->next();
      }
      else {
	l->setText(2,tr("[unassigned]"));
      }
    }
  }
  delete q;

  //
  // Now go back and get the descriptions for the 'Off' carts
  //
  l=list_list_view->firstChild();
  while(l!=NULL) {
    if(l->text(0).toInt()>0) {
      if(l->text(3).toInt()>0) {
	RDCart *cart=new RDCart(l->text(3).toUInt());
	l->setText(4,cart->title());
	delete cart;
      }
      else {
	l->setText(4,tr("[unassigned]"));
      }
    }
    l=l->nextSibling();
  }

}
EditFunctions::EditFunctions( QWidget *parent, FormWindow *fw, bool justSlots )
    : EditFunctionsBase( parent, 0, TRUE ), formWindow( fw )
{
    connect( helpButton, SIGNAL( clicked() ), MainWindow::self, SLOT( showDialogHelp() ) );

    id = 0;
    functList.clear();

    QValueList<MetaDataBase::Function> functionList = MetaDataBase::functionList( fw );
    for ( QValueList<MetaDataBase::Function>::Iterator it = functionList.begin(); it != functionList.end(); ++it ) {
        QListViewItem *i = new QListViewItem( functionListView );

        i->setPixmap( 0, QPixmap::fromMimeSource( "designer_editslots.png" ) );
        i->setText( 0, (*it).function );
        i->setText( 1, (*it).returnType );
        i->setText( 2, (*it).specifier );
        i->setText( 3, (*it).access  );
        i->setText( 4, (*it).type );

        FunctItem fui;
        fui.id = id;
        fui.oldName = (*it).function;
        fui.newName = fui.oldName;
        fui.oldRetTyp = (*it).returnType;
        fui.retTyp = fui.oldRetTyp;
        fui.oldSpec = (*it).specifier;
        fui.spec = fui.oldSpec;
        fui.oldAccess = (*it).access;
        fui.access = fui.oldAccess;
        fui.oldType = (*it).type;
        fui.type = fui.oldType;
        functList.append( fui );

        functionIds.insert( i, id );
        id++;

        if ( (*it).type == "slot" ) {
            if ( MetaDataBase::isSlotUsed( formWindow, MetaDataBase::normalizeFunction( (*it).function ).latin1() ) )
                i->setText( 5, tr( "Yes" ) );
            else
                i->setText( 5, tr( "No" ) );
        } else {
            i->setText( 5, "---" );
        }
    }

    boxProperties->setEnabled( FALSE );
    functionName->setValidator( new AsciiValidator( TRUE, functionName ) );

    if ( functionListView->firstChild() )
        functionListView->setCurrentItem( functionListView->firstChild() );

    showOnlySlots->setChecked( justSlots );
    lastType = "function";

    // Enable rename for all QListViewItems
    QListViewItemIterator lvit = functionListView->firstChild();
    for ( ; *lvit; lvit++ )
        (*lvit)->setRenameEnabled( 0, TRUE );

    // Connect listview signal to signal-relay
    QObject::connect( functionListView,
                      SIGNAL( itemRenamed( QListViewItem*, int, const QString & ) ),
                      this,
                      SLOT( emitItemRenamed(QListViewItem*, int, const QString&) ) );

    // Connect signal-relay to QLineEdit "functionName"
    QObjectList *l = parent->queryList( "QLineEdit", "functionName" );
    QObject *obj;
    QObjectListIt itemsLineEditIt( *l );
    while ( (obj = itemsLineEditIt.current()) != 0 ) {
        ++itemsLineEditIt;
        QObject::connect( this,
                          SIGNAL( itemRenamed( const QString & ) ),
                          obj,
                          SLOT( setText( const QString & ) ) );
    }
    delete l;
}
Beispiel #14
0
/**
 * 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);
                channelItem->setText(nlvcAdditionalInfo, nickMode);

                // Icon for mode of nick in each channel.
                Images::NickPrivilege nickPrivilege = Images::Normal;
                if (channelNick->hasVoice()) nickPrivilege = Images::Voice;
                if (channelNick->isHalfOp()) nickPrivilege = Images::HalfOp;
                if (channelNick->isOp()) nickPrivilege = Images::Op;
                if (channelNick->isOwner()) nickPrivilege = Images::Owner;
                if (channelNick->isAdmin()) nickPrivilege = Images::Admin;
                if (server->getJoinedChannelMembers(channelName) != 0)
                    channelItem->setPixmap(nlvcChannel,
                                           KonversationApplication::instance()->images()->getNickIcon(nickPrivilege, false));
                else
                    channelItem->setPixmap(nlvcChannel,
                                           KonversationApplication::instance()->images()->getNickIcon(nickPrivilege, true));
            }
            // Remove channel if nick no longer in it.
            QListViewItem* child = nickRoot->firstChild();
            while (child)
            {
                QListViewItem* nextChild = child->nextSibling();
                if (channelList.find(child->text(nlvcNick)) == channelList.end())
                    delete child;
                child = nextChild;
            }
        }
        else
        {
            // Nick is offline.
            // Remove from online nicks, if present.
            QListViewItem* item = findItemChild(networkRoot, nickname, NicksOnlineItem::NicknameItem);
            if (item) delete item;
            // Add to offline list if not already listed.
            QListViewItem* nickRoot = findItemChild(offlineRoot, nickname, NicksOnlineItem::NicknameItem);
            if (!nickRoot) nickRoot = new NicksOnlineItem(NicksOnlineItem::NicknameItem,offlineRoot, nickname);
            nickRoot->setText(nlvcServerName, serverName);
            // Get addressbook entry for the nick.
            KABC::Addressee addressee = servr->getOfflineNickAddressee(nickname);
            // Format additional information for the nick.
            bool needWhois = false;
            QString nickAdditionalInfo = getNickAdditionalInfo(0, addressee, needWhois);
            nickRoot->setText(nlvcAdditionalInfo, nickAdditionalInfo);
            // 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));
        }
    }
    // Erase nicks no longer being watched.
    QListViewItem* item = networkRoot->firstChild();
    while (item)
    {
        QListViewItem* nextItem = item->nextSibling();
        if (static_cast<NicksOnlineItem*>(item)->type() != NicksOnlineItem::OfflineItem)
        {
            QString nickname = item->text(nlvcNick);
            if ((watchList.find(nickname) == watchList.end()) &&
                    (serverName == item->text(nlvcServerName))) delete item;
        }
        item = nextItem;
    }
    item = offlineRoot->firstChild();

    if(item) {
        while (item)
        {
            QListViewItem* nextItem = item->nextSibling();
            QString nickname = item->text(nlvcNick);
            if ((watchList.find(nickname) == watchList.end()) &&
                    (serverName == item->text(nlvcServerName))) delete item;
            item = nextItem;
        }
    }
    else
    {
        delete offlineRoot;
    }
    // Expand server if newly added to list.
    if (newNetworkRoot)
    {
        networkRoot->setOpen(true);
        // Connect server NickInfo updates.
        connect (servr, SIGNAL(nickInfoChanged(Server*, const NickInfoPtr)),
                 this, SLOT(slotNickInfoChanged(Server*, const NickInfoPtr)));
    }
}
Beispiel #15
0
void UISearchPage::recvIO_SearchReply( IOMessage * io )
{
        if ( m_done == true )
                return ;


        // Order of appearance
        //
        // the first time a filename shows up it gets it's own line,
        // and if it shows up more than once it is reparented.

        QListViewItem * item = new QListViewItem( m_view );
        item->setText( UIPageView::Col_Name, io->find( "name" ) );
        item->setText( UIPageView::Col_Bitr, io->find( "bitrate" ) );
        item->setText( UIPageView::Col_Size, io->find( "size" ) );
        item->setText( UIPageView::Col_Time, io->find( "time" ) );
        item->setText( UIPageView::Col_Freq, io->find( "freq" ) );
        item->setText( UIPageView::Col_Link, io->find( "speed" ) );
        item->setText( UIPageView::Col_Nick, io->find( "nick" ) );
        item->setText( UIPageView::Col_Path, io->find( "path" ) );
        item->setText( UIPageView::Col_Host, io->find( "host" ) );

        //
        // count gets bumped, title gets updated
        //

        incrementCount();
        updateTitle();

        //
        // do some bizzare tree m_view stuff ?
        //

        QListViewItem * item2 = m_items->find( io->find( "name" ) );

        if ( item2 == 0 )
        {
                m_items->replace( io->find( "name" ), item );
        }
        else
        {
                QListViewItem * from = 0;

                if ( item2->text( UIPageView::Col_Path ).isEmpty() == false )
                {
                        from = new QListViewItem( m_view );
                        from->setText( UIPageView::Col_Name, io->find( "name" ) );
                        from->setOpen( true );
                        from->setPixmap( UIPageView::Col_Name, m_folder );

                        // also add this item under parent
                        m_view->takeItem( item2 );
                        from->insertItem( item2 );
                }
                else
                {
                        from = item2;
                }

                m_view->takeItem( item );
                from->insertItem( item );

                m_items->replace( io->find( "name" ), from );
        }

        m_view->triggerUpdate();
}
Beispiel #16
0
void *JabberBrowser::processEvent(Event *e)
{
    if (e->type() == EventCommandExec) {
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != this)
            return NULL;
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdBack) {
            if (m_historyPos) {
                QString url = QString::fromUtf8(m_history[--m_historyPos].c_str());
                go(url);
            }
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdForward) {
            if (m_historyPos + 1 < (int)(m_history.size())) {
                QString url = QString::fromUtf8(m_history[++m_historyPos].c_str());
                go(url);
            }
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdUrl) {
            if (!m_id1.empty() || !m_id2.empty()) {
                stop("");
                return e->param();
            }
            Command cmd;
            cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdUrl;
            cmd->param	= this;
            Event eWidget(EventCommandWidget, cmd);
            CToolCombo *cmbUrl = (CToolCombo*)(eWidget.process());
            if (cmbUrl) {
                QString text = cmbUrl->lineEdit()->text();
                if (!text.isEmpty()) {
                    addHistory(text);
                    goUrl(text);
                }
            }
            return e->param();
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdInfo) {
            if (m_category.isEmpty() && m_type.isEmpty() && m_name.isEmpty() && m_features.isEmpty())
                return e->param();
            if (m_info == NULL)
                m_info = new DiscoInfo(this);
            m_info->reset();
            raiseWindow(m_info);
            return e->param();
        }
    }
    if (e->type() == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->EventDiscoItem) {
        JabberDiscoItem *item = (JabberDiscoItem*)(e->param());
        if (m_id1 == item->id) {
            if (item->jid.empty()) {
                m_id1 = "";
                m_list->adjustColumn();
                QString err;
                if (!item->name.empty()) {
                    err = QString::fromUtf8(item->name.c_str());
                } else if (!item->node.empty()) {
                    err = i18n("Error %1") .arg(atol(item->node.c_str()));
                }
                if (err.isEmpty() || m_id2.empty())
                    stop(err);
                return e->param();
            }
            QListViewItem *i = new QListViewItem(m_list);
            i->setText(COL_JID, QString::fromUtf8(item->jid.c_str()));
            i->setText(COL_NAME, QString::fromUtf8(item->name.c_str()));
            i->setText(COL_NODE, QString::fromUtf8(item->node.c_str()));
            return e->param();
        }
        if (m_id2 == item->id) {
            if (item->jid.empty()) {
                m_id2 = "";
                m_list->adjustColumn();
                QString err;
                if (!item->name.empty()) {
                    err = QString::fromUtf8(item->name.c_str());
                } else if (!item->node.empty()) {
                    err = i18n("Error %1") .arg(atol(item->node.c_str()));
                }
                if (m_id1.empty())
                    stop(err);
                return e->param();
            }
            if (item->jid == "feature") {
                if (!m_features.isEmpty())
                    m_features += "\n";
                m_features += QString::fromUtf8(item->name.c_str());
            } else {
                m_category = QString::fromUtf8(item->jid.c_str());
                m_type	   = QString::fromUtf8(item->node.c_str());
                m_name	   = QString::fromUtf8(item->name.c_str());
            }
            return e->param();
        }
    }
    return NULL;
}
Beispiel #17
0
void LayoutConfig::initUI()
{
    const char *modelName = m_rules->models()[m_kxkbConfig.m_model];
    if(modelName == NULL)
        modelName = DEFAULT_MODEL;

    widget->comboModel->setCurrentText(i18n(modelName));

    QValueList< LayoutUnit > otherLayouts = m_kxkbConfig.m_layouts;
    widget->listLayoutsDst->clear();
    // to optimize we should have gone from it.end to it.begin
    QValueList< LayoutUnit >::ConstIterator it;
    for(it = otherLayouts.begin(); it != otherLayouts.end(); ++it)
    {
        QListViewItemIterator src_it(widget->listLayoutsSrc);
        LayoutUnit layoutUnit = *it;

        for(; src_it.current(); ++src_it)
        {
            QListViewItem *srcItem = src_it.current();

            if(layoutUnit.layout == src_it.current()->text(LAYOUT_COLUMN_MAP))
            { // check if current config knows about this layout
                QListViewItem *newItem = copyLVI(srcItem, widget->listLayoutsDst);

                newItem->setText(LAYOUT_COLUMN_VARIANT, layoutUnit.variant);
                newItem->setText(LAYOUT_COLUMN_INCLUDE, layoutUnit.includeGroup);
                newItem->setText(LAYOUT_COLUMN_DISPLAY_NAME, layoutUnit.displayName);
                widget->listLayoutsDst->insertItem(newItem);
                newItem->moveItem(widget->listLayoutsDst->lastItem());

                break;
            }
        }
    }

    // display KXKB switching options
    widget->chkShowSingle->setChecked(m_kxkbConfig.m_showSingle);
    widget->chkShowFlag->setChecked(m_kxkbConfig.m_showFlag);

    widget->chkEnableOptions->setChecked(m_kxkbConfig.m_enableXkbOptions);
    widget->checkResetOld->setChecked(m_kxkbConfig.m_resetOldOptions);

    switch(m_kxkbConfig.m_switchingPolicy)
    {
        default:
        case SWITCH_POLICY_GLOBAL:
            widget->grpSwitching->setButton(0);
            break;
        case SWITCH_POLICY_WIN_CLASS:
            widget->grpSwitching->setButton(1);
            break;
        case SWITCH_POLICY_WINDOW:
            widget->grpSwitching->setButton(2);
            break;
    }

    widget->chkEnableSticky->setChecked(m_kxkbConfig.m_stickySwitching);
    widget->spinStickyDepth->setEnabled(m_kxkbConfig.m_stickySwitching);
    widget->spinStickyDepth->setValue(m_kxkbConfig.m_stickySwitchingDepth);

    updateStickyLimit();

    widget->chkEnable->setChecked(m_kxkbConfig.m_useKxkb);
    widget->grpLayouts->setEnabled(m_kxkbConfig.m_useKxkb);
    widget->optionsFrame->setEnabled(m_kxkbConfig.m_useKxkb);

    // display xkb options
    QStringList options = QStringList::split(',', m_kxkbConfig.m_options);
    for(QStringList::ConstIterator it = options.begin(); it != options.end(); ++it)
    {
        QString option = *it;
        QString optionKey = option.mid(0, option.find(':'));
        QString optionName = m_rules->options()[option];
        OptionListItem *item = m_optionGroups[i18n(optionKey.latin1())];

        if(item != NULL)
        {
            OptionListItem *child = item->findChildItem(option);

            if(child)
                child->setState(QCheckListItem::On);
            else
                kdDebug() << "load: Unknown option: " << option << endl;
        }
        else
        {
            kdDebug() << "load: Unknown option group: " << optionKey << " of " << option << endl;
        }
    }

    updateOptionsCommand();
    emit KCModule::changed(false);
}
Beispiel #18
0
void *JabberBrowser::processEvent(Event *e)
{
    if (e->type() == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->EventAgentInfo){
        JabberAgentInfo *data = (JabberAgentInfo*)(e->param());
        if (m_search_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_search_id = "";
                    delete m_search;
                    m_search = NULL;
                    Command cmd;
                    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdSearch;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_search->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showSearch()));
                }
                m_search_id = "";
                return e->param();
            }
            m_search->m_search->addWidget(data);
            return e->param();
        }
        if (m_reg_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_reg_id = "";
                    delete m_reg;
                    m_reg = NULL;
                    Command cmd;
                    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdRegister;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_reg->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showReg()));
                }
                m_reg_id = "";
                return e->param();
            }
            m_reg->m_search->addWidget(data);
            return e->param();
        }
        if (m_config_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_config_id = "";
                    delete m_config;
                    m_config = NULL;
                    Command cmd;
                    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdConfigure;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_config->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showConfig()));
                }
                m_config_id = "";
                return e->param();
            }
            m_config->m_search->addWidget(data);
            return e->param();
        }
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != this)
            return NULL;
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdSearch){
            if (m_search)
                delete m_search;
            m_search = new JabberWizard(this, I18N_NOOP("%1 Search"), "find", m_client, m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "search");
            m_search_id = m_client->get_agent_info(m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "search");
            return e->param();
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdRegister){
            if (m_reg)
                delete m_reg;
            m_reg = new JabberWizard(this, I18N_NOOP("%1 Register"), "reg", m_client, m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "register");
            m_reg_id = m_client->get_agent_info(m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "register");
            return e->param();
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdConfigure){
            if (m_config)
                delete m_config;
            m_config = new JabberWizard(this, I18N_NOOP("%1 Configure"), "configure", m_client, m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "data");
            m_config_id = m_client->get_agent_info(m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "data");
            return e->param();
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdBack){
            if (m_historyPos){
                m_historyPos--;
                QString url  = QString::fromUtf8(m_history[m_historyPos].c_str());
                QString node;
                if (!m_nodes[m_historyPos].empty())
                    node = QString::fromUtf8(m_nodes[m_historyPos].c_str());
                go(url, node);
            }
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdForward){
            if (m_historyPos + 1 < (int)(m_history.size())){
                m_historyPos++;
                QString url  = QString::fromUtf8(m_history[m_historyPos].c_str());
                QString node;
                if (!m_nodes[m_historyPos].empty())
                    node = QString::fromUtf8(m_nodes[m_historyPos].c_str());
                go(url, node);
            }
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdUrl){
            if (!m_id1.empty() || !m_id2.empty()){
                stop("");
                return e->param();
            }
            QString jid;
            QString node;
            Command cmd;
            cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdUrl;
            cmd->param	= this;
            Event eWidget(EventCommandWidget, cmd);
            CToolCombo *cmbUrl = (CToolCombo*)(eWidget.process());
            if (cmbUrl)
                jid = cmbUrl->lineEdit()->text();
            cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdNode;
            CToolCombo *cmbNode = (CToolCombo*)(eWidget.process());
            if (cmbNode)
                node = cmbNode->lineEdit()->text();
            if (!jid.isEmpty()){
                addHistory(jid);
                goUrl(jid, node);
            }
            return e->param();
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdInfo){
            if (m_category.isEmpty() && m_type.isEmpty() && m_name.isEmpty() && m_features.isEmpty())
                return e->param();
            if (m_info == NULL)
                m_info = new DiscoInfo(this);
            m_info->reset();
            raiseWindow(m_info);
            return e->param();
        }
    }
    if (e->type() == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->EventDiscoItem){
        JabberDiscoItem *item = (JabberDiscoItem*)(e->param());
        if (m_id1 == item->id){
            if (item->jid.empty()){
                m_id1 = "";
                m_list->adjustColumn();
                QString err;
                if (!item->name.empty()){
                    err = QString::fromUtf8(item->name.c_str());
                }else if (!item->node.empty()){
                    err = i18n("Error %1") .arg(atol(item->node.c_str()));
                }
                if (err.isEmpty() || m_id2.empty())
                    stop(err);
                return e->param();
            }
            QListViewItem *i = new QListViewItem(m_list);
            i->setText(COL_JID, QString::fromUtf8(item->jid.c_str()));
            i->setText(COL_NAME, QString::fromUtf8(item->name.c_str()));
            i->setText(COL_NODE, QString::fromUtf8(item->node.c_str()));
            return e->param();
        }
        if (m_id2 == item->id){
            if (item->jid.empty()){
                m_id2 = "";
                m_list->adjustColumn();
                QString err;
                if (!item->name.empty()){
                    err = QString::fromUtf8(item->name.c_str());
                }else if (!item->node.empty()){
                    err = i18n("Error %1") .arg(atol(item->node.c_str()));
                }
                if (m_id1.empty())
                    stop(err);
                return e->param();
            }
            if (item->jid == "feature"){
                if (!m_features.isEmpty())
                    m_features += "\n";
                m_features += QString::fromUtf8(item->name.c_str());
            }else{
                m_category = QString::fromUtf8(item->jid.c_str());
                m_type	   = QString::fromUtf8(item->node.c_str());
                m_name	   = QString::fromUtf8(item->name.c_str());
            }
            return e->param();
        }
    }
    return NULL;
}
Beispiel #19
0
void *AddResult::processEvent(Event *e)
{
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->menu_id == MenuSearchResult){
            Contact *contact;
            if (cmd->id == CmdJabberMessage){
                contact = createContact(CONTACT_TEMP);
                if (!contact) return NULL;
                Message *msg = new Message(MessageGeneric);
                msg->setContact(contact->id());
                Event e(EventOpenMessage, &msg);
                e.process();
                delete msg;
            }
            if (cmd->id == CmdInfo){
                JabberUserData *data;
                contact = createContact(CONTACT_TEMP, &data);
                if (!contact) return NULL;
                m_client->updateInfo(contact, data);
                Command cmd;
                cmd->id = CmdInfo;
                cmd->menu_id = MenuContact;
                cmd->param   = (void*)contact->id();
                Event e(EventCommandExec, cmd);
                e.process();
            }
            return e->param();
        }
        if (cmd->menu_id == MenuJabberGroups){
            Contact *contact = createContact(0);
            if (!contact) return NULL;
            contact->setGroup(cmd->id - 1);
            Event eContact(EventContactChanged, contact);
            eContact.process();
            return e->param();
        }
    }
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if ((cmd->menu_id == MenuJabberGroups) &&
                (cmd->id == CmdGroups)){
            unsigned n = 1;
            ContactList::GroupIterator it;
            while (++it)
                n++;
            CommandDef *cmds = new CommandDef[n];
            memset(cmds, 0, sizeof(CommandDef) * n);
            n = 0;
            it.reset();
            Group *grp;
            while ((grp = ++it) != NULL){
                cmds[n].id		 = grp->id() + 1;
                cmds[n].text	 = "_";
                QString name = grp->getName();
                if (grp->id() == 0)
                    name = i18n("Not in list");
                cmds[n].text_wrk = strdup(name.utf8());
                n++;
            }
            cmd->param = cmds;
            cmd->flags |= COMMAND_RECURSIVE;
            return e->param();
        }
    }
    if (e->type() == EventSearch){
        JabberSearchData *data = (JabberSearchData*)(e->param());
        if (m_searchId == data->ID.ptr){
            if (m_bXSearch){
                if (data->JID.ptr){
                    m_nFound++;
                    lblStatus->setText(i18n("Search") + foundStatus());
                    QListViewItem *item = new QListViewItem(tblUser);
                    item->setText(0, QString::fromUtf8(data->JID.ptr));
                    for (unsigned col = 0; col < data->nFields.value; col++)
                        item->setText(col + 1, QString::fromUtf8(get_str(data->Fields, col)));
                }else{
                    for (unsigned col = 0; col < data->nFields.value; col++)
                        tblUser->addColumn(QString::fromUtf8(get_str(data->Fields, col)));
                    tblUser->adjustColumn();
                }
            }else{
                m_nFound++;
                lblStatus->setText(i18n("Search") + foundStatus());
                QListViewItem *item = new QListViewItem(tblUser);
                if (data->JID.ptr)
                    item->setText(0, QString::fromUtf8(data->JID.ptr));
                if (data->Nick.ptr)
                    item->setText(1, QString::fromUtf8(data->Nick.ptr));
                if (data->First.ptr)
                    item->setText(2, QString::fromUtf8(data->First.ptr));
                if (data->Last.ptr)
                    item->setText(3, QString::fromUtf8(data->Last.ptr));
                if (data->EMail.ptr)
                    item->setText(4, QString::fromUtf8(data->EMail.ptr));
            }
        }
    }
    if ((e->type() == EventSearchDone) && (m_searchId == (const char*)(e->param()))){
        lblStatus->setText(i18n("Search done") + foundStatus());
        m_searchId = "";
        tblUser->adjustColumn();
        currentChanged(NULL);
    }
    return NULL;
}
Beispiel #20
0
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);
}
Beispiel #21
0
/**
 * 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;
}
Beispiel #22
0
void *DiscoInfo::processEvent(Event *e)
{
    if (e->type() == static_cast<JabberPlugin*>(m_browser->m_client->protocol()->plugin())->EventVCard){
        JabberUserData *data = (JabberUserData*)(e->param());
        if (!str_cmp(m_data.ID, data->ID) && !str_cmp(m_data.Node, data->Node)){
            edtFirstName->setText(data->FirstName ? QString::fromUtf8(data->FirstName) : QString(""));
            edtNick->setText(data->Nick ? QString::fromUtf8(data->Nick) : QString(""));
            edtBirthday->setText(data->Bday ? QString::fromUtf8(data->Bday) : QString(""));
            edtUrl->setText(data->Url ? QString::fromUtf8(data->Url) : QString(""));
            urlChanged(edtUrl->text());
            edtEMail->setText(data->EMail ? QString::fromUtf8(data->EMail) : QString(""));
            edtPhone->setText(data->Phone ? QString::fromUtf8(data->Phone) : QString(""));
        }
    }
    if (e->type() == static_cast<JabberPlugin*>(m_browser->m_client->protocol()->plugin())->EventDiscoItem){
        JabberDiscoItem *item = (JabberDiscoItem*)(e->param());
        if (m_versionId == item->id){
            m_versionId = "";
            edtName->setText(QString::fromUtf8(item->name.c_str()));
            edtVersion->setText(QString::fromUtf8(item->jid.c_str()));
            edtSystem->setText(QString::fromUtf8(item->node.c_str()));
            return e->param();
        }
        if (m_timeId == item->id){
            m_timeId = "";
            edtTime->setText(QString::fromUtf8(item->jid.c_str()));
            return e->param();
        }
        if (m_statId == item->id){
            if (item->jid.empty()){
                m_statId = "";
                return e->param();
            }
            QListViewItem *i = new QListViewItem(lstStat);
            i->setText(0, QString::fromUtf8(item->jid.c_str()));
            i->setText(1, QString::fromUtf8(item->name.c_str()));
            i->setText(2, QString::fromUtf8(item->node.c_str()));
            return e->param();
        }
        if (m_lastId == item->id){
            m_lastId = "";
            unsigned ss = atol(item->jid.c_str());
            unsigned mm = ss / 60;
            ss -= mm * 60;
            unsigned hh = mm / 60;
            mm -= hh * 60;
            unsigned dd = hh / 24;
            hh -= dd * 24;
            QString date;
            if (dd){
                date  = i18n("%n day", "%n days", dd);
                date += " ";
            }
            QString time;
            time.sprintf("%02u:%02u:%02u", hh, mm, ss);
            date += time;
            edtLast->setText(date);
            return e->param();
        }
    }
    return NULL;
}
Beispiel #23
0
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);
		}
	    }
	}
    }
}
Beispiel #24
0
void KeySetup::keyChanged()
{
    QListViewItem *item = lstActions->currentItem();
    if (item == NULL) return;
    item->setText(1, chkEnable->isChecked() ? btnKey->text() : QString(""));
}
void TeamMembersDlg::slotEditMember()
{
   QListViewItem *item =membersListView->currentItem();
   if (!item) return;
   KDialogBase editDlg(this, "edit_member", true, i18n("Edit Member"), KDialogBase::Ok | KDialogBase::Cancel);
   MemberEditDlg memberDlg(&editDlg);
   memberDlg.selectMember(item->text(NAME_COL));
   memberDlg.nicknameEdit->setText(item->text(NICKNAME_COL));
   memberDlg.emailEdit->setText(item->text(EMAIL_COL));
   QString role = item->text(ROLE_COL);
   for (int i = 0; i < memberDlg.roleCombo->count(); i++)
   {
      if (memberDlg.roleCombo->text(i) == role)
      {
         memberDlg.roleCombo->setCurrentItem(i);
         memberDlg.slotRoleSelected(role);
         break;
      }
   }
   memberDlg.taskEdit->setText(item->text(TASK_COL));
   int idx = 0;
   int subprojectIdx = 0;
   QValueList<SubProject> *subprojects = Project::ref()->subprojects();
   for (QValueList<SubProject>::ConstIterator it = subprojects->constBegin(); it != subprojects->constEnd(); ++it)
   {
      if (item->text(SUBPROJECT_COL) == (*it).name)
      {
        subprojectIdx = idx;
        break;
      }
      idx++;
   }
   memberDlg.subprojectCombo->setCurrentItem(subprojectIdx);

   editDlg.setMainWidget(&memberDlg);
   bool result;
   do {
     result = editDlg.exec();
     if (result)
     {
        QString name = memberDlg.nameCombo->currentText();
        QString nickName = memberDlg.nicknameEdit->text();
        QString email = memberDlg.emailEdit->text();
        QString role = memberDlg.roleCombo->currentText();
        QString task = memberDlg.taskEdit->text();
        QString subProject = memberDlg.subprojectCombo->currentText();
        if (name.isEmpty())
        {
           KMessageBox::error(this, i18n("The member name cannot be empty."));
           editDlg.show();
        } else
         if (nickName.isEmpty())
        {
           KMessageBox::error(this, i18n("The nickname cannot be empty as it is used as a unique identifier."));
           editDlg.show();
        } else
       if (!checkDuplicates(item, name, nickName, email, role, task, subProject))
        {
          editDlg.show();
        } else
        {
          item->setText(NAME_COL, name);
          item->setText(NICKNAME_COL, nickName);
          item->setText(EMAIL_COL, email);
          item->setText(ROLE_COL, role);
          item->setText(TASK_COL, task);
          if (memberDlg.subprojectCombo->isEnabled())
            item->setText(SUBPROJECT_COL, subProject);
          result = false;
        }
     }
   } while (result);
}
BookmarksSettingsPage::BookmarksSettingsPage(QWidget*parent) :
    SettingsPageBase(parent),
    m_addButton(0),
    m_removeButton(0),
    m_moveUpButton(0),
    m_moveDownButton(0)
{
    QVBoxLayout* topLayout = new QVBoxLayout(parent, 2, KDialog::spacingHint());

    const int spacing = KDialog::spacingHint();

    QHBox* hBox = new QHBox(parent);
    hBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    hBox->setSpacing(spacing);
    hBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);

    m_listView = new KListView(hBox);
    m_listView->addColumn(i18n("Icon"));
    m_listView->addColumn(i18n("Name"));
    m_listView->addColumn(i18n("Location"));
    m_listView->setResizeMode(QListView::LastColumn);
    m_listView->setColumnAlignment(0, Qt::AlignHCenter);
    m_listView->setAllColumnsShowFocus(true);
    m_listView->setSorting(-1);
    connect(m_listView, SIGNAL(selectionChanged()),
            this, SLOT(updateButtons()));
    connect(m_listView, SIGNAL(pressed(QListViewItem*)),
            this, SLOT(slotBookmarkPressed(QListViewItem*)));
    connect(m_listView, SIGNAL(doubleClicked(QListViewItem*, const QPoint&, int)),
            this, SLOT(slotBookmarkDoubleClicked(QListViewItem*, const QPoint&, int)));

    QVBox* buttonBox = new QVBox(hBox);
    buttonBox->setSpacing(spacing);

    const QSizePolicy buttonSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);

    m_addButton = new KPushButton(i18n("Add..."), buttonBox);
    connect(m_addButton, SIGNAL(clicked()),
            this, SLOT(slotAddButtonClicked()));
    m_addButton->setSizePolicy(buttonSizePolicy);

    m_editButton = new KPushButton(i18n("Edit..."), buttonBox);
    connect(m_editButton, SIGNAL(clicked()),
            this, SLOT(slotEditButtonClicked()));
    m_editButton->setSizePolicy(buttonSizePolicy);

    m_removeButton = new KPushButton(i18n("Remove"), buttonBox);
    connect(m_removeButton, SIGNAL(clicked()),
            this, SLOT(slotRemoveButtonClicked()));
    m_removeButton->setSizePolicy(buttonSizePolicy);

    m_moveUpButton = new KPushButton(i18n("Move Up"), buttonBox);
    connect(m_moveUpButton, SIGNAL(clicked()),
            this, SLOT(slotMoveUpButtonClicked()));
    m_moveUpButton->setSizePolicy(buttonSizePolicy);

    m_moveDownButton = new KPushButton(i18n("Move Down"), buttonBox);
    connect(m_moveDownButton, SIGNAL(clicked()),
            this, SLOT(slotMoveDownButtonClicked()));
    m_moveDownButton->setSizePolicy(buttonSizePolicy);

    // Add a dummy widget with no restriction regarding a vertical resizing.
    // This assures that the spacing between the buttons is not increased.
    new QWidget(buttonBox);

    topLayout->addWidget(hBox);

    // insert all editable bookmarks.
    KBookmarkGroup root = DolphinSettings::instance().bookmarkManager()->root();
    KBookmark bookmark = root.first();

    QListViewItem* prev = 0;
    while (!bookmark.isNull()) {
        QListViewItem* item = new QListViewItem(m_listView);
        item->setPixmap(PixmapIdx, SmallIcon(bookmark.icon()));
        item->setText(NameIdx, bookmark.text());
        item->setText(URLIdx, bookmark.url().prettyURL());

        // add hidden column to be able to retrieve the icon name again
        item->setText(IconIdx, bookmark.icon());

        m_listView->insertItem(item);
        if (prev != 0) {
            item->moveItem(prev);
        }
        prev = item;

        bookmark = root.next(bookmark);
    }
    m_listView->setSelected(m_listView->firstChild(), true);

    updateButtons();
}
Beispiel #27
0
void
wCatalogEditor::openForm(const bool toSelect)
{

	
	aLog::print(aLog::MT_DEBUG, tr("wCatalog Editor open form for select=%1 ").arg((int)toSelect));
	MainForm *mainform;
	if(parent())
	{
		mainform = (MainForm*) topLevelWidget();
		ws = mainform->ws;
	}
//  aWindowsList *wl = mainform->wl;
	int objid = catId;
/*	if ( wl->find( objid ) )
    	{
//		wl->remove(objid);
		wl->get( objid )->setFocus();
		return;
    	}
	else
	{
  		CatalogForm* newform = new CatalogForm(ws,0, WDestructiveClose);
		wl->insert( objid, newform );
	}*/
	CatalogForm* newform = new CatalogForm(ws,0, WDestructiveClose);

	connect( newform,	SIGNAL(selected(Q_ULLONG)),
  		 this,		SLOT(on_selected( Q_ULLONG )));
	connect( newform, 	SIGNAL(destroyed()),
  	  	 this,		SLOT(on_destroyed_form()));

	aCatalogue *cat = new aCatalogue(md->find(catId),db);
	int count=0;
	bool est=true;
	QMap<Q_ULLONG,QListViewItem*> map, map_el;
	aCfgItem tmp, tmp_f,tmp_el,tmp_group, o;
	QListViewItem * item;
	QListViewItem * p_item;
	Q_ULLONG idGrForm=0, idElForm=0;
	QStringList listPos, listPosGroup;
	newform->ListHint->hide();
	QPixmap pixmap(newform->getGroupPixmap());
	QPixmap pixmap_mark_deleted(newform->getMarkDeletedPixmap());
	tmp = md->find(catId);
	newform->setCaption(md->attr(tmp,mda_name));
	o = md->findChild(tmp, md_forms); // get obj forms
  	if(!o.isNull())
  	{
		count = md->count(o,md_form);
		for(int i=0; i<count; i++)
		{
			tmp_f = md->findChild(o,md_form,i);
			if(!tmp_f.isNull()
			   && atoi(md->attr(tmp_f,mda_type).ascii())==md_form_elem)
	 		{
				aLog::print(aLog::MT_DEBUG, tr("wCatalog Editor found element forms"));
				idElForm = md->id(tmp_f);
//				 continue;
	 		}
			if(!tmp_f.isNull()
			   && atoi(md->attr(tmp_f,mda_type).ascii())==md_form_group)
	 		{
				aLog::print(aLog::MT_DEBUG, tr("wCatalog Editor found group forms"));
				idGrForm = md->id(tmp_f);
	 		}
		}
  	}
	else
	{
		aLog::print(aLog::MT_ERROR, tr("wCatalog Editor meta object forms not found"));
	}
	tmp_el = md->findChild(tmp, md_element);
	tmp_group = md->findChild(tmp,md_group);
	tmp = md->findChild(tmp_el, md_field);
	int count_fields = md->count(tmp_el,md_field);
	listPosGroup = cat->getGroupUserFields();
	int i,level = 0;
	cat->Select();
  	while(est) // add group in tree on levels
  	{
		est = false;
		++level;
		cat->selectByLevel(level-1);

  		if(!cat->FirstInGroupTable()) break;
  		do
  		{
			if(cat->GroupSysValue("level").toInt()==level-1) //all groups, having this level
			{
				est = true;
				QString displayString;
				displayString= cat->GroupSysValue(listPosGroup[0]).toString();
				if(map.contains(cat->GroupSysValue("idp").toULongLong()))
				{
					p_item = map[(cat->GroupSysValue("idp").toULongLong())];
					item = new QListViewItem(p_item);
				}
				else
				{
					item = new QListViewItem(newform->ListView);
					newform->ListView->insertItem(item);
				}
				item->setText(0, displayString);
				if(cat->isGroupMarkDeleted())
					item->setPixmap(0,pixmap_mark_deleted);
				else
					item->setPixmap(0,pixmap);

				map.insert(cat->GroupSysValue("id").toULongLong(),item);
			//printf("%lu\n",cat->GroupSysValue("id").toULongLong());

			}


		}while(cat->NextInGroupTable());

	}
  	listPos = cat->getUserFields();
	checkUserFields(listPos);
	int fid;
	//sets column name
	for(uint i=0; i<listPos.count(); i++)
  	{
		fid = atoi(listPos[i].remove("uf",false).ascii());
		if(!fid)
		{
//			printf("listPos[]=%s",listPos[i].remove("text_uf",false).ascii());
			fid = (listPos[i].remove("text_",false)).toInt();
			//tmp = md->find(fid);
		}
		if(fid)
		{
			tmp = md->find(fid);
			newform->ListView->addColumn(md->attr(tmp,mda_name));
		}
  	}

	listPos.clear();
	listPos = cat->getUserFields();
	checkUserFields(listPos);
  	//Q_ULLONG res = 0;		
   	// cat deleted in function catalogform::destroy(); 

 	 newform->setData(	cat,
		   		map,
		   		listPos,
		   		cat->getGroupUserFields(),
		   		idElForm,
		   		idGrForm,
				toSelect);

	newform->setId(value().toULongLong());
	newform->show();
	((QWidget*)newform->parent())->move(0,0);
}
void PageAutoConnect::add_pressed()
{
    int fnd = 0;
    QListViewItem *s = 0;

    s = KLVAutoConnect->selectedItem();
    if(!s){ /* new item */
	QString server = ServerLE->text();
	QString ssl = QString::null;
	QString port;

	port.setNum(PortKI->value());
	if(sslCB->isChecked())
	    ssl = i18n("SSL");

	s = new QListViewItem(KLVAutoConnect, server, port, PassLE->text(), ssl);
	s->setOpen(TRUE);
	s = new QListViewItem(s, ChannelLE->text(), KeyLE->text());
        KLVAutoConnect->setCurrentItem(s);
    }
    else { /* update the existing one */
	QListViewItem *parent;
	QListViewItem *child;

	if(s->parent()){
	    parent = s->parent();
            child = s;
	}
	else {
	    parent = s;
            child = 0x0;
	}

	parent->setText(NAME, ServerLE->text());
	parent->setText(PK, QString("%1").arg(PortKI->value()));
	parent->setText(PASS, PassLE->text());
	if(sslCB->isChecked())
	    parent->setText(SSL, i18n("SSL"));
	else
	    parent->setText(SSL, QString::null);

	if(child){
	    child->setText(NAME, ChannelLE->text());
	    child->setText(PK, KeyLE->text());
	}
	else {
	    if(ChannelLE->text().length() > 0){
                fnd = 0;
		QListViewItem *c = parent->firstChild();
		for( ; c != 0 && fnd == 0; c = c->nextSibling()){
		    if(c->text(NAME) == ChannelLE->text()){
			c->setText(PK, KeyLE->text());
			fnd = 1;
		    }
		}
		if(fnd == 0){
		    new QListViewItem(parent, ChannelLE->text(), KeyLE->text());
		}
	    }
	}

    }
    changed();
}
Beispiel #29
0
// --------------------------------------------------------------------------------
void QmvSelect::init()
{
    current_item = -1;
    setCaption( tr( "Select" ) );

        // ------------------------------------------------------------
        // Top level layout - add a groupbox, and manage it manually
        // ------------------------------------------------------------
    QVBoxLayout * vl_top = new QVBoxLayout( this );
    QLabel * lbl = new QLabel( "Select from list", this, "selection list" );
    vl_top->addWidget( lbl );

        // ------------------------------------------------------------
        // Create the listview.
        // ------------------------------------------------------------
    list_view = new QListView( this, "select list" );
    vl_top->addWidget( list_view );
    list_view->setAllColumnsShowFocus(TRUE);
    bool increasing = (sort_by >= 0) ? true : false;
    if ( sort_by < 0 ) sort_by = -sort_by;
    list_view->setSorting( sort_by, increasing );
    list_view->setShowSortIndicator( true );

        // clicked
    connect( list_view, SIGNAL( currentChanged( QListViewItem * ) ),
             this, SLOT( highlighted( QListViewItem * ) ) );
        // select
    connect( list_view, SIGNAL( doubleClicked( QListViewItem * ) ),
             this, SLOT( selected( QListViewItem * ) ) );

        // ----------------
        // Column Headings:
        // ----------------
    num_cols = label_list.count();
    for ( int col = 0; col < num_cols; col++ )
        list_view->addColumn( label_list[col] );
    
        // Add the index column at the right
    index_column = list_view->addColumn( "#" );

        // ----------------
        // Load the rows.
        // ----------------
    
    list_view->clear();
    list_view->setFocusPolicy(StrongFocus);
    QListViewItem * item = 0;
    QListViewItem * after = 0;

        // load the rows
    num_rows = value_list.count();
    for ( int row = 0; row < num_rows; row++)
    {
            // Place first item at top of list.
        if ( row == 0 )
            item = new QListViewItem( list_view );
        else
            item = new QListViewItem( list_view, after );

            // Extract the stringlist first
        QStringList * sl = value_list.at(row);
        if (sl) {
                // Load the strings into items
            for ( int col = 0; col < num_cols; col++ ) {
                if (sl->at(col) == sl->end())   // at() returns iterator
                    continue;
                item->setText( col, (*(sl->at(col))) );
            }
        }
            // Extract the pixmap list
        QList<QPixmap> * pl = pixmap_list.at(row);
        if (pl) {
                // Load the pixmaps
            int pm_count = pl->count();
            for ( int col = 0; col < num_cols; col++ ) {
                QPixmap * pm;
                pm = pl->at(col);               // at() returns pointer to pixmap
                if (!pm || pm->isNull() )
                    continue;
                item->setPixmap( col, *pm );
                item->setText( col, "");        // unset the text
            }
            
        }

            // the index column
        int index = 1 + static_cast<int> (floor(log10(num_rows)));
        QString format = QString("0%1d").arg(index);
        format.prepend("%");
        item->setText( num_cols, QString("%1").sprintf(format,row) );

        after = item;
        
    }
        
    QHBoxLayout * hl_button = new QHBoxLayout( vl_top );
    QPushButton *pb;
    pb = new QPushButton("OK", this );
    pb->setDefault(TRUE);
    hl_button->addWidget( pb );
    connect( pb, SIGNAL( clicked() ), this, SLOT( accept() ) );
    pb = new QPushButton( "Cancel", this );
    hl_button->addWidget( pb );
    connect( pb, SIGNAL( clicked() ), this, SLOT( reject() ) );

        // cancel
    connect( this, SIGNAL( escapePressed() ),
             this, SLOT( cancelSelect() ) );

        // Highlight the first row
    
    QListViewItem *first = list_view->firstChild();
    if ( first )
    {
        list_view->setCurrentItem( first );
        list_view->setSelected( first, TRUE );
    } else {
        pb->setFocus();
    }
    

    setFocusProxy( list_view );
    adjustSize();
    updateGeometry();
//  no need to set focus - has been set above by setCurrentItem
//  setFocus();

}