summaryrefslogtreecommitdiffstats
path: root/konq-plugins/sidebar/delicious/mainWidget.h
blob: 5970524cb5e51aadff59bfd61ee9fd137736c2ec (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
167
168
169
170
171
172
173
174
175
// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
//////////////////////////////////////////////////////////////////////////
// mainWidget.h                                                         //
//                                                                      //
// Copyright (C)  2005  Lukas Tinkl <lukas@kde.org>                     //
//                                                                      //
// This program is free software; you can redistribute it and/or        //
// modify it under the terms of the GNU General Public License          //
// as published by the Free Software Foundation; either version 2       //
// of the License, or (at your option) any later version.               //
//                                                                      //
// This program is distributed in the hope that it will be useful,      //
// but WITHOUT ANY WARRANTY; without even the implied warranty of       //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        //
// GNU General Public License for more details.                         //
//                                                                      //
// You should have received a copy of the GNU General Public License    //
// along with this program; if not, write to the Free Software          //
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA            //
// 02111-1307, USA.                                                     //
//////////////////////////////////////////////////////////////////////////

#ifndef _MAINWIDGET_H_
#define _MAINWIDGET_H_

#include "widget.h"

#include <kio/jobclasses.h>
#include <kparts/browserextension.h>

class QStringList;
class KURL;
class KConfig;

/**
 * Main widget of the del.icio.us bookmarks panel
 */
class MainWidget: public MainWidget_base
{
    Q_OBJECT
public:
    MainWidget( KConfig * config, QWidget * parent );
    ~MainWidget();

    /**
     * @return all the tags user has
     * (used in the DCOP iface)
     */
    QStringList tags() const;

    /**
     * @return all the (currently visible) bookmark (URLs)
     * (used in the DCOP iface)
     */
    QStringList bookmarks() const;

    /**
     * Set the internal URL to @p url
     */
    void setCurrentURL( const KURL & url );

public slots:
    /**
     * Show a dialog for adding a new bookmark
     */
    void slotNewBookmark();

private slots:
    /**
     * Start the job to get the list of tags
     */
    void slotGetTags();

    /**
     * Fill the Tags listview with job->data()
     * (parses the XML returned by the server)
     */
    void slotFillTags( KIO::Job * job );

    /**
     * Start the job to get the list of bookmarks
     * for checked tags
     */
    void slotGetBookmarks();

    /**
     * Fill the Bookmarks listview with job->data()
     * (parses the XML returned by the server)
     */
    void slotFillBookmarks( KIO::Job * job );

    /**
     * Handle clicking on a bookmark (KDE mode)
     */
    void slotBookmarkExecuted( QListViewItem * item );

    /**
     * Handle middle clicking a bookmark
     */
    void slotBookmarkClicked( int button, QListViewItem * item, const QPoint & pnt, int col );

    /**
     * Popup a tag context menu over @p item and position @pos
     */
    void slotTagsContextMenu( QListViewItem * item, const QPoint & pos, int col );

    /**
     * Popup a bookmark context menu over @p item and position @pos
     */
    void slotBookmarksContextMenu( QListViewItem * item, const QPoint & pos, int col );

    /**
     * Put a checkmark before all tags
     */
    void slotCheckAllTags();

    /**
     * Cancel the checkmark before all tags
     */
    void slotUncheckAllTags();

    /**
     * Toggle the checkmark before all tags
     */
    void slotToggleTags();

    /**
     * Starts a singleshot timer once an item (tag) has been toggled. Timer will update bookmarks.
     */
    void itemToggled();

    /**
     * Display a dialog box that allows renaming of tags
     */
    void slotRenameTag();

    /**
     * Delete the selected bookmark
     */
    void slotDeleteBookmark();

signals:
    /**
     * Emit a signal to the plugin interface that a @p url has been left-clicked
     */
    void signalURLClicked( const KURL & url, const KParts::URLArgs & args = KParts::URLArgs() );

    /**
     * Emit a signal to the plugin interface that a @p url has been mid-clicked
     */
    void signalURLMidClicked( const KURL & url, const KParts::URLArgs & args = KParts::URLArgs() );

private:
    /**
     * @return list of checked tags
     */
    QStringList checkedTags() const;

    /**
     * Save the tag list to the config file
     */
    void saveTags();

    /**
     * Load the tag list from the config file
     */
    void loadTags();

    QTimer *m_updateTimer;
    KURL m_currentURL;
    QStringList m_tags;
    KConfig * m_config;
};

#endif