void RDListView::mouseButtonClickedData(int button,QListViewItem *item, const QPoint &pt,int col) { QListViewItem *l; bool contiguous; if((selectionMode()!=QListView::Extended)||(item==NULL)||(button!=1)) { return; } // // Get Selected Range // l=item; contiguous=true; while((l=l->itemAbove())!=NULL) { if(!l->isSelected()) { contiguous=false; } if(!contiguous) { setSelected(l,false); } } l=item; contiguous=true; while((l=l->itemBelow())!=NULL) { if(!l->isSelected()) { contiguous=false; } if(!contiguous) { setSelected(l,false); } } }
void ListViews::slotMessageChanged() { QListViewItem *i = messages->currentItem(); if ( !i ) return; if ( !i->isSelected() ) { message->setText( "" ); return; } MessageListItem *item = ( MessageListItem* )i; Message *msg = item->message(); QString text; QString tmp = msg->header().sender(); tmp = tmp.replace( QRegExp( "[<]" ), "<" ); tmp = tmp.replace( QRegExp( "[>]" ), ">" ); text = QString( "<b><i>From:</i></b> <a href=\"mailto:[email protected]\">%1</a><br>" "<b><i>Subject:</i></b> <big><big><b>%2</b></big></big><br>" "<b><i>Date:</i></b> %3<br><br>" "%4" ). arg( tmp ).arg( msg->header().subject() ). arg( msg->header().datetime().toString() ).arg( msg->body() ); message->setText( text ); msg->setState( Message::Read ); }
QList<QListViewItem> UIListView::selectedItems() { QList<QListViewItem> list; // set current item as first item firstChild(); // // run through items // QListViewItemIterator it( this ); QListViewItem * item = 0; for ( ; it.current(); ++it ) { item = it.current(); if ( item->isSelected() == false ) continue; list.append( item ); } return list; }
void FolderListView::startDrag() { QListViewItem *item = currentItem(); if (!item) return; if (item == firstChild() && item->listView()->rootIsDecorated()) return;//it's the project folder so we don't want the user to move it QPoint orig = viewportToContents( viewport()->mapFromGlobal( QCursor::pos() ) ); QPixmap pix; if (item->rtti() == FolderListItem::ListItemType) pix = QPixmap( folder_closed_xpm ); else pix = *item->pixmap (0); QIconDrag *drag = new QIconDrag(viewport()); drag->setPixmap(pix, QPoint(pix.width()/2, pix.height()/2 ) ); QPtrList<QListViewItem> lst; for (item = firstChild(); item; item = item->itemBelow()) { if (item->isSelected()) lst.append(item); } emit dragItems(lst); drag->drag(); }
static bool listViewHasSelection( QListView *lv ) { for ( QListViewItem *i = lv->firstChild(); i; i = i->itemBelow() ) if ( i->isSelected() ) return true; return false; }
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); }
static void selectedItems( QPtrList<Kleo::KeyListViewItem> & result, QListViewItem * start ) { for ( QListViewItem * item = start ; item ; item = item->nextSibling() ) { if ( item->isSelected() ) if ( Kleo::KeyListViewItem * i = Kleo::lvi_cast<Kleo::KeyListViewItem>( item ) ) result.append( i ); selectedItems( result, item->firstChild() ); } }
void UIListView::invertSelection() { firstChild(); QListViewItemIterator it( this ); QListViewItem * item; for ( ; ( item = it.current() ); ++it ) setSelected( item, ! item->isSelected() ); }
void popupPublic::sort() { bool reselect=false; QListViewItem *current = keysList->firstChild(); if (current==NULL) return; if ((untrustedList.find(current->text(2))!=untrustedList.end()) && (!current->text(2).isEmpty())){ if (current->isSelected()) { current->setSelected(false); reselect=true; } current->setVisible(false); } while ( current->nextSibling() ) { current = current->nextSibling(); if ((untrustedList.find(current->text(2))!=untrustedList.end()) && (!current->text(2).isEmpty())) { if (current->isSelected()) { current->setSelected(false); reselect=true; } current->setVisible(false); } } if (reselect || !keysList->currentItem()->isVisible()) { QListViewItem *firstvisible; firstvisible=keysList->firstChild(); while (firstvisible->isVisible()!=true) { firstvisible=firstvisible->nextSibling(); if (firstvisible==NULL) return; } keysList->setSelected(firstvisible,true); keysList->setCurrentItem(firstvisible); keysList->ensureItemVisible(firstvisible); } }
QStringList KexiFieldListView::selectedFieldNames() const { if (!schema()) return QStringList(); QStringList selectedFields; for (QListViewItem *item = firstChild(); item; item = item->nextSibling()) { if (item->isSelected()) { //! @todo what about query fields/aliases? it.current()->text(0) can be not enough if (item == m_allColumnsItem && m_allColumnsItem) selectedFields.append("*"); else selectedFields.append(item->text(0)); } } return selectedFields; }
int ServerListItem::selectedChildrenCount() { int count = 0; QListViewItem* item = firstChild(); while (item) { if (item->isSelected()) ++count; item = item->nextSibling(); } return count; }
void oprof_start::event_selected() { // The deal is simple: QT lack of a way to know what item was the last // (de)selected item so we record a set of selected items and diff // it in the appropriate way with the previous list of selected items. set<QListViewItem *> current_selection; QListViewItem * cur; for (cur = events_list->firstChild(); cur; cur = cur->nextSibling()) { if (cur->isSelected()) current_selection.insert(cur); } // First remove the deselected item. vector<QListViewItem *> new_deselected; set_difference(selected_events.begin(), selected_events.end(), current_selection.begin(), current_selection.end(), back_inserter(new_deselected)); vector<QListViewItem *>::const_iterator it; for (it = new_deselected.begin(); it != new_deselected.end(); ++it) selected_events.erase(*it); // Now try to add the newly selected item if enough HW resource exists vector<QListViewItem *> new_selected; set_difference(current_selection.begin(), current_selection.end(), selected_events.begin(), selected_events.end(), back_inserter(new_selected)); for (it = new_selected.begin(); it != new_selected.end(); ++it) { selected_events.insert(*it); if (!alloc_selected_events()) { (*it)->setSelected(false); selected_events.erase(*it); } else { current_event = *it; } } draw_event_list(); if (current_event) display_event(locate_event(current_event->text(0).latin1())); }
void RKVarSlot::listSelectionChanged () { RK_TRACE (PLUGIN); bool selection = false; ObjectList sellist; QListViewItem *item = list->firstChild (); while (item) { if (item->isSelected ()) { selection = true; RObject *robj = item_map[item]; RK_ASSERT (robj); sellist.append (robj); } item = item->nextSibling (); } selected->setObjectList (sellist); setSelectButton (((!multi) || (!selection)) && (!available->atMaxLength ())); }
void KACLListView::contentsMousePressEvent(QMouseEvent *e) { QListViewItem *clickedItem = itemAt(contentsToViewport(e->pos())); if(!clickedItem) return; // if the click is on an as yet unselected item, select it first if(!clickedItem->isSelected()) KListView::contentsMousePressEvent(e); if(!currentItem()) return; int column = header()->sectionAt(e->x()); acl_perm_t perm; switch(column) { case 2: perm = ACL_READ; break; case 3: perm = ACL_WRITE; break; case 4: perm = ACL_EXECUTE; break; default: return KListView::contentsMousePressEvent(e); } KACLListViewItem *referenceItem = static_cast< KACLListViewItem * >(clickedItem); unsigned short referenceHadItSet = referenceItem->value & perm; QListViewItemIterator it(this); while(KACLListViewItem *item = static_cast< KACLListViewItem * >(it.current())) { ++it; if(!item->isSelected()) continue; // toggle those with the same value as the clicked item, leave the others if(referenceHadItSet == (item->value & perm)) item->togglePerm(perm); } }
void UIChannelDialog::slot_Join() { m_view->firstChild(); QListViewItemIterator it( m_view ); QListViewItem * item; for ( ; ( item = it.current() ); ++it ) { if ( item->text( Col_Size ).isEmpty() == true ) continue ; if ( item->isSelected() == false ) continue ; IOMessage * io = new IOMessage( 0 ); io->setMessageType( IONapsterCodes::ChanJoinRequest ); io->insert( "rawdata", item->text( Col_Chan ) ); emit sendIO( io ); delete io; } accept(); }
bool RefactoringAssistant::acceptDrag(QDropEvent *event) const { //first check if we can accept drops at all, and if the operation // is a move within the list itself if( !acceptDrops() || !itemsMovable() || (event->source()!=viewport())) { return false; } RefactoringAssistant *me = const_cast<RefactoringAssistant*>(this); //ok, check if the move is valid QListViewItem *movingItem = 0, *afterme = 0, *parentItem = 0; me->findDrop(event->pos(), parentItem, afterme); for( movingItem = firstChild(); movingItem != 0; movingItem = movingItem->itemBelow() ) { if( movingItem->isSelected() ) break; } if(!movingItem || !parentItem) { kDebug()<<"moving/parent items not found - can't accept drag!"<<endl; return false; } UMLObject *movingObject; if( !(movingObject = me->findUMLObject(movingItem)) ) { kDebug()<<"Moving object not found in uml map!"<<movingItem->text(0)<<endl; return false; } Uml::Object_Type t = movingObject->getBaseType(); if (t != Uml::ot_Attribute && t != Uml::ot_Operation) { kDebug()<<"only operations and attributes are movable! - return false"<<endl; return false; } kDebug()<<"parent item is "<<parentItem->text(0)<<endl; UMLObject *parentObject = me->findUMLObject(parentItem); if( parentObject && dynamic_cast<UMLClassifier*>(parentObject) ) { //droping to a classifier, ok } else {//parent is not a classifier, so maybe it's a folder.. check types if( (parentItem->text(1) == "operations" && t == Uml::ot_Operation) || (parentItem->text(1) == "attributes" && t == Uml::ot_Attribute)) { parentObject = me->findUMLObject( parentItem->parent() ); } else { kDebug()<<"moving to item "<<parentItem->text(0)<<" -- "<<parentItem->text(1)<<" not valid"<<endl; return false; } } if (dynamic_cast<UMLClassifier*>(parentObject) && (t == Uml::ot_Attribute || t == Uml::ot_Operation)) { return true; } kDebug()<<"how did I get here? return false!!"<<endl; return false; }
bool oprof_start::save_config() { if (!record_config()) return false; vector<string> args; // saving config is done by running opcontrol --setup with appropriate // setted parameters so we use the same config file as command line // tools args.push_back("--setup"); bool one_enabled = false; vector<string> tmpargs; tmpargs.push_back("--setup"); QListViewItem * cur; for (cur = events_list->firstChild(); cur; cur = cur->nextSibling()) { if (!cur->isSelected()) continue; event_setting & cfg = event_cfgs[cur->text(0).latin1()]; op_event_descr const & descr = locate_event(cur->text(0).latin1()); one_enabled = true; string arg = "--event=" + descr.name; arg += ":" + op_lexical_cast<string>(cfg.count); arg += ":" + op_lexical_cast<string>(cfg.umask); arg += ":" + op_lexical_cast<string>(cfg.os_ring_count); arg += ":" + op_lexical_cast<string>(cfg.user_ring_count); tmpargs.push_back(arg); } // only set counters if at least one is enabled if (one_enabled) args = tmpargs; if (config.no_kernel) { args.push_back("--no-vmlinux"); } else { args.push_back("--vmlinux=" + config.kernel_filename); } args.push_back("--buffer-size=" + op_lexical_cast<string>(config.buffer_size)); if (op_get_interface() == OP_INTERFACE_24) { args.push_back("--note-table-size=" + op_lexical_cast<string>(config.note_table_size)); } else { args.push_back("--buffer-watershed=" + op_lexical_cast<string>(config.buffer_watershed)); args.push_back("--cpu-buffer-size=" + op_lexical_cast<string>(config.cpu_buffer_size)); if (op_file_readable("/dev/oprofile/backtrace_depth")) { args.push_back("--callgraph=" + op_lexical_cast<string>(config.callgraph_depth)); } } string sep = "--separate="; if (config.separate_lib) sep += "library,"; if (config.separate_kernel) sep += "kernel,"; if (config.separate_cpu) sep += "cpu,"; if (config.separate_thread) sep += "thread,"; if (sep == "--separate=") sep += "none"; args.push_back(sep); // 2.95 work-around, it didn't like return !do_exec_command() bool ret = !do_exec_command(OP_BINDIR "/opcontrol", args); return ret; }
// user is happy of its setting. void oprof_start::on_start_profiler() { // save the current settings record_selected_event_config(); bool one_enable = false; QListViewItem * cur; for (cur = events_list->firstChild(); cur; cur = cur->nextSibling()) { if (!cur->isSelected()) continue; // the missing reference is intended: gcc 2.91.66 can compile // "op_event_descr const & descr = ..." w/o a warning op_event_descr const descr = locate_event(cur->text(0).latin1()); event_setting & cfg = event_cfgs[cur->text(0).latin1()]; one_enable = true; if (!cfg.os_ring_count && !cfg.user_ring_count) { QMessageBox::warning(this, 0, "You must select to " "profile at least one of user binaries/kernel"); return; } if (cfg.count < descr.min_count || cfg.count > max_perf_count()) { ostringstream out; out << "event " << descr.name << " count of range: " << cfg.count << " must be in [ " << descr.min_count << ", " << max_perf_count() << "]"; QMessageBox::warning(this, 0, out.str().c_str()); return; } if (descr.unit && descr.unit->unit_type_mask == utm_bitmask && cfg.umask == 0) { ostringstream out; out << "event " << descr.name << " invalid unit mask: " << cfg.umask << endl; QMessageBox::warning(this, 0, out.str().c_str()); return; } } if (one_enable == false && cpu_type != CPU_TIMER_INT) { QMessageBox::warning(this, 0, "No counters enabled.\n"); return; } if (daemon_status().running) { // gcc 2.91 work around int user_choice = 0; user_choice = QMessageBox::warning(this, 0, "Profiler already started:\n\n" "stop and restart it?", "&Restart", "&Cancel", 0, 0, 1); if (user_choice == 1) return; // this flush profiler data also. on_stop_profiler(); } vector<string> args; // save_config validate and setup the config if (save_config()) { // now actually start args.push_back("--start"); if (config.verbose) args.push_back("--verbose"); do_exec_command(OP_BINDIR "/opcontrol", args); } total_nr_interrupts = 0; timerEvent(0); }
static bool hasSelection( QListViewItem * start ) { for ( QListViewItem * item = start ; item ; item = item->nextSibling() ) if ( item->isSelected() || hasSelection( item->firstChild() ) ) return true; return false; }
void RefactoringAssistant::movableDropEvent (QListViewItem* parentItem, QListViewItem* afterme) { //when dropping on a class, we have to put the item in the appropriate folder! UMLObject *movingObject; UMLClassifier *newClassifier; QListViewItem *movingItem; for( movingItem = firstChild(); movingItem != 0; movingItem = movingItem->itemBelow() ) { if( movingItem->isSelected() ) break; } if( !movingItem || (movingItem == afterme) || !(movingObject = findUMLObject(movingItem)) ) { kWarning()<<"Moving item not found or dropping after itself or item not found in uml obj map. aborting. (drop had already been accepted)"<<endl; return; } Uml::Object_Type t = movingObject->getBaseType(); newClassifier = dynamic_cast<UMLClassifier*>( findUMLObject( parentItem ) ); if(!newClassifier) { if ((parentItem->text(1) == "operations" && t == Uml::ot_Operation) || (parentItem->text(1) == "attributes" && t == Uml::ot_Attribute)) { newClassifier = dynamic_cast<UMLClassifier*>( findUMLObject( parentItem->parent() ) ); } if(!newClassifier) { kWarning()<<"New parent of object is not a Classifier - Drop had already been accepted - check!"<<endl; return; } } if (t == Uml::ot_Operation) {kDebug()<<"moving operation"<<endl; UMLOperation *op = static_cast<UMLOperation*>(movingObject); if(newClassifier->checkOperationSignature(op->getName(), op->getParmList())) { QString msg = QString(i18n("An operation with that signature already exists in %1.\n")).arg(newClassifier->getName()) + QString(i18n("Choose a different name or parameter list." )); KMessageBox::error(this, msg, i18n("Operation Name Invalid"), false); return; } UMLClassifier *oldClassifier = dynamic_cast<UMLClassifier*>(op->parent()); if(oldClassifier) oldClassifier->removeOperation( op ); newClassifier->addOperation( op ); } else if (t == Uml::ot_Attribute) {kDebug()<<"moving attribute - not implemented"<<endl; // UMLAttribute *att = static_cast<UMLAttribute*>(movingObject); // if(!newClassifier->checkAttributeSignature(att)) // { // QString msg = QString(i18n("An attribute with that signature already exists in %1.\n")).arg(newClassifier->getName()) // + // QString(i18n("Choose a different name or parameter list." )); // KMessageBox::error(this, msg, i18n("Operation Name Invalid"), false); // return; // } // oldClassifier->removeAttribute( att ); // newClassifier->addAttribute( att ); } //emit moved(moving, afterFirst, afterme); emit moved(); }
void DolphinView::renameSelectedItems() { const KURL::List urls = selectedURLs(); if (urls.count() > 1) { // More than one item has been selected for renaming. Open // a rename dialog and rename all items afterwards. RenameDialog dialog(urls); if (dialog.exec() == QDialog::Rejected) { return; } DolphinView* view = Dolphin::mainWin().activeView(); const QString& newName = dialog.newName(); if (newName.isEmpty()) { view->statusBar()->setMessage(i18n("The new item name is invalid."), DolphinStatusBar::Error); } else { UndoManager& undoMan = UndoManager::instance(); undoMan.beginMacro(); assert(newName.contains('#')); const int urlsCount = urls.count(); ProgressIndicator* progressIndicator = new ProgressIndicator(i18n("Renaming items..."), i18n("Renaming finished."), urlsCount); // iterate through all selected items and rename them... const int replaceIndex = newName.find('#'); assert(replaceIndex >= 0); for (int i = 0; i < urlsCount; ++i) { const KURL& source = urls[i]; QString name(newName); name.replace(replaceIndex, 1, renameIndexPresentation(i + 1, urlsCount)); if (source.fileName() != name) { KURL dest(source.upURL()); dest.addPath(name); const bool destExists = KIO::NetAccess::exists(dest, false, view); if (destExists) { delete progressIndicator; progressIndicator = 0; view->statusBar()->setMessage(i18n("Renaming failed (item '%1' already exists).").arg(name), DolphinStatusBar::Error); break; } else if (KIO::NetAccess::file_move(source, dest)) { // TODO: From the users point of view he executed one 'rename n files' operation, // but internally we store it as n 'rename 1 file' operations for the undo mechanism. DolphinCommand command(DolphinCommand::Rename, source, dest); undoMan.addCommand(command); } } progressIndicator->execOperation(); } delete progressIndicator; progressIndicator = 0; undoMan.endMacro(); } } else { // Only one item has been selected for renaming. Use the custom // renaming mechanism from the views. assert(urls.count() == 1); if (m_mode == DetailsView) { QListViewItem* item = m_detailsView->firstChild(); while (item != 0) { if (item->isSelected()) { m_detailsView->rename(item, DolphinDetailsView::NameColumn); break; } item = item->nextSibling(); } } else { KFileIconViewItem* item = static_cast<KFileIconViewItem*>(m_iconsView->firstItem()); while (item != 0) { if (item->isSelected()) { item->rename(); break; } item = static_cast<KFileIconViewItem*>(item->nextItem()); } } } }