Added drop-support to add dialog (closes #8)

If text is dropped in the add dialog, a receipt is added with that
text.
develop
tastytea 2018-11-02 12:00:51 +01:00
parent f6ff77571d
commit 9cc5af5142
No known key found for this signature in database
GPG Key ID: CFC39497F1B26E07
5 changed files with 45 additions and 24 deletions

View File

@ -300,6 +300,22 @@ void DialogAdd::accept()
delete this;
}
void DialogAdd::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasFormat("text/plain"))
{
event->acceptProposedAction();
}
}
void DialogAdd::dropEvent(QDropEvent *event)
{
const QString text = event->mimeData()->text();
QListWidgetItem *item = new QListWidgetItem(text);
item->setFlags(item->flags() | Qt::ItemIsEditable);
list_receipts->insertItem(list_receipts->count(), item);
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);

View File

@ -73,6 +73,8 @@ public:
private:
const Dialogdata get_data() const;
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
MainWindow *_parent;

View File

@ -10,6 +10,9 @@
<height>300</height>
</rect>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>Add entry</string>
</property>

View File

@ -4,62 +4,62 @@
<context>
<name>DialogAdd</name>
<message>
<location filename="../src/whyblocked_add.ui" line="14"/>
<location filename="../src/whyblocked_add.ui" line="17"/>
<source>Add entry</source>
<translation>Eintrag hinzufügen</translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="37"/>
<location filename="../src/whyblocked_add.ui" line="40"/>
<source>Memory aids, proof</source>
<translation>Gedächtnisstützen, Beweise</translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="40"/>
<location filename="../src/whyblocked_add.ui" line="43"/>
<source>Rece&amp;ipts</source>
<translation>Be&amp;lege</translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="53"/>
<location filename="../src/whyblocked_add.ui" line="56"/>
<source>Add receipt</source>
<translation>Beleg hinzufügen</translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="56"/>
<location filename="../src/whyblocked_add.ui" line="59"/>
<source>&amp;Add</source>
<translation>&amp;Hinzufügen</translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="76"/>
<location filename="../src/whyblocked_add.ui" line="79"/>
<source>&amp;Blocked</source>
<translation>&amp;Blockiert</translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="95"/>
<location filename="../src/whyblocked_add.ui" line="98"/>
<source>&amp;Silenced</source>
<translation>&amp;Gedämpft</translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="102"/>
<location filename="../src/whyblocked_add.ui" line="105"/>
<source>R&amp;eason</source>
<translation>B&amp;egründung</translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="131"/>
<location filename="../src/whyblocked_add.ui" line="134"/>
<source>Blocked/Silenced</source>
<translation>Blockiert/Gedämpft</translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="141"/>
<location filename="../src/whyblocked_add.ui" line="144"/>
<source>&amp;User/Instance</source>
<translation>Ben&amp;utzer/Instanz</translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="151"/>
<location filename="../src/whyblocked_add.ui" line="154"/>
<source>Remove receipt</source>
<translation>Beleg entfernen</translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="154"/>
<location filename="../src/whyblocked_add.ui" line="157"/>
<source>Re&amp;move</source>
<translation>Ent&amp;fernen</translation>
</message>

View File

@ -4,62 +4,62 @@
<context>
<name>DialogAdd</name>
<message>
<location filename="../src/whyblocked_add.ui" line="14"/>
<location filename="../src/whyblocked_add.ui" line="17"/>
<source>Add entry</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="37"/>
<location filename="../src/whyblocked_add.ui" line="40"/>
<source>Memory aids, proof</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="40"/>
<location filename="../src/whyblocked_add.ui" line="43"/>
<source>Rece&amp;ipts</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="53"/>
<location filename="../src/whyblocked_add.ui" line="56"/>
<source>Add receipt</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="56"/>
<location filename="../src/whyblocked_add.ui" line="59"/>
<source>&amp;Add</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="76"/>
<location filename="../src/whyblocked_add.ui" line="79"/>
<source>&amp;Blocked</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="95"/>
<location filename="../src/whyblocked_add.ui" line="98"/>
<source>&amp;Silenced</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="102"/>
<location filename="../src/whyblocked_add.ui" line="105"/>
<source>R&amp;eason</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="131"/>
<location filename="../src/whyblocked_add.ui" line="134"/>
<source>Blocked/Silenced</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="141"/>
<location filename="../src/whyblocked_add.ui" line="144"/>
<source>&amp;User/Instance</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="151"/>
<location filename="../src/whyblocked_add.ui" line="154"/>
<source>Remove receipt</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/whyblocked_add.ui" line="154"/>
<location filename="../src/whyblocked_add.ui" line="157"/>
<source>Re&amp;move</source>
<translation type="unfinished"></translation>
</message>