void SetupDialog::iconChanged() { setIcon(Pict("configure")); for (QListViewItem *item = lstBars->firstChild(); item != NULL; item = item->nextSibling()) iconChanged(item); }
void AnnotationOutput::readAnnotations() { if (!Project::ref()->hasProject()) { m_allAnnotations->clear(); m_yourAnnotations->clear(); m_yourAnnotationsNum = 0; setTabLabel(m_yourAnnotations, i18n("For You")); return; } KURL baseURL = Project::ref()->projectBaseURL(); QStringList openedItems; QListViewItem *item = m_allAnnotations->firstChild(); while (item) { if (item->isOpen()) openedItems += item->text(0); item = item->nextSibling(); } m_allAnnotations->clear(); m_annotatedFileItems.clear(); m_fileNames.clear(); m_lines.clear(); QStringList yourOpenedItems; item = m_yourAnnotations->firstChild(); while (item) { if (item->isOpen()) yourOpenedItems += item->text(0); item = item->nextSibling(); } m_yourAnnotations->clear(); m_yourFileItems.clear(); m_yourFileNames.clear(); m_yourLines.clear(); m_yourAnnotationsNum = 0; QDomElement annotationElement = Project::ref()->dom()->firstChild().firstChild().namedItem("annotations").toElement(); if (annotationElement.isNull()) return; QString yourself = Project::ref()->yourself().lower(); QStringList roles = Project::ref()->yourRoles(); QDomNodeList nodes = annotationElement.childNodes(); int count = nodes.count(); for (int i = 0; i < count; i++) { QDomElement el = nodes.item(i).toElement(); QString fileName = el.attribute("url"); KURL u = baseURL; QuantaCommon::setUrl(u, fileName); u = QExtFileInfo::toAbsolute(u, baseURL); if (Project::ref()->contains(u)) { bool ok; int line = el.attribute("line").toInt(&ok, 10); QString text = el.attribute("text"); QString receiver = el.attribute("receiver"); text.replace('\n',' '); QString lineText = QString("%1").arg(line); if (lineText.length() < 20) { QString s; s.fill('0', 20 - lineText.length()); lineText.prepend(s); } KListViewItem *fileIt = m_annotatedFileItems[fileName]; if (!fileIt) { fileIt = new KListViewItem(m_allAnnotations, fileName); m_annotatedFileItems.insert(fileName, fileIt); m_fileNames[fileIt] = u.url(); } KListViewItem *it = new KListViewItem(fileIt, fileIt, text, lineText); if (openedItems.contains(fileName)) fileIt->setOpen(true); m_fileNames[it] = u.url(); m_lines[it] = line; if (!yourself.isEmpty() && (receiver == yourself || roles.contains(receiver))) { m_yourAnnotationsNum++; KListViewItem *fileIt = m_yourFileItems[fileName]; if (!fileIt) { fileIt = new KListViewItem(m_yourAnnotations, fileName); m_yourFileItems.insert(fileName, fileIt); m_yourFileNames[fileIt] = u.url(); } KListViewItem *it = new KListViewItem(fileIt, fileIt, text, lineText); if (yourOpenedItems.contains(fileName)) fileIt->setOpen(true); m_yourFileNames[it] = u.url(); m_yourLines[it] = line; } } else { annotationElement.removeChild(el); } } if (m_yourAnnotationsNum > 0) { setTabLabel(m_yourAnnotations, i18n("For You: %1").arg(m_yourAnnotationsNum)); } else { setTabLabel(m_yourAnnotations, i18n("For You")); } }
QListViewItem* ServerListDialog::insertServerGroup(ServerGroupSettingsPtr serverGroup) { // Produce a list of this server group's channels QString channels; Konversation::ChannelList channelList = serverGroup->channelList(); Konversation::ChannelList::iterator channelIt; Konversation::ChannelList::iterator begin = channelList.begin(); for(channelIt = begin; channelIt != channelList.end(); ++channelIt) { if (channelIt != begin) channels += ", "; channels += (*channelIt).name(); } QListViewItem* networkItem = 0; // Insert the server group into the list networkItem = new ServerListItem(m_serverList, serverGroup->id(), serverGroup->sortIndex(), serverGroup->name(), serverGroup->identity()->getName(), channels); // Recreate expanded/collapsed state if (serverGroup->expanded()) networkItem->setOpen(true); // Produce a list of this server group's servers and iterate over it Konversation::ServerList serverList = serverGroup->serverList(); Konversation::ServerList::iterator serverIt; QListViewItem* serverItem = 0; int i = 0; for (serverIt = serverList.begin(); serverIt != serverList.end(); ++serverIt) { // Produce a string representation of the server object QString name = (*serverIt).host(); if ((*serverIt).port() != 6667) name += ':' + QString::number((*serverIt).port()); if ((*serverIt).SSLEnabled()) name += + " (SSL)"; // Insert the server into the list, as child of the server group list item serverItem = new ServerListItem(networkItem, serverGroup->id(), i, name, (*serverIt)); // The listview shouldn't allow this to be dragged serverItem->setDragEnabled(false); // Initialize a pointer to the new location of the last edited server if (m_selectedItem && m_selectedServer==(*serverIt)) m_selectedItemPtr = serverItem; ++i; } return networkItem; }
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(); }
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); }
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; }
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; }
void Project::slotOptions() { KURL url; KDialogBase optionsDlg(KDialogBase::Tabbed, WStyle_DialogBorder, d->m_mainWindow, "project_options", true, i18n("Project Settings"), KDialogBase::Ok | KDialogBase::Cancel); // optionsDlg.setMainWidget(&optionsPage); //add the main options page QFrame *page = optionsDlg.addPage(i18n("Options")); ProjectOptions optionsPage(page); QVBoxLayout *topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() ); topLayout->addWidget(&optionsPage); optionsPage.linePrjName->setText( d->projectName ); url = QExtFileInfo::toRelative(d->templateURL, d->baseURL); optionsPage.linePrjTmpl->setText(QuantaCommon::qUrl(url)); url = QExtFileInfo::toRelative(d->toolbarURL, d->baseURL); optionsPage.linePrjToolbar->setText( QuantaCommon::qUrl(url) ); optionsPage.lineAuthor->setText( d->author ); optionsPage.lineEmail->setText( d->email ); // Signals to handle debugger settings connect(optionsPage.buttonDebuggerOptions, SIGNAL(clicked()), d, SLOT(slotDebuggerOptions())); connect(optionsPage.comboDebuggerClient, SIGNAL(activated(const QString &)), d, SLOT(slotDebuggerChanged(const QString &))); // Debuggers Combo KTrader::OfferList offers = KTrader::self()->query("Quanta/Debugger"); KTrader::OfferList::ConstIterator iterDbg; optionsPage.comboDebuggerClient->clear(); optionsPage.comboDebuggerClient->insertItem(i18n("No Debugger")); int idxDbg = 0; d->m_debuggerClientEdit = d->debuggerClient; optionsPage.buttonDebuggerOptions->setEnabled(false); for(iterDbg = offers.begin(); iterDbg != offers.end(); ++iterDbg) { KService::Ptr service = *iterDbg; optionsPage.comboDebuggerClient->insertItem(service->name()); idxDbg++; if(d->debuggerClient == service->name()) { optionsPage.comboDebuggerClient->setCurrentItem(idxDbg); optionsPage.buttonDebuggerOptions->setEnabled(true); } } optionsPage.checkDebuggerPersistentBreakpoints->setChecked(d->m_debuggerPersistentBreakpoints); optionsPage.checkDebuggerPersistentWatches->setChecked(d->m_debuggerPersistentWatches); QString excludeStr; for (uint i = 0; i < d->excludeList.count(); i++) { excludeStr.append(d->excludeList[i]); excludeStr.append(";"); } optionsPage.lineExclude->setText(excludeStr); optionsPage.checkCvsignore->setChecked(d->m_excludeCvsignore); optionsPage.linePrefix->setText(d->previewPrefix.prettyURL()); QStringList lst = DTDs::ref()->nickNameList(true); uint pos = 0; for (uint i = 0; i < lst.count(); i++) { optionsPage.dtdCombo->insertItem(lst[i]); if (lst[i] == DTDs::ref()->getDTDNickNameFromName(d->m_defaultDTD)) pos = i; } optionsPage.dtdCombo->setCurrentItem(pos); QStringList availableEncodingNames(KGlobal::charsets()->availableEncodingNames()); optionsPage.encodingCombo->insertStringList( availableEncodingNames ); QStringList::ConstIterator iter; int iIndex = -1; for (iter = availableEncodingNames.begin(); iter != availableEncodingNames.end(); ++iter) { ++iIndex; if ((*iter).lower() == d->m_defaultEncoding.lower()) { optionsPage.encodingCombo->setCurrentItem(iIndex); break; } } QStringList list = d->projectViewList(); QString defaultView = d->dom.firstChild().firstChild().namedItem("autoload").toElement().attribute("projectview"); if (list.count() > 0) { optionsPage.viewCombo->insertStringList(list); for (uint i = 0; i < list.count(); i++) { if (list[i] == defaultView) { optionsPage.viewCombo->setCurrentItem(i); break; } } } else { optionsPage.viewCombo->insertItem(i18n("No view was saved yet.")); optionsPage.viewCombo->setEnabled(false); } optionsPage.checkPrefix->setChecked(d->usePreviewPrefix); optionsPage.checkPersistentBookmarks->setChecked(d->m_persistentBookmarks); //add upload profiles page page = optionsDlg.addPage(i18n("Up&load Profiles")); UploadProfilesPage uploadProfilesPage(page); topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() ); topLayout->addWidget(&uploadProfilesPage); QDomElement uploadEl = d->m_sessionDom.firstChild().firstChild().namedItem("uploadprofiles").toElement(); uploadProfilesPage.profileLabel->setText(uploadEl.attribute("defaultProfile")); uploadProfilesPage.checkShowUploadTreeviews->setChecked(d->m_showUploadTreeviews); //add the team members page page = optionsDlg.addPage(i18n("Team Configuration")); TeamMembersDlg membersPage(page); topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() ); topLayout->addWidget(&membersPage); QListViewItem *item; if (!teamLeader().name.isEmpty()) { TeamMember member = teamLeader(); item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Team Leader"), member.task); membersPage.membersListView->insertItem(item); } for (QMap<QString, TeamMember>::ConstIterator it = d->m_subprojectLeaders.constBegin(); it != d->m_subprojectLeaders.constEnd(); ++it) { TeamMember member = it.data(); item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Subproject Leader"), member.task, it.key()); } for (QMap<QString, TeamMember>::ConstIterator it = d->m_taskLeaders.constBegin(); it != d->m_taskLeaders.constEnd(); ++it) { TeamMember member = it.data(); item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Task Leader"), it.key()); } for (QValueList<TeamMember>::ConstIterator it = d->m_simpleMembers.constBegin(); it != d->m_simpleMembers.constEnd(); ++it) { TeamMember member = *it; item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Simple Member"), member.task); } membersPage.mailingListEdit->setText(d->m_mailingList); membersPage.setYourself(d->m_yourself); //add the event configuration page page = optionsDlg.addPage(i18n("Event Configuration")); EventConfigurationDlg eventsPage(d->m_mainWindow->actionCollection(), page); topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() ); topLayout->addWidget(&eventsPage); eventsPage.initEvents(d->m_events); eventsPage.enableEventsBox->setChecked(d->m_eventsEnabled); if ( optionsDlg.exec() ) { d->projectName = optionsPage.linePrjName->text(); d->author = optionsPage.lineAuthor ->text(); d->email = optionsPage.lineEmail ->text(); // Debugger d->debuggerClient = optionsPage.comboDebuggerClient->currentText(); d->m_debuggerPersistentBreakpoints = optionsPage.checkDebuggerPersistentBreakpoints->isChecked(); d->m_debuggerPersistentWatches = optionsPage.checkDebuggerPersistentWatches->isChecked(); d->m_defaultDTD = DTDs::ref()->getDTDNameFromNickName(optionsPage.dtdCombo->currentText()).lower(); d->m_defaultEncoding = optionsPage.encodingCombo->currentText(); QuantaCommon::setUrl(d->templateURL, optionsPage.linePrjTmpl->text()); d->templateURL.adjustPath(1); d->templateURL = QExtFileInfo::toAbsolute(d->templateURL, d->baseURL); if (!QExtFileInfo::createDir(d->templateURL, d->m_mainWindow)) { QuantaCommon::dirCreationError(d->m_mainWindow, d->templateURL); } QuantaCommon::setUrl(d->toolbarURL, optionsPage.linePrjToolbar->text()); d->toolbarURL.adjustPath(1); d->toolbarURL = QExtFileInfo::toAbsolute(d->toolbarURL, d->baseURL); if (!QExtFileInfo::createDir(d->toolbarURL, d->m_mainWindow)) { QuantaCommon::dirCreationError(d->m_mainWindow, d->toolbarURL); } d->previewPrefix = KURL::fromPathOrURL( optionsPage.linePrefix->text() ); d->usePreviewPrefix = optionsPage.checkPrefix->isChecked(); d->m_persistentBookmarks = optionsPage.checkPersistentBookmarks->isChecked(); QDomNode projectNode = d->dom.firstChild().firstChild(); QDomElement el; el = projectNode.toElement(); el.setAttribute("name",d->projectName); el.setAttribute("encoding", d->m_defaultEncoding); el = d->m_sessionDom.firstChild().firstChild().toElement(); el.setAttribute("previewPrefix", d->previewPrefix.url() ); el.setAttribute("usePreviewPrefix", d->usePreviewPrefix ); el.setAttribute("usePersistentBookmarks", d->m_persistentBookmarks); el = projectNode.namedItem("author").toElement(); if (!el.isNull()) el.parentNode().removeChild(el); el =d->dom.createElement("author"); projectNode.appendChild( el ); el.appendChild(d->dom.createTextNode( d->author ) ); el = projectNode.namedItem("email").toElement(); if (!el.isNull()) el.parentNode().removeChild(el); el =d->dom.createElement("email"); projectNode.appendChild( el ); el.appendChild(d->dom.createTextNode( d->email ) ); // Debugger el =projectNode.namedItem("debuggerclient").toElement(); if (!el.isNull()) el.parentNode().removeChild(el); el =d->dom.createElement("debuggerclient"); projectNode.appendChild( el ); el.appendChild(d->dom.createTextNode( d->debuggerClient ) ); el.setAttribute("persistentBreakpoints", d->m_debuggerPersistentBreakpoints); el.setAttribute("persistentWatches", d->m_debuggerPersistentWatches); d->m_excludeCvsignore = optionsPage.checkCvsignore->isChecked(); excludeStr = optionsPage.lineExclude->text(); el =projectNode.namedItem("exclude").toElement(); if (!el.isNull()) el.parentNode().removeChild(el); el =d->dom.createElement("exclude"); if (d->m_excludeCvsignore) el.setAttribute("cvsignore", "true"); else el.setAttribute("cvsignore", "false"); projectNode.appendChild( el ); el.appendChild(d->dom.createTextNode( excludeStr ) ); el =projectNode.namedItem("defaultDTD").toElement(); if(el.isNull()) { el =d->dom.createElement("defaultDTD"); projectNode.appendChild(el); el.appendChild(d->dom.createTextNode(d->m_defaultDTD)); } else { el.firstChild().setNodeValue(d->m_defaultDTD); } el = projectNode.namedItem("templates").toElement(); url = QExtFileInfo::toRelative(d->templateURL, d->baseURL); if(el.isNull()) { el =d->dom.createElement("templates"); projectNode.appendChild(el); el.appendChild(d->dom.createTextNode(QuantaCommon::qUrl(url))); } else { el.firstChild().setNodeValue(QuantaCommon::qUrl(url)); } url = QExtFileInfo::toRelative(d->toolbarURL, d->baseURL); el = projectNode.namedItem("toolbars").toElement(); if(el.isNull()) { el =d->dom.createElement("toolbars"); projectNode.appendChild(el); el.appendChild(d->dom.createTextNode(QuantaCommon::qUrl(url))); } else { el.firstChild().setNodeValue(QuantaCommon::qUrl(url)); } if (optionsPage.viewCombo->isEnabled()) { defaultView = optionsPage.viewCombo->currentText(); el = projectNode.namedItem("autoload").toElement(); if (el.isNull()) { el =d->dom.createElement("autoload"); el.setAttribute("projectview", defaultView); projectNode.appendChild( el ); } else { el.setAttribute("projectview", defaultView); } } uploadEl.setAttribute("showtreeviews", uploadProfilesPage.checkShowUploadTreeviews->isChecked() ? "true" : "false"); QDomNode teamNode = projectNode.namedItem("teamdata"); if (!teamNode.isNull()) projectNode.removeChild(teamNode); teamNode = d->dom.createElement("teamdata"); QDomNode taskLeadersNode = d->dom.createElement("taskleaders"); teamNode.appendChild(taskLeadersNode); QDomNode subLeadersNode = d->dom.createElement("subprojectleaders"); teamNode.appendChild(subLeadersNode); QListViewItemIterator it(membersPage.membersListView); QListViewItem *item; QStringList savedSubprojects; while (it.current()) { item = it.current(); QString role = item->text(3); if (role == i18n(teamLeaderStr.utf8())) { QDomElement leaderEl = d->dom.createElement("leader"); teamNode.appendChild(leaderEl); el = d->dom.createElement("name"); leaderEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(0))); el = d->dom.createElement("nickName"); leaderEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(1))); el = d->dom.createElement("email"); leaderEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(2))); } else if (role == i18n(subprojectLeaderStr.utf8())) { QString prjName = item->text(5); savedSubprojects.append(prjName); QDomElement subEl = d->dom.createElement("subproject"); for (uint i = 0; i < d->m_subprojects.count(); i++) { if (d->m_subprojects[i].name == prjName) { subEl.setAttribute("location", d->m_subprojects[i].location); break; } } subEl.setAttribute("name", prjName); subLeadersNode.appendChild(subEl); el = d->dom.createElement("subprojectleader"); el.setAttribute("name", item->text(0)); el.setAttribute("nickName", item->text(1)); el.setAttribute("email", item->text(2)); subEl.appendChild(el); } else if (role == i18n(taskLeaderStr.utf8())) { el = d->dom.createElement("projecttask"); el.setAttribute("tasklead", item->text(0)); el.setAttribute("nickName", item->text(1)); el.setAttribute("email", item->text(2)); el.setAttribute("task", item->text(4)); taskLeadersNode.appendChild(el); } else if (role == i18n(simpleMemberStr.utf8())) { QDomElement memberEl = d->dom.createElement("member"); memberEl.setAttribute("task", item->text(4)); teamNode.appendChild(memberEl); el = d->dom.createElement("name"); memberEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(0))); el = d->dom.createElement("nickName"); memberEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(1))); el = d->dom.createElement("email"); memberEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(2))); } ++it; } //subprojects without a leader for (uint i = 0; i < d->m_subprojects.count(); i++) { if (!savedSubprojects.contains(d->m_subprojects[i].name)) { el = d->dom.createElement("subproject"); el.setAttribute("name", d->m_subprojects[i].name); el.setAttribute("location", d->m_subprojects[i].location); } } el = d->dom.createElement("mailinglist"); el.setAttribute("address", membersPage.mailingListEdit->text()); teamNode.appendChild(el); projectNode.appendChild(teamNode); teamNode = d->m_sessionDom.firstChild().namedItem("teamdata"); if (!teamNode.isNull()) d->m_sessionDom.firstChild().removeChild(teamNode); d->m_yourself = membersPage.yourself(); el = d->m_sessionDom.createElement("teamdata"); el.setAttribute("yourself", d->m_yourself); d->m_sessionDom.firstChild().appendChild(el); eventsPage.saveEvents(d->dom); d->m_eventsEnabled = eventsPage.enableEventsBox->isChecked(); projectNode.toElement().setAttribute("enableEvents", d->m_eventsEnabled?"true":"false"); setModified(); d->loadProjectXML(); } }
/** * 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; }
void KstObjectItem::update(bool recursive) { switch (_rtti) { case RTTI_OBJ_DATA_VECTOR: { KstVectorPtr px = *KST::vectorList.findTag(_name); assert(px.data()); assert(dynamic_cast<KstRVector*>(px.data())); KstRVectorPtr x = static_cast<KstRVector*>(px.data()); setText(2, QString::number(x->getUsage() - 3)); // caller has a ptr setText(3, QString::number(x->sampleCount())); setText(4, i18n("%3: %4 [%1..%2]").arg(x->reqStartFrame()) .arg(x->reqStartFrame() + x->reqNumFrames()) .arg(x->getFilename()) .arg(x->getField())); _removable = x->getUsage() == 3; break; } case RTTI_OBJ_VECTOR: { KstVectorPtr x = *KST::vectorList.findTag(_name); assert(x.data()); setText(2, QString::number(x->getUsage() - 2)); //caller also points setText(3, QString::number(x->sampleCount())); setText(4, i18n("[%1..%2]").arg(x->min()).arg(x->max())); _removable = false; break; } case RTTI_OBJ_OBJECT: { KstDataObjectPtr x = *KST::dataObjectList.findTag(_name); assert(x.data()); setText(1, x->typeString()); setText(2, QString::number(x->getUsage() - 1)); // our pointer setText(3, QString::number(x->sampleCount())); setText(4, x->propertyString()); if (recursive) { QPtrStack<QListViewItem> trash; for (QListViewItem *i = firstChild(); i; i = i->nextSibling()) { KstObjectItem *oi = static_cast<KstObjectItem*>(i); if (x->outputVectors().findTag(oi->tagName()) == x->outputVectors().end()) { trash.push(i); } } trash.setAutoDelete(true); trash.clear(); for (KstVectorMap::Iterator p = x->outputVectors().begin(); p != x->outputVectors().end(); ++p) { bool found = false; for (QListViewItem *i = firstChild(); i; i = i->nextSibling()) { KstObjectItem *oi = static_cast<KstObjectItem*>(i); if (oi->tagName() == p.data()->tagName()) { oi->update(); found = true; break; } } if (!found) { new KstObjectItem(this, p.data(), _dm); } } } _removable = x->getUsage() == 1; break; } default: assert(0); } }
void DistributionListDialog::slotUser1() { bool isEmpty = true; KABC::AddressBook *ab = KABC::StdAddressBook::self( true ); QListViewItem *i = mRecipientsList->firstChild(); while( i ) { DistributionListItem *item = static_cast<DistributionListItem *>( i ); if ( item->isOn() ) { isEmpty = false; break; } i = i->nextSibling(); } if ( isEmpty ) { KMessageBox::information( this, i18n("There are no recipients in your list. " "First select some recipients, " "then try again.") ); return; } #ifndef KDEPIM_NEW_DISTRLISTS KABC::DistributionListManager manager( ab ); manager.load(); #endif QString name = mTitleEdit->text(); if ( name.isEmpty() ) { bool ok = false; name = KInputDialog::getText( i18n("New Distribution List"), i18n("Please enter name:"), QString::null, &ok, this ); if ( !ok || name.isEmpty() ) return; } #ifdef KDEPIM_NEW_DISTRLISTS if ( !KPIM::DistributionList::findByName( ab, name ).isEmpty() ) { #else if ( manager.list( name ) ) { #endif KMessageBox::information( this, i18n( "<qt>Distribution list with the given name <b>%1</b> " "already exists. Please select a different name.</qt>" ).arg( name ) ); return; } #ifdef KDEPIM_NEW_DISTRLISTS KPIM::DistributionList dlist; dlist.setName( name ); i = mRecipientsList->firstChild(); while( i ) { DistributionListItem *item = static_cast<DistributionListItem *>( i ); if ( item->isOn() ) { kdDebug() << " " << item->addressee().fullEmail() << endl; if ( item->isTransient() ) { ab->insertAddressee( item->addressee() ); } if ( item->email() == item->addressee().preferredEmail() ) { dlist.insertEntry( item->addressee() ); } else { dlist.insertEntry( item->addressee(), item->email() ); } } i = i->nextSibling(); } ab->insertAddressee( dlist ); #else KABC::DistributionList *dlist = new KABC::DistributionList( &manager, name ); i = mRecipientsList->firstChild(); while( i ) { DistributionListItem *item = static_cast<DistributionListItem *>( i ); if ( item->isOn() ) { kdDebug() << " " << item->addressee().fullEmail() << endl; if ( item->isTransient() ) { ab->insertAddressee( item->addressee() ); } if ( item->email() == item->addressee().preferredEmail() ) { dlist->insertEntry( item->addressee() ); } else { dlist->insertEntry( item->addressee(), item->email() ); } } i = i->nextSibling(); } #endif // FIXME: Ask the user which resource to save to instead of the default bool saveError = true; KABC::Ticket *ticket = ab->requestSaveTicket( 0 /*default resource */ ); if ( ticket ) if ( ab->save( ticket ) ) saveError = false; else ab->releaseSaveTicket( ticket ); if ( saveError ) kdWarning(5006) << k_funcinfo << " Couldn't save new addresses in the distribution list just created to the address book" << endl; #ifndef KDEPIM_NEW_DISTRLISTS manager.save(); #endif close(); }
void KstDataManagerI::update() { if (!isShown()) { return; } QPtrStack<QListViewItem> trash; // Garbage collect first for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) { KstObjectItem *oi = static_cast<KstObjectItem*>(i); if (i->rtti() == RTTI_OBJ_OBJECT) { if (KST::dataObjectList.findTag(oi->tagName()) == KST::dataObjectList.end()) { trash.push(i); } } else { if (KST::vectorList.findTag(oi->tagName()) == KST::vectorList.end()) { trash.push(i); } } } trash.setAutoDelete(true); trash.clear(); for (KstDataObjectList::iterator it = KST::dataObjectList.begin(); it != KST::dataObjectList.end(); ++it) { bool found = false; for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) { KstObjectItem *oi = static_cast<KstObjectItem*>(i); if (oi->rtti() == RTTI_OBJ_OBJECT && oi->tagName() == (*it)->tagName()) { oi->update(); found = true; break; } } if (!found) { KstObjectItem *i = new KstObjectItem(DataView, *it, this); connect(i, SIGNAL(updated()), this, SLOT(doUpdates())); } } KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList); for (KstRVectorList::iterator it = rvl.begin(); it != rvl.end(); ++it) { bool found = false; for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) { KstObjectItem *oi = static_cast<KstObjectItem*>(i); if (oi->rtti() == RTTI_OBJ_DATA_VECTOR && oi->tagName() == (*it)->tagName()) { oi->update(); found = true; break; } } if (!found) { KstObjectItem *i = new KstObjectItem(DataView, *it, this); connect(i, SIGNAL(updated()), this, SLOT(doUpdates())); } } if (DataView->selectedItem()) { static_cast<KstObjectItem*>(DataView->currentItem())->updateButtons(); } else { Edit->setEnabled(false); Delete->setEnabled(false); } }
void KfindWindow::saveResults() { QListViewItem *item; KFileDialog *dlg = new KFileDialog(QString::null, QString::null, this, "filedialog", true); dlg->setOperationMode(KFileDialog::Saving); dlg->setCaption(i18n("Save Results As")); QStringList list; list << "text/plain" << "text/html"; dlg->setOperationMode(KFileDialog::Saving); dlg->setMimeFilter(list, QString("text/plain")); dlg->exec(); KURL u = dlg->selectedURL(); KMimeType::Ptr mimeType = dlg->currentFilterMimeType(); delete dlg; if(!u.isValid() || !u.isLocalFile()) return; QString filename = u.path(); QFile file(filename); if(!file.open(IO_WriteOnly)) KMessageBox::error(parentWidget(), i18n("Unable to save results.")); else { QTextStream stream(&file); stream.setEncoding(QTextStream::Locale); if(mimeType->name() == "text/html") { stream << QString::fromLatin1( "<HTML><HEAD>\n" "<!DOCTYPE %1>\n" "<TITLE>%2</TITLE></HEAD>\n" "<BODY><H1>%3</H1>" "<DL><p>\n") .arg(i18n("KFind Results File")) .arg(i18n("KFind Results File")) .arg(i18n("KFind Results File")); item = firstChild(); while(item != NULL) { QString path = ((KfFileLVI *)item)->fileitem.url().url(); QString pretty = ((KfFileLVI *)item)->fileitem.url().htmlURL(); stream << QString::fromLatin1("<DT><A HREF=\"") << path << QString::fromLatin1("\">") << pretty << QString::fromLatin1("</A>\n"); item = item->nextSibling(); } stream << QString::fromLatin1("</DL><P></BODY></HTML>\n"); } else { item = firstChild(); while(item != NULL) { QString path = ((KfFileLVI *)item)->fileitem.url().url(); stream << path << endl; item = item->nextSibling(); } } file.close(); KMessageBox::information(parentWidget(), i18n("Results were saved to file\n") + filename); } }
void SetupDialog::raiseWidget(int id) { for (QListViewItem *item = lstBars->firstChild(); item != NULL; item = item->nextSibling()) if (raiseWidget(item, id)) break; }
/** * 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))); } }
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); } } } } }
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; }
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); }
void KMWRlpr::initialize() { m_view->clear(); QFile f(QDir::homeDirPath()+"/.rlprrc"); if (!f.exists()) f.setName("/etc/rlprrc"); if (f.exists() && f.open(IO_ReadOnly)) { QTextStream t(&f); QString line, host; int p(-1); while (!t.eof()) { line = t.readLine().stripWhiteSpace(); if (line.isEmpty()) continue; if ((p=line.find(':')) != -1) { host = line.left(p).stripWhiteSpace(); QListViewItem *hitem = new QListViewItem(m_view,host); hitem->setPixmap(0,SmallIcon("kdeprint_computer")); QStringList prs = QStringList::split(' ',line.right(line.length()-p-1),false); for (QStringList::ConstIterator it=prs.begin(); it!=prs.end(); ++it) { QListViewItem *pitem = new QListViewItem(hitem,*it); pitem->setPixmap(0,SmallIcon("kdeprint_printer")); } } } f.close(); } // parse printcap file for local printers f.setName("/etc/printcap"); if (f.exists() && f.open(IO_ReadOnly)) { QTextStream t(&f); QString line, buffer; QListViewItem *hitem(m_view->firstChild()); while (hitem) if (hitem->text(0) == "localhost") break; else hitem = hitem->nextSibling(); while (!t.eof()) { buffer = QString::null; while (!t.eof()) { line = t.readLine().stripWhiteSpace(); if (line.isEmpty() || line[0] == '#') continue; buffer.append(line); if (buffer.right(1) == "\\") buffer = buffer.left(buffer.length()-1).stripWhiteSpace(); else break; } if (buffer.isEmpty()) continue; int p = buffer.find(':'); if (p != -1) { QString name = buffer.left(p); if (!hitem) { hitem = new QListViewItem(m_view,"localhost"); hitem->setPixmap(0,SmallIcon("kdeprint_computer")); } QListViewItem *pitem = new QListViewItem(hitem,name); pitem->setPixmap(0,SmallIcon("kdeprint_printer")); } } } if (m_view->childCount() == 0) new QListViewItem(m_view,i18n("No Predefined Printers")); }
void ListViewEditor::itemLeftClicked() { QListViewItem *i = itemsPreview->currentItem(); if ( !i ) return; QListViewItemIterator it( i ); QListViewItem *parent = i->parent(); if ( !parent ) return; parent = parent->parent(); --it; while ( it.current() ) { if ( it.current()->parent() == parent ) break; --it; } if ( !it.current() ) return; QListViewItem *other = it.current(); for ( int c = 0; c < itemsPreview->columns(); ++c ) { QString s = i->text( c ); i->setText( c, other->text( c ) ); other->setText( c, s ); QPixmap pix; if ( i->pixmap( c ) ) pix = *i->pixmap( c ); if ( other->pixmap( c ) ) i->setPixmap( c, *other->pixmap( c ) ); else i->setPixmap( c, QPixmap() ); other->setPixmap( c, pix ); } itemsPreview->setCurrentItem( other ); itemsPreview->setSelected( other, TRUE ); }
void *MainInfo::processEvent(Event *e) { if (e->type() == EventContactChanged){ Contact *contact = (Contact*)(e->param()); if (contact == m_contact) fill(); } if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->menu_id == MenuMailList){ if ((cmd->id != CmdEditList) && (cmd->id != CmdRemoveList)) return NULL; QListViewItem *item = (QListViewItem*)(cmd->param); if (item->listView() != lstMails) return NULL; cmd->flags &= ~(COMMAND_CHECKED | COMMAND_DISABLED); bool bEnable = ((item != NULL) && (item->text(MAIL_PROTO).isEmpty() || (item->text(MAIL_PROTO) == "-"))); if (!bEnable) cmd->flags |= COMMAND_DISABLED; return e->param(); } if (cmd->menu_id == MenuPhoneList){ if ((cmd->id != CmdEditList) && (cmd->id != CmdRemoveList)) return NULL; QListViewItem *item = (QListViewItem*)(cmd->param); if (item->listView() != lstPhones) return NULL; cmd->flags &= ~(COMMAND_CHECKED | COMMAND_DISABLED); bool bEnable = ((item != NULL) && (item->text(PHONE_PROTO).isEmpty() || (item->text(PHONE_PROTO) == "-"))); if (!bEnable) cmd->flags |= COMMAND_DISABLED; return e->param(); } } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->menu_id == MenuMailList){ QListViewItem *item = (QListViewItem*)(cmd->param); if (item->listView() != lstMails) return NULL; bool bEnable = ((item != NULL) && (item->text(MAIL_PROTO).isEmpty() || (item->text(MAIL_PROTO) == "-"))); if (!bEnable) return NULL; if (cmd->id == CmdEditList){ editMail(item); return e->param(); } if (cmd->id == CmdRemoveList){ deleteMail(item); return e->param(); } } if (cmd->menu_id == MenuPhoneList){ QListViewItem *item = (QListViewItem*)(cmd->param); if (item->listView() != lstPhones) return NULL; bool bEnable = ((item != NULL) && (item->text(PHONE_PROTO).isEmpty() || (item->text(PHONE_PROTO) == "-"))); if (!bEnable) return NULL; if (cmd->id == CmdEditList){ editPhone(item); return e->param(); } if (cmd->id == CmdRemoveList){ deletePhone(item); return e->param(); } } } return NULL; }
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 MainInfo::apply() { Contact *contact = m_contact; if (contact == NULL){ contact = getContacts()->owner(); contact->setPhoneStatus(cmbStatus->currentItem()); } contact->setNotes(edtNotes->text()); QListViewItem *item; QString mails; for (item = lstMails->firstChild(); item; item = item->nextSibling()){ if (mails.length()) mails += ";"; mails += quoteChars(item->text(MAIL_ADDRESS), ";/"); mails += "/"; mails += item->text(MAIL_PROTO); } contact->setEMails(mails); QString phones; for (item = lstPhones->firstChild(); item; item = item->nextSibling()){ if (phones.length()) phones += ";"; phones += quoteChars(item->text(PHONE_NUMBER), ";/,"); phones += ","; phones += quoteChars(item->text(PHONE_TYPE_ASIS), ";/,"); phones += ","; phones += item->text(PHONE_ICON); if (m_contact){ if (!item->text(PHONE_ACTIVE).isEmpty()) phones += ",1"; }else{ if (item->text(PHONE_NUMBER) == cmbCurrent->currentText()) phones += ",1"; } phones += "/"; phones += item->text(PHONE_PROTO); } contact->setPhones(phones); QString firstName = contact->getFirstName(); QString lastName = contact->getLastName(); if (firstName != edtFirstName->text()) contact->setFirstName(edtFirstName->text(), NULL); if (lastName != edtLastName->text()) contact->setLastName(edtLastName->text(), NULL); QString name = cmbDisplay->lineEdit()->text(); if (name.isEmpty()){ name = edtFirstName->text(); if (!edtLastName->text().isEmpty()){ if (!name.isEmpty()){ name += " "; name += edtLastName->text(); } } } contact->setName(name); Event e(EventContactChanged, contact); e.process(); }
bool PropertyEditor::handleKeyPress(QKeyEvent* ev) { const int k = ev->key(); const Qt::ButtonState s = ev->state(); //selection moving QListViewItem *item = 0; if ((s == NoButton && k == Key_Up) || k == Key_BackTab) { //find prev visible item = selectedItem() ? selectedItem()->itemAbove() : 0; while (item && (!item->isSelectable() || !item->isVisible())) item = item->itemAbove(); if (!item) return true; } else if (s == NoButton && (k == Key_Down || k == Key_Tab)) { //find next visible item = selectedItem() ? selectedItem()->itemBelow() : 0; while (item && (!item->isSelectable() || !item->isVisible())) item = item->itemBelow(); if (!item) return true; } else if (s == NoButton && k == Key_Home) { if (m_currentEditor && m_currentEditor->hasFocus()) return false; //find 1st visible item = firstChild(); while (item && (!item->isSelectable() || !item->isVisible())) item = item->itemBelow(); } else if (s == NoButton && k == Key_End) { if (m_currentEditor && m_currentEditor->hasFocus()) return false; //find last visible item = selectedItem(); QListViewItem *lastVisible = item; while (item) { // && (!item->isSelectable() || !item->isVisible())) item = item->itemBelow(); if (item && item->isSelectable() && item->isVisible()) lastVisible = item; } item = lastVisible; } if (item) { ev->accept(); ensureItemVisible(item); setSelected(item, true); return true; } return false; }
void UserConfig::removeCommand(unsigned id) { for (QListViewItem *item = lstBox->firstChild(); item; item = item->nextSibling()) removeCommand(id, item); }
void HierarchyList::insertObject( QObject *o, QListViewItem *parent ) { bool fakeMainWindow = false; if ( o && o->inherits( "QMainWindow" ) ) { QObject *cw = ( (QMainWindow*)o )->centralWidget(); if ( cw ) { o = cw; fakeMainWindow = true; } } QListViewItem *item = 0; QString className = WidgetFactory::classNameOf( o ); if ( o->inherits( "QLayoutWidget" ) ) { switch ( WidgetFactory::layoutType( (QWidget*)o ) ) { case WidgetFactory::HBox: className = "HBox"; break; case WidgetFactory::VBox: className = "VBox"; break; case WidgetFactory::Grid: className = "Grid"; break; default: break; } } QString dbInfo; #ifndef QT_NO_SQL dbInfo = MetaDataBase::fakeProperty( o, "database" ).toStringList().join("."); #endif QString name = o->name(); if ( o->parent() && o->parent()->inherits( "QWidgetStack" ) && o->parent()->parent() ) { if ( o->parent()->parent()->inherits( "QTabWidget" ) ) name = ( (QTabWidget*)o->parent()->parent() )->tabLabel( (QWidget*)o ); else if ( o->parent()->parent()->inherits( "QWizard" ) ) name = ( (QWizard*)o->parent()->parent() )->title( (QWidget*)o ); } QToolBox *tb; if ( o->parent() && o->parent()->parent() && (tb = ::qt_cast<QToolBox*>(o->parent()->parent()->parent())) ) name = tb->itemLabel( tb->indexOf((QWidget*)o) ); if ( fakeMainWindow ) { name = o->parent()->name(); className = "QMainWindow"; } if ( !parent ) item = new HierarchyItem( HierarchyItem::Widget, this, name, className, dbInfo ); else item = new HierarchyItem( HierarchyItem::Widget, parent, name, className, dbInfo ); if ( !parent ) item->setPixmap( 0, PixmapChooser::loadPixmap( "form.xpm", PixmapChooser::Mini ) ); else if ( o->inherits( "QLayoutWidget") ) item->setPixmap( 0, PixmapChooser::loadPixmap( "layout.xpm", PixmapChooser::Small ) ); else item->setPixmap( 0, WidgetDatabase::iconSet( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( o ) ) ). pixmap( QIconSet::Small, QIconSet::Normal ) ); ( (HierarchyItem*)item )->setWidget( (QWidget*)o ); const QObjectList *l = o->children(); if ( !l ) return; QObjectListIt it( *l ); it.toLast(); for ( ; it.current(); --it ) { if ( !it.current()->isWidgetType() || ( (QWidget*)it.current() )->isHidden() ) continue; if ( !formWindow->widgets()->find( (QWidget*)it.current() ) ) { if ( it.current()->parent() && ( it.current()->parent()->inherits( "QTabWidget" ) || it.current()->parent()->inherits( "QWizard" ) ) && it.current()->inherits( "QWidgetStack" ) ) { QObject *obj = it.current(); QObjectList *l2 = obj->queryList( "QWidget", 0, true, false ); QDesignerTabWidget *tw = 0; QDesignerWizard *dw = 0; if ( it.current()->parent()->inherits( "QTabWidget" ) ) tw = (QDesignerTabWidget*)it.current()->parent(); if ( it.current()->parent()->inherits( "QWizard" ) ) dw = (QDesignerWizard*)it.current()->parent(); QWidgetStack *stack = (QWidgetStack*)obj; for ( obj = l2->last(); obj; obj = l2->prev() ) { if ( qstrcmp( obj->className(), "QWidgetStackPrivate::Invisible" ) == 0 || ( tw && !tw->tabBar()->tab( stack->id( (QWidget*)obj ) ) ) || ( dw && dw->isPageRemoved( (QWidget*)obj ) ) ) continue; insertObject( obj, item ); } delete l2; } else if ( ::qt_cast<QToolBox*>(it.current()->parent()) ) { if ( !::qt_cast<QScrollView*>(it.current()) ) continue; QToolBox *tb = (QToolBox*)it.current()->parent(); for ( int i = tb->count() - 1; i >= 0; --i ) insertObject( tb->item( i ), item ); } continue; } insertObject( it.current(), item ); } if ( item->firstChild() ) item->setOpen( true ); }
void SequenceEditor::slotOKClicked() { // // Values // m_sequence->m_steps.setAutoDelete(true); m_sequence->m_steps.clear(); m_sequence->m_steps.setAutoDelete(false); for (QListViewItem* item = m_list->firstChild(); item != NULL; item = item->itemBelow()) { SceneValue* value = new SceneValue[m_channels]; for (t_channel i = 0; i < m_channels; i++) { value[i].value = item->text(i).toInt(); if (item->text(i) != QString("---")) { value[i].type = Scene::Set; } else { value[i].type = Scene::NoSet; } } m_sequence->m_steps.append(value); } // // Name // m_sequence->setName(m_name->text()); // // Run Order // if (m_runOrderGroup->selected() == m_singleShot) { m_sequence->setRunOrder(Sequence::SingleShot); } else if (m_runOrderGroup->selected() == m_pingPong) { m_sequence->setRunOrder(Sequence::PingPong); } else { m_sequence->setRunOrder(Sequence::Loop); } // // Direction // if (m_directionGroup->selected() == m_backward) { m_sequence->setDirection(Sequence::Backward); } else { m_sequence->setDirection(Sequence::Forward); } accept(); }
void FileManager::showInEditor(const KURL& url) { for (std::list<ManagedFileInfo*>::iterator mfi = files.begin(); mfi != files.end(); ++mfi) if ((*mfi)->getFileURL() == url) { if (!(*mfi)->getEditor()) { // The file has not yet been loaded, so we create an editor for // it. KTextEditor::Document* document; if (!(document = KTextEditor::EditorChooser::createDocument (viewStack, "KTextEditor::Document", "Editor"))) { KMessageBox::error (viewStack, i18n("A KDE text-editor component could not " "be found; please check your KDE " "installation.")); return; } if (!editorConfigured) { if (!KTextEditor::configInterface(document)) { KMessageBox::error (viewStack, i18n("You have selected a KDE Editor component " "that is not powerful enough for " "TaskJuggler. " "Please select the 'Embedded Advanced Text " "Editor' component in the KDE Control " "Panel.")); return; } KTextEditor::configInterface(document)->readConfig(config); editorConfigured = true; } KTextEditor::View* editor = document->createView(viewStack); viewStack->addWidget(editor); (*mfi)->setEditor(editor); editor->setMinimumSize(400, 200); editor->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum, 0, 85, editor->sizePolicy() .hasHeightForWidth())); document->openURL(url); document->setReadWrite(true); document->setModified(false); // Signal to update the file-modified status connect(document, SIGNAL(textChanged()), *mfi, SLOT(setModified())); connect(document, SIGNAL(modifiedOnDisc(Kate::Document*, bool, unsigned char)), *mfi, SLOT(setModifiedOnDisc(Kate::Document*, bool, unsigned char))); /* Remove some actions of the editor that we don't want to * show in the menu/toolbars */ KActionCollection* ac = editor->actionCollection(); if (ac->action("file_print")) ac->remove(ac->action("file_print")); if (ac->action("view_folding_markers")) ac->action("view_folding_markers")-> setShortcut(KShortcut()); if (ac->action("view_border")) ac->action("view_border")->setShortcut(KShortcut()); if (ac->action("view_line_numbers")) ac->action("view_line_numbers")->setShortcut(KShortcut()); if (ac->action("view_dynamic_word_wrap")) ac->action("view_dynamic_word_wrap")-> setShortcut(KShortcut()); /* KActionPtrList actionList = editor->actionCollection()->actions(); for (KActionPtrList::iterator it = actionList.begin(); it != actionList.end(); ++it) { printf("** Action found: %s\n", (*it)->name()); }*/ } viewStack->raiseWidget((*mfi)->getEditor()); browser->clearSelection(); QListViewItem* lvi = (*mfi)->getBrowserEntry(); if (lvi) { browser->setCurrentItem(lvi); lvi->setSelected(true); } break; }
void ConfigureDialog::fill(unsigned id) { lstBox->clear(); lstBox->setSorting(1); ConfigItem *parentItem = new MainInfoItem(lstBox, 0); for (unsigned i = 0; i < getContacts()->nClients(); i++){ Client *client = getContacts()->getClient(i); CommandDef *cmds = client->configWindows(); if (cmds){ parentItem = NULL; for (; cmds->text; cmds++){ if (parentItem){ new ClientItem(parentItem, client, cmds); }else{ parentItem = new ClientItem(lstBox, client, cmds); parentItem->setOpen(true); } } } } unsigned n; parentItem = NULL; list<unsigned> st; for (n = 0; n < getContacts()->nClients(); n++){ Protocol *protocol = getContacts()->getClient(n)->protocol(); if ((protocol->description()->flags & (PROTOCOL_AR | 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 = protocol->statusList(); d->text; d++){ if (((protocol->description()->flags & PROTOCOL_AR_OFFLINE) == 0) && ((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("Plugins")); parentItem->setPixmap(0, Pict("run")); parentItem->setOpen(true); for ( n = 0;; n++){ Event e(EventPluginGetInfo, (void*)n); pluginInfo *info = (pluginInfo*)e.process(); if (info == NULL) break; if (info->info == NULL){ Event e(EventLoadPlugin, info->name); e.process(); } if ((info->info == NULL) || (info->info->title == NULL)) continue; QString title = i18n(info->info->title); new PluginItem(parentItem, title, info, n); } 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); if (id){ for (QListViewItem *item = lstBox->firstChild(); item; item = item->nextSibling()){ if (setCurrentItem(item, id)) return; } } lstBox->setCurrentItem(lstBox->firstChild()); }
void KeySetup::keyChanged() { QListViewItem *item = lstActions->currentItem(); if (item == NULL) return; item->setText(1, chkEnable->isChecked() ? btnKey->text() : QString("")); }