summaryrefslogtreecommitdiffstats
path: root/kspread/plugins/insertcalendar/kspread_insertcalendardialog.h
blob: 40d5731a6de23d364d10cfd9d3d8029a3f89efef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
 /***************************************************************************
 *   Copyright (C) 2005 by Raphael Langerhorst                             *
 *   raphael-langerhorst@gmx.at                                            *
 *                                                                         *
 *   Permission is hereby granted, free of charge, to any person obtaining *
 *   a copy of this software and associated documentation files (the       *
 *   "Software"), to deal in the Software without restriction, including   *
 *   without limitation the rights to use, copy, modify, merge, publish,   *
 *   distribute, sublicense, and/or sell copies of the Software, and to    *
 *   permit persons to whom the Software is furnished to do so, subject to *
 *   the following conditions:                                             *
 *                                                                         *
 *   The above copyright notice and this permission notice shall be        *
 *   included in all copies or substantial portions of the Software.       *
 *                                                                         *
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
 *   OTHER DEALINGS IN THE SOFTWARE.                                       *
 ***************************************************************************/

#ifndef KSPREAD_INSERTCALENDARDIALOG_H
#define KSPREAD_INSERTCALENDARDIALOG_H

#include <kspread_insertcalendardialogbase.h>
#include <koffice_export.h>

#include <tqdatetime.h>

class KDatePicker;

namespace KSpread
{

class KSPREAD_EXPORT InsertCalendarDialog : public InsertCalendarDialogBase
{
  Q_OBJECT
  

  private:

    /**
     * Stores a pointer to the currently active date picker frame.
     * This is useful if we want to delete it manually.
     * @see datePickerDeleted
     */
    KDatePicker* m_datePicker;

  public:

    /**
     * Constructor, initializes functionality.
     * The dates in the dialog initialize to a complete calendar for the
     * current month.
     */
    InsertCalendarDialog(TQWidget* parent = 0, const char* name = 0);

    /**
     * Virtual destructor.
     */
    virtual ~InsertCalendarDialog();

  protected:

    /**
     * Creates a KDatePicker frame that is not connected
     * to any date widget. Normally showStartDatePicker
     * of showEndDatePicker use this method to build
     * a generally usable date picker widget and connect
     * it to the appropriate KDateWidget of the dialog.
     *
     * DatePickerDeleted is already connected!
     */
    bool buildDatePickerFrame();

  protected slots:

    /**
     * Sets the currently active KDatePicker frame to NULL.
     * It's expected that the date picker frame is deleted.
     * @see m_datePicker
     */
    void datePickerDeleted();

    /**
     * This slot is reimplemented from TQDialog and
     * is connected to the insert button.
     * It also emits a insertCalendar signal.
     *
     * The dialog is closed (not deleted) when
     * this slot is called.
     *
     * @see insertCalendar, reject, TQDialog::done
     */
    virtual void accept();

    /**
     * This slot is reimplemented from TQDialog and
     * is connected to the cancel button.
     *
     * The dialog is closed (not deleted) when
     * this slot is called.
     *
     * @see accept, TQDialog::done
     */
    virtual void reject();

  public slots:

    /**
     * Shows a KDatePicker widget to select the start date.
     * This slot is activated by the select date button.
     */
    void showStartDatePicker();

    /**
     * Shows a KDatePicker widget to select the end date.
     * This slot is activated by the select date button.
     */
    void showEndDatePicker();

    /**
     * Slot for setting the start date in the KDateWidget.
     * Normally this slot is activated by a KDatePicker widget.
     */
    void setStartDate(TQDate);

    /**
     * Slot for setting the end date in the KDateWidget.
     * Normally this slot is activated by a KDatePicker widget.
     */
    void setEndDate(TQDate);

  public:

    // METHODS for getting data //

    /**
     * @returns the selected start date.
     */
    TQDate startDate() const;

    /**
     * @returns the selected end date.
     */
    TQDate endDate() const;

  signals:

    /**
     * This signal is emitted when the dialog is
     * accepted - that is, when the Insert button
     * is clicked.
     * This signal is meant to tell the
     * insert calendar plugin to actually insert
     * the calendar with the selected dates.
     */
    void insertCalendar(const TQDate &from, const TQDate &to);
};

}

#endif