Пример #1
0
void MediaRoutingView::cleanUp()
{
	D_METHOD(("MediaRoutingView::cleanUp()\n"));

	sortItems(DiagramItem::M_BOX, compareID);

	// move all the panels offscreen
	for (uint32 i = 0; i < countItems(DiagramItem::M_BOX); i++)
	{
		itemAt(i, DiagramItem::M_BOX)->moveTo(BPoint(-200.0, -200.0));
	}

	// move all panels to their 'ideal' position
	for (uint32 i = 0; i < countItems(DiagramItem::M_BOX); i++)
	{
		MediaNodePanel *panel;
		panel = dynamic_cast<MediaNodePanel *>(itemAt(i, DiagramItem::M_BOX));
		BPoint p = findFreePositionFor(panel);
		panel->moveTo(p);
	}

	sortItems(DiagramItem::M_BOX, compareSelectionTime);
	Invalidate();
	updateDataRect();
}
void AbstractSortingStrategy::check(AbstractGroupableItem *itemToCheck)
{
    AbstractGroupableItem *item;
    if (!itemToCheck) {
        item = dynamic_cast<AbstractGroupableItem *>(sender());
    } else {
        item = itemToCheck;
    }

    if (!item) {
        qWarning() << "invalid item" << itemToCheck;
        return;
    }
    //qDebug() << item->name();

    if (item->itemType() == TaskItemType) {
        if (!(qobject_cast<TaskItem*>(item))->task()) { //ignore startup tasks
            return;
        }
    }

    if (!item->parentGroup()) {
        //qDebug() << "No parent group";
        return;
    }

    ItemList sortedList = item->parentGroup()->members();
    sortItems(sortedList);

    int oldIndex = item->parentGroup()->members().indexOf(item);
    int newIndex = sortedList.indexOf(item);
    if (oldIndex != newIndex) {
        item->parentGroup()->moveItem(oldIndex, newIndex);
    }
}
Пример #3
0
FunctionListWidget::FunctionListWidget(QWidget *parent)
  : QListWidget(parent)
{

  QString skeleton;
  QString statusTip;

  QHashIterator<enum FunctionNames, QString> i(presetFunctions.fcnNames());
  while (i.hasNext()) {

    i.next();
    QListWidgetItem *functionItem = new QListWidgetItem(this);
    functionItem->setText(i.value());
    skeleton = presetFunctions.fcnSkeleton(i.key());
    statusTip = presetFunctions.fcnStatusTip(i.key());
    functionItem->setStatusTip(skeleton + statusTip);
    functionItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);

  }

  sortItems();
  setMouseTracking(true);

  // add connections
  connect(this, SIGNAL(itemActivated(QListWidgetItem*)),
          this, SLOT(itemSkeleton(QListWidgetItem*)));

}
void showChanges(){
	item items[total_items];
	int i,j;
	unsigned char tmp[20];
	for (i=0,j=0 ; i < total_items ; i++){
		if (list[i].stock != 10){
			items[j] = list[i];
			/*
			printf("name:%s\n",list[i].name);
			printf("stock:%d\n",list[i].stock);
			printf("stock difference:%d\n",10-list[i].stock);
			printMsg(list[i].name,20,8+j*2);
			sprintf(tmp, "%d", 10-list[i].stock);
			printMsg(tmp,30,8+j*2);*/
			j++;
		}
	}
	items[j].name[0] = '\0';

	sortItems(items);
	printMsg("Top 5 Sales of last week:",20,6);
	for (i=0;i < 5;i++){
		printf("name:%s\n",items[i].name);
		printf("stock:%d\n",items[i].stock);
		printf("stock difference:%d\n",10-items[i].stock);
		printMsg(items[i].name,20,8+j*2);
		sprintf(tmp, "%d", 10-items[i].stock);
		printMsg(tmp,30,8+j*2);
	}
}
Пример #5
0
void KACLListView::slotEditEntry()
{
    QTreeWidgetItem * current = currentItem();
    if ( !current ) return;
    KACLListViewItem *item = static_cast<KACLListViewItem*>( current );
    int allowedTypes = item->type | NamedUser | NamedGroup;
    bool itemWasMask = item->type == Mask;
    if ( !m_hasMask || itemWasMask )
        allowedTypes |= Mask;
    int allowedDefaultTypes = item->type | NamedUser | NamedGroup;
    if ( !findDefaultItemByType( Mask ) )
        allowedDefaultTypes |=  Mask;
    if ( !hasDefaultEntries() )
        allowedDefaultTypes |= User | Group;

    EditACLEntryDialog dlg( this, item,
                            allowedUsers( false, item ), allowedGroups( false, item ),
                            allowedUsers( true, item ), allowedGroups( true, item ),
                            allowedTypes, allowedDefaultTypes, m_allowDefaults );
    dlg.exec();
    if ( itemWasMask && item->type != Mask ) {
        m_hasMask = false;
        m_mask = 0;
    }
    if ( !itemWasMask && item->type == Mask ) {
        m_mask = item->value;
        m_hasMask = true;
    }
    calculateEffectiveRights();
    sortItems( sortColumn(), Qt::AscendingOrder );
}
BracketStackList::BracketStackList(Interface* iface, QWidget* parent)
                : QTreeWidget(parent), d(new BracketStackListPriv)
{
    d->iface = iface;

    setIconSize(QSize(64, 64));
    setSelectionMode(QAbstractItemView::SingleSelection);
    setSortingEnabled(true);
    setAllColumnsShowFocus(true);
    setRootIsDecorated(false);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    setColumnCount(3);
    setHeaderHidden(false);
    setDragEnabled(false);
    header()->setResizeMode(QHeaderView::Stretch);

    QStringList labels;
    labels.append( i18n("To process") );
    labels.append( i18n("File Name") );
    labels.append( i18n("Exposure (EV)") );
    setHeaderLabels(labels);

    if (d->iface)
    {
        connect(d->iface, SIGNAL(gotThumbnail(KUrl,QPixmap)),
                this, SLOT(slotThumbnail(KUrl,QPixmap)));
    }

    d->loadRawThumb = new KPRawThumbThread(this);

    connect(d->loadRawThumb, SIGNAL(signalRawThumb(KUrl,QImage)),
            this, SLOT(slotRawThumb(KUrl,QImage)));

    sortItems(2, Qt::DescendingOrder);
}
Пример #7
0
void DataTreeView::addNodeItem( serialization::Node* a_pNode )
{
    DataTreeViewItem* pNewItem = new DataTreeViewItem(m_pDataBase, a_pNode->getGuid());
    if(a_pNode->getParentNode())
    {
        serialization::Node* pNodeNode = a_pNode->getParentNode();
        DataTreeViewItem* pParentItem = getItem(pNodeNode);
        o_assert(pParentItem);
        pParentItem->addChild(pNewItem);
    }
    else
    {
        addTopLevelItem(pNewItem);
    }

    const string* values = getDataBase()->getNodeAttributeValues(a_pNode);

    bool editable = false;
    string name = values[m_uiNameAttributeIndex];

    pNewItem->setText(0, name.c_str());
    pNewItem->setIcon(0, a_pNode->isLoaded() ? a_pNode->getParentNode() ? m_NodeLoadedIcon : m_NodeRootIcon : QIcon(m_NodeUnloadedIcon.pixmap(16, QIcon::Disabled)));
    char buffer[64] = "";
    sprintf(buffer, "%08X", m_pDataBase->getGuid(a_pNode));
    pNewItem->setText(2, buffer);
    pNewItem->setText(3, nameOf(phantom::typeOf<serialization::Node>()).c_str());

    if(editable)
    {
        pNewItem->setFlags(Qt::ItemIsEditable | pNewItem->flags());
    }

    sortItems(0, Qt::AscendingOrder);
}
void KeepassGroupView::OnSort() {
	QHash<QTreeWidgetItem*,int> oldIndex;
	for (int i=0; i<Items.size(); i++) {
		if (Items[i]->parent())
			oldIndex.insert(Items[i], Items[i]->parent()->indexOfChild(Items[i]));
		else
			oldIndex.insert(Items[i], invisibleRootItem()->indexOfChild(Items[i]));
	}
	
	sortItems(0, Qt::AscendingOrder);
	
	bool modified = false;
	QMutableHashIterator<QTreeWidgetItem*, int> i(oldIndex);
	while (i.hasNext()) {
		i.next();
		int newIndex;
		IGroupHandle* parent;
		if (i.key()->parent()) {
			newIndex = i.key()->parent()->indexOfChild(i.key());
			parent = static_cast<GroupViewItem*>(i.key()->parent())->GroupHandle;
		}
		else {
			newIndex = invisibleRootItem()->indexOfChild(i.key());
			parent = NULL;
		}
		
		if (newIndex != i.value()) {
			db->moveGroup(static_cast<GroupViewItem*>(i.key())->GroupHandle, parent, newIndex);
			modified = true;
		}
	}
	
	if (modified)
		emit fileModified();
}
Пример #9
0
/**
  * User clicked the header
  * Sorting is disable when starting a new search to avoid annoying automatic moving in the list when adding new items
  * So enable it when the user really wants to sort results
  */
void SearchListView::headerClicked(int i)
{
    if (!isSortingEnabled()) {
        setSortingEnabled(true);
        sortItems(i, Qt::AscendingOrder);
    }
}
Пример #10
0
void KACLListView::slotAddEntry()
{
    int allowedTypes = NamedUser | NamedGroup;
    if ( !m_hasMask )
        allowedTypes |= Mask;
    int allowedDefaultTypes = NamedUser | NamedGroup;
    if ( !findDefaultItemByType( Mask ) )
        allowedDefaultTypes |=  Mask;
    if ( !hasDefaultEntries() )
        allowedDefaultTypes |= User | Group;
    EditACLEntryDialog dlg( this, 0,
                            allowedUsers( false ), allowedGroups( false ),
                            allowedUsers( true ), allowedGroups( true ),
                            allowedTypes, allowedDefaultTypes, m_allowDefaults );
    dlg.exec();
    KACLListViewItem *item = dlg.item();
    if ( !item ) return; // canceled
    if ( item->type == Mask && !item->isDefault ) {
        m_hasMask = true;
        m_mask = item->value;
    }
    if ( item->isDefault && !hasDefaultEntries() ) {
        // first default entry, fill in what is needed
        if ( item->type != User ) {
            unsigned short v = findDefaultItemByType( User )->value;
            new KACLListViewItem( this, User, v, true );
        }
        if ( item->type != Group ) {
            unsigned short v = findDefaultItemByType( Group )->value;
            new KACLListViewItem( this, Group, v, true );
        }
        if ( item->type != Others ) {
            unsigned short v = findDefaultItemByType( Others )->value;
            new KACLListViewItem( this, Others, v, true );
        }
    }
    const KACLListViewItem *defaultMaskItem = findDefaultItemByType( Mask );
    if ( item->isDefault && !defaultMaskItem ) {
        unsigned short v = calculateMaskValue( true );
        new KACLListViewItem( this, Mask, v, true );
    }
    if ( !item->isDefault && !m_hasMask &&
            ( item->type == Group
              || item->type == NamedUser
              || item->type == NamedGroup ) ) {
        // auto-add a mask entry
        unsigned short v = calculateMaskValue( false );
        new KACLListViewItem( this, Mask, v, false );
        m_hasMask = true;
        m_mask = v;
    }
    calculateEffectiveRights();
    sortItems( sortColumn(), Qt::AscendingOrder );
    setCurrentItem( item );
    // QTreeWidget doesn't seem to emit, in this case, and we need to update
    // the buttons...
    if ( topLevelItemCount() == 1 )
        emit currentItemChanged( item, item );
}
Пример #11
0
void GPathList::AddPath(const QString& path)
{
    if (findItems(path, Qt::MatchFixedString).size())
        return;

    addItem(path);
    sortItems(Qt::AscendingOrder);
}
Пример #12
0
void PlayerListWidget::addPlayer(ServerInfo_PlayerProperties *player)
{
	QTreeWidgetItem *newPlayer = new PlayerListTWI;
	players.insert(player->getPlayerId(), newPlayer);
	updatePlayerProperties(player);
	addTopLevelItem(newPlayer);
	sortItems(1, Qt::AscendingOrder);
}
Пример #13
0
void DataTreeView::dataAdded( const phantom::data& a_Data, serialization::Node* a_pNode)
{
    DataTreeViewItem* pParentItem = getItem(a_pNode);
    o_assert(pParentItem);
    string name = nameOf(a_Data.type()).c_str();
    addDataItem(a_Data);
    sortItems(0, Qt::AscendingOrder);
}
Пример #14
0
void VDirectoryTree::sortItems()
{
    if (!m_notebook) {
        return;
    }

    QTreeWidgetItem *item = currentItem();
    if (item && item->parent()) {
        sortItems(getVDirectory(item->parent()));
    } else {
        sortItems(m_notebook->getRootDir());
    }

    if (item) {
        setCurrentItem(item);
    }
}
Пример #15
0
int main(int argc, char const *argv[]){
	char *type = (char*)argv[1];
	int limit = atoi(argv[2]);
	TypeConverter integerType = {"%d",limit,4,compareIntegers,retriveIntegerItem};
	TypeConverter floatType = {"%f",limit,4,compareFloats,retriveFloatItem};
	TypeConverter doubleType = {"%lf",limit,8,compareDoubles,retriveDoubleItem};
	TypeConverter stringType = {"%s",limit,30,compareString,retriveStringItem,1};
	if(strcmp(type, "int")==0)
		sortItems(integerType);
	if(strcmp(type, "float")==0)
		sortItems(floatType);
	if(strcmp(type, "double")==0)
		sortItems(doubleType);
	if(strcmp(type, "string")==0)
		sortItems(stringType);
	return 0;
}
ChannelTreeWidget::ChannelTreeWidget(QWidget *parent) :
    QTreeWidget(parent)
{
    iconchannel = new QIcon(":/icons/small/channel.png");
    iconuser = new QIcon(":/icons/small/user.png");
    connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(channelItemDoubleClicked(QTreeWidgetItem*,int)));
    sortItems(0, Qt::AscendingOrder);
}
Пример #17
0
void AclWidget::insertAddress(const QString &address)
{
  if (!containsAddress(address))
  {
    addItem(address);
    sortItems();
  }
}
void FOX16_GuiSortingList::sortByColumn(int c, bool up) {
  switch(c) {
  case 0:
    if (up) setSortFunc(sortFuncCol0a);
    else setSortFunc(sortFuncCol0d);
    break;
  case 1:
    if (up) setSortFunc(sortFuncCol1a);
    else setSortFunc(sortFuncCol1d);
    break;

  case 2:
    if (up) setSortFunc(sortFuncCol2a);
    else setSortFunc(sortFuncCol2d);
    break;

  case 3:
    if (up) setSortFunc(sortFuncCol3a);
    else setSortFunc(sortFuncCol3d);
    break;

  case 4:
    if (up) setSortFunc(sortFuncCol4a);
    else setSortFunc(sortFuncCol4d);
    break;

  case 5:
    if (up) setSortFunc(sortFuncCol5a);
    else setSortFunc(sortFuncCol5d);
    break;

  case 6:
    if (up) setSortFunc(sortFuncCol6a);
    else setSortFunc(sortFuncCol6d);
    break;

  case 7:
    if (up) setSortFunc(sortFuncCol7a);
    else setSortFunc(sortFuncCol7d);
    break;

  case 8:
    if (up) setSortFunc(sortFuncCol8a);
    else setSortFunc(sortFuncCol8d);
    break;

  case 9:
    if (up) setSortFunc(sortFuncCol9a);
    else setSortFunc(sortFuncCol9d);
    break;

  default:
    DBG_ERROR(GWEN_LOGDOMAIN, "Column %d is out of range (no more functions)", c);
    return;
  }

  sortItems();
}
Пример #19
0
void MessageListView::addMessages(const CWizMessageDataArray& arrayMessage)
{
    CWizMessageDataArray::const_iterator it;
    for (it = arrayMessage.begin(); it != arrayMessage.end(); it++) {
        addMessage(*it, false);
    }

    sortItems();
}
void CWizDocumentListView::addDocuments(const CWizDocumentDataArray& arrayDocument)
{
    CWizDocumentDataArray::const_iterator it;
    for (it = arrayDocument.begin(); it != arrayDocument.end(); it++) {
        addDocument(*it, false);
    }

    sortItems();
}
Пример #21
0
void DataTreeView::removeNodeItem( serialization::Node* a_pNode )
{
    DataTreeViewItem* pItem = getItem(a_pNode);
    o_assert(pItem); // we should not be able to remove the root node
    o_assert(a_pNode->getParentNode()); // we should not be able to remove the root node
    DataTreeViewItem* pParentItem = getItem(a_pNode->getParentNode());
    o_assert(pItem AND pParentItem);
    pParentItem->removeChild(pItem);
    sortItems(0, Qt::AscendingOrder);
}
Пример #22
0
/**
 * inserts a photo into Tree Widget
 * cannot be templated because photos behave a little different from galleries
 * \param photo photo we are inserting, needed to create widget data
 * \param parent parent widget to which we are adding, default NULL
 */
MTreeWidgetItem* MTreeWidget::insert(mcore::MPhoto* photo, MTreeWidgetItem* parent)
{
    MTreeWidgetItem* item = new MTreeWidgetItem(this, photo);

    parent->addChild(item); // photos must always have a parent gallery

    sortItems(0, Qt::AscendingOrder); // sort in alphabetical order

    return item;
}
Пример #23
0
/**
 * inserts a gallery into Tree Widget
 * \param gallery gallery we are inserting, needed to create widget data
 * \param parent parent widget to which we are adding, default NULL
 */
MTreeWidgetItem* MTreeWidget::insert(mcore::MGallery* gallery, MTreeWidgetItem* parent)
{
    // creates a new widget item based on gallery data
    MTreeWidgetItem* item = new MTreeWidgetItem(this, gallery);
    parent ? parent->addChild(item) : insertTopLevelItem(0, item);

    sortItems(0, Qt::AscendingOrder); // sort in alphabetical order

    return item;
}
Пример #24
0
int CWizDocumentListView::addDocument(const WIZDOCUMENTDATA& data, bool sort)
{
    CWizDocumentListViewItem* pItem = new CWizDocumentListViewItem(data, this);

    addItem(pItem);
    if (sort) {
        sortItems();
    }

    return count();
}
Пример #25
0
FunctionsTreeWidget::FunctionsTreeWidget(Doc *doc, QWidget *parent) :
    QTreeWidget(parent)
  , m_doc(doc)
{
    sortItems(COL_NAME, Qt::AscendingOrder);

    QTreeWidgetItem *root = invisibleRootItem();
    root->setFlags(root->flags() & ~Qt::ItemIsDropEnabled);

    connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
                this, SLOT(slotItemChanged(QTreeWidgetItem*)));
}
Пример #26
0
void CWizDocumentListView::addDocuments(const CWizDocumentDataArray& arrayDocument)
{
    CWizDocumentDataArray::const_iterator it;
    for (it = arrayDocument.begin(); it != arrayDocument.end(); it++) {
        addDocument(*it, false);
    }

    sortItems();

    //if (selectedItems().empty()) {
    //    setCurrentRow(0);
    //}
}
Пример #27
0
void NotesWidget::setNoteSortType(qint8 type)
{
    sortType = type;

    for (int i = 0; i < count(); i++) {
        ListItem* item = reinterpret_cast<ListItem*>(this->item(i));
        item->setSortType(sortType);
    }

    sortItems();

    sql::updateSyncStatus("noteSortType", sortType);
}
Пример #28
0
bool pc_record_type::giveToPC(item_record_type item, bool print_result)
{
	short free_space;
	char announce_string[60];

	if (item.variety == ITEM_TYPE_NO_ITEM)
		return true;

	if (item.variety == ITEM_TYPE_GOLD) {
		party.gold += item.item_level;
		ASB("You get some gold.");
		return true;
		}
	if (item.variety == ITEM_TYPE_FOOD) {
		party.food += item.item_level;
		ASB("You get some food.");
		return true;
		}
	if (item_weight(item) >  amountCanCarry() - amountCarried()) {
	  	if (print_result == true) {
		  	MessageBeep(MB_OK);
			ASB("Item too heavy to carry.");
			}
		return false;
	  	}
	if (((free_space = hasSpace()) == 24) || (!isAlive()))
		return false;
	else {
			item.item_properties = item.item_properties & 253; // not property
			item.item_properties = item.item_properties & 247; // not contained
			items[free_space] = item;


			if (print_result == 1) {
				if (stat_window == getNum())
					put_item_screen(stat_window,0);
			}
			if (in_startup_mode == false) {
				if (item.isIdent() == false)
					sprintf((char *) announce_string,"  %s gets %s.",name,item.name);
					else sprintf((char *) announce_string,"  %s gets %s.",name,item.full_name);
				if (print_result)
					add_string_to_buf((char *)announce_string);
				}

			combineThings();
			sortItems();
			return true;
			}
	return false;
}
Пример #29
0
void EntityTreeWidget::update()
{
    this->clear();
    QMultiMap<QString, QString> entityCatalogue;
    _entityModelHash = ModelsManager::getOrCreate()->getEntityModelHash();
    QStringList availableEntities = ModelsManager::getOrCreate()->getAvailableEntities().keys();

    foreach (NtgEntityModel entityModel, _entityModelHash)
    {

        if (entityModel.browsable && availableEntities.contains(entityModel.name))
        {
          entityCatalogue.insert(entityModel.category,entityModel.name);
        }
    }

    QTreeWidgetItem * categoryItem = NULL;
    EntityTreeWidgetItem * entityItem = NULL;
    QList<QTreeWidgetItem *> treeWidgetList;
    QMultiMap<QString, QString>::iterator i = entityCatalogue.begin();
    while (i != entityCatalogue.end())
    {
    QString categoryName = i.key();
    QString entityName = i.value();
    treeWidgetList = findItems(categoryName,Qt::MatchExactly,0);
    if (treeWidgetList.size() == 0)
    {
      categoryItem = new QTreeWidgetItem(this);
      categoryItem->setText(0,categoryName);
    }
    else
    {
      categoryItem = treeWidgetList.at(0);
    }
    entityItem = new EntityTreeWidgetItem(categoryItem);


    QString uuidName = entityName.toLower().simplified().replace(" ","");
    entityItem->setText(0, _entityModelHash.value(entityName).longName);
    entityItem->setText(1, entityName);
    QPixmap pixmap;
    pixmap.loadFromData(_entityModelHash.value(entityName).imagePNG,"PNG");
    entityItem->setIcon(0, QIcon(pixmap));

    ++i;
    }
    sortItems (0, Qt::AscendingOrder);
    expandAll();
}
Пример #30
0
void CWizDocumentListView::addAndSelectDocument(const WIZDOCUMENTDATA& document)
{
    Q_ASSERT(acceptDocument(document));

    int index = documentIndexFromGUID(document.strGUID);
    if (-1 == index) {
        index = addDocument(document, false);
    }

    if (-1 == index)
        return;

    setCurrentItem(item(index), QItemSelectionModel::ClearAndSelect);
    sortItems();
}