/*** * Get a list of all of the files to backup. */ int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent) { QListViewItem * currentItem; QString currentHome; if(!parent) currentItem = backupList->firstChild(); else { currentItem = parent->firstChild(); currentHome = parent->text(BACKUP_LOCATION); } uint count = 0; while( currentItem != 0 ) { if(currentItem->text(HEADER_BACKUP) == "B" ) { if(currentItem->childCount() == 0 ) { if(parent == NULL) backupFiles += currentItem->text(BACKUP_LOCATION); else backupFiles += currentHome + currentItem->text(HEADER_NAME); backupFiles += " "; count++; } else { count += getBackupFiles(backupFiles, currentItem); } } currentItem = currentItem->nextSibling(); } return count; }
void PlaylistSelection::loadChildren( QListViewItem* browserParent, QListViewItem* selectionParent ) { QListViewItem* browserChild = browserParent->firstChild(); while( browserChild ) { SelectionListItem* selectionChild = new SelectionListItem( selectionParent, browserChild->text(0), browserChild ); if ( browserChild->pixmap(0) ) selectionChild->setPixmap( 0, *browserChild->pixmap(0) ); if( browserChild->childCount() > 0 ) loadChildren( browserChild, selectionChild ); browserChild = browserChild->nextSibling(); } }
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 ); } }
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; } }