Enabled drag and drop in ShareManager to add folders to the share.

Fixed german language.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4172 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-04-26 23:38:29 +00:00
parent 993e0d225c
commit f29b41f303
4 changed files with 99 additions and 24 deletions

View File

@ -26,6 +26,7 @@
#include <QPoint> #include <QPoint>
#include <QHeaderView> #include <QHeaderView>
#include <QMessageBox> #include <QMessageBox>
#include <QUrl>
#include <retroshare/rsfiles.h> #include <retroshare/rsfiles.h>
@ -76,6 +77,7 @@ ShareManager::ShareManager(QWidget *parent, Qt::WFlags flags)
ui.shareddirList->setRangeSelected(QTableWidgetSelectionRange(0, 0, 0, COLUMN_COUNT), true); ui.shareddirList->setRangeSelected(QTableWidgetSelectionRange(0, 0, 0, COLUMN_COUNT), true);
setAcceptDrops(true);
setAttribute(Qt::WA_DeleteOnClose, true); setAttribute(Qt::WA_DeleteOnClose, true);
} }
@ -306,3 +308,57 @@ void ShareManager::shareddirListCurrentCellChanged(int currentRow, int currentCo
ui.removeButton->setEnabled(false); ui.removeButton->setEnabled(false);
} }
} }
void ShareManager::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
}
}
void ShareManager::dropEvent(QDropEvent *event)
{
if (!(Qt::CopyAction & event->possibleActions())) {
/* can't do it */
return;
}
QStringList formats = event->mimeData()->formats();
QStringList::iterator it;
bool errorShown = false;
if (event->mimeData()->hasUrls()) {
QList<QUrl> urls = event->mimeData()->urls();
QList<QUrl>::iterator it;
for (it = urls.begin(); it != urls.end(); it++) {
QString localpath = it->toLocalFile();
if (localpath.isEmpty() == false) {
QDir dir(localpath);
if (dir.exists()) {
SharedDirInfo sdi;
sdi.filename = localpath.toUtf8().constData();
sdi.virtualname.clear();
sdi.shareflags = 0;
/* add new share */
rsFiles->addSharedDirectory(sdi);
} else if (QFile::exists(localpath)) {
if (errorShown == false) {
QMessageBox mb(tr("Drop file error."), tr("File can't be dropped, only directories are accepted."), QMessageBox::Information, QMessageBox::Ok, 0, 0, this);
mb.exec();
errorShown = true;
}
} else {
QMessageBox mb(tr("Drop file error."), tr("Directory not found or directory name not accepted."), QMessageBox::Information, QMessageBox::Ok, 0, 0, this);
mb.exec();
}
}
}
}
event->setDropAction(Qt::CopyAction);
event->accept();
}

View File

@ -48,6 +48,9 @@ private:
protected: protected:
virtual void showEvent(QShowEvent * event); virtual void showEvent(QShowEvent * event);
virtual void dragEnterEvent(QDragEnterEvent *event);
virtual void dropEvent(QDropEvent *event);
private slots: private slots:
/** Create the context popup menu and it's submenus */ /** Create the context popup menu and it's submenus */
void shareddirListCurrentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn); void shareddirListCurrentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn);

View File

@ -3365,37 +3365,37 @@ p, li { white-space: pre-wrap; }
<message> <message>
<location filename="../gui/RemoteDirModel.cpp" line="+664"/> <location filename="../gui/RemoteDirModel.cpp" line="+664"/>
<source>Friends Directories</source> <source>Friends Directories</source>
<translation type="unfinished">Dateien von Freunden</translation> <translation>Dateien von Freunden</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>My Directories</source> <source>My Directories</source>
<translation type="unfinished">Meine Ordner</translation> <translation>Meine Ordner</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>Size</source> <source>Size</source>
<translation type="unfinished">Grösse</translation> <translation>Grösse</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>Age</source> <source>Age</source>
<translation type="unfinished">Alter</translation> <translation>Alter</translation>
</message> </message>
<message> <message>
<location line="+3"/> <location line="+3"/>
<source>Friend</source> <source>Friend</source>
<translation type="unfinished">Freund</translation> <translation>Freund</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>Share Type</source> <source>Share Type</source>
<translation type="unfinished">Freigabe Typ</translation> <translation>Freigabe Typ</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>Directory</source> <source>Directory</source>
<translation type="unfinished">Ordner</translation> <translation>Ordner</translation>
</message> </message>
</context> </context>
<context> <context>
@ -3689,7 +3689,7 @@ p, li { white-space: pre-wrap; }
<location line="+6"/> <location line="+6"/>
<location line="+93"/> <location line="+93"/>
<source>Copy RetroShare Link</source> <source>Copy RetroShare Link</source>
<translation type="unfinished">Kopiere RetroShare Link</translation> <translation>Kopiere RetroShare Link</translation>
</message> </message>
<message> <message>
<location line="-88"/> <location line="-88"/>
@ -10281,7 +10281,7 @@ p, li { white-space: pre-wrap; }
<translation>Freigabe entfernen</translation> <translation>Freigabe entfernen</translation>
</message> </message>
<message> <message>
<location filename="../gui/ShareManager.cpp" line="+125"/> <location filename="../gui/ShareManager.cpp" line="+127"/>
<source>If checked, the share is anonymously shared to anybody.</source> <source>If checked, the share is anonymously shared to anybody.</source>
<translation>Wenn aktiviert, dann ist dieser Ordner anonym feigegeben.</translation> <translation>Wenn aktiviert, dann ist dieser Ordner anonym feigegeben.</translation>
</message> </message>
@ -10295,9 +10295,25 @@ p, li { white-space: pre-wrap; }
<source>Do you really want to stop sharing this directory ?</source> <source>Do you really want to stop sharing this directory ?</source>
<translation>Möchtes Du die Freigabe dieses Ordners wirklich aufheben ?</translation> <translation>Möchtes Du die Freigabe dieses Ordners wirklich aufheben ?</translation>
</message> </message>
<message>
<location line="+75"/>
<location line="+5"/>
<source>Drop file error.</source>
<translation>Dateifehler bei Drag&apos;n&apos;Drop.</translation>
</message>
<message>
<location line="-5"/>
<source>File can&apos;t be dropped, only directories are accepted.</source>
<translation>Dateien können nicht für Drag&apos;n&apos;Drop genutzt werden. Nur Ordner werden akzeptiert.</translation>
</message>
<message>
<location line="+5"/>
<source>Directory not found or directory name not accepted.</source>
<translation>Ordner nicht gefunden oder Ordnername nicht akzeptiert.</translation>
</message>
<message> <message>
<location filename="../gui/ShareManager.ui" line="+3"/> <location filename="../gui/ShareManager.ui" line="+3"/>
<location filename="../gui/ShareManager.cpp" line="-176"/> <location filename="../gui/ShareManager.cpp" line="-256"/>
<source>Remove</source> <source>Remove</source>
<translation>Entfernen</translation> <translation>Entfernen</translation>
</message> </message>
@ -10335,7 +10351,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;&quot;&gt;You can separately setup share flags for each shared directory:&lt;/span&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &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;&quot;&gt;You can separately setup share flags for each shared directory:&lt;/span&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt; &lt;/span&gt;&lt;/p&gt;
&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;Browsable&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Sans&apos;; font-size:8pt;&quot;&gt;: files are browsable from your direct friends.&lt;/span&gt;&lt;/p&gt; &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;Browsable&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Sans&apos;; font-size:8pt;&quot;&gt;: files are browsable from your direct friends.&lt;/span&gt;&lt;/p&gt;
&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;Network Wide&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Sans&apos;; font-size:8pt;&quot;&gt;: files can be downloaded by anybody through anonymous tunnels.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source> &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;Network Wide&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Sans&apos;; font-size:8pt;&quot;&gt;: files can be downloaded by anybody through anonymous tunnels.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; <translation>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; } p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;MS Shell Dlg 2&apos;; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt; &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;MS Shell Dlg 2&apos;; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
@ -10466,12 +10482,12 @@ p, li { white-space: pre-wrap; }
<message> <message>
<location line="+28"/> <location line="+28"/>
<source>Tree view</source> <source>Tree view</source>
<translation type="unfinished"></translation> <translation>Baumansicht</translation>
</message> </message>
<message> <message>
<location line="+5"/> <location line="+5"/>
<source>Flat view</source> <source>Flat view</source>
<translation type="unfinished"></translation> <translation>Listenansicht</translation>
</message> </message>
<message> <message>
<location line="+173"/> <location line="+173"/>
@ -11862,58 +11878,58 @@ p, li { white-space: pre-wrap; }
<location filename="../gui/RemoteDirModel.cpp" line="+136"/> <location filename="../gui/RemoteDirModel.cpp" line="+136"/>
<location line="+108"/> <location line="+108"/>
<source>FILE</source> <source>FILE</source>
<translation type="unfinished">DATEI</translation> <translation>DATEI</translation>
</message> </message>
<message> <message>
<location line="-95"/> <location line="-95"/>
<source>Files</source> <source>Files</source>
<translation type="unfinished">Dateien</translation> <translation>Dateien</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>File</source> <source>File</source>
<translation type="unfinished">Datei</translation> <translation>Datei</translation>
</message> </message>
<message> <message>
<location line="+6"/> <location line="+6"/>
<location line="+103"/> <location line="+103"/>
<source>DIR</source> <source>DIR</source>
<translation type="unfinished">ORDNER</translation> <translation>ORDNER</translation>
</message> </message>
<message> <message>
<location line="+145"/> <location line="+145"/>
<source>Friends Directories</source> <source>Friends Directories</source>
<translation type="unfinished">Dateien von Freunden</translation> <translation>Dateien von Freunden</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>My Directories</source> <source>My Directories</source>
<translation type="unfinished">Meine Ordner</translation> <translation>Meine Ordner</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>Size</source> <source>Size</source>
<translation type="unfinished">Grösse</translation> <translation>Grösse</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>Age</source> <source>Age</source>
<translation type="unfinished">Alter</translation> <translation>Alter</translation>
</message> </message>
<message> <message>
<location line="+3"/> <location line="+3"/>
<source>Friend</source> <source>Friend</source>
<translation type="unfinished">Freund</translation> <translation>Freund</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>Share Type</source> <source>Share Type</source>
<translation type="unfinished">Freigabe Typ</translation> <translation>Freigabe Typ</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>What&apos;s new</source> <source>What&apos;s new</source>
<translation type="unfinished">Was ist neu</translation> <translation>Was ist neu</translation>
</message> </message>
</context> </context>
<context> <context>