示例#1
0
AbstractItemDetail::AbstractItemDetail(const QModelIndex *index)
{
	Q_UNUSED(index)

	initDialog();
	retrieveItem();
	fillData();
}
示例#2
0
文件: BST.cpp 项目: elisemmc/EECS268
void BST::searchTreeRetrieve(KeyType searchKey,
                             TreeItemType& treeItem) const                                        
                             throw(TreeException)
{
   // if retrieveItem throws a TreeException, it is 
   // ignored here and passed on to the point in the code 
   // where searchTreeRetrieve was called
   retrieveItem(root, searchKey, treeItem);
}  // end searchTreeRetrieve
示例#3
0
int PropertyModel::rowCount(const QModelIndex & parentIndex) const
{
    if (parentIndex.column() > 0)
        return 0;
    
    PropertyItem * item = parentIndex.isValid() ? retrieveItem(parentIndex) : m_root;
    
    return item->childCount();
}
示例#4
0
QModelIndex PropertyModel::parent(const QModelIndex & index) const
{    
    PropertyItem * item = index.isValid() ? retrieveItem(index) : m_root;
    
    if (!item->hasParent())
        return QModelIndex();

    return createIndex(item->parent());
}
示例#5
0
QModelIndex PropertyModel::index(int row, int column, const QModelIndex & parentIndex) const
{
    if (!hasIndex(row, column, parentIndex))
        return QModelIndex();
    
    PropertyItem * item = parentIndex.isValid() ? retrieveItem(parentIndex) : m_root;

    return createIndex(item->at(row), column);
}
示例#6
0
文件: BST.cpp 项目: elisemmc/EECS268
void BST::retrieveItem(TreeNode *treePtr, 
                                    KeyType searchKey,
                                    TreeItemType& treeItem) const
                                    throw(TreeException)
{
   if (treePtr == NULL)
      throw TreeException("TreeException: searchKey not found"); 

   else if (searchKey == treePtr->item.getKey())
      // item is in the root of some subtree
      treeItem = treePtr->item;

   else if (searchKey < treePtr->item.getKey())
   // search the left subtree
      retrieveItem(treePtr->leftChildPtr, 
                   searchKey, treeItem);

   else  // search the right subtree
      retrieveItem(treePtr->rightChildPtr,
                          searchKey, treeItem);
}  // end retrieveItem
示例#7
0
Qt::ItemFlags PropertyModel::flags(const QModelIndex & index) const
{
    if (!index.isValid())
        return 0;
    
    PropertyItem * item = retrieveItem(index);

    Qt::ItemFlags flags = Qt::ItemIsSelectable;

    if (index.column() == 1 && item->property()->isValue() && !item->isReadOnly())
        flags |= Qt::ItemIsEditable;

    if (item->isEnabled())
        flags |= Qt::ItemIsEnabled;
    
    return flags;
}
示例#8
0
QVariant PropertyModel::data(const QModelIndex & index, int role) const
{
    if (!index.isValid())
        return QVariant();
    
    AbstractProperty * property = retrieveItem(index)->property();
    
    if (role == Qt::DisplayRole && index.column() == 0)
    {
        std::string title;
        if (property->hasOption("title"))
            title = property->option("title").value<std::string>();
        else
            title = property->name();
        
        return QVariant(QString::fromStdString(title));
    }

    if (role == Qt::ToolTipRole && property->hasOption("tooltip"))
        return QVariant(QString::fromStdString(property->option("tooltip").value<std::string>()));
    
    return QVariant();
}
示例#9
0
// @author Andre Allan Ponce
// @author Computergeek01
// url: http://www.cplusplus.com/forum/beginner/75529/
void Game::getKeyInput(WORD key, Location* currRoom){
	switch(key)
    {
	case VK_ESCAPE:{
		break;
	}
    case VK_LEFT:
	case VK_NUMPAD4:{
		activeText = "left!\n";
		movePlayer(MOVE_LEFT, currRoom);
		break;
	}
	case VK_UP:
	case VK_NUMPAD8:{
		activeText = "up!\n";
		movePlayer(MOVE_UP, currRoom);
		break;
	}
	case VK_RIGHT:
	case VK_NUMPAD6:{
		activeText =  "right!\n";
		movePlayer(MOVE_RIGHT, currRoom);
		break;
	}
	case VK_DOWN:
	case VK_NUMPAD2:{
		activeText =  "down!\n";
		movePlayer(MOVE_DOWN, currRoom);
		break;
	}
	case 0x41: // a key // this was steve
		{
			activeText = "ea \n";
			int i = 0;
			int id = detectItemID();
			if(id >= 0){
				Item* thisItem = retrieveItem(id);
				thisItem->setDescription(itemData.getItemDesc(id));
				thisItem->action();
				int check = 0;
				while(check == 0 && i<8)
				{
					activeText = "orb\n";
					int run = rand()%orbProb[i];
					cout << run;
					if( run == 1)
					{
						orbInventory[i] = true;
						updateOrbProbability();
						check++;
					}
				i++;
				}
			}
			break;
		}


			
	case 0x49: // this was steve as well
		{
			displayInventory();
			break;

		}
	default :{
		// we dont move.
		break;
	}
    } 
}
示例#10
0
int PropertyModel::columnCount(const QModelIndex & parentIndex) const
{
    PropertyItem * item = parentIndex.isValid() ? retrieveItem(parentIndex) : m_root;
    
    return item->hasChildren() ? 2 : 0;
}