summaryrefslogtreecommitdiffstats
path: root/kate/app/katefilelist.h
blob: e3504cb69fc1dee5a70c3c377619fea071454d49 (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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/* This file is part of the KDE project
   Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
   Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
   Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>

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

   This library 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef __KATE_FILELIST_H__
#define __KATE_FILELIST_H__

#include "katemain.h"

#include <kate/document.h>

#include <klistview.h>

#include <tqtooltip.h>
#include <tqcolor.h>
#include <tqptrlist.h>

#define RTTI_KateFileListItem 1001

class KateMainWindow;

class KAction;
class KSelectAction;

class KateFileListItem : public TQListViewItem
{
  public:
    KateFileListItem( TQListView *lv,
		      Kate::Document *doc );
    ~KateFileListItem();

    inline uint documentNumber () { return m_docNumber; }
    inline Kate::Document * document() { return doc; }

    int rtti() const { return RTTI_KateFileListItem; }

    /**
     * Sets the view history position.
     */
    void setViewHistPos( int p ) {  m_viewhistpos = p; }
    /**
     * Sets the edit history position.
     */
    void setEditHistPos( int p ) { m_edithistpos = p; }

  protected:
    virtual const TQPixmap *pixmap ( int column ) const;
    void paintCell( TQPainter *painter, const TQColorGroup & cg, int column, int width, int align );
    /**
     * Reimplemented so we can sort by a number of different document properties.
     */
    int compare ( TQListViewItem * i, int col, bool ascending ) const;

  private:
    Kate::Document *doc;
    int m_viewhistpos; ///< this gets set by the list as needed
    int m_edithistpos; ///< this gets set by the list as needed
    uint m_docNumber;
};

class KateFileList : public KListView
{
  Q_OBJECT

  friend class KFLConfigPage;

  public:
    KateFileList (KateMainWindow *main, KateViewManager *_viewManager, TQWidget * parent = 0, const char * name = 0 );
    ~KateFileList ();

    int sortType () const { return m_sort; };
    void updateSort ();

    enum sorting {
      sortByID = 0,
      sortByName = 1,
      sortByURL = 2,
      sortManual = 3
    };

    TQString tooltip( TQListViewItem *item, int );

    uint histCount() const { return m_viewHistory.count(); }
    uint editHistCount() const { return m_editHistory.count(); }
    TQColor editShade() const { return m_editShade; }
    TQColor viewShade() const { return m_viewShade; }
    bool shadingEnabled() { return m_enableBgShading; }

    void readConfig( class KConfig *config, const TQString &group );
    void writeConfig( class KConfig *config, const TQString &group );

    /**
     * reimplemented to remove the item from the history stacks
     */
    void takeItem( TQListViewItem * );

  public slots:
    void setSortType (int s);
    void moveFileUp();
    void moveFileDown();
    void slotNextDocument();
    void slotPrevDocument();

  private slots:
    void slotDocumentCreated (Kate::Document *doc);
    void slotDocumentDeleted (uint documentNumber);
    void slotActivateView( TQListViewItem *item );
    void slotModChanged (Kate::Document *doc);
    void slotModifiedOnDisc (Kate::Document *doc, bool b, unsigned char reason);
    void slotNameChanged (Kate::Document *doc);
    void slotViewChanged ();
    void slotMenu ( TQListViewItem *item, const TQPoint &p, int col );

  protected:
    virtual void keyPressEvent( TQKeyEvent *e );
    /**
     * Reimplemented to force Single mode for real:
     * don't let a mouse click outside items deselect.
     */
    virtual void contentsMousePressEvent( TQMouseEvent *e );
    /**
     * Reimplemented to make sure the first (and only) column is at least
     * the width of the viewport
     */
    virtual void resizeEvent( TQResizeEvent *e );

  private:
    void setupActions ();
    void updateActions ();

  private:
    KateMainWindow *m_main;
    KateViewManager *viewManager;

    int m_sort;
    bool notify;

    KAction* windowNext;
    KAction* windowPrev;
    KSelectAction* sortAction;
    KAction* listMoveFileUp;
    KAction* listMoveFileDown;

    TQPtrList<KateFileListItem> m_viewHistory;
    TQPtrList<KateFileListItem> m_editHistory;

    TQColor m_viewShade, m_editShade;
    bool m_enableBgShading;

    TQListViewItem *m_clickedMenuItem;

    class ToolTip *m_tooltip;
};

class KFLConfigPage : public Kate::ConfigPage {
  Q_OBJECT
  public:
    KFLConfigPage( TQWidget* parent=0, const char *name=0, KateFileList *fl=0 );
    virtual ~KFLConfigPage() {};

    virtual void apply();
    virtual void reload();

  public slots:
    void slotEnableChanged();

  private slots:
    void slotMyChanged();

  private:
    class TQCheckBox *cbEnableShading;
    class KColorButton *kcbViewShade, *kcbEditShade;
    class TQLabel *lEditShade, *lViewShade, *lSort;
    class TQComboBox *cmbSort;
    KateFileList *m_filelist;

    bool m_changed;
};


#endif
// kate: space-indent on; indent-width 2; replace-tabs on;