* updated Library Dialog

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@708 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2008-08-27 08:41:43 +00:00
parent d62876ae37
commit 1bc0cf6bf3
4 changed files with 139 additions and 19 deletions

View File

@ -71,14 +71,8 @@ LibraryDialog::LibraryDialog(QWidget *parent)
PopulateList();
QDirModel * dmodel=new QDirModel(this);
ui.organizertreeView->setModel(dmodel);
ui.organizerListView->setModel(dmodel);
ui.organizerListView->setSpacing(10);
QDir retroshareLib;
retroshareLib.mkdir("RetroShare Library");
connect(ui.organizerListView, SIGNAL(rightButtonClicked(QModelIndex,QPoint)), this, SLOT(ListLibrarymenu(QModelIndex,QPoint)));
connect(ui.shareFiles_btn,SIGNAL(clicked()),this, SLOT(CallShareFilesBtn_library()));
connect(ui.tileView_btn_library,SIGNAL(clicked()),this, SLOT(CallTileViewBtn_library()));
@ -100,16 +94,89 @@ LibraryDialog::LibraryDialog(QWidget *parent)
#endif
}
void LibraryDialog::PopulateList()
{
QDir dir;
QString libPath;
QDir DwnlFolder,ShrFolder,retroshareLib,treePath;
retroshareLib.mkdir("RetroShare Library");
DwnlFolder.mkdir("RetroShare Library/Download");
ShrFolder.mkdir("RetroShare Library/SharedFolder");
LibShared=treePath.currentPath();
LibShared.append("/RetroShare Library");
QDirModel * dmodel=new QDirModel;
ui.organizertreeView->setModel(dmodel);
ui.organizertreeView->setRootIndex(dmodel->index(LibShared));
ui.organizerListView->setModel(dmodel);
ui.organizerListView->setViewMode(QListView::ListMode);
ui.organizerListView->setWordWrap (true);
QDirModel *dirmodel=new QDirModel(this);
//ui.organizertreeView->setModel(dirmodel);
libPath=dir.currentPath();
//QModelIndex cmodel=dirmodel->index(QDir::rootPath());
//ui.organizertreeView->setRootIndex(cmodel);
}
void LibraryDialog::ListLibrarymenu(QModelIndex index,QPoint pos)
{
ind=index;
if(index.isValid())
{
bool indexselected=true;
QMenu rmenu(this);
rmenu.move(pos);
if(indexselected)
rmenu.addAction(QIcon(""),tr("Play"), this, SLOT(PlayFrmList()));
if(indexselected)
rmenu.addAction(QIcon(""),tr("Copy"), this, SLOT(copyFile()));
if(indexselected)
rmenu.addAction(QIcon(""),tr("Delete"), this, SLOT(DeleteFile()));
if(indexselected)
rmenu.addAction(QIcon(""),tr("Rename"), this, SLOT(RenameFile()));
rmenu.exec();
}
else
return;
}
void LibraryDialog::PlayFrmList()
{
QDirModel *dmodel=new QDirModel;
QModelIndex parentIndex = dmodel->index(LibShared+"/Download");
QModelIndex index = dmodel->index(ind.row(), 0, parentIndex);
QString text = dmodel->data(index, Qt::DisplayRole).toString();
filechose.clear();
QDir dir;
filechose.append(LibShared+"/Download/");
filechose.append(text);
if(filechose.contains("avi")|| filechose.contains("MP3")||filechose.contains("mp3")|| filechose.contains("wmv")||filechose.contains("wav")|| filechose.contains("dat")|| filechose.contains("mov")|| filechose.contains("mpeg")|| filechose.contains("mpg"))
{
player();
}
else
QMessageBox::information(this,"Information", "Not Supported By the Player");
}
void LibraryDialog::copyFile()
{
}
void LibraryDialog::DeleteFile()
{
}
void LibraryDialog::RenameFile()
{
ui.organizerListView->openPersistentEditor (ind);
progtime=new QTimer(this);
progtime->start(100000);
connect(progtime, SIGNAL(timeout()), this, SLOT(StopRename()));
}
void LibraryDialog::StopRename()
{
ui.organizerListView->closePersistentEditor(ind);
progtime->stop();
}
@ -151,3 +218,25 @@ void LibraryDialog::CallFindBtn_library()
FindWindow *files = new FindWindow(this);
files->show();
}
void LibraryDialog:: player()
{
QString avi;
avi.append(filechose);
QStringList argu;
QString smlayer="./smplayer";
argu<<avi;
QProcess *retroshareplayer=new QProcess(this);
retroshareplayer->start(smlayer,argu);
}
void LibraryDialog::browseFile()
{
QDir dir;
QString pathseted =dir.currentPath();
pathseted.append("/RetroShare Library/Download");
filechose = QFileDialog::getOpenFileName(this, tr("Open File..."),
pathseted, tr("Media-Files (*.avi *.mp3 *.wmv *.wav *.dat *.mov *.mpeg);;All Files (*)"));
//movieEdit->setText(filechose);
}

View File

@ -42,9 +42,11 @@ public:
/** Default Destructor */
QString filePass();
QString LibShared;
QString filechose;
QModelIndex ind;
private slots:
void PopulateList();
@ -54,14 +56,23 @@ private slots:
void CallCreateAlbumBtn_library();
void CallDeleteAlbumBtn_library();
void CallFindBtn_library();
void browseFile();
void player();
void ListLibrarymenu(QModelIndex,QPoint);
void PlayFrmList();
void copyFile();
void DeleteFile();
void RenameFile();
void StopRename();
signals:
void rightButtonClicked(const QModelIndex , const QPoint);
private:
QTimer *progtime;
/** Qt Designer generated object */

View File

@ -526,6 +526,9 @@
</item>
<item row="1" column="1" colspan="4" >
<widget class="QListView" name="organizerListView" >
<property name="contextMenuPolicy" >
<enum>Qt::DefaultContextMenu</enum>
</property>
<property name="movement" >
<enum>QListView::Free</enum>
</property>
@ -675,9 +678,9 @@
<connections>
<connection>
<sender>organizertreeView</sender>
<signal>clicked(QModelIndex)</signal>
<signal>doubleClicked(QModelIndex)</signal>
<receiver>organizerListView</receiver>
<slot>setCurrentIndex(QModelIndex)</slot>
<slot>setRootIndex(QModelIndex)</slot>
<hints>
<hint type="sourcelabel" >
<x>139</x>

View File

@ -53,6 +53,9 @@
<property name="toolTip" >
<string>Remove Item</string>
</property>
<property name="styleSheet" >
<string notr="true" />
</property>
<property name="text" >
<string/>
</property>
@ -93,6 +96,9 @@
<bold>true</bold>
</font>
</property>
<property name="styleSheet" >
<string notr="true" />
</property>
<property name="text" >
<string>Connected</string>
</property>
@ -116,6 +122,9 @@
</item>
<item>
<widget class="QLabel" name="nameLabel" >
<property name="styleSheet" >
<string notr="true" />
</property>
<property name="text" >
<string>name</string>
</property>
@ -214,6 +223,10 @@
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="iconLabel" >
<property name="styleSheet" >
<string notr="true" > background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 lightgray, stop:1 darkgray);</string>
</property>
<property name="text" >
<string/>
</property>
@ -230,6 +243,10 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet" >
<string notr="true" > background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 lightgray, stop:1 darkgray);</string>
</property>
<property name="text" >
<string>Description
of Forum</string>