~ubuntu-branches/ubuntu/raring/juffed/raring

« back to all changes in this revision

Viewing changes to plugins/doclist/DocListPanel.h

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2011-04-30 13:43:26 UTC
  • mfrom: (2.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20110430134326-0bnvvo5z2medbdxi
Tags: 0.9.1137-1
* New upstream release.
* Remove debian/juffed.1, added upstream (in debian.in).
* Remove debian/patches/static.patch: we can now bundle the .so after
  upstream has resolved soname issues.
* debian/control:
  - Bump Standards-Version to 0.9.2.
  - Update homepage.
  - Do not build-depend on chrpath, not needed anymore.
* debian/rules:
  - Remove chrpath rule, not needed anymore.
* Add juffed-dev and juffed-plugins packages.
* Do not install the libkeybindings.so plugin: causes a segfault on my
  amd64 machine.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __DOC_LIST_PLUGIN_PANEL_H__
 
2
#define __DOC_LIST_PLUGIN_PANEL_H__
 
3
 
 
4
#include <QContextMenuEvent>
 
5
#include <QHBoxLayout>
 
6
#include <QLineEdit>
 
7
#include <QMenu>
 
8
#include <QPushButton>
 
9
#include <QWidget>
 
10
#include <QTreeWidget>
 
11
 
 
12
static const int BtnSize = 24;
 
13
 
 
14
class FilterLineEdit : public QWidget {
 
15
public:
 
16
        FilterLineEdit(QWidget* parent = 0) : QWidget(parent) {
 
17
                lineEd_ = new QLineEdit("", this);
 
18
                clearBtn_ = new QPushButton(QIcon(":clear"), "", this);
 
19
                clearBtn_->setFlat(true);
 
20
                clearBtn_->setFocusPolicy(Qt::NoFocus);
 
21
                clearBtn_->setCursor(Qt::ArrowCursor);
 
22
                clearBtn_->setMaximumWidth(BtnSize);
 
23
                
 
24
                QHBoxLayout* hBox = new QHBoxLayout(this);
 
25
                hBox->setMargin(0);
 
26
                hBox->setSpacing(0);
 
27
                hBox->addWidget(lineEd_);
 
28
#if QT_VERSION >= 0x040500
 
29
                lineEd_->setTextMargins(0, 0, BtnSize, 0);
 
30
                clearBtn_->setParent(lineEd_);
 
31
#else
 
32
                hBox->addWidget(clearBtn_);
 
33
#endif
 
34
        }
 
35
        
 
36
#if QT_VERSION >= 0x040500
 
37
        virtual void resizeEvent(QResizeEvent*) {
 
38
                clearBtn_->setGeometry(lineEd_->width() - BtnSize, (lineEd_->height() - BtnSize) / 2, BtnSize, BtnSize);
 
39
        }
 
40
#endif
 
41
        
 
42
        QLineEdit* lineEd_;
 
43
        QPushButton* clearBtn_;
 
44
};
 
45
 
 
46
class TreeWidget : public QTreeWidget {
 
47
public:
 
48
        TreeWidget() : QTreeWidget() {
 
49
                contextMenu_ = new QMenu();
 
50
//              contextMenu_->addAction(CommandStorage::instance()->action(Juff::FileSave));
 
51
//              contextMenu_->addAction(CommandStorage::instance()->action(Juff::FileClose));
 
52
        }
 
53
        virtual ~TreeWidget() {
 
54
                delete contextMenu_;
 
55
        }
 
56
        
 
57
        virtual void contextMenuEvent(QContextMenuEvent * event) {
 
58
                contextMenu_->popup(event->globalPos());
 
59
        }
 
60
        
 
61
        QMenu* contextMenu_;
 
62
};
 
63
 
 
64
 
 
65
 
 
66
class DocListPanel : public QWidget {
 
67
Q_OBJECT
 
68
public:
 
69
        DocListPanel();
 
70
 
 
71
        // Yes, it's an incapsulation violation but I'll better keep
 
72
        // it this way (for now) than introduce either 5 additional
 
73
        // methods to manage these members or two methods disclosing them
 
74
        // completely (which has no difference between it and currently 
 
75
        // selected approach).
 
76
        TreeWidget* tree_;
 
77
        FilterLineEdit* filter_;
 
78
 
 
79
public slots:
 
80
        void filterItems(const QString& text);
 
81
        void clear();
 
82
};
 
83
 
 
84
#endif