Example #1
0
void
KCustomMenuEditor::load(KConfigBase *cfg)
{
   cfg->setGroup(QString::null);
   int count = cfg->readNumEntry("NrOfItems");
   QListViewItem *last = 0;
   for(int i = 0; i < count; i++)
   {
      QString entry = cfg->readPathEntry(QString("Item%1").arg(i+1));
      if (entry.isEmpty())
         continue;

      // Try KSycoca first.
      KService::Ptr menuItem = KService::serviceByDesktopPath( entry );
      if (!menuItem)
         menuItem = KService::serviceByDesktopName( entry );
      if (!menuItem)
         menuItem = new KService( entry );

      if (!menuItem->isValid())
         continue;

      QListViewItem *item = new Item(m_listView, menuItem);
      item->moveItem(last);
      last = item;
   }
}
Example #2
0
void LayoutConfig::moveDown()
{
    QListViewItem *sel = widget->listLayoutsDst->selectedItem();
    if(sel == 0 || sel->itemBelow() == 0)
        return;

    sel->moveItem(sel->itemBelow());
}
Example #3
0
/* config-slot: "down" button clicked */
void TopLevel::downButtonClicked() {
	QListViewItem* item = listbox->currentItem();

	if (item && item->itemBelow())
		item->moveItem(item->itemBelow());

	enable_controls();
}
Example #4
0
/** Button Down */
void KControlAddEdit::slotMoveDownAnswer()
{
    QListViewItem *item = _listAnswers->currentItem();

    if (item)
        item->moveItem(item->itemBelow());

    _buttonUp->setEnabled(item->itemAbove()!=0);
    _buttonDown->setEnabled(item->itemBelow()!=0);
}
Example #5
0
void OListEditForm::downItem()
{
    QListViewItem *selectedItem = m_listView->selectedItem();
    if( selectedItem )
    {
        QListViewItem *nextItem = selectedItem->nextSibling();
        if( nextItem )
            selectedItem->moveItem( nextItem );
    }
}
void kiptablesgenerator::slotDownService()
{
  QListView* ports = (QListView*) namedWidgets["iPorts"];
  QListViewItem *sel = ports->selectedItem(), *ibelow = 0;
  
  if (sel)
    ibelow=sel->itemBelow(); // Only check itemAbove() if it exists...

  if (sel  && ibelow)
    sel->moveItem(ibelow); //Move the Item
}
void DlgDirectories::upEntry()
{
    QListViewItem *item = lv_entries->selectedItem();

    if ( !item || !item->itemAbove() )
        return;

    item->moveItem( item->itemAbove()->itemAbove() );

    updateUpDown();
    emit configChanged();
}
void GofunListWidget::up()
{
    if (!list->currentItem())
        return;
    if (list->currentItem() == list->firstChild()) 
        return;
    
    QListViewItem *item = list->firstChild();
    while (item->nextSibling() != list->currentItem())
        item = item->nextSibling();
    item->moveItem( list->currentItem()); 

	emit listChanged();
}
Example #9
0
void
KCustomMenuEditor::slotMoveDown()
{
   QListViewItem *item = m_listView->currentItem();
   if (!item)
      return;

   QListViewItem *after = item->nextSibling();
   if (!after)
      return;

   item->moveItem( after );
   refreshButton();
}
Example #10
0
void SequenceEditor::slotRaise()
{
  QListViewItem* item = m_list->currentItem();
  if (!item)
    {
      return;
    }

  QListViewItem* itemAbove = item->itemAbove();
  if (itemAbove)
    {
      if (itemAbove->itemAbove())
	{
	  item->moveItem(itemAbove->itemAbove());
	}
      else
	{
	  itemAbove->moveItem(item);
	}
    }

  m_list->ensureItemVisible(item);
}
Example #11
0
void LayoutConfig::moveUp()
{
    QListViewItem *sel = widget->listLayoutsDst->selectedItem();
    if(sel == 0 || sel->itemAbove() == 0)
        return;

    if(sel->itemAbove()->itemAbove() == 0)
    {
        widget->listLayoutsDst->takeItem(sel);
        widget->listLayoutsDst->insertItem(sel);
        widget->listLayoutsDst->setSelected(sel, true);
    }
    else
        sel->moveItem(sel->itemAbove()->itemAbove());
}
Example #12
0
void SequenceEditor::slotLower()
{
  QListViewItem* item = m_list->currentItem();
  if (!item)
    {
      return;
    }

  QListViewItem* itemBelow = item->itemBelow();
  if (itemBelow)
    {
      item->moveItem(itemBelow);
    }

  m_list->ensureItemVisible(item);
}
Example #13
0
void OListEditForm::upItem()
{
    QListViewItem *selectedItem = m_listView->selectedItem();
    if( selectedItem )
    {
        QListViewItem *previousItem = NULL;
        for( QListViewItem *item = m_listView->firstChild(); item; item = item->nextSibling() )
        {
            if( item->nextSibling() == selectedItem )
                previousItem = item;
        }

        if( previousItem )
            previousItem->moveItem( selectedItem );
    }
}
Example #14
0
void
StdWidgetFactory::readListItem(QDomElement &node, QListViewItem *parent, KListView *listview)
{
	QListViewItem *item;
	if(parent)
		item = new KListViewItem(parent);
	else
		item = new KListViewItem(listview);

	// We need to move the item at the end of the list
	QListViewItem *last;
	if(parent)
		last = parent->firstChild();
	else
		last = listview->firstChild();

	while(last->nextSibling())
		last = last->nextSibling();
	item->moveItem(last);

	int i = 0;
	for(QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling())
	{
		QDomElement childEl = n.toElement();
		QString prop = childEl.attribute("name");
		QString tag = childEl.tagName();

		// We read sub items
		if(tag == "item")
		{
			item->setOpen(true);
			readListItem(childEl, item, listview);
		}
		// and column texts
		else if((tag == "property") && (prop == "text"))
		{
			QVariant val = KFormDesigner::FormIO::readPropertyValue(n.firstChild(), listview, "item");
			item->setText(i, val.toString());
			i++;
		}
	}
}
Example #15
0
void
KCustomMenuEditor::slotMoveUp()
{
   QListViewItem *item = m_listView->currentItem();
   if (!item)
      return;

   QListViewItem *searchItem = m_listView->firstChild();
   while(searchItem)
   {
      QListViewItem *next = searchItem->nextSibling();
      if (next == item)
      {
         searchItem->moveItem(item);
         break;
      }
      searchItem = next;
   }
   refreshButton();
}
Example #16
0
void LayoutConfig::add()
{
    QListViewItem *sel = widget->listLayoutsSrc->selectedItem();
    if(sel == 0)
        return;

    // Create a copy of the sel widget, as one might add the same layout more
    // than one time, with different variants.
    QListViewItem *toadd = copyLVI(sel, widget->listLayoutsDst);

    widget->listLayoutsDst->insertItem(toadd);
    if(widget->listLayoutsDst->childCount() > 1)
        toadd->moveItem(widget->listLayoutsDst->lastItem());
    // disabling temporary: does not work reliable in Qt :(
    //    widget->listLayoutsDst->setSelected(sel, true);
    //    layoutSelChanged(sel);

    updateStickyLimit();
    changed();
}
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 );
}
void BookmarksSettingsPage::slotAddButtonClicked()
{
    KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Add Bookmark"),
                         i18n("New bookmark"),
                         KURL(),
                         "bookmark");
    if (!bookmark.isNull()) {
        // insert bookmark into listview
        QListViewItem* item = new QListViewItem(m_listView);
        item->setPixmap(PixmapIdx, SmallIcon(bookmark.icon()));
        item->setText(NameIdx, bookmark.text());
        item->setText(URLIdx, bookmark.url().prettyURL());
        item->setText(IconIdx, bookmark.icon());
        m_listView->insertItem(item);

        QListViewItem* lastItem = m_listView->lastChild();
        if (lastItem != 0) {
            item->moveItem(lastItem);
        }

        m_listView->setSelected(item, true);
        updateButtons();
    }
}
BookmarksSettingsPage::BookmarksSettingsPage(QWidget*parent) :
    SettingsPageBase(parent),
    m_addButton(0),
    m_removeButton(0),
    m_moveUpButton(0),
    m_moveDownButton(0)
{
    QVBoxLayout* topLayout = new QVBoxLayout(parent, 2, KDialog::spacingHint());

    const int spacing = KDialog::spacingHint();

    QHBox* hBox = new QHBox(parent);
    hBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    hBox->setSpacing(spacing);
    hBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);

    m_listView = new KListView(hBox);
    m_listView->addColumn(i18n("Icon"));
    m_listView->addColumn(i18n("Name"));
    m_listView->addColumn(i18n("Location"));
    m_listView->setResizeMode(QListView::LastColumn);
    m_listView->setColumnAlignment(0, Qt::AlignHCenter);
    m_listView->setAllColumnsShowFocus(true);
    m_listView->setSorting(-1);
    connect(m_listView, SIGNAL(selectionChanged()),
            this, SLOT(updateButtons()));
    connect(m_listView, SIGNAL(pressed(QListViewItem*)),
            this, SLOT(slotBookmarkPressed(QListViewItem*)));
    connect(m_listView, SIGNAL(doubleClicked(QListViewItem*, const QPoint&, int)),
            this, SLOT(slotBookmarkDoubleClicked(QListViewItem*, const QPoint&, int)));

    QVBox* buttonBox = new QVBox(hBox);
    buttonBox->setSpacing(spacing);

    const QSizePolicy buttonSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);

    m_addButton = new KPushButton(i18n("Add..."), buttonBox);
    connect(m_addButton, SIGNAL(clicked()),
            this, SLOT(slotAddButtonClicked()));
    m_addButton->setSizePolicy(buttonSizePolicy);

    m_editButton = new KPushButton(i18n("Edit..."), buttonBox);
    connect(m_editButton, SIGNAL(clicked()),
            this, SLOT(slotEditButtonClicked()));
    m_editButton->setSizePolicy(buttonSizePolicy);

    m_removeButton = new KPushButton(i18n("Remove"), buttonBox);
    connect(m_removeButton, SIGNAL(clicked()),
            this, SLOT(slotRemoveButtonClicked()));
    m_removeButton->setSizePolicy(buttonSizePolicy);

    m_moveUpButton = new KPushButton(i18n("Move Up"), buttonBox);
    connect(m_moveUpButton, SIGNAL(clicked()),
            this, SLOT(slotMoveUpButtonClicked()));
    m_moveUpButton->setSizePolicy(buttonSizePolicy);

    m_moveDownButton = new KPushButton(i18n("Move Down"), buttonBox);
    connect(m_moveDownButton, SIGNAL(clicked()),
            this, SLOT(slotMoveDownButtonClicked()));
    m_moveDownButton->setSizePolicy(buttonSizePolicy);

    // Add a dummy widget with no restriction regarding a vertical resizing.
    // This assures that the spacing between the buttons is not increased.
    new QWidget(buttonBox);

    topLayout->addWidget(hBox);

    // insert all editable bookmarks.
    KBookmarkGroup root = DolphinSettings::instance().bookmarkManager()->root();
    KBookmark bookmark = root.first();

    QListViewItem* prev = 0;
    while (!bookmark.isNull()) {
        QListViewItem* item = new QListViewItem(m_listView);
        item->setPixmap(PixmapIdx, SmallIcon(bookmark.icon()));
        item->setText(NameIdx, bookmark.text());
        item->setText(URLIdx, bookmark.url().prettyURL());

        // add hidden column to be able to retrieve the icon name again
        item->setText(IconIdx, bookmark.icon());

        m_listView->insertItem(item);
        if (prev != 0) {
            item->moveItem(prev);
        }
        prev = item;

        bookmark = root.next(bookmark);
    }
    m_listView->setSelected(m_listView->firstChild(), true);

    updateButtons();
}
Example #20
0
void LayoutConfig::initUI()
{
    const char *modelName = m_rules->models()[m_kxkbConfig.m_model];
    if(modelName == NULL)
        modelName = DEFAULT_MODEL;

    widget->comboModel->setCurrentText(i18n(modelName));

    QValueList< LayoutUnit > otherLayouts = m_kxkbConfig.m_layouts;
    widget->listLayoutsDst->clear();
    // to optimize we should have gone from it.end to it.begin
    QValueList< LayoutUnit >::ConstIterator it;
    for(it = otherLayouts.begin(); it != otherLayouts.end(); ++it)
    {
        QListViewItemIterator src_it(widget->listLayoutsSrc);
        LayoutUnit layoutUnit = *it;

        for(; src_it.current(); ++src_it)
        {
            QListViewItem *srcItem = src_it.current();

            if(layoutUnit.layout == src_it.current()->text(LAYOUT_COLUMN_MAP))
            { // check if current config knows about this layout
                QListViewItem *newItem = copyLVI(srcItem, widget->listLayoutsDst);

                newItem->setText(LAYOUT_COLUMN_VARIANT, layoutUnit.variant);
                newItem->setText(LAYOUT_COLUMN_INCLUDE, layoutUnit.includeGroup);
                newItem->setText(LAYOUT_COLUMN_DISPLAY_NAME, layoutUnit.displayName);
                widget->listLayoutsDst->insertItem(newItem);
                newItem->moveItem(widget->listLayoutsDst->lastItem());

                break;
            }
        }
    }

    // display KXKB switching options
    widget->chkShowSingle->setChecked(m_kxkbConfig.m_showSingle);
    widget->chkShowFlag->setChecked(m_kxkbConfig.m_showFlag);

    widget->chkEnableOptions->setChecked(m_kxkbConfig.m_enableXkbOptions);
    widget->checkResetOld->setChecked(m_kxkbConfig.m_resetOldOptions);

    switch(m_kxkbConfig.m_switchingPolicy)
    {
        default:
        case SWITCH_POLICY_GLOBAL:
            widget->grpSwitching->setButton(0);
            break;
        case SWITCH_POLICY_WIN_CLASS:
            widget->grpSwitching->setButton(1);
            break;
        case SWITCH_POLICY_WINDOW:
            widget->grpSwitching->setButton(2);
            break;
    }

    widget->chkEnableSticky->setChecked(m_kxkbConfig.m_stickySwitching);
    widget->spinStickyDepth->setEnabled(m_kxkbConfig.m_stickySwitching);
    widget->spinStickyDepth->setValue(m_kxkbConfig.m_stickySwitchingDepth);

    updateStickyLimit();

    widget->chkEnable->setChecked(m_kxkbConfig.m_useKxkb);
    widget->grpLayouts->setEnabled(m_kxkbConfig.m_useKxkb);
    widget->optionsFrame->setEnabled(m_kxkbConfig.m_useKxkb);

    // display xkb options
    QStringList options = QStringList::split(',', m_kxkbConfig.m_options);
    for(QStringList::ConstIterator it = options.begin(); it != options.end(); ++it)
    {
        QString option = *it;
        QString optionKey = option.mid(0, option.find(':'));
        QString optionName = m_rules->options()[option];
        OptionListItem *item = m_optionGroups[i18n(optionKey.latin1())];

        if(item != NULL)
        {
            OptionListItem *child = item->findChildItem(option);

            if(child)
                child->setState(QCheckListItem::On);
            else
                kdDebug() << "load: Unknown option: " << option << endl;
        }
        else
        {
            kdDebug() << "load: Unknown option group: " << optionKey << " of " << option << endl;
        }
    }

    updateOptionsCommand();
    emit KCModule::changed(false);
}