Location selector and edit window finished
[ptas] / zouba / src / addressdialog.h
1 #ifndef ADDRESSDIALOG_H
2 #define ADDRESSDIALOG_H
3
4 #include <QDialog>
5 #include <QList>
6
7 class Location;
8 class QString;
9 class QWidget;
10 class QLineEdit;
11 class QNetworkReply;
12 class QListWidget;
13 class QListWidgetItem;
14
15 /* TODO: Layout
16  * - Name and andress text input fields in a form layout on the left
17  *   - Name text input field not enabled if editing an existing location
18  * - Buttons on the right
19  *   - Add button
20  *     - Enabled if search once and no typing has been done to address
21  *   - Search
22  *     - Searches for the address in the address text input field
23  */
24 class AddressDialog : public QDialog
25 {
26     Q_OBJECT
27 public:
28     explicit AddressDialog(QWidget *parent = 0, const Location *location = 0);
29
30 signals:
31     void busy(bool busy);
32
33 public slots:
34     void searchFinished();
35     void locationSelected(Location* location);
36
37 private slots:
38     void searchAddress();
39     void addLocation();
40     void typedInAddress();
41
42 private:
43     QLineEdit *m_label;
44     QLineEdit *m_address;
45     QPushButton *m_addButton;
46
47     QNetworkReply *m_reply;
48
49     QList<Location*> m_places;
50     QList<Location*> m_roadNames;
51     QList<Location*> m_stops;
52     
53     Location* m_current;
54 };
55
56
57
58 /* TODO: Layout
59  * - One list of found locations
60  * - Clicking one selects the location
61  * - If the clicked one is disabled, nothing happens (clicked signal might not be enabled so this needs to implemented only if selecting a heading line emits clicked signal
62  * - When selected emits locationSelected(Location *location) signal with the selected locations copy.
63  * - When selected calls close
64  */
65 class AddressDialogSelection : public QDialog
66 {
67     Q_OBJECT
68 public:
69     explicit AddressDialogSelection(const QList<Location*> &places, const QList<Location*> &roads, const QList<Location*> &stops, QWidget *parent = 0);
70
71 signals:
72     void locationSelected(Location* location);
73     
74 private slots:
75     void itemSelected(QListWidgetItem *item);
76
77 private:
78   const QList<Location*>& m_places;
79   const QList<Location*>& m_roads;
80   const QList<Location*>& m_stops;
81 };
82
83 #endif // ADDRESSDIALOGNEW_H