void KSecretServiceTest::testCreateAndDelete() { auto collection = KSecrets::Service::findCollection( QLatin1String(TEST_CREATE_COLLECTION_NAME), KSecrets::Service::OpenOnly).result(); QCOMPARE(collection->status(), KSecrets::Collection::NotFound); collection = KSecrets::Service::findCollection( QLatin1String(TEST_CREATE_COLLECTION_NAME), KSecrets::Service::CreateCollection).result(); QCOMPARE(collection->status(), KSecrets::Collection::NewlyCreated); auto removeResult = collection->deleteCollection().result(); QVERIFY(removeResult); }
QList<QAction *> QgsOgrDataCollectionItem::actions( QWidget *parent ) { QList<QAction *> lst = QgsDataCollectionItem::actions( parent ); const bool isFolder = QFileInfo( mPath ).isDir(); // Messages are different for files and tables QString message = QObject::tr( "Delete %1 “%2”…" ).arg( isFolder ? tr( "Folder" ) : tr( "File" ), mName ); QAction *actionDeleteLayer = new QAction( message, parent ); // IMPORTANT - we need to capture the stuff we need, and then hand the slot // off to a static method. This is because it's possible for this item // to be deleted in the background on us (e.g. by a parent directory refresh) const QString path = mPath; QPointer< QgsDataItem > parentItem( mParent ); connect( actionDeleteLayer, &QAction::triggered, this, [ path, parentItem ] { deleteCollection( path, parentItem ); } ); lst.append( actionDeleteLayer ); return lst; }
CollectionDialog::CollectionDialog(SLManager *slm,int selC,QWidget *parent,const char *name) : QDialog(parent,name,TRUE) { setCaption(i18n("Collections Manager")); ok=new KPushButton(KStdGuiItem::ok(),this); ok->setGeometry(140,200,100,30); connect(ok,SIGNAL(clicked()),SLOT(accept()) ); cancel=new KPushButton(KStdGuiItem::cancel(),this); cancel->setGeometry(250,200,100,30); connect(cancel,SIGNAL(clicked()),SLOT(reject()) ); label=new QLabel(i18n("Available collections:"),this); label->adjustSize(); label->move(10,10); collections=new QListBox(this,"collectionlist"); collections->setGeometry(10,20+label->height(),340,90); connect(collections,SIGNAL(highlighted(int)),SLOT(collectionselected(int))); connect(collections,SIGNAL(selected(int)),SLOT(changeCollectionName(int))); slman=slm; for (int i=0;i<=slman->numberOfCollections();i++) { collections->insertItem(i18n( slman->getCollectionName(i) ),i); #ifdef COLLECTDLGDEBUG printf("Name : %s\n",slman->getCollectionName(i)); #endif }; selectedC=selC; #ifdef COLLECTDLGDEBUG printf("selectedC : %d\n",selectedC); #endif label2=new QLabel(i18n("Songs in selected collection:"),this); label2->adjustSize(); label2->move(10,collections->y()+collections->height()+10); songs=new QListBox(this,"songlist"); songs->setGeometry(10,label2->y()+label2->height()+10,340,120); connect(songs,SIGNAL(highlighted(int)),SLOT(songselected(int))); currentsl=slman->getCollection(selectedC); if (slman->numberOfCollections()>0) { collections->setCurrentItem(selectedC); collections->centerCurrentItem(); }; //fillInSongList(); newC=new QPushButton(i18n("&New..."),this); newC->adjustSize(); newC->move(360,collections->y()+5); connect(newC,SIGNAL(clicked()),SLOT(newCollection()) ); copyC=new QPushButton(i18n("&Copy..."),this); copyC->adjustSize(); copyC->move(360,newC->y()+newC->height()+5); connect(copyC,SIGNAL(clicked()),SLOT(copyCollection()) ); deleteC=new QPushButton(i18n("Delete"),this); deleteC->adjustSize(); deleteC->move(360,copyC->y()+copyC->height()+5); connect(deleteC,SIGNAL(clicked()),SLOT(deleteCollection()) ); addS=new QPushButton(i18n("&Add..."),this); addS->adjustSize(); addS->move(360,songs->y()+5); connect(addS,SIGNAL(clicked()),SLOT(addSong()) ); delS=new QPushButton(i18n("&Remove"),this); delS->adjustSize(); delS->move(360,addS->y()+addS->height()+5); connect(delS,SIGNAL(clicked()),SLOT(removeSong()) ); ok->move(ok->x(),songs->y()+songs->height()+10); cancel->move(ok->x()+ok->width()+5,ok->y()); setMinimumSize(400,ok->y()+ok->height()+5); //setMaximumSize(360,240); }
void CollectionListView::deleteCollectionActionTriggered() { deleteCollection(); }