Exemple #1
0
void NValue::castAndSortAndDedupArrayForInList(const ValueType outputType, std::vector<NValue> &outList) const
{
    int size = arrayLength();

    // make a set to eliminate unique values in O(nlogn) time
    std::set<StlFriendlyNValue> uniques;

    // iterate over the array of values and build a sorted set of unique
    // values that don't overflow or violate unique constaints
    // (n.b. sorted set means dups are removed)
    for (int i = 0; i < size; i++) {
        NValue value = itemAtIndex(i);
        // cast the value to the right type and catch overflow/cast problems
        try {
            StlFriendlyNValue stlValue;
            stlValue = value.castAs(outputType);
            std::pair<std::set<StlFriendlyNValue>::iterator, bool> ret;
            ret = uniques.insert(stlValue);
        }
        // cast exceptions mean the in-list test is redundant
        // don't include these values in the materialized table
        // TODO: make this less hacky
        catch (SQLException &sqlException) {}
    }

    // insert all items in the set in order
    std::set<StlFriendlyNValue>::const_iterator iter;
    for (iter = uniques.begin(); iter != uniques.end(); iter++) {
        outList.push_back(*iter);
    }
}
Exemple #2
0
QString BasketModel::login(QModelIndex idx) const
{
    BasketBaseItem *item = itemAtIndex(idx);
    if ( !item )
        return QString();

    QString login = item->login();

    return login;
}
Exemple #3
0
void
GridView::setCurrentItem(unsigned int index)
{
    ILOG_TRACE_W(ILX_GRIDVIEW);
    if (_currentIndex != index && index < _items.size())
    {
        _currentIndex = index;
        _currentItem = itemAtIndex(_currentIndex);
        _scrollArea->scrollTo(_currentItem);
    }
}
Exemple #4
0
bool
GridView::removeItem(unsigned int index)
{
    ILOG_TRACE_W(ILX_GRIDVIEW);
    Widget* widget = itemAtIndex(index);
    if (widget)
    {
        _layout->removeWidget(widget);
        return true;
    }
    return false;
}
Exemple #5
0
void
QueueList::moveSelectedUp() // SLOT
{
    QPtrList<QListViewItem> selected = selectedItems();

    // Whilst it would be substantially faster to do this: ((*it)->itemAbove())->move( *it ),
    // this would only work for sequentially ordered items
    for( QListViewItem *item = selected.first(); item; item = selected.next() )
    {
        if( item == itemAtIndex(0) )
            continue;

        QListViewItem *after;

        item == itemAtIndex(1) ?
        after = 0:
                after = ( item->itemAbove() )->itemAbove();

        moveItem( item, 0, after );
    }

    ensureItemVisible( selected.first() );
}
Exemple #6
0
QString BasketModel::cleanPassword(QModelIndex idx) const
{
    if ( !idx.isValid() )
        return QString();

    BasketBaseItem *item = itemAtIndex(idx);
    if ( !item )
        return QString();

    QString encPwd = item->password();
    BasketUtils butil;
    QString cleanPwd = butil.decrypt(encPwd, hash());

    return cleanPwd;
}
Exemple #7
0
// move an item one position down
void UserMenuTree::itemDown()
{
	QTreeWidgetItem *current = currentItem();
	bool expanded = current->isExpanded();
	blockSignals(true);

	// get all necessary parameter
	UserMenuItem *parent = dynamic_cast<UserMenuItem *>(current->parent());
	int index = itemIndex(parent,current);
	int children = numChildren(parent);

	// successor exists?
	if ( index < children-1 ) {
		UserMenuItem *successor = dynamic_cast<UserMenuItem *>( itemAtIndex(parent,index+1) );
		takeItem(parent,current);
		if ( successor->menutype() == UserMenuData::Submenu ) {
			successor->insertChild(0,current);
		}
		else {
			insertItem(parent,index+1,current);
		}
	}
	else if ( parent ) {
			QTreeWidgetItem *grandparent = parent->parent();
			int parentindex = itemIndex(grandparent,parent);
			takeItem(parent,current);
			insertItem(grandparent,parentindex+1,current);
	}

	// update model data of old and new parent, if it has changed
	UserMenuItem *newparent = dynamic_cast<UserMenuItem *>(current->parent());
	if ( parent != newparent ) {
		if ( parent ) {
			parent->setModelData();
			parent->setText(0, parent->updateMenutitle());
		}
		if ( newparent ) {
			newparent->setModelData();
			newparent->setText(0, newparent->updateMenutitle());
		}
	}

	current->setExpanded(expanded);
	setCurrentItem(current);
	blockSignals(false);
}
Exemple #8
0
void KSim::MonitorPrefs::readConfig(KSim::Config *config)
{
  int location;
  TQCheckListItem *origItem;
  TQStringList::ConstIterator it;
  for (it = m_locatedFiles.begin(); it != m_locatedFiles.end(); ++it) {
    KSim::PluginInfo info = KSim::PluginLoader::self().findPluginInfo((*it));
    location = config->monitorLocation(info.libName());
    origItem = static_cast<TQCheckListItem *>(findItem(info.name(), 0));
    origItem->setOn(config->enabledMonitor(info.libName()));
    origItem->setText(2, config->monitorCommand(info.libName()));
    if (TQListViewItem *item = itemAtIndex(location)) {
      if (location) {
        origItem->moveItem(item->itemAbove());
      }
      else {
        origItem->moveItem(firstChild());
        firstChild()->moveItem(origItem);
      }
    }
  }
}