author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /libkcal/dndfactory.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | libkcal/dndfactory.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libkcal/dndfactory.cpp b/libkcal/dndfactory.cpp index cdcfae4..ca7e212 100644 --- a/libkcal/dndfactory.cpp +++ b/libkcal/dndfactory.cpp | |||
@@ -9,32 +9,35 @@ | |||
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <qapplication.h> | 23 | #include <qapplication.h> |
24 | #include <qclipboard.h> | 24 | #include <qclipboard.h> |
25 | //Added by qt3to4: | ||
26 | #include <QDropEvent> | ||
27 | #include <Q3PtrList> | ||
25 | 28 | ||
26 | #include <kiconloader.h> | 29 | #include <kiconloader.h> |
27 | #include <kdebug.h> | 30 | #include <kdebug.h> |
28 | #include <kmessagebox.h> | 31 | #include <kmessagebox.h> |
29 | #include <klocale.h> | 32 | #include <klocale.h> |
30 | 33 | ||
31 | #include "vcaldrag.h" | 34 | #include "vcaldrag.h" |
32 | #include "icaldrag.h" | 35 | #include "icaldrag.h" |
33 | #include "calendar.h" | 36 | #include "calendar.h" |
34 | #include "vcalformat.h" | 37 | #include "vcalformat.h" |
35 | #include "icalformat.h" | 38 | #include "icalformat.h" |
36 | #include "calendarlocal.h" | 39 | #include "calendarlocal.h" |
37 | 40 | ||
38 | #include "dndfactory.h" | 41 | #include "dndfactory.h" |
39 | 42 | ||
40 | using namespace KCal; | 43 | using namespace KCal; |
@@ -55,52 +58,52 @@ ICalDrag *DndFactory::createDrag( Incidence *incidence, QWidget *owner ) | |||
55 | icd->setPixmap( BarIcon( "appointment" ) ); | 58 | icd->setPixmap( BarIcon( "appointment" ) ); |
56 | else if ( i->type() == "Todo" ) | 59 | else if ( i->type() == "Todo" ) |
57 | icd->setPixmap( BarIcon( "todo" ) ); | 60 | icd->setPixmap( BarIcon( "todo" ) ); |
58 | 61 | ||
59 | return icd; | 62 | return icd; |
60 | } | 63 | } |
61 | 64 | ||
62 | Event *DndFactory::createDrop(QDropEvent *de) | 65 | Event *DndFactory::createDrop(QDropEvent *de) |
63 | { | 66 | { |
64 | kdDebug(5800) << "DndFactory::createDrop()" << endl; | 67 | kdDebug(5800) << "DndFactory::createDrop()" << endl; |
65 | 68 | ||
66 | CalendarLocal cal( mCalendar->timeZoneId() ); | 69 | CalendarLocal cal( mCalendar->timeZoneId() ); |
67 | 70 | ||
68 | if ( ICalDrag::decode( de, &cal ) || VCalDrag::decode( de, &cal ) ) { | 71 | if ( ICalDrag::decode( de, &cal ) || VCalDrag::decode( de, &cal ) ) { |
69 | de->accept(); | 72 | de->accept(); |
70 | 73 | ||
71 | QPtrList<Event> events = cal.events(); | 74 | Q3PtrList<Event> events = cal.events(); |
72 | if ( !events.isEmpty() ) { | 75 | if ( !events.isEmpty() ) { |
73 | Event *event = new Event( *events.first() ); | 76 | Event *event = new Event( *events.first() ); |
74 | return event; | 77 | return event; |
75 | } | 78 | } |
76 | } | 79 | } |
77 | 80 | ||
78 | return 0; | 81 | return 0; |
79 | } | 82 | } |
80 | 83 | ||
81 | Todo *DndFactory::createDropTodo(QDropEvent *de) | 84 | Todo *DndFactory::createDropTodo(QDropEvent *de) |
82 | { | 85 | { |
83 | kdDebug(5800) << "VCalFormat::createDropTodo()" << endl; | 86 | kdDebug(5800) << "VCalFormat::createDropTodo()" << endl; |
84 | 87 | ||
85 | CalendarLocal cal( mCalendar->timeZoneId() ); | 88 | CalendarLocal cal( mCalendar->timeZoneId() ); |
86 | 89 | ||
87 | if ( ICalDrag::decode( de, &cal ) || VCalDrag::decode( de, &cal ) ) { | 90 | if ( ICalDrag::decode( de, &cal ) || VCalDrag::decode( de, &cal ) ) { |
88 | de->accept(); | 91 | de->accept(); |
89 | 92 | ||
90 | QPtrList<Todo> todos = cal.todos(); | 93 | Q3PtrList<Todo> todos = cal.todos(); |
91 | if ( !todos.isEmpty() ) { | 94 | if ( !todos.isEmpty() ) { |
92 | Todo *todo = new Todo( *todos.first() ); | 95 | Todo *todo = new Todo( *todos.first() ); |
93 | return todo; | 96 | return todo; |
94 | } | 97 | } |
95 | } | 98 | } |
96 | 99 | ||
97 | return 0; | 100 | return 0; |
98 | } | 101 | } |
99 | 102 | ||
100 | 103 | ||
101 | void DndFactory::cutIncidence( Incidence *selectedInc ) | 104 | void DndFactory::cutIncidence( Incidence *selectedInc ) |
102 | { | 105 | { |
103 | if ( copyIncidence( selectedInc ) ) { | 106 | if ( copyIncidence( selectedInc ) ) { |
104 | mCalendar->deleteIncidence( selectedInc ); | 107 | mCalendar->deleteIncidence( selectedInc ); |
105 | } | 108 | } |
106 | } | 109 | } |
@@ -120,33 +123,33 @@ bool DndFactory::copyIncidence( Incidence *selectedInc ) | |||
120 | } | 123 | } |
121 | 124 | ||
122 | Incidence *DndFactory::pasteIncidence(const QDate &newDate, const QTime *newTime) | 125 | Incidence *DndFactory::pasteIncidence(const QDate &newDate, const QTime *newTime) |
123 | { | 126 | { |
124 | // kdDebug(5800) << "DnDFactory::pasteEvent()" << endl; | 127 | // kdDebug(5800) << "DnDFactory::pasteEvent()" << endl; |
125 | 128 | ||
126 | CalendarLocal cal( mCalendar->timeZoneId() ); | 129 | CalendarLocal cal( mCalendar->timeZoneId() ); |
127 | 130 | ||
128 | QClipboard *cb = QApplication::clipboard(); | 131 | QClipboard *cb = QApplication::clipboard(); |
129 | 132 | ||
130 | if ( !ICalDrag::decode( cb->data(), &cal ) && | 133 | if ( !ICalDrag::decode( cb->data(), &cal ) && |
131 | !VCalDrag::decode( cb->data(), &cal ) ) { | 134 | !VCalDrag::decode( cb->data(), &cal ) ) { |
132 | kdDebug(5800) << "Can't parse clipboard" << endl; | 135 | kdDebug(5800) << "Can't parse clipboard" << endl; |
133 | return 0; | 136 | return 0; |
134 | } | 137 | } |
135 | 138 | ||
136 | QPtrList<Incidence> incList = cal.incidences(); | 139 | Q3PtrList<Incidence> incList = cal.incidences(); |
137 | Incidence *inc = incList.first(); | 140 | Incidence *inc = incList.first(); |
138 | 141 | ||
139 | if ( !incList.isEmpty() && inc ) { | 142 | if ( !incList.isEmpty() && inc ) { |
140 | inc = inc->clone(); | 143 | inc = inc->clone(); |
141 | 144 | ||
142 | inc->recreate(); | 145 | inc->recreate(); |
143 | 146 | ||
144 | if ( inc->type() == "Event" ) { | 147 | if ( inc->type() == "Event" ) { |
145 | 148 | ||
146 | Event *anEvent = static_cast<Event*>( inc ); | 149 | Event *anEvent = static_cast<Event*>( inc ); |
147 | // Calculate length of event | 150 | // Calculate length of event |
148 | int daysOffset = anEvent->dtStart().date().daysTo( | 151 | int daysOffset = anEvent->dtStart().date().daysTo( |
149 | anEvent->dtEnd().date() ); | 152 | anEvent->dtEnd().date() ); |
150 | // new end date if event starts at the same time on the new day | 153 | // new end date if event starts at the same time on the new day |
151 | QDateTime endDate( newDate.addDays(daysOffset), anEvent->dtEnd().time() ); | 154 | QDateTime endDate( newDate.addDays(daysOffset), anEvent->dtEnd().time() ); |
152 | 155 | ||