More s/which/that/ replacements.
[ttfautohint.git] / frontend / ddlineedit.cpp
blob072bab4975778abe31f677980abc0641b1160bf8
1 // ddlineedit.cpp
3 // Copyright (C) 2012-2013 by Werner Lemberg.
4 //
5 // This file is part of the ttfautohint library, and may only be used,
6 // modified, and distributed under the terms given in `COPYING'. By
7 // continuing to use, modify, or distribute this file you indicate that you
8 // have read `COPYING' and understand and accept it fully.
9 //
10 // The file `COPYING' mentioned in the previous paragraph is distributed
11 // with the ttfautohint library.
14 // Derived class `Drag_Drop_Line_Edit' is Tooltip_Line_Edit
15 // that accepts drag and drop.
17 #include <config.h>
19 #include "ddlineedit.h"
21 Drag_Drop_Line_Edit::Drag_Drop_Line_Edit(QWidget* parent)
22 : Tooltip_Line_Edit(parent)
24 // empty
28 // XXX: There are no standardized MIME types for TTFs and TTCs
29 // that work everywhere. So we rely on the extension.
31 void
32 Drag_Drop_Line_Edit::dragEnterEvent(QDragEnterEvent* event)
34 QList<QUrl> url_list;
35 QString file_name;
37 if (event->mimeData()->hasUrls())
39 url_list = event->mimeData()->urls();
41 // if just text was dropped, url_list is empty
42 if (url_list.size())
44 file_name = url_list[0].toLocalFile();
46 if (file_name.endsWith(".ttf")
47 || file_name.endsWith(".TTF")
48 || file_name.endsWith(".ttc")
49 || file_name.endsWith(".TTC"))
50 event->acceptProposedAction();
56 void
57 Drag_Drop_Line_Edit::dropEvent(QDropEvent* event)
59 QList<QUrl> url_list;
60 QString file_name;
61 QFileInfo info;
63 if (event->mimeData()->hasUrls())
65 url_list = event->mimeData()->urls();
67 // if just text was dropped, url_list is empty
68 if (url_list.size())
70 file_name = url_list[0].toLocalFile();
72 // check whether `file_name' is valid
73 info.setFile(file_name);
74 if (info.isFile())
75 setText(file_name);
79 event->acceptProposedAction();
82 // end of ddlineedit.cpp