~ubuntu-branches/ubuntu/vivid/regina-normal/vivid-proposed

« back to all changes in this revision

Viewing changes to kdeui/src/part/packeteditiface.cpp

  • Committer: Package Import Robot
  • Author(s): Ben Burton
  • Date: 2011-09-10 07:17:25 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: package-import@ubuntu.com-20110910071725-97n90tywdq60w2cr
Tags: 4.90-1
* New upstream release!
* The user interface has been ported from KDE3 to KDE4 (closes: #556318).
  Re-enabled the GUI as a result.
* The build system has been ported from autotools to cmake.
* The new upstream release builds fine on amd64 (closes: #624882).
* Moved the users' handbook into regina-normal-doc.
* Upgraded several suggests/recommends.  Upgraded regina-normal-mpi to
  depend on mpi-default-bin, and regina-normal to depend on both graphviz
  and regina-normal-doc (which the GUI expends to be present).  Upgraded
  regina-normal to recommend gap.
* Bumped standards-version to 3.9.2.0 (no changes required).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/**************************************************************************
 
3
 *                                                                        *
 
4
 *  Regina - A Normal Surface Theory Calculator                           *
 
5
 *  KDE User Interface                                                    *
 
6
 *                                                                        *
 
7
 *  Copyright (c) 1999-2011, Ben Burton                                   *
 
8
 *  For further details contact Ben Burton (bab@debian.org).              *
 
9
 *                                                                        *
 
10
 *  This program is free software; you can redistribute it and/or         *
 
11
 *  modify it under the terms of the GNU General Public License as        *
 
12
 *  published by the Free Software Foundation; either version 2 of the    *
 
13
 *  License, or (at your option) any later version.                       *
 
14
 *                                                                        *
 
15
 *  This program is distributed in the hope that it will be useful, but   *
 
16
 *  WITHOUT ANY WARRANTY; without even the implied warranty of            *
 
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 
18
 *  General Public License for more details.                              *
 
19
 *                                                                        *
 
20
 *  You should have received a copy of the GNU General Public             *
 
21
 *  License along with this program; if not, write to the Free            *
 
22
 *  Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,       *
 
23
 *  MA 02110-1301, USA.                                                   *
 
24
 *                                                                        *
 
25
 **************************************************************************/
 
26
 
 
27
/* end stub */
 
28
 
 
29
// UI includes:
 
30
#include "packeteditiface.h"
 
31
#include "packettabui.h"
 
32
 
 
33
#include <qclipboard.h>
 
34
#include <qtreewidget.h>
 
35
#include <kapplication.h>
 
36
#include <ktexteditor/document.h>
 
37
#include <ktexteditor/view.h>
 
38
 
 
39
PacketEditTextEditor::PacketEditTextEditor(KTextEditor::View* view) :
 
40
        view_(view) {
 
41
    connect(this, SIGNAL(sendCutToEditor()), view, SLOT(cut()));
 
42
    connect(this, SIGNAL(sendCopyToEditor()), view, SLOT(copy()));
 
43
    connect(this, SIGNAL(sendPasteToEditor()), view, SLOT(paste()));
 
44
 
 
45
    connect(view_, SIGNAL(selectionChanged(KTextEditor::View*)),
 
46
        this, SLOT(fireStatesChanged()));
 
47
    connect(KApplication::kApplication()->clipboard(), SIGNAL(dataChanged()),
 
48
        this, SLOT(fireStatesChanged()));
 
49
}
 
50
 
 
51
bool PacketEditTextEditor::cutEnabled() const {
 
52
    return view_->selection() && view_->document()->isReadWrite();
 
53
}
 
54
 
 
55
bool PacketEditTextEditor::copyEnabled() const {
 
56
    return view_->selection();
 
57
}
 
58
 
 
59
bool PacketEditTextEditor::pasteEnabled() const {
 
60
    return (! (KApplication::kApplication()->clipboard()->text(
 
61
        QClipboard::Clipboard).isNull())) &&
 
62
        view_->document()->isReadWrite();
 
63
}
 
64
 
 
65
void PacketEditTextEditor::cut() {
 
66
    emit sendCutToEditor();
 
67
}
 
68
 
 
69
void PacketEditTextEditor::copy() {
 
70
    emit sendCopyToEditor();
 
71
}
 
72
 
 
73
void PacketEditTextEditor::paste() {
 
74
    emit sendPasteToEditor();
 
75
}
 
76
 
 
77
PacketEditTreeWidgetSingleLine::PacketEditTreeWidgetSingleLine(
 
78
        QTreeWidget* tree) : tree_(tree) {
 
79
    connect(tree_, SIGNAL(itemSelectionChanged()), this,
 
80
        SLOT(fireStatesChanged()));
 
81
}
 
82
 
 
83
bool PacketEditTreeWidgetSingleLine::copyEnabled() const {
 
84
    return (! tree_->selectedItems().empty());
 
85
}
 
86
 
 
87
void PacketEditTreeWidgetSingleLine::copy() {
 
88
    if (! tree_->selectedItems().empty())
 
89
        QApplication::clipboard()->setText(
 
90
            tree_->selectedItems().front()->text(0), QClipboard::Clipboard);
 
91
}
 
92
 
 
93
PacketEditTabbedUI::PacketEditTabbedUI(PacketTabbedUI* tabs) :
 
94
        tabs_(tabs) {
 
95
    connect(tabs_->tabs, SIGNAL(currentChanged(int)),
 
96
        this, SLOT(tabChanged(int)));
 
97
 
 
98
    currentTab_ = tabs_->currentInterface();
 
99
 
 
100
    if (currentTab_->getEditIface())
 
101
        connect(currentTab_->getEditIface(), SIGNAL(statesChanged()),
 
102
            this, SLOT(fireStatesChanged()));
 
103
}
 
104
 
 
105
bool PacketEditTabbedUI::cutEnabled() const {
 
106
    if (! (currentTab_ && currentTab_->getEditIface()))
 
107
        return false;
 
108
    return currentTab_->getEditIface()->cutEnabled();
 
109
}
 
110
 
 
111
bool PacketEditTabbedUI::copyEnabled() const {
 
112
    if (! (currentTab_ && currentTab_->getEditIface()))
 
113
        return false;
 
114
    return currentTab_->getEditIface()->copyEnabled();
 
115
}
 
116
 
 
117
bool PacketEditTabbedUI::pasteEnabled() const {
 
118
    if (! (currentTab_ && currentTab_->getEditIface()))
 
119
        return false;
 
120
    return currentTab_->getEditIface()->pasteEnabled();
 
121
}
 
122
 
 
123
void PacketEditTabbedUI::cut() {
 
124
    if (currentTab_ && currentTab_->getEditIface())
 
125
        currentTab_->getEditIface()->cut();
 
126
}
 
127
 
 
128
void PacketEditTabbedUI::copy() {
 
129
    if (currentTab_ && currentTab_->getEditIface())
 
130
        currentTab_->getEditIface()->copy();
 
131
}
 
132
 
 
133
void PacketEditTabbedUI::paste() {
 
134
    if (currentTab_ && currentTab_->getEditIface())
 
135
        currentTab_->getEditIface()->paste();
 
136
}
 
137
 
 
138
void PacketEditTabbedUI::tabChanged(int newTab) {
 
139
    if (currentTab_->getEditIface())
 
140
        disconnect(currentTab_->getEditIface(), SIGNAL(statesChanged()),
 
141
            this, SLOT(fireStatesChanged()));
 
142
 
 
143
    currentTab_ = tabs_->interfaceAtIndex(newTab);
 
144
    fireStatesChanged();
 
145
 
 
146
    if (currentTab_->getEditIface())
 
147
        connect(currentTab_->getEditIface(), SIGNAL(statesChanged()),
 
148
            this, SLOT(fireStatesChanged()));
 
149
}
 
150