2008-08-19 18:08:48 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008, defnax
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2009-02-02 07:07:07 -05:00
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include "rshare.h"
|
|
|
|
#include "LibraryDialog.h"
|
2008-08-19 18:08:48 -04:00
|
|
|
|
|
|
|
#include "rsiface/rsiface.h"
|
|
|
|
#include "rsiface/rspeers.h"
|
|
|
|
#include "rsiface/rsfiles.h"
|
|
|
|
#include "rsiface/RemoteDirModel.h"
|
2009-02-02 07:07:07 -05:00
|
|
|
#include "ShareManager.h"
|
|
|
|
|
2008-08-19 18:08:48 -04:00
|
|
|
|
|
|
|
#include "util/RsAction.h"
|
|
|
|
#include "msgs/ChanMsgDialog.h"
|
2008-08-20 17:39:03 -04:00
|
|
|
#include "library/FindWindow.h"
|
2008-08-19 18:08:48 -04:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#include <QtGui>
|
|
|
|
#include <QContextMenuEvent>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QCursor>
|
|
|
|
#include <QPoint>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QHeaderView>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QMovie>
|
|
|
|
#include <QLabel>
|
|
|
|
|
|
|
|
/* Images for context menu icons */
|
|
|
|
#define IMAGE_DOWNLOAD ":/images/download16.png"
|
2009-02-02 07:07:07 -05:00
|
|
|
#define IMAGE_PLAY ":/images/start.png"
|
2008-08-19 18:08:48 -04:00
|
|
|
#define IMAGE_HASH_BUSY ":/images/settings.png"
|
|
|
|
#define IMAGE_HASH_DONE ":/images/friendsfolder24.png"
|
|
|
|
#define IMAGE_MSG ":/images/message-mail.png"
|
|
|
|
#define IMAGE_ATTACHMENT ":/images/attachment.png"
|
|
|
|
#define IMAGE_FRIEND ":/images/peers_16x16.png"
|
|
|
|
#define IMAGE_PROGRESS ":/images/browse-looking.gif"
|
|
|
|
#define IMAGE_LIBRARY ":/images/library.png"
|
|
|
|
|
2008-08-20 17:39:03 -04:00
|
|
|
QString fileToFind;
|
|
|
|
|
2009-02-02 07:07:07 -05:00
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
LibraryDialog::LibraryDialog(QWidget *parent)
|
|
|
|
: MainPage(parent)
|
|
|
|
{
|
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
2008-08-19 18:08:48 -04:00
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
|
|
|
|
PopulateList();
|
|
|
|
|
2008-08-27 04:41:43 -04:00
|
|
|
connect(ui.organizerListView, SIGNAL(rightButtonClicked(QModelIndex,QPoint)), this, SLOT(ListLibrarymenu(QModelIndex,QPoint)));
|
2008-08-19 18:08:48 -04:00
|
|
|
|
|
|
|
connect(ui.shareFiles_btn,SIGNAL(clicked()),this, SLOT(CallShareFilesBtn_library()));
|
|
|
|
connect(ui.tileView_btn_library,SIGNAL(clicked()),this, SLOT(CallTileViewBtn_library()));
|
|
|
|
connect(ui.showDetails_btn_library,SIGNAL(clicked()),this, SLOT(CallShowDetailsBtn_library()));
|
|
|
|
connect(ui.createAlbum_btn_library,SIGNAL(clicked()),this, SLOT(CallCreateAlbumBtn_library()));
|
|
|
|
connect(ui.deleteAlbum_btn_library,SIGNAL(clicked()),this, SLOT(CallDeleteAlbumBtn_library()));
|
|
|
|
connect(ui.find_btn_library,SIGNAL(clicked()),this, SLOT(CallFindBtn_library()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QTimer *timer = new QTimer(this);
|
|
|
|
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
|
|
|
|
timer->start(1000);
|
|
|
|
|
2009-02-02 07:07:07 -05:00
|
|
|
/* Hide platform specific features */
|
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
2008-08-19 18:08:48 -04:00
|
|
|
|
2008-08-27 04:41:43 -04:00
|
|
|
|
2008-08-19 18:08:48 -04:00
|
|
|
void LibraryDialog::PopulateList()
|
|
|
|
{
|
2008-08-27 04:41:43 -04:00
|
|
|
QDir DwnlFolder,ShrFolder,retroshareLib,treePath;
|
2008-11-27 16:26:52 -05:00
|
|
|
|
|
|
|
#if 0
|
2008-08-27 04:41:43 -04:00
|
|
|
retroshareLib.mkdir("RetroShare Library");
|
|
|
|
DwnlFolder.mkdir("RetroShare Library/Download");
|
|
|
|
ShrFolder.mkdir("RetroShare Library/SharedFolder");
|
|
|
|
LibShared=treePath.currentPath();
|
|
|
|
LibShared.append("/RetroShare Library");
|
2008-11-27 16:26:52 -05:00
|
|
|
#else
|
|
|
|
LibShared=treePath.currentPath();
|
|
|
|
#endif
|
|
|
|
|
2008-08-27 04:41:43 -04:00
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
2008-08-19 18:08:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LibraryDialog::CallShareFilesBtn_library()
|
|
|
|
{
|
2009-02-02 07:07:07 -05:00
|
|
|
static ShareManager* sharemanager = new ShareManager(this);
|
|
|
|
sharemanager->show();
|
|
|
|
|
2008-08-19 18:08:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void LibraryDialog::CallTileViewBtn_library()
|
|
|
|
{
|
|
|
|
//QMessageBox::information(this, tr("RetroShare"),tr("Will be Introducing this .. soon- tilesView in Library"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void LibraryDialog::CallShowDetailsBtn_library()
|
|
|
|
{
|
|
|
|
//QMessageBox::information(this, tr("RetroShare"),tr("Will be Introducing this .. soon- showdetails in Library"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void LibraryDialog::CallCreateAlbumBtn_library()
|
|
|
|
{
|
|
|
|
//QMessageBox::information(this, tr("RetroShare"),tr("Will be Introducing this .. soon- Create Album in Library"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void LibraryDialog::CallDeleteAlbumBtn_library()
|
|
|
|
{
|
|
|
|
//QMessageBox::information(this, tr("RetroShare"),tr("Will be Introducing this .. soon- Delete Album in Library"));
|
|
|
|
}
|
|
|
|
|
2008-08-20 17:39:03 -04:00
|
|
|
QString LibraryDialog::filePass()
|
|
|
|
{
|
|
|
|
fileToFind=ui.findEditmain->text();
|
|
|
|
return fileToFind;
|
|
|
|
}
|
2008-08-19 18:08:48 -04:00
|
|
|
|
2008-08-20 17:39:03 -04:00
|
|
|
void LibraryDialog::CallFindBtn_library()
|
|
|
|
{
|
|
|
|
filePass();
|
|
|
|
FindWindow *files = new FindWindow(this);
|
|
|
|
files->show();
|
|
|
|
}
|
2008-08-27 04:41:43 -04:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|