Added edit of shared folders. The change of the virtual name results in a rehash of the shared folder.

Save and restore the position of the ShareManager window.
Fixed german translation.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3513 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-09-18 16:05:32 +00:00
parent 7baafb3f90
commit 831c73dd9d
9 changed files with 211 additions and 100 deletions

View File

@ -943,6 +943,8 @@ bool FileIndexMonitor::internal_setSharedDirectories()
}
}
pendingDirList.clear();
/* now we've decided on the 'root' dirs set them to the
* fileIndex
*/

View File

@ -28,7 +28,7 @@
#include <QComboBox>
/** Default constructor */
ShareDialog::ShareDialog(QWidget *parent, Qt::WFlags flags)
ShareDialog::ShareDialog(std::string filename, QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags)
{
/* Invoke Qt Designer generated QObject setup routine */
@ -36,18 +36,32 @@ ShareDialog::ShareDialog(QWidget *parent, Qt::WFlags flags)
connect(ui.browseButton, SIGNAL(clicked( bool ) ), this , SLOT( browseDirectory() ) );
connect(ui.okButton, SIGNAL(clicked( bool ) ), this , SLOT( addDirectory() ) );
connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(closedialog()));
connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(close()));
ui.okButton->setEnabled(false);
load();
}
if (filename.empty() == false) {
/* edit exisiting share */
std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(dirs);
void ShareDialog::load()
{
ui.localpath_lineEdit->clear();
ui.browsableCheckBox->setChecked(false);
ui.networkwideCheckBox->setChecked(false);
std::list<SharedDirInfo>::const_iterator it;
for (it = dirs.begin(); it != dirs.end(); it++) {
if (it->filename == filename) {
/* fill dialog */
ui.okButton->setEnabled(true);
ui.localpath_lineEdit->setText(QString::fromUtf8(it->filename.c_str()));
ui.localpath_lineEdit->setDisabled(true);
ui.browseButton->setDisabled(true);
ui.virtualpath_lineEdit->setText(QString::fromUtf8(it->virtualname.c_str()));
ui.browsableCheckBox->setChecked(it->shareflags & RS_FILE_HINTS_BROWSABLE);
ui.networkwideCheckBox->setChecked(it->shareflags & RS_FILE_HINTS_NETWORK_WIDE);
break;
}
}
}
}
void ShareDialog::browseDirectory()
@ -79,25 +93,44 @@ void ShareDialog::addDirectory()
sdi.shareflags |= RS_FILE_HINTS_NETWORK_WIDE;
}
rsFiles->addSharedDirectory(sdi);
if (ui.localpath_lineEdit->isEnabled()) {
/* add new share */
rsFiles->addSharedDirectory(sdi);
} else {
/* edit exisiting share */
bool found = false;
load();
close();
}
std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(dirs);
void ShareDialog::showEvent(QShowEvent *event)
{
if (!event->spontaneous())
{
load();
std::list<SharedDirInfo>::iterator it;
for (it = dirs.begin(); it != dirs.end(); it++) {
if (it->filename == sdi.filename) {
found = true;
if (it->virtualname != sdi.virtualname) {
/* virtual name changed, remove shared directory and add it again */
rsFiles->removeSharedDirectory(it->filename);
rsFiles->addSharedDirectory(sdi);
break;
}
if (it->shareflags ^ sdi.shareflags) {
/* modifies the flags */
it->shareflags = sdi.shareflags;
rsFiles->updateShareFlags(*it);
break;
}
/* nothing changed */
break;
}
}
if (found == false) {
/* not modified, add share directory instead */
rsFiles->addSharedDirectory(sdi);
}
}
}
void ShareDialog::closedialog()
{
ui.localpath_lineEdit->clear();
ui.browsableCheckBox->setChecked(false);
ui.networkwideCheckBox->setChecked(false);
close();
}

View File

@ -31,27 +31,15 @@ class ShareDialog : public QDialog
Q_OBJECT
public:
/** Default constructor */
ShareDialog( QWidget *parent = 0, Qt::WFlags flags = 0);
ShareDialog( std::string filename, QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */
public slots:
/** Loads the settings for this page */
void load();
protected:
virtual void showEvent(QShowEvent * event);
private slots:
void browseDirectory();
void addDirectory();
void closedialog();
private:
/** Qt Designer generated object */
Ui::ShareDialog ui;
};

View File

@ -180,17 +180,7 @@ p, li { white-space: pre-wrap; }
<string>Share Flags</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="0">
<widget class="QCheckBox" name="networkwideCheckBox">
<property name="toolTip">
<string>Anonymous shared Network Wide</string>
</property>
<property name="text">
<string>Network Wide</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -203,7 +193,7 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QCheckBox" name="browsableCheckBox">
<property name="toolTip">
<string>Browseable by Friends</string>
@ -213,6 +203,16 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="networkwideCheckBox">
<property name="toolTip">
<string>Anonymous shared Network Wide</string>
</property>
<property name="text">
<string>Network Wide</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -18,10 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "ShareManager.h"
#include <retroshare/rsfiles.h>
#include "ShareDialog.h"
#include <QContextMenuEvent>
#include <QMenu>
@ -31,6 +27,12 @@
#include <QHeaderView>
#include <QMessageBox>
#include <retroshare/rsfiles.h>
#include "ShareManager.h"
#include "ShareDialog.h"
#include "settings/rsharesettings.h"
/* Images for context menu icons */
#define IMAGE_CANCEL ":/images/delete.png"
@ -38,6 +40,7 @@
#define COLUMN_VIRTUALNAME 1
#define COLUMN_NETWORKWIDE 2
#define COLUMN_BROWSABLE 3
#define COLUMN_COUNT 3
ShareManager *ShareManager::_instance = NULL ;
@ -51,14 +54,18 @@ ShareManager::ShareManager(QWidget *parent, Qt::WFlags flags)
isLoading = false;
load();
Settings->loadWidgetInformation(this);
connect(ui.addButton, SIGNAL(clicked( bool ) ), this , SLOT( showShareDialog() ) );
connect(ui.editButton, SIGNAL(clicked( bool ) ), this , SLOT( editShareDirectory() ) );
connect(ui.removeButton, SIGNAL(clicked( bool ) ), this , SLOT( removeShareDirectory() ) );
connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(close()));
connect( ui.shareddirList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( shareddirListCostumPopupMenu( QPoint ) ) );
connect(ui.shareddirList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(shareddirListCostumPopupMenu(QPoint)));
connect(ui.shareddirList, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(shareddirListCurrentCellChanged(int,int,int,int)));
ui.addButton->setToolTip(tr("Add a Share Directory"));
ui.removeButton->setToolTip(tr("Stop sharing selected Directory"));
ui.editButton->setEnabled(false);
ui.removeButton->setEnabled(false);
ui.shareddirList->horizontalHeader()->setResizeMode( COLUMN_PATH, QHeaderView::Stretch);
ui.shareddirList->horizontalHeader()->setResizeMode( COLUMN_BROWSABLE, QHeaderView::Interactive);
@ -66,21 +73,30 @@ ShareManager::ShareManager(QWidget *parent, Qt::WFlags flags)
ui.shareddirList->horizontalHeader()->resizeSection( COLUMN_PATH, 360 );
ui.shareddirList->horizontalHeader()->setStretchLastSection(false);
ui.shareddirList->setRangeSelected(QTableWidgetSelectionRange(0, 0, 0, COLUMN_COUNT), true);
setAttribute(Qt::WA_DeleteOnClose, true);
}
ShareManager::~ShareManager()
{
_instance = NULL;
Settings->saveWidgetInformation(this);
}
void ShareManager::shareddirListCostumPopupMenu( QPoint point )
{
QMenu contextMnu( this );
removeAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Remove" ), this );
QAction *editAct = new QAction(tr( "Edit" ), &contextMnu );
connect( editAct , SIGNAL( triggered() ), this, SLOT( editShareDirectory() ) );
QAction *removeAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Remove" ), &contextMnu );
connect( removeAct , SIGNAL( triggered() ), this, SLOT( removeShareDirectory() ) );
contextMnu.addAction( editAct );
contextMnu.addAction( removeAct );
contextMnu.exec(QCursor::pos());
@ -105,8 +121,8 @@ void ShareManager::load()
connect(this,SIGNAL(itemClicked(QTableWidgetItem*)),this,SLOT(updateFlags(QTableWidgetItem*))) ;
#ifndef USE_COMBOBOX
QString ToolTips [2] = { QString("If checked, the share is anonymously shared to anybody."),
QString("If checked, the share is browsable by your friends.") };
QString ToolTips [2] = { tr("If checked, the share is anonymously shared to anybody."),
tr("If checked, the share is browsable by your friends.") };
int Flags [2] = { RS_FILE_HINTS_NETWORK_WIDE, RS_FILE_HINTS_BROWSABLE };
#endif
@ -219,6 +235,30 @@ void ShareManager::updateFlags(bool b)
}
}
void ShareManager::editShareDirectory()
{
/* id current dir */
int row = ui.shareddirList->currentRow();
QTableWidgetItem *item = ui.shareddirList->item(row, COLUMN_PATH);
if (item) {
std::string filename = item->text().toUtf8().constData();
std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(dirs);
std::list<SharedDirInfo>::const_iterator it;
for (it = dirs.begin(); it != dirs.end(); it++) {
if (it->filename == filename) {
/* file name found, show dialog */
ShareDialog sharedlg (it->filename, this);
sharedlg.exec();
break;
}
}
}
}
void ShareManager::removeShareDirectory()
{
/* id current dir */
@ -227,13 +267,9 @@ void ShareManager::removeShareDirectory()
int row = listWidget -> currentRow();
QTableWidgetItem *qdir = listWidget->item(row, COLUMN_PATH);
QString queryWrn;
queryWrn.clear();
queryWrn.append(tr("Do you really want to stop sharing this directory ?"));
if (qdir)
{
if ((QMessageBox::question(this, tr("Warning!"),queryWrn,QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes)
if ((QMessageBox::question(this, tr("Warning!"),tr("Do you really want to stop sharing this directory ?"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes)
{
rsFiles->removeSharedDirectory( qdir->text().toUtf8().constData());
load();
@ -251,6 +287,21 @@ void ShareManager::showEvent(QShowEvent *event)
void ShareManager::showShareDialog()
{
ShareDialog sharedlg (this);
ShareDialog sharedlg ("", this);
sharedlg.exec();
}
void ShareManager::shareddirListCurrentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
{
Q_UNUSED(currentColumn);
Q_UNUSED(previousRow);
Q_UNUSED(previousColumn);
if (currentRow >= 0) {
ui.editButton->setEnabled(true);
ui.removeButton->setEnabled(true);
} else {
ui.editButton->setEnabled(false);
ui.removeButton->setEnabled(false);
}
}

View File

@ -50,9 +50,11 @@ protected:
private slots:
/** Create the context popup menu and it's submenus */
void shareddirListCurrentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn);
void shareddirListCostumPopupMenu( QPoint point );
void showShareDialog();
void editShareDirectory();
void removeShareDirectory();
void updateFlags(bool);
@ -62,8 +64,6 @@ private:
/** Define the popup menus for the Context menu */
QMenu* contextMnu;
/** Defines the actions for the context menu */
QAction* removeAct;
/** Qt Designer generated object */
Ui::ShareManager ui;

View File

@ -109,7 +109,7 @@ p, li { white-space: pre-wrap; }
<property name="topMargin">
<number>6</number>
</property>
<item row="0" column="0" colspan="5">
<item row="0" column="0" colspan="6">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Shared Folder Manager</string>
@ -231,6 +231,9 @@ p, li { white-space: pre-wrap; }
<height>200</height>
</size>
</property>
<property name="toolTip">
<string>Add a Share Directory</string>
</property>
<property name="text">
<string>Add</string>
</property>
@ -242,7 +245,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="2">
<widget class="QPushButton" name="removeButton">
<property name="minimumSize">
<size>
@ -256,6 +259,9 @@ p, li { white-space: pre-wrap; }
<height>200</height>
</size>
</property>
<property name="toolTip">
<string>Stop sharing selected Directory</string>
</property>
<property name="text">
<string>Remove</string>
</property>
@ -267,7 +273,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="1" column="2">
<item row="1" column="3">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -280,13 +286,23 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="1" column="3">
<item row="1" column="4">
<widget class="QPushButton" name="closeButton">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="editButton">
<property name="toolTip">
<string>Edit selected Shared Directory</string>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -6817,7 +6817,7 @@ p, li { white-space: pre-wrap; }
<context>
<name>PeersDialog</name>
<message>
<location filename="../gui/PeersDialog.cpp" line="+356"/>
<location filename="../gui/PeersDialog.cpp" line="+357"/>
<source>Chat</source>
<translation>Chat</translation>
</message>
@ -6918,17 +6918,17 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location line="+103"/>
<location line="+5"/>
<location line="+7"/>
<source>Drop file error.</source>
<translation>Dateifehler bei Drag&apos;n&apos;Drop.</translation>
</message>
<message>
<location line="-5"/>
<location line="+0"/>
<source>File not found or file name not accepted.</source>
<translation>Datei nicht gefunden oder Dateiname nicht akzeptiert.</translation>
</message>
<message>
<location line="+5"/>
<location line="-7"/>
<source>Directory can&apos;t be dropped, only files are accepted.</source>
<translation>Ordner können nicht für Drag&apos;n&apos;Drop genutzt werden. Nur Dateien werden akzeptiert.</translation>
</message>
@ -7066,7 +7066,7 @@ p, li { white-space: pre-wrap; }
<translation>Verlauf löschen</translation>
</message>
<message>
<location filename="../gui/PeersDialog.cpp" line="-1230"/>
<location filename="../gui/PeersDialog.cpp" line="-1225"/>
<source>Profile View</source>
<translation type="unfinished"></translation>
</message>
@ -7462,7 +7462,7 @@ p, li { white-space: pre-wrap; }
<translation>Avatar zeigen</translation>
</message>
<message>
<location line="+337"/>
<location line="+342"/>
<source>File not found or file name not accepted.</source>
<translation>Datei nicht gefunden oder Dateiname nicht akzeptiert.</translation>
</message>
@ -7510,7 +7510,7 @@ p, li { white-space: pre-wrap; }
<translation>Deaktiviere Emoticons</translation>
</message>
<message>
<location filename="../gui/chat/PopupChatDialog.cpp" line="-813"/>
<location filename="../gui/chat/PopupChatDialog.cpp" line="-818"/>
<source>Paste retroshare Link</source>
<translation>RetroShare Link einfügen</translation>
</message>
@ -7535,13 +7535,13 @@ p, li { white-space: pre-wrap; }
<translation>Zusätzlich eine Datei hinzufügen</translation>
</message>
<message>
<location line="+169"/>
<location line="+5"/>
<location line="+167"/>
<location line="+7"/>
<source>Drop file error.</source>
<translation>Dateifehler bei Drag&apos;n&apos;Drop.</translation>
</message>
<message>
<location line="+0"/>
<location line="-7"/>
<source>Directory can&apos;t be dropped, only files are accepted.</source>
<translation>Ordner können nicht für Drag&apos;n&apos;Drop genutzt werden. Nur Dateien werden akzeptiert.</translation>
</message>
@ -7557,7 +7557,7 @@ p, li { white-space: pre-wrap; }
<translation>Chat Verlauf speichern</translation>
</message>
<message>
<location filename="../gui/chat/PopupChatDialog.cpp" line="+57"/>
<location filename="../gui/chat/PopupChatDialog.cpp" line="+62"/>
<source>Save as...</source>
<translation>Speichern unter...</translation>
</message>
@ -7567,7 +7567,7 @@ p, li { white-space: pre-wrap; }
<translation>Text Datei (*.txt );;Alle Dateien (*)</translation>
</message>
<message>
<location line="-671"/>
<location line="-669"/>
<source>Your Friend is offline
Do you want to send them a Message instead</source>
<translation>Dein Freund ist Offline willst du ihm stattdessen eine Nachricht senden</translation>
@ -7584,7 +7584,7 @@ Do you want to send them a Message instead</source>
<translation></translation>
</message>
<message>
<location filename="../gui/chat/PopupChatDialog.cpp" line="+705"/>
<location filename="../gui/chat/PopupChatDialog.cpp" line="+703"/>
<source>is Idle and may not reply</source>
<translation>antwortet möglicherweise nicht, da der Status auf &quot;Untätig&quot; gesetzt wurde</translation>
</message>
@ -7610,7 +7610,7 @@ Do you want to send them a Message instead</source>
Diesem Kontakt stattdessen eine RS-Mail senden.</translation>
</message>
<message>
<location line="-655"/>
<location line="-653"/>
<source>is typing...</source>
<translation>tippt...</translation>
</message>
@ -9247,7 +9247,7 @@ p, li { white-space: pre-wrap; }
<translation>Abbrechen</translation>
</message>
<message>
<location filename="../gui/ShareDialog.cpp" line="+56"/>
<location filename="../gui/ShareDialog.cpp" line="+70"/>
<source>Select A Folder To Share</source>
<translation>Wähle einen Ordner zum Freigeben aus</translation>
</message>
@ -9311,33 +9311,43 @@ p, li { white-space: pre-wrap; }
<context>
<name>ShareManager</name>
<message>
<location filename="../gui/ShareManager.cpp" line="+60"/>
<location filename="../gui/ShareManager.ui" line="+235"/>
<source>Add a Share Directory</source>
<translation>Ordner hinzufügen</translation>
<translation>Freigabe hinzufügen</translation>
</message>
<message>
<location line="+28"/>
<source>Stop sharing selected Directory</source>
<translation>Freigabe entfernen</translation>
</message>
<message>
<location filename="../gui/ShareManager.cpp" line="+124"/>
<source>If checked, the share is anonymously shared to anybody.</source>
<translation>Wenn aktiviert, dann ist dieser Ordner anonym feigegeben.</translation>
</message>
<message>
<location line="+1"/>
<source>Stop sharing selected Directory</source>
<translation>Stoppe die Freigabe des Ordners</translation>
<source>If checked, the share is browsable by your friends.</source>
<translation>Wenn aktiviert, dann ist dieser Ordner von Deinen Freunden durchsuchbar.</translation>
</message>
<message>
<location line="+171"/>
<location line="+147"/>
<source>Do you really want to stop sharing this directory ?</source>
<translation>Möchtes Du die Freigabe dieses Ordners wirklich aufheben ?</translation>
</message>
<message>
<location filename="../gui/ShareManager.ui" line="+257"/>
<location filename="../gui/ShareManager.cpp" line="-151"/>
<location filename="../gui/ShareManager.ui" line="+3"/>
<location filename="../gui/ShareManager.cpp" line="-176"/>
<source>Remove</source>
<translation>Entfernen</translation>
</message>
<message>
<location filename="../gui/ShareManager.cpp" line="+155"/>
<location filename="../gui/ShareManager.cpp" line="+176"/>
<source>Warning!</source>
<translation>Warnung!</translation>
</message>
<message>
<location filename="../gui/ShareManager.ui" line="-240"/>
<location filename="../gui/ShareManager.ui" line="-249"/>
<source>RetroShare Share Manager</source>
<translation>RetroShare Freigabe Manager</translation>
</message>
@ -9376,7 +9386,7 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;Sans&apos;; font-size:8pt; font-weight:600;&quot;&gt;Netzwerkweit&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Sans&apos;; font-size:8pt;&quot;&gt;: Dateien können von jedem über anoynme Tunnel heruntergeladen werden.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<location line="+64"/>
<location line="+67"/>
<source>Directory</source>
<translation>Ordner</translation>
</message>
@ -9396,17 +9406,28 @@ p, li { white-space: pre-wrap; }
<translation>Durchsuchbar</translation>
</message>
<message>
<location line="+77"/>
<location line="+83"/>
<source>Close</source>
<translation>Schliessen</translation>
</message>
<message>
<location line="-51"/>
<location line="+7"/>
<source>Edit selected Shared Directory</source>
<translation>Freigabe bearbeiten</translation>
</message>
<message>
<location line="+3"/>
<location filename="../gui/ShareManager.cpp" line="-179"/>
<source>Edit</source>
<translation>Bearbeiten</translation>
</message>
<message>
<location line="-64"/>
<source>Add</source>
<translation>Hinzufügen</translation>
</message>
<message>
<location line="-117"/>
<location line="-123"/>
<source>Shared Folder Manager</source>
<translation>Freigabe Manager</translation>
</message>