Source Code (Use browser search to find items of interest.)

Class Index

kmid'CollectionDialog (./kdemultimedia/kmid/collectdlg.h:34)

class CollectionDialog : public QDialog
{
	Q_OBJECT
private:
	SLManager *slman;
	SongList *currentsl;

protected:

	virtual void resizeEvent(QResizeEvent *qre);
	void fillInSongList(void); //clear the songs list and insert in it
				// the songs in currentsl
public:

	CollectionDialog(SLManager *slm,int selc,QWidget *parent,const char *name);

public slots:
	void collectionselected(int idx);
	void songselected(int idx);
	void newCollection();
	void copyCollection();
	void deleteCollection();
	void changeCollectionName(int idx);
	void addSong();
	void removeSong();

private:
QLabel *label;
QLabel *label2;
QPushButton *ok;
QPushButton *cancel;
QListBox *collections;
QListBox *songs;
QPushButton *newC;
QPushButton *copyC;
QPushButton *deleteC;
QPushButton *addS;
QPushButton *delS;


public:
static int selectedC;
static int selectedS;

};

kmid'CollectionDialog::CollectionDialog() (./kdemultimedia/kmid/collectdlg.cpp:40)

CollectionDialog::CollectionDialog(SLManager *slm,int selC,QWidget *parent,const char *name) : QDialog(parent,name,TRUE)
{
setCaption(i18n("Collections Manager"));
ok=new QPushButton(i18n("OK"),this);
ok->setGeometry(140,200,100,30);
connect(ok,SIGNAL(clicked()),SLOT(accept()) );
cancel=new QPushButton(i18n("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(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);
};


kmid'CollectionDialog::collectionselected() (./kdemultimedia/kmid/collectdlg.cpp:113)

void CollectionDialog::collectionselected(int idx)
{
selectedC=idx;
#ifdef COLLECTDLGDEBUG
printf("Selected collection : %d\n",selectedC);
#endif
currentsl=slman->getCollection(selectedC);
fillInSongList();
};


kmid'CollectionDialog::fillInSongList() (./kdemultimedia/kmid/collectdlg.cpp:123)

void CollectionDialog::fillInSongList(void)
{
QString qs;
songs->clear();
if (currentsl!=NULL)
   {
   currentsl->iteratorStart();
   int i=0;
   while (!currentsl->iteratorAtEnd())
       {
       qs=QString(currentsl->getIteratorName());
       KURL::decode(qs);	
       songs->insertItem(qs,i);
       currentsl->iteratorNext();
       i++;    
       };
   songs->setCurrentItem(currentsl->getActiveSongID()-1);
   songs->centerCurrentItem();
   };
};


kmid'CollectionDialog::songselected() (./kdemultimedia/kmid/collectdlg.cpp:144)

void CollectionDialog::songselected(int idx)
{
selectedS=idx;
currentsl->setActiveSong(idx+1);

#ifdef COLLECTDLGDEBUG
printf("Selected song : %d\n",selectedS);
#endif
};


kmid'CollectionDialog::newCollection() (./kdemultimedia/kmid/collectdlg.cpp:154)

void CollectionDialog::newCollection()
{
KAskDialog *dlg;
dlg=new KAskDialog(i18n("Enter the name of the new collection"),
			i18n("New Collection"),this,"kask");
if (dlg->exec()==QDialog::Accepted)
   {
   int i=slman->createCollection(KAskDialog::getResult().ascii());
   if (i==-1)
	{
	QString s = i18n("The name '%1' is already used")
			.arg(KAskDialog::getResult());
	KMessageBox::sorry(this, s);
	}
	else
	{
	collections->insertItem(KAskDialog::getResult(),i);
	collections->setCurrentItem(i);
        collections->centerCurrentItem();
	};
   };
};


kmid'CollectionDialog::copyCollection() (./kdemultimedia/kmid/collectdlg.cpp:177)

void CollectionDialog::copyCollection()
{
SongList *src=currentsl;
KAskDialog *dlg;
int i;
dlg=new KAskDialog(i18n("Enter the name of the copy collection"),
			i18n("Copy Collection"),this,"kask");
if (dlg->exec()==QDialog::Accepted)
   {
   i=slman->createCollection(KAskDialog::getResult().ascii());
   if (i==-1)
	{
	QString s = i18n("The name '%1' is already used")
			.arg(KAskDialog::getResult());
	KMessageBox::sorry(this, s);
	}
	else
	{
	collections->insertItem(KAskDialog::getResult(),i);
	SongList *tgt=slman->getCollection(i);
	src->iteratorStart();
	while (!src->iteratorAtEnd())
	   {
	   tgt->AddSong(src->getIteratorName());
	   src->iteratorNext();
	   };
	collections->setCurrentItem(i);
        collections->centerCurrentItem();
	};
   };
};


kmid'CollectionDialog::deleteCollection() (./kdemultimedia/kmid/collectdlg.cpp:209)

void CollectionDialog::deleteCollection()
{
if (selectedC==0) return;
slman->deleteCollection(selectedC);
int i=selectedC;
collections->removeItem(selectedC);
collections->setCurrentItem(i);
collections->centerCurrentItem();
};


kmid'CollectionDialog::changeCollectionName() (./kdemultimedia/kmid/collectdlg.cpp:219)

void CollectionDialog::changeCollectionName(int idx)
{
if (idx==0) return;
KAskDialog *dlg;
dlg=new KAskDialog(i18n("Enter the new name for the selected collection"),
			i18n("Change Collection Name"),this,"kask");
if (dlg->exec()==QDialog::Accepted)
   {
   if (slman->getCollection(KAskDialog::getResult().ascii())!=NULL)
	{
	QString s = i18n("The name '%1' is already used")
			.arg(KAskDialog::getResult());
	KMessageBox::sorry(this, s);
	}
	else
	{
	slman->changeCollectionName(idx,KAskDialog::getResult().ascii());
	collections->changeItem(KAskDialog::getResult(),idx);
	};
   };
};


kmid'CollectionDialog::addSong() (./kdemultimedia/kmid/collectdlg.cpp:241)

void CollectionDialog::addSong()
{
  if (currentsl==NULL) return;

  KURL url = KFileDialog::getOpenURL(QString::null,"*.kar *.mid",this);

  if( url.isEmpty())
    return;

  if( !url.isLocalFile() )
  {
    KMessageBox::sorry( 0L, i18n( "Only local files are supported yet." ) );
    return;
  }

  QString filename = url.path();

  int id=currentsl->AddSong(filename.ascii());

  if (id==-1)
  {
    printf("Couldn't add song to collection\n");
    return;
  };

  songs->insertItem(filename.ascii(),id-1);
};


kmid'CollectionDialog::removeSong() (./kdemultimedia/kmid/collectdlg.cpp:269)

void CollectionDialog::removeSong()
{
if (currentsl==NULL) return;
currentsl->DelSong(selectedS+1);
int i=selectedS;
songs->removeItem(selectedS);
songs->setCurrentItem(i);
};


kmid'CollectionDialog::resizeEvent() (./kdemultimedia/kmid/collectdlg.cpp:278)

void CollectionDialog::resizeEvent(QResizeEvent *)
{
int maxw=newC->width();
if (copyC->width()>maxw) maxw=copyC->width();
if (deleteC->width()>maxw) maxw=deleteC->width();
if (addS->width()>maxw) maxw=addS->width();
if (delS->width()>maxw) maxw=delS->width();

newC->setGeometry(width()-maxw-5,newC->y(),maxw,newC->height());
copyC->setGeometry(width()-maxw-5,copyC->y(),maxw,copyC->height());
deleteC->setGeometry(width()-maxw-5,deleteC->y(),maxw,deleteC->height());

collections->resize(width()-maxw-20,(height()*35)/100);
label2->move(10,collections->y()+collections->height()+10);
songs->setGeometry(10,label2->y()+label2->height()+10,width()-maxw-20,height()-(label2->y()+label2->height()+10+ok->height()+10));
addS->setGeometry(width()-maxw-5,songs->y()+5,maxw,addS->height());
delS->setGeometry(width()-maxw-5,addS->y()+addS->height()+5,maxw,delS->height());

cancel->move(width()-cancel->width()-5,height()-cancel->height()-5);
ok->move(cancel->x()-5-ok->width(),height()-ok->height()-5);
};