summaryrefslogtreecommitdiffstats
path: root/src/documentlistview.h
blob: 37adc027ed26e20e5aef559a11e67f410b7f898d (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
/***************************************************************************
*   Copyright (C) 2004-2006 by Thomas Fischer                             *
*   fischer@unix-ag.uni-kl.de                                             *
*                                                                         *
*   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 KBIBTEXDOCUMENTLISTVIEW_H
#define KBIBTEXDOCUMENTLISTVIEW_H

#include <tdelistview.h>
#include <kxmlguifactory.h>

#include "fileimporter.h"
#include "settings.h"
#include "file.h"

class TQString;
class KURL;
class TDEActionMenu;
class TDEPopupMenu;

namespace KBibTeX
{
    class DocumentWidget;
    class DocumentListViewItem;

    class DocumentListView : public TDEListView
    {
        Q_OBJECT
    public:
        DocumentListView( KBibTeX::DocumentWidget *docWidget, bool isReadOnly, TQWidget *parent = 0, const char *name = 0 );
        ~DocumentListView();

        void setFactory( KXMLGUIFactory *factory, KXMLGUIClient *client );
        void setViewShowColumnsMenu( TDEActionMenu *actionMenu );

        bool setBibTeXFile( BibTeX::File *bibtexFile );
        BibTeX::File* getBibTeXFile( );
        KBibTeX::DocumentListViewItem *insertItem( BibTeX::Element *item, KBibTeX::DocumentListViewItem *after );

        void deleteSelected();
        const TQValueList<BibTeX::Element*> selectedItems();
//         void sendSelectedToLyx();

        void updateVisiblity();
        void updateVisiblity( KBibTeX::DocumentListViewItem *item );

        void deferredInitialization();
        void restoreState();

    signals:
        void modified();
        void executed( DocumentListViewItem* );

    public slots:
        void copy();
        void copyReferences();
        void cut();
        bool paste();
        bool paste( const TQString& text, DocumentListViewItem *at );
        void selectAll();
        void filter( const TQString& text, BibTeX::Element::FilterType filterType, BibTeX::EntryField::FieldType fieldType );
        void setReadOnly( bool isReadOnly );
        void activateShowColumnMenu( int id );

        void insertItems( BibTeX::File *items, KBibTeX::DocumentListViewItem *after = NULL );
        void insertItem( BibTeX::Element *item );

    private slots:
        void slotDoubleClick( TQListViewItem * item = NULL );
        void setSortingColumn( int column );
        void showBibtexListContextMenu( TDEListView *, TQListViewItem *, const TQPoint &p );
        void slotDropped( TQDropEvent* event, TQListViewItem* item );
        void saveColumnIndex();
        void restoreColumnIndex();
        void saveColumnWidths( int col = -1 );
        void restoreColumnWidths();
        void restoreSortingColumn();
        void makeNewItemsUnread();

    protected:
        bool acceptDrag( TQDropEvent* e ) const;
        void startDrag();

        virtual bool eventFilter( TQObject *watched, TQEvent *e );

        virtual void keyPressEvent( TQKeyEvent *e );

    private:
        static const int maxColumns = 256;
        KBibTeX::DocumentWidget *m_docWidget;
        BibTeX::File *m_bibtexFile;
        TDEPopupMenu *m_contextMenu;
        TDEPopupMenu *m_headerMenu;
        TDEActionMenu *m_columnVisibleAction;
        bool m_isReadOnly;
        TQValueList<DocumentListViewItem*> m_unreadItems;

        TQString m_filter;
        BibTeX::Element::FilterType m_filterType;
        BibTeX::EntryField::FieldType m_filterFieldType;
        int m_newElementCounter;

        void setItems();
        TQString selectedToBibTeXText();
        TQString selectedToBibTeXRefs();

        void showColumn( int col, int colWidth = 0xffff );
        void hideColumn( int col );
        void buildColumns();
    };
}

#endif