~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy

« back to all changes in this revision

Viewing changes to klipper/historyurlitem.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*-
 
2
/* This file is part of the KDE project
 
3
   Copyright (C) 2004  Esben Mose Hansen <kde@mosehansen.dk>
 
4
 
 
5
   This program is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2 of the License, or (at your option) any later version.
 
9
 
 
10
   This program is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
    General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU General Public License
 
16
   along with this program; see the file COPYING.  If not, write to
 
17
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
   Boston, MA 02110-1301, USA.
 
19
*/
 
20
#include "historyurlitem.h"
 
21
 
 
22
#include <k3multipledrag.h>
 
23
#include <k3urldrag.h>
 
24
#include <Qt3Support/Q3CString>
 
25
 
 
26
HistoryURLItem::HistoryURLItem( const KUrl::List &_urls, KUrl::MetaDataMap _metaData, bool _cut )
 
27
    : urls( _urls ), metaData( _metaData ), cut( _cut )
 
28
{
 
29
}
 
30
 
 
31
/* virtual */
 
32
void HistoryURLItem::write( QDataStream& stream ) const
 
33
{
 
34
    stream << QString( "url" ) << urls << metaData << (int)cut;
 
35
}
 
36
 
 
37
QString HistoryURLItem::text() const {
 
38
    return urls.toStringList().join( " " );
 
39
}
 
40
 
 
41
QMimeData* HistoryURLItem::mimeData() const {
 
42
    QMimeData *data = new QMimeData();
 
43
    urls.populateMimeData(data, metaData);
 
44
    data->setData("application/x-kde-cutselection", QByteArray(cut ? "1" : "0"));
 
45
    return data;
 
46
}
 
47
 
 
48
bool HistoryURLItem::operator==( const HistoryItem& rhs) const
 
49
{
 
50
    if ( const HistoryURLItem* casted_rhs = dynamic_cast<const HistoryURLItem*>( &rhs ) ) {
 
51
        return casted_rhs->urls == urls
 
52
            && casted_rhs->metaData.count() == metaData.count()
 
53
            && qEqual( casted_rhs->metaData.begin(), casted_rhs->metaData.end(), metaData.begin())
 
54
            && casted_rhs->cut == cut;
 
55
    }
 
56
    return false;
 
57
}