Beispiel #1
0
//! Returns caption of this element.
const wchar_t* CGUIComboBox::getText() const
{
	return getItem(Selected);
}
Beispiel #2
0
bool TreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
  bool success = false;

  if(action != Qt::CopyAction) return success;

 TreeItem * parentItem = getItem(parent);
 OS_ASSERT(parentItem);

 if(data->hasText()){
    if(!data->hasFormat("ListWidget data")) return success;
    QString string = data->text();
    QStringList strings = string.split(",");
    openstudio::IddFile iddFile = mTreeViewWidget->getIddFile();
    boost::optional<openstudio::IddObject> optionalIddObject;

    openstudio::OptionalWorkspaceObject optionalWorkspaceObject;
    openstudio::model::OptionalModelObject optionalModelObject;
    openstudio::model::OptionalParentObject optionalParentObject;
    for(int i=0; i<strings.size(); i++)
    {
      optionalIddObject = iddFile.getObject(strings.at(i).toStdString());
      if(optionalIddObject)
      {
        openstudio::IdfObject idfObject(optionalIddObject->type());
        optionalWorkspaceObject = mTreeViewWidget->getModel().addObject(idfObject);
        if(optionalWorkspaceObject)
        {
          optionalModelObject = parentItem->modelObject().model().getModelObject<ModelObject>(optionalWorkspaceObject->handle());
          if(optionalModelObject)
          {
            ///! OpenStudio model update...
            ModelObject temp(parentItem->modelObject());
            if(OptionalParentObject tempParent = temp.optionalCast<ParentObject>())
            {
              success = optionalModelObject->setParent(*tempParent);
            }
            if(success)
            {
              success = mTreeViewWidget->getModel().order().insert(optionalWorkspaceObject->handle(), this->modelAtIndex(parent)->handle());
            }
          }
        }
      }
    }
  }
  else{
    OS_ASSERT(mTreeViewWidget && mTreeViewWidget->getTreeView());
    QModelIndexList rowList;
    if(!mTreeViewWidget->getTreeView()->getSelectedRows(rowList)){
      return success;
    }

    //FIX THIS why is position unused? LER
    //int position = rowList.at(0).row();
    int rows = rowList.size();
    //QModelIndex sourceParent = rowList.at(0).parent();

    TreeItem * parentItem = getItem(parent);

    ///! OpenStudio model update...
    for(int i=0; i<rows; i++){
      ModelObject temp(parentItem->modelObject());
      if(OptionalParentObject tempParent = temp.optionalCast<ParentObject>())
      {
        success = this->modelAtIndex(rowList.at(i))->setParent(*tempParent);
      }
    }
  }

  mTreeViewWidget->loadModel();
  mTreeViewWidget->emitModelDirty();

  return success; // not updating Qt model
}
bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem)
{
	if(!gAssetStorage)
	{
		llwarns << "Not connected to an asset storage system." << llendl;
		return false;
	}

	
	LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor");

	if (editor && !editor->isPristine())
	{
		// We need to update the asset information
		LLTransactionID tid;
		LLAssetID asset_id;
		tid.generate();
		asset_id = tid.makeAssetID(gAgent.getSecureSessionID());

		LLVFile file(gVFS, asset_id, LLAssetType::AT_NOTECARD, LLVFile::APPEND);

		std::string buffer;
		if (!editor->exportBuffer(buffer))
		{
			return false;
		}

		editor->makePristine();

		S32 size = buffer.length() + 1;
		file.setMaxSize(size);
		file.write((U8*)buffer.c_str(), size);

		const LLInventoryItem* item = getItem();
		// save it out to database
		if (item)
		{			
			std::string agent_url = gAgent.getRegion()->getCapability("UpdateNotecardAgentInventory");
			std::string task_url = gAgent.getRegion()->getCapability("UpdateNotecardTaskInventory");
			if (mObjectUUID.isNull() && !agent_url.empty())
			{
				// Saving into agent inventory
				mAssetStatus = PREVIEW_ASSET_LOADING;
				setEnabled(FALSE);
				LLSD body;
				body["item_id"] = mItemUUID;
				llinfos << "Saving notecard " << mItemUUID
					<< " into agent inventory via " << agent_url << llendl;
				LLHTTPClient::post(agent_url, body,
					new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
			}
			else if (!mObjectUUID.isNull() && !task_url.empty())
			{
				// Saving into task inventory
				mAssetStatus = PREVIEW_ASSET_LOADING;
				setEnabled(FALSE);
				LLSD body;
				body["task_id"] = mObjectUUID;
				body["item_id"] = mItemUUID;
				llinfos << "Saving notecard " << mItemUUID << " into task "
					<< mObjectUUID << " via " << task_url << llendl;
				LLHTTPClient::post(task_url, body,
					new LLUpdateTaskInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
			}
			else if (gAssetStorage)
			{
				LLSaveNotecardInfo* info = new LLSaveNotecardInfo(this, mItemUUID, mObjectUUID,
																tid, copyitem);
				gAssetStorage->storeAssetData(tid, LLAssetType::AT_NOTECARD,
												&onSaveComplete,
												(void*)info,
												FALSE);
			}
		}
	}
	return true;
}
Beispiel #4
0
input_item_t * VLCModel::getInputItem( const QModelIndex &index ) const
{
    AbstractPLItem *item = getItem( index );
    if ( !item ) return NULL;
    return item->inputItem();
}
Beispiel #5
0
bool VLCModel::isCurrent( const QModelIndex &index ) const
{
    AbstractPLItem *item = getItem( index );
    if ( !item ) return false;
    return item->inputItem() == THEMIM->currentInputItem();
}
Beispiel #6
0
void GameMapGump::PaintThis(RenderSurface *surf, sint32 lerp_factor, bool scaled)
{
	World *world = World::get_instance();
	if (!world) return;	// Is it possible the world doesn't exist?

	CurrentMap *map = world->getCurrentMap();
	if (!map) return;	// Is it possible the map doesn't exist?


	// Get the camera location
	int lx, ly, lz;
	GetCameraLocation(lx, ly, lz, lerp_factor);

	CameraProcess *camera = CameraProcess::GetCameraProcess();

	uint16 roofid = 0;
	int zlimit = 1 << 16; // should be high enough

	if (!camera)
	{
		// Check roof
		//!! This is _not_ the right place for this...
		sint32 ax, ay, az, axd, ayd, azd;
		Actor* av = getMainActor();
		av->getLocation(ax, ay, az);
		av->getFootpadWorld(axd, ayd, azd);
		map->isValidPosition(ax, ay, az, 32, 32, 8, 0, 1, 0, &roofid);
	}
	else
		roofid = camera->FindRoof(lerp_factor);

	Item* roof = getItem(roofid);
	if (roof) {
		zlimit = roof->getZ();
	}

	display_list->BeginDisplayList(surf, lx, ly, lz);

	uint32 gametick = Kernel::get_instance()->getFrameNum();

	bool paintEditorItems = GUIApp::get_instance()->isPaintEditorItems();

	// Get all the required items
	for (int cy = 0; cy < MAP_NUM_CHUNKS; cy++)
	{
		for (int cx = 0; cx < MAP_NUM_CHUNKS; cx++)
		{
			// Not fast, ignore
			if (!map->isChunkFast(cx,cy)) continue;

			const std::list<Item*>* items = map->getItemList(cx,cy);

			if (!items) continue;

			std::list<Item*>::const_iterator it = items->begin();
			std::list<Item*>::const_iterator end = items->end();
			for (; it != end; ++it)
			{
				Item *item = *it;
				if (!item) continue;

				item->setupLerp(gametick);
				item->doLerp(lerp_factor);

				if (item->getZ() >= zlimit && !item->getShapeInfo()->is_draw())
					continue;
				if (!paintEditorItems && item->getShapeInfo()->is_editor())
					continue;
				if (item->getFlags() & Item::FLG_INVISIBLE) {
					// special case: invisible avatar _is_ drawn
					// HACK: unless EXT_TRANSPARENT is also set.
					// (Used for hiding the avatar when drawing a full area map)

					if (item->getObjId() == 1) {
						if (item->getExtFlags() & Item::EXT_TRANSPARENT)
							continue;

						sint32 x, y, z;
						item->getLerped(x, y, z);
						display_list->AddItem(x,y,z,item->getShape(),item->getFrame(), item->getFlags() & ~Item::FLG_INVISIBLE, item->getExtFlags() | Item::EXT_TRANSPARENT, 1);
					}

					continue;
				}
				display_list->AddItem(item);
			}
		}
	}

	// Dragging:

	if (display_dragging) {
		display_list->AddItem(dragging_pos[0],dragging_pos[1],dragging_pos[2],
							  dragging_shape, dragging_frame,
							  dragging_flags, Item::EXT_TRANSPARENT);
	}


	display_list->PaintDisplayList(highlightItems);
}
// Sub-classes should override this function if they allow editing
void LLPreview::onCommit()
{
	const LLViewerInventoryItem *item = dynamic_cast<const LLViewerInventoryItem*>(getItem());
	if(item)
	{
		if (!item->isFinished())
		{
			// We are attempting to save an item that was never loaded
			LL_WARNS() << "LLPreview::onCommit() called with mIsComplete == FALSE"
					<< " Type: " << item->getType()
					<< " ID: " << item->getUUID()
					<< LL_ENDL;
			return;
		}
		
		LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
		new_item->setDescription(getChild<LLUICtrl>("desc")->getValue().asString());

		std::string new_name = getChild<LLUICtrl>("name")->getValue().asString();
		if ( (new_item->getName() != new_name) && !new_name.empty())
		{
			new_item->rename(getChild<LLUICtrl>("name")->getValue().asString());
		}

		if(mObjectUUID.notNull())
		{
			// must be in an object
			LLViewerObject* object = gObjectList.findObject(mObjectUUID);
			if(object)
			{
				object->updateInventory(
					new_item,
					TASK_INVENTORY_ITEM_KEY,
					false);
			}
		}
		else if(item->getPermissions().getOwner() == gAgent.getID())
		{
			new_item->updateServer(FALSE);
			gInventory.updateItem(new_item);
			gInventory.notifyObservers();

			// If the item is an attachment that is currently being worn,
			// update the object itself.
			if( item->getType() == LLAssetType::AT_OBJECT )
			{
				if (isAgentAvatarValid())
				{
					LLViewerObject* obj = gAgentAvatarp->getWornAttachment( item->getUUID() );
					if( obj )
					{
						LLSelectMgr::getInstance()->deselectAll();
						LLSelectMgr::getInstance()->addAsIndividual( obj, SELECT_ALL_TES, FALSE );
						LLSelectMgr::getInstance()->selectionSetObjectDescription( getChild<LLUICtrl>("desc")->getValue().asString() );

						LLSelectMgr::getInstance()->deselectAll();
					}
				}
			}
		}
	}
}
Beispiel #8
0
void LiveEventControl::setPanelLoopRange(int index, double start, double end)
{
	QTableWidgetItem * item = getItem(index, 6);
	item->setText(QString::number(start + 1) + "-" + QString::number(end + 1));
}
Beispiel #9
0
void LiveEventControl::setPanelLoopLength(int index, double length)
{
	QTableWidgetItem * item = getItem(index, 5);
	item->setText(QString::number(length));
}
void LLPreviewGesture::refresh()
{
	// If previewing or item is incomplete, all controls are disabled
	LLViewerInventoryItem* item = (LLViewerInventoryItem*)getItem();
	bool is_complete = (item && item->isFinished()) ? true : false;
	if (mPreviewGesture || !is_complete)
	{
		
		childSetEnabled("desc", FALSE);
		//mDescEditor->setEnabled(FALSE);
		mTriggerEditor->setEnabled(FALSE);
		mReplaceText->setEnabled(FALSE);
		mReplaceEditor->setEnabled(FALSE);
		mModifierCombo->setEnabled(FALSE);
		mKeyCombo->setEnabled(FALSE);
		mLibraryList->setEnabled(FALSE);
		mAddBtn->setEnabled(FALSE);
		mUpBtn->setEnabled(FALSE);
		mDownBtn->setEnabled(FALSE);
		mDeleteBtn->setEnabled(FALSE);
		mStepList->setEnabled(FALSE);
		mOptionsText->setEnabled(FALSE);
		mAnimationCombo->setEnabled(FALSE);
		mAnimationRadio->setEnabled(FALSE);
		mSoundCombo->setEnabled(FALSE);
		mChatEditor->setEnabled(FALSE);
		mWaitAnimCheck->setEnabled(FALSE);
		mWaitTimeCheck->setEnabled(FALSE);
		mWaitTimeEditor->setEnabled(FALSE);
		mActiveCheck->setEnabled(FALSE);
		mSaveBtn->setEnabled(FALSE);

		// Make sure preview button is enabled, so we can stop it
		mPreviewBtn->setEnabled(TRUE);
		return;
	}

	BOOL modifiable = item->getPermissions().allowModifyBy(gAgent.getID());

	childSetEnabled("desc", modifiable);
	mTriggerEditor->setEnabled(TRUE);
	mLibraryList->setEnabled(modifiable);
	mStepList->setEnabled(modifiable);
	mOptionsText->setEnabled(modifiable);
	mAnimationCombo->setEnabled(modifiable);
	mAnimationRadio->setEnabled(modifiable);
	mSoundCombo->setEnabled(modifiable);
	mChatEditor->setEnabled(modifiable);
	mWaitAnimCheck->setEnabled(modifiable);
	mWaitTimeCheck->setEnabled(modifiable);
	mWaitTimeEditor->setEnabled(modifiable);
	mActiveCheck->setEnabled(TRUE);

	const std::string& trigger = mTriggerEditor->getText();
	BOOL have_trigger = !trigger.empty();

	const std::string& replace = mReplaceEditor->getText();
	BOOL have_replace = !replace.empty();

	LLScrollListItem* library_item = mLibraryList->getFirstSelected();
	BOOL have_library = (library_item != NULL);

	LLScrollListItem* step_item = mStepList->getFirstSelected();
	S32 step_index = mStepList->getFirstSelectedIndex();
	S32 step_count = mStepList->getItemCount();
	BOOL have_step = (step_item != NULL);

	mReplaceText->setEnabled(have_trigger || have_replace);
	mReplaceEditor->setEnabled(have_trigger || have_replace);

	mModifierCombo->setEnabled(TRUE);
	mKeyCombo->setEnabled(TRUE);

	mAddBtn->setEnabled(modifiable && have_library);
	mUpBtn->setEnabled(modifiable && have_step && step_index > 0);
	mDownBtn->setEnabled(modifiable && have_step && step_index < step_count-1);
	mDeleteBtn->setEnabled(modifiable && have_step);

	// Assume all not visible
	mAnimationCombo->setVisible(FALSE);
	mAnimationRadio->setVisible(FALSE);
	mSoundCombo->setVisible(FALSE);
	mChatEditor->setVisible(FALSE);
	mWaitAnimCheck->setVisible(FALSE);
	mWaitTimeCheck->setVisible(FALSE);
	mWaitTimeEditor->setVisible(FALSE);

	std::string optionstext;
	
	if (have_step)
	{
		// figure out the type, show proper options, update text
		LLGestureStep* step = (LLGestureStep*)step_item->getUserdata();
		EStepType type = step->getType();

		switch(type)
		{
		case STEP_ANIMATION:
			{
				LLGestureStepAnimation* anim_step = (LLGestureStepAnimation*)step;
				optionstext = getString("step_anim");
				mAnimationCombo->setVisible(TRUE);
				mAnimationRadio->setVisible(TRUE);
				mAnimationRadio->setSelectedIndex((anim_step->mFlags & ANIM_FLAG_STOP) ? 1 : 0);
				mAnimationCombo->setCurrentByID(anim_step->mAnimAssetID);
				break;
			}
		case STEP_SOUND:
			{
				LLGestureStepSound* sound_step = (LLGestureStepSound*)step;
				optionstext = getString("step_sound");
				mSoundCombo->setVisible(TRUE);
				mSoundCombo->setCurrentByID(sound_step->mSoundAssetID);
				break;
			}
		case STEP_CHAT:
			{
				LLGestureStepChat* chat_step = (LLGestureStepChat*)step;
				optionstext = getString("step_chat");
				mChatEditor->setVisible(TRUE);
				mChatEditor->setText(chat_step->mChatText);
				break;
			}
		case STEP_WAIT:
			{
				LLGestureStepWait* wait_step = (LLGestureStepWait*)step;
				optionstext = getString("step_wait");
				mWaitAnimCheck->setVisible(TRUE);
				mWaitAnimCheck->set(wait_step->mFlags & WAIT_FLAG_ALL_ANIM);
				mWaitTimeCheck->setVisible(TRUE);
				mWaitTimeCheck->set(wait_step->mFlags & WAIT_FLAG_TIME);
				mWaitTimeEditor->setVisible(TRUE);
				std::string buffer = llformat("%.1f", (double)wait_step->mWaitSeconds);
				mWaitTimeEditor->setText(buffer);
				break;
			}
		default:
			break;
		}
	}
	
	mOptionsText->setText(optionstext);

	BOOL active = gGestureManager.isGestureActive(mItemUUID);
	mActiveCheck->set(active);

	// Can only preview if there are steps
	mPreviewBtn->setEnabled(step_count > 0);

	// And can only save if changes have been made
	mSaveBtn->setEnabled(mDirty);
	addAnimations();
	addSounds();
}
Beispiel #11
0
void LiveEventControl::renamePanel(int index, QString newName)
{
	QTableWidgetItem * item = getItem(index, 4);
	item->setText(newName);
}
BOOL LLPreviewGesture::postBuild()
{
	LLLineEditor* edit;
	LLComboBox* combo;
	LLButton* btn;
	LLScrollListCtrl* list;
	LLTextBox* text;
	LLCheckBoxCtrl* check;

	edit = getChild<LLLineEditor>("trigger_editor");
	edit->setKeystrokeCallback(onKeystrokeCommit);
	edit->setCommitCallback(onCommitSetDirty);
	edit->setCommitOnFocusLost(TRUE);
	edit->setCallbackUserData(this);
	edit->setIgnoreTab(TRUE);
	mTriggerEditor = edit;

	text = getChild<LLTextBox>("replace_text");
	text->setEnabled(FALSE);
	mReplaceText = text;

	edit = getChild<LLLineEditor>("replace_editor");
	edit->setEnabled(FALSE);
	edit->setKeystrokeCallback(onKeystrokeCommit);
	edit->setCommitCallback(onCommitSetDirty);
	edit->setCommitOnFocusLost(TRUE);
	edit->setCallbackUserData(this);
	edit->setIgnoreTab(TRUE);
	mReplaceEditor = edit;

	combo = getChild<LLComboBox>( "modifier_combo");
	combo->setCommitCallback(onCommitSetDirty);
	combo->setCallbackUserData(this);
	mModifierCombo = combo;

	combo = getChild<LLComboBox>( "key_combo");
	combo->setCommitCallback(onCommitSetDirty);
	combo->setCallbackUserData(this);
	mKeyCombo = combo;

	list = getChild<LLScrollListCtrl>("library_list");
	list->setCommitCallback(onCommitLibrary);
	list->setDoubleClickCallback(onClickAdd);
	list->setCallbackUserData(this);
	mLibraryList = list;

	btn = getChild<LLButton>( "add_btn");
	btn->setClickedCallback(onClickAdd);
	btn->setCallbackUserData(this);
	btn->setEnabled(FALSE);
	mAddBtn = btn;

	btn = getChild<LLButton>( "up_btn");
	btn->setClickedCallback(onClickUp);
	btn->setCallbackUserData(this);
	btn->setEnabled(FALSE);
	mUpBtn = btn;

	btn = getChild<LLButton>( "down_btn");
	btn->setClickedCallback(onClickDown);
	btn->setCallbackUserData(this);
	btn->setEnabled(FALSE);
	mDownBtn = btn;

	btn = getChild<LLButton>( "delete_btn");
	btn->setClickedCallback(onClickDelete);
	btn->setCallbackUserData(this);
	btn->setEnabled(FALSE);
	mDeleteBtn = btn;

	list = getChild<LLScrollListCtrl>("step_list");
	list->setCommitCallback(onCommitStep);
	list->setCallbackUserData(this);
	mStepList = list;

	// Options
	text = getChild<LLTextBox>("options_text");
	text->setBorderVisible(TRUE);
	mOptionsText = text;

	combo = getChild<LLComboBox>( "animation_list");
	combo->setVisible(FALSE);
	combo->setCommitCallback(onCommitAnimation);
	combo->setCallbackUserData(this);
	mAnimationCombo = combo;

	LLRadioGroup* group;
	group = getChild<LLRadioGroup>("animation_trigger_type");
	group->setVisible(FALSE);
	group->setCommitCallback(onCommitAnimationTrigger);
	group->setCallbackUserData(this);
	mAnimationRadio = group;

	combo = getChild<LLComboBox>( "sound_list");
	combo->setVisible(FALSE);
	combo->setCommitCallback(onCommitSound);
	combo->setCallbackUserData(this);
	mSoundCombo = combo;

	edit = getChild<LLLineEditor>("chat_editor");
	edit->setVisible(FALSE);
	edit->setCommitCallback(onCommitChat);
	//edit->setKeystrokeCallback(onKeystrokeCommit);
	edit->setCommitOnFocusLost(TRUE);
	edit->setCallbackUserData(this);
	edit->setIgnoreTab(TRUE);
	mChatEditor = edit;

	check = getChild<LLCheckBoxCtrl>( "wait_anim_check");
	check->setVisible(FALSE);
	check->setCommitCallback(onCommitWait);
	check->setCallbackUserData(this);
	mWaitAnimCheck = check;

	check = getChild<LLCheckBoxCtrl>( "wait_time_check");
	check->setVisible(FALSE);
	check->setCommitCallback(onCommitWait);
	check->setCallbackUserData(this);
	mWaitTimeCheck = check;

	edit = getChild<LLLineEditor>("wait_time_editor");
	edit->setEnabled(FALSE);
	edit->setVisible(FALSE);
	edit->setPrevalidate(LLLineEditor::prevalidateFloat);
//	edit->setKeystrokeCallback(onKeystrokeCommit);
	edit->setCommitOnFocusLost(TRUE);
	edit->setCommitCallback(onCommitWaitTime);
	edit->setCallbackUserData(this);
	edit->setIgnoreTab(TRUE);
	mWaitTimeEditor = edit;

	// Buttons at the bottom
	check = getChild<LLCheckBoxCtrl>( "active_check");
	check->setCommitCallback(onCommitActive);
	check->setCallbackUserData(this);
	mActiveCheck = check;

	btn = getChild<LLButton>( "save_btn");
	btn->setClickedCallback(onClickSave);
	btn->setCallbackUserData(this);
	mSaveBtn = btn;

	btn = getChild<LLButton>( "preview_btn");
	btn->setClickedCallback(onClickPreview);
	btn->setCallbackUserData(this);
	mPreviewBtn = btn;


	// Populate the comboboxes
	addModifiers();
	addKeys();
	addAnimations();
	addSounds();


	const LLInventoryItem* item = getItem();

	if (item) 
	{
		childSetCommitCallback("desc", LLPreview::onText, this);
		childSetText("desc", item->getDescription());
		childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);
	}

	return TRUE;
}
void LLPreviewGesture::saveIfNeeded()
{
	if (!gAssetStorage)
	{
		llwarns << "Can't save gesture, no asset storage system." << llendl;
		return;
	}

	if (!mDirty)
	{
		return;
	}

	// Copy the UI into a gesture
	LLMultiGesture* gesture = createGesture();

	// Serialize the gesture
	S32 max_size = gesture->getMaxSerialSize();
	char* buffer = new char[max_size];

	LLDataPackerAsciiBuffer dp(buffer, max_size);

	BOOL ok = gesture->serialize(dp);

	if (dp.getCurrentSize() > 1000)
	{
		LLNotifications::instance().add("GestureSaveFailedTooManySteps");

		delete gesture;
		gesture = NULL;
	}
	else if (!ok)
	{
		LLNotifications::instance().add("GestureSaveFailedTryAgain");
		delete gesture;
		gesture = NULL;
	}
	else
	{
		// Every save gets a new UUID.  Yup.
		LLTransactionID tid;
		LLAssetID asset_id;
		tid.generate();
		asset_id = tid.makeAssetID(gAgent.getSecureSessionID());

		LLVFile file(gVFS, asset_id, LLAssetType::AT_GESTURE, LLVFile::APPEND);

		S32 size = dp.getCurrentSize();
		file.setMaxSize(size);
		file.write((U8*)buffer, size);

		BOOL delayedUpload = FALSE;

		// Upload that asset to the database
		LLViewerInventoryItem* item = (LLViewerInventoryItem*) getItem();
		if (item)
		{
			std::string agent_url = gAgent.getRegion()->getCapability("UpdateGestureAgentInventory");
			std::string task_url = gAgent.getRegion()->getCapability("UpdateGestureTaskInventory");
			if (mObjectUUID.isNull() && !agent_url.empty())
			{
				//need to disable the preview floater so item
				//isn't re-saved before new asset arrives
				//fake out refresh.
				item->setComplete(FALSE);
				refresh();				
				item->setComplete(TRUE);

				// Saving into agent inventory
				LLSD body;
				body["item_id"] = mItemUUID;
				LLHTTPClient::post(agent_url, body,
					new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_GESTURE));
				delayedUpload = TRUE;
			}
			else if (!mObjectUUID.isNull() && !task_url.empty())
			{
				// Saving into task inventory
				LLSD body;
				body["task_id"] = mObjectUUID;
				body["item_id"] = mItemUUID;
				LLHTTPClient::post(task_url, body,
					new LLUpdateTaskInventoryResponder(body, asset_id, LLAssetType::AT_GESTURE));
			}
			else if (gAssetStorage)
			{
				LLLineEditor* descEditor = getChild<LLLineEditor>("desc");
				LLSaveInfo* info = new LLSaveInfo(mItemUUID, mObjectUUID, descEditor->getText(), tid);
				gAssetStorage->storeAssetData(tid, LLAssetType::AT_GESTURE, onSaveComplete, info, FALSE);
			}
		}

		// If this gesture is active, then we need to update the in-memory
		// active map with the new pointer.
		if (!delayedUpload && gGestureManager.isGestureActive(mItemUUID))
		{
			// gesture manager now owns the pointer
			gGestureManager.replaceGesture(mItemUUID, gesture, asset_id);

			// replaceGesture may deactivate other gestures so let the
			// inventory know.
			gInventory.notifyObservers();
		}
		else
		{
			// we're done with this gesture
			delete gesture;
			gesture = NULL;
		}

		mDirty = FALSE;
		// refresh will be called when callback
		// if triggered when delayedUpload
		if(!delayedUpload)
		{
			refresh();
		}
	}

	delete [] buffer;
	buffer = NULL;
}
v8::Handle<v8::Value> V8HTMLAllCollection::itemCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.HTMLAllCollection.item()");
    HTMLAllCollection* imp = V8HTMLAllCollection::toNative(args.Holder());
    return getItem(imp, args[0], args.Holder(), args.GetIsolate());
}
Beispiel #15
0
static void test_comboboxex(void) {
    HWND myHwnd = 0;
    LONG res = -1;
    COMBOBOXEXITEMA cbexItem;
    static const char *first_item  = "First Item",
                *second_item = "Second Item",
                *third_item  = "Third Item",
                *middle_item = "Between First and Second Items",
                *replacement_item = "Between First and Second Items",
                *out_of_range_item = "Out of Range Item";

    /* Allocate space for result */
    textBuffer = HeapAlloc(GetProcessHeap(), 0, MAX_CHARS);

    /* Basic comboboxex test */
    myHwnd = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);

    /* Add items onto the end of the combobox */
    res = addItem(myHwnd, -1, first_item);
    ok(res == 0, "Adding simple item failed (%d)\n", res);
    res = addItem(myHwnd, -1, second_item);
    ok(res == 1, "Adding simple item failed (%d)\n", res);
    res = addItem(myHwnd, 2, third_item);
    ok(res == 2, "Adding simple item failed (%d)\n", res);
    res = addItem(myHwnd, 1, middle_item);
    ok(res == 1, "Inserting simple item failed (%d)\n", res);

    /* Add an item completely out of range */
    res = addItem(myHwnd, 99, out_of_range_item);
    ok(res == -1, "Adding using out of range index worked unexpectedly (%d)\n", res);
    res = addItem(myHwnd, 5, out_of_range_item);
    ok(res == -1, "Adding using out of range index worked unexpectedly (%d)\n", res);
    /* Removed: Causes traps on Windows XP
       res = addItem(myHwnd, -2, "Out Of Range Item");
       ok(res == -1, "Adding out of range worked unexpectedly (%ld)\n", res);
     */

    /* Get an item completely out of range */ 
    res = getItem(myHwnd, 99, &cbexItem); 
    ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);
    res = getItem(myHwnd, 4, &cbexItem); 
    ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);
    res = getItem(myHwnd, -2, &cbexItem); 
    ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);

    /* Get an item in range */ 
    res = getItem(myHwnd, 0, &cbexItem); 
    ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
    ok(strcmp(first_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);

    res = getItem(myHwnd, 1, &cbexItem); 
    ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
    ok(strcmp(middle_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);

    res = getItem(myHwnd, 2, &cbexItem); 
    ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
    ok(strcmp(second_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);

    res = getItem(myHwnd, 3, &cbexItem); 
    ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
    ok(strcmp(third_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);

    /* Set an item completely out of range */ 
    res = setItem(myHwnd, 99, replacement_item); 
    ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);
    res = setItem(myHwnd, 4, replacement_item); 
    ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);
    res = setItem(myHwnd, -2, replacement_item); 
    ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);

    /* Set an item in range */ 
    res = setItem(myHwnd, 0, replacement_item);
    ok(res != 0, "Setting first item failed (%d)\n", res);
    res = setItem(myHwnd, 3, replacement_item);
    ok(res != 0, "Setting last item failed (%d)\n", res);

    /* Remove items completely out of range (4 items in control at this point) */
    res = delItem(myHwnd, -1);
    ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);
    res = delItem(myHwnd, 4);
    ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);

    /* Remove items in range (4 items in control at this point) */
    res = delItem(myHwnd, 3);
    ok(res == 3, "Deleting using out of range index failed (%d)\n", res);
    res = delItem(myHwnd, 0);
    ok(res == 2, "Deleting using out of range index failed (%d)\n", res);
    res = delItem(myHwnd, 0);
    ok(res == 1, "Deleting using out of range index failed (%d)\n", res);
    res = delItem(myHwnd, 0);
    ok(res == 0, "Deleting using out of range index failed (%d)\n", res);

    /* Remove from an empty box */
    res = delItem(myHwnd, 0);
    ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);


    /* Cleanup */
    HeapFree(GetProcessHeap(), 0, textBuffer);
    DestroyWindow(myHwnd);
}
Beispiel #16
0
void LiveEventControl::setPanelLoopEnabled(int index, bool enabled)
{
	QTableWidgetItem * item = getItem(index, 2);
	item->setCheckState(enabled ? Qt::Checked : Qt::Unchecked);
}
Beispiel #17
0
void GameMapGump::OnMouseClick(int button, int mx, int my)
{
	MainActor* avatar = getMainActor();
	switch (button) {
	case BUTTON_LEFT:
	{
		if (avatar->isInCombat()) break;

		if (GUIApp::get_instance()->isMouseDown(BUTTON_RIGHT)) break;

		if (GUIApp::get_instance()->isAvatarInStasis()) {
			pout << "Can't: avatarInStasis" << std::endl;
			break;
		}

		uint16 objID = TraceObjId(mx, my);
		Item *item = getItem(objID);
		if (item) {
			sint32 x,y,z;
			item->getLocation(x,y,z);
			item->dumpInfo();
			
			// call the 'look' event
			item->callUsecodeEvent_look();
		}
		break;
	}
	case BUTTON_MIDDLE:
	{
		uint16 objID = TraceObjId(mx, my);
		Item *item = getItem(objID);
		if (item) {
			sint32 x,y,z;
			item->getLocation(x,y,z);
			item->dumpInfo();

#if 1
			Actor* devon = getActor(1);
			PathfinderProcess* pfp = new PathfinderProcess(devon, x, y, z);
//			PathfinderProcess* pfp = new PathfinderProcess(devon, objID, false);
			Kernel::get_instance()->addProcess(pfp);
#elif 0
			if (p_dynamic_cast<Actor*>(item)) {
				p_dynamic_cast<Actor*>(item)->die(0);
			} else {
				item->destroy();
			}
#elif 0
			UCList uclist(2);
			LOOPSCRIPT(script, LS_TOKEN_TRUE); // we want all items
			World* world= World::get_instance();
			world->getCurrentMap()->surfaceSearch(&uclist, script,
												  sizeof(script),
												  item, true, false, true);
			for (uint32 i = 0; i < uclist.getSize(); i++)
			{
				Item *item2 = getItem(uclist.getuint16(i));
				if (!item2) continue;
				item2->setExtFlag(Item::EXT_HIGHLIGHT);
			}
#elif 0
			item->receiveHit(1, 0, 1024, 0);
#elif 0
			item->clearFlag(Item::FLG_HANGING);
#endif
		}
	}
	default:
		break;
	}
}
Beispiel #18
0
void LiveEventControl::setPanelTempo(int index, double tempo)
{
	QTableWidgetItem * item = getItem(index, 7);
	item->setText(QString::number(tempo));
}
/** Process groups. Groups are processed differently depending on transmission
 * runs and polarization analysis. If transmission run is a matrix workspace, it
 * will be applied to each of the members in the input workspace group. If
 * transmission run is a workspace group, the behaviour is different depending
 * on polarization analysis. If polarization analysis is off (i.e.
 * 'PolarizationAnalysis' is set to 'None') each item in the transmission group
 * is associated with the corresponding item in the input workspace group. If
 * polarization analysis is on (i.e. 'PolarizationAnalysis' is 'PA' or 'PNR')
 * items in the transmission group will be summed to produce a matrix workspace
 * that will be applied to each of the items in the input workspace group. See
 * documentation of this algorithm for more details.
*/
bool ReflectometryReductionOneAuto2::processGroups() {
  // this algorithm effectively behaves as MultiPeriodGroupAlgorithm
  m_usingBaseProcessGroups = true;

  // Get our input workspace group
  auto group = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(
      getPropertyValue("InputWorkspace"));
  // Get name of IvsQ workspace (native binning)
  const std::string outputIvsQ = getPropertyValue("OutputWorkspace");
  // Get name of IvsQ (native binning) workspace
  const std::string outputIvsQBinned =
      getPropertyValue("OutputWorkspaceBinned");
  // Get name of IvsLam workspace
  const std::string outputIvsLam =
      getPropertyValue("OutputWorkspaceWavelength");

  // Create a copy of ourselves
  Algorithm_sptr alg =
      createChildAlgorithm(name(), -1, -1, isLogging(), version());
  alg->setChild(false);
  alg->setRethrows(true);

  // Copy all the non-workspace properties over
  const std::vector<Property *> props = getProperties();
  for (auto &prop : props) {
    if (prop) {
      IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty *>(prop);
      if (!wsProp)
        alg->setPropertyValue(prop->name(), prop->value());
    }
  }

  const bool polarizationAnalysisOn =
      getPropertyValue("PolarizationAnalysis") != "None";

  // Check if the transmission runs are groups or not

  const std::string firstTrans = getPropertyValue("FirstTransmissionRun");
  WorkspaceGroup_sptr firstTransG;
  MatrixWorkspace_sptr firstTransSum;
  if (!firstTrans.empty()) {
    auto firstTransWS =
        AnalysisDataService::Instance().retrieveWS<Workspace>(firstTrans);
    firstTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(firstTransWS);
    if (!firstTransG) {
      alg->setProperty("FirstTransmissionRun", firstTrans);
    } else if (polarizationAnalysisOn) {
      firstTransSum = sumTransmissionWorkspaces(firstTransG);
    }
  }
  const std::string secondTrans = getPropertyValue("SecondTransmissionRun");
  WorkspaceGroup_sptr secondTransG;
  MatrixWorkspace_sptr secondTransSum;
  if (!secondTrans.empty()) {
    auto secondTransWS =
        AnalysisDataService::Instance().retrieveWS<Workspace>(secondTrans);
    secondTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(secondTransWS);
    if (!secondTransG) {
      alg->setProperty("SecondTransmissionRun", secondTrans);
    } else if (polarizationAnalysisOn) {
      secondTransSum = sumTransmissionWorkspaces(secondTransG);
    }
  }

  std::vector<std::string> IvsQGroup, IvsQUnbinnedGroup, IvsLamGroup;

  // Execute algorithm over each group member
  for (size_t i = 0; i < group->size(); ++i) {

    const std::string IvsQName = outputIvsQ + "_" + std::to_string(i + 1);
    const std::string IvsQBinnedName =
        outputIvsQBinned + "_" + std::to_string(i + 1);
    const std::string IvsLamName = outputIvsLam + "_" + std::to_string(i + 1);

    if (firstTransG) {
      if (!polarizationAnalysisOn)
        alg->setProperty("FirstTransmissionRun",
                         firstTransG->getItem(i)->getName());
      else
        alg->setProperty("FirstTransmissionRun", firstTransSum);
    }
    if (secondTransG) {
      if (!polarizationAnalysisOn)
        alg->setProperty("SecondTransmissionRun",
                         secondTransG->getItem(i)->getName());
      else
        alg->setProperty("SecondTransmissionRun", secondTransSum);
    }

    alg->setProperty("InputWorkspace", group->getItem(i)->getName());
    alg->setProperty("OutputWorkspace", IvsQName);
    alg->setProperty("OutputWorkspaceBinned", IvsQBinnedName);
    alg->setProperty("OutputWorkspaceWavelength", IvsLamName);
    alg->execute();

    IvsQGroup.push_back(IvsQName);
    IvsQUnbinnedGroup.push_back(IvsQBinnedName);
    IvsLamGroup.push_back(IvsLamName);
  }

  // Group the IvsQ and IvsLam workspaces
  Algorithm_sptr groupAlg = createChildAlgorithm("GroupWorkspaces");
  groupAlg->setChild(false);
  groupAlg->setRethrows(true);
  groupAlg->setProperty("InputWorkspaces", IvsLamGroup);
  groupAlg->setProperty("OutputWorkspace", outputIvsLam);
  groupAlg->execute();
  groupAlg->setProperty("InputWorkspaces", IvsQGroup);
  groupAlg->setProperty("OutputWorkspace", outputIvsQ);
  groupAlg->execute();
  groupAlg->setProperty("InputWorkspaces", IvsQUnbinnedGroup);
  groupAlg->setProperty("OutputWorkspace", outputIvsQBinned);
  groupAlg->execute();

  // Set other properties so they can be updated in the Reflectometry interface
  setPropertyValue("ThetaIn", alg->getPropertyValue("ThetaIn"));
  setPropertyValue("MomentumTransferMin",
                   alg->getPropertyValue("MomentumTransferMin"));
  setPropertyValue("MomentumTransferMax",
                   alg->getPropertyValue("MomentumTransferMax"));
  setPropertyValue("MomentumTransferStep",
                   alg->getPropertyValue("MomentumTransferStep"));
  setPropertyValue("ScaleFactor", alg->getPropertyValue("ScaleFactor"));

  if (!polarizationAnalysisOn) {
    // No polarization analysis. Reduction stops here
    setPropertyValue("OutputWorkspace", outputIvsQ);
    setPropertyValue("OutputWorkspaceBinned", outputIvsQBinned);
    setPropertyValue("OutputWorkspaceWavelength", outputIvsLam);
    return true;
  }

  if (!group->isMultiperiod()) {
    g_log.warning("Polarization corrections can only be performed on "
                  "multiperiod workspaces.");
    setPropertyValue("OutputWorkspace", outputIvsQ);
    setPropertyValue("OutputWorkspaceBinned", outputIvsQBinned);
    setPropertyValue("OutputWorkspaceWavelength", outputIvsLam);
    return true;
  }

  Algorithm_sptr polAlg = createChildAlgorithm("PolarizationCorrection");
  polAlg->setChild(false);
  polAlg->setRethrows(true);
  polAlg->setProperty("InputWorkspace", outputIvsLam);
  polAlg->setProperty("OutputWorkspace", outputIvsLam);
  polAlg->setProperty("PolarizationAnalysis",
                      getPropertyValue("PolarizationAnalysis"));
  polAlg->setProperty("CPp", getPropertyValue("CPp"));
  polAlg->setProperty("CRho", getPropertyValue("CRho"));
  polAlg->setProperty("CAp", getPropertyValue("CAp"));
  polAlg->setProperty("CAlpha", getPropertyValue("CAlpha"));
  polAlg->execute();

  // Now we've overwritten the IvsLam workspaces, we'll need to recalculate
  // the IvsQ ones
  alg->setProperty("FirstTransmissionRun", "");
  alg->setProperty("SecondTransmissionRun", "");
  alg->setProperty("CorrectionAlgorithm", "None");
  alg->setProperty("ThetaIn", Mantid::EMPTY_DBL());
  alg->setProperty("ProcessingInstructions", "0");
  for (size_t i = 0; i < group->size(); ++i) {
    const std::string IvsQName = outputIvsQ + "_" + std::to_string(i + 1);
    const std::string IvsQBinnedName =
        outputIvsQBinned + "_" + std::to_string(i + 1);
    const std::string IvsLamName = outputIvsLam + "_" + std::to_string(i + 1);
    alg->setProperty("InputWorkspace", IvsLamName);
    alg->setProperty("OutputWorkspace", IvsQName);
    alg->setProperty("OutputWorkspaceBinned", IvsQBinnedName);
    alg->setProperty("OutputWorkspaceWavelength", IvsLamName);
    alg->execute();
  }

  setPropertyValue("OutputWorkspace", outputIvsQ);
  setPropertyValue("OutputWorkspaceBinned", outputIvsQBinned);
  setPropertyValue("OutputWorkspaceWavelength", outputIvsLam);

  return true;
}
Beispiel #20
0
int DDLT::Select::l__index( lua_State* L )
{
  const char* key = luaL_checkstring( L, 2 );
  uint32_t hash = DDLParser::StringCrc32( key );

  switch ( hash )
  {
  case 0x44e9085cU: // getType
    lua_pushcfunction( L, getType );
    return 1;
  case 0x96142173U: // getName
    lua_pushcfunction( L, getName );
    return 1;
  case 0x55eac3d6U: // getAuthor
    lua_pushcfunction( L, getAuthor );
    return 1;
  case 0x13f87889U: // getDescription
    lua_pushcfunction( L, getDescription );
    return 1;
  case 0xfc020d89U: // getLabel
    lua_pushcfunction( L, getLabel );
    return 1;
  case 0x8d3caf7aU: // getDisplayLabel
    lua_pushcfunction( L, getDisplayLabel );
    return 1;
  case 0x2709d01bU: // getNameHash
    lua_pushcfunction( L, getNameHash );
    return 1;
  case 0x5379b335U: // getNumItems
    lua_pushcfunction( L, getNumItems );
    return 1;
  case 0xa239d858U: // getDefaultItem
    lua_pushcfunction( L, getDefaultItem );
    return 1;
  case 0xd72c7a6bU: // getItem
    lua_pushcfunction( L, getItem );
    return 1;
  case 0xaede4adeU: // findItem
    lua_pushcfunction( L, findItem );
    return 1;
  case 0x3dc5bb1dU: // getOwner
    lua_pushcfunction( L, getOwner );
    return 1;
  case 0x398c0a88U: // items
    lua_pushcfunction( L, items );
    return 1;
  case 0xff1efba8U: // tags
    lua_pushcfunction( L, tags );
    return 1;
  default:
    if ( lua_isnumber( L, 2 ) )
    {
      return getItem( L );
    }
    else
    {
      return findItem( L );
    }
  }

  return 0;
}
Beispiel #21
0
int VLCModel::itemId( const QModelIndex &index ) const
{
    AbstractPLItem *item = getItem( index );
    if ( !item ) return -1;
    return item->id();
}
Beispiel #22
0
bool
CGlobalOptions::save(HWND hwnd)
{
	HWND child;
	int newDelayTime     = 0;
	int newTwoTapTime    = 0;
	int newHeartbeatTime = 0;

	// get requested options
	child = getItem(hwnd, IDC_GLOBAL_DELAY_CHECK);
	if (isItemChecked(child)) {
		child         = getItem(hwnd, IDC_GLOBAL_DELAY_TIME);
		newDelayTime  = getTime(hwnd, child, true);
		if (newDelayTime == 0) {
			return false;
		}
	}
	else {
		child         = getItem(hwnd, IDC_GLOBAL_DELAY_TIME);
		newDelayTime  = getTime(hwnd, child, false);
		if (newDelayTime == 0) {
			newDelayTime = s_defaultDelay;
		}
	}
	child = getItem(hwnd, IDC_GLOBAL_TWO_TAP_CHECK);
	if (isItemChecked(child)) {
		child         = getItem(hwnd, IDC_GLOBAL_TWO_TAP_TIME);
		newTwoTapTime = getTime(hwnd, child, true);
		if (newTwoTapTime == 0) {
			return false;
		}
	}
	else {
		child         = getItem(hwnd, IDC_GLOBAL_TWO_TAP_TIME);
		newTwoTapTime = getTime(hwnd, child, false);
		if (newTwoTapTime == 0) {
			newTwoTapTime = s_defaultDelay;
		}
	}
	child = getItem(hwnd, IDC_GLOBAL_HEARTBEAT_CHECK);
	if (isItemChecked(child)) {
		child            = getItem(hwnd, IDC_GLOBAL_HEARTBEAT_TIME);
		newHeartbeatTime = getTime(hwnd, child, true);
		if (newHeartbeatTime == 0) {
			return false;
		}
	}
	else {
		child            = getItem(hwnd, IDC_GLOBAL_HEARTBEAT_TIME);
		newHeartbeatTime = getTime(hwnd, child, false);
		if (newHeartbeatTime == 0) {
			newHeartbeatTime = s_defaultHeartbeat;
		}
	}

	// remove existing config options
	m_config->removeOption("", kOptionScreenSwitchDelay);
	m_config->removeOption("", kOptionScreenSwitchTwoTap);
	m_config->removeOption("", kOptionHeartbeat);
	m_config->removeOption("", kOptionScreenSaverSync);
	m_config->removeOption("", kOptionRelativeMouseMoves);
	m_config->removeOption("", kOptionWin32KeepForeground);

	// add requested options
	child = getItem(hwnd, IDC_GLOBAL_DELAY_CHECK);
	if (isItemChecked(child)) {
		m_config->addOption("", kOptionScreenSwitchDelay, newDelayTime);
	}
	child = getItem(hwnd, IDC_GLOBAL_TWO_TAP_CHECK);
	if (isItemChecked(child)) {
		m_config->addOption("", kOptionScreenSwitchTwoTap, newTwoTapTime);
	}
	child = getItem(hwnd, IDC_GLOBAL_HEARTBEAT_CHECK);
	if (isItemChecked(child)) {
		m_config->addOption("", kOptionHeartbeat, newHeartbeatTime);
	}
	child = getItem(hwnd, IDC_GLOBAL_SCREENSAVER_SYNC);
	if (!isItemChecked(child)) {
		m_config->addOption("", kOptionScreenSaverSync, 0);
	}
	child = getItem(hwnd, IDC_GLOBAL_RELATIVE_MOVES);
	if (isItemChecked(child)) {
		m_config->addOption("", kOptionRelativeMouseMoves, 1);
	}
	child = getItem(hwnd, IDC_GLOBAL_LEAVE_FOREGROUND);
	if (isItemChecked(child)) {
		m_config->addOption("", kOptionWin32KeepForeground, 1);
	}

	// save last values
	m_delayTime     = newDelayTime;
	m_twoTapTime    = newTwoTapTime;
	m_heartbeatTime = newHeartbeatTime;
	return true;
}
Beispiel #23
0
QString VLCModel::getTitle( const QModelIndex &index ) const
{
    AbstractPLItem *item = getItem( index );
    if ( !item ) return QString();
    return item->getTitle();
}
Beispiel #24
0
void
CGlobalOptions::init(HWND hwnd)
{
	HWND child;
	char buffer[30];

	// reset options
	sprintf(buffer, "%d", m_delayTime);
	child = getItem(hwnd, IDC_GLOBAL_DELAY_CHECK);
	setItemChecked(child, false);
	child = getItem(hwnd, IDC_GLOBAL_DELAY_TIME);
	setWindowText(child, buffer);
	sprintf(buffer, "%d", m_twoTapTime);
	child = getItem(hwnd, IDC_GLOBAL_TWO_TAP_CHECK);
	setItemChecked(child, false);
	child = getItem(hwnd, IDC_GLOBAL_TWO_TAP_TIME);
	setWindowText(child, buffer);
	sprintf(buffer, "%d", m_heartbeatTime);
	child = getItem(hwnd, IDC_GLOBAL_HEARTBEAT_CHECK);
	setItemChecked(child, false);
	child = getItem(hwnd, IDC_GLOBAL_HEARTBEAT_TIME);
	setWindowText(child, buffer);
	child = getItem(hwnd, IDC_GLOBAL_SCREENSAVER_SYNC);
	setItemChecked(child, true);
	child = getItem(hwnd, IDC_GLOBAL_RELATIVE_MOVES);
	setItemChecked(child, false);
	child = getItem(hwnd, IDC_GLOBAL_LEAVE_FOREGROUND);
	setItemChecked(child, false);

	// get the global options
	const CConfig::CScreenOptions* options = m_config->getOptions("");
	if (options != NULL) {
		for (CConfig::CScreenOptions::const_iterator index = options->begin();
										index != options->end(); ++index) {
			const OptionID id       = index->first;
			const OptionValue value = index->second;
			if (id == kOptionScreenSwitchDelay) {
				if (value > 0) {
					sprintf(buffer, "%d", value);
					child = getItem(hwnd, IDC_GLOBAL_DELAY_CHECK);
					setItemChecked(child, true);
					child = getItem(hwnd, IDC_GLOBAL_DELAY_TIME);
					setWindowText(child, buffer);
				}
			}
			else if (id == kOptionScreenSwitchTwoTap) {
				if (value > 0) {
					sprintf(buffer, "%d", value);
					child = getItem(hwnd, IDC_GLOBAL_TWO_TAP_CHECK);
					setItemChecked(child, true);
					child = getItem(hwnd, IDC_GLOBAL_TWO_TAP_TIME);
					setWindowText(child, buffer);
				}
			}
			else if (id == kOptionHeartbeat) {
				if (value > 0) {
					sprintf(buffer, "%d", value);
					child = getItem(hwnd, IDC_GLOBAL_HEARTBEAT_CHECK);
					setItemChecked(child, true);
					child = getItem(hwnd, IDC_GLOBAL_HEARTBEAT_TIME);
					setWindowText(child, buffer);
				}
			}
			else if (id == kOptionScreenSaverSync) {
				child = getItem(hwnd, IDC_GLOBAL_SCREENSAVER_SYNC);
				setItemChecked(child, (value != 0));
			}
			else if (id == kOptionRelativeMouseMoves) {
				child = getItem(hwnd, IDC_GLOBAL_RELATIVE_MOVES);
				setItemChecked(child, (value != 0));
			}
			else if (id == kOptionWin32KeepForeground) {
				child = getItem(hwnd, IDC_GLOBAL_LEAVE_FOREGROUND);
				setItemChecked(child, (value != 0));
			}
		}
	}
}
Beispiel #25
0
bool TreeModel::insertRows(const QModelIndex row, const QModelIndexList rowList, openstudio::IddObjectType type)
{
  bool success = false;

  if(type == openstudio::IddObjectType::UserCustom){
    return success;
  }

  int position = rowList.at(0).row();
  int rows = rowList.size();

  QModelIndex parent = row;
  TreeItem * parentItem = getItem(row);
  OS_ASSERT(parentItem);
  //OptionalWorkspaceObject workspaceObject = parentItem->data().workspaceObject();
  //OS_ASSERT(workspaceObject);
  //QString iddObjectName(workspaceObject->iddObject().name().c_str());

  ///! For now, we should only try objects without children as the children wouldn't be
  ///! handled in the Qt model with this current arrangement.

  ///! OpenStudio model update...
  ///! Currently unable to safely try a list.   Need to cache what was successfully
  ///! pasted and then use that vector to populate the Qt model.

  openstudio::OptionalWorkspaceObject optWsObj;
  openstudio::model::OptionalModelObject optModelObj;
  std::vector<openstudio::model::ModelObject> parentObjects;

  for(int i=0; i<rows; ++i)
  {
    optWsObj = parentItem->modelObject().workspace().addObject(openstudio::IdfObject(type));
    if(!optWsObj)
    {
      return success;
    }
    else
    {
      optModelObj = parentItem->modelObject().model().getModelObject<ModelObject>(optWsObj->handle());
      if(!optModelObj)
      {
        return success;
      }
      else
      {
        ModelObject temp(parentItem->modelObject());
        OptionalParentObject tempParent = temp.optionalCast<ParentObject>();
        success = optModelObj->setParent(*tempParent);
        if(success)
        {
          mTreeViewWidget->loadModel();
          parentObjects.push_back(*optModelObj);
        }
      }
    }
  }

  return success; // not updating Qt model

  if(!success) return success; // Nothing to add to the Qt model;

  ///! Qt model update...
  beginInsertRows(parent, position+1, position+rows);
  // get the idd object type
  QList<QVariant> objectNames;
  for(unsigned i=0; i<parentObjects.size(); i++)
  {
    getObjectNames(parentObjects.at(i), objectNames);
    success = parentItem->insertChildren(parentObjects.at(i), objectNames, position+1, rows, rootItem->columnCount());
    if(!success)
    {
      break;
    }
  }
  endInsertRows();

  return success;
}
bool saveDotaData (char const* dest)
{
  MPQFILE file = MPQOpenFile (((CDotAReplayApp*) ::AfxGetApp ())->res, dest, MPQFILE_REWRITE);
  if (file)
  {
    static int hsub[256];
    static int isub[512];
    memset (hsub, 0, sizeof hsub);
    memset (isub, 0, sizeof isub);
    int mxh = bk_numHeroes;
    for (int i = 1; i < numHeroes; i++)
    {
      bool found = false;
      for (int j = 1; j < bk_numHeroes && !found; j++)
      {
        if (samename (heroes[i].name, bk_heroes[j].name))
        {
          hsub[j] = i;
          found = true;
        }
      }
      if (!found)
        hsub[mxh++] = i;
    }
    int mxi = bk_numItems;
    for (int i = 1; i < numItems; i++)
    {
      bool found = false;
      for (int j = 1; j < bk_numItems && !found; j++)
      {
        if (items[i].type/2 == bk_items[j].type/2 && samename (items[i].name, bk_items[j].name))
        {
          isub[j] = i;
          found = true;
        }
      }
      if (!found)
        isub[mxi++] = i;
    }
    MPQFilePuts (file, "[HERO]\r\n");
    for (int m = 0; m < mxh; m++)
    {
      int i = hsub[m];
      DotaHero* hero = &heroes[i];
      MPQFilePuts (file, mprintf ("\"%s\",\"%s\",%d,\"%s\",%d,%d", hero->name, hero->oname, hero->tavern,
        hero->imgTag, hero->slot, hero->point));
      for (int j = 0; j < 5; j++)
        MPQFilePuts (file, mprintf (",%s", make_id (hero->abils[j])));
      for (int j = 0; j < hero->numIds; j++)
        MPQFilePuts (file, mprintf (",%s", make_id (hero->ids[j])));
      MPQFilePuts (file, "\r\n");
    }
    MPQFilePuts (file, "[ITEM]\r\n");
    for (int m = 0; m < mxi; m++)
    {
      int i = isub[m];
      DotaItem* item = getItem (i);
      MPQFilePuts (file, mprintf ("\"%s\",%d,\"%s\"", item->name, item->cost, item->imgTag));
      for (int j = 0; j < item->numIds; j++)
        MPQFilePuts (file, mprintf (",%s", make_id (item->ids[j])));
      MPQFilePuts (file, "\r\n");
    }
    MPQFilePuts (file, "[ABILITY]\r\n");
    for (int i = 1; i < numAbilities; i++)
    {
      DotaAbility* abil = getAbility (i);
      MPQFilePuts (file, mprintf ("\"%s\",%d,\"%s\"", abil->name, abil->slot, abil->imgTag));
      for (int j = 0; j < abil->numIds; j++)
        MPQFilePuts (file, mprintf (",%s", make_id (abil->ids[j])));
      MPQFilePuts (file, "\r\n");
    }
    MPQFilePuts (file, "[RECIPE]\r\n");
    for (int i = 0; i < numRecipes; i++)
    {
      DotaRecipe* recipe = getRecipe (i);
      MPQFilePuts (file, make_id (recipe->result));
      for (int j = 0; j < recipe->numsrc; j++)
        MPQFilePuts (file, mprintf (",%s,%d", make_id (recipe->srcid[j]), recipe->srccount[j]));
      MPQFilePuts (file, "\r\n");
    }
    MPQCloseFile (file);
  }
  else
    return false;
  MPQFlushListfile (((CDotAReplayApp*) ::AfxGetApp ())->res);
  return true;
}
void LLPreviewNotecard::loadAsset()
{
	LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor");

	if (!editor)
		return;

	// request the asset.
	if (const LLInventoryItem* item = getItem())
	{
		if (gAgent.allowOperation(PERM_COPY, item->getPermissions(),
									GP_OBJECT_MANIPULATE)
			|| gAgent.isGodlike())
		{
			mAssetID = item->getAssetUUID();
			if(mAssetID.isNull())
			{
				editor->setText(LLStringUtil::null);
				editor->makePristine();
				editor->setEnabled(TRUE);
				mAssetStatus = PREVIEW_ASSET_LOADED;
			}
			else
			{
				LLUUID* new_uuid = new LLUUID(mItemUUID);
				LLHost source_sim = LLHost::invalid;
				if (mObjectUUID.notNull())
				{
					LLViewerObject *objectp = gObjectList.findObject(mObjectUUID);
					if (objectp && objectp->getRegion())
					{
						source_sim = objectp->getRegion()->getHost();
					}
					else
					{
						// The object that we're trying to look at disappeared, bail.
						llwarns << "Can't find object " << mObjectUUID << " associated with notecard." << llendl;
						mAssetID.setNull();
						editor->setText(getString("no_object"));
						editor->makePristine();
						editor->setEnabled(FALSE);
						mAssetStatus = PREVIEW_ASSET_LOADED;
						delete new_uuid;
						return;
					}
				}
				gAssetStorage->getInvItemAsset(source_sim,
												gAgent.getID(),
												gAgent.getSessionID(),
												item->getPermissions().getOwner(),
												mObjectUUID,
												item->getUUID(),
												item->getAssetUUID(),
												item->getType(),
												&onLoadComplete,
												(void*)new_uuid,
												TRUE);
				mAssetStatus = PREVIEW_ASSET_LOADING;
			}
		}
		else
		{
			mAssetID.setNull();
			editor->setText(getString("not_allowed"));
			editor->makePristine();
			editor->setEnabled(FALSE);
			mAssetStatus = PREVIEW_ASSET_LOADED;
		}
		if(!gAgent.allowOperation(PERM_MODIFY, item->getPermissions(),
								GP_OBJECT_MANIPULATE))
		{
			editor->setEnabled(FALSE);
			// <edit> You can always save in task inventory
			if(!mObjectUUID.isNull()) editor->setEnabled(TRUE);
			// </edit>
			if (LLUICtrl* ctrl = findChild<LLUICtrl>("lock"))
				ctrl->setVisible(true);
		}
	}
	else
	{
		editor->setText(LLStringUtil::null);
		editor->makePristine();
		editor->setEnabled(TRUE);
		mAssetStatus = PREVIEW_ASSET_LOADED;
	}
}
void V8HTMLAllCollection::itemMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    HTMLAllCollection* impl = V8HTMLAllCollection::toImpl(info.Holder());
    v8SetReturnValue(info, getItem(impl, info[0], info));
}
// Default constructor
LLPreviewNotecard::LLPreviewNotecard(const std::string& name,
									 const LLRect& rect,
									 const std::string& title,
									 const LLUUID& item_id, 
									 const LLUUID& object_id,
									 const LLUUID& asset_id,
									 BOOL show_keep_discard,
									 LLPointer<LLViewerInventoryItem> inv_item) :
	LLPreview(name, rect, title, item_id, object_id, TRUE,
			  PREVIEW_MIN_WIDTH,
			  PREVIEW_MIN_HEIGHT,
			  inv_item),
	mAssetID( asset_id ),
	mNotecardItemID(item_id),
	mObjectID(object_id)
{
	LLRect curRect = rect;

	if (show_keep_discard)
	{
		LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_notecard_keep_discard.xml");
		childSetAction("Keep",onKeepBtn,this);
		childSetAction("Discard",onDiscardBtn,this);
	}
	else
	{
		LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_notecard.xml");
		// <edit>
		childSetAction("Get Items", onClickGetItems, this);
		// </edit>

		if( mAssetID.isNull() )
		{
			const LLInventoryItem* item = getItem();
			if( item )
			{
				mAssetID = item->getAssetUUID();
			}
		}
	}	
	if (hasChild("Save", true))
		childSetAction("Save",onClickSave,this);

	// only assert shape if not hosted in a multifloater
	if (!getHost())
	{
		reshape(curRect.getWidth(), curRect.getHeight(), TRUE);
		setRect(curRect);
	}
			
	if (LLUICtrl* ctrl = findChild<LLUICtrl>("lock"))
		ctrl->setVisible(false);
	
	if (hasChild("desc", true))
	{
		childSetCommitCallback("desc", LLPreview::onText, this);
		if (const LLInventoryItem* item = getItem())
			childSetText("desc", item->getDescription());
		childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);
	}

	setTitle(title);
	
	LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor");

	if (editor)
	{
		editor->setWordWrap(TRUE);
		editor->setSourceID(item_id);
		editor->setHandleEditKeysDirectly(TRUE);
	}

	initMenu();

	gAgentCamera.changeCameraToDefault();
}
Beispiel #30
0
void Sensors::showSensorList() {
    // get http response
    auto http_response_data =
        lib::network::DataStoreSingleton::getInstance()->getResponseData(
            lib::network::DataStoreSingleton::Request_Pointcast_Home_e);

    const char* json = http_response_data.c_str();

    // JSON解析
    rapidjson::Document document;
    document.Parse<0>(json);
    if (document.HasParseError()) {
        // 解析エラー
        assert(false);
        return;
    }

    // read list view
    auto p_panel =
        this->_p_contents->getChildByName<ui::Layout*>("panelBackground");

    auto p_list_view = p_panel->getChildByName<ui::ListView*>("listSensors");
    p_list_view->setInnerContainerSize(p_list_view->getContentSize());
    p_list_view->setBounceEnabled(true);
    p_list_view->setTouchEnabled(true);

    p_list_view->addEventListener(
        [this](Ref* ref, ui::ListView::EventType eventType) {
            if (eventType == ui::ListView::EventType::ON_SELECTED_ITEM_END) {
                auto listView = static_cast<ui::ListView*>(ref);
                auto selectedIndex = listView->getCurSelectedIndex();

                // revert color all record
                for (auto widget : listView->getItems()) {
                    auto p_record = widget->getChildByTag(Tag_Id_Sensor_Record);
                    p_record->getChildByName<ui::Layout*>("panelRecord")
                        ->setColor(Color3B::WHITE);
                }
                // change color selected record
                auto widget = listView->getItem(selectedIndex);
                auto p_record = widget->getChildByTag(Tag_Id_Sensor_Record);
                p_record->getChildByName<ui::Layout*>("panelRecord")
                    ->setColor(Color3B(250, 219, 218));
                CCLOG("selected index %ld", selectedIndex);

                this->showAnalyticsDialog(widget->getTag());
            } else {
                CCLOG("touch list event type %d", eventType);
            }
        });

    std::map<int, lib::object::LocationItem> m_sensors =
        lib::network::DataStoreSingleton::getInstance()->getLocationItemAll();

    for (auto item : m_sensors) {
        auto p_record =
            CSLoader::getInstance()->createNode("res/sensors_record.csb");

        this->setMesurementData(p_record, item.second);

        auto widget = ui::Widget::create();
        p_record->setTag(Tag_Id_Sensor_Record);
        widget->addChild(p_record);
        widget->setTag(item.second.m_sensor_main_id);

        widget->setContentSize(p_record->getContentSize());
        p_list_view->pushBackCustomItem(widget);

        widget->setTouchEnabled(true);  // enable listview touch event
    }
}