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
|
/***************************************************************************
mainwidget.cpp - description
-------------------
begin : Mon Nov 8 1999
copyright : (C) 1999 by Falk Brettschneider
email : falkbr@kdevelop.org
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include <qlayout.h>
#include <qmenubar.h>
#include <qtoolbar.h>
#include <qmultilineedit.h>
#include <qlistview.h>
#include <qfile.h>
#include <kmdimainfrm.h>
#include <kmditoolviewaccessor.h>
#include "mainwidget.h"
MainWidget::MainWidget(QDomElement& dockConfig,KMdi::MdiMode mode)
: KMdiMainFrm(0L, "theMDIMainFrm",mode)
,m_dockConfig(dockConfig)
{
setIDEAlModeStyle(1); // KDEV3
dockManager->setReadDockConfigMode(KDockManager::RestoreAllDockwidgets);
initMenu();
if (m_dockConfig.hasChildNodes()) {
readDockConfig(m_dockConfig);
}
QMultiLineEdit* mle = new QMultiLineEdit(0L,"theMultiLineEditWidget");
mle->setText("This is a QMultiLineEdit widget.");
addToolWindow( mle, KDockWidget::DockBottom, m_pMdi, 70);
QMultiLineEdit* mle2 = new QMultiLineEdit(0L,"theMultiLineEditWidget2");
addToolWindow( mle2, KDockWidget::DockCenter, mle, 70);
QMultiLineEdit* mle3 = new QMultiLineEdit(0L,"theMultiLineEditWidget3");
addToolWindow( mle3, KDockWidget::DockCenter, mle, 70);
QMultiLineEdit* mle4 = new QMultiLineEdit(0L,"theMultiLineEditWidget4");
addToolWindow( mle4, KDockWidget::DockCenter, mle, 70);
KMdiToolViewAccessor *tva=createToolWindow();
tva->setWidgetToWrap(new QMultiLineEdit(tva->wrapperWidget(),"theMultiLineEditWidget5"));
tva->placeAndShow(KDockWidget::DockCenter,mle,70);
QListView* lv = new QListView(0L,"theListViewWidget");
#include "../res/filenew.xpm"
lv->setIcon(filenew);
lv->addColumn("Test", 50);
lv->addColumn("KMDI", 70);
new QListViewItem(lv,QString("test"),QString("test"));
addToolWindow( lv, KDockWidget::DockLeft, m_pMdi, 35, "1");
QListView* lv2 = new QListView(0L,"theListViewWidget2");
lv2->setIcon(filenew);
lv2->addColumn("Test2", 50);
lv2->addColumn("KMDI2", 70);
new QListViewItem(lv,QString("test2"),QString("test2"));
addToolWindow( lv2, KDockWidget::DockCenter, lv, 35, "2");
QListView* lv3 = new QListView(0L,"theListViewWidget3");
lv3->setIcon(filenew);
lv3->addColumn("Test3", 50);
lv3->addColumn("KMDI3", 70);
new QListViewItem(lv,QString("test3"),QString("test3"));
addToolWindow( lv3, KDockWidget::DockCenter, lv, 35, "3");
dockManager->finishReadDockConfig();
setMenuForSDIModeSysButtons( menuBar());
}
MainWidget::~MainWidget()
{
writeDockConfig(m_dockConfig);
QDomDocument doc = m_dockConfig.ownerDocument();
QString s = doc.toString();
QFile f("/tmp/dc.txt");
f.open(IO_ReadWrite);
f.writeBlock(s.latin1(), s.length());
f.close();
}
void MainWidget::initMenu()
{
menuBar()->insertItem("&Window", windowMenu());
menuBar()->insertItem("&Docking", dockHideShowMenu());
}
/** additionally fit the system menu button position to the menu position */
void MainWidget::resizeEvent( QResizeEvent *pRSE)
{
KMdiMainFrm::resizeEvent( pRSE);
setSysButtonsAtMenuPosition();
}
RestartWidget::RestartWidget():KMainWindow()
{
mdimode=KMdi::ChildframeMode;
QVBoxLayout* bl = new QVBoxLayout(this);
QLabel* l = new QLabel("This is for the testing of\nKMdiMainFrm::read/writeDockConfig().\n", this);
QCheckBox* b1 = new QCheckBox("KMdiMainFrm close/restart", this);
b1->toggle();
QObject::connect(b1, SIGNAL(stateChanged(int)), this, SLOT(onStateChanged(int)));
bl->add(l);
bl->add(b1);
bl->setMargin(10);
bl->activate();
show();
dockConfig = domDoc.createElement("dockConfig");
domDoc.appendChild(dockConfig);
}
void RestartWidget::onStateChanged(int on)
{
if (on) {
m_w = new MainWidget(dockConfig,mdimode);
m_w->resize(500,500);
m_w->show();
}
else {
mdimode=m_w->mdiMode();
m_w->close();
delete m_w;
}
}
void RestartWidget::setWindow(MainWidget *w) {
m_w=w;
}
#include "mainwidget.moc"
|