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; 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[]) int main(int argc, char *argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);

View File

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

View File

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

View File

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

View File

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