summaryrefslogtreecommitdiffstats
path: root/konqueror/keditbookmarks/bookmarkinfo.h
blob: b1c00dc6b282226524c69f3c06c1c6bb36ce7d67 (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
/* This file is part of the KDE project
   Copyright (C) 2000 David Faure <faure@kde.org>
   Copyright (C) 2002-2003 Alexander Kellett <lypanov@kde.org>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License version 2 as published by the Free Software Foundation.

   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; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef __bookmarkinfo_h
#define __bookmarkinfo_h

#include "commands.h"

#include <kbookmark.h>
#include <tqwidget.h>
#include <klineedit.h>

class TQTimer;

class BookmarkLineEdit : public KLineEdit {
    Q_OBJECT
public:
    BookmarkLineEdit( TQWidget * );
public slots:
    virtual void cut ();
};


class BookmarkInfoWidget : public TQWidget {
    Q_OBJECT
public:
    BookmarkInfoWidget(TQWidget * = 0, const char * = 0);
    void showBookmark(const KBookmark &bk);
    void saveBookmark(const KBookmark &bk);
    KBookmark bookmark() { return m_bk; }
    bool connected() { return m_connected; };
    void setConnected(bool b) { m_connected = b; };
    void updateStatus();

public slots:
    void slotTextChangedURL(const TQString &);
    void slotTextChangedTitle(const TQString &);
    void slotTextChangedComment(const TQString &);

    // _The deal with all those commitChanges() calls_
    // First a short example how all the components 
    // normally fit together:
    // Note: not all details are included
    // For example: The user clicks on "New Bookmark"
    // This constructs a cmd = new CreateCommand( .. )
    // CmdHistory::self()->addCommand( cmd ) is called
    //   CmdHistory executes the command
    //   and enables the undo button
    //   and emits slotCommandExecuted
    // We catch the signal and call
    //  CurrentMgr::self()->notifyManagers( .. );

    // The bookmarkinfo widget is special, because
    // we don't want to send a notification 
    // for every change, but want to enable the undo
    // button and need to send the notification
    // if the user has stopped typing

    // So as soon as the user starts typing
    // we create a command
    // and call CmdHistory::self()->addInFlightCommand( cmd );
    // addInFlightCommand() doesn't execute the command, it just
    // adds it to the command history (To enable the undo button)
    // For every keystroke after that the command is modified
    // and we change our internal state to reflect the change
    // (Basically changing it in the same way, executing would have.)

    // At this point we have a modified state, but haven't send it
    // to the other bookmarkmanagers
    // That is done in commitChanges()
    // commitChanges() should be called everywhere, where we are
    // sure that the user has stopped typing.
    // And a few other cleanups are done in commitChanges()
    void commitChanges();
    void commitTitle();
    void commitURL();
    void commitComment();

signals:
    void updateListViewItem();
private:
    NodeEditCommand *titlecmd;
    EditCommand *urlcmd;
    NodeEditCommand *commentcmd;
    TQTimer * timer;
    BookmarkLineEdit *m_title_le, *m_url_le,
        *m_comment_le;
    KLineEdit  *m_visitdate_le, *m_credate_le,
              *m_visitcount_le;
    KBookmark m_bk;
    bool m_connected;
};

#endif