Пример #1
0
void OCompletionBox::setItems( const QStringList& items )
{
    bool block = signalsBlocked();
    blockSignals( true );

    QListBoxItem* item = firstItem();
    if ( !item ) {
        insertStringList( items );
    }
    else {
        for ( QStringList::ConstIterator it = items.begin(); it != items.end(); it++) {
            if ( item ) {
                ((OCompletionBoxItem*)item)->reuse( *it );
                item = item->next();
            }
            else {
                insertItem( new QListBoxText( *it ) );
            }
        }
        QListBoxItem* tmp = item;
        while ( (item = tmp ) ) {
            tmp = item->next();
            delete item;
        }
        triggerUpdate( false );
    }

    blockSignals( block );
    d->down_workaround = true;
}
Пример #2
0
void ConnectWizard::slotMoveDown()
{
    // when nothing is selected, select the first
    QListBoxItem* i = m_viewList->selectedItem();
    if( !i ) {
        m_viewList->setSelected( 0, true );
        return;
    }
    // when next exists, select it, otherwise do nothing
    if( i->next() ) {
        m_viewList->setSelected( i->next(), true );
    } else {
        m_viewList->setSelected( i, true );
    }
}
Пример #3
0
void MessageFilterDialog::addedFilter(uint32_t mask, uint8_t filterid, 
				      const MessageFilter& filter)
{
  if (m_existingFilters->count() == 0)
  {
      // add the new message filter 
      new MessageFilterListBoxText(m_existingFilters, 0,
				   filter.name(), filterid);

  }

  // iterate over all the existing filters
  for (QListBoxItem* currentLBT = m_existingFilters->firstItem();
       currentLBT;
       currentLBT = currentLBT->next())
  {
    // check if this is the removed filter
    if (((MessageFilterListBoxText*)currentLBT)->data() > filterid)
    {
      // add a new message filter at the appropriate location
      //   NOTE: This maintains list order during an item update
      new MessageFilterListBoxText(m_existingFilters, currentLBT->prev(),
				   filter.name(), filterid);

      break;
    }
  }
}
Пример #4
0
bool ListBoxDnd::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();
	QListBoxItem * after = itemAt( pos );

	if ( ListBoxItemDrag::decode( event, (QListBox *) src, after ) ) {
	    event->accept();
	    QListBox * src = (QListBox *) this->src;
	    QListBoxItem * item = ( after ? after->next() : src->firstItem() );
	    src->setCurrentItem( item );
	    emit dropped( item ); // ###FIX: Supports only one item!
	}
    }

    line->hide();
    dragInside = FALSE;

    return TRUE;
}
Пример #5
0
void MessageFilterDialog::existingFilterSelectionChanged(QListBoxItem * item)
{
  if (item)
  {
    // get the current filter number from the listbox item
    m_currentFilterNum = ((MessageFilterListBoxText*)item)->data();
    
    // get the specified filter
    m_currentFilter = m_filters->filter(m_currentFilterNum);

    // set the GroupBox's label
    m_filterGroup->setTitle(m_currentFilter->name() + " &Filter");

    // setup all the filter values
    m_name->setText(m_currentFilter->name());
    m_pattern->setText(m_currentFilter->regexp().pattern());

    // select all the message types
    uint64_t messageTypes = m_currentFilter->types();
    uint32_t messageType;
    for (QListBoxItem* currentLBT = m_messageTypes->firstItem();
	 currentLBT;
	 currentLBT = currentLBT->next())
    {
      messageType = ((MessageFilterListBoxText*)currentLBT)->data();
      m_messageTypes->setSelected(currentLBT, ((uint64_t(1) << messageType) & messageTypes) != 0);
    }
  }
  else // no item selected, clear all filter setup
    clearFilter();

  // check the current state
  checkState();
}
Пример #6
0
void KURLBar::setCurrentItem(const KURL &url)
{
    d->currentURL = url;

    QString u = url.url(-1);

    if(m_activeItem && m_activeItem->url().url(-1) == u)
        return;

    bool hasURL = false;
    QListBoxItem *item = m_listBox->firstItem();
    while(item)
    {
        if(static_cast< KURLBarItem * >(item)->url().url(-1) == u)
        {
            m_activeItem = static_cast< KURLBarItem * >(item);
            m_listBox->setCurrentItem(item);
            m_listBox->setSelected(item, true);
            hasURL = true;
            break;
        }
        item = item->next();
    }

    if(!hasURL)
    {
        m_activeItem = 0L;
        m_listBox->clearSelection();
    }
}
Пример #7
0
const KProxyData KManualProxyDlg::data() const
{
    KProxyData data;

    if (!m_bHasValidData)
      return data;

    data.proxyList["http"] = urlFromInput( mDlg->leHttp, mDlg->sbHttp );
    
    if ( mDlg->cbSameProxy->isChecked () )
    {
        data.proxyList["https"] = data.proxyList["http"];
        data.proxyList["ftp"] = data.proxyList["http"];
    }
    else
    {
        data.proxyList["https"] = urlFromInput( mDlg->leHttps, mDlg->sbHttps );
        data.proxyList["ftp"] = urlFromInput( mDlg->leFtp, mDlg->sbFtp );
    }

    if ( mDlg->lbExceptions->count() )
    {
        QListBoxItem* item = mDlg->lbExceptions->firstItem();
        for( ; item != 0L; item = item->next() )
            data.noProxyFor << item->text();
    }

    data.type = KProtocolManager::ManualProxy;
    data.useReverseProxy = mDlg->cbReverseProxy->isChecked();

    return data;
}
Пример #8
0
int ListBoxDnd::buildList( ListBoxItemList & list )
{
    QListBoxItem * i = ((QListBox *)src)->firstItem();
    while ( i ) {
	if ( i->isSelected() ) {
	    ((QListBox *)src)->setSelected( i, FALSE );
	    list.append( i );
	}
	i = i->next();
    }
    return list.count();
}
Пример #9
0
void TableEditor::readRows()
{
    int j = 0;
#ifndef QT_NO_TABLE
    for ( QListBoxItem *i = listRows->firstItem(); i; i = i->next(), ++j ) {
	if ( i->pixmap() )
	    table->verticalHeader()->setLabel( j, *i->pixmap(), i->text() );
	else
	    table->verticalHeader()->setLabel( j, i->text() );
    }
#endif
}
Пример #10
0
void ClsQSAList::slotMoveDown() {
//    cout << "ClsQSAList::slotMoveDown()" << endl;
    
    int iCurrent = qlbox->currentItem();
    if(iCurrent>=0) {
	QListBoxItem * lbCurrent = qlbox->item(iCurrent);
	QListBoxItem * lbNext = lbCurrent->next();
	if(lbNext!=NULL) {
	    int iNext = qlbox->index(lbNext);
	    qlbox->takeItem(lbCurrent);
	    qlbox->insertItem(lbCurrent, iNext);
	    qlbox->setCurrentItem ( iNext );
	}
    }
}
Пример #11
0
void ListViewEditor::columnDownClicked()
{
    if ( colPreview->currentItem() == -1 ||
	 colPreview->currentItem() > (int)colPreview->count() - 2 )
	return;

    colPreview->clearSelection();
    QListBoxItem *i = colPreview->item( colPreview->currentItem() );
    QListBoxItem *below = i->next();

    colPreview->takeItem( i );
    colPreview->insertItem( i, below );

    colPreview->setCurrentItem( i );
    colPreview->setSelected( i, TRUE );
}
Пример #12
0
void ListBoxEditor::applyClicked()
{
    QListBoxItem *i = 0;
    QValueList<PopulateListBoxCommand::Item> items;
    for ( i = preview->firstItem(); i; i = i->next() ) {
	PopulateListBoxCommand::Item item;
	if ( i->pixmap() )
	    item.pix = *i->pixmap();
	item.text = i->text();
	items.append( item );
    }

    PopulateListBoxCommand *cmd = new PopulateListBoxCommand( tr( "Edit Items of '%1'" ).arg( listbox->name() ),
							      formwindow, listbox, items );
    cmd->execute();
    formwindow->commandHistory()->addCommand( cmd );
}
Пример #13
0
void KActionSelector::buttonRemoveClicked()
{
  // move all selected items from selected to available listbox
  QListBoxItem *item = d->selectedListBox->firstItem();
  while ( item ) {
    if ( item->isSelected() ) {
      d->selectedListBox->takeItem( item );
      d->availableListBox->insertItem( item, insertionIndex( d->availableListBox, d->availableInsertionPolicy ) );
      d->availableListBox->setCurrentItem( item );
      emit removed( item );
    }
    item = item->next();
  }
  if ( d->availableInsertionPolicy == Sorted )
    d->availableListBox->sort();
  d->availableListBox->setFocus();
}
Пример #14
0
void MessageFilterDialog::removedFilter(uint32_t mask, uint8_t filter)
{
  // iterate over all the existing filters
  for (QListBoxItem* currentLBT = m_existingFilters->firstItem();
       currentLBT;
       currentLBT = currentLBT->next())
  {
    // check if this is the removed filter
    if (((MessageFilterListBoxText*)currentLBT)->data() == filter)
    {
      // delete the removed filter's list box item
      delete currentLBT;

      // nothing more to do
      break;
    }
  }
}
Пример #15
0
bool KManualProxyDlg::handleDuplicate( const QString& site )
{
    QListBoxItem* item = mDlg->lbExceptions->firstItem();
    while ( item != 0 )
    {
        if ( item->text().findRev( site ) != -1 &&
             item != mDlg->lbExceptions->selectedItem() )
        {
            QString msg = i18n("You entered a duplicate address. "
                               "Please try again.");
            QString details = i18n("<qt><center><b>%1</b></center> "
                                   "is already in the list.</qt>").arg(site);
            KMessageBox::detailedError( this, msg, details, i18n("Duplicate Entry") );
            return true;
        }
        
        item = item->next();
    }
    return false;
}
Пример #16
0
void KFSConfigPage::apply()
{
  if ( ! m_changed )
    return;

  m_changed = false;

  KConfig *config = kapp->config();
  config->setGroup( "fileselector" );
  // toolbar
  QStringList l;
  QListBoxItem *item = acSel->selectedListBox()->firstItem();
  ActionLBItem *aItem;
  while ( item )
  {
    aItem = (ActionLBItem*)item;
    if ( aItem )
    {
      l << aItem->idstring();
    }
    item = item->next();
  }
  config->writeEntry( "toolbar actions", l );
  fileSelector->setupToolbar( config );
  // sync
  int s = 0;
  if ( cbSyncActive->isChecked() )
    s |= KateFileSelector::DocumentChanged;
  if ( cbSyncShow->isChecked() )
    s |= KateFileSelector::GotVisible;
  fileSelector->autoSyncEvents = s;

  // histories
  fileSelector->cmbPath->setMaxItems( sbPathHistLength->value() );
  fileSelector->filter->setMaxCount( sbFilterHistLength->value() );
  // session - theese are read/written directly to the app config,
  //           as they are not needed during operation.
  config->writeEntry( "restore location", cbSesLocation->isChecked() );
  config->writeEntry( "restore last filter", cbSesFilter->isChecked() );
}
Пример #17
0
void ListViewEditor::setupItems()
{
    itemColumn->setMinValue( 0 );
    itemColumn->setMaxValue( QMAX( numColumns - 1, 0 ) );
    int i = 0;
    QHeader *header = itemsPreview->header();
    for ( QListBoxItem *item = colPreview->firstItem(); item; item = item->next() ) {
	Column *col = findColumn( item );
	if ( !col )
	    continue;
	if ( i >= itemsPreview->columns() )
	    itemsPreview->addColumn( col->text );
	header->setLabel( i, col->pixmap, col->text );
	header->setResizeEnabled( col->resizable, i );
	header->setClickEnabled( col->clickable, i );
	++i;
    }
    while ( itemsPreview->columns() > i )
	itemsPreview->removeColumn( i );

    itemColumn->setValue( QMIN( numColumns - 1, itemColumn->value() ) );
}
Пример #18
0
ListBoxEditor::ListBoxEditor( QWidget *parent, QWidget *editWidget, FormWindow *fw )
    : ListBoxEditorBase( parent, 0, TRUE ), formwindow( fw )
{
    connect( helpButton, SIGNAL( clicked() ), MainWindow::self, SLOT( showDialogHelp() ) );
    listbox = (QListBox*)editWidget;

    itemText->setText( "" );
    itemText->setEnabled( FALSE );
    itemPixmap->setText( "" );
    itemChoosePixmap->setEnabled( FALSE );
    itemDeletePixmap->setEnabled( FALSE );

    QListBoxItem *i = 0;
    for ( i = listbox->firstItem(); i; i = i->next() ) {
	if ( i->pixmap() )
	    (void)new QListBoxPixmap( preview, *i->pixmap(), i->text() );
	else
	    (void)new QListBoxText( preview, i->text() );
    }

    if ( preview->firstItem() )
	preview->setCurrentItem( preview->firstItem() );
}
Пример #19
0
void ListBoxEditor::moveItemDown()
{
    if ( preview->currentItem() == -1 || preview->currentItem() > (int)preview->count() - 2 )
	return;

    QListBoxItem *i = preview->item( preview->currentItem() );
    bool hasPix = (bool)i->pixmap();
    QPixmap pix;
    if ( hasPix )
	pix = *i->pixmap();
    QString txt = i->text();

    QListBoxItem *n = i->next();
    if ( n->pixmap() )
	preview->changeItem( *n->pixmap(), n->text(), preview->currentItem() );
    else
	preview->changeItem( n->text(), preview->currentItem() );

    if ( hasPix )
	preview->changeItem( pix, txt, preview->currentItem() + 1 );
    else
	preview->changeItem( txt, preview->currentItem() + 1 );
}
Пример #20
0
void MessageFilterDialog::addFilter()
{
  uint32_t type;
  uint64_t types = 0;

  // iterate over the message types
  for (QListBoxItem* currentLBT = m_messageTypes->firstItem();
       currentLBT;
       currentLBT = currentLBT->next())
  {
    // if the item isn't selected, add in its type flag, and enable updates
    if (currentLBT->isSelected())
    {
      // get the message type of the selected item
      type = ((MessageFilterListBoxText*)currentLBT)->data();

      // add its flag to the types 
      types |= (uint64_t(1) << type);
    }
  } 

  // create a message filter object
  MessageFilter newFilter(m_name->text(), types, m_pattern->text());

  // if this isn't a valid filter, don't create it
  if (!newFilter.valid())
    return;

  // add the new filter
  m_currentFilterNum = m_filters->addFilter(newFilter);
  
  // if it is a valid filter, make the new filter the current selection
  if (m_currentFilterNum != 0xFF)
  {
    // retrieve the current item
    m_currentFilter = m_filters->filter(m_currentFilterNum);

    // iterate over the existing filters
    for (QListBoxItem* currentLBT = m_existingFilters->firstItem();
	 currentLBT;
	 currentLBT = currentLBT->next())
    {
      // find the current filter
      if (((MessageFilterListBoxText*)currentLBT)->data() == m_currentFilterNum)
      {
	// make the current filter the selected filter
	m_existingFilters->setSelected(currentLBT, true);
	break;
      }
    }
  }
  else // clear the current filter
  {
    // clear the current filter
    m_currentFilter = 0;
    clearFilter();
  }
  
  // setup the current dialog state
  checkState();
}
Пример #21
0
void MessageFilterDialog::checkState()
{
  bool update = false;
  bool add = false;

  // the state check varies depending on if their is a current filter or not
  if (m_currentFilter)
  {
    uint32_t type;
    uint64_t types = 0;
    
    // buttons should only be enabled for valid message filter content
    if (!m_name->text().isEmpty() &&
	!m_pattern->text().isEmpty() &&
	QRegExp(m_pattern->text()).isValid())
    {
      // iterate over all the message types
      for (QListBoxItem* currentLBT = m_messageTypes->firstItem();
	   currentLBT;
	   currentLBT = currentLBT->next())
      {
	// is the current item selected
	if (currentLBT->isSelected())
	{
	  // get the items message type
	  type = ((MessageFilterListBoxText*)currentLBT)->data();

	  // add the message type into the message types
	  types |= (uint64_t(1) << type);

	  // found a selected item, fields are valid for update
	  update = true;
	}
      }

      // only enable add if the filter is different from its predecessor
      if ((m_name->text() != m_currentFilter->name()) || 
	  (m_pattern->text() != m_currentFilter->regexp().pattern()) ||
	  (types != m_currentFilter->types()))
	add = true;

    }
  }
  else
  {
    // buttons should only be enabled for valid message filter content
    if (!m_name->text().isEmpty() &&
	!m_pattern->text().isEmpty())
    {
      // iterate over all the message types
      for (QListBoxItem* currentLBT = m_messageTypes->firstItem();
	   currentLBT;
	   currentLBT = currentLBT->next())
      {
	// if the item isn't selected, try the next item
	if (!currentLBT->isSelected())
	  continue;
	
	// found a selected item, fields are valid for add
	add = true;
	break;
      }
    }
  }

  // set the button states according to the results from above
  m_add->setEnabled(add);
  m_update->setEnabled(update);

  // only enable delete if editing an existing filter
  m_delete->setEnabled(m_currentFilter != 0);
}