void MigrateStandaloneTask::doTask() { auto wildc = gcRefPtr<WildcardManager>::create(); wildc->onNeedSpecialEvent += delegate(&getUserCore()->getNeedWildCardEvent()); for (size_t x=0; x<m_vFileList.size(); x++) { AutoDelFile adf(m_vFileList[x]); XML::gcXMLDocument doc(m_vFileList[x].getFullPath().c_str()); if (!doc.IsValid()) continue; auto root = doc.GetRoot("game"); if (!root.IsValid()) continue; gcString path; gcString id; uint32 branch = -1; uint32 build = -1; root.GetChild("path", path); root.GetChild("id", id); root.GetChild("branch", branch); root.GetChild("build", build); if (id == "" || !UTIL::FS::isValidFolder(path)) continue; DesuraId itemId(id.c_str(), "games"); auto info = getUserCore()->getItemManager()->findItemInfo(itemId); if (!info || info->isInstalled()) continue; try { getUserCore()->getCIPManager()->updateItem(itemId, path); getUserCore()->getItemManager()->retrieveItemInfo(getItemId(), 0, wildc); } catch (...) { continue; } info = getUserCore()->getItemManager()->findItemInfo(itemId); auto realInfo = gcRefPtr<UserCore::Item::ItemInfo>::dyn_cast(info); if (!realInfo) continue; realInfo->migrateStandalone(MCFBranch::BranchFromInt(branch), MCFBuild::BuildFromInt(build)); } }
void Input::changeSelection(QModelIndex _index) { if (!dataModel() || this->isLocked()) return; int _row = _index.row(); if (_row < 1 || _row > dataModel()->inputs().numberOfChildren()) { _row = -1; } if (itemId(_row) == dataModel()->inputs().currentId()) return; selectInputId(itemId(_row)); showParameterWidget(); emit inputIndexChanged(); }
void KAction::updateToolTip( int i ) { QWidget *w = container( i ); if ( ::qt_cast<KToolBar *>( w ) ) QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); }
QVariant ThumbnailModel::data(const QModelIndex &index, int role) const { if (role == Qt::DecorationRole && index.isValid()) { QString id = itemId(index).toString(); QFutureWatcher<QImage> *future = cache.object(id); if (!future) { future = new QFutureWatcher<QImage>; QString path = imagePath(index); if (!path.isEmpty()) { future->setFuture(QtConcurrent::run(ThumbnailModel::load, path)); connect(future, SIGNAL(finished()), this, SLOT(thumbnailLoaded())); } cache.insert(id, future); } return !future->isCanceled() ? future->result() : QVariant(); } else { return QGalleryQueryModel::data(index, role); } }
//------------------------------------------------------------------------------ //! bool ComboBox::performSet( VMState* vm ) { switch( _attributes[ VM::toCString( vm, 2 ) ] ) { case ATTRIB_ITEM_ID: itemId( VM::toCString( vm, 3 ) ); return true; case ATTRIB_ITEM: // Read only. return true; case ATTRIB_ONITEM_CHANGED: VM::toRef( vm, 3, _onItemChangedRef ); return true; case ATTRIB_MENU_ABOVE: _menuAbove = VM::toBoolean( vm, 3 ); return true; case ATTRIB_MENU_OFFSET: _offset = VM::toVec2f( vm, 3 ); return true; case ATTRIB_OPENED: return false; default: break; } return Widget::performSet( vm ); }
ScriptItem::ScriptItem(const openstudio::path& path, OSItemType type, QWidget * parent) : OSItem(scriptToItemId(path), type, parent), m_removed(false), m_scriptInfo(path, true, false) { setText(openstudio::toQString(path.filename())); setLeftPixmap(QPixmap(":/images/icon_scripts.png")); if (boost::regex_search(toString(itemId().sourceId()),boost::regex("resource"))) { m_scriptInfo.isUserScript = false; } else { try { m_scriptInfo = runmanager::RubyJobBuilder::updateArgumentsFromDb(m_scriptInfo); } catch (const runmanager::ScriptDetectionError &e) { // Nothing to display here in the constructor m_scriptInfo = e.scriptInfo; } } std::shared_ptr<OSDocument> osDoc = OSAppBase::instance()->currentDocument(); connect(this, &ScriptItem::argChanged, osDoc.get(), &OSDocument::markAsModified); }
void MLModel::doDelete( QModelIndexList list ) { for (int i = 0; i < list.count(); ++i) { int id = itemId( list.at(i) ); ml_DeleteSimple( p_ml, id ); } }
bool ScriptItem::equal(const openstudio::OSItem* otherItem) const { if (otherItem) { return otherItem->itemId() == itemId(); } return false; }
void MLModel::doDelete( QModelIndexList list ) { for (int i = 0; i < list.count(); ++i) { const QModelIndex &index = list.at( i ); if ( !index.isValid() ) break; int id = itemId( list.at(i), MLMEDIA_ID ); ml_DeleteSimple( p_ml, id ); /* row will be removed by the lib callback */ } }
void KAction::updateShortcut( int i ) { int id = itemId( i ); QWidget* w = container( i ); if ( ::qt_cast<QPopupMenu *>( w ) ) { QPopupMenu* menu = static_cast<QPopupMenu*>(w); updateShortcut( menu, id ); } else if ( ::qt_cast<QMenuBar *>( w ) ) static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id ); }
bool BCLComponentItem::equal(const openstudio::OSItem * item) const { if( item->itemId().sourceId() == OSItemId::BCL_SOURCE_ID ) { if( item->itemId().itemId() == itemId().itemId() ) { return true; } } return false; }
void TKAction::updateLayout() { int len = containerCount(); for( int id = 0; id < len; ++id ) { QWidget* w = container( id ); if (w->inherits("KToolBar")) { QWidget* r = static_cast<KToolBar*>(w)->getWidget(itemId(id)); if (qstrcmp(r->name(),"KTToolBarLayout")==0) { updateLayout(r); } } } }
void PMSpinBoxAction::unplug( QWidget *w ) { if( !w->inherits( "KToolBar" ) ) return; KToolBar *toolBar = (KToolBar *)w; int idx = findContainer( w ); toolBar->removeItem( itemId( idx ) ); removeContainer( idx ); m_spinBox = 0L; }
/*virtual*/ wxDragResult BFBackupTree::OnDragOver(wxCoord x, wxCoord y, wxDragResult def) { wxTreeItemId itemId(HitTest(wxPoint(x, y))); // clean all selections UnselectAll(); // is an item selected? if ( itemId.IsOk() ) { bool bSelect = false; // get the task behind the item BFTask* pTask = GetTaskByItem(itemId); if (pTask) { if ( pTask->GetType() == TaskDIRCOPY ) bSelect = true; } if (!bSelect) { // get the imageId of the selected item int iImageId(GetItemImage(itemId)); // identify the item if (iImageId == BFIconTable::folder || iImageId == BFIconTable::folder_open || iImageId == BFIconTable::folder_virtual || iImageId == BFIconTable::folder_virtual_open || iImageId == BFIconTable::volume_harddisk || iImageId == BFIconTable::volume_cdrom || iImageId == BFIconTable::volume_floppy || iImageId == BFIconTable::volume_removable) { bSelect = true; } } if (bSelect) { // select it if it is not if (GetSelection() != itemId) SelectItem( itemId ); } } return def; }
void cMenuFileBrowserBase::RefreshIfDirty() { if(!HasSubMenu()) { if(dirty_) { if(!hidden) { Refresh(itemId(), true); } dirty_ = false; } } else { dirty_ = true; } }
void PMLabelAction::unplug( QWidget *widget ) { if( widget->inherits( "KToolBar" ) ) { KToolBar* bar = ( KToolBar* ) widget; int idx = findContainer( bar ); if( idx != -1 ) { bar->removeItem( itemId( idx ) ); removeContainer( idx ); } m_button = 0; return; } }
bool KAction::isPlugged( const QWidget *container, int id ) const { int i = findContainer( container ); return ( i > -1 && itemId( i ) == id ); }
void SyncCalendarTask::DeleteItem(const char * item_id) { nsCString itemId(item_id); if (!m_DeletedItemIds.Contains(itemId)) m_DeletedItemIds.AppendElement(itemId); }
/** Persist the items belonging to curent group into group table @param aGroup referece to a contact group */ void CPplGroupsTable::WriteGroupMembersL(const CContactItem& aGroup) { if (aGroup.Type() != KUidContactGroup) { return; } const TContactItemId KGroupId(aGroup.Id() ); // make sure we clear out any previous, out-of-date data TBool lowDiskErr(EFalse); DeleteItemL(KGroupId, lowDiskErr); if (lowDiskErr) { User::Leave(KErrDiskFull); } // build the RSqlStatement RSqlStatement stmnt; CleanupClosePushL(stmnt); stmnt.PrepareL(iDatabase, iInsertStmnt->SqlStringL() ); const TInt KGroupIdIndex(KFirstIndex); // first parameter in query... const TInt KMemberIdIndex(KGroupIdIndex + 1); // ...and the second parameter // copy and sort the member id array so we can see if there are duplicates const CContactIdArray* contactIdArray = static_cast<const CContactGroup&>(aGroup).ItemsContained(); //does not take the ownership const TInt arrayCount = contactIdArray->Count(); CArrayFixFlat<TContactItemId>* sortedList = new(ELeave) CArrayFixFlat<TContactItemId>(KArrayGranularity); CleanupStack::PushL(sortedList); for(TInt loop = 0;loop < arrayCount; ++loop) { sortedList->AppendL((*contactIdArray)[loop]); } TKeyArrayFix key(0,ECmpTInt); sortedList->Sort(key); // insert the group-member relationships const TInt KCountStmntParamIndex(KFirstIndex); // first and only parameter in query const TInt listLen(sortedList->Count() ); TInt lastId(0); for (TInt i = 0; i < listLen; ++i) { TInt itemId((*sortedList)[i]); //check if a contact item with itemId id really exists in contact database RSqlStatement countStmnt; CleanupClosePushL(countStmnt); countStmnt.PrepareL(iDatabase, iCountContactsStmnt->SqlStringL() ); User::LeaveIfError(countStmnt.BindInt(KCountStmntParamIndex, itemId) ); TInt count = 0; TInt err = KErrNone; if((err = countStmnt.Next() ) == KSqlAtRow) { count = countStmnt.ColumnInt(iCountContactsStmnt->ParameterIndex(KSqlCount) ); } else { User::LeaveIfError(err); } if(count == 0) { User::Leave(KErrNotFound); } CleanupStack::PopAndDestroy(&countStmnt); // only insert this if we haven't already seen it if (itemId != lastId || i == 0) { User::LeaveIfError(stmnt.BindInt(KGroupIdIndex, KGroupId) ); User::LeaveIfError(stmnt.BindInt(KMemberIdIndex, itemId) ); User::LeaveIfError(stmnt.Exec() ); User::LeaveIfError(stmnt.Reset() ); } lastId = itemId; } CleanupStack::PopAndDestroy(2, &stmnt); // and sortedList }
bool MLModel::action( QAction *action, const QModelIndexList &indexes ) { actionsContainerType a = action->data().value<actionsContainerType>(); input_item_t *p_input; switch ( a.action ) { case ACTION_PLAY: if ( ! indexes.empty() && indexes.first().isValid() ) { activateItem( indexes.first() ); return true; } break; case ACTION_ADDTOPLAYLIST: foreach( const QModelIndex &index, indexes ) { if( !index.isValid() ) return false; AddItemToPlaylist( itemId( index, MLMEDIA_ID ), false, p_ml, true ); } return true; case ACTION_REMOVE: doDelete( indexes ); return true; case ACTION_SORT: break; case ACTION_CLEAR: removeAll(); return true; case ACTION_ENQUEUEFILE: foreach( const QString &uri, a.uris ) playlist_Add( THEPL, uri.toAscii().constData(), NULL, PLAYLIST_APPEND | PLAYLIST_PREPARSE, PLAYLIST_END, false, pl_Unlocked ); return true; case ACTION_ENQUEUEDIR: if( a.uris.isEmpty() ) return false; p_input = input_item_New( a.uris.first().toAscii().constData(), NULL ); if( unlikely( p_input == NULL ) ) return false; /* FIXME: playlist_AddInput() can fail */ playlist_AddInput( THEPL, p_input, PLAYLIST_APPEND, PLAYLIST_END, true, pl_Unlocked ); vlc_gc_decref( p_input ); return true; case ACTION_ENQUEUEGENERIC: foreach( const QString &uri, a.uris ) { p_input = input_item_New( qtu( uri ), NULL ); /* Insert options */ foreach( const QString &option, a.options.split( " :" ) ) { QString temp = colon_unescape( option ); if( !temp.isEmpty() ) input_item_AddOption( p_input, qtu( temp ), VLC_INPUT_OPTION_TRUSTED ); } /* FIXME: playlist_AddInput() can fail */ playlist_AddInput( THEPL, p_input, PLAYLIST_APPEND | PLAYLIST_PREPARSE, PLAYLIST_END, false, pl_Unlocked ); vlc_gc_decref( p_input ); } return true; default: break; } return false; }
void MLModel::activateItem( const QModelIndex &idx ) { if( !idx.isValid() ) return; AddItemToPlaylist( itemId( idx, MLMEDIA_ID ), true, p_ml, true ); }
OSItemId bclComponentToItemId(const openstudio::BCLComponent & component) { OSItemId itemId(QString::fromStdString(component.uid()),OSItemId::BCL_SOURCE_ID,false); return itemId; }