File: quickopen.h

package info (click to toggle)
kdevelop 4%3A4.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 18,844 kB
  • sloc: cpp: 91,758; python: 1,095; lex: 422; ruby: 120; sh: 114; xml: 42; makefile: 38
file content (96 lines) | stat: -rw-r--r-- 3,387 bytes parent folder | download | duplicates (2)
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
/*
 * This file is part of KDevelop
 *
 * Copyright 2007 David Nolden <david.nolden.kdevelop@art-master.de>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Library 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.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef CPP_QUICKOPEN_H
#define CPP_QUICKOPEN_H

#include <language/interfaces/quickopendataprovider.h>
#include <language/interfaces/quickopenfilter.h>
#include <kurl.h>
#include <language/duchain/duchainpointer.h>
#include <language/duchain/indexedstring.h>
#include <language/util/includeitem.h>

class IncludeFileData : public KDevelop::QuickOpenDataBase {
  public:
    /**
     * includedFrom is zero if the file is not included into the current document
     * In case of importers(marked by item.pathNumber == -1), includedFrom should be the context of the current open document.
     * */
  IncludeFileData( const KDevelop::IncludeItem& item, const KDevelop::TopDUContextPointer& includedFrom );
    
    virtual QString text() const;
    virtual QString htmlDescription() const;

    bool execute( QString& filterText );

    virtual bool isExpandable() const;
    virtual QWidget* expandingWidget() const;

    virtual QList<QVariant> highlighting() const;
    
    virtual QIcon icon() const;
  private:
    KDevelop::IncludeItem m_item;
    bool m_isDirectory;
    KDevelop::TopDUContextPointer m_includedFrom;
};

/**
 * A QuickOpenDataProvider for file-completion using include-paths.
 * It provides all files from the whole include-path, filters them by the text, and
 * also searches sub-directories if the typed text wants it.
 * */

class IncludeFileDataProvider: public KDevelop::QuickOpenDataProviderBase, public KDevelop::FilterWithSeparator<KDevelop::IncludeItem>, public KDevelop::QuickOpenFileSetInterface {
  public:
    IncludeFileDataProvider();
    virtual void setFilterText( const QString& text );
    virtual void reset();
    virtual uint itemCount() const;
    virtual QList<KDevelop::QuickOpenDataPointer> data( uint start, uint end ) const;
    virtual void enableData( const QStringList& items, const QStringList& scopes );

    ///Returns all scopes supported by this data-provider
    static QStringList scopes();
    
    virtual QSet<KDevelop::IndexedString> files() const;
  private slots:
    void documentDestroyed( QObject* obl );
  private:
  
    //Reimplemented from Filter<..>
    virtual QString itemText( const KDevelop::IncludeItem& data ) const;

    KUrl m_baseUrl;
    QString m_lastSearchedPrefix;

    QList<KDevelop::IncludeItem> m_baseItems;
    
    bool m_allowImports, m_allowPossibleImports, m_allowImporters;

    ///Cache for all documents that import the current one
    QList<KDevelop::IndexedString> m_importers;
  
    KDevelop::TopDUContextPointer m_duContext;
};

#endif