QString FavoriteFolderView::prettyName(KMFolderTreeItem *fti) { assert(fti); assert(fti->folder()); QString name = fti->folder()->label(); QListViewItem *accountFti = fti; while(accountFti->parent()) accountFti = accountFti->parent(); if(fti->type() == KFolderTreeItem::Inbox) { if(fti->protocol() == KFolderTreeItem::Local || fti->protocol() == KFolderTreeItem::NONE) { name = i18n("Local Inbox"); } else { name = i18n("Inbox of %1").arg(accountFti->text(0)); } } else { if(fti->protocol() != KFolderTreeItem::Local && fti->protocol() != KFolderTreeItem::NONE) { name = i18n("%1 on %2").arg(fti->text(0)).arg(accountFti->text(0)); } else { name = i18n("%1 (local)").arg(fti->text(0)); } } return name; }
void servercontroller::new_channel() { QString server; QListViewItem *citem = ConnectionTree->currentItem(); // get item if(citem){ // if it exist, ie something is highlighted, continue if(proc_list[citem->text(0)]){ // If it's a match with a server, ok server = citem->text(0); } // Otherwise, check the parent to see it's perhaps a server. else if ( citem->parent() ) { if(proc_list[citem->parent()->text(0)]){ server = citem->parent()->text(0); } } } if(server.isEmpty()) return; KSircChannel ci(server, QString::null); NewWindowDialog w(ci); connect(&w, SIGNAL(openTopLevel(const KSircChannel &)), this, SLOT(new_toplevel(const KSircChannel &))); w.exec(); }
QListViewItem * ListViewDnd::itemAt( QPoint pos ) { QListView * src = (QListView *) this->src; int headerHeight = (int)(src->header()->height()); pos.ry() -= headerHeight; QListViewItem * result = src->itemAt( pos ); if ( result && ( pos.ry() < (src->itemPos(result) + result->height()/2) ) ) result = result->itemAbove(); // Wind back if has parent, and we're in flat mode while ( result && result->parent() && (dMode & Flat) ) result = result->parent(); // Wind back if has parent, and we're in flat mode while ( result && !result->isVisible() && result->parent() ) result = result->parent(); if ( !result && src->firstChild() && (pos.y() > src->itemRect(src->firstChild()).bottom()) ) { result = src->lastItem(); if ( !result->isVisible() ) // Handle special case where last item is actually hidden result = result->itemAbove(); } return result; }
void ActionConfigDialog::slotNewAction() { QDomDocument doc; QDomElement el = doc.createElement("action"); el.setAttribute( "name", "user_"+KApplication::randomString(10) ); el.setAttribute( "icon", "ball" ); currentAction = new TagAction(&el, m_mainWindow); //add the actions to every toolbar xmlguiclient QDictIterator<ToolbarEntry> it(m_toolbarList); while (it.current()) { it.current()->guiClient->actionCollection()->insert(currentAction); ++it; } selectedShortcut = KShortcut(); static_cast<TagAction*>(currentAction)->setModified(true); QListViewItem *currentItem = actionTreeView->currentItem(); QListViewItem *item = new KListViewItem(allActionsItem); QString actionText = QString("Action_%1").arg(m_mainWindow->actionCollection()->count()); currentAction->setText(actionText); item->setText(2, currentAction->name()); item->setText(0, actionText); item->setPixmap(0, SmallIcon("ball")); allActionsItem->sortChildItems(0, true); if (currentItem->parent() && currentItem->parent() == allActionsItem) { actionTreeView->setCurrentItem(item); } else { QListViewItem *parentItem = currentItem->parent(); if (!parentItem) parentItem = currentItem; item = new KListViewItem(parentItem, currentItem); item->setText(0, actionText); item->setText(2, currentAction->name()); item->setPixmap(0, SmallIcon("ball")); actionTreeView->setCurrentItem(item); if (parentItem != allActionsItem) { toolbarListBox->insertItem(parentItem->text(0)); toolbarListBox->setCurrentItem(0); toolbarListBox->setSelected(0, true); } } actionTreeView->ensureItemVisible(item); buttonApply->setEnabled(true); }
void ActionConfigDialog::slotEditToolbar() { QString toolbarName; QString toolbarId; QListViewItem *oldItem; QListViewItem *item = actionTreeView->currentItem(); if (item->parent()) item = item->parent(); toolbarName = item->text(0); if ( toolbarName != i18n("All")) { emit configureToolbars(toolbarName +" <quanta>"); //update the tree view KAction *action; KActionCollection *ac = m_mainWindow->actionCollection(); ToolbarTabWidget *tb = ToolbarTabWidget::ref(); for (int i = 0; i < tb->count(); i++) { toolbarName = tb->label(i); toolbarId = tb->id(i); ToolbarEntry *p_toolbar = m_toolbarList[toolbarId]; if (p_toolbar) { oldItem = actionTreeView->findItem(toolbarName, 0); item = new KListViewItem(actionTreeView, oldItem, toolbarName); item->setOpen(oldItem->isOpen()); delete oldItem; QDomNode node = p_toolbar->guiClient->domDocument().firstChild().firstChild().firstChild(); while (!node.isNull()) { if (node.nodeName() == "Action") { action = ac->action(node.toElement().attribute("name")); if (action) { oldItem = new KListViewItem(item, oldItem, action->text().replace(QRegExp("\\&(?!\\&)"),""), action->shortcut().toString(), action->name()); oldItem->setPixmap(0, SmallIcon(action->icon())); } } node = node.nextSibling(); } } } actionTreeView->setCurrentItem(allActionsItem); actionTreeView->setSelected(allActionsItem, true); } }
qsamplerInstrumentGroup *qsamplerInstrumentGroup::groupItem (void) const { QListViewItem *pParent = QListViewItem::parent(); while (pParent && pParent->rtti() != qsamplerInstrumentList::Group) pParent = pParent->parent(); return static_cast<qsamplerInstrumentGroup *> (pParent); }
int ListViewDnd::buildFlatList( ListViewItemList & list ) { bool addKids = FALSE; QListViewItem *nextSibling = 0; QListViewItem *nextParent = 0; QListViewItemIterator it = ((QListView *)src)->firstChild(); for ( ; *it; it++ ) { // Hit the nextSibling, turn of child processing if ( (*it) == nextSibling ) addKids = FALSE; if ( (*it)->isSelected() ) { if ( (*it)->childCount() == 0 ) { // Selected, no children list.append( *it ); } else if ( !addKids ) { // Children processing not set, so set it // Also find the item were we shall quit // processing children...if any such item addKids = TRUE; nextSibling = (*it)->nextSibling(); nextParent = (*it)->parent(); while ( nextParent && !nextSibling ) { nextSibling = nextParent->nextSibling(); nextParent = nextParent->parent(); } } } else if ( ((*it)->childCount() == 0) && addKids ) { // Leaf node, and we _do_ process children list.append( *it ); } } return list.count(); }
void DOMTreeView::deleteNodes() { // kdDebug(90180) << k_funcinfo << endl; DOM::Node last; MultiCommand *cmd = new MultiCommand(i18n("Delete Nodes")); QListViewItemIterator it(m_listView, QListViewItemIterator::Selected); for (; *it; ++it) { DOMListViewItem *item = static_cast<DOMListViewItem *>(*it); // kdDebug(90180) << " item->node " << item->node().nodeName().string() << " clos " << item->isClosing() << endl; if (item->isClosing()) continue; // don't regard node more than once if (item->node() == last) continue; // check for selected parent bool has_selected_parent = false; for (QListViewItem *p = item->parent(); p; p = p->parent()) { if (p->isSelected()) { has_selected_parent = true; break; } } if (has_selected_parent) continue; // kdDebug(90180) << " item->node " << item->node().nodeName().string() << ": schedule for removal" << endl; // remove this node if it isn't already recursively removed by its parent cmd->addCommand(new RemoveNodeCommand(item->node(), item->node().parentNode(), item->node().nextSibling())); last = item->node(); } mainWindow()->executeAndAddCommand(cmd); }
void Kleo::KeyListView::scatterGathered( QListViewItem * start ) { QListViewItem * item = start; while ( item ) { QListViewItem * cur = item; item = item->nextSibling(); scatterGathered( cur->firstChild() ); assert( cur->childCount() == 0 ); // ### todo: optimize by suppressing removing/adding the item to the itemMap... if ( cur->parent() ) cur->parent()->takeItem( cur ); else takeItem( cur ); insertItem( cur ); } }
QString VariablesListViewItem::stringPath() { QListViewItem* item = this; QString str = item->text(VariablesListView::NameCol); while((item = item->parent()) != NULL) { str = item->text(VariablesListView::NameCol) + "/" + str; } return str; }
void ActionConfigDialog::slotRemoveToolbar() { QListViewItem *item = actionTreeView->currentItem(); QString s = item->text(0); if (item->parent()) { item = item->parent(); s = item->text(0); } if (s != i18n("All")) { if ( KMessageBox::warningContinueCancel(this, i18n("Do you really want to remove the \"%1\" toolbar?").arg(s),QString::null,KStdGuiItem::del()) == KMessageBox::Continue ) { m_toolbarItem = item; connect(m_mainWindow, SIGNAL(toolbarRemoved(const QString&)), SLOT(slotToolbarRemoved(const QString&))); emit removeToolbar(s.lower()); } } }
void ActionConfigDialog::slotAddToolbar() { emit addToolbar(); QString toolbarName; QListViewItem *item; ToolbarTabWidget *tb = ToolbarTabWidget::ref(); for (int i = 0; i < tb->count(); i++) { toolbarName = tb->label(i); if (!actionTreeView->findItem(toolbarName, 0)) { item = actionTreeView->lastItem(); if (item->parent()) item = item->parent(); new KListViewItem(actionTreeView, item, i18n(toolbarName.utf8())); break; } } }
void servercontroller::server_debug() { QListViewItem *citem = ConnectionTree->currentItem(); // get item if(citem){ // if it exist, ie something is highlighted, continue QString server; if(proc_list[citem->text(0)]){ // If it's a match with a server, ok server = citem->text(0); } else if ( citem->parent() ) { if(proc_list[citem->parent()->text(0)]){ server = citem->parent()->text(0); } } if( !server.isNull() ){ bool sh = proc_list[server]->getIOController()->isDebugTraffic(); proc_list[server]->getIOController()->showDebugTraffic(!sh); } } }
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 ); }
QString EditorView::keyName ( const QListViewItem * item ) const { QString key = item->text(0); QListViewItem *parent = item->parent(); while (parent != 0) { key = parent->text(0) + RG_KEY_DELIM + key; parent = parent->parent(); } return key; }
void KMWRlpr::initPrinter(KMPrinter *p) { m_host->setText(p->option("host")); m_queue->setText(p->option("queue")); QListViewItem *item = findChild(m_view->firstChild(),m_host->text()); if (item) { item = findChild(item->firstChild(),m_queue->text()); if (item) { item->parent()->setOpen(true); m_view->setCurrentItem(item); m_view->ensureItemVisible(item); } } }
void AccountingSelector::enableItems(bool enabled) { tl->setEnabled(enabled); if(!enabled || (!tl->currentItem())) selected->setText(i18n("(none)")); else { QListViewItem* i = tl->currentItem(); QString s; while(i) { s = "/" + i->text(0) + s; i = i->parent(); } selected->setText(s.mid(1)); s += ".rst"; edit_s = nameToFileName(s); } }
void ListViewEditor::itemUpClicked() { QListViewItem *i = itemsPreview->currentItem(); if ( !i ) return; QListViewItemIterator it( i ); QListViewItem *parent = i->parent(); --it; while ( it.current() ) { if ( it.current()->parent() == parent ) break; --it; } if ( !it.current() ) return; QListViewItem *other = it.current(); other->moveItem( i ); }
bool ListViewDnd::dropEvent( QDropEvent * event ) { if ( dragInside ) { if ( dMode & NullDrop ) { // combined with Move, a NullDrop will delete an item event->accept(); emit dropped( 0 ); // a NullDrop return TRUE; } QPoint pos = event->pos(); ListViewItemDrag::DropRelation dr = ListViewItemDrag::Sibling; QListViewItem *item = itemAt( pos ); int dpos = dropDepth( item, pos ); if ( item ) { if ( dpos > item->depth() && !(dMode & Flat) ) { // Child node dr = ListViewItemDrag::Child; } else if ( dpos < item->depth() ) { // Parent(s) Sibling while ( item && (item->depth() > dpos) ) item = item->parent(); } } if ( ListViewItemDrag::decode( event, (QListView *) src, item, dr ) ) { event->accept(); emit dropped( 0 ); // Use ID instead of item? } } line->hide(); dragInside = FALSE; return TRUE; }
void servercontroller::ProcMessage(QString server, int command, QString args) { QListViewItem *serverItem = 0L; QListViewItem *item = ConnectionTree->firstChild(); while ( item ) { if ( !item->parent() && item->text(0) == server ) { serverItem = item; break; } item = item->nextSibling(); } if ( !serverItem ) { kdDebug(5008) << "* ProcMessage for non-existant server?! - " << server<< endl; return; } switch(command){ // Nick offline and online both remove the nick first. // We remove the nick in case of an online so that we don't get // duplicates. // Args == nick comming on/offline. case ProcCommand::nickOffline: { QListViewItem *online_item = findChild(serverItem, i18n("Online")); if(online_item){ item = findChild(online_item, args); delete item; if(online_item->childCount() == 0) delete online_item; if(ksopts->runDocked && ksopts->dockPopups) KPassivePopup::message(i18n("%1 just went offline on %2").arg(args).arg(server), dockWidget); } dockWidget->nickOffline(server, args); break; } case ProcCommand::nickOnline: { QListViewItem *online_item = findChild(serverItem, i18n("Online")); if(!online_item){ online_item = new QListViewItem(serverItem, i18n("Online")); online_item->setPixmap( 0, pic_gf ); online_item->setOpen( true ); } else { item = findChild(online_item, args); if( item ){ delete item; } } item = new QListViewItem(online_item, args); item->setPixmap( 0, pic_run ); if(ksopts->runDocked && ksopts->dockPopups) KPassivePopup::message(i18n("%1 just came online on %2").arg(args).arg(server), dockWidget); dockWidget->nickOnline(server, args); break; } /* // Add new channel, first add the parent to the path path.push(&server); path.push(&online); path.push(&args); // Remove old one if it's there ConnectionTree->removeItem(&path); // Remove the item path.pop(); // add a new child item with parent as its parent ConnectionTree->addChildItem(args, pic_run, &path); if (kSircConfig->BeepNotify) { KNotifyClient::beep(); } break; */ /** * Args: * parent: the server name that the new channel is being joined on * child: the new channel name * Action: * Adds "child" to the list of joined channles in the main * window. Always call this on new window creation! */ case ProcCommand::addTopLevel: // Add new channel if(args[0] == '!') args.remove(0, 1); // If the first char is !, it's control, remove it // add a new child item with parent as it's parent item = new QListViewItem( serverItem, args ); item->setPixmap( 0, pic_ppl ); open_toplevels++; break; /** * Args: * parent: the server name of which channel is closing * child: the channle that is closing. IFF Emtpy, parent is * deleted. * Action: * Deletes the "child" window from the list of connections. If * the child is Empty the whole tree is removed since it is assumed * the parent has disconnected and is closing. */ case ProcCommand::deleteTopLevel: // If the child is emtpy, delete the whole tree, otherwise just the child if(args[0] == '!') args.remove(0, 1); // If the first char is !, it's control, remove it item = findChild( serverItem, args ); delete item; if ( serverItem->childCount() == 0 ) delete serverItem; open_toplevels--; break; /** * Args: * parent: parent server connection * old: the old name for the window * new: the new name for the window * Action: * Changes the old window name to the new window name in the tree * list box. Call for all name change! */ case ProcCommand::changeChannel: { char *new_s, *old_s; new_s = new char[args.length()+1]; old_s = new char[args.length()+1]; sscanf(args.ascii(), "%s %s", old_s, new_s); // If the channel has a !, it's a control channel, remove the ! if(old_s[0] == '!') // Even though, we want strlen() -1 characters, strlen doesn't // include the \0, so we need to copy one more. -1 + 1 = 0. memmove(old_s, old_s+1, strlen(old_s)); if(new_s[0] == '!') memmove(new_s, new_s+1, strlen(new_s)); // See above for strlen() item = findChild( serverItem, old_s ); delete item; item = new QListViewItem( serverItem, new_s ); item->setPixmap( 0, pic_ppl ); delete[] new_s; delete[] old_s; } break; case ProcCommand::procClose: dockWidget->serverClose(server); delete serverItem; proc_list.remove(server); // Remove process entry while we are at it if(proc_list.count() == 0){ ConnectionTree->clear(); connections->setItemEnabled(join_id, FALSE); } break; case ProcCommand::turnOffAutoCreate: if (ksopts->autoCreateWin) { ToggleAutoCreate(); } break; case ProcCommand::turnOnAutoCreate: if (!ksopts->autoCreateWin) { ToggleAutoCreate(); } break; default: kdDebug(5008) << "Unkown command: [" << command << "] from " << server << " " << args << endl; } }
//returns true if the item has been dropped successfully void KWalletEntryList::itemDropped(QDropEvent *e, QListViewItem *item) { bool ok = true; bool isEntry; QFile file; QDataStream *ds; KWalletEntryList *el = 0L; QListViewItem *sel = 0L; //detect if we are dragging from kwallet itself if (e->source() && e->source()->parent() && !strcmp(e->source()->parent()->className(), "KWalletEntryList")) { el = dynamic_cast<KWalletEntryList*>(e->source()->parent()); if (!el) { KMessageBox::error(this, i18n("An unexpected error occurred trying to drop the item")); } else sel = el->selectedItem(); } if (e->provides("application/x-kwallet-entry")) { //do nothing if we are in the same folder if (sel && sel->parent()->parent() == KWalletEntryList::getItemFolder(item)) { e->ignore(); return; } isEntry = true; QByteArray data = e->encodedData("application/x-kwallet-entry"); if (data.isEmpty()) { e->ignore(); return; } ds = new QDataStream(data, IO_ReadOnly); } else if (e->provides("application/x-kwallet-folder")) { //do nothing if we are in the same wallet if (this == el) { e->ignore(); return; } isEntry = false; QByteArray data = e->encodedData("application/x-kwallet-folder"); if (data.isEmpty()) { e->ignore(); return; } ds = new QDataStream(data, IO_ReadOnly); } else if (e->provides("text/uri-list")) { QStrList urls; QUriDrag::decode(e, urls); if (urls.isEmpty()) { e->ignore(); return; } KURL u(urls.first()); if (u.fileName().isEmpty()) { e->ignore(); return; } QString tmpFile; if (KIO::NetAccess::download(u, tmpFile, 0L)) { file.setName(tmpFile); file.open(IO_ReadOnly); ds = new QDataStream(&file); //check magic to discover mime type Q_UINT32 magic; (*ds) >> magic; if (magic == KWALLETENTRYMAGIC) { isEntry = true; } else if (magic == KWALLETFOLDERMAGIC) { isEntry = false; } else { kdDebug() << "bad magic" << endl; e->ignore(); return; } delete ds; //set the file back to the beginning file.reset(); ds = new QDataStream(&file); KIO::NetAccess::removeTempFile(tmpFile); } else {
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(); }
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()); } } }