void cdwChangeAccess(char *chmodString, char *rqlWhere) /* cdwChangeAccess - Change access to files.. */ { char cWhere, cDir, cAccess; parseChmodString(chmodString, &cWhere, &cDir, &cAccess); /* Get list of all stanzas matching query */ struct sqlConnection *conn = cdwConnectReadWrite(); struct tagStorm *tags = cdwTagStorm(conn); struct dyString *rqlQuery = dyStringNew(0); dyStringPrintf(rqlQuery, "select accession from cdwFileTags where accession and %s", rqlWhere); struct slRef *ref, *matchRefList = tagStanzasMatchingQuery(tags, rqlQuery->string); /* Make one pass through mostly for early error reporting and building up * hash of cdwValidFiles keyed by accession */ struct hash *validHash = hashNew(0); for (ref = matchRefList; ref != NULL; ref = ref->next) { struct tagStanza *stanza = ref->val; char *acc = tagFindVal(stanza, "accession"); if (acc != NULL) { struct cdwValidFile *vf = cdwValidFileFromLicensePlate(conn, acc); if (vf == NULL) errAbort("%s not found in cdwValidFile", acc); hashAdd(validHash, acc, vf); } } /* Second pass through matching list we call routine that actually adds * the group/file relationship. */ for (ref = matchRefList; ref != NULL; ref = ref->next) { struct tagStanza *stanza = ref->val; char *acc = tagFindVal(stanza, "accession"); if (acc != NULL) { struct cdwValidFile *vf = hashFindVal(validHash, acc); if (vf != NULL) { changeAccess(conn, vf->fileId, cWhere, cDir, cAccess); } } } }
MembersDialog::MembersDialog( int projectId ) : InformationDialog( NULL, Qt::Window ), m_projectId( projectId ) { ProjectEntity project = ProjectEntity::find( projectId ); QAction* action; action = new QAction( IconLoader::icon( "user-new" ), tr( "&Add Members..." ), this ); action->setShortcut( QKeySequence::New ); connect( action, SIGNAL( triggered() ), this, SLOT( addMember() ) ); setAction( "addMember", action ); action = new QAction( IconLoader::icon( "edit-access" ), tr( "&Change Access..." ), this ); connect( action, SIGNAL( triggered() ), this, SLOT( changeAccess() ) ); setAction( "changeAccess", action ); action = new QAction( IconLoader::icon( "edit-delete" ), tr( "&Remove Members" ), this ); action->setShortcut( QKeySequence::Delete ); connect( action, SIGNAL( triggered() ), this, SLOT( removeMember() ) ); setAction( "removeMember", action ); setDefaultMenuAction( "menuMember", "changeAccess" ); loadXmlUiFile( ":/resources/membersdialog.xml" ); XmlUi::Builder* builder = new XmlUi::Builder( this ); builder->addClient( this ); setWindowTitle( tr( "Manage Permissions" ) ); setPromptPixmap( IconLoader::pixmap( "edit-access", 22 ) ); setPrompt( tr( "Edit permissions of project <b>%1</b>:" ).arg( project.name() ) ); QVBoxLayout* layout = new QVBoxLayout(); QGroupBox* globalGroup = new QGroupBox( tr( "Global Access" ), this ); layout->addWidget( globalGroup ); QHBoxLayout* globalLayout = new QHBoxLayout( globalGroup ); m_globalEdit = new QLineEdit( globalGroup ); m_globalEdit->setReadOnly( true ); globalLayout->addWidget( m_globalEdit ); QPushButton* globalButton = new QPushButton( tr( "Change..." ), globalGroup ); globalButton->setIcon( IconLoader::icon( "edit-modify" ) ); globalButton->setIconSize( QSize( 16, 16 ) ); globalLayout->addWidget( globalButton ); connect( globalButton, SIGNAL( clicked() ), this, SLOT( changeGlobalAccess() ) ); layout->addSpacing( 5 ); QVBoxLayout* membersLayout = new QVBoxLayout(); membersLayout->setSpacing( 4 ); layout->addLayout( membersLayout ); XmlUi::ToolStrip* strip = new XmlUi::ToolStrip( this ); builder->registerToolStrip( "stripMembers", strip ); membersLayout->addWidget( strip ); m_list = new QTreeView( this ); membersLayout->addWidget( m_list ); TreeViewHelper helper( m_list ); helper.initializeView( TreeViewHelper::MultiSelect ); m_list->sortByColumn( 0, Qt::AscendingOrder ); m_model = new MembersModel( projectId, this ); m_list->setModel( m_model ); helper.loadColumnWidths( "MembersDialogWidths", QList<int>() << 150 << 150 ); connect( m_list->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( updateActions() ) ); connect( m_list, SIGNAL( doubleClicked( const QModelIndex& ) ), this, SLOT( doubleClicked( const QModelIndex& ) ) ); connect( m_list, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( listContextMenu( const QPoint& ) ) ); connect( m_model, SIGNAL( layoutChanged() ), this, SLOT( updateActions() ) ); connect( m_model, SIGNAL( modelReset() ), this, SLOT( updateActions() ) ); setContentLayout( layout, false ); resize( 350, 450 ); dataManager->addObserver( this ); updateGlobalAccess(); updateActions(); }