author | mickeyl <mickeyl> | 2003-12-07 13:51:01 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-12-07 13:51:01 (UTC) |
commit | c648101ca50a9782911b58b5158b31e1d0427ab3 (patch) (unidiff) | |
tree | 0fcf5801e23d95e071c7f1b62230c5b15c6256ea | |
parent | 2d793ca674944241480f6939814e3f61d0a0e0fb (diff) | |
download | opie-c648101ca50a9782911b58b5158b31e1d0427ab3.zip opie-c648101ca50a9782911b58b5158b31e1d0427ab3.tar.gz opie-c648101ca50a9782911b58b5158b31e1d0427ab3.tar.bz2 |
s/QPEMenuBar/QMenuBar:
- remove usage of deprecated classses
- makes it easier to migrate to OMenuBar in the future
43 files changed, 76 insertions, 67 deletions
diff --git a/core/apps/embeddedkonsole/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp index 8b2abfa..97b0a9e 100644 --- a/core/apps/embeddedkonsole/commandeditdialog.cpp +++ b/core/apps/embeddedkonsole/commandeditdialog.cpp | |||
@@ -1,199 +1,199 @@ | |||
1 | //comandeditdialog.cpp | 1 | //comandeditdialog.cpp |
2 | 2 | ||
3 | #include "commandeditdialog.h" | 3 | #include "commandeditdialog.h" |
4 | #include "playlistselection.h" | 4 | #include "playlistselection.h" |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | #include <qpe/config.h> | 6 | #include <qpe/config.h> |
7 | #include <qpe/qpetoolbar.h> | 7 | #include <qpe/qpetoolbar.h> |
8 | #include <qwidget.h> | 8 | #include <qwidget.h> |
9 | #include <qpe/qpemenubar.h> | 9 | #include <qmenubar.h> |
10 | #include <qpe/resource.h> | 10 | #include <qpe/resource.h> |
11 | #include <qlist.h> | 11 | #include <qlist.h> |
12 | #include <qtoolbutton.h> | 12 | #include <qtoolbutton.h> |
13 | #include <qvbox.h> | 13 | #include <qvbox.h> |
14 | #include <qlistview.h> | 14 | #include <qlistview.h> |
15 | #include <qlineedit.h> | 15 | #include <qlineedit.h> |
16 | #include <qheader.h> | 16 | #include <qheader.h> |
17 | #include <qlabel.h> | 17 | #include <qlabel.h> |
18 | #include <qmessagebox.h> | 18 | #include <qmessagebox.h> |
19 | #include "smallcommandeditdialogbase.h" | 19 | #include "smallcommandeditdialogbase.h" |
20 | 20 | ||
21 | CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) | 21 | CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) |
22 | : CommandEditDialogBase(parent, name, TRUE, fl) | 22 | : CommandEditDialogBase(parent, name, TRUE, fl) |
23 | 23 | ||
24 | { | 24 | { |
25 | m_SuggestedCommandList->addColumn( tr("Command Selection") ); | 25 | m_SuggestedCommandList->addColumn( tr("Command Selection") ); |
26 | m_SuggestedCommandList->header()->hide(); | 26 | m_SuggestedCommandList->header()->hide(); |
27 | m_SuggestedCommandList->setSorting(-1,FALSE); | 27 | m_SuggestedCommandList->setSorting(-1,FALSE); |
28 | m_SuggestedCommandList->clearSelection(); | 28 | m_SuggestedCommandList->clearSelection(); |
29 | m_SuggestedCommandList->setSorting(0,TRUE); | 29 | m_SuggestedCommandList->setSorting(0,TRUE); |
30 | QListViewItem *item; | 30 | QListViewItem *item; |
31 | item = new QListViewItem( m_SuggestedCommandList,"export "); | 31 | item = new QListViewItem( m_SuggestedCommandList,"export "); |
32 | item = new QListViewItem( m_SuggestedCommandList,"ifconfig "); | 32 | item = new QListViewItem( m_SuggestedCommandList,"ifconfig "); |
33 | item = new QListViewItem( m_SuggestedCommandList,"ipkg "); | 33 | item = new QListViewItem( m_SuggestedCommandList,"ipkg "); |
34 | item = new QListViewItem( m_SuggestedCommandList,"gzip "); | 34 | item = new QListViewItem( m_SuggestedCommandList,"gzip "); |
35 | item = new QListViewItem( m_SuggestedCommandList,"gunzip "); | 35 | item = new QListViewItem( m_SuggestedCommandList,"gunzip "); |
36 | item = new QListViewItem( m_SuggestedCommandList,"chgrp "); | 36 | item = new QListViewItem( m_SuggestedCommandList,"chgrp "); |
37 | item = new QListViewItem( m_SuggestedCommandList,"chown "); | 37 | item = new QListViewItem( m_SuggestedCommandList,"chown "); |
38 | item = new QListViewItem( m_SuggestedCommandList,"date "); | 38 | item = new QListViewItem( m_SuggestedCommandList,"date "); |
39 | item = new QListViewItem( m_SuggestedCommandList,"dd "); | 39 | item = new QListViewItem( m_SuggestedCommandList,"dd "); |
40 | item = new QListViewItem( m_SuggestedCommandList,"dmesg "); | 40 | item = new QListViewItem( m_SuggestedCommandList,"dmesg "); |
41 | item = new QListViewItem( m_SuggestedCommandList,"fuser "); | 41 | item = new QListViewItem( m_SuggestedCommandList,"fuser "); |
42 | item = new QListViewItem( m_SuggestedCommandList,"hostname "); | 42 | item = new QListViewItem( m_SuggestedCommandList,"hostname "); |
43 | item = new QListViewItem( m_SuggestedCommandList,"kill "); | 43 | item = new QListViewItem( m_SuggestedCommandList,"kill "); |
44 | item = new QListViewItem( m_SuggestedCommandList,"killall "); | 44 | item = new QListViewItem( m_SuggestedCommandList,"killall "); |
45 | item = new QListViewItem( m_SuggestedCommandList,"ln "); | 45 | item = new QListViewItem( m_SuggestedCommandList,"ln "); |
46 | item = new QListViewItem( m_SuggestedCommandList,"ln -s "); | 46 | item = new QListViewItem( m_SuggestedCommandList,"ln -s "); |
47 | item = new QListViewItem( m_SuggestedCommandList,"lsmod"); | 47 | item = new QListViewItem( m_SuggestedCommandList,"lsmod"); |
48 | item = new QListViewItem( m_SuggestedCommandList,"depmod -a"); | 48 | item = new QListViewItem( m_SuggestedCommandList,"depmod -a"); |
49 | item = new QListViewItem( m_SuggestedCommandList,"modprobe "); | 49 | item = new QListViewItem( m_SuggestedCommandList,"modprobe "); |
50 | item = new QListViewItem( m_SuggestedCommandList,"mount "); | 50 | item = new QListViewItem( m_SuggestedCommandList,"mount "); |
51 | item = new QListViewItem( m_SuggestedCommandList,"more "); | 51 | item = new QListViewItem( m_SuggestedCommandList,"more "); |
52 | item = new QListViewItem( m_SuggestedCommandList,"sort "); | 52 | item = new QListViewItem( m_SuggestedCommandList,"sort "); |
53 | item = new QListViewItem( m_SuggestedCommandList,"touch "); | 53 | item = new QListViewItem( m_SuggestedCommandList,"touch "); |
54 | item = new QListViewItem( m_SuggestedCommandList,"umount "); | 54 | item = new QListViewItem( m_SuggestedCommandList,"umount "); |
55 | item = new QListViewItem( m_SuggestedCommandList,"mknod "); | 55 | item = new QListViewItem( m_SuggestedCommandList,"mknod "); |
56 | item = new QListViewItem( m_SuggestedCommandList,"netstat "); | 56 | item = new QListViewItem( m_SuggestedCommandList,"netstat "); |
57 | item = new QListViewItem( m_SuggestedCommandList,"route "); | 57 | item = new QListViewItem( m_SuggestedCommandList,"route "); |
58 | item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); | 58 | item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); |
59 | m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); | 59 | m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); |
60 | m_SuggestedCommandList->sort(); | 60 | m_SuggestedCommandList->sort(); |
61 | 61 | ||
62 | connect( m_SuggestedCommandList, SIGNAL( clicked( QListViewItem * ) ), m_PlayListSelection, SLOT( addToSelection( QListViewItem *) ) ); | 62 | connect( m_SuggestedCommandList, SIGNAL( clicked( QListViewItem * ) ), m_PlayListSelection, SLOT( addToSelection( QListViewItem *) ) ); |
63 | 63 | ||
64 | 64 | ||
65 | 65 | ||
66 | ToolButton1->setTextLabel("new"); | 66 | ToolButton1->setTextLabel("new"); |
67 | ToolButton1->setPixmap(Resource::loadPixmap("new")); | 67 | ToolButton1->setPixmap(Resource::loadPixmap("new")); |
68 | ToolButton1->setAutoRaise(TRUE); | 68 | ToolButton1->setAutoRaise(TRUE); |
69 | ToolButton1->setFocusPolicy(QWidget::NoFocus); | 69 | ToolButton1->setFocusPolicy(QWidget::NoFocus); |
70 | connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); | 70 | connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); |
71 | 71 | ||
72 | ToolButton2->setTextLabel("edit"); | 72 | ToolButton2->setTextLabel("edit"); |
73 | ToolButton2->setPixmap(Resource::loadPixmap("edit")); | 73 | ToolButton2->setPixmap(Resource::loadPixmap("edit")); |
74 | ToolButton2->setAutoRaise(TRUE); | 74 | ToolButton2->setAutoRaise(TRUE); |
75 | ToolButton2->setFocusPolicy(QWidget::NoFocus); | 75 | ToolButton2->setFocusPolicy(QWidget::NoFocus); |
76 | connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); | 76 | connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); |
77 | 77 | ||
78 | ToolButton3->setTextLabel("delete"); | 78 | ToolButton3->setTextLabel("delete"); |
79 | ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); | 79 | ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); |
80 | ToolButton3->setAutoRaise(TRUE); | 80 | ToolButton3->setAutoRaise(TRUE); |
81 | ToolButton3->setFocusPolicy(QWidget::NoFocus); | 81 | ToolButton3->setFocusPolicy(QWidget::NoFocus); |
82 | connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); | 82 | connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); |
83 | 83 | ||
84 | ToolButton4->setTextLabel("up"); | 84 | ToolButton4->setTextLabel("up"); |
85 | ToolButton4->setPixmap(Resource::loadPixmap("up")); | 85 | ToolButton4->setPixmap(Resource::loadPixmap("up")); |
86 | ToolButton4->setAutoRaise(TRUE); | 86 | ToolButton4->setAutoRaise(TRUE); |
87 | ToolButton4->setFocusPolicy(QWidget::NoFocus); | 87 | ToolButton4->setFocusPolicy(QWidget::NoFocus); |
88 | connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); | 88 | connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); |
89 | 89 | ||
90 | ToolButton5->setTextLabel("down"); | 90 | ToolButton5->setTextLabel("down"); |
91 | ToolButton5->setPixmap(Resource::loadPixmap("down")); | 91 | ToolButton5->setPixmap(Resource::loadPixmap("down")); |
92 | ToolButton5->setAutoRaise(TRUE); | 92 | ToolButton5->setAutoRaise(TRUE); |
93 | ToolButton5->setFocusPolicy(QWidget::NoFocus); | 93 | ToolButton5->setFocusPolicy(QWidget::NoFocus); |
94 | 94 | ||
95 | connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); | 95 | connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); |
96 | 96 | ||
97 | 97 | ||
98 | 98 | ||
99 | 99 | ||
100 | QListViewItem *current = m_SuggestedCommandList->selectedItem(); | 100 | QListViewItem *current = m_SuggestedCommandList->selectedItem(); |
101 | if ( current ) | 101 | if ( current ) |
102 | item->moveItem( current ); | 102 | item->moveItem( current ); |
103 | m_SuggestedCommandList->setSelected( item, TRUE ); | 103 | m_SuggestedCommandList->setSelected( item, TRUE ); |
104 | m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); | 104 | m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); |
105 | Config cfg("Konsole"); | 105 | Config cfg("Konsole"); |
106 | cfg.setGroup("Commands"); | 106 | cfg.setGroup("Commands"); |
107 | if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { | 107 | if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { |
108 | for (int i = 0; i < 100; i++) { | 108 | for (int i = 0; i < 100; i++) { |
109 | QString tmp; | 109 | QString tmp; |
110 | tmp = cfg.readEntry( QString::number(i),""); | 110 | tmp = cfg.readEntry( QString::number(i),""); |
111 | if (!tmp.isEmpty()) | 111 | if (!tmp.isEmpty()) |
112 | m_PlayListSelection->addStringToSelection(tmp); | 112 | m_PlayListSelection->addStringToSelection(tmp); |
113 | } | 113 | } |
114 | } else { | 114 | } else { |
115 | 115 | ||
116 | m_PlayListSelection->addStringToSelection("ls "); | 116 | m_PlayListSelection->addStringToSelection("ls "); |
117 | m_PlayListSelection->addStringToSelection("cardctl eject"); | 117 | m_PlayListSelection->addStringToSelection("cardctl eject"); |
118 | m_PlayListSelection->addStringToSelection("cat "); | 118 | m_PlayListSelection->addStringToSelection("cat "); |
119 | m_PlayListSelection->addStringToSelection("cd "); | 119 | m_PlayListSelection->addStringToSelection("cd "); |
120 | m_PlayListSelection->addStringToSelection("chmod "); | 120 | m_PlayListSelection->addStringToSelection("chmod "); |
121 | m_PlayListSelection->addStringToSelection("cp "); | 121 | m_PlayListSelection->addStringToSelection("cp "); |
122 | m_PlayListSelection->addStringToSelection("dc "); | 122 | m_PlayListSelection->addStringToSelection("dc "); |
123 | m_PlayListSelection->addStringToSelection("df "); | 123 | m_PlayListSelection->addStringToSelection("df "); |
124 | m_PlayListSelection->addStringToSelection("dmesg"); | 124 | m_PlayListSelection->addStringToSelection("dmesg"); |
125 | m_PlayListSelection->addStringToSelection("echo "); | 125 | m_PlayListSelection->addStringToSelection("echo "); |
126 | m_PlayListSelection->addStringToSelection("env"); | 126 | m_PlayListSelection->addStringToSelection("env"); |
127 | m_PlayListSelection->addStringToSelection("find "); | 127 | m_PlayListSelection->addStringToSelection("find "); |
128 | m_PlayListSelection->addStringToSelection("free"); | 128 | m_PlayListSelection->addStringToSelection("free"); |
129 | m_PlayListSelection->addStringToSelection("grep "); | 129 | m_PlayListSelection->addStringToSelection("grep "); |
130 | m_PlayListSelection->addStringToSelection("ifconfig "); | 130 | m_PlayListSelection->addStringToSelection("ifconfig "); |
131 | m_PlayListSelection->addStringToSelection("ipkg "); | 131 | m_PlayListSelection->addStringToSelection("ipkg "); |
132 | m_PlayListSelection->addStringToSelection("mkdir "); | 132 | m_PlayListSelection->addStringToSelection("mkdir "); |
133 | m_PlayListSelection->addStringToSelection("mv "); | 133 | m_PlayListSelection->addStringToSelection("mv "); |
134 | m_PlayListSelection->addStringToSelection("nc localhost 7776"); | 134 | m_PlayListSelection->addStringToSelection("nc localhost 7776"); |
135 | m_PlayListSelection->addStringToSelection("nc localhost 7777"); | 135 | m_PlayListSelection->addStringToSelection("nc localhost 7777"); |
136 | m_PlayListSelection->addStringToSelection("nslookup "); | 136 | m_PlayListSelection->addStringToSelection("nslookup "); |
137 | m_PlayListSelection->addStringToSelection("ping "); | 137 | m_PlayListSelection->addStringToSelection("ping "); |
138 | m_PlayListSelection->addStringToSelection("ps aux"); | 138 | m_PlayListSelection->addStringToSelection("ps aux"); |
139 | m_PlayListSelection->addStringToSelection("pwd "); | 139 | m_PlayListSelection->addStringToSelection("pwd "); |
140 | m_PlayListSelection->addStringToSelection("rm "); | 140 | m_PlayListSelection->addStringToSelection("rm "); |
141 | m_PlayListSelection->addStringToSelection("rmdir "); | 141 | m_PlayListSelection->addStringToSelection("rmdir "); |
142 | m_PlayListSelection->addStringToSelection("route "); | 142 | m_PlayListSelection->addStringToSelection("route "); |
143 | m_PlayListSelection->addStringToSelection("set "); | 143 | m_PlayListSelection->addStringToSelection("set "); |
144 | m_PlayListSelection->addStringToSelection("traceroute"); | 144 | m_PlayListSelection->addStringToSelection("traceroute"); |
145 | 145 | ||
146 | } | 146 | } |
147 | } | 147 | } |
148 | CommandEditDialog::~CommandEditDialog() | 148 | CommandEditDialog::~CommandEditDialog() |
149 | { | 149 | { |
150 | } | 150 | } |
151 | 151 | ||
152 | void CommandEditDialog::accept() | 152 | void CommandEditDialog::accept() |
153 | { | 153 | { |
154 | int i = 0; | 154 | int i = 0; |
155 | Config *cfg = new Config("Konsole"); | 155 | Config *cfg = new Config("Konsole"); |
156 | cfg->setGroup("Commands"); | 156 | cfg->setGroup("Commands"); |
157 | cfg->clearGroup(); | 157 | cfg->clearGroup(); |
158 | 158 | ||
159 | QListViewItemIterator it( m_PlayListSelection ); | 159 | QListViewItemIterator it( m_PlayListSelection ); |
160 | 160 | ||
161 | for ( ; it.current(); ++it ) { | 161 | for ( ; it.current(); ++it ) { |
162 | // qDebug(it.current()->text(0)); | 162 | // qDebug(it.current()->text(0)); |
163 | cfg->writeEntry(QString::number(i),it.current()->text(0)); | 163 | cfg->writeEntry(QString::number(i),it.current()->text(0)); |
164 | i++; | 164 | i++; |
165 | 165 | ||
166 | } | 166 | } |
167 | cfg->writeEntry("Commands Set","TRUE"); | 167 | cfg->writeEntry("Commands Set","TRUE"); |
168 | // qDebug("CommandEditDialog::accept() - written"); | 168 | // qDebug("CommandEditDialog::accept() - written"); |
169 | delete cfg; | 169 | delete cfg; |
170 | emit commandsEdited(); | 170 | emit commandsEdited(); |
171 | close(); | 171 | close(); |
172 | 172 | ||
173 | 173 | ||
174 | 174 | ||
175 | 175 | ||
176 | 176 | ||
177 | } | 177 | } |
178 | 178 | ||
179 | void CommandEditDialog::showEditDialog() | 179 | void CommandEditDialog::showEditDialog() |
180 | { | 180 | { |
181 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); | 181 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); |
182 | d->setCaption("Edit command"); | 182 | d->setCaption("Edit command"); |
183 | d->TextLabel->setText("Edit command:"); | 183 | d->TextLabel->setText("Edit command:"); |
184 | d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); | 184 | d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); |
185 | int i = d->exec(); | 185 | int i = d->exec(); |
186 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) | 186 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) |
187 | m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); | 187 | m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); |
188 | } | 188 | } |
189 | 189 | ||
190 | void CommandEditDialog::showAddDialog() | 190 | void CommandEditDialog::showAddDialog() |
191 | { | 191 | { |
192 | 192 | ||
193 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); | 193 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); |
194 | int i = d->exec(); | 194 | int i = d->exec(); |
195 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) | 195 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) |
196 | m_PlayListSelection->addStringToSelection(d->commandEdit->text()); | 196 | m_PlayListSelection->addStringToSelection(d->commandEdit->text()); |
197 | 197 | ||
198 | } | 198 | } |
199 | 199 | ||
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index ec438c3..d855d90 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,544 +1,544 @@ | |||
1 | /* ---------------------------------------------------------------------- */ | 1 | /* ---------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [main.C] Konsole */ | 3 | /* [main.C] Konsole */ |
4 | /* */ | 4 | /* */ |
5 | /* ---------------------------------------------------------------------- */ | 5 | /* ---------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole, an X terminal. */ | 9 | /* This file is part of Konsole, an X terminal. */ |
10 | /* */ | 10 | /* */ |
11 | /* The material contained in here more or less directly orginates from */ | 11 | /* The material contained in here more or less directly orginates from */ |
12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
13 | /* */ | 13 | /* */ |
14 | /* ---------------------------------------------------------------------- */ | 14 | /* ---------------------------------------------------------------------- */ |
15 | /* */ | 15 | /* */ |
16 | /* Ported Konsole to Qt/Embedded */ | 16 | /* Ported Konsole to Qt/Embedded */ |
17 | /* */ | 17 | /* */ |
18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
19 | /* */ | 19 | /* */ |
20 | /* -------------------------------------------------------------------------- */ | 20 | /* -------------------------------------------------------------------------- */ |
21 | // enhancements added by L.J. Potter <ljp@llornkcor.com> | 21 | // enhancements added by L.J. Potter <ljp@llornkcor.com> |
22 | #define QT_QWS_OPIE | 22 | #define QT_QWS_OPIE |
23 | 23 | ||
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | #include <qdir.h> | 26 | #include <qdir.h> |
27 | #include <qevent.h> | 27 | #include <qevent.h> |
28 | #include <qdragobject.h> | 28 | #include <qdragobject.h> |
29 | #include <qobjectlist.h> | 29 | #include <qobjectlist.h> |
30 | #include <qtoolbutton.h> | 30 | #include <qtoolbutton.h> |
31 | #include <qpe/qpetoolbar.h> | 31 | #include <qpe/qpetoolbar.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qfontdialog.h> | 33 | #include <qfontdialog.h> |
34 | #include <qglobal.h> | 34 | #include <qglobal.h> |
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qpe/qpemenubar.h> | 36 | #include <qmenubar.h> |
37 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
38 | #include <qaction.h> | 38 | #include <qaction.h> |
39 | #include <qapplication.h> | 39 | #include <qapplication.h> |
40 | #include <qfontmetrics.h> | 40 | #include <qfontmetrics.h> |
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | #include <qevent.h> | 42 | #include <qevent.h> |
43 | #include <qtabwidget.h> | 43 | #include <qtabwidget.h> |
44 | #include <qtabbar.h> | 44 | #include <qtabbar.h> |
45 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
46 | #include <qstringlist.h> | 46 | #include <qstringlist.h> |
47 | #include <qpalette.h> | 47 | #include <qpalette.h> |
48 | 48 | ||
49 | #include <unistd.h> | 49 | #include <unistd.h> |
50 | #include <pwd.h> | 50 | #include <pwd.h> |
51 | #include <sys/types.h> | 51 | #include <sys/types.h> |
52 | #include <sys/wait.h> | 52 | #include <sys/wait.h> |
53 | #include <stdio.h> | 53 | #include <stdio.h> |
54 | #include <stdlib.h> | 54 | #include <stdlib.h> |
55 | #include <assert.h> | 55 | #include <assert.h> |
56 | 56 | ||
57 | #include "konsole.h" | 57 | #include "konsole.h" |
58 | #include "keytrans.h" | 58 | #include "keytrans.h" |
59 | #include "commandeditdialog.h" | 59 | #include "commandeditdialog.h" |
60 | 60 | ||
61 | #ifdef QT_QWS_OPIE | 61 | #ifdef QT_QWS_OPIE |
62 | #include <opie/colorpopupmenu.h> | 62 | #include <opie/colorpopupmenu.h> |
63 | #endif | 63 | #endif |
64 | 64 | ||
65 | class EKNumTabBar : public QTabBar { | 65 | class EKNumTabBar : public QTabBar { |
66 | public: | 66 | public: |
67 | void numberTabs() | 67 | void numberTabs() |
68 | { | 68 | { |
69 | // Yes, it really is this messy. QTabWidget needs functions | 69 | // Yes, it really is this messy. QTabWidget needs functions |
70 | // that provide acces to tabs in a sequential way. | 70 | // that provide acces to tabs in a sequential way. |
71 | int m=INT_MIN; | 71 | int m=INT_MIN; |
72 | for (int i=0; i<count(); i++) { | 72 | for (int i=0; i<count(); i++) { |
73 | QTab* left=0; | 73 | QTab* left=0; |
74 | QListIterator<QTab> it(*tabList()); | 74 | QListIterator<QTab> it(*tabList()); |
75 | int x=INT_MAX; | 75 | int x=INT_MAX; |
76 | for( QTab* t; (t=it.current()); ++it ) { | 76 | for( QTab* t; (t=it.current()); ++it ) { |
77 | int tx = t->rect().x(); | 77 | int tx = t->rect().x(); |
78 | if ( tx<x && tx>m ) { | 78 | if ( tx<x && tx>m ) { |
79 | x = tx; | 79 | x = tx; |
80 | left = t; | 80 | left = t; |
81 | } | 81 | } |
82 | } | 82 | } |
83 | if ( left ) { | 83 | if ( left ) { |
84 | left->setText(QString::number(i+1)); | 84 | left->setText(QString::number(i+1)); |
85 | m = left->rect().x(); | 85 | m = left->rect().x(); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | } | 88 | } |
89 | }; | 89 | }; |
90 | 90 | ||
91 | class EKNumTabWidget : public QTabWidget { | 91 | class EKNumTabWidget : public QTabWidget { |
92 | public: | 92 | public: |
93 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 93 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
94 | { | 94 | { |
95 | } | 95 | } |
96 | 96 | ||
97 | void addTab(QWidget* w) | 97 | void addTab(QWidget* w) |
98 | { | 98 | { |
99 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 99 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
100 | QTabWidget::addTab(w,t); | 100 | QTabWidget::addTab(w,t); |
101 | } | 101 | } |
102 | 102 | ||
103 | void removeTab(QWidget* w) | 103 | void removeTab(QWidget* w) |
104 | { | 104 | { |
105 | removePage(w); | 105 | removePage(w); |
106 | ((EKNumTabBar*)tabBar())->numberTabs(); | 106 | ((EKNumTabBar*)tabBar())->numberTabs(); |
107 | } | 107 | } |
108 | }; | 108 | }; |
109 | 109 | ||
110 | // This could be configurable or dynamicly generated from the bash history | 110 | // This could be configurable or dynamicly generated from the bash history |
111 | // file of the user | 111 | // file of the user |
112 | static const char *commonCmds[] = | 112 | static const char *commonCmds[] = |
113 | { | 113 | { |
114 | "ls ", // I left this here, cause it looks better than the first alpha | 114 | "ls ", // I left this here, cause it looks better than the first alpha |
115 | "cardctl eject", | 115 | "cardctl eject", |
116 | "cat ", | 116 | "cat ", |
117 | "cd ", | 117 | "cd ", |
118 | "chmod ", | 118 | "chmod ", |
119 | "clear", | 119 | "clear", |
120 | "cp ", | 120 | "cp ", |
121 | "dc ", | 121 | "dc ", |
122 | "df ", | 122 | "df ", |
123 | "dmesg", | 123 | "dmesg", |
124 | "echo ", | 124 | "echo ", |
125 | "env", | 125 | "env", |
126 | "find ", | 126 | "find ", |
127 | "free", | 127 | "free", |
128 | "grep ", | 128 | "grep ", |
129 | "ifconfig ", | 129 | "ifconfig ", |
130 | "ipkg ", | 130 | "ipkg ", |
131 | "mkdir ", | 131 | "mkdir ", |
132 | "mv ", | 132 | "mv ", |
133 | "nc localhost 7776", | 133 | "nc localhost 7776", |
134 | "nc localhost 7777", | 134 | "nc localhost 7777", |
135 | "netstat ", | 135 | "netstat ", |
136 | "nslookup ", | 136 | "nslookup ", |
137 | "ping ", | 137 | "ping ", |
138 | "ps aux", | 138 | "ps aux", |
139 | "pwd ", | 139 | "pwd ", |
140 | "qcop QPE/System 'linkChanged(QString)' ''", | 140 | "qcop QPE/System 'linkChanged(QString)' ''", |
141 | "qcop QPE/System 'restart()'", | 141 | "qcop QPE/System 'restart()'", |
142 | "qcop QPE/System 'quit()'", | 142 | "qcop QPE/System 'quit()'", |
143 | "rm ", | 143 | "rm ", |
144 | "rmdir ", | 144 | "rmdir ", |
145 | "route ", | 145 | "route ", |
146 | "set ", | 146 | "set ", |
147 | "traceroute", | 147 | "traceroute", |
148 | 148 | ||
149 | /* | 149 | /* |
150 | "gzip", | 150 | "gzip", |
151 | "gunzip", | 151 | "gunzip", |
152 | "chgrp", | 152 | "chgrp", |
153 | "chown", | 153 | "chown", |
154 | "date", | 154 | "date", |
155 | "dd", | 155 | "dd", |
156 | "df", | 156 | "df", |
157 | "dmesg", | 157 | "dmesg", |
158 | "fuser", | 158 | "fuser", |
159 | "hostname", | 159 | "hostname", |
160 | "kill", | 160 | "kill", |
161 | "killall", | 161 | "killall", |
162 | "ln", | 162 | "ln", |
163 | "ping", | 163 | "ping", |
164 | "mount", | 164 | "mount", |
165 | "more", | 165 | "more", |
166 | "sort", | 166 | "sort", |
167 | "touch", | 167 | "touch", |
168 | "umount", | 168 | "umount", |
169 | "mknod", | 169 | "mknod", |
170 | "netstat", | 170 | "netstat", |
171 | */ | 171 | */ |
172 | 172 | ||
173 | "exit", | 173 | "exit", |
174 | NULL | 174 | NULL |
175 | }; | 175 | }; |
176 | 176 | ||
177 | static void konsoleInit(const char** shell) { | 177 | static void konsoleInit(const char** shell) { |
178 | if(setuid(getuid()) !=0) qDebug("setuid failed"); | 178 | if(setuid(getuid()) !=0) qDebug("setuid failed"); |
179 | if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges | 179 | if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges |
180 | 180 | ||
181 | 181 | ||
182 | // QPEApplication::grabKeyboard(); // for CTRL and ALT | 182 | // QPEApplication::grabKeyboard(); // for CTRL and ALT |
183 | 183 | ||
184 | qDebug("keyboard grabbed"); | 184 | qDebug("keyboard grabbed"); |
185 | #ifdef FAKE_CTRL_AND_ALT | 185 | #ifdef FAKE_CTRL_AND_ALT |
186 | qDebug("Fake Ctrl and Alt defined"); | 186 | qDebug("Fake Ctrl and Alt defined"); |
187 | QPEApplication::grabKeyboard(); // for CTRL and ALT | 187 | QPEApplication::grabKeyboard(); // for CTRL and ALT |
188 | #endif | 188 | #endif |
189 | 189 | ||
190 | *shell = getenv("SHELL"); | 190 | *shell = getenv("SHELL"); |
191 | qWarning("SHell initially is %s", *shell ); | 191 | qWarning("SHell initially is %s", *shell ); |
192 | 192 | ||
193 | if (shell == NULL || *shell == '\0') { | 193 | if (shell == NULL || *shell == '\0') { |
194 | struct passwd *ent = 0; | 194 | struct passwd *ent = 0; |
195 | uid_t me = getuid(); | 195 | uid_t me = getuid(); |
196 | *shell = "/bin/sh"; | 196 | *shell = "/bin/sh"; |
197 | 197 | ||
198 | while ( (ent = getpwent()) != 0 ) { | 198 | while ( (ent = getpwent()) != 0 ) { |
199 | if (ent->pw_uid == me) { | 199 | if (ent->pw_uid == me) { |
200 | if (ent->pw_shell != "") | 200 | if (ent->pw_shell != "") |
201 | *shell = ent->pw_shell; | 201 | *shell = ent->pw_shell; |
202 | break; | 202 | break; |
203 | } | 203 | } |
204 | } | 204 | } |
205 | endpwent(); | 205 | endpwent(); |
206 | } | 206 | } |
207 | 207 | ||
208 | qWarning("SHELL now is %s", *shell ); | 208 | qWarning("SHELL now is %s", *shell ); |
209 | 209 | ||
210 | if( putenv((char*)"COLORTERM=") !=0) | 210 | if( putenv((char*)"COLORTERM=") !=0) |
211 | qDebug("putenv failed"); // to trigger mc's color detection | 211 | qDebug("putenv failed"); // to trigger mc's color detection |
212 | } | 212 | } |
213 | 213 | ||
214 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 214 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
215 | QMainWindow(parent, name, fl) | 215 | QMainWindow(parent, name, fl) |
216 | { | 216 | { |
217 | QStrList tmp; const char* shell; | 217 | QStrList tmp; const char* shell; |
218 | 218 | ||
219 | setCaption( tr("Terminal") ); | 219 | setCaption( tr("Terminal") ); |
220 | 220 | ||
221 | konsoleInit( &shell); | 221 | konsoleInit( &shell); |
222 | qWarning("Using shell %s", shell); | 222 | qWarning("Using shell %s", shell); |
223 | init(shell,tmp); | 223 | init(shell,tmp); |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | 227 | ||
228 | void Konsole::initCommandList() | 228 | void Konsole::initCommandList() |
229 | { | 229 | { |
230 | // qDebug("Konsole::initCommandList"); | 230 | // qDebug("Konsole::initCommandList"); |
231 | Config cfg("Konsole"); | 231 | Config cfg("Konsole"); |
232 | cfg.setGroup("Commands"); | 232 | cfg.setGroup("Commands"); |
233 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 233 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
234 | commonCombo->clear(); | 234 | commonCombo->clear(); |
235 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { | 235 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { |
236 | for (int i = 0; commonCmds[i] != NULL; i++) { | 236 | for (int i = 0; commonCmds[i] != NULL; i++) { |
237 | commonCombo->insertItem(commonCmds[i],i); | 237 | commonCombo->insertItem(commonCmds[i],i); |
238 | } | 238 | } |
239 | } else { | 239 | } else { |
240 | for (int i = 0; i < 100; i++) { | 240 | for (int i = 0; i < 100; i++) { |
241 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 241 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
242 | commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); | 242 | commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | } | 246 | } |
247 | 247 | ||
248 | void Konsole::init(const char* _pgm, QStrList & _args) | 248 | void Konsole::init(const char* _pgm, QStrList & _args) |
249 | { | 249 | { |
250 | b_scroll = TRUE; // histon; | 250 | b_scroll = TRUE; // histon; |
251 | n_keytab = 0; | 251 | n_keytab = 0; |
252 | n_render = 0; | 252 | n_render = 0; |
253 | startUp=0; | 253 | startUp=0; |
254 | fromMenu = FALSE; | 254 | fromMenu = FALSE; |
255 | 255 | ||
256 | setCaption( tr("Terminal") ); | 256 | setCaption( tr("Terminal") ); |
257 | setIcon( Resource::loadPixmap( "konsole" ) ); | 257 | setIcon( Resource::loadPixmap( "konsole" ) ); |
258 | 258 | ||
259 | Config cfg("Konsole"); | 259 | Config cfg("Konsole"); |
260 | cfg.setGroup("Konsole"); | 260 | cfg.setGroup("Konsole"); |
261 | QString tmp; | 261 | QString tmp; |
262 | // initialize the list of allowed fonts /////////////////////////////////// | 262 | // initialize the list of allowed fonts /////////////////////////////////// |
263 | cfont = cfg.readNumEntry("FontID", 1); | 263 | cfont = cfg.readNumEntry("FontID", 1); |
264 | QFont f = QFont("Micro", 4, QFont::Normal); | 264 | QFont f = QFont("Micro", 4, QFont::Normal); |
265 | f.setFixedPitch(TRUE); | 265 | f.setFixedPitch(TRUE); |
266 | fonts.append(new VTFont(tr("Micro"), f)); | 266 | fonts.append(new VTFont(tr("Micro"), f)); |
267 | 267 | ||
268 | f = QFont("Fixed", 7, QFont::Normal); | 268 | f = QFont("Fixed", 7, QFont::Normal); |
269 | f.setFixedPitch(TRUE); | 269 | f.setFixedPitch(TRUE); |
270 | fonts.append(new VTFont(tr("Small Fixed"), f)); | 270 | fonts.append(new VTFont(tr("Small Fixed"), f)); |
271 | 271 | ||
272 | f = QFont("Fixed", 12, QFont::Normal); | 272 | f = QFont("Fixed", 12, QFont::Normal); |
273 | f.setFixedPitch(TRUE); | 273 | f.setFixedPitch(TRUE); |
274 | fonts.append(new VTFont(tr("Medium Fixed"), f)); | 274 | fonts.append(new VTFont(tr("Medium Fixed"), f)); |
275 | 275 | ||
276 | // create terminal emulation framework //////////////////////////////////// | 276 | // create terminal emulation framework //////////////////////////////////// |
277 | nsessions = 0; | 277 | nsessions = 0; |
278 | 278 | ||
279 | tab = new EKNumTabWidget(this); | 279 | tab = new EKNumTabWidget(this); |
280 | 280 | ||
281 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 281 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
282 | 282 | ||
283 | // create terminal toolbar //////////////////////////////////////////////// | 283 | // create terminal toolbar //////////////////////////////////////////////// |
284 | setToolBarsMovable( FALSE ); | 284 | setToolBarsMovable( FALSE ); |
285 | QPEToolBar *menuToolBar = new QPEToolBar( this ); | 285 | QPEToolBar *menuToolBar = new QPEToolBar( this ); |
286 | menuToolBar->setHorizontalStretchable( TRUE ); | 286 | menuToolBar->setHorizontalStretchable( TRUE ); |
287 | 287 | ||
288 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); | 288 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); |
289 | 289 | ||
290 | fontList = new QPopupMenu( this ); | 290 | fontList = new QPopupMenu( this ); |
291 | for(uint i = 0; i < fonts.count(); i++) { | 291 | for(uint i = 0; i < fonts.count(); i++) { |
292 | VTFont *fnt = fonts.at(i); | 292 | VTFont *fnt = fonts.at(i); |
293 | fontList->insertItem(fnt->getName(), i); | 293 | fontList->insertItem(fnt->getName(), i); |
294 | } | 294 | } |
295 | fontChanged(cfont); | 295 | fontChanged(cfont); |
296 | 296 | ||
297 | configMenu = new QPopupMenu( this); | 297 | configMenu = new QPopupMenu( this); |
298 | colorMenu = new QPopupMenu( this); | 298 | colorMenu = new QPopupMenu( this); |
299 | scrollMenu = new QPopupMenu( this); | 299 | scrollMenu = new QPopupMenu( this); |
300 | editCommandListMenu = new QPopupMenu( this); | 300 | editCommandListMenu = new QPopupMenu( this); |
301 | 301 | ||
302 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 302 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
303 | 303 | ||
304 | bool listHidden; | 304 | bool listHidden; |
305 | cfg.setGroup("Menubar"); | 305 | cfg.setGroup("Menubar"); |
306 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { | 306 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { |
307 | editCommandListMenu->insertItem( tr( "Show command list" )); | 307 | editCommandListMenu->insertItem( tr( "Show command list" )); |
308 | listHidden=TRUE; | 308 | listHidden=TRUE; |
309 | } else { | 309 | } else { |
310 | editCommandListMenu->insertItem( tr( "Hide command list" )); | 310 | editCommandListMenu->insertItem( tr( "Hide command list" )); |
311 | listHidden=FALSE; | 311 | listHidden=FALSE; |
312 | } | 312 | } |
313 | 313 | ||
314 | cfg.setGroup("Tabs"); | 314 | cfg.setGroup("Tabs"); |
315 | tmp=cfg.readEntry("Position","Bottom"); | 315 | tmp=cfg.readEntry("Position","Bottom"); |
316 | if(tmp=="Top") { | 316 | if(tmp=="Top") { |
317 | tab->setTabPosition(QTabWidget::Top); | 317 | tab->setTabPosition(QTabWidget::Top); |
318 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); | 318 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); |
319 | } else { | 319 | } else { |
320 | tab->setTabPosition(QTabWidget::Bottom); | 320 | tab->setTabPosition(QTabWidget::Bottom); |
321 | configMenu->insertItem(tr("Tabs on Top")); | 321 | configMenu->insertItem(tr("Tabs on Top")); |
322 | } | 322 | } |
323 | configMenu->insertSeparator(2); | 323 | configMenu->insertSeparator(2); |
324 | 324 | ||
325 | colorMenu->insertItem(tr( "Green on Black")); | 325 | colorMenu->insertItem(tr( "Green on Black")); |
326 | colorMenu->insertItem(tr( "Black on White")); | 326 | colorMenu->insertItem(tr( "Black on White")); |
327 | colorMenu->insertItem(tr( "White on Black")); | 327 | colorMenu->insertItem(tr( "White on Black")); |
328 | colorMenu->insertItem(tr( "Black on Transparent")); | 328 | colorMenu->insertItem(tr( "Black on Transparent")); |
329 | colorMenu->insertItem(tr( "Black on Red")); | 329 | colorMenu->insertItem(tr( "Black on Red")); |
330 | colorMenu->insertItem(tr( "Red on Black")); | 330 | colorMenu->insertItem(tr( "Red on Black")); |
331 | colorMenu->insertItem(tr( "Green on Yellow")); | 331 | colorMenu->insertItem(tr( "Green on Yellow")); |
332 | colorMenu->insertItem(tr( "Blue on Magenta")); | 332 | colorMenu->insertItem(tr( "Blue on Magenta")); |
333 | colorMenu->insertItem(tr( "Magenta on Blue")); | 333 | colorMenu->insertItem(tr( "Magenta on Blue")); |
334 | colorMenu->insertItem(tr( "Cyan on White")); | 334 | colorMenu->insertItem(tr( "Cyan on White")); |
335 | colorMenu->insertItem(tr( "White on Cyan")); | 335 | colorMenu->insertItem(tr( "White on Cyan")); |
336 | colorMenu->insertItem(tr( "Blue on Black")); | 336 | colorMenu->insertItem(tr( "Blue on Black")); |
337 | colorMenu->insertItem(tr( "Amber on Black")); | 337 | colorMenu->insertItem(tr( "Amber on Black")); |
338 | 338 | ||
339 | #ifdef QT_QWS_OPIE | 339 | #ifdef QT_QWS_OPIE |
340 | colorMenu->insertItem(tr( "Custom")); | 340 | colorMenu->insertItem(tr( "Custom")); |
341 | #endif | 341 | #endif |
342 | 342 | ||
343 | configMenu->insertItem( tr("Font"), fontList ); | 343 | configMenu->insertItem( tr("Font"), fontList ); |
344 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 344 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
345 | 345 | ||
346 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 346 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
347 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 347 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
348 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 348 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
349 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 349 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
350 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 350 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
351 | 351 | ||
352 | menuBar->insertItem( tr("Options"), configMenu ); | 352 | menuBar->insertItem( tr("Options"), configMenu ); |
353 | 353 | ||
354 | QPEToolBar *toolbar = new QPEToolBar( this ); | 354 | QPEToolBar *toolbar = new QPEToolBar( this ); |
355 | 355 | ||
356 | QAction *a; | 356 | QAction *a; |
357 | 357 | ||
358 | // Button Commands | 358 | // Button Commands |
359 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); | 359 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); |
360 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); | 360 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); |
361 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 361 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
362 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); | 362 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); |
363 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 363 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
364 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); | 364 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); |
365 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 365 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
366 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); | 366 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); |
367 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 367 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
368 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 368 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
369 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 369 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
370 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 370 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
371 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 371 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
372 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); | 372 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); |
373 | /* | 373 | /* |
374 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); | 374 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); |
375 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 375 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
376 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); | 376 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); |
377 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 377 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
378 | */ | 378 | */ |
379 | 379 | ||
380 | secondToolBar = new QPEToolBar( this ); | 380 | secondToolBar = new QPEToolBar( this ); |
381 | secondToolBar->setHorizontalStretchable( TRUE ); | 381 | secondToolBar->setHorizontalStretchable( TRUE ); |
382 | 382 | ||
383 | commonCombo = new QComboBox( secondToolBar ); | 383 | commonCombo = new QComboBox( secondToolBar ); |
384 | commonCombo->setMaximumWidth(236); | 384 | commonCombo->setMaximumWidth(236); |
385 | 385 | ||
386 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 386 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
387 | if( listHidden) { | 387 | if( listHidden) { |
388 | secondToolBar->hide(); | 388 | secondToolBar->hide(); |
389 | editCommandListMenu->setItemEnabled(-23 ,FALSE); | 389 | editCommandListMenu->setItemEnabled(-23 ,FALSE); |
390 | } | 390 | } |
391 | editCommandListMenu->insertItem(tr( "Edit" ) ); | 391 | editCommandListMenu->insertItem(tr( "Edit" ) ); |
392 | 392 | ||
393 | cfg.setGroup("Commands"); | 393 | cfg.setGroup("Commands"); |
394 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 394 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
395 | 395 | ||
396 | initCommandList(); | 396 | initCommandList(); |
397 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 397 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
398 | // commonCombo->insertItem( commonCmds[i], i ); | 398 | // commonCombo->insertItem( commonCmds[i], i ); |
399 | // tmp = cfg.readEntry( QString::number(i),""); | 399 | // tmp = cfg.readEntry( QString::number(i),""); |
400 | // if(tmp != "") | 400 | // if(tmp != "") |
401 | // commonCombo->changeItem( tmp,i ); | 401 | // commonCombo->changeItem( tmp,i ); |
402 | // } | 402 | // } |
403 | 403 | ||
404 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 404 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
405 | 405 | ||
406 | scrollMenu->insertItem(tr( "None" )); | 406 | scrollMenu->insertItem(tr( "None" )); |
407 | scrollMenu->insertItem(tr( "Left" )); | 407 | scrollMenu->insertItem(tr( "Left" )); |
408 | scrollMenu->insertItem(tr( "Right" )); | 408 | scrollMenu->insertItem(tr( "Right" )); |
409 | // scrollMenu->insertSeparator(4); | 409 | // scrollMenu->insertSeparator(4); |
410 | // scrollMenu->insertItem(tr( "Horizontal" )); | 410 | // scrollMenu->insertItem(tr( "Horizontal" )); |
411 | 411 | ||
412 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 412 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
413 | 413 | ||
414 | int jut = configMenu->insertItem(tr( "Wrap" )); | 414 | int jut = configMenu->insertItem(tr( "Wrap" )); |
415 | cfg.setGroup("ScrollBar"); | 415 | cfg.setGroup("ScrollBar"); |
416 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); | 416 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); |
417 | 417 | ||
418 | jut = configMenu->insertItem(tr( "Use Beep" )); | 418 | jut = configMenu->insertItem(tr( "Use Beep" )); |
419 | cfg.setGroup("Menubar"); | 419 | cfg.setGroup("Menubar"); |
420 | 420 | ||
421 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); | 421 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); |
422 | 422 | ||
423 | 423 | ||
424 | //scrollMenuSelected(-29); | 424 | //scrollMenuSelected(-29); |
425 | // cfg.setGroup("ScrollBar"); | 425 | // cfg.setGroup("ScrollBar"); |
426 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 426 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
427 | // if(cfg.readNumEntry("Position",2) == 0) | 427 | // if(cfg.readNumEntry("Position",2) == 0) |
428 | // te->setScrollbarLocation(1); | 428 | // te->setScrollbarLocation(1); |
429 | // else | 429 | // else |
430 | // te->setScrollbarLocation(0); | 430 | // te->setScrollbarLocation(0); |
431 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 431 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
432 | // te->setWrapAt(120); | 432 | // te->setWrapAt(120); |
433 | // } | 433 | // } |
434 | // create applications ///////////////////////////////////////////////////// | 434 | // create applications ///////////////////////////////////////////////////// |
435 | setCentralWidget(tab); | 435 | setCentralWidget(tab); |
436 | 436 | ||
437 | // load keymaps //////////////////////////////////////////////////////////// | 437 | // load keymaps //////////////////////////////////////////////////////////// |
438 | KeyTrans::loadAll(); | 438 | KeyTrans::loadAll(); |
439 | for (int i = 0; i < KeyTrans::count(); i++) | 439 | for (int i = 0; i < KeyTrans::count(); i++) |
440 | { KeyTrans* s = KeyTrans::find(i); | 440 | { KeyTrans* s = KeyTrans::find(i); |
441 | assert( s ); | 441 | assert( s ); |
442 | } | 442 | } |
443 | 443 | ||
444 | se_pgm = _pgm; | 444 | se_pgm = _pgm; |
445 | se_args = _args; | 445 | se_args = _args; |
446 | se_args.prepend("--login"); | 446 | se_args.prepend("--login"); |
447 | parseCommandLine(); | 447 | parseCommandLine(); |
448 | // read and apply default values /////////////////////////////////////////// | 448 | // read and apply default values /////////////////////////////////////////// |
449 | resize(321, 321); // Dummy. | 449 | resize(321, 321); // Dummy. |
450 | QSize currentSize = size(); | 450 | QSize currentSize = size(); |
451 | if (currentSize != size()) | 451 | if (currentSize != size()) |
452 | defaultSize = size(); | 452 | defaultSize = size(); |
453 | } | 453 | } |
454 | 454 | ||
455 | void Konsole::show() | 455 | void Konsole::show() |
456 | { | 456 | { |
457 | if ( !nsessions ) { | 457 | if ( !nsessions ) { |
458 | newSession(); | 458 | newSession(); |
459 | } | 459 | } |
460 | QMainWindow::show(); | 460 | QMainWindow::show(); |
461 | 461 | ||
462 | } | 462 | } |
463 | 463 | ||
464 | void Konsole::initSession(const char*, QStrList &) | 464 | void Konsole::initSession(const char*, QStrList &) |
465 | { | 465 | { |
466 | QMainWindow::show(); | 466 | QMainWindow::show(); |
467 | } | 467 | } |
468 | 468 | ||
469 | Konsole::~Konsole() | 469 | Konsole::~Konsole() |
470 | { | 470 | { |
471 | while (nsessions > 0) { | 471 | while (nsessions > 0) { |
472 | doneSession(getTe()->currentSession, 0); | 472 | doneSession(getTe()->currentSession, 0); |
473 | } | 473 | } |
474 | 474 | ||
475 | Config cfg("Konsole"); | 475 | Config cfg("Konsole"); |
476 | cfg.setGroup("Konsole"); | 476 | cfg.setGroup("Konsole"); |
477 | cfg.writeEntry("FontID", cfont); | 477 | cfg.writeEntry("FontID", cfont); |
478 | } | 478 | } |
479 | 479 | ||
480 | void Konsole::fontChanged(int f) | 480 | void Konsole::fontChanged(int f) |
481 | { | 481 | { |
482 | VTFont* font = fonts.at(f); | 482 | VTFont* font = fonts.at(f); |
483 | if (font != 0) { | 483 | if (font != 0) { |
484 | for(uint i = 0; i < fonts.count(); i++) { | 484 | for(uint i = 0; i < fonts.count(); i++) { |
485 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 485 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
486 | } | 486 | } |
487 | 487 | ||
488 | cfont = f; | 488 | cfont = f; |
489 | 489 | ||
490 | TEWidget* te = getTe(); | 490 | TEWidget* te = getTe(); |
491 | if (te != 0) { | 491 | if (te != 0) { |
492 | te->setVTFont(font->getFont()); | 492 | te->setVTFont(font->getFont()); |
493 | } | 493 | } |
494 | } | 494 | } |
495 | } | 495 | } |
496 | 496 | ||
497 | 497 | ||
498 | void Konsole::enterCommand(int c) | 498 | void Konsole::enterCommand(int c) |
499 | { | 499 | { |
500 | TEWidget* te = getTe(); | 500 | TEWidget* te = getTe(); |
501 | if (te != 0) { | 501 | if (te != 0) { |
502 | if(!commonCombo->editable()) { | 502 | if(!commonCombo->editable()) { |
503 | QString text = commonCombo->text(c); //commonCmds[c]; | 503 | QString text = commonCombo->text(c); //commonCmds[c]; |
504 | te->emitText(text); | 504 | te->emitText(text); |
505 | } else { | 505 | } else { |
506 | changeCommand( commonCombo->text(c), c); | 506 | changeCommand( commonCombo->text(c), c); |
507 | } | 507 | } |
508 | } | 508 | } |
509 | } | 509 | } |
510 | 510 | ||
511 | void Konsole::hitEnter() | 511 | void Konsole::hitEnter() |
512 | { | 512 | { |
513 | TEWidget* te = getTe(); | 513 | TEWidget* te = getTe(); |
514 | if (te != 0) { | 514 | if (te != 0) { |
515 | te->emitText(QString("\r")); | 515 | te->emitText(QString("\r")); |
516 | } | 516 | } |
517 | } | 517 | } |
518 | 518 | ||
519 | void Konsole::hitSpace() | 519 | void Konsole::hitSpace() |
520 | { | 520 | { |
521 | TEWidget* te = getTe(); | 521 | TEWidget* te = getTe(); |
522 | if (te != 0) { | 522 | if (te != 0) { |
523 | te->emitText(QString(" ")); | 523 | te->emitText(QString(" ")); |
524 | } | 524 | } |
525 | } | 525 | } |
526 | 526 | ||
527 | void Konsole::hitTab() | 527 | void Konsole::hitTab() |
528 | { | 528 | { |
529 | TEWidget* te = getTe(); | 529 | TEWidget* te = getTe(); |
530 | if (te != 0) { | 530 | if (te != 0) { |
531 | te->emitText(QString("\t")); | 531 | te->emitText(QString("\t")); |
532 | } | 532 | } |
533 | } | 533 | } |
534 | 534 | ||
535 | void Konsole::hitPaste() | 535 | void Konsole::hitPaste() |
536 | { | 536 | { |
537 | TEWidget* te = getTe(); | 537 | TEWidget* te = getTe(); |
538 | if (te != 0) { | 538 | if (te != 0) { |
539 | te->pasteClipboard(); | 539 | te->pasteClipboard(); |
540 | } | 540 | } |
541 | } | 541 | } |
542 | 542 | ||
543 | void Konsole::hitUp() | 543 | void Konsole::hitUp() |
544 | { | 544 | { |
diff --git a/core/apps/helpbrowser/helpbrowser.cpp b/core/apps/helpbrowser/helpbrowser.cpp index 531dbff..ed1c165 100644 --- a/core/apps/helpbrowser/helpbrowser.cpp +++ b/core/apps/helpbrowser/helpbrowser.cpp | |||
@@ -1,250 +1,250 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_LANGLIST | 21 | #define QTOPIA_INTERNAL_LANGLIST |
22 | 22 | ||
23 | #include "helpbrowser.h" | 23 | #include "helpbrowser.h" |
24 | 24 | ||
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/mimetype.h> | 27 | #include <qpe/mimetype.h> |
28 | #include <qpe/applnk.h> | 28 | #include <qpe/applnk.h> |
29 | #include <qpe/global.h> | 29 | #include <qpe/global.h> |
30 | 30 | ||
31 | #include <qstatusbar.h> | 31 | #include <qstatusbar.h> |
32 | #include <qdragobject.h> | 32 | #include <qdragobject.h> |
33 | #include <qpixmap.h> | 33 | #include <qpixmap.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qpe/qpemenubar.h> | 35 | #include <qmenubar.h> |
36 | #include <qpe/qpetoolbar.h> | 36 | #include <qpe/qpetoolbar.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
38 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
39 | #include <qiconset.h> | 39 | #include <qiconset.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qstylesheet.h> | 42 | #include <qstylesheet.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qfiledialog.h> | 44 | #include <qfiledialog.h> |
45 | #include <qevent.h> | 45 | #include <qevent.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qobjectlist.h> | 47 | #include <qobjectlist.h> |
48 | #include <qfileinfo.h> | 48 | #include <qfileinfo.h> |
49 | #include <qfile.h> | 49 | #include <qfile.h> |
50 | #include <qdatastream.h> | 50 | #include <qdatastream.h> |
51 | #include <qprinter.h> | 51 | #include <qprinter.h> |
52 | #include <qsimplerichtext.h> | 52 | #include <qsimplerichtext.h> |
53 | #include <qpaintdevicemetrics.h> | 53 | #include <qpaintdevicemetrics.h> |
54 | #include <qaction.h> | 54 | #include <qaction.h> |
55 | 55 | ||
56 | #include <cctype> | 56 | #include <cctype> |
57 | 57 | ||
58 | #include "magictextbrowser.h" | 58 | #include "magictextbrowser.h" |
59 | 59 | ||
60 | HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) | 60 | HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) |
61 | : QMainWindow( parent, name, f ), | 61 | : QMainWindow( parent, name, f ), |
62 | selectedURL() | 62 | selectedURL() |
63 | { | 63 | { |
64 | init( "index.html" ); | 64 | init( "index.html" ); |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | 68 | ||
69 | void HelpBrowser::init( const QString& _home ) | 69 | void HelpBrowser::init( const QString& _home ) |
70 | { | 70 | { |
71 | setIcon( Resource::loadPixmap( "HelpBrowser" ) ); | 71 | setIcon( Resource::loadPixmap( "HelpBrowser" ) ); |
72 | setBackgroundMode( PaletteButton ); | 72 | setBackgroundMode( PaletteButton ); |
73 | 73 | ||
74 | browser = new MagicTextBrowser( this ); | 74 | browser = new MagicTextBrowser( this ); |
75 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 75 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
76 | connect( browser, SIGNAL( textChanged() ), | 76 | connect( browser, SIGNAL( textChanged() ), |
77 | this, SLOT( textChanged() ) ); | 77 | this, SLOT( textChanged() ) ); |
78 | 78 | ||
79 | setCentralWidget( browser ); | 79 | setCentralWidget( browser ); |
80 | setToolBarsMovable( FALSE ); | 80 | setToolBarsMovable( FALSE ); |
81 | 81 | ||
82 | if ( !_home.isEmpty() ) | 82 | if ( !_home.isEmpty() ) |
83 | browser->setSource( _home ); | 83 | browser->setSource( _home ); |
84 | 84 | ||
85 | QPEToolBar* toolbar = new QPEToolBar( this ); | 85 | QPEToolBar* toolbar = new QPEToolBar( this ); |
86 | toolbar->setHorizontalStretchable( TRUE ); | 86 | toolbar->setHorizontalStretchable( TRUE ); |
87 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 87 | QMenuBar *menu = new QMenuBar( toolbar ); |
88 | 88 | ||
89 | toolbar = new QPEToolBar( this ); | 89 | toolbar = new QPEToolBar( this ); |
90 | // addToolBar( toolbar, "Toolbar"); | 90 | // addToolBar( toolbar, "Toolbar"); |
91 | 91 | ||
92 | QPopupMenu* go = new QPopupMenu( this ); | 92 | QPopupMenu* go = new QPopupMenu( this ); |
93 | backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 ); | 93 | backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 ); |
94 | connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); | 94 | connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); |
95 | connect( browser, SIGNAL( backwardAvailable( bool ) ), | 95 | connect( browser, SIGNAL( backwardAvailable( bool ) ), |
96 | backAction, SLOT( setEnabled( bool ) ) ); | 96 | backAction, SLOT( setEnabled( bool ) ) ); |
97 | backAction->addTo( go ); | 97 | backAction->addTo( go ); |
98 | backAction->addTo( toolbar ); | 98 | backAction->addTo( toolbar ); |
99 | backAction->setEnabled( FALSE ); | 99 | backAction->setEnabled( FALSE ); |
100 | 100 | ||
101 | forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 ); | 101 | forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 ); |
102 | connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); | 102 | connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); |
103 | connect( browser, SIGNAL( forwardAvailable( bool ) ), | 103 | connect( browser, SIGNAL( forwardAvailable( bool ) ), |
104 | forwardAction, SLOT( setEnabled( bool ) ) ); | 104 | forwardAction, SLOT( setEnabled( bool ) ) ); |
105 | forwardAction->addTo( go ); | 105 | forwardAction->addTo( go ); |
106 | forwardAction->addTo( toolbar ); | 106 | forwardAction->addTo( toolbar ); |
107 | forwardAction->setEnabled( FALSE ); | 107 | forwardAction->setEnabled( FALSE ); |
108 | 108 | ||
109 | QAction *a = new QAction( tr( "Home" ), Resource::loadIconSet( "home" ), QString::null, 0, this, 0 ); | 109 | QAction *a = new QAction( tr( "Home" ), Resource::loadIconSet( "home" ), QString::null, 0, this, 0 ); |
110 | connect( a, SIGNAL( activated() ), browser, SLOT( home() ) ); | 110 | connect( a, SIGNAL( activated() ), browser, SLOT( home() ) ); |
111 | a->addTo( go ); | 111 | a->addTo( go ); |
112 | a->addTo( toolbar ); | 112 | a->addTo( toolbar ); |
113 | 113 | ||
114 | bookm = new QPopupMenu( this ); | 114 | bookm = new QPopupMenu( this ); |
115 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); | 115 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); |
116 | bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) ); | 116 | bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) ); |
117 | bookm->insertSeparator(); | 117 | bookm->insertSeparator(); |
118 | connect( bookm, SIGNAL( activated( int ) ), | 118 | connect( bookm, SIGNAL( activated( int ) ), |
119 | this, SLOT( bookmChosen( int ) ) ); | 119 | this, SLOT( bookmChosen( int ) ) ); |
120 | 120 | ||
121 | readBookmarks(); | 121 | readBookmarks(); |
122 | 122 | ||
123 | menu->insertItem( tr("Go"), go ); | 123 | menu->insertItem( tr("Go"), go ); |
124 | menu->insertItem( tr( "Bookmarks" ), bookm ); | 124 | menu->insertItem( tr( "Bookmarks" ), bookm ); |
125 | 125 | ||
126 | resize( 240, 300 ); | 126 | resize( 240, 300 ); |
127 | browser->setFocus(); | 127 | browser->setFocus(); |
128 | browser->setFrameStyle( QFrame::NoFrame ); | 128 | browser->setFrameStyle( QFrame::NoFrame ); |
129 | 129 | ||
130 | #if !defined(QT_NO_COP) | 130 | #if !defined(QT_NO_COP) |
131 | QCopChannel *addressChannel = new QCopChannel("QPE/HelpBrowser" , this ); | 131 | QCopChannel *addressChannel = new QCopChannel("QPE/HelpBrowser" , this ); |
132 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 132 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
133 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); | 133 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); |
134 | #endif | 134 | #endif |
135 | 135 | ||
136 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), | 136 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), |
137 | this, SLOT(appMessage(const QCString&, const QByteArray&)) ); | 137 | this, SLOT(appMessage(const QCString&, const QByteArray&)) ); |
138 | } | 138 | } |
139 | 139 | ||
140 | void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) | 140 | void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) |
141 | { | 141 | { |
142 | qDebug("reached appMessage"); | 142 | qDebug("reached appMessage"); |
143 | if ( msg == "showFile(QString)" ) { | 143 | if ( msg == "showFile(QString)" ) { |
144 | QDataStream ds(data,IO_ReadOnly); | 144 | QDataStream ds(data,IO_ReadOnly); |
145 | QString fn; | 145 | QString fn; |
146 | ds >> fn; | 146 | ds >> fn; |
147 | setDocument( fn ); | 147 | setDocument( fn ); |
148 | 148 | ||
149 | QPEApplication::setKeepRunning(); | 149 | QPEApplication::setKeepRunning(); |
150 | 150 | ||
151 | showMaximized(); | 151 | showMaximized(); |
152 | setActiveWindow(); | 152 | setActiveWindow(); |
153 | raise(); | 153 | raise(); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | 156 | ||
157 | void HelpBrowser::setDocument( const QString &doc ) | 157 | void HelpBrowser::setDocument( const QString &doc ) |
158 | { | 158 | { |
159 | if ( !doc.isEmpty() ) | 159 | if ( !doc.isEmpty() ) |
160 | browser->setSource( doc ); | 160 | browser->setSource( doc ); |
161 | raise(); | 161 | raise(); |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | void HelpBrowser::textChanged() | 165 | void HelpBrowser::textChanged() |
166 | { | 166 | { |
167 | if ( browser->documentTitle().isNull() ) | 167 | if ( browser->documentTitle().isNull() ) |
168 | setCaption( tr("Help Browser") ); | 168 | setCaption( tr("Help Browser") ); |
169 | else | 169 | else |
170 | setCaption( browser->documentTitle() ) ; | 170 | setCaption( browser->documentTitle() ) ; |
171 | 171 | ||
172 | selectedURL = caption(); | 172 | selectedURL = caption(); |
173 | } | 173 | } |
174 | 174 | ||
175 | HelpBrowser::~HelpBrowser() | 175 | HelpBrowser::~HelpBrowser() |
176 | { | 176 | { |
177 | QStringList bookmarks; | 177 | QStringList bookmarks; |
178 | QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin(); | 178 | QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin(); |
179 | for ( ; it2 != mBookmarks.end(); ++it2 ) | 179 | for ( ; it2 != mBookmarks.end(); ++it2 ) |
180 | bookmarks.append( (*it2).name + "=" + (*it2).file ); | 180 | bookmarks.append( (*it2).name + "=" + (*it2).file ); |
181 | 181 | ||
182 | QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") ); | 182 | QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") ); |
183 | if ( f2.open( IO_WriteOnly ) ) { | 183 | if ( f2.open( IO_WriteOnly ) ) { |
184 | QDataStream s2( &f2 ); | 184 | QDataStream s2( &f2 ); |
185 | s2 << bookmarks; | 185 | s2 << bookmarks; |
186 | f2.close(); | 186 | f2.close(); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | void HelpBrowser::pathSelected( const QString &_path ) | 190 | void HelpBrowser::pathSelected( const QString &_path ) |
191 | { | 191 | { |
192 | browser->setSource( _path ); | 192 | browser->setSource( _path ); |
193 | } | 193 | } |
194 | 194 | ||
195 | void HelpBrowser::readBookmarks() | 195 | void HelpBrowser::readBookmarks() |
196 | { | 196 | { |
197 | QString file = Global::applicationFileName("helpbrowser", "bookmarks"); | 197 | QString file = Global::applicationFileName("helpbrowser", "bookmarks"); |
198 | if ( QFile::exists( file ) ) { | 198 | if ( QFile::exists( file ) ) { |
199 | QStringList bookmarks; | 199 | QStringList bookmarks; |
200 | QFile f( file ); | 200 | QFile f( file ); |
201 | if ( f.open( IO_ReadOnly ) ) { | 201 | if ( f.open( IO_ReadOnly ) ) { |
202 | QDataStream s( &f ); | 202 | QDataStream s( &f ); |
203 | s >> bookmarks; | 203 | s >> bookmarks; |
204 | f.close(); | 204 | f.close(); |
205 | } | 205 | } |
206 | QStringList::Iterator it = bookmarks.begin(); | 206 | QStringList::Iterator it = bookmarks.begin(); |
207 | for ( ; it != bookmarks.end(); ++it ) { | 207 | for ( ; it != bookmarks.end(); ++it ) { |
208 | Bookmark b; | 208 | Bookmark b; |
209 | QString current = *it; | 209 | QString current = *it; |
210 | int equal = current.find( "=" ); | 210 | int equal = current.find( "=" ); |
211 | if ( equal < 1 || equal == (int)current.length() - 1 ) | 211 | if ( equal < 1 || equal == (int)current.length() - 1 ) |
212 | continue; | 212 | continue; |
213 | b.name = current.left( equal ); | 213 | b.name = current.left( equal ); |
214 | b.file = current.mid( equal + 1 ); | 214 | b.file = current.mid( equal + 1 ); |
215 | mBookmarks[ bookm->insertItem( b.name ) ] = b; | 215 | mBookmarks[ bookm->insertItem( b.name ) ] = b; |
216 | } | 216 | } |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | void HelpBrowser::bookmChosen( int i ) | 220 | void HelpBrowser::bookmChosen( int i ) |
221 | { | 221 | { |
222 | if ( mBookmarks.contains( i ) ) | 222 | if ( mBookmarks.contains( i ) ) |
223 | browser->setSource( mBookmarks[ i ].file ); | 223 | browser->setSource( mBookmarks[ i ].file ); |
224 | } | 224 | } |
225 | 225 | ||
226 | void HelpBrowser::addBookmark() | 226 | void HelpBrowser::addBookmark() |
227 | { | 227 | { |
228 | Bookmark b; | 228 | Bookmark b; |
229 | b.name = browser->documentTitle(); | 229 | b.name = browser->documentTitle(); |
230 | b.file = browser->source(); | 230 | b.file = browser->source(); |
231 | if (b.name.isEmpty() ) { | 231 | if (b.name.isEmpty() ) { |
232 | b.name = b.file.left( b.file.length() - 5 ); // remove .html | 232 | b.name = b.file.left( b.file.length() - 5 ); // remove .html |
233 | } | 233 | } |
234 | QMap<int, Bookmark>::Iterator it; | 234 | QMap<int, Bookmark>::Iterator it; |
235 | for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it ) | 235 | for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it ) |
236 | if ( (*it).file == b.file ) return; | 236 | if ( (*it).file == b.file ) return; |
237 | mBookmarks[ bookm->insertItem( b.name ) ] = b; | 237 | mBookmarks[ bookm->insertItem( b.name ) ] = b; |
238 | } | 238 | } |
239 | 239 | ||
240 | void HelpBrowser::removeBookmark() | 240 | void HelpBrowser::removeBookmark() |
241 | { | 241 | { |
242 | QString file = browser->source(); | 242 | QString file = browser->source(); |
243 | QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); | 243 | QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); |
244 | for( ; it != mBookmarks.end(); ++it ) | 244 | for( ; it != mBookmarks.end(); ++it ) |
245 | if ( (*it).file == file ) { | 245 | if ( (*it).file == file ) { |
246 | bookm->removeItem( it.key() ); | 246 | bookm->removeItem( it.key() ); |
247 | mBookmarks.remove( it ); | 247 | mBookmarks.remove( it ); |
248 | break; | 248 | break; |
249 | } | 249 | } |
250 | } | 250 | } |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index b875228..0e3254f 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,445 +1,445 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | // textedit.cpp | 2 | // textedit.cpp |
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file is part of Opie Environment. | 5 | ** This file is part of Opie Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | **********************************************************************/ | 12 | **********************************************************************/ |
13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 | 13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 |
14 | #include "textedit.h" | 14 | #include "textedit.h" |
15 | #include "filePermissions.h" | 15 | #include "filePermissions.h" |
16 | 16 | ||
17 | 17 | ||
18 | #include <opie/ofileselector.h> | 18 | #include <opie/ofileselector.h> |
19 | #include <opie/ofiledialog.h> | 19 | #include <opie/ofiledialog.h> |
20 | #include <opie/ofontselector.h> | 20 | #include <opie/ofontselector.h> |
21 | 21 | ||
22 | #include <qpe/fontdatabase.h> | 22 | #include <qpe/fontdatabase.h> |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/fileselector.h> | 24 | #include <qpe/fileselector.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #include <qpe/qpemenubar.h> | 29 | #include <qmenubar.h> |
30 | #include <qpe/qpetoolbar.h> | 30 | #include <qpe/qpetoolbar.h> |
31 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | 32 | ||
33 | #include <qpoint.h> | 33 | #include <qpoint.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include <qclipboard.h> | 36 | #include <qclipboard.h> |
37 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
38 | #include <qaction.h> | 38 | #include <qaction.h> |
39 | #include <qcolordialog.h> | 39 | #include <qcolordialog.h> |
40 | #include <qfileinfo.h> | 40 | #include <qfileinfo.h> |
41 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
42 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
43 | #include <qobjectlist.h> | 43 | #include <qobjectlist.h> |
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qspinbox.h> | 45 | #include <qspinbox.h> |
46 | #include <qtoolbutton.h> | 46 | #include <qtoolbutton.h> |
47 | #include <qwidgetstack.h> | 47 | #include <qwidgetstack.h> |
48 | #include <qcheckbox.h> | 48 | #include <qcheckbox.h> |
49 | #include <qcombo.h> | 49 | #include <qcombo.h> |
50 | #include <qlayout.h> | 50 | #include <qlayout.h> |
51 | #include <qapplication.h> | 51 | #include <qapplication.h> |
52 | #include <qtimer.h> | 52 | #include <qtimer.h> |
53 | #include <qdir.h> | 53 | #include <qdir.h> |
54 | #include <unistd.h> | 54 | #include <unistd.h> |
55 | #include <sys/stat.h> | 55 | #include <sys/stat.h> |
56 | #include <stdlib.h> //getenv | 56 | #include <stdlib.h> //getenv |
57 | 57 | ||
58 | #if QT_VERSION < 300 | 58 | #if QT_VERSION < 300 |
59 | 59 | ||
60 | class QpeEditor : public QMultiLineEdit | 60 | class QpeEditor : public QMultiLineEdit |
61 | { | 61 | { |
62 | 62 | ||
63 | public: | 63 | public: |
64 | QpeEditor( QWidget *parent, const char * name = 0 ) | 64 | QpeEditor( QWidget *parent, const char * name = 0 ) |
65 | : QMultiLineEdit( parent, name ) { | 65 | : QMultiLineEdit( parent, name ) { |
66 | clearTableFlags(); | 66 | clearTableFlags(); |
67 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 67 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
68 | } | 68 | } |
69 | 69 | ||
70 | void find( const QString &txt, bool caseSensitive, | 70 | void find( const QString &txt, bool caseSensitive, |
71 | bool backwards ); | 71 | bool backwards ); |
72 | protected: | 72 | protected: |
73 | bool markIt; | 73 | bool markIt; |
74 | int line1, line2, col1, col2; | 74 | int line1, line2, col1, col2; |
75 | void mousePressEvent( QMouseEvent * ); | 75 | void mousePressEvent( QMouseEvent * ); |
76 | void mouseReleaseEvent( QMouseEvent * ); | 76 | void mouseReleaseEvent( QMouseEvent * ); |
77 | 77 | ||
78 | //public slots: | 78 | //public slots: |
79 | /* | 79 | /* |
80 | signals: | 80 | signals: |
81 | void notFound(); | 81 | void notFound(); |
82 | void searchWrapped(); | 82 | void searchWrapped(); |
83 | */ | 83 | */ |
84 | 84 | ||
85 | private: | 85 | private: |
86 | 86 | ||
87 | }; | 87 | }; |
88 | 88 | ||
89 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { | 89 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { |
90 | switch(e->button()) { | 90 | switch(e->button()) { |
91 | case RightButton: | 91 | case RightButton: |
92 | { //rediculous workaround for qt popup menu | 92 | { //rediculous workaround for qt popup menu |
93 | //and the hold right click mechanism | 93 | //and the hold right click mechanism |
94 | this->setSelection( line1, col1, line2, col2); | 94 | this->setSelection( line1, col1, line2, col2); |
95 | QMultiLineEdit::mousePressEvent( e ); | 95 | QMultiLineEdit::mousePressEvent( e ); |
96 | markIt = false; | 96 | markIt = false; |
97 | } | 97 | } |
98 | break; | 98 | break; |
99 | default: | 99 | default: |
100 | { | 100 | { |
101 | if(!markIt) { | 101 | if(!markIt) { |
102 | int line, col; | 102 | int line, col; |
103 | this->getCursorPosition(&line, &col); | 103 | this->getCursorPosition(&line, &col); |
104 | line1=line2=line; | 104 | line1=line2=line; |
105 | col1=col2=col; | 105 | col1=col2=col; |
106 | } | 106 | } |
107 | QMultiLineEdit::mousePressEvent( e ); | 107 | QMultiLineEdit::mousePressEvent( e ); |
108 | } | 108 | } |
109 | break; | 109 | break; |
110 | }; | 110 | }; |
111 | } | 111 | } |
112 | 112 | ||
113 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { | 113 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { |
114 | if(this->hasMarkedText()) { | 114 | if(this->hasMarkedText()) { |
115 | markIt = true; | 115 | markIt = true; |
116 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); | 116 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); |
117 | } else { | 117 | } else { |
118 | markIt = false; | 118 | markIt = false; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 122 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
123 | bool backwards ) | 123 | bool backwards ) |
124 | { | 124 | { |
125 | static bool wrap = false; | 125 | static bool wrap = false; |
126 | int line, col; | 126 | int line, col; |
127 | if ( wrap ) { | 127 | if ( wrap ) { |
128 | if ( !backwards ) | 128 | if ( !backwards ) |
129 | line = col = 0; | 129 | line = col = 0; |
130 | wrap = false; | 130 | wrap = false; |
131 | // emit searchWrapped(); | 131 | // emit searchWrapped(); |
132 | } else { | 132 | } else { |
133 | getCursorPosition( &line, &col ); | 133 | getCursorPosition( &line, &col ); |
134 | } | 134 | } |
135 | //ignore backwards for now.... | 135 | //ignore backwards for now.... |
136 | if ( !backwards ) { | 136 | if ( !backwards ) { |
137 | for ( ; ; ) { | 137 | for ( ; ; ) { |
138 | if ( line >= numLines() ) { | 138 | if ( line >= numLines() ) { |
139 | wrap = true; | 139 | wrap = true; |
140 | //emit notFound(); | 140 | //emit notFound(); |
141 | break; | 141 | break; |
142 | } | 142 | } |
143 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 143 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
144 | if ( findCol >= 0 ) { | 144 | if ( findCol >= 0 ) { |
145 | setCursorPosition( line, findCol, false ); | 145 | setCursorPosition( line, findCol, false ); |
146 | col = findCol + txt.length(); | 146 | col = findCol + txt.length(); |
147 | setCursorPosition( line, col, true ); | 147 | setCursorPosition( line, col, true ); |
148 | 148 | ||
149 | //found = true; | 149 | //found = true; |
150 | break; | 150 | break; |
151 | } | 151 | } |
152 | line++; | 152 | line++; |
153 | col = 0; | 153 | col = 0; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | #else | 159 | #else |
160 | 160 | ||
161 | #error "Must make a QpeEditor that inherits QTextEdit" | 161 | #error "Must make a QpeEditor that inherits QTextEdit" |
162 | 162 | ||
163 | #endif | 163 | #endif |
164 | 164 | ||
165 | 165 | ||
166 | static const int nfontsizes = 6; | 166 | static const int nfontsizes = 6; |
167 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 167 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
168 | 168 | ||
169 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 169 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
170 | : QMainWindow( parent, name, f ), bFromDocView( false ) | 170 | : QMainWindow( parent, name, f ), bFromDocView( false ) |
171 | { | 171 | { |
172 | doc = 0; | 172 | doc = 0; |
173 | edited=false; | 173 | edited=false; |
174 | fromSetDocument=false; | 174 | fromSetDocument=false; |
175 | 175 | ||
176 | setToolBarsMovable( false ); | 176 | setToolBarsMovable( false ); |
177 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 177 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
178 | 178 | ||
179 | channel = new QCopChannel( "QPE/Application/textedit", this ); | 179 | channel = new QCopChannel( "QPE/Application/textedit", this ); |
180 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 180 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
181 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 181 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
182 | 182 | ||
183 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 183 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
184 | 184 | ||
185 | QPEToolBar *bar = new QPEToolBar( this ); | 185 | QPEToolBar *bar = new QPEToolBar( this ); |
186 | bar->setHorizontalStretchable( true ); | 186 | bar->setHorizontalStretchable( true ); |
187 | menu = bar; | 187 | menu = bar; |
188 | 188 | ||
189 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 189 | QMenuBar *mb = new QMenuBar( bar ); |
190 | QPopupMenu *file = new QPopupMenu( this ); | 190 | QPopupMenu *file = new QPopupMenu( this ); |
191 | QPopupMenu *edit = new QPopupMenu( this ); | 191 | QPopupMenu *edit = new QPopupMenu( this ); |
192 | QPopupMenu *advancedMenu = new QPopupMenu(this); | 192 | QPopupMenu *advancedMenu = new QPopupMenu(this); |
193 | 193 | ||
194 | font = new QPopupMenu( this ); | 194 | font = new QPopupMenu( this ); |
195 | 195 | ||
196 | bar = new QPEToolBar( this ); | 196 | bar = new QPEToolBar( this ); |
197 | editBar = bar; | 197 | editBar = bar; |
198 | 198 | ||
199 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 199 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), |
200 | QString::null, 0, this, 0 ); | 200 | QString::null, 0, this, 0 ); |
201 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 201 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
202 | // a->addTo( bar ); | 202 | // a->addTo( bar ); |
203 | a->addTo( file ); | 203 | a->addTo( file ); |
204 | 204 | ||
205 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), | 205 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), |
206 | QString::null, 0, this, 0 ); | 206 | QString::null, 0, this, 0 ); |
207 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 207 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
208 | a->addTo( bar ); | 208 | a->addTo( bar ); |
209 | a->addTo( file ); | 209 | a->addTo( file ); |
210 | 210 | ||
211 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , | 211 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , |
212 | QString::null, 0, this, 0 ); | 212 | QString::null, 0, this, 0 ); |
213 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 213 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
214 | file->insertSeparator(); | 214 | file->insertSeparator(); |
215 | a->addTo( bar ); | 215 | a->addTo( bar ); |
216 | a->addTo( file ); | 216 | a->addTo( file ); |
217 | 217 | ||
218 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , | 218 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , |
219 | QString::null, 0, this, 0 ); | 219 | QString::null, 0, this, 0 ); |
220 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 220 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
221 | a->addTo( file ); | 221 | a->addTo( file ); |
222 | 222 | ||
223 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), | 223 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), |
224 | QString::null, 0, this, 0 ); | 224 | QString::null, 0, this, 0 ); |
225 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 225 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
226 | a->addTo( editBar ); | 226 | a->addTo( editBar ); |
227 | a->addTo( edit ); | 227 | a->addTo( edit ); |
228 | 228 | ||
229 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), | 229 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), |
230 | QString::null, 0, this, 0 ); | 230 | QString::null, 0, this, 0 ); |
231 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 231 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
232 | a->addTo( editBar ); | 232 | a->addTo( editBar ); |
233 | a->addTo( edit ); | 233 | a->addTo( edit ); |
234 | 234 | ||
235 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), | 235 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), |
236 | QString::null, 0, this, 0 ); | 236 | QString::null, 0, this, 0 ); |
237 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 237 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
238 | a->addTo( editBar ); | 238 | a->addTo( editBar ); |
239 | a->addTo( edit ); | 239 | a->addTo( edit ); |
240 | 240 | ||
241 | 241 | ||
242 | #ifndef QT_NO_CLIPBOARD | 242 | #ifndef QT_NO_CLIPBOARD |
243 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), | 243 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), |
244 | QString::null, 0, this, 0 ); | 244 | QString::null, 0, this, 0 ); |
245 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | 245 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); |
246 | a->addTo( edit ); | 246 | a->addTo( edit ); |
247 | #endif | 247 | #endif |
248 | 248 | ||
249 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), | 249 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), |
250 | QString::null, 0, this, 0 ); | 250 | QString::null, 0, this, 0 ); |
251 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); | 251 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); |
252 | edit->insertSeparator(); | 252 | edit->insertSeparator(); |
253 | a->addTo( edit ); | 253 | a->addTo( edit ); |
254 | 254 | ||
255 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), | 255 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), |
256 | QString::null, 0, this, 0 ); | 256 | QString::null, 0, this, 0 ); |
257 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 257 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
258 | a->addTo( bar ); | 258 | a->addTo( bar ); |
259 | a->addTo( edit ); | 259 | a->addTo( edit ); |
260 | 260 | ||
261 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 261 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
262 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 262 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
263 | zin->addTo( font ); | 263 | zin->addTo( font ); |
264 | 264 | ||
265 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 265 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
266 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 266 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
267 | zout->addTo( font ); | 267 | zout->addTo( font ); |
268 | 268 | ||
269 | font->insertSeparator(); | 269 | font->insertSeparator(); |
270 | 270 | ||
271 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 271 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
272 | 272 | ||
273 | font->insertSeparator(); | 273 | font->insertSeparator(); |
274 | font->insertItem(tr("Advanced Features"), advancedMenu); | 274 | font->insertItem(tr("Advanced Features"), advancedMenu); |
275 | 275 | ||
276 | QAction *wa = new QAction( tr("Wrap lines"), | 276 | QAction *wa = new QAction( tr("Wrap lines"), |
277 | QString::null, 0, this, 0 ); | 277 | QString::null, 0, this, 0 ); |
278 | connect( wa, SIGNAL( toggled(bool) ), | 278 | connect( wa, SIGNAL( toggled(bool) ), |
279 | this, SLOT( setWordWrap(bool) ) ); | 279 | this, SLOT( setWordWrap(bool) ) ); |
280 | wa->setToggleAction(true); | 280 | wa->setToggleAction(true); |
281 | wa->addTo( advancedMenu); | 281 | wa->addTo( advancedMenu); |
282 | 282 | ||
283 | nStart = new QAction( tr("Start with new file"), | 283 | nStart = new QAction( tr("Start with new file"), |
284 | QString::null, 0, this, 0 ); | 284 | QString::null, 0, this, 0 ); |
285 | connect( nStart, SIGNAL( toggled(bool) ), | 285 | connect( nStart, SIGNAL( toggled(bool) ), |
286 | this, SLOT( changeStartConfig(bool) ) ); | 286 | this, SLOT( changeStartConfig(bool) ) ); |
287 | nStart->setToggleAction(true); | 287 | nStart->setToggleAction(true); |
288 | nStart->addTo( advancedMenu ); | 288 | nStart->addTo( advancedMenu ); |
289 | nStart->setEnabled(false); | 289 | nStart->setEnabled(false); |
290 | 290 | ||
291 | nAdvanced = new QAction( tr("Prompt on Exit"), | 291 | nAdvanced = new QAction( tr("Prompt on Exit"), |
292 | QString::null, 0, this, 0 ); | 292 | QString::null, 0, this, 0 ); |
293 | connect( nAdvanced, SIGNAL( toggled(bool) ), | 293 | connect( nAdvanced, SIGNAL( toggled(bool) ), |
294 | this, SLOT( doPrompt(bool) ) ); | 294 | this, SLOT( doPrompt(bool) ) ); |
295 | nAdvanced->setToggleAction(true); | 295 | nAdvanced->setToggleAction(true); |
296 | nAdvanced->addTo( advancedMenu ); | 296 | nAdvanced->addTo( advancedMenu ); |
297 | 297 | ||
298 | desktopAction = new QAction( tr("Always open linked file"), | 298 | desktopAction = new QAction( tr("Always open linked file"), |
299 | QString::null, 0, this, 0 ); | 299 | QString::null, 0, this, 0 ); |
300 | connect( desktopAction, SIGNAL( toggled(bool) ), | 300 | connect( desktopAction, SIGNAL( toggled(bool) ), |
301 | this, SLOT( doDesktop(bool) ) ); | 301 | this, SLOT( doDesktop(bool) ) ); |
302 | desktopAction->setToggleAction(true); | 302 | desktopAction->setToggleAction(true); |
303 | desktopAction->addTo( advancedMenu); | 303 | desktopAction->addTo( advancedMenu); |
304 | 304 | ||
305 | filePermAction = new QAction( tr("File Permissions"), | 305 | filePermAction = new QAction( tr("File Permissions"), |
306 | QString::null, 0, this, 0 ); | 306 | QString::null, 0, this, 0 ); |
307 | connect( filePermAction, SIGNAL( toggled(bool) ), | 307 | connect( filePermAction, SIGNAL( toggled(bool) ), |
308 | this, SLOT( doFilePerms(bool) ) ); | 308 | this, SLOT( doFilePerms(bool) ) ); |
309 | filePermAction->setToggleAction(true); | 309 | filePermAction->setToggleAction(true); |
310 | filePermAction->addTo( advancedMenu); | 310 | filePermAction->addTo( advancedMenu); |
311 | 311 | ||
312 | searchBarAction = new QAction( tr("Search Bar Open"), | 312 | searchBarAction = new QAction( tr("Search Bar Open"), |
313 | QString::null, 0, this, 0 ); | 313 | QString::null, 0, this, 0 ); |
314 | connect( searchBarAction, SIGNAL( toggled(bool) ), | 314 | connect( searchBarAction, SIGNAL( toggled(bool) ), |
315 | this, SLOT( setSearchBar(bool) ) ); | 315 | this, SLOT( setSearchBar(bool) ) ); |
316 | searchBarAction->setToggleAction(true); | 316 | searchBarAction->setToggleAction(true); |
317 | searchBarAction->addTo( advancedMenu); | 317 | searchBarAction->addTo( advancedMenu); |
318 | 318 | ||
319 | nAutoSave = new QAction( tr("Auto Save 5 min."), | 319 | nAutoSave = new QAction( tr("Auto Save 5 min."), |
320 | QString::null, 0, this, 0 ); | 320 | QString::null, 0, this, 0 ); |
321 | connect( nAutoSave, SIGNAL( toggled(bool) ), | 321 | connect( nAutoSave, SIGNAL( toggled(bool) ), |
322 | this, SLOT( doTimer(bool) ) ); | 322 | this, SLOT( doTimer(bool) ) ); |
323 | nAutoSave->setToggleAction(true); | 323 | nAutoSave->setToggleAction(true); |
324 | nAutoSave->addTo( advancedMenu); | 324 | nAutoSave->addTo( advancedMenu); |
325 | 325 | ||
326 | 326 | ||
327 | //font->insertSeparator(); | 327 | //font->insertSeparator(); |
328 | 328 | ||
329 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 329 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
330 | 330 | ||
331 | mb->insertItem( tr( "File" ), file ); | 331 | mb->insertItem( tr( "File" ), file ); |
332 | mb->insertItem( tr( "Edit" ), edit ); | 332 | mb->insertItem( tr( "Edit" ), edit ); |
333 | mb->insertItem( tr( "View" ), font ); | 333 | mb->insertItem( tr( "View" ), font ); |
334 | 334 | ||
335 | searchBar = new QPEToolBar(this); | 335 | searchBar = new QPEToolBar(this); |
336 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); | 336 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); |
337 | 337 | ||
338 | searchBar->setHorizontalStretchable( true ); | 338 | searchBar->setHorizontalStretchable( true ); |
339 | 339 | ||
340 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 340 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
341 | searchBar->setStretchableWidget( searchEdit ); | 341 | searchBar->setStretchableWidget( searchEdit ); |
342 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 342 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
343 | this, SLOT( search() ) ); | 343 | this, SLOT( search() ) ); |
344 | 344 | ||
345 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), | 345 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), |
346 | QString::null, 0, this, 0 ); | 346 | QString::null, 0, this, 0 ); |
347 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 347 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
348 | a->addTo( searchBar ); | 348 | a->addTo( searchBar ); |
349 | a->addTo( edit ); | 349 | a->addTo( edit ); |
350 | 350 | ||
351 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), | 351 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), |
352 | QString::null, 0, this, 0 ); | 352 | QString::null, 0, this, 0 ); |
353 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 353 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
354 | a->addTo( searchBar ); | 354 | a->addTo( searchBar ); |
355 | 355 | ||
356 | edit->insertSeparator(); | 356 | edit->insertSeparator(); |
357 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), | 357 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), |
358 | QString::null, 0, this, 0 ); | 358 | QString::null, 0, this, 0 ); |
359 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 359 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
360 | a->addTo( edit ); | 360 | a->addTo( edit ); |
361 | 361 | ||
362 | searchBar->hide(); | 362 | searchBar->hide(); |
363 | 363 | ||
364 | editor = new QpeEditor( this ); | 364 | editor = new QpeEditor( this ); |
365 | setCentralWidget( editor ); | 365 | setCentralWidget( editor ); |
366 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 366 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
367 | connect( editor, SIGNAL( textChanged() ), | 367 | connect( editor, SIGNAL( textChanged() ), |
368 | this, SLOT( editorChanged() ) ); | 368 | this, SLOT( editorChanged() ) ); |
369 | 369 | ||
370 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); | 370 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); |
371 | 371 | ||
372 | Config cfg("TextEdit"); | 372 | Config cfg("TextEdit"); |
373 | cfg. setGroup ( "Font" ); | 373 | cfg. setGroup ( "Font" ); |
374 | 374 | ||
375 | QFont defaultFont = editor-> font ( ); | 375 | QFont defaultFont = editor-> font ( ); |
376 | 376 | ||
377 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 377 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
378 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 378 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
379 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 379 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
380 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 380 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
381 | 381 | ||
382 | defaultFont = QFont ( family, size, weight, italic ); | 382 | defaultFont = QFont ( family, size, weight, italic ); |
383 | editor-> setFont ( defaultFont ); | 383 | editor-> setFont ( defaultFont ); |
384 | // updateCaption(); | 384 | // updateCaption(); |
385 | 385 | ||
386 | cfg.setGroup ( "View" ); | 386 | cfg.setGroup ( "View" ); |
387 | 387 | ||
388 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); | 388 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); |
389 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); | 389 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); |
390 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); | 390 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); |
391 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); | 391 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); |
392 | startWithNew = cfg.readBoolEntry ( "startNew", true); | 392 | startWithNew = cfg.readBoolEntry ( "startNew", true); |
393 | featureAutoSave = cfg.readBoolEntry( "autosave", false); | 393 | featureAutoSave = cfg.readBoolEntry( "autosave", false); |
394 | 394 | ||
395 | if(useSearchBar) searchBarAction->setOn(true); | 395 | if(useSearchBar) searchBarAction->setOn(true); |
396 | if(promptExit) nAdvanced->setOn( true ); | 396 | if(promptExit) nAdvanced->setOn( true ); |
397 | if(openDesktop) desktopAction->setOn( true ); | 397 | if(openDesktop) desktopAction->setOn( true ); |
398 | if(filePerms) filePermAction->setOn( true ); | 398 | if(filePerms) filePermAction->setOn( true ); |
399 | if(startWithNew) nStart->setOn( true ); | 399 | if(startWithNew) nStart->setOn( true ); |
400 | if(featureAutoSave) nAutoSave->setOn(true); | 400 | if(featureAutoSave) nAutoSave->setOn(true); |
401 | 401 | ||
402 | // { | 402 | // { |
403 | // doTimer(true); | 403 | // doTimer(true); |
404 | // } | 404 | // } |
405 | 405 | ||
406 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 406 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
407 | wa-> setOn ( wrap ); | 407 | wa-> setOn ( wrap ); |
408 | setWordWrap ( wrap ); | 408 | setWordWrap ( wrap ); |
409 | 409 | ||
410 | ///////////////// | 410 | ///////////////// |
411 | if( qApp->argc() > 1) { | 411 | if( qApp->argc() > 1) { |
412 | currentFileName=qApp->argv()[1]; | 412 | currentFileName=qApp->argv()[1]; |
413 | 413 | ||
414 | QFileInfo fi(currentFileName); | 414 | QFileInfo fi(currentFileName); |
415 | 415 | ||
416 | if(fi.baseName().left(1) == "") { | 416 | if(fi.baseName().left(1) == "") { |
417 | openDotFile(currentFileName); | 417 | openDotFile(currentFileName); |
418 | } else { | 418 | } else { |
419 | openFile(currentFileName); | 419 | openFile(currentFileName); |
420 | } | 420 | } |
421 | } else { | 421 | } else { |
422 | edited1=false; | 422 | edited1=false; |
423 | openDotFile(""); | 423 | openDotFile(""); |
424 | } | 424 | } |
425 | 425 | ||
426 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 426 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
427 | } | 427 | } |
428 | 428 | ||
429 | TextEdit::~TextEdit() { | 429 | TextEdit::~TextEdit() { |
430 | qWarning("textedit d'tor"); | 430 | qWarning("textedit d'tor"); |
431 | delete editor; | 431 | delete editor; |
432 | } | 432 | } |
433 | 433 | ||
434 | void TextEdit::closeEvent(QCloseEvent *) { | 434 | void TextEdit::closeEvent(QCloseEvent *) { |
435 | if( edited1 && promptExit) | 435 | if( edited1 && promptExit) |
436 | { | 436 | { |
437 | switch( savePrompt() ) | 437 | switch( savePrompt() ) |
438 | { | 438 | { |
439 | case 1: | 439 | case 1: |
440 | { | 440 | { |
441 | saveAs(); | 441 | saveAs(); |
442 | qApp->quit(); | 442 | qApp->quit(); |
443 | } | 443 | } |
444 | break; | 444 | break; |
445 | 445 | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 8016d8e..cfcfd41 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,417 +1,417 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | 21 | #define QTOPIA_INTERNAL_FSLP |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | 23 | ||
24 | #include <qpe/qpemenubar.h> | 24 | #include <qmenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/fileselector.h> | 26 | #include <qpe/fileselector.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/lnkproperties.h> | 28 | #include <qpe/lnkproperties.h> |
29 | #include <qpe/storage.h> | 29 | #include <qpe/storage.h> |
30 | 30 | ||
31 | #include <qpe/applnk.h> | 31 | #include <qpe/applnk.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <qpe/global.h> | 33 | #include <qpe/global.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qaction.h> | 35 | #include <qaction.h> |
36 | #include <qcursor.h> | 36 | #include <qcursor.h> |
37 | #include <qimage.h> | 37 | #include <qimage.h> |
38 | #include <qfile.h> | 38 | #include <qfile.h> |
39 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qlabel.h> | 41 | #include <qlabel.h> |
42 | #include <qlist.h> | 42 | #include <qlist.h> |
43 | #include <qlistbox.h> | 43 | #include <qlistbox.h> |
44 | #include <qmainwindow.h> | 44 | #include <qmainwindow.h> |
45 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
46 | #include <qtoolbutton.h> | 46 | #include <qtoolbutton.h> |
47 | #include <qtabwidget.h> | 47 | #include <qtabwidget.h> |
48 | #include <qlistview.h> | 48 | #include <qlistview.h> |
49 | #include <qpoint.h> | 49 | #include <qpoint.h> |
50 | #include <qlineedit.h> | 50 | #include <qlineedit.h> |
51 | #include <qpushbutton.h> | 51 | #include <qpushbutton.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qtextstream.h> | 53 | #include <qtextstream.h> |
54 | 54 | ||
55 | //#include <qtimer.h> | 55 | //#include <qtimer.h> |
56 | 56 | ||
57 | #include "playlistselection.h" | 57 | #include "playlistselection.h" |
58 | #include "playlistwidget.h" | 58 | #include "playlistwidget.h" |
59 | #include "mediaplayerstate.h" | 59 | #include "mediaplayerstate.h" |
60 | 60 | ||
61 | #include "inputDialog.h" | 61 | #include "inputDialog.h" |
62 | 62 | ||
63 | #include <stdlib.h> | 63 | #include <stdlib.h> |
64 | #include "audiowidget.h" | 64 | #include "audiowidget.h" |
65 | #include "videowidget.h" | 65 | #include "videowidget.h" |
66 | 66 | ||
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #include <sys/file.h> | 68 | #include <sys/file.h> |
69 | #include <sys/ioctl.h> | 69 | #include <sys/ioctl.h> |
70 | #include <sys/soundcard.h> | 70 | #include <sys/soundcard.h> |
71 | 71 | ||
72 | // for setBacklight() | 72 | // for setBacklight() |
73 | #include <linux/fb.h> | 73 | #include <linux/fb.h> |
74 | #include <sys/types.h> | 74 | #include <sys/types.h> |
75 | #include <sys/stat.h> | 75 | #include <sys/stat.h> |
76 | #include <stdlib.h> | 76 | #include <stdlib.h> |
77 | 77 | ||
78 | #define BUTTONS_ON_TOOLBAR | 78 | #define BUTTONS_ON_TOOLBAR |
79 | #define SIDE_BUTTONS | 79 | #define SIDE_BUTTONS |
80 | #define CAN_SAVE_LOAD_PLAYLISTS | 80 | #define CAN_SAVE_LOAD_PLAYLISTS |
81 | 81 | ||
82 | extern AudioWidget *audioUI; | 82 | extern AudioWidget *audioUI; |
83 | extern VideoWidget *videoUI; | 83 | extern VideoWidget *videoUI; |
84 | extern MediaPlayerState *mediaPlayerState; | 84 | extern MediaPlayerState *mediaPlayerState; |
85 | 85 | ||
86 | static inline QString fullBaseName ( const QFileInfo &fi ) | 86 | static inline QString fullBaseName ( const QFileInfo &fi ) |
87 | { | 87 | { |
88 | QString str = fi. fileName ( ); | 88 | QString str = fi. fileName ( ); |
89 | return str. left ( str. findRev ( '.' )); | 89 | return str. left ( str. findRev ( '.' )); |
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | QString audioMimes ="audio/mpeg;audio/x-wav;application/ogg;audio/x-mod"; | 93 | QString audioMimes ="audio/mpeg;audio/x-wav;application/ogg;audio/x-mod"; |
94 | // class myFileSelector { | 94 | // class myFileSelector { |
95 | 95 | ||
96 | // }; | 96 | // }; |
97 | class PlayListWidgetPrivate { | 97 | class PlayListWidgetPrivate { |
98 | public: | 98 | public: |
99 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 99 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
100 | QFrame *playListFrame; | 100 | QFrame *playListFrame; |
101 | FileSelector *files; | 101 | FileSelector *files; |
102 | PlayListSelection *selectedFiles; | 102 | PlayListSelection *selectedFiles; |
103 | bool setDocumentUsed; | 103 | bool setDocumentUsed; |
104 | DocLnk *current; | 104 | DocLnk *current; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | 107 | ||
108 | class ToolButton : public QToolButton { | 108 | class ToolButton : public QToolButton { |
109 | public: | 109 | public: |
110 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 110 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
111 | : QToolButton( parent, name ) { | 111 | : QToolButton( parent, name ) { |
112 | setTextLabel( name ); | 112 | setTextLabel( name ); |
113 | setPixmap( Resource::loadPixmap( icon ) ); | 113 | setPixmap( Resource::loadPixmap( icon ) ); |
114 | setAutoRaise( TRUE ); | 114 | setAutoRaise( TRUE ); |
115 | setFocusPolicy( QWidget::NoFocus ); | 115 | setFocusPolicy( QWidget::NoFocus ); |
116 | setToggleButton( t ); | 116 | setToggleButton( t ); |
117 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 117 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
118 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 118 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
119 | } | 119 | } |
120 | }; | 120 | }; |
121 | 121 | ||
122 | 122 | ||
123 | class MenuItem : public QAction { | 123 | class MenuItem : public QAction { |
124 | public: | 124 | public: |
125 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 125 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
126 | : QAction( text, QString::null, 0, 0 ) { | 126 | : QAction( text, QString::null, 0, 0 ) { |
127 | connect( this, SIGNAL( activated() ), handler, slot ); | 127 | connect( this, SIGNAL( activated() ), handler, slot ); |
128 | addTo( parent ); | 128 | addTo( parent ); |
129 | } | 129 | } |
130 | }; | 130 | }; |
131 | 131 | ||
132 | 132 | ||
133 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 133 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
134 | : QMainWindow( parent, name, fl ) { | 134 | : QMainWindow( parent, name, fl ) { |
135 | 135 | ||
136 | d = new PlayListWidgetPrivate; | 136 | d = new PlayListWidgetPrivate; |
137 | d->setDocumentUsed = FALSE; | 137 | d->setDocumentUsed = FALSE; |
138 | d->current = NULL; | 138 | d->current = NULL; |
139 | fromSetDocument = FALSE; | 139 | fromSetDocument = FALSE; |
140 | insanityBool=FALSE; | 140 | insanityBool=FALSE; |
141 | audioScan = FALSE; | 141 | audioScan = FALSE; |
142 | videoScan = FALSE; | 142 | videoScan = FALSE; |
143 | // menuTimer = new QTimer( this ,"menu timer"), | 143 | // menuTimer = new QTimer( this ,"menu timer"), |
144 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 144 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
145 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); | 145 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); |
146 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 146 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
147 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); | 147 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); |
148 | 148 | ||
149 | setBackgroundMode( PaletteButton ); | 149 | setBackgroundMode( PaletteButton ); |
150 | 150 | ||
151 | setCaption( tr("OpiePlayer") ); | 151 | setCaption( tr("OpiePlayer") ); |
152 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 152 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
153 | 153 | ||
154 | setToolBarsMovable( FALSE ); | 154 | setToolBarsMovable( FALSE ); |
155 | 155 | ||
156 | // Create Toolbar | 156 | // Create Toolbar |
157 | QPEToolBar *toolbar = new QPEToolBar( this ); | 157 | QPEToolBar *toolbar = new QPEToolBar( this ); |
158 | toolbar->setHorizontalStretchable( TRUE ); | 158 | toolbar->setHorizontalStretchable( TRUE ); |
159 | 159 | ||
160 | // Create Menubar | 160 | // Create Menubar |
161 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 161 | QMenuBar *menu = new QMenuBar( toolbar ); |
162 | menu->setMargin( 0 ); | 162 | menu->setMargin( 0 ); |
163 | 163 | ||
164 | QPEToolBar *bar = new QPEToolBar( this ); | 164 | QPEToolBar *bar = new QPEToolBar( this ); |
165 | bar->setLabel( tr( "Play Operations" ) ); | 165 | bar->setLabel( tr( "Play Operations" ) ); |
166 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 166 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", |
167 | // this , SLOT( addSelected()) ); | 167 | // this , SLOT( addSelected()) ); |
168 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 168 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
169 | tbDeletePlaylist->setFlat(TRUE); | 169 | tbDeletePlaylist->setFlat(TRUE); |
170 | 170 | ||
171 | tbDeletePlaylist->setFixedSize(20,20); | 171 | tbDeletePlaylist->setFixedSize(20,20); |
172 | 172 | ||
173 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 173 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
174 | this , SLOT(addSelected()) ); | 174 | this , SLOT(addSelected()) ); |
175 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 175 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
176 | this , SLOT(removeSelected()) ); | 176 | this , SLOT(removeSelected()) ); |
177 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 177 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
178 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 178 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
179 | this , SLOT( btnPlay(bool) ), TRUE ); | 179 | this , SLOT( btnPlay(bool) ), TRUE ); |
180 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 180 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
181 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 181 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
182 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 182 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
183 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 183 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
184 | tbDeletePlaylist->hide(); | 184 | tbDeletePlaylist->hide(); |
185 | 185 | ||
186 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 186 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
187 | menu->insertItem( tr( "File" ), pmPlayList ); | 187 | menu->insertItem( tr( "File" ), pmPlayList ); |
188 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 188 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
189 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 189 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
190 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 190 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
191 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 191 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
192 | pmPlayList->insertSeparator(-1); | 192 | pmPlayList->insertSeparator(-1); |
193 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 193 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
194 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 194 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
195 | pmPlayList->insertSeparator(-1); | 195 | pmPlayList->insertSeparator(-1); |
196 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 196 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
197 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 197 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
198 | 198 | ||
199 | QPopupMenu *pmView = new QPopupMenu( this ); | 199 | QPopupMenu *pmView = new QPopupMenu( this ); |
200 | menu->insertItem( tr( "View" ), pmView ); | 200 | menu->insertItem( tr( "View" ), pmView ); |
201 | 201 | ||
202 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 202 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
203 | fullScreenButton->addTo(pmView); | 203 | fullScreenButton->addTo(pmView); |
204 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 204 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
205 | scaleButton->addTo(pmView); | 205 | scaleButton->addTo(pmView); |
206 | 206 | ||
207 | 207 | ||
208 | skinsMenu = new QPopupMenu( this ); | 208 | skinsMenu = new QPopupMenu( this ); |
209 | menu->insertItem( tr( "Skins" ), skinsMenu ); | 209 | menu->insertItem( tr( "Skins" ), skinsMenu ); |
210 | skinsMenu->isCheckable(); | 210 | skinsMenu->isCheckable(); |
211 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 211 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
212 | this, SLOT( skinsMenuActivated( int ) ) ); | 212 | this, SLOT( skinsMenuActivated( int ) ) ); |
213 | populateSkinsMenu(); | 213 | populateSkinsMenu(); |
214 | 214 | ||
215 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 215 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
216 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 216 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
217 | 217 | ||
218 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 218 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
219 | 219 | ||
220 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 220 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
221 | // tabWidget->setTabShape(QTabWidget::Triangular); | 221 | // tabWidget->setTabShape(QTabWidget::Triangular); |
222 | 222 | ||
223 | QWidget *pTab; | 223 | QWidget *pTab; |
224 | pTab = new QWidget( tabWidget, "pTab" ); | 224 | pTab = new QWidget( tabWidget, "pTab" ); |
225 | // playlistView = new QListView( pTab, "playlistview" ); | 225 | // playlistView = new QListView( pTab, "playlistview" ); |
226 | // playlistView->setMinimumSize(236,260); | 226 | // playlistView->setMinimumSize(236,260); |
227 | tabWidget->insertTab( pTab,"Playlist"); | 227 | tabWidget->insertTab( pTab,"Playlist"); |
228 | 228 | ||
229 | 229 | ||
230 | // Add the playlist area | 230 | // Add the playlist area |
231 | 231 | ||
232 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 232 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
233 | d->playListFrame = vbox3; | 233 | d->playListFrame = vbox3; |
234 | 234 | ||
235 | QGridLayout *layoutF = new QGridLayout( pTab ); | 235 | QGridLayout *layoutF = new QGridLayout( pTab ); |
236 | layoutF->setSpacing( 2); | 236 | layoutF->setSpacing( 2); |
237 | layoutF->setMargin( 2); | 237 | layoutF->setMargin( 2); |
238 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); | 238 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); |
239 | 239 | ||
240 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 240 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
241 | 241 | ||
242 | d->selectedFiles = new PlayListSelection( hbox2); | 242 | d->selectedFiles = new PlayListSelection( hbox2); |
243 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 243 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
244 | 244 | ||
245 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 245 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
246 | 246 | ||
247 | 247 | ||
248 | 248 | ||
249 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 249 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
250 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 250 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
251 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 251 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
252 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 252 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
253 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 253 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
254 | 254 | ||
255 | QWidget *aTab; | 255 | QWidget *aTab; |
256 | aTab = new QWidget( tabWidget, "aTab" ); | 256 | aTab = new QWidget( tabWidget, "aTab" ); |
257 | audioView = new QListView( aTab, "Audioview" ); | 257 | audioView = new QListView( aTab, "Audioview" ); |
258 | 258 | ||
259 | QGridLayout *layoutA = new QGridLayout( aTab ); | 259 | QGridLayout *layoutA = new QGridLayout( aTab ); |
260 | layoutA->setSpacing( 2); | 260 | layoutA->setSpacing( 2); |
261 | layoutA->setMargin( 2); | 261 | layoutA->setMargin( 2); |
262 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 262 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
263 | 263 | ||
264 | audioView->addColumn( tr("Title"),-1); | 264 | audioView->addColumn( tr("Title"),-1); |
265 | audioView->addColumn(tr("Size"), -1); | 265 | audioView->addColumn(tr("Size"), -1); |
266 | audioView->addColumn(tr("Media"),-1); | 266 | audioView->addColumn(tr("Media"),-1); |
267 | audioView->addColumn( tr( "Path" ), -1 ); | 267 | audioView->addColumn( tr( "Path" ), -1 ); |
268 | 268 | ||
269 | audioView->setColumnAlignment(1, Qt::AlignRight); | 269 | audioView->setColumnAlignment(1, Qt::AlignRight); |
270 | audioView->setColumnAlignment(2, Qt::AlignRight); | 270 | audioView->setColumnAlignment(2, Qt::AlignRight); |
271 | audioView->setAllColumnsShowFocus(TRUE); | 271 | audioView->setAllColumnsShowFocus(TRUE); |
272 | 272 | ||
273 | audioView->setMultiSelection( TRUE ); | 273 | audioView->setMultiSelection( TRUE ); |
274 | audioView->setSelectionMode( QListView::Extended); | 274 | audioView->setSelectionMode( QListView::Extended); |
275 | audioView->setSorting( 3, TRUE ); | 275 | audioView->setSorting( 3, TRUE ); |
276 | 276 | ||
277 | tabWidget->insertTab(aTab,tr("Audio")); | 277 | tabWidget->insertTab(aTab,tr("Audio")); |
278 | 278 | ||
279 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 279 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
280 | 280 | ||
281 | // audioView | 281 | // audioView |
282 | // populateAudioView(); | 282 | // populateAudioView(); |
283 | // videowidget | 283 | // videowidget |
284 | 284 | ||
285 | QWidget *vTab; | 285 | QWidget *vTab; |
286 | vTab = new QWidget( tabWidget, "vTab" ); | 286 | vTab = new QWidget( tabWidget, "vTab" ); |
287 | videoView = new QListView( vTab, "Videoview" ); | 287 | videoView = new QListView( vTab, "Videoview" ); |
288 | 288 | ||
289 | QGridLayout *layoutV = new QGridLayout( vTab ); | 289 | QGridLayout *layoutV = new QGridLayout( vTab ); |
290 | layoutV->setSpacing( 2); | 290 | layoutV->setSpacing( 2); |
291 | layoutV->setMargin( 2); | 291 | layoutV->setMargin( 2); |
292 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 292 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
293 | 293 | ||
294 | videoView->addColumn(tr("Title"),-1); | 294 | videoView->addColumn(tr("Title"),-1); |
295 | videoView->addColumn(tr("Size"),-1); | 295 | videoView->addColumn(tr("Size"),-1); |
296 | videoView->addColumn(tr("Media"),-1); | 296 | videoView->addColumn(tr("Media"),-1); |
297 | videoView->addColumn(tr( "Path" ), -1 ); | 297 | videoView->addColumn(tr( "Path" ), -1 ); |
298 | videoView->setColumnAlignment(1, Qt::AlignRight); | 298 | videoView->setColumnAlignment(1, Qt::AlignRight); |
299 | videoView->setColumnAlignment(2, Qt::AlignRight); | 299 | videoView->setColumnAlignment(2, Qt::AlignRight); |
300 | videoView->setAllColumnsShowFocus(TRUE); | 300 | videoView->setAllColumnsShowFocus(TRUE); |
301 | videoView->setMultiSelection( TRUE ); | 301 | videoView->setMultiSelection( TRUE ); |
302 | videoView->setSelectionMode( QListView::Extended); | 302 | videoView->setSelectionMode( QListView::Extended); |
303 | 303 | ||
304 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 304 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
305 | 305 | ||
306 | tabWidget->insertTab( vTab,tr("Video")); | 306 | tabWidget->insertTab( vTab,tr("Video")); |
307 | 307 | ||
308 | QWidget *LTab; | 308 | QWidget *LTab; |
309 | LTab = new QWidget( tabWidget, "LTab" ); | 309 | LTab = new QWidget( tabWidget, "LTab" ); |
310 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); | 310 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); |
311 | 311 | ||
312 | QGridLayout *layoutL = new QGridLayout( LTab ); | 312 | QGridLayout *layoutL = new QGridLayout( LTab ); |
313 | layoutL->setSpacing( 2); | 313 | layoutL->setSpacing( 2); |
314 | layoutL->setMargin( 2); | 314 | layoutL->setMargin( 2); |
315 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 315 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
316 | 316 | ||
317 | tabWidget->insertTab(LTab,tr("Lists")); | 317 | tabWidget->insertTab(LTab,tr("Lists")); |
318 | 318 | ||
319 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 319 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
320 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 320 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
321 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 321 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
322 | 322 | ||
323 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 323 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
324 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 324 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
325 | 325 | ||
326 | 326 | ||
327 | ///audioView | 327 | ///audioView |
328 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 328 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
329 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 329 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
330 | 330 | ||
331 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 331 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
332 | this,SLOT( playIt( QListViewItem *)) ); | 332 | this,SLOT( playIt( QListViewItem *)) ); |
333 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 333 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
334 | 334 | ||
335 | 335 | ||
336 | //videoView | 336 | //videoView |
337 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 337 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
338 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 338 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
339 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 339 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
340 | this,SLOT( playIt( QListViewItem *)) ); | 340 | this,SLOT( playIt( QListViewItem *)) ); |
341 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 341 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
342 | 342 | ||
343 | //playlists | 343 | //playlists |
344 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 344 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
345 | 345 | ||
346 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 346 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
347 | 347 | ||
348 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 348 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
349 | 349 | ||
350 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 350 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
351 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 351 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
352 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 352 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
353 | 353 | ||
354 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 354 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
355 | 355 | ||
356 | setCentralWidget( vbox5 ); | 356 | setCentralWidget( vbox5 ); |
357 | 357 | ||
358 | Config cfg( "OpiePlayer" ); | 358 | Config cfg( "OpiePlayer" ); |
359 | readConfig( cfg ); | 359 | readConfig( cfg ); |
360 | 360 | ||
361 | currentPlayList = cfg.readEntry("CurrentPlaylist","default"); | 361 | currentPlayList = cfg.readEntry("CurrentPlaylist","default"); |
362 | loadList(DocLnk( currentPlayList)); | 362 | loadList(DocLnk( currentPlayList)); |
363 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); | 363 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); |
364 | 364 | ||
365 | initializeStates(); | 365 | initializeStates(); |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
369 | PlayListWidget::~PlayListWidget() { | 369 | PlayListWidget::~PlayListWidget() { |
370 | Config cfg( "OpiePlayer" ); | 370 | Config cfg( "OpiePlayer" ); |
371 | writeConfig( cfg ); | 371 | writeConfig( cfg ); |
372 | 372 | ||
373 | if ( d->current ) | 373 | if ( d->current ) |
374 | delete d->current; | 374 | delete d->current; |
375 | if(d) delete d; | 375 | if(d) delete d; |
376 | } | 376 | } |
377 | 377 | ||
378 | 378 | ||
379 | void PlayListWidget::initializeStates() { | 379 | void PlayListWidget::initializeStates() { |
380 | 380 | ||
381 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 381 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
382 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 382 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
383 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 383 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
384 | setPlaylist( true); | 384 | setPlaylist( true); |
385 | } | 385 | } |
386 | 386 | ||
387 | 387 | ||
388 | void PlayListWidget::readConfig( Config& cfg ) { | 388 | void PlayListWidget::readConfig( Config& cfg ) { |
389 | cfg.setGroup("PlayList"); | 389 | cfg.setGroup("PlayList"); |
390 | QString currentString = cfg.readEntry("current", "" ); | 390 | QString currentString = cfg.readEntry("current", "" ); |
391 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 391 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
392 | for ( int i = 0; i < noOfFiles; i++ ) { | 392 | for ( int i = 0; i < noOfFiles; i++ ) { |
393 | QString entryName; | 393 | QString entryName; |
394 | entryName.sprintf( "File%i", i + 1 ); | 394 | entryName.sprintf( "File%i", i + 1 ); |
395 | QString linkFile = cfg.readEntry( entryName ); | 395 | QString linkFile = cfg.readEntry( entryName ); |
396 | DocLnk lnk( linkFile ); | 396 | DocLnk lnk( linkFile ); |
397 | if ( lnk.isValid() ) { | 397 | if ( lnk.isValid() ) { |
398 | d->selectedFiles->addToSelection( lnk ); | 398 | d->selectedFiles->addToSelection( lnk ); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | d->selectedFiles->setSelectedItem( currentString); | 401 | d->selectedFiles->setSelectedItem( currentString); |
402 | } | 402 | } |
403 | 403 | ||
404 | 404 | ||
405 | void PlayListWidget::writeConfig( Config& cfg ) const { | 405 | void PlayListWidget::writeConfig( Config& cfg ) const { |
406 | 406 | ||
407 | d->selectedFiles->writeCurrent( cfg); | 407 | d->selectedFiles->writeCurrent( cfg); |
408 | cfg.setGroup("PlayList"); | 408 | cfg.setGroup("PlayList"); |
409 | int noOfFiles = 0; | 409 | int noOfFiles = 0; |
410 | d->selectedFiles->first(); | 410 | d->selectedFiles->first(); |
411 | do { | 411 | do { |
412 | const DocLnk *lnk = d->selectedFiles->current(); | 412 | const DocLnk *lnk = d->selectedFiles->current(); |
413 | if ( lnk ) { | 413 | if ( lnk ) { |
414 | QString entryName; | 414 | QString entryName; |
415 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 415 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
416 | // qDebug(entryName); | 416 | // qDebug(entryName); |
417 | cfg.writeEntry( entryName, lnk->linkFile() ); | 417 | cfg.writeEntry( entryName, lnk->linkFile() ); |
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 438c270..406ced6 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -1,352 +1,352 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of the Open Palmtop Environment (see www.opie.info). | 5 | ** This file is part of the Open Palmtop Environment (see www.opie.info). |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** | 17 | ** |
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #define QTOPIA_INTERNAL_FD | 20 | #define QTOPIA_INTERNAL_FD |
21 | 21 | ||
22 | #include "contacteditor.h" | 22 | #include "contacteditor.h" |
23 | #include "ablabel.h" | 23 | #include "ablabel.h" |
24 | #include "abview.h" | 24 | #include "abview.h" |
25 | #include "abtable.h" | 25 | #include "abtable.h" |
26 | // #include "addresssettings.h" | 26 | // #include "addresssettings.h" |
27 | #include "addressbook.h" | 27 | #include "addressbook.h" |
28 | 28 | ||
29 | 29 | ||
30 | #include <opie/ofileselector.h> | 30 | #include <opie/ofileselector.h> |
31 | #include <opie/ofiledialog.h> | 31 | #include <opie/ofiledialog.h> |
32 | #include <opie/ocontact.h> | 32 | #include <opie/ocontact.h> |
33 | #include <opie/ocontactaccessbackend_vcard.h> | 33 | #include <opie/ocontactaccessbackend_vcard.h> |
34 | 34 | ||
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/ir.h> | 36 | #include <qpe/ir.h> |
37 | #include <qpe/qpemessagebox.h> | 37 | #include <qpe/qpemessagebox.h> |
38 | #include <qpe/qcopenvelope_qws.h> | 38 | #include <qpe/qcopenvelope_qws.h> |
39 | #include <qpe/qpetoolbar.h> | 39 | #include <qpe/qpetoolbar.h> |
40 | #include <qpe/qpemenubar.h> | 40 | #include <qmenubar.h> |
41 | // #include <qtoolbar.h> | 41 | // #include <qtoolbar.h> |
42 | // #include <qmenubar.h> | 42 | // #include <qmenubar.h> |
43 | #include <qpe/qpeapplication.h> | 43 | #include <qpe/qpeapplication.h> |
44 | #include <qpe/config.h> | 44 | #include <qpe/config.h> |
45 | 45 | ||
46 | #include <qaction.h> | 46 | #include <qaction.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #include <qfile.h> | 49 | #include <qfile.h> |
50 | #include <qimage.h> | 50 | #include <qimage.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qpixmap.h> | 53 | #include <qpixmap.h> |
54 | #include <qpopupmenu.h> | 54 | #include <qpopupmenu.h> |
55 | #include <qstringlist.h> | 55 | #include <qstringlist.h> |
56 | #include <qtoolbutton.h> | 56 | #include <qtoolbutton.h> |
57 | #include <qwhatsthis.h> | 57 | #include <qwhatsthis.h> |
58 | #include <qdatetime.h> | 58 | #include <qdatetime.h> |
59 | 59 | ||
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include <sys/stat.h> | 61 | #include <sys/stat.h> |
62 | #include <sys/types.h> | 62 | #include <sys/types.h> |
63 | #include <fcntl.h> | 63 | #include <fcntl.h> |
64 | #include <unistd.h> | 64 | #include <unistd.h> |
65 | 65 | ||
66 | 66 | ||
67 | #include "picker.h" | 67 | #include "picker.h" |
68 | #include "configdlg.h" | 68 | #include "configdlg.h" |
69 | 69 | ||
70 | extern QString addressbookPersonalVCardName(); | 70 | extern QString addressbookPersonalVCardName(); |
71 | 71 | ||
72 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 72 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
73 | WFlags f ) | 73 | WFlags f ) |
74 | : QMainWindow( parent, name, f ), | 74 | : QMainWindow( parent, name, f ), |
75 | catMenu (0l), | 75 | catMenu (0l), |
76 | abEditor(0l), | 76 | abEditor(0l), |
77 | syncing(FALSE), | 77 | syncing(FALSE), |
78 | m_tableViewButton(0l), | 78 | m_tableViewButton(0l), |
79 | m_cardViewButton(0l) | 79 | m_cardViewButton(0l) |
80 | { | 80 | { |
81 | isLoading = true; | 81 | isLoading = true; |
82 | 82 | ||
83 | m_config.load(); | 83 | m_config.load(); |
84 | 84 | ||
85 | setCaption( tr("Contacts") ); | 85 | setCaption( tr("Contacts") ); |
86 | setIcon( Resource::loadPixmap( "AddressBook" ) ); | 86 | setIcon( Resource::loadPixmap( "AddressBook" ) ); |
87 | 87 | ||
88 | // Settings for Main Menu | 88 | // Settings for Main Menu |
89 | // setToolBarsMovable( false ); | 89 | // setToolBarsMovable( false ); |
90 | setToolBarsMovable( !m_config.fixedBars() ); | 90 | setToolBarsMovable( !m_config.fixedBars() ); |
91 | setRightJustification( true ); | 91 | setRightJustification( true ); |
92 | 92 | ||
93 | QPEToolBar *bar = new QPEToolBar( this ); | 93 | QPEToolBar *bar = new QPEToolBar( this ); |
94 | bar->setHorizontalStretchable( TRUE ); | 94 | bar->setHorizontalStretchable( TRUE ); |
95 | 95 | ||
96 | QPEMenuBar *mbList = new QPEMenuBar( bar ); | 96 | QMenuBar *mbList = new QMenuBar( bar ); |
97 | mbList->setMargin( 0 ); | 97 | mbList->setMargin( 0 ); |
98 | 98 | ||
99 | QPopupMenu *edit = new QPopupMenu( mbList ); | 99 | QPopupMenu *edit = new QPopupMenu( mbList ); |
100 | mbList->insertItem( tr( "Contact" ), edit ); | 100 | mbList->insertItem( tr( "Contact" ), edit ); |
101 | 101 | ||
102 | // Category Menu | 102 | // Category Menu |
103 | catMenu = new QPopupMenu( this ); | 103 | catMenu = new QPopupMenu( this ); |
104 | catMenu->setCheckable( TRUE ); | 104 | catMenu->setCheckable( TRUE ); |
105 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); | 105 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); |
106 | mbList->insertItem( tr("View"), catMenu ); | 106 | mbList->insertItem( tr("View"), catMenu ); |
107 | 107 | ||
108 | // Create Toolbar | 108 | // Create Toolbar |
109 | listTools = new QPEToolBar( this, "list operations" ); | 109 | listTools = new QPEToolBar( this, "list operations" ); |
110 | listTools->setHorizontalStretchable( true ); | 110 | listTools->setHorizontalStretchable( true ); |
111 | addToolBar( listTools ); | 111 | addToolBar( listTools ); |
112 | moveToolBar( listTools, m_config.getToolBarPos() ); | 112 | moveToolBar( listTools, m_config.getToolBarPos() ); |
113 | 113 | ||
114 | // View Icons | 114 | // View Icons |
115 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), | 115 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), |
116 | QString::null, 0, this, 0 ); | 116 | QString::null, 0, this, 0 ); |
117 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); | 117 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); |
118 | m_tableViewButton->setToggleAction( true ); | 118 | m_tableViewButton->setToggleAction( true ); |
119 | m_tableViewButton->addTo( listTools ); | 119 | m_tableViewButton->addTo( listTools ); |
120 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 ); | 120 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 ); |
121 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); | 121 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); |
122 | m_cardViewButton->setToggleAction( true ); | 122 | m_cardViewButton->setToggleAction( true ); |
123 | m_cardViewButton->addTo( listTools ); | 123 | m_cardViewButton->addTo( listTools ); |
124 | 124 | ||
125 | listTools->addSeparator(); | 125 | listTools->addSeparator(); |
126 | 126 | ||
127 | // Other Buttons | 127 | // Other Buttons |
128 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, | 128 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, |
129 | 0, this, 0 ); | 129 | 0, this, 0 ); |
130 | actionNew = a; | 130 | actionNew = a; |
131 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); | 131 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); |
132 | a->addTo( edit ); | 132 | a->addTo( edit ); |
133 | a->addTo( listTools ); | 133 | a->addTo( listTools ); |
134 | 134 | ||
135 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 135 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
136 | 0, this, 0 ); | 136 | 0, this, 0 ); |
137 | actionEdit = a; | 137 | actionEdit = a; |
138 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); | 138 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); |
139 | a->addTo( edit ); | 139 | a->addTo( edit ); |
140 | a->addTo( listTools ); | 140 | a->addTo( listTools ); |
141 | 141 | ||
142 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 142 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
143 | 0, this, 0 ); | 143 | 0, this, 0 ); |
144 | actionTrash = a; | 144 | actionTrash = a; |
145 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); | 145 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); |
146 | a->addTo( edit ); | 146 | a->addTo( edit ); |
147 | a->addTo( listTools ); | 147 | a->addTo( listTools ); |
148 | 148 | ||
149 | 149 | ||
150 | // make it possible to go directly to businesscard via qcop call | 150 | // make it possible to go directly to businesscard via qcop call |
151 | //#if defined(Q_WS_QWS) // Why this ? (se) | 151 | //#if defined(Q_WS_QWS) // Why this ? (se) |
152 | #if !defined(QT_NO_COP) | 152 | #if !defined(QT_NO_COP) |
153 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); | 153 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); |
154 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 154 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
155 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); | 155 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); |
156 | #endif | 156 | #endif |
157 | // #endif | 157 | // #endif |
158 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), | 158 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), |
159 | QString::null, 0, this, 0 ); | 159 | QString::null, 0, this, 0 ); |
160 | actionFind = a; | 160 | actionFind = a; |
161 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); | 161 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); |
162 | a->addTo( edit ); | 162 | a->addTo( edit ); |
163 | a->addTo( listTools ); | 163 | a->addTo( listTools ); |
164 | 164 | ||
165 | // Much better search widget, taken from QTReader.. (se) | 165 | // Much better search widget, taken from QTReader.. (se) |
166 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 166 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
167 | searchBar->setHorizontalStretchable( TRUE ); | 167 | searchBar->setHorizontalStretchable( TRUE ); |
168 | searchBar->hide(); | 168 | searchBar->hide(); |
169 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 169 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
170 | 170 | ||
171 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 171 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
172 | // searchEdit->setFont( f ); | 172 | // searchEdit->setFont( f ); |
173 | 173 | ||
174 | searchBar->setStretchableWidget( searchEdit ); | 174 | searchBar->setStretchableWidget( searchEdit ); |
175 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 175 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
176 | this, SLOT( slotFind( ) ) ); | 176 | this, SLOT( slotFind( ) ) ); |
177 | 177 | ||
178 | a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); | 178 | a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); |
179 | connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 179 | connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
180 | a->addTo( searchBar ); | 180 | a->addTo( searchBar ); |
181 | 181 | ||
182 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 182 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
183 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); | 183 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); |
184 | a->addTo( searchBar ); | 184 | a->addTo( searchBar ); |
185 | 185 | ||
186 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), | 186 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), |
187 | QString::null, 0, this, 0 ); | 187 | QString::null, 0, this, 0 ); |
188 | //a->setEnabled( FALSE ); we got support for it now :) zecke | 188 | //a->setEnabled( FALSE ); we got support for it now :) zecke |
189 | actionMail = a; | 189 | actionMail = a; |
190 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); | 190 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); |
191 | a->addTo( edit ); | 191 | a->addTo( edit ); |
192 | a->addTo( listTools ); | 192 | a->addTo( listTools ); |
193 | 193 | ||
194 | if ( Ir::supported() ) { | 194 | if ( Ir::supported() ) { |
195 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, | 195 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, |
196 | 0, this, 0 ); | 196 | 0, this, 0 ); |
197 | actionBeam = a; | 197 | actionBeam = a; |
198 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 198 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
199 | a->addTo( edit ); | 199 | a->addTo( edit ); |
200 | a->addTo( listTools ); | 200 | a->addTo( listTools ); |
201 | } | 201 | } |
202 | 202 | ||
203 | edit->insertSeparator(); | 203 | edit->insertSeparator(); |
204 | 204 | ||
205 | a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, | 205 | a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, |
206 | 0, this, 0); | 206 | 0, this, 0); |
207 | actionPersonal = a; | 207 | actionPersonal = a; |
208 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); | 208 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); |
209 | a->addTo( edit ); | 209 | a->addTo( edit ); |
210 | 210 | ||
211 | a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, | 211 | a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, |
212 | 0, this, 0); | 212 | 0, this, 0); |
213 | actionPersonal = a; | 213 | actionPersonal = a; |
214 | connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); | 214 | connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); |
215 | a->addTo( edit ); | 215 | a->addTo( edit ); |
216 | 216 | ||
217 | edit->insertSeparator(); | 217 | edit->insertSeparator(); |
218 | 218 | ||
219 | a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), | 219 | a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), |
220 | QString::null, 0, this, 0 , TRUE ); | 220 | QString::null, 0, this, 0 , TRUE ); |
221 | actionPersonal = a; | 221 | actionPersonal = a; |
222 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); | 222 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); |
223 | a->addTo( edit ); | 223 | a->addTo( edit ); |
224 | 224 | ||
225 | 225 | ||
226 | #ifdef __DEBUG_RELEASE | 226 | #ifdef __DEBUG_RELEASE |
227 | // Remove this function for public Release ! This is only | 227 | // Remove this function for public Release ! This is only |
228 | // for debug purposes .. | 228 | // for debug purposes .. |
229 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); | 229 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); |
230 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); | 230 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); |
231 | a->addTo( edit ); | 231 | a->addTo( edit ); |
232 | #endif | 232 | #endif |
233 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, | 233 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, |
234 | 0, this, 0 ); | 234 | 0, this, 0 ); |
235 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); | 235 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); |
236 | a->addTo( edit ); | 236 | a->addTo( edit ); |
237 | 237 | ||
238 | // Create Views | 238 | // Create Views |
239 | listContainer = new QWidget( this ); | 239 | listContainer = new QWidget( this ); |
240 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); | 240 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); |
241 | 241 | ||
242 | m_abView = new AbView( listContainer, m_config.orderList() ); | 242 | m_abView = new AbView( listContainer, m_config.orderList() ); |
243 | vb->addWidget( m_abView ); | 243 | vb->addWidget( m_abView ); |
244 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 244 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
245 | connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), | 245 | connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), |
246 | this, SLOT( slotViewSwitched( int ) ) ); | 246 | this, SLOT( slotViewSwitched( int ) ) ); |
247 | 247 | ||
248 | 248 | ||
249 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); | 249 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); |
250 | 250 | ||
251 | // m_abView->load(); // Already done by c'tor . | 251 | // m_abView->load(); // Already done by c'tor . |
252 | 252 | ||
253 | // Letter Picker | 253 | // Letter Picker |
254 | pLabel = new LetterPicker( listContainer ); | 254 | pLabel = new LetterPicker( listContainer ); |
255 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 255 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); |
256 | connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); | 256 | connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); |
257 | 257 | ||
258 | vb->addWidget( pLabel ); | 258 | vb->addWidget( pLabel ); |
259 | 259 | ||
260 | // All Categories into view-menu.. | 260 | // All Categories into view-menu.. |
261 | populateCategories(); | 261 | populateCategories(); |
262 | 262 | ||
263 | // Fontsize | 263 | // Fontsize |
264 | defaultFont = new QFont( m_abView->font() ); | 264 | defaultFont = new QFont( m_abView->font() ); |
265 | slotSetFont(m_config.fontSize()); | 265 | slotSetFont(m_config.fontSize()); |
266 | m_curFontSize = m_config.fontSize(); | 266 | m_curFontSize = m_config.fontSize(); |
267 | 267 | ||
268 | setCentralWidget(listContainer); | 268 | setCentralWidget(listContainer); |
269 | 269 | ||
270 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 270 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
271 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); | 271 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); |
272 | connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) ); | 272 | connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) ); |
273 | connect( qApp, SIGNAL( appMessage(const QCString &, const QByteArray &) ), | 273 | connect( qApp, SIGNAL( appMessage(const QCString &, const QByteArray &) ), |
274 | this, SLOT( appMessage(const QCString &, const QByteArray &) ) ); | 274 | this, SLOT( appMessage(const QCString &, const QByteArray &) ) ); |
275 | 275 | ||
276 | 276 | ||
277 | isLoading = false; | 277 | isLoading = false; |
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
281 | void AddressbookWindow::slotConfig() | 281 | void AddressbookWindow::slotConfig() |
282 | { | 282 | { |
283 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); | 283 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); |
284 | dlg -> setConfig( m_config ); | 284 | dlg -> setConfig( m_config ); |
285 | dlg -> showMaximized(); | 285 | dlg -> showMaximized(); |
286 | if ( dlg -> exec() ) { | 286 | if ( dlg -> exec() ) { |
287 | qWarning ("Config Dialog accepted!"); | 287 | qWarning ("Config Dialog accepted!"); |
288 | m_config = dlg -> getConfig(); | 288 | m_config = dlg -> getConfig(); |
289 | if ( m_curFontSize != m_config.fontSize() ){ | 289 | if ( m_curFontSize != m_config.fontSize() ){ |
290 | qWarning("Font was changed!"); | 290 | qWarning("Font was changed!"); |
291 | m_curFontSize = m_config.fontSize(); | 291 | m_curFontSize = m_config.fontSize(); |
292 | emit slotSetFont( m_curFontSize ); | 292 | emit slotSetFont( m_curFontSize ); |
293 | } | 293 | } |
294 | m_abView -> setListOrder( m_config.orderList() ); | 294 | m_abView -> setListOrder( m_config.orderList() ); |
295 | } | 295 | } |
296 | 296 | ||
297 | delete dlg; | 297 | delete dlg; |
298 | } | 298 | } |
299 | 299 | ||
300 | 300 | ||
301 | void AddressbookWindow::slotSetFont( int size ) | 301 | void AddressbookWindow::slotSetFont( int size ) |
302 | { | 302 | { |
303 | qWarning("void AddressbookWindow::slotSetFont( %d )", size); | 303 | qWarning("void AddressbookWindow::slotSetFont( %d )", size); |
304 | 304 | ||
305 | if (size > 2 || size < 0) | 305 | if (size > 2 || size < 0) |
306 | size = 1; | 306 | size = 1; |
307 | 307 | ||
308 | m_config.setFontSize( size ); | 308 | m_config.setFontSize( size ); |
309 | 309 | ||
310 | QFont *currentFont; | 310 | QFont *currentFont; |
311 | 311 | ||
312 | switch (size) { | 312 | switch (size) { |
313 | case 0: | 313 | case 0: |
314 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 314 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
315 | currentFont = new QFont (m_abView->font()); | 315 | currentFont = new QFont (m_abView->font()); |
316 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX | 316 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX |
317 | // abList->resizeRows(); | 317 | // abList->resizeRows(); |
318 | break; | 318 | break; |
319 | case 1: | 319 | case 1: |
320 | m_abView->setFont( *defaultFont ); | 320 | m_abView->setFont( *defaultFont ); |
321 | currentFont = new QFont (m_abView->font()); | 321 | currentFont = new QFont (m_abView->font()); |
322 | // // abList->resizeRows(currentFont->pixelSize() + 7); | 322 | // // abList->resizeRows(currentFont->pixelSize() + 7); |
323 | // abList->resizeRows(); | 323 | // abList->resizeRows(); |
324 | break; | 324 | break; |
325 | case 2: | 325 | case 2: |
326 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 326 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
327 | currentFont = new QFont (m_abView->font()); | 327 | currentFont = new QFont (m_abView->font()); |
328 | // //abList->resizeRows(currentFont->pixelSize() + 7); | 328 | // //abList->resizeRows(currentFont->pixelSize() + 7); |
329 | // abList->resizeRows(); | 329 | // abList->resizeRows(); |
330 | break; | 330 | break; |
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | 335 | ||
336 | void AddressbookWindow::importvCard() { | 336 | void AddressbookWindow::importvCard() { |
337 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | 337 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); |
338 | if(!str.isEmpty() ){ | 338 | if(!str.isEmpty() ){ |
339 | setDocument((const QString&) str ); | 339 | setDocument((const QString&) str ); |
340 | } | 340 | } |
341 | 341 | ||
342 | } | 342 | } |
343 | void AddressbookWindow::exportvCard() | 343 | void AddressbookWindow::exportvCard() |
344 | { | 344 | { |
345 | qWarning(" void AddressbookWindow::exportvCard()"); | 345 | qWarning(" void AddressbookWindow::exportvCard()"); |
346 | QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); | 346 | QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); |
347 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ | 347 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ |
348 | qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); | 348 | qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); |
349 | OContact curCont = m_abView->currentEntry(); | 349 | OContact curCont = m_abView->currentEntry(); |
350 | if ( !curCont.isEmpty() ){ | 350 | if ( !curCont.isEmpty() ){ |
351 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 351 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
352 | filename ); | 352 | filename ); |
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 07d7164..a040d7c 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -1,362 +1,362 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | ** $Id$ | 19 | ** $Id$ |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | 22 | ||
23 | #define QTOPIA_INTERNAL_FD | 23 | #define QTOPIA_INTERNAL_FD |
24 | 24 | ||
25 | #include "datebook.h" | 25 | #include "datebook.h" |
26 | #include "datebookday.h" | 26 | #include "datebookday.h" |
27 | #include "datebooksettings.h" | 27 | #include "datebooksettings.h" |
28 | #include "datebookweek.h" | 28 | #include "datebookweek.h" |
29 | #include "datebookweeklst.h" | 29 | #include "datebookweeklst.h" |
30 | #include "dateentryimpl.h" | 30 | #include "dateentryimpl.h" |
31 | 31 | ||
32 | #include <qpe/datebookmonth.h> | 32 | #include <qpe/datebookmonth.h> |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/qpedebug.h> | 35 | #include <qpe/qpedebug.h> |
36 | #include <qpe/event.h> | 36 | #include <qpe/event.h> |
37 | #include <qpe/finddialog.h> | 37 | #include <qpe/finddialog.h> |
38 | #include <qpe/ir.h> | 38 | #include <qpe/ir.h> |
39 | #include <qpe/qpemenubar.h> | 39 | #include <qmenubar.h> |
40 | #include <qpe/qpemessagebox.h> | 40 | #include <qpe/qpemessagebox.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <qpe/sound.h> | 42 | #include <qpe/sound.h> |
43 | #include <qpe/timestring.h> | 43 | #include <qpe/timestring.h> |
44 | #include <qpe/qpetoolbar.h> | 44 | #include <qpe/qpetoolbar.h> |
45 | #include <qpe/tzselect.h> | 45 | #include <qpe/tzselect.h> |
46 | #include <qpe/xmlreader.h> | 46 | #include <qpe/xmlreader.h> |
47 | 47 | ||
48 | #include <qaction.h> | 48 | #include <qaction.h> |
49 | #include <qcopchannel_qws.h> | 49 | #include <qcopchannel_qws.h> |
50 | #include <qdatetime.h> | 50 | #include <qdatetime.h> |
51 | #include <qdialog.h> | 51 | #include <qdialog.h> |
52 | #include <qfile.h> | 52 | #include <qfile.h> |
53 | #include <qlabel.h> | 53 | #include <qlabel.h> |
54 | #include <qlayout.h> | 54 | #include <qlayout.h> |
55 | #include <qmessagebox.h> | 55 | #include <qmessagebox.h> |
56 | #include <qpopupmenu.h> | 56 | #include <qpopupmenu.h> |
57 | #include <qpushbutton.h> | 57 | #include <qpushbutton.h> |
58 | #include <qregexp.h> | 58 | #include <qregexp.h> |
59 | #include <qtextcodec.h> | 59 | #include <qtextcodec.h> |
60 | #include <qtextstream.h> | 60 | #include <qtextstream.h> |
61 | #include <qtimer.h> | 61 | #include <qtimer.h> |
62 | #include <qtl.h> | 62 | #include <qtl.h> |
63 | #include <qwidgetstack.h> | 63 | #include <qwidgetstack.h> |
64 | #include <qwindowsystem_qws.h> | 64 | #include <qwindowsystem_qws.h> |
65 | 65 | ||
66 | #include <sys/stat.h> | 66 | #include <sys/stat.h> |
67 | #include <sys/types.h> | 67 | #include <sys/types.h> |
68 | #include <fcntl.h> | 68 | #include <fcntl.h> |
69 | #include <unistd.h> | 69 | #include <unistd.h> |
70 | 70 | ||
71 | #include <stdlib.h> | 71 | #include <stdlib.h> |
72 | 72 | ||
73 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | 73 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) |
74 | : QMainWindow( parent, "datebook", f ), | 74 | : QMainWindow( parent, "datebook", f ), |
75 | aPreset( FALSE ), | 75 | aPreset( FALSE ), |
76 | presetTime( -1 ), | 76 | presetTime( -1 ), |
77 | startTime( 8 ), // an acceptable default | 77 | startTime( 8 ), // an acceptable default |
78 | rowStyle( 0 ), | 78 | rowStyle( 0 ), |
79 | bJumpToCurTime(FALSE), | 79 | bJumpToCurTime(FALSE), |
80 | syncing(FALSE), | 80 | syncing(FALSE), |
81 | inSearch(FALSE), | 81 | inSearch(FALSE), |
82 | alarmCounter(0) | 82 | alarmCounter(0) |
83 | { | 83 | { |
84 | bool needEvilHack= false; // if we need an Evil Hack | 84 | bool needEvilHack= false; // if we need an Evil Hack |
85 | QTime t; | 85 | QTime t; |
86 | t.start(); | 86 | t.start(); |
87 | db = new DateBookDBHack; | 87 | db = new DateBookDBHack; |
88 | qDebug("loading db t=%d", t.elapsed() ); | 88 | qDebug("loading db t=%d", t.elapsed() ); |
89 | loadSettings(); | 89 | loadSettings(); |
90 | setCaption( tr("Calendar") ); | 90 | setCaption( tr("Calendar") ); |
91 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | 91 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); |
92 | 92 | ||
93 | setToolBarsMovable( FALSE ); | 93 | setToolBarsMovable( FALSE ); |
94 | 94 | ||
95 | views = new QWidgetStack( this ); | 95 | views = new QWidgetStack( this ); |
96 | setCentralWidget( views ); | 96 | setCentralWidget( views ); |
97 | 97 | ||
98 | dayView = 0; | 98 | dayView = 0; |
99 | weekView = 0; | 99 | weekView = 0; |
100 | weekLstView = 0; | 100 | weekLstView = 0; |
101 | monthView = 0; | 101 | monthView = 0; |
102 | 102 | ||
103 | // QPEToolBar *bar = new QPEToolBar( this ); | 103 | // QPEToolBar *bar = new QPEToolBar( this ); |
104 | // bar->setHorizontalStretchable( TRUE ); | 104 | // bar->setHorizontalStretchable( TRUE ); |
105 | 105 | ||
106 | // QPEMenuBar *mb = new QPEMenuBar( bar ); | 106 | // QMenuBar *mb = new QMenuBar( bar ); |
107 | // mb->setMargin( 0 ); | 107 | // mb->setMargin( 0 ); |
108 | 108 | ||
109 | // QPopupMenu *view = new QPopupMenu( this ); | 109 | // QPopupMenu *view = new QPopupMenu( this ); |
110 | // mb->insertItem( tr( "View" ), view ); | 110 | // mb->insertItem( tr( "View" ), view ); |
111 | 111 | ||
112 | QPEToolBar *sub_bar = new QPEToolBar(this); | 112 | QPEToolBar *sub_bar = new QPEToolBar(this); |
113 | sub_bar->setHorizontalStretchable(TRUE); | 113 | sub_bar->setHorizontalStretchable(TRUE); |
114 | 114 | ||
115 | QActionGroup *g = new QActionGroup( this ); | 115 | QActionGroup *g = new QActionGroup( this ); |
116 | g->setExclusive( TRUE ); | 116 | g->setExclusive( TRUE ); |
117 | 117 | ||
118 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 118 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
119 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 119 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
120 | a->addTo( sub_bar ); | 120 | a->addTo( sub_bar ); |
121 | 121 | ||
122 | sub_bar->addSeparator(); | 122 | sub_bar->addSeparator(); |
123 | 123 | ||
124 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); | 124 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); |
125 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); | 125 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); |
126 | a->addTo( sub_bar ); | 126 | a->addTo( sub_bar ); |
127 | //a->addTo( view ); | 127 | //a->addTo( view ); |
128 | 128 | ||
129 | sub_bar->addSeparator(); | 129 | sub_bar->addSeparator(); |
130 | 130 | ||
131 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); | 131 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); |
132 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); | 132 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); |
133 | a->addTo( sub_bar ); | 133 | a->addTo( sub_bar ); |
134 | // a->addTo( view ); | 134 | // a->addTo( view ); |
135 | a->setToggleAction( TRUE ); | 135 | a->setToggleAction( TRUE ); |
136 | a->setOn( TRUE ); | 136 | a->setOn( TRUE ); |
137 | dayAction = a; | 137 | dayAction = a; |
138 | 138 | ||
139 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); | 139 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); |
140 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); | 140 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); |
141 | a->addTo( sub_bar ); | 141 | a->addTo( sub_bar ); |
142 | // a->addTo( view ); | 142 | // a->addTo( view ); |
143 | a->setToggleAction( TRUE ); | 143 | a->setToggleAction( TRUE ); |
144 | weekAction = a; | 144 | weekAction = a; |
145 | 145 | ||
146 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); | 146 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); |
147 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); | 147 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); |
148 | a->addTo( sub_bar ); | 148 | a->addTo( sub_bar ); |
149 | // a->addTo( view ); | 149 | // a->addTo( view ); |
150 | a->setToggleAction( TRUE ); | 150 | a->setToggleAction( TRUE ); |
151 | weekLstAction = a; | 151 | weekLstAction = a; |
152 | 152 | ||
153 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); | 153 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); |
154 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); | 154 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); |
155 | a->addTo( sub_bar ); | 155 | a->addTo( sub_bar ); |
156 | // a->addTo( view ); | 156 | // a->addTo( view ); |
157 | a->setToggleAction( TRUE ); | 157 | a->setToggleAction( TRUE ); |
158 | monthAction = a; | 158 | monthAction = a; |
159 | 159 | ||
160 | sub_bar->addSeparator(); | 160 | sub_bar->addSeparator(); |
161 | 161 | ||
162 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); | 162 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); |
163 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 163 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
164 | a->addTo( sub_bar ); | 164 | a->addTo( sub_bar ); |
165 | 165 | ||
166 | a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); | 166 | a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); |
167 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 167 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
168 | a->addTo( sub_bar ); | 168 | a->addTo( sub_bar ); |
169 | 169 | ||
170 | if(defaultView==DAY) viewDay(); | 170 | if(defaultView==DAY) viewDay(); |
171 | if(defaultView==WEEK) needEvilHack=true;// viewWeek(); | 171 | if(defaultView==WEEK) needEvilHack=true;// viewWeek(); |
172 | if(defaultView==WEEKLST) viewWeekLst(); | 172 | if(defaultView==WEEKLST) viewWeekLst(); |
173 | if(defaultView==MONTH) viewMonth(); | 173 | if(defaultView==MONTH) viewMonth(); |
174 | 174 | ||
175 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); | 175 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); |
176 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); | 176 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); |
177 | 177 | ||
178 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 178 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
179 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); | 179 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); |
180 | #endif | 180 | #endif |
181 | 181 | ||
182 | // listen on QPE/System | 182 | // listen on QPE/System |
183 | #if defined(Q_WS_QWS) | 183 | #if defined(Q_WS_QWS) |
184 | #if !defined(QT_NO_COP) | 184 | #if !defined(QT_NO_COP) |
185 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 185 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
186 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); | 186 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); |
187 | channel = new QCopChannel( "QPE/Datebook", this ); | 187 | channel = new QCopChannel( "QPE/Datebook", this ); |
188 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); | 188 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); |
189 | qDebug("olle\n"); | 189 | qDebug("olle\n"); |
190 | #endif | 190 | #endif |
191 | #endif | 191 | #endif |
192 | 192 | ||
193 | qDebug("done t=%d", t.elapsed() ); | 193 | qDebug("done t=%d", t.elapsed() ); |
194 | 194 | ||
195 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); | 195 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); |
196 | connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); | 196 | connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); |
197 | /* | 197 | /* |
198 | * Here is a problem description: | 198 | * Here is a problem description: |
199 | * When Weekview is the default view | 199 | * When Weekview is the default view |
200 | * a DateBookWeekView get's created | 200 | * a DateBookWeekView get's created |
201 | * redraw() get's called. So what? | 201 | * redraw() get's called. So what? |
202 | * Remember that we're still in the c'tor | 202 | * Remember that we're still in the c'tor |
203 | * and no final layout has happened? Ok | 203 | * and no final layout has happened? Ok |
204 | * now all Events get arranged. Their x | 204 | * now all Events get arranged. Their x |
205 | * position get's determined by a QHeader | 205 | * position get's determined by a QHeader |
206 | * position. But the QHeader isn't layouted or | 206 | * position. But the QHeader isn't layouted or |
207 | * at the right position. redraw() is a slot | 207 | * at the right position. redraw() is a slot |
208 | * so we'll call it then via a singleShot | 208 | * so we'll call it then via a singleShot |
209 | * from view() | 209 | * from view() |
210 | */ | 210 | */ |
211 | if( needEvilHack ){ | 211 | if( needEvilHack ){ |
212 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); | 212 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | void DateBook::receive( const QCString &msg, const QByteArray &data ) | 216 | void DateBook::receive( const QCString &msg, const QByteArray &data ) |
217 | { | 217 | { |
218 | QDataStream stream( data, IO_ReadOnly ); | 218 | QDataStream stream( data, IO_ReadOnly ); |
219 | if ( msg == "timeChange(QString)" ) { | 219 | if ( msg == "timeChange(QString)" ) { |
220 | // update active view! | 220 | // update active view! |
221 | if ( dayAction->isOn() ) | 221 | if ( dayAction->isOn() ) |
222 | viewDay(); | 222 | viewDay(); |
223 | else if ( weekAction->isOn() ) | 223 | else if ( weekAction->isOn() ) |
224 | viewWeek(); | 224 | viewWeek(); |
225 | else if ( monthAction->isOn() ) | 225 | else if ( monthAction->isOn() ) |
226 | viewMonth(); | 226 | viewMonth(); |
227 | } | 227 | } |
228 | else if (msg == "editEvent(int)") { | 228 | else if (msg == "editEvent(int)") { |
229 | int uid; | 229 | int uid; |
230 | stream >> uid; | 230 | stream >> uid; |
231 | Event e=db->eventByUID(uid); | 231 | Event e=db->eventByUID(uid); |
232 | editEvent(e); | 232 | editEvent(e); |
233 | }else if (msg == "viewDefault(QDate)"){ | 233 | }else if (msg == "viewDefault(QDate)"){ |
234 | QDate day; | 234 | QDate day; |
235 | stream >> day; | 235 | stream >> day; |
236 | viewDefault(day); | 236 | viewDefault(day); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | DateBook::~DateBook() | 240 | DateBook::~DateBook() |
241 | { | 241 | { |
242 | } | 242 | } |
243 | 243 | ||
244 | void DateBook::slotSettings() | 244 | void DateBook::slotSettings() |
245 | { | 245 | { |
246 | DateBookSettings frmSettings( ampm, this ); | 246 | DateBookSettings frmSettings( ampm, this ); |
247 | frmSettings.setStartTime( startTime ); | 247 | frmSettings.setStartTime( startTime ); |
248 | frmSettings.setAlarmPreset( aPreset, presetTime ); | 248 | frmSettings.setAlarmPreset( aPreset, presetTime ); |
249 | frmSettings.setJumpToCurTime( bJumpToCurTime ); | 249 | frmSettings.setJumpToCurTime( bJumpToCurTime ); |
250 | frmSettings.setRowStyle( rowStyle ); | 250 | frmSettings.setRowStyle( rowStyle ); |
251 | frmSettings.comboDefaultView->setCurrentItem(defaultView-1); | 251 | frmSettings.comboDefaultView->setCurrentItem(defaultView-1); |
252 | frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); | 252 | frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); |
253 | 253 | ||
254 | bool found=false; | 254 | bool found=false; |
255 | for (int i=0; i<(frmSettings.comboLocation->count()); i++) { | 255 | for (int i=0; i<(frmSettings.comboLocation->count()); i++) { |
256 | if ( frmSettings.comboLocation->text(i) == defaultLocation ) { | 256 | if ( frmSettings.comboLocation->text(i) == defaultLocation ) { |
257 | frmSettings.comboLocation->setCurrentItem(i); | 257 | frmSettings.comboLocation->setCurrentItem(i); |
258 | found=true; | 258 | found=true; |
259 | break; | 259 | break; |
260 | } | 260 | } |
261 | } | 261 | } |
262 | if(!found) { | 262 | if(!found) { |
263 | frmSettings.comboLocation->insertItem(defaultLocation); | 263 | frmSettings.comboLocation->insertItem(defaultLocation); |
264 | frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); | 264 | frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); |
265 | } | 265 | } |
266 | frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); | 266 | frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); |
267 | 267 | ||
268 | #if defined (Q_WS_QWS) || defined(_WS_QWS_) | 268 | #if defined (Q_WS_QWS) || defined(_WS_QWS_) |
269 | frmSettings.showMaximized(); | 269 | frmSettings.showMaximized(); |
270 | #endif | 270 | #endif |
271 | 271 | ||
272 | if ( frmSettings.exec() ) { | 272 | if ( frmSettings.exec() ) { |
273 | 273 | ||
274 | aPreset = frmSettings.alarmPreset(); | 274 | aPreset = frmSettings.alarmPreset(); |
275 | presetTime = frmSettings.presetTime(); | 275 | presetTime = frmSettings.presetTime(); |
276 | startTime = frmSettings.startTime(); | 276 | startTime = frmSettings.startTime(); |
277 | bJumpToCurTime = frmSettings.jumpToCurTime(); | 277 | bJumpToCurTime = frmSettings.jumpToCurTime(); |
278 | rowStyle = frmSettings.rowStyle(); | 278 | rowStyle = frmSettings.rowStyle(); |
279 | defaultView=frmSettings.comboDefaultView->currentItem()+1; | 279 | defaultView=frmSettings.comboDefaultView->currentItem()+1; |
280 | weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); | 280 | weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); |
281 | defaultLocation=frmSettings.comboLocation->currentText(); | 281 | defaultLocation=frmSettings.comboLocation->currentText(); |
282 | defaultCategories=frmSettings.comboCategory->currentCategories(); | 282 | defaultCategories=frmSettings.comboCategory->currentCategories(); |
283 | 283 | ||
284 | if ( dayView ) { | 284 | if ( dayView ) { |
285 | dayView->setStartViewTime( startTime ); | 285 | dayView->setStartViewTime( startTime ); |
286 | dayView->setJumpToCurTime( bJumpToCurTime ); | 286 | dayView->setJumpToCurTime( bJumpToCurTime ); |
287 | dayView->setRowStyle( rowStyle ); | 287 | dayView->setRowStyle( rowStyle ); |
288 | } | 288 | } |
289 | if ( weekView ) { | 289 | if ( weekView ) { |
290 | weekView->setStartViewTime( startTime ); | 290 | weekView->setStartViewTime( startTime ); |
291 | } | 291 | } |
292 | saveSettings(); | 292 | saveSettings(); |
293 | 293 | ||
294 | // make the change obvious | 294 | // make the change obvious |
295 | if ( views->visibleWidget() ) { | 295 | if ( views->visibleWidget() ) { |
296 | if ( views->visibleWidget() == dayView ) | 296 | if ( views->visibleWidget() == dayView ) |
297 | dayView->redraw(); | 297 | dayView->redraw(); |
298 | else if ( views->visibleWidget() == weekView ) | 298 | else if ( views->visibleWidget() == weekView ) |
299 | weekView->redraw(); | 299 | weekView->redraw(); |
300 | else if ( views->visibleWidget() == weekLstView ) | 300 | else if ( views->visibleWidget() == weekLstView ) |
301 | weekLstView->redraw(); | 301 | weekLstView->redraw(); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | void DateBook::fileNew() | 306 | void DateBook::fileNew() |
307 | { | 307 | { |
308 | slotNewEventFromKey(""); | 308 | slotNewEventFromKey(""); |
309 | } | 309 | } |
310 | 310 | ||
311 | QString DateBook::checkEvent(const Event &e) | 311 | QString DateBook::checkEvent(const Event &e) |
312 | { | 312 | { |
313 | /* check if overlaps with itself */ | 313 | /* check if overlaps with itself */ |
314 | bool checkFailed = FALSE; | 314 | bool checkFailed = FALSE; |
315 | 315 | ||
316 | /* check the next 12 repeats. should catch most problems */ | 316 | /* check the next 12 repeats. should catch most problems */ |
317 | QDate current_date = e.start().date(); | 317 | QDate current_date = e.start().date(); |
318 | Event previous = e; | 318 | Event previous = e; |
319 | for(int i = 0; i < 12; i++) | 319 | for(int i = 0; i < 12; i++) |
320 | { | 320 | { |
321 | QDateTime next; | 321 | QDateTime next; |
322 | if (!nextOccurance(previous, current_date.addDays(1), next)) { | 322 | if (!nextOccurance(previous, current_date.addDays(1), next)) { |
323 | break; // no more repeats | 323 | break; // no more repeats |
324 | } | 324 | } |
325 | if(next < previous.end()) { | 325 | if(next < previous.end()) { |
326 | checkFailed = TRUE; | 326 | checkFailed = TRUE; |
327 | break; | 327 | break; |
328 | } | 328 | } |
329 | current_date = next.date(); | 329 | current_date = next.date(); |
330 | } | 330 | } |
331 | 331 | ||
332 | if(checkFailed) | 332 | if(checkFailed) |
333 | return tr("Event duration is potentially longer\n" | 333 | return tr("Event duration is potentially longer\n" |
334 | "than interval between repeats."); | 334 | "than interval between repeats."); |
335 | 335 | ||
336 | return QString::null; | 336 | return QString::null; |
337 | } | 337 | } |
338 | 338 | ||
339 | QDate DateBook::currentDate() | 339 | QDate DateBook::currentDate() |
340 | { | 340 | { |
341 | QDate d = QDate::currentDate(); | 341 | QDate d = QDate::currentDate(); |
342 | 342 | ||
343 | if ( dayView && views->visibleWidget() == dayView ) { | 343 | if ( dayView && views->visibleWidget() == dayView ) { |
344 | d = dayView->date(); | 344 | d = dayView->date(); |
345 | } else if ( weekView && views->visibleWidget() == weekView ) { | 345 | } else if ( weekView && views->visibleWidget() == weekView ) { |
346 | d = weekView->date(); | 346 | d = weekView->date(); |
347 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { | 347 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { |
348 | d = weekLstView->date(); | 348 | d = weekLstView->date(); |
349 | } else if ( monthView && views->visibleWidget() == monthView ) { | 349 | } else if ( monthView && views->visibleWidget() == monthView ) { |
350 | d = monthView->selectedDate(); | 350 | d = monthView->selectedDate(); |
351 | } | 351 | } |
352 | 352 | ||
353 | return d; | 353 | return d; |
354 | } | 354 | } |
355 | 355 | ||
356 | void DateBook::view(int v, const QDate &d) { | 356 | void DateBook::view(int v, const QDate &d) { |
357 | if (v==DAY) { | 357 | if (v==DAY) { |
358 | initDay(); | 358 | initDay(); |
359 | dayAction->setOn( TRUE ); | 359 | dayAction->setOn( TRUE ); |
360 | dayView->setDate( d ); | 360 | dayView->setDate( d ); |
361 | views->raiseWidget( dayView ); | 361 | views->raiseWidget( dayView ); |
362 | dayView->redraw(); | 362 | dayView->redraw(); |
diff --git a/core/pim/datebook2/mainwindow.cpp b/core/pim/datebook2/mainwindow.cpp index 68525b3..7d436ae 100644 --- a/core/pim/datebook2/mainwindow.cpp +++ b/core/pim/datebook2/mainwindow.cpp | |||
@@ -1,305 +1,305 @@ | |||
1 | 1 | ||
2 | #include <qcopchannel_qws.h> | 2 | #include <qcopchannel_qws.h> |
3 | #include <qwidgetstack.h> | 3 | #include <qwidgetstack.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qaction.h> | 5 | #include <qaction.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtimer.h> | 7 | #include <qtimer.h> |
8 | 8 | ||
9 | #include <qpe/qpeapplication.h> | 9 | #include <qpe/qpeapplication.h> |
10 | #include <qpe/ir.h> | 10 | #include <qpe/ir.h> |
11 | #include <qpe/qpemenubar.h> | 11 | #include <qmenubar.h> |
12 | #include <qpe/qpetoolbar.h> | 12 | #include <qpe/qpetoolbar.h> |
13 | #include <qpe/qpemessagebox.h> | 13 | #include <qpe/qpemessagebox.h> |
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | 15 | ||
16 | #include "editor.h" | 16 | #include "editor.h" |
17 | #include "show.h" | 17 | #include "show.h" |
18 | #include "templatemanager.h" | 18 | #include "templatemanager.h" |
19 | #include "bookmanager.h" | 19 | #include "bookmanager.h" |
20 | #include "mainwindow.h" | 20 | #include "mainwindow.h" |
21 | 21 | ||
22 | 22 | ||
23 | using namespace Datebook; | 23 | using namespace Datebook; |
24 | 24 | ||
25 | MainWindow::MainWindow() | 25 | MainWindow::MainWindow() |
26 | : OPimMainWindow( "Datebook", 0, 0 ), m_descMan( "Descriptions" ), m_locMan( "Locations" ) | 26 | : OPimMainWindow( "Datebook", 0, 0 ), m_descMan( "Descriptions" ), m_locMan( "Locations" ) |
27 | { | 27 | { |
28 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | 28 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); |
29 | initUI(); | 29 | initUI(); |
30 | initManagers(); | 30 | initManagers(); |
31 | initView(); | 31 | initView(); |
32 | initConfig(); | 32 | initConfig(); |
33 | 33 | ||
34 | QTimer::singleShot(0, this, SLOT(populate() ) ); | 34 | QTimer::singleShot(0, this, SLOT(populate() ) ); |
35 | 35 | ||
36 | QCopChannel* chan = new QCopChannel( "QPE/System", this ); | 36 | QCopChannel* chan = new QCopChannel( "QPE/System", this ); |
37 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), | 37 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), |
38 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); | 38 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); |
39 | 39 | ||
40 | chan = new QCopChannel( "QPE/Datebook", this ); | 40 | chan = new QCopChannel( "QPE/Datebook", this ); |
41 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), | 41 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), |
42 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); | 42 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); |
43 | } | 43 | } |
44 | MainWindow::~MainWindow() { | 44 | MainWindow::~MainWindow() { |
45 | m_tempMan.save(); | 45 | m_tempMan.save(); |
46 | m_locMan.save(); | 46 | m_locMan.save(); |
47 | m_descMan.save(); | 47 | m_descMan.save(); |
48 | 48 | ||
49 | manager()->save(); | 49 | manager()->save(); |
50 | delete m_manager; | 50 | delete m_manager; |
51 | } | 51 | } |
52 | void MainWindow::doSetDocument( const QString& str ) { | 52 | void MainWindow::doSetDocument( const QString& str ) { |
53 | 53 | ||
54 | } | 54 | } |
55 | void MainWindow::flush() { | 55 | void MainWindow::flush() { |
56 | manager()->save(); | 56 | manager()->save(); |
57 | } | 57 | } |
58 | void MainWindow::reload() { | 58 | void MainWindow::reload() { |
59 | manager()->reload(); | 59 | manager()->reload(); |
60 | } | 60 | } |
61 | int MainWindow::create() { | 61 | int MainWindow::create() { |
62 | return 0; | 62 | return 0; |
63 | } | 63 | } |
64 | bool MainWindow::remove( int uid ) { | 64 | bool MainWindow::remove( int uid ) { |
65 | manager()->remove( uid ); | 65 | manager()->remove( uid ); |
66 | return true; | 66 | return true; |
67 | } | 67 | } |
68 | void MainWindow::beam( int uid ) { | 68 | void MainWindow::beam( int uid ) { |
69 | 69 | ||
70 | } | 70 | } |
71 | void MainWindow::show( int uid ) { | 71 | void MainWindow::show( int uid ) { |
72 | 72 | ||
73 | eventShow()->show( manager()->event( uid ) ); | 73 | eventShow()->show( manager()->event( uid ) ); |
74 | } | 74 | } |
75 | void MainWindow::add( const OPimRecord& ad) { | 75 | void MainWindow::add( const OPimRecord& ad) { |
76 | manager()->add( ad ); | 76 | manager()->add( ad ); |
77 | } | 77 | } |
78 | void MainWindow::edit() { | 78 | void MainWindow::edit() { |
79 | edit ( currentView()->currentItem() ); | 79 | edit ( currentView()->currentItem() ); |
80 | } | 80 | } |
81 | void MainWindow::edit( int uid ) { | 81 | void MainWindow::edit( int uid ) { |
82 | 82 | ||
83 | } | 83 | } |
84 | /* | 84 | /* |
85 | * init tool bars layout and so on | 85 | * init tool bars layout and so on |
86 | */ | 86 | */ |
87 | void MainWindow::initUI() { | 87 | void MainWindow::initUI() { |
88 | setToolBarsMovable( false ); | 88 | setToolBarsMovable( false ); |
89 | 89 | ||
90 | m_stack = new QWidgetStack( this ); | 90 | m_stack = new QWidgetStack( this ); |
91 | setCentralWidget( m_stack ); | 91 | setCentralWidget( m_stack ); |
92 | 92 | ||
93 | m_toolBar = new QPEToolBar( this ); | 93 | m_toolBar = new QPEToolBar( this ); |
94 | m_toolBar->setHorizontalStretchable( TRUE ); | 94 | m_toolBar->setHorizontalStretchable( TRUE ); |
95 | 95 | ||
96 | QPEMenuBar* mb = new QPEMenuBar( m_toolBar ); | 96 | QMenuBar* mb = new QMenuBar( m_toolBar ); |
97 | 97 | ||
98 | m_popView = new QPopupMenu( this ); | 98 | m_popView = new QPopupMenu( this ); |
99 | m_popSetting = new QPopupMenu( this ); | 99 | m_popSetting = new QPopupMenu( this ); |
100 | 100 | ||
101 | mb->insertItem( tr("View"), m_popView ); | 101 | mb->insertItem( tr("View"), m_popView ); |
102 | mb->insertItem( tr("Settings" ), m_popSetting ); | 102 | mb->insertItem( tr("Settings" ), m_popSetting ); |
103 | 103 | ||
104 | m_popTemplate = new QPopupMenu( this ); | 104 | m_popTemplate = new QPopupMenu( this ); |
105 | m_popTemplate->setCheckable( TRUE ); | 105 | m_popTemplate->setCheckable( TRUE ); |
106 | connect( m_popTemplate, SIGNAL(activated(int) ), | 106 | connect( m_popTemplate, SIGNAL(activated(int) ), |
107 | this, SLOT(slotNewFromTemplate(int) ) ); | 107 | this, SLOT(slotNewFromTemplate(int) ) ); |
108 | m_popView->insertItem(tr("New from template"), m_popTemplate, -1, 0); | 108 | m_popView->insertItem(tr("New from template"), m_popTemplate, -1, 0); |
109 | 109 | ||
110 | 110 | ||
111 | QAction* a = new QAction( tr("New Event"), Resource::loadPixmap("new"), | 111 | QAction* a = new QAction( tr("New Event"), Resource::loadPixmap("new"), |
112 | QString::null, 0, this, 0 ); | 112 | QString::null, 0, this, 0 ); |
113 | a->addTo( m_toolBar ); | 113 | a->addTo( m_toolBar ); |
114 | a->addTo( m_popView ); | 114 | a->addTo( m_popView ); |
115 | connect(a, SIGNAL( activated() ), this, SLOT( create() ) ); | 115 | connect(a, SIGNAL( activated() ), this, SLOT( create() ) ); |
116 | 116 | ||
117 | a = new QAction( tr("Edit Event"), Resource::loadPixmap("edit"), | 117 | a = new QAction( tr("Edit Event"), Resource::loadPixmap("edit"), |
118 | QString::null, 0, this, 0 ); | 118 | QString::null, 0, this, 0 ); |
119 | a->addTo( m_popView ); | 119 | a->addTo( m_popView ); |
120 | connect(a, SIGNAL( activated() ), this, SLOT( edit() ) ); | 120 | connect(a, SIGNAL( activated() ), this, SLOT( edit() ) ); |
121 | 121 | ||
122 | a = new QAction( tr("Today" ), Resource::loadPixmap( "datebook/to_day"), | 122 | a = new QAction( tr("Today" ), Resource::loadPixmap( "datebook/to_day"), |
123 | QString::null, 0, this, 0 ); | 123 | QString::null, 0, this, 0 ); |
124 | a->addTo( m_toolBar ); | 124 | a->addTo( m_toolBar ); |
125 | connect(a, SIGNAL( activated() ), this, SLOT( slotGoToNow() ) ); | 125 | connect(a, SIGNAL( activated() ), this, SLOT( slotGoToNow() ) ); |
126 | 126 | ||
127 | a = new QAction( tr("Find"), Resource::loadPixmap( "mag" ), | 127 | a = new QAction( tr("Find"), Resource::loadPixmap( "mag" ), |
128 | QString::null, 0, this, 0 ); | 128 | QString::null, 0, this, 0 ); |
129 | a->addTo( m_toolBar ); | 129 | a->addTo( m_toolBar ); |
130 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 130 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
131 | 131 | ||
132 | a = new QAction( tr("Configure"), QString::null, 0, 0 ); | 132 | a = new QAction( tr("Configure"), QString::null, 0, 0 ); |
133 | a->addTo( m_popSetting ); | 133 | a->addTo( m_popSetting ); |
134 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); | 134 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); |
135 | 135 | ||
136 | a = new QAction( tr("Configure Locations"), QString::null, 0, 0 ); | 136 | a = new QAction( tr("Configure Locations"), QString::null, 0, 0 ); |
137 | a->addTo( m_popSetting ); | 137 | a->addTo( m_popSetting ); |
138 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigureLocs() ) ); | 138 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigureLocs() ) ); |
139 | 139 | ||
140 | a = new QAction( tr("Configure Descriptions"), QString::null, 0, 0 ); | 140 | a = new QAction( tr("Configure Descriptions"), QString::null, 0, 0 ); |
141 | a->addTo( m_popSetting ); | 141 | a->addTo( m_popSetting ); |
142 | connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) ); | 142 | connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) ); |
143 | 143 | ||
144 | a = new QAction( tr("Configure Templates"), QString::null, 0, 0 ); | 144 | a = new QAction( tr("Configure Templates"), QString::null, 0, 0 ); |
145 | a->addTo( m_popSetting ); | 145 | a->addTo( m_popSetting ); |
146 | connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureTemp() ) ); | 146 | connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureTemp() ) ); |
147 | 147 | ||
148 | connect( qApp, SIGNAL(clockChanged(bool) ), | 148 | connect( qApp, SIGNAL(clockChanged(bool) ), |
149 | this, SLOT(slotClockChanged(bool) ) ); | 149 | this, SLOT(slotClockChanged(bool) ) ); |
150 | connect( qApp, SIGNAL(weekChanged(bool) ), | 150 | connect( qApp, SIGNAL(weekChanged(bool) ), |
151 | this, SLOT(slotWeekChanged(bool) ) ); | 151 | this, SLOT(slotWeekChanged(bool) ) ); |
152 | 152 | ||
153 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), | 153 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), |
154 | this, SLOT(slotAppMessage( const QCString&, const QByteArray& ) ) ); | 154 | this, SLOT(slotAppMessage( const QCString&, const QByteArray& ) ) ); |
155 | } | 155 | } |
156 | void MainWindow::initConfig() { | 156 | void MainWindow::initConfig() { |
157 | 157 | ||
158 | } | 158 | } |
159 | void MainWindow::initView() { | 159 | void MainWindow::initView() { |
160 | 160 | ||
161 | } | 161 | } |
162 | void MainWindow::initManagers() { | 162 | void MainWindow::initManagers() { |
163 | m_manager = new BookManager; | 163 | m_manager = new BookManager; |
164 | 164 | ||
165 | m_tempMan.load(); | 165 | m_tempMan.load(); |
166 | m_locMan.load(); | 166 | m_locMan.load(); |
167 | m_descMan.load(); | 167 | m_descMan.load(); |
168 | 168 | ||
169 | setTemplateMenu(); | 169 | setTemplateMenu(); |
170 | } | 170 | } |
171 | void MainWindow::raiseCurrentView() { | 171 | void MainWindow::raiseCurrentView() { |
172 | 172 | ||
173 | } | 173 | } |
174 | /* | 174 | /* |
175 | * populate the view | 175 | * populate the view |
176 | */ | 176 | */ |
177 | void MainWindow::populate() { | 177 | void MainWindow::populate() { |
178 | if (!manager()->isLoaded() ) | 178 | if (!manager()->isLoaded() ) |
179 | manager()->load(); | 179 | manager()->load(); |
180 | } | 180 | } |
181 | void MainWindow::slotGoToNow() { | 181 | void MainWindow::slotGoToNow() { |
182 | 182 | ||
183 | } | 183 | } |
184 | View* MainWindow::currentView() { | 184 | View* MainWindow::currentView() { |
185 | 185 | ||
186 | } | 186 | } |
187 | void MainWindow::slotFind() { | 187 | void MainWindow::slotFind() { |
188 | 188 | ||
189 | } | 189 | } |
190 | void MainWindow::slotConfigure() { | 190 | void MainWindow::slotConfigure() { |
191 | 191 | ||
192 | } | 192 | } |
193 | void MainWindow::slotClockChanged( bool ) { | 193 | void MainWindow::slotClockChanged( bool ) { |
194 | 194 | ||
195 | } | 195 | } |
196 | void MainWindow::slotWeekChanged(bool ) { | 196 | void MainWindow::slotWeekChanged(bool ) { |
197 | 197 | ||
198 | } | 198 | } |
199 | void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) { | 199 | void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) { |
200 | 200 | ||
201 | } | 201 | } |
202 | void MainWindow::slotReceive( const QCString&, const QByteArray& ) { | 202 | void MainWindow::slotReceive( const QCString&, const QByteArray& ) { |
203 | 203 | ||
204 | } | 204 | } |
205 | BookManager* MainWindow::manager() { | 205 | BookManager* MainWindow::manager() { |
206 | return m_manager; | 206 | return m_manager; |
207 | } | 207 | } |
208 | TemplateManager MainWindow::templateManager() { | 208 | TemplateManager MainWindow::templateManager() { |
209 | return m_tempMan; | 209 | return m_tempMan; |
210 | } | 210 | } |
211 | LocationManager MainWindow::locationManager() { | 211 | LocationManager MainWindow::locationManager() { |
212 | return m_locMan; | 212 | return m_locMan; |
213 | } | 213 | } |
214 | DescriptionManager MainWindow::descriptionManager() { | 214 | DescriptionManager MainWindow::descriptionManager() { |
215 | return m_descMan; | 215 | return m_descMan; |
216 | } | 216 | } |
217 | void MainWindow::setLocationManager( const LocationManager& loc) { | 217 | void MainWindow::setLocationManager( const LocationManager& loc) { |
218 | m_locMan = loc; | 218 | m_locMan = loc; |
219 | } | 219 | } |
220 | void MainWindow::setDescriptionManager( const DescriptionManager& dsc ) { | 220 | void MainWindow::setDescriptionManager( const DescriptionManager& dsc ) { |
221 | m_descMan = dsc; | 221 | m_descMan = dsc; |
222 | } | 222 | } |
223 | Show* MainWindow::eventShow() { | 223 | Show* MainWindow::eventShow() { |
224 | return m_show; | 224 | return m_show; |
225 | } | 225 | } |
226 | void MainWindow::slotAction( QAction* act ) { | 226 | void MainWindow::slotAction( QAction* act ) { |
227 | 227 | ||
228 | } | 228 | } |
229 | void MainWindow::slotConfigureLocs() { | 229 | void MainWindow::slotConfigureLocs() { |
230 | LocationManagerDialog dlg( locationManager() ); | 230 | LocationManagerDialog dlg( locationManager() ); |
231 | dlg.setCaption( tr("Configure Locations") ); | 231 | dlg.setCaption( tr("Configure Locations") ); |
232 | dlg.showMaximized(); | 232 | dlg.showMaximized(); |
233 | if (dlg.exec() == QDialog::Accepted ) { | 233 | if (dlg.exec() == QDialog::Accepted ) { |
234 | setLocationManager( dlg.manager() ); | 234 | setLocationManager( dlg.manager() ); |
235 | } | 235 | } |
236 | } | 236 | } |
237 | void MainWindow::slotConfigureDesc() { | 237 | void MainWindow::slotConfigureDesc() { |
238 | DescriptionManagerDialog dlg( descriptionManager() ); | 238 | DescriptionManagerDialog dlg( descriptionManager() ); |
239 | dlg.setCaption( tr("Configure Descriptions") ); | 239 | dlg.setCaption( tr("Configure Descriptions") ); |
240 | dlg.showMaximized(); | 240 | dlg.showMaximized(); |
241 | if (dlg.exec() == QDialog::Accepted ) { | 241 | if (dlg.exec() == QDialog::Accepted ) { |
242 | setDescriptionManager( dlg.manager() ); | 242 | setDescriptionManager( dlg.manager() ); |
243 | } | 243 | } |
244 | } | 244 | } |
245 | void MainWindow::slotConfigureTemp() { | 245 | void MainWindow::slotConfigureTemp() { |
246 | TemplateDialog dlg( templateManager(), editor() ); | 246 | TemplateDialog dlg( templateManager(), editor() ); |
247 | dlg.setCaption( tr("Configure Templates") ); | 247 | dlg.setCaption( tr("Configure Templates") ); |
248 | dlg.showMaximized(); | 248 | dlg.showMaximized(); |
249 | if ( dlg.exec() == QDialog::Accepted ) { | 249 | if ( dlg.exec() == QDialog::Accepted ) { |
250 | m_tempMan = dlg.manager(); | 250 | m_tempMan = dlg.manager(); |
251 | setTemplateMenu(); | 251 | setTemplateMenu(); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | void MainWindow::hideShow() { | 254 | void MainWindow::hideShow() { |
255 | 255 | ||
256 | } | 256 | } |
257 | void MainWindow::viewPopup(int ) { | 257 | void MainWindow::viewPopup(int ) { |
258 | 258 | ||
259 | } | 259 | } |
260 | void MainWindow::viewAdd(const QDate& ) { | 260 | void MainWindow::viewAdd(const QDate& ) { |
261 | 261 | ||
262 | } | 262 | } |
263 | void MainWindow::viewAdd( const QDateTime&, const QDateTime& ) { | 263 | void MainWindow::viewAdd( const QDateTime&, const QDateTime& ) { |
264 | 264 | ||
265 | } | 265 | } |
266 | bool MainWindow::viewAP()const{ | 266 | bool MainWindow::viewAP()const{ |
267 | } | 267 | } |
268 | bool MainWindow::viewStartMonday()const { | 268 | bool MainWindow::viewStartMonday()const { |
269 | 269 | ||
270 | } | 270 | } |
271 | void MainWindow::setTemplateMenu() { | 271 | void MainWindow::setTemplateMenu() { |
272 | m_popTemplate->clear(); | 272 | m_popTemplate->clear(); |
273 | 273 | ||
274 | QStringList list = templateManager().names(); | 274 | QStringList list = templateManager().names(); |
275 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 275 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
276 | m_popTemplate->insertItem( (*it) ); | 276 | m_popTemplate->insertItem( (*it) ); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | /* | 279 | /* |
280 | * get the name of the item with the id id | 280 | * get the name of the item with the id id |
281 | * then ask for an OEvent from the manager | 281 | * then ask for an OEvent from the manager |
282 | */ | 282 | */ |
283 | void MainWindow::slotNewFromTemplate(int id ) { | 283 | void MainWindow::slotNewFromTemplate(int id ) { |
284 | QString name = m_popTemplate->text( id ); | 284 | QString name = m_popTemplate->text( id ); |
285 | 285 | ||
286 | OEvent ev = templateManager().value( name ); | 286 | OEvent ev = templateManager().value( name ); |
287 | 287 | ||
288 | if ( editor()->edit( ev ) ) { | 288 | if ( editor()->edit( ev ) ) { |
289 | ev = editor()->event(); | 289 | ev = editor()->event(); |
290 | ev.setUid( -1 ); | 290 | ev.setUid( -1 ); |
291 | manager()->add( ev ); | 291 | manager()->add( ev ); |
292 | 292 | ||
293 | /* | 293 | /* |
294 | * no we'll find out if the current view | 294 | * no we'll find out if the current view |
295 | * should show the new event | 295 | * should show the new event |
296 | * and then we will ask it to refresh | 296 | * and then we will ask it to refresh |
297 | * FIXME for now we'll call a refresh | 297 | * FIXME for now we'll call a refresh |
298 | */ | 298 | */ |
299 | currentView()->reschedule(); | 299 | currentView()->reschedule(); |
300 | raiseCurrentView(); | 300 | raiseCurrentView(); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | Editor* MainWindow::editor() { | 303 | Editor* MainWindow::editor() { |
304 | return m_edit; | 304 | return m_edit; |
305 | } | 305 | } |
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp index f768d81..80738df 100644 --- a/core/pim/osearch/mainwindow.cpp +++ b/core/pim/osearch/mainwindow.cpp | |||
@@ -1,277 +1,277 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
11 | 11 | ||
12 | 12 | ||
13 | 13 | ||
14 | #include <qaction.h> | 14 | #include <qaction.h> |
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qpopupmenu.h> | 16 | #include <qpopupmenu.h> |
17 | #include <qtoolbutton.h> | 17 | #include <qtoolbutton.h> |
18 | #include <qstring.h> | 18 | #include <qstring.h> |
19 | #include <qlabel.h> | 19 | #include <qlabel.h> |
20 | #include <qfile.h> | 20 | #include <qfile.h> |
21 | #include <qhbuttongroup.h> | 21 | #include <qhbuttongroup.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
24 | #include <qintdict.h> | 24 | #include <qintdict.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qlineedit.h> | 26 | #include <qlineedit.h> |
27 | #include <qsignalmapper.h> | 27 | #include <qsignalmapper.h> |
28 | #include <qtextbrowser.h> | 28 | #include <qtextbrowser.h> |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | #include <qwhatsthis.h> | 30 | #include <qwhatsthis.h> |
31 | #include <qpe/qpemenubar.h> | 31 | #include <qmenubar.h> |
32 | #include <qpe/qpemessagebox.h> | 32 | #include <qpe/qpemessagebox.h> |
33 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
34 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/qpetoolbar.h> | 35 | #include <qpe/qpetoolbar.h> |
36 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <opie/owait.h> | 39 | #include <opie/owait.h> |
40 | 40 | ||
41 | #include "olistview.h" | 41 | #include "olistview.h" |
42 | #include "olistviewitem.h" | 42 | #include "olistviewitem.h" |
43 | #include "resultitem.h" | 43 | #include "resultitem.h" |
44 | #include "adresssearch.h" | 44 | #include "adresssearch.h" |
45 | #include "todosearch.h" | 45 | #include "todosearch.h" |
46 | #include "datebooksearch.h" | 46 | #include "datebooksearch.h" |
47 | #include "applnksearch.h" | 47 | #include "applnksearch.h" |
48 | #include "doclnksearch.h" | 48 | #include "doclnksearch.h" |
49 | #include "mainwindow.h" | 49 | #include "mainwindow.h" |
50 | 50 | ||
51 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | 51 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : |
52 | QMainWindow( parent, name, f ), _currentItem(0) | 52 | QMainWindow( parent, name, f ), _currentItem(0) |
53 | { | 53 | { |
54 | setCaption( tr("OSearch") ); | 54 | setCaption( tr("OSearch") ); |
55 | 55 | ||
56 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 56 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); |
57 | 57 | ||
58 | QFrame *mainFrame = new QFrame( this, "mainFrame" ); | 58 | QFrame *mainFrame = new QFrame( this, "mainFrame" ); |
59 | mainFrame->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 59 | mainFrame->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); |
60 | 60 | ||
61 | mainLayout = new QVBoxLayout( mainFrame ); | 61 | mainLayout = new QVBoxLayout( mainFrame ); |
62 | mainLayout->setSpacing( 0 ); | 62 | mainLayout->setSpacing( 0 ); |
63 | mainLayout->setMargin( 0 ); | 63 | mainLayout->setMargin( 0 ); |
64 | 64 | ||
65 | resultsList = new OListView( mainFrame ); | 65 | resultsList = new OListView( mainFrame ); |
66 | resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 66 | resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); |
67 | mainLayout->addWidget( resultsList ); | 67 | mainLayout->addWidget( resultsList ); |
68 | 68 | ||
69 | detailsFrame = new QFrame( mainFrame, "detailsFrame" ); | 69 | detailsFrame = new QFrame( mainFrame, "detailsFrame" ); |
70 | QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); | 70 | QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); |
71 | richEdit = new QTextView( detailsFrame ); | 71 | richEdit = new QTextView( detailsFrame ); |
72 | QWhatsThis::add( richEdit, tr("The details of the current result") ); | 72 | QWhatsThis::add( richEdit, tr("The details of the current result") ); |
73 | richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 73 | richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); |
74 | detailsLayout->addWidget( richEdit ); | 74 | detailsLayout->addWidget( richEdit ); |
75 | 75 | ||
76 | buttonBox = new QHBox( mainFrame, "Button Box" ); | 76 | buttonBox = new QHBox( mainFrame, "Button Box" ); |
77 | 77 | ||
78 | _buttonCount = 0; | 78 | _buttonCount = 0; |
79 | 79 | ||
80 | mainLayout->addWidget( detailsFrame ); | 80 | mainLayout->addWidget( detailsFrame ); |
81 | mainLayout->addWidget( buttonBox ); | 81 | mainLayout->addWidget( buttonBox ); |
82 | detailsFrame->hide(); | 82 | detailsFrame->hide(); |
83 | buttonBox->hide(); | 83 | buttonBox->hide(); |
84 | 84 | ||
85 | searches.append( new AppLnkSearch( resultsList, tr("Applications") ) ); | 85 | searches.append( new AppLnkSearch( resultsList, tr("Applications") ) ); |
86 | searches.append( new DocLnkSearch( resultsList, tr("Documents") ) ); | 86 | searches.append( new DocLnkSearch( resultsList, tr("Documents") ) ); |
87 | searches.append( new TodoSearch( resultsList, tr("Todo List") ) ); | 87 | searches.append( new TodoSearch( resultsList, tr("Todo List") ) ); |
88 | searches.append( new DatebookSearch( resultsList, tr("Calendar") ) ); | 88 | searches.append( new DatebookSearch( resultsList, tr("Calendar") ) ); |
89 | searches.append( new AdressSearch( resultsList, tr("Contacts") ) ); | 89 | searches.append( new AdressSearch( resultsList, tr("Contacts") ) ); |
90 | 90 | ||
91 | setCentralWidget( mainFrame ); | 91 | setCentralWidget( mainFrame ); |
92 | 92 | ||
93 | popupTimer = new QTimer(); | 93 | popupTimer = new QTimer(); |
94 | searchTimer = new QTimer(); | 94 | searchTimer = new QTimer(); |
95 | 95 | ||
96 | connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); | 96 | connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); |
97 | connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); | 97 | connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); |
98 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); | 98 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); |
99 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); | 99 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); |
100 | 100 | ||
101 | signalMapper = new QSignalMapper( this ); | 101 | signalMapper = new QSignalMapper( this ); |
102 | 102 | ||
103 | connect(signalMapper, SIGNAL(mapped(int)), SLOT( slotAction(int) ) ); | 103 | connect(signalMapper, SIGNAL(mapped(int)), SLOT( slotAction(int) ) ); |
104 | 104 | ||
105 | makeMenu(); | 105 | makeMenu(); |
106 | 106 | ||
107 | Config cfg( "osearch", Config::User ); | 107 | Config cfg( "osearch", Config::User ); |
108 | cfg.setGroup( "search_settings" ); | 108 | cfg.setGroup( "search_settings" ); |
109 | actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); | 109 | actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); |
110 | actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); | 110 | actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); |
111 | // actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) ); | 111 | // actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) ); |
112 | } | 112 | } |
113 | 113 | ||
114 | void MainWindow::makeMenu() | 114 | void MainWindow::makeMenu() |
115 | { | 115 | { |
116 | QPEToolBar *toolBar = new QPEToolBar( this ); | 116 | QPEToolBar *toolBar = new QPEToolBar( this ); |
117 | QPEToolBar *searchBar = new QPEToolBar(this); | 117 | QPEToolBar *searchBar = new QPEToolBar(this); |
118 | QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); | 118 | QMenuBar *menuBar = new QMenuBar( toolBar ); |
119 | QPopupMenu *searchMenu = new QPopupMenu( menuBar ); | 119 | QPopupMenu *searchMenu = new QPopupMenu( menuBar ); |
120 | // QPopupMenu *viewMenu = new QPopupMenu( menuBar ); | 120 | // QPopupMenu *viewMenu = new QPopupMenu( menuBar ); |
121 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); | 121 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); |
122 | QPopupMenu *searchOptions = new QPopupMenu( cfgMenu ); | 122 | QPopupMenu *searchOptions = new QPopupMenu( cfgMenu ); |
123 | 123 | ||
124 | setToolBarsMovable( false ); | 124 | setToolBarsMovable( false ); |
125 | toolBar->setHorizontalStretchable( true ); | 125 | toolBar->setHorizontalStretchable( true ); |
126 | menuBar->insertItem( tr( "Search" ), searchMenu ); | 126 | menuBar->insertItem( tr( "Search" ), searchMenu ); |
127 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); | 127 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); |
128 | 128 | ||
129 | //SETTINGS MENU | 129 | //SETTINGS MENU |
130 | cfgMenu->insertItem( tr( "Search" ), searchOptions ); | 130 | cfgMenu->insertItem( tr( "Search" ), searchOptions ); |
131 | QPopupMenu *pop; | 131 | QPopupMenu *pop; |
132 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ | 132 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ |
133 | pop = s->popupMenu(); | 133 | pop = s->popupMenu(); |
134 | if (pop){ | 134 | if (pop){ |
135 | cfgMenu->insertItem( s->text(0), pop ); | 135 | cfgMenu->insertItem( s->text(0), pop ); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | 139 | ||
140 | //SEARCH | 140 | //SEARCH |
141 | SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); | 141 | SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); |
142 | SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); | 142 | SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); |
143 | // QWhatsThis::add( SearchAllAction, tr("Search everything...") ); | 143 | // QWhatsThis::add( SearchAllAction, tr("Search everything...") ); |
144 | connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); | 144 | connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); |
145 | SearchAllAction->addTo( searchMenu ); | 145 | SearchAllAction->addTo( searchMenu ); |
146 | searchMenu->insertItem( tr( "Options" ), searchOptions ); | 146 | searchMenu->insertItem( tr( "Options" ), searchOptions ); |
147 | 147 | ||
148 | //SEARCH OPTIONS | 148 | //SEARCH OPTIONS |
149 | //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true ); | 149 | //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true ); |
150 | //actionWholeWordsOnly->addTo( searchOptions ); | 150 | //actionWholeWordsOnly->addTo( searchOptions ); |
151 | actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); | 151 | actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); |
152 | actionCaseSensitiv->addTo( searchOptions ); | 152 | actionCaseSensitiv->addTo( searchOptions ); |
153 | actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); | 153 | actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); |
154 | actionWildcards->addTo( searchOptions ); | 154 | actionWildcards->addTo( searchOptions ); |
155 | 155 | ||
156 | //SEARCH BAR | 156 | //SEARCH BAR |
157 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 157 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
158 | QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); | 158 | QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); |
159 | QWhatsThis::add( searchEdit, tr("Enter your search terms here") ); | 159 | QWhatsThis::add( searchEdit, tr("Enter your search terms here") ); |
160 | searchEdit->setFocus(); | 160 | searchEdit->setFocus(); |
161 | searchBar->setHorizontalStretchable( TRUE ); | 161 | searchBar->setHorizontalStretchable( TRUE ); |
162 | searchBar->setStretchableWidget( searchEdit ); | 162 | searchBar->setStretchableWidget( searchEdit ); |
163 | SearchAllAction->addTo( searchBar ); | 163 | SearchAllAction->addTo( searchBar ); |
164 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 164 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
165 | this, SLOT( setSearch( const QString & ) ) ); | 165 | this, SLOT( setSearch( const QString & ) ) ); |
166 | 166 | ||
167 | } | 167 | } |
168 | 168 | ||
169 | MainWindow::~MainWindow() | 169 | MainWindow::~MainWindow() |
170 | { | 170 | { |
171 | Config cfg( "osearch", Config::User ); | 171 | Config cfg( "osearch", Config::User ); |
172 | cfg.setGroup( "search_settings" ); | 172 | cfg.setGroup( "search_settings" ); |
173 | cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() ); | 173 | cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() ); |
174 | cfg.writeEntry( "wildcards", actionWildcards->isOn() ); | 174 | cfg.writeEntry( "wildcards", actionWildcards->isOn() ); |
175 | //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() ); | 175 | //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() ); |
176 | } | 176 | } |
177 | 177 | ||
178 | void MainWindow::setCurrent(QListViewItem *item) | 178 | void MainWindow::setCurrent(QListViewItem *item) |
179 | { | 179 | { |
180 | if (!item) return; | 180 | if (!item) return; |
181 | _currentItem = (OListViewItem*)item; | 181 | _currentItem = (OListViewItem*)item; |
182 | //_currentItem = dynamic_cast<OListViewItem*>(item); | 182 | //_currentItem = dynamic_cast<OListViewItem*>(item); |
183 | if (_currentItem->rtti() == OListViewItem::Result){ | 183 | if (_currentItem->rtti() == OListViewItem::Result){ |
184 | ResultItem *res = (ResultItem*)item; | 184 | ResultItem *res = (ResultItem*)item; |
185 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | 185 | // ResultItem *res = dynamic_cast<ResultItem*>(item); |
186 | richEdit->setText( res->toRichText() ); | 186 | richEdit->setText( res->toRichText() ); |
187 | QIntDict<QString> acts = res->actions(); | 187 | QIntDict<QString> acts = res->actions(); |
188 | QButton *button; | 188 | QButton *button; |
189 | for (uint i = 0; i < acts.count(); i++){ | 189 | for (uint i = 0; i < acts.count(); i++){ |
190 | button = buttonMap[i]; | 190 | button = buttonMap[i]; |
191 | if (!button) { | 191 | if (!button) { |
192 | qWarning(" no button for %s", (*acts[i]).latin1() ); | 192 | qWarning(" no button for %s", (*acts[i]).latin1() ); |
193 | button = new QPushButton( buttonBox ); | 193 | button = new QPushButton( buttonBox ); |
194 | buttonMap.insert( i, button ); | 194 | buttonMap.insert( i, button ); |
195 | signalMapper->setMapping(button, i ); | 195 | signalMapper->setMapping(button, i ); |
196 | connect(button, SIGNAL(clicked() ), signalMapper, SLOT(map() ) ); | 196 | connect(button, SIGNAL(clicked() ), signalMapper, SLOT(map() ) ); |
197 | } | 197 | } |
198 | button->setText( *acts[i] ); | 198 | button->setText( *acts[i] ); |
199 | button->show(); | 199 | button->show(); |
200 | } | 200 | } |
201 | for (uint i = acts.count(); i < _buttonCount; i++){ | 201 | for (uint i = acts.count(); i < _buttonCount; i++){ |
202 | button = buttonMap[i]; | 202 | button = buttonMap[i]; |
203 | if (button) button->hide(); | 203 | if (button) button->hide(); |
204 | } | 204 | } |
205 | _buttonCount = acts.count(); | 205 | _buttonCount = acts.count(); |
206 | detailsFrame->show(); | 206 | detailsFrame->show(); |
207 | buttonBox->show(); | 207 | buttonBox->show(); |
208 | 208 | ||
209 | }else { | 209 | }else { |
210 | detailsFrame->hide(); | 210 | detailsFrame->hide(); |
211 | buttonBox->hide(); | 211 | buttonBox->hide(); |
212 | } | 212 | } |
213 | popupTimer->start( 300, true ); | 213 | popupTimer->start( 300, true ); |
214 | } | 214 | } |
215 | 215 | ||
216 | void MainWindow::stopTimer(QListViewItem*) | 216 | void MainWindow::stopTimer(QListViewItem*) |
217 | { | 217 | { |
218 | popupTimer->stop(); | 218 | popupTimer->stop(); |
219 | } | 219 | } |
220 | 220 | ||
221 | void MainWindow::showPopup() | 221 | void MainWindow::showPopup() |
222 | { | 222 | { |
223 | popupTimer->stop(); | 223 | popupTimer->stop(); |
224 | if (!_currentItem) return; | 224 | if (!_currentItem) return; |
225 | QPopupMenu *pop = _currentItem->popupMenu(); | 225 | QPopupMenu *pop = _currentItem->popupMenu(); |
226 | if (pop) pop->popup( QCursor::pos() ); | 226 | if (pop) pop->popup( QCursor::pos() ); |
227 | } | 227 | } |
228 | 228 | ||
229 | void MainWindow::setSearch( const QString &key ) | 229 | void MainWindow::setSearch( const QString &key ) |
230 | { | 230 | { |
231 | searchTimer->stop(); | 231 | searchTimer->stop(); |
232 | _searchString = key; | 232 | _searchString = key; |
233 | searchTimer->start( 300 ); | 233 | searchTimer->start( 300 ); |
234 | } | 234 | } |
235 | 235 | ||
236 | void MainWindow::searchStringChanged() | 236 | void MainWindow::searchStringChanged() |
237 | { | 237 | { |
238 | #ifdef NEW_OWAIT | 238 | #ifdef NEW_OWAIT |
239 | OWait("setting search string"); | 239 | OWait("setting search string"); |
240 | #endif | 240 | #endif |
241 | searchTimer->stop(); | 241 | searchTimer->stop(); |
242 | QString ss = _searchString; | 242 | QString ss = _searchString; |
243 | //ss = Global::stringQuote( _searchString ); | 243 | //ss = Global::stringQuote( _searchString ); |
244 | //if (actionWholeWordsOnly->isOn()) | 244 | //if (actionWholeWordsOnly->isOn()) |
245 | // ss = "\\s"+_searchString+"\\s"; | 245 | // ss = "\\s"+_searchString+"\\s"; |
246 | //qDebug(" set searchString >%s<",ss.latin1()); | 246 | //qDebug(" set searchString >%s<",ss.latin1()); |
247 | QRegExp re( ss ); | 247 | QRegExp re( ss ); |
248 | re.setCaseSensitive( actionCaseSensitiv->isOn() ); | 248 | re.setCaseSensitive( actionCaseSensitiv->isOn() ); |
249 | re.setWildcard( actionWildcards->isOn() ); | 249 | re.setWildcard( actionWildcards->isOn() ); |
250 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) | 250 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) |
251 | s->setSearch( re ); | 251 | s->setSearch( re ); |
252 | } | 252 | } |
253 | 253 | ||
254 | void MainWindow::searchAll() | 254 | void MainWindow::searchAll() |
255 | { | 255 | { |
256 | #ifdef NEW_OWAIT | 256 | #ifdef NEW_OWAIT |
257 | OWait("searching..."); | 257 | OWait("searching..."); |
258 | #endif | 258 | #endif |
259 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ | 259 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ |
260 | s->doSearch(); | 260 | s->doSearch(); |
261 | //resultsList->repaint(); | 261 | //resultsList->repaint(); |
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
265 | void MainWindow::slotAction( int act ) | 265 | void MainWindow::slotAction( int act ) |
266 | { | 266 | { |
267 | if ( _currentItem && _currentItem->rtti() == OListViewItem::Result){ | 267 | if ( _currentItem && _currentItem->rtti() == OListViewItem::Result){ |
268 | ResultItem *res = (ResultItem*)_currentItem; | 268 | ResultItem *res = (ResultItem*)_currentItem; |
269 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | 269 | // ResultItem *res = dynamic_cast<ResultItem*>(item); |
270 | res->action(act); | 270 | res->action(act); |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | void MainWindow::optionChanged(int ) | 274 | void MainWindow::optionChanged(int ) |
275 | { | 275 | { |
276 | searchStringChanged(); | 276 | searchStringChanged(); |
277 | } | 277 | } |
diff --git a/noncore/applets/brightnessapplet/.cvsignore b/noncore/applets/brightnessapplet/.cvsignore new file mode 100644 index 0000000..51d12e8 --- a/dev/null +++ b/noncore/applets/brightnessapplet/.cvsignore | |||
@@ -0,0 +1,4 @@ | |||
1 | Makefile* | ||
2 | advancedconfigbase.cpp | ||
3 | advancedconfigbase.h | ||
4 | moc_* | ||
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index bf00102..25f9910 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp | |||
@@ -1,325 +1,325 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "mainwindow.h" | 29 | #include "mainwindow.h" |
30 | #include "cbinfo.h" | 30 | #include "cbinfo.h" |
31 | #include "configuration.h" | 31 | #include "configuration.h" |
32 | #include "password.h" | 32 | #include "password.h" |
33 | #include "checkbook.h" | 33 | #include "checkbook.h" |
34 | #include "listedit.h" | 34 | #include "listedit.h" |
35 | 35 | ||
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/global.h> | 37 | #include <qpe/global.h> |
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | #include <qpe/qpemenubar.h> | 39 | #include <qpe/qpemenubar.h> |
40 | #include <qpe/qpemessagebox.h> | 40 | #include <qpe/qpemessagebox.h> |
41 | #include <qpe/qpetoolbar.h> | 41 | #include <qpe/qpetoolbar.h> |
42 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
43 | 43 | ||
44 | #include <qaction.h> | 44 | #include <qaction.h> |
45 | #include <qcheckbox.h> | 45 | #include <qcheckbox.h> |
46 | #include <qdir.h> | 46 | #include <qdir.h> |
47 | #include <qlineedit.h> | 47 | #include <qlineedit.h> |
48 | #include <qwhatsthis.h> | 48 | #include <qwhatsthis.h> |
49 | 49 | ||
50 | 50 | ||
51 | MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) | 51 | MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) |
52 | : QMainWindow( parent, name, fl || WStyle_ContextHelp ) | 52 | : QMainWindow( parent, name, fl || WStyle_ContextHelp ) |
53 | { | 53 | { |
54 | setCaption( tr( "Checkbook" ) ); | 54 | setCaption( tr( "Checkbook" ) ); |
55 | 55 | ||
56 | cbDir = Global::applicationFileName( "checkbook", "" ); | 56 | cbDir = Global::applicationFileName( "checkbook", "" ); |
57 | lockIcon = Resource::loadPixmap( "locked" ); | 57 | lockIcon = Resource::loadPixmap( "locked" ); |
58 | 58 | ||
59 | // Load configuration options | 59 | // Load configuration options |
60 | Config config( "checkbook" ); | 60 | Config config( "checkbook" ); |
61 | _cfg.readConfig( config ); | 61 | _cfg.readConfig( config ); |
62 | 62 | ||
63 | 63 | ||
64 | // Build menu and tool bars | 64 | // Build menu and tool bars |
65 | setToolBarsMovable( FALSE ); | 65 | setToolBarsMovable( FALSE ); |
66 | 66 | ||
67 | QPEToolBar *bar = new QPEToolBar( this ); | 67 | QPEToolBar *bar = new QPEToolBar( this ); |
68 | bar->setHorizontalStretchable( TRUE ); | 68 | bar->setHorizontalStretchable( TRUE ); |
69 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 69 | QMenuBar *mb = new QMenuBar( bar ); |
70 | mb->setMargin( 0 ); | 70 | mb->setMargin( 0 ); |
71 | QPopupMenu *popup = new QPopupMenu( this ); | 71 | QPopupMenu *popup = new QPopupMenu( this ); |
72 | 72 | ||
73 | bar = new QPEToolBar( this ); | 73 | bar = new QPEToolBar( this ); |
74 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 74 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
75 | a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); | 75 | a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); |
76 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); | 76 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); |
77 | a->addTo( popup ); | 77 | a->addTo( popup ); |
78 | a->addTo( bar ); | 78 | a->addTo( bar ); |
79 | 79 | ||
80 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 80 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
81 | 0, this, 0 ); | 81 | 0, this, 0 ); |
82 | actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); | 82 | actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); |
83 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); | 83 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); |
84 | actionOpen->addTo( popup ); | 84 | actionOpen->addTo( popup ); |
85 | actionOpen->addTo( bar ); | 85 | actionOpen->addTo( bar ); |
86 | 86 | ||
87 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 87 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
88 | 0, this, 0 ); | 88 | 0, this, 0 ); |
89 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); | 89 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); |
90 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); | 90 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); |
91 | actionDelete->addTo( popup ); | 91 | actionDelete->addTo( popup ); |
92 | actionDelete->addTo( bar ); | 92 | actionDelete->addTo( bar ); |
93 | 93 | ||
94 | popup->insertSeparator(); | 94 | popup->insertSeparator(); |
95 | 95 | ||
96 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 96 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
97 | a->setWhatsThis( tr( "Click here to configure this app." ) ); | 97 | a->setWhatsThis( tr( "Click here to configure this app." ) ); |
98 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); | 98 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); |
99 | a->addTo( popup ); | 99 | a->addTo( popup ); |
100 | a->addTo( bar ); | 100 | a->addTo( bar ); |
101 | 101 | ||
102 | mb->insertItem( tr( "Checkbook" ), popup ); | 102 | mb->insertItem( tr( "Checkbook" ), popup ); |
103 | 103 | ||
104 | // Load Checkbook selection list | 104 | // Load Checkbook selection list |
105 | checkbooks = new CBInfoList(); | 105 | checkbooks = new CBInfoList(); |
106 | 106 | ||
107 | QDir checkdir( cbDir ); | 107 | QDir checkdir( cbDir ); |
108 | if (checkdir.exists() == true) | 108 | if (checkdir.exists() == true) |
109 | { | 109 | { |
110 | QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, | 110 | QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, |
111 | QDir::Time ); | 111 | QDir::Time ); |
112 | CBInfo *cb = 0x0; | 112 | CBInfo *cb = 0x0; |
113 | QString filename; | 113 | QString filename; |
114 | 114 | ||
115 | for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) | 115 | for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) |
116 | { | 116 | { |
117 | filename = cbDir; | 117 | filename = cbDir; |
118 | filename.append( (*it) ); | 118 | filename.append( (*it) ); |
119 | 119 | ||
120 | cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); | 120 | cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); |
121 | checkbooks->inSort( cb ); | 121 | checkbooks->inSort( cb ); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | // Build Checkbook selection list control | 125 | // Build Checkbook selection list control |
126 | cbList = 0x0; | 126 | cbList = 0x0; |
127 | buildList(); | 127 | buildList(); |
128 | 128 | ||
129 | // open last book? | 129 | // open last book? |
130 | if( _cfg.isOpenLastBook() ) { | 130 | if( _cfg.isOpenLastBook() ) { |
131 | this->show(); | 131 | this->show(); |
132 | this->showMaximized(); | 132 | this->showMaximized(); |
133 | QListViewItem *itm=cbList->firstChild(); | 133 | QListViewItem *itm=cbList->firstChild(); |
134 | while( itm ) { | 134 | while( itm ) { |
135 | if( itm->text(posName)==_cfg.getLastBook() ) { | 135 | if( itm->text(posName)==_cfg.getLastBook() ) { |
136 | openBook( itm ); | 136 | openBook( itm ); |
137 | break; | 137 | break; |
138 | } | 138 | } |
139 | itm=itm->nextSibling(); | 139 | itm=itm->nextSibling(); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | // --- ~MainWindow ------------------------------------------------------------ | 145 | // --- ~MainWindow ------------------------------------------------------------ |
146 | MainWindow::~MainWindow() | 146 | MainWindow::~MainWindow() |
147 | { | 147 | { |
148 | writeConfig(); | 148 | writeConfig(); |
149 | } | 149 | } |
150 | 150 | ||
151 | 151 | ||
152 | // --- buildList -------------------------------------------------------------- | 152 | // --- buildList -------------------------------------------------------------- |
153 | void MainWindow::buildList() | 153 | void MainWindow::buildList() |
154 | { | 154 | { |
155 | if ( cbList ) | 155 | if ( cbList ) |
156 | delete cbList; | 156 | delete cbList; |
157 | 157 | ||
158 | cbList = new QListView( this ); | 158 | cbList = new QListView( this ); |
159 | QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); | 159 | QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); |
160 | 160 | ||
161 | if ( _cfg.getShowLocks() ) | 161 | if ( _cfg.getShowLocks() ) |
162 | { | 162 | { |
163 | cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); | 163 | cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); |
164 | posName = 1; | 164 | posName = 1; |
165 | } | 165 | } |
166 | else | 166 | else |
167 | { | 167 | { |
168 | posName = 0; | 168 | posName = 0; |
169 | } | 169 | } |
170 | cbList->addColumn( tr( "Checkbook Name" ) ); | 170 | cbList->addColumn( tr( "Checkbook Name" ) ); |
171 | if ( _cfg.getShowBalances() ) | 171 | if ( _cfg.getShowBalances() ) |
172 | { | 172 | { |
173 | int colnum = cbList->addColumn( tr( "Balance" ) ); | 173 | int colnum = cbList->addColumn( tr( "Balance" ) ); |
174 | cbList->setColumnAlignment( colnum, Qt::AlignRight ); | 174 | cbList->setColumnAlignment( colnum, Qt::AlignRight ); |
175 | } | 175 | } |
176 | cbList->setAllColumnsShowFocus( TRUE ); | 176 | cbList->setAllColumnsShowFocus( TRUE ); |
177 | cbList->setSorting( posName ); | 177 | cbList->setSorting( posName ); |
178 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); | 178 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); |
179 | connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 179 | connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
180 | this, SLOT( slotEdit() ) ); | 180 | this, SLOT( slotEdit() ) ); |
181 | setCentralWidget( cbList ); | 181 | setCentralWidget( cbList ); |
182 | 182 | ||
183 | for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) | 183 | for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) |
184 | { | 184 | { |
185 | addCheckbook( cb ); | 185 | addCheckbook( cb ); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | void MainWindow::addCheckbook( CBInfo *cb ) | 189 | void MainWindow::addCheckbook( CBInfo *cb ) |
190 | { | 190 | { |
191 | QListViewItem *lvi = new QListViewItem( cbList ); | 191 | QListViewItem *lvi = new QListViewItem( cbList ); |
192 | if ( _cfg.getShowLocks() && !cb->password().isNull() ) | 192 | if ( _cfg.getShowLocks() && !cb->password().isNull() ) |
193 | { | 193 | { |
194 | lvi->setPixmap( 0, lockIcon ); | 194 | lvi->setPixmap( 0, lockIcon ); |
195 | } | 195 | } |
196 | lvi->setText( posName, cb->name() ); | 196 | lvi->setText( posName, cb->name() ); |
197 | if ( _cfg.getShowBalances() ) | 197 | if ( _cfg.getShowBalances() ) |
198 | { | 198 | { |
199 | QString balance; | 199 | QString balance; |
200 | balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); | 200 | balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); |
201 | lvi->setText( posName + 1, balance ); | 201 | lvi->setText( posName + 1, balance ); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | void MainWindow::buildFilename( const QString &name ) | 205 | void MainWindow::buildFilename( const QString &name ) |
206 | { | 206 | { |
207 | tempFilename = cbDir; | 207 | tempFilename = cbDir; |
208 | tempFilename.append( name ); | 208 | tempFilename.append( name ); |
209 | tempFilename.append( ".qcb" ); | 209 | tempFilename.append( ".qcb" ); |
210 | } | 210 | } |
211 | 211 | ||
212 | void MainWindow::slotNew() | 212 | void MainWindow::slotNew() |
213 | { | 213 | { |
214 | CBInfo *cb = new CBInfo(); | 214 | CBInfo *cb = new CBInfo(); |
215 | 215 | ||
216 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); | 216 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); |
217 | currcb->showMaximized(); | 217 | currcb->showMaximized(); |
218 | if ( currcb->exec() == QDialog::Accepted ) | 218 | if ( currcb->exec() == QDialog::Accepted ) |
219 | { | 219 | { |
220 | // Save new checkbook | 220 | // Save new checkbook |
221 | buildFilename( cb->name() ); | 221 | buildFilename( cb->name() ); |
222 | _cfg.setLastBook( cb->name() ); | 222 | _cfg.setLastBook( cb->name() ); |
223 | cb->setFilename( tempFilename ); | 223 | cb->setFilename( tempFilename ); |
224 | cb->write(); | 224 | cb->write(); |
225 | 225 | ||
226 | // Add to listbox | 226 | // Add to listbox |
227 | checkbooks->inSort( cb ); | 227 | checkbooks->inSort( cb ); |
228 | addCheckbook( cb ); | 228 | addCheckbook( cb ); |
229 | } | 229 | } |
230 | delete currcb; | 230 | delete currcb; |
231 | } | 231 | } |
232 | 232 | ||
233 | // --- slotEdit --------------------------------------------------------------- | 233 | // --- slotEdit --------------------------------------------------------------- |
234 | void MainWindow::slotEdit() | 234 | void MainWindow::slotEdit() |
235 | { | 235 | { |
236 | // get name and open it | 236 | // get name and open it |
237 | QListViewItem *curritem = cbList->currentItem(); | 237 | QListViewItem *curritem = cbList->currentItem(); |
238 | if ( !curritem ) | 238 | if ( !curritem ) |
239 | return; | 239 | return; |
240 | openBook( curritem ); | 240 | openBook( curritem ); |
241 | } | 241 | } |
242 | 242 | ||
243 | 243 | ||
244 | // --- openBook --------------------------------------------------------------- | 244 | // --- openBook --------------------------------------------------------------- |
245 | void MainWindow::openBook(QListViewItem *curritem) | 245 | void MainWindow::openBook(QListViewItem *curritem) |
246 | { | 246 | { |
247 | // find book in List | 247 | // find book in List |
248 | QString currname=curritem->text(posName); | 248 | QString currname=curritem->text(posName); |
249 | CBInfo *cb = checkbooks->first(); | 249 | CBInfo *cb = checkbooks->first(); |
250 | while ( cb ) { | 250 | while ( cb ) { |
251 | if ( cb->name() == currname ) | 251 | if ( cb->name() == currname ) |
252 | break; | 252 | break; |
253 | cb = checkbooks->next(); | 253 | cb = checkbooks->next(); |
254 | } | 254 | } |
255 | if ( !cb ) return; | 255 | if ( !cb ) return; |
256 | 256 | ||
257 | // | 257 | // |
258 | buildFilename( currname ); | 258 | buildFilename( currname ); |
259 | float currbalance = cb->balance(); | 259 | float currbalance = cb->balance(); |
260 | bool currlock = !cb->password().isNull(); | 260 | bool currlock = !cb->password().isNull(); |
261 | 261 | ||
262 | if ( currlock ) | 262 | if ( currlock ) |
263 | { | 263 | { |
264 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | 264 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); |
265 | if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) | 265 | if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) |
266 | { | 266 | { |
267 | delete pw; | 267 | delete pw; |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | delete pw; | 270 | delete pw; |
271 | } | 271 | } |
272 | 272 | ||
273 | _cfg.setLastBook( currname ); | 273 | _cfg.setLastBook( currname ); |
274 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); | 274 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); |
275 | currcb->showMaximized(); | 275 | currcb->showMaximized(); |
276 | if ( currcb->exec() == QDialog::Accepted ) | 276 | if ( currcb->exec() == QDialog::Accepted ) |
277 | { | 277 | { |
278 | QString newname = cb->name(); | 278 | QString newname = cb->name(); |
279 | if ( currname != newname ) | 279 | if ( currname != newname ) |
280 | { | 280 | { |
281 | // Update name if changed | 281 | // Update name if changed |
282 | if( curritem ) { | 282 | if( curritem ) { |
283 | curritem->setText( posName, newname ); | 283 | curritem->setText( posName, newname ); |
284 | cbList->sort(); | 284 | cbList->sort(); |
285 | } | 285 | } |
286 | _cfg.setLastBook( newname ); | 286 | _cfg.setLastBook( newname ); |
287 | 287 | ||
288 | // Remove old file | 288 | // Remove old file |
289 | QFile f( tempFilename ); | 289 | QFile f( tempFilename ); |
290 | if ( f.exists() ) | 290 | if ( f.exists() ) |
291 | f.remove(); | 291 | f.remove(); |
292 | 292 | ||
293 | // Get new filename | 293 | // Get new filename |
294 | buildFilename( newname ); | 294 | buildFilename( newname ); |
295 | cb->setFilename( tempFilename ); | 295 | cb->setFilename( tempFilename ); |
296 | } | 296 | } |
297 | 297 | ||
298 | cb->write(); | 298 | cb->write(); |
299 | 299 | ||
300 | // Update lock if changed | 300 | // Update lock if changed |
301 | if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) | 301 | if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) |
302 | { | 302 | { |
303 | if ( !cb->password().isNull() ) | 303 | if ( !cb->password().isNull() ) |
304 | curritem->setPixmap( 0, lockIcon ); | 304 | curritem->setPixmap( 0, lockIcon ); |
305 | else | 305 | else |
306 | curritem->setPixmap( 0, nullIcon ); | 306 | curritem->setPixmap( 0, nullIcon ); |
307 | } | 307 | } |
308 | 308 | ||
309 | // Update balance if changed | 309 | // Update balance if changed |
310 | if ( _cfg.getShowBalances() && cb->balance() != currbalance ) | 310 | if ( _cfg.getShowBalances() && cb->balance() != currbalance ) |
311 | { | 311 | { |
312 | QString tempstr; | 312 | QString tempstr; |
313 | tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); | 313 | tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); |
314 | curritem->setText( posName + 1, tempstr ); | 314 | curritem->setText( posName + 1, tempstr ); |
315 | } | 315 | } |
316 | 316 | ||
317 | // write config, if needed | 317 | // write config, if needed |
318 | if( _cfg.isDirty() ) { | 318 | if( _cfg.isDirty() ) { |
319 | Config config("checkbook"); | 319 | Config config("checkbook"); |
320 | _cfg.writeConfig( config ); | 320 | _cfg.writeConfig( config ); |
321 | } | 321 | } |
322 | } | 322 | } |
323 | delete currcb; | 323 | delete currcb; |
324 | } | 324 | } |
325 | 325 | ||
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp index 58538af..4fe45ba 100644 --- a/noncore/apps/confedit/mainwindow.cpp +++ b/noncore/apps/confedit/mainwindow.cpp | |||
@@ -1,204 +1,198 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
11 | 11 | ||
12 | 12 | ||
13 | #include "mainwindow.h" | 13 | #include "mainwindow.h" |
14 | 14 | ||
15 | #include <opie2/omenubar.h> | ||
16 | #include <opie2/omessagebox.h> | ||
17 | #include <opie2/oresource.h> | ||
18 | #include <opie2/oconfig.h> | ||
19 | #include <opie2/otoolbar.h> | ||
20 | #include <opie2/oapplication.h> | ||
21 | #include <qaction.h> | 15 | #include <qaction.h> |
22 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
23 | #include <qpopupmenu.h> | 17 | #include <qpopupmenu.h> |
24 | #include <qtoolbutton.h> | 18 | #include <qtoolbutton.h> |
25 | #include <qstring.h> | 19 | #include <qstring.h> |
26 | #include <qlabel.h> | 20 | #include <qlabel.h> |
27 | #include <qfile.h> | 21 | #include <qfile.h> |
28 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
29 | #include <qlayout.h> | 23 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 24 | #include <qlineedit.h> |
31 | #include <qcursor.h> | 25 | #include <qcursor.h> |
32 | 26 | ||
33 | #include "listviewconfdir.h" | 27 | #include "listviewconfdir.h" |
34 | #include "listviewitemconf.h" | 28 | #include "listviewitemconf.h" |
35 | #include "listviewitemconfigentry.h" | 29 | #include "listviewitemconfigentry.h" |
36 | 30 | ||
37 | 31 | ||
38 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | 32 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : |
39 | QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) | 33 | QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) |
40 | { | 34 | { |
41 | setCaption( tr("Conf File Editor") ); | 35 | setCaption( tr("Conf File Editor") ); |
42 | 36 | ||
43 | //setBaseSize( qApp->globalStrut() ); | 37 | //setBaseSize( qApp->globalStrut() ); |
44 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); | 38 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); |
45 | 39 | ||
46 | mainLayout = new QVBoxLayout( this ); | 40 | mainLayout = new QVBoxLayout( this ); |
47 | mainLayout->setSpacing( 0 ); | 41 | mainLayout->setSpacing( 0 ); |
48 | mainLayout->setMargin( 0 ); | 42 | mainLayout->setMargin( 0 ); |
49 | 43 | ||
50 | 44 | ||
51 | qDebug("creating settingList"); | 45 | qDebug("creating settingList"); |
52 | settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist"); | 46 | settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist"); |
53 | settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); | 47 | settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); |
54 | mainLayout->addWidget( settingList, 0); | 48 | mainLayout->addWidget( settingList, 0); |
55 | 49 | ||
56 | qDebug("creating editor"); | 50 | qDebug("creating editor"); |
57 | editor = new EditWidget(this); | 51 | editor = new EditWidget(this); |
58 | editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) ); | 52 | editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) ); |
59 | mainLayout->addWidget( editor, 1 ); | 53 | mainLayout->addWidget( editor, 1 ); |
60 | editor->layoutType( ListViewItemConf::File ); | 54 | editor->layoutType( ListViewItemConf::File ); |
61 | 55 | ||
62 | makeMenu(); | 56 | makeMenu(); |
63 | 57 | ||
64 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), | 58 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), |
65 | this, SLOT(setCurrent(QListViewItem*))); | 59 | this, SLOT(setCurrent(QListViewItem*))); |
66 | connect( settingList, SIGNAL( clicked( QListViewItem* ) ), | 60 | connect( settingList, SIGNAL( clicked( QListViewItem* ) ), |
67 | this, SLOT( stopTimer( QListViewItem* ) ) ); | 61 | this, SLOT( stopTimer( QListViewItem* ) ) ); |
68 | 62 | ||
69 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), | 63 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), |
70 | SLOT( groupChanged(const QString&) ) ); | 64 | SLOT( groupChanged(const QString&) ) ); |
71 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), | 65 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), |
72 | SLOT( keyChanged(const QString&) ) ); | 66 | SLOT( keyChanged(const QString&) ) ); |
73 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), | 67 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), |
74 | SLOT( valueChanged(const QString&) ) ); | 68 | SLOT( valueChanged(const QString&) ) ); |
75 | 69 | ||
76 | setCurrent(0); | 70 | setCurrent(0); |
77 | editor->layoutType(EditWidget::File); | 71 | editor->layoutType(EditWidget::File); |
78 | } | 72 | } |
79 | 73 | ||
80 | void MainWindow::makeMenu() | 74 | void MainWindow::makeMenu() |
81 | { | 75 | { |
82 | popupTimer = new QTimer(this); | 76 | popupTimer = new QTimer(this); |
83 | popupMenuFile = new QPopupMenu(this); | 77 | popupMenuFile = new QPopupMenu(this); |
84 | popupMenuEntry = new QPopupMenu(this); | 78 | popupMenuEntry = new QPopupMenu(this); |
85 | 79 | ||
86 | popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); | 80 | popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); |
87 | popupActionSave->addTo( popupMenuFile ); | 81 | popupActionSave->addTo( popupMenuFile ); |
88 | // popupActionSave->addTo( popupMenuEntry ); | 82 | // popupActionSave->addTo( popupMenuEntry ); |
89 | connect( popupActionSave, SIGNAL( activated() ), | 83 | connect( popupActionSave, SIGNAL( activated() ), |
90 | this , SLOT( saveConfFile() ) ); | 84 | this , SLOT( saveConfFile() ) ); |
91 | 85 | ||
92 | popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); | 86 | popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); |
93 | popupActionRevert->addTo( popupMenuFile ); | 87 | popupActionRevert->addTo( popupMenuFile ); |
94 | popupActionRevert->addTo( popupMenuEntry ); | 88 | popupActionRevert->addTo( popupMenuEntry ); |
95 | connect( popupActionRevert, SIGNAL( activated() ), | 89 | connect( popupActionRevert, SIGNAL( activated() ), |
96 | this , SLOT( revertConfFile() ) ); | 90 | this , SLOT( revertConfFile() ) ); |
97 | 91 | ||
98 | popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); | 92 | popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); |
99 | popupActionDelete->addTo( popupMenuFile ); | 93 | popupActionDelete->addTo( popupMenuFile ); |
100 | popupActionDelete->addTo( popupMenuEntry ); | 94 | popupActionDelete->addTo( popupMenuEntry ); |
101 | connect( popupActionDelete, SIGNAL( activated() ), | 95 | connect( popupActionDelete, SIGNAL( activated() ), |
102 | this , SLOT( removeConfFile() ) ); | 96 | this , SLOT( removeConfFile() ) ); |
103 | 97 | ||
104 | connect( popupTimer, SIGNAL(timeout()), | 98 | connect( popupTimer, SIGNAL(timeout()), |
105 | this, SLOT(showPopup()) ); | 99 | this, SLOT(showPopup()) ); |
106 | } | 100 | } |
107 | 101 | ||
108 | MainWindow::~MainWindow() | 102 | MainWindow::~MainWindow() |
109 | { | 103 | { |
110 | } | 104 | } |
111 | 105 | ||
112 | 106 | ||
113 | 107 | ||
114 | void MainWindow::setCurrent(QListViewItem *item) | 108 | void MainWindow::setCurrent(QListViewItem *item) |
115 | { | 109 | { |
116 | //qDebug("MainWindow::setCurrent"); | 110 | //qDebug("MainWindow::setCurrent"); |
117 | if (!item) return; | 111 | if (!item) return; |
118 | _item = (ListViewItemConf*) item; | 112 | _item = (ListViewItemConf*) item; |
119 | if (!_item) return; | 113 | if (!_item) return; |
120 | popupTimer->start( 750, true ); | 114 | popupTimer->start( 750, true ); |
121 | if (_item->getType() == ListViewItemConf::File) | 115 | if (_item->getType() == ListViewItemConf::File) |
122 | { | 116 | { |
123 | editor->layoutType(EditWidget::File); | 117 | editor->layoutType(EditWidget::File); |
124 | _currentItem=0; | 118 | _currentItem=0; |
125 | _fileItem = (ListViewItemConfFile*)item; | 119 | _fileItem = (ListViewItemConfFile*)item; |
126 | return; | 120 | return; |
127 | } | 121 | } |
128 | _fileItem = 0; | 122 | _fileItem = 0; |
129 | _currentItem = (ListViewItemConfigEntry*)item; | 123 | _currentItem = (ListViewItemConfigEntry*)item; |
130 | if (!_currentItem) return; | 124 | if (!_currentItem) return; |
131 | QString file = _currentItem->getFile(); | 125 | QString file = _currentItem->getFile(); |
132 | QString group = _currentItem->getGroup(); | 126 | QString group = _currentItem->getGroup(); |
133 | QString key = _currentItem->getKey(); | 127 | QString key = _currentItem->getKey(); |
134 | QString val = _currentItem->getValue(); | 128 | QString val = _currentItem->getValue(); |
135 | editor->TextFileName->setText(file); | 129 | editor->TextFileName->setText(file); |
136 | editor->LineEditGroup->setText(group); | 130 | editor->LineEditGroup->setText(group); |
137 | if (!key.isEmpty()) | 131 | if (!key.isEmpty()) |
138 | { | 132 | { |
139 | editor->layoutType(EditWidget::Entry); | 133 | editor->layoutType(EditWidget::Entry); |
140 | editor->LineEditKey->setText(key); | 134 | editor->LineEditKey->setText(key); |
141 | editor->LineEditValue->setText(val); | 135 | editor->LineEditValue->setText(val); |
142 | }else{ | 136 | }else{ |
143 | editor->layoutType(EditWidget::Group); | 137 | editor->layoutType(EditWidget::Group); |
144 | } | 138 | } |
145 | } | 139 | } |
146 | 140 | ||
147 | 141 | ||
148 | void MainWindow::groupChanged(const QString &g) | 142 | void MainWindow::groupChanged(const QString &g) |
149 | { | 143 | { |
150 | if (!_currentItem) return; | 144 | if (!_currentItem) return; |
151 | _currentItem->setGroup(g); | 145 | _currentItem->setGroup(g); |
152 | } | 146 | } |
153 | 147 | ||
154 | void MainWindow::keyChanged(const QString &k) | 148 | void MainWindow::keyChanged(const QString &k) |
155 | { | 149 | { |
156 | if (!_currentItem) return; | 150 | if (!_currentItem) return; |
157 | _currentItem->keyChanged(k); | 151 | _currentItem->keyChanged(k); |
158 | } | 152 | } |
159 | 153 | ||
160 | void MainWindow::valueChanged(const QString &v) | 154 | void MainWindow::valueChanged(const QString &v) |
161 | { | 155 | { |
162 | if (!_currentItem) return; | 156 | if (!_currentItem) return; |
163 | _currentItem->valueChanged(v); | 157 | _currentItem->valueChanged(v); |
164 | } | 158 | } |
165 | 159 | ||
166 | 160 | ||
167 | void MainWindow::stopTimer( QListViewItem* ) | 161 | void MainWindow::stopTimer( QListViewItem* ) |
168 | { | 162 | { |
169 | popupTimer->stop(); | 163 | popupTimer->stop(); |
170 | } | 164 | } |
171 | 165 | ||
172 | void MainWindow::saveConfFile() | 166 | void MainWindow::saveConfFile() |
173 | { | 167 | { |
174 | if (!_fileItem) return; | 168 | if (!_fileItem) return; |
175 | _fileItem->save(); | 169 | _fileItem->save(); |
176 | } | 170 | } |
177 | 171 | ||
178 | void MainWindow::revertConfFile() | 172 | void MainWindow::revertConfFile() |
179 | { | 173 | { |
180 | if (!_item) return; | 174 | if (!_item) return; |
181 | _item->revert(); | 175 | _item->revert(); |
182 | } | 176 | } |
183 | 177 | ||
184 | void MainWindow::removeConfFile() | 178 | void MainWindow::removeConfFile() |
185 | { | 179 | { |
186 | if (!_item) return; | 180 | if (!_item) return; |
187 | _item->remove(); | 181 | _item->remove(); |
188 | } | 182 | } |
189 | 183 | ||
190 | void MainWindow::showPopup() | 184 | void MainWindow::showPopup() |
191 | { | 185 | { |
192 | qDebug("showPopup"); | 186 | qDebug("showPopup"); |
193 | if (!_item) return; | 187 | if (!_item) return; |
194 | popupActionRevert->setEnabled(_item->revertable()); | 188 | popupActionRevert->setEnabled(_item->revertable()); |
195 | popupActionSave->setEnabled(_item->isChanged()); | 189 | popupActionSave->setEnabled(_item->isChanged()); |
196 | if (_fileItem) | 190 | if (_fileItem) |
197 | { | 191 | { |
198 | popupActionSave->setEnabled(_fileItem->isChanged()); | 192 | popupActionSave->setEnabled(_fileItem->isChanged()); |
199 | popupMenuFile->popup( QCursor::pos() ); | 193 | popupMenuFile->popup( QCursor::pos() ); |
200 | }else if(_currentItem) | 194 | }else if(_currentItem) |
201 | { | 195 | { |
202 | popupMenuEntry->popup( QCursor::pos() ); | 196 | popupMenuEntry->popup( QCursor::pos() ); |
203 | } | 197 | } |
204 | } | 198 | } |
diff --git a/noncore/apps/opie-bartender/bartender.cpp b/noncore/apps/opie-bartender/bartender.cpp index 5661ad5..3a0d8d1 100644 --- a/noncore/apps/opie-bartender/bartender.cpp +++ b/noncore/apps/opie-bartender/bartender.cpp | |||
@@ -1,326 +1,326 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** | 2 | ** |
3 | ** Created: Sat Jul 20 08:10:53 2002 | 3 | ** Created: Sat Jul 20 08:10:53 2002 |
4 | ** by: L.J. Potter <ljp@llornkcor.com> | 4 | ** by: L.J. Potter <ljp@llornkcor.com> |
5 | ** copyright : (C) 2002 by ljp | 5 | ** copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | 12 | ||
13 | #include "bartender.h" | 13 | #include "bartender.h" |
14 | #include "newdrinks.h" | 14 | #include "newdrinks.h" |
15 | #include "showdrinks.h" | 15 | #include "showdrinks.h" |
16 | #include "inputDialog.h" | 16 | #include "inputDialog.h" |
17 | #include "searchresults.h" | 17 | #include "searchresults.h" |
18 | #include "bac.h" | 18 | #include "bac.h" |
19 | 19 | ||
20 | #include <qpe/qpetoolbar.h> | 20 | #include <qpe/qpetoolbar.h> |
21 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
22 | #include <opie/colorpopupmenu.h> | 22 | #include <opie/colorpopupmenu.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | #include <qcstring.h> | 26 | #include <qcstring.h> |
27 | #include <qlineedit.h> | 27 | #include <qlineedit.h> |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qlistbox.h> | 30 | #include <qlistbox.h> |
31 | #include <qstringlist.h> | 31 | #include <qstringlist.h> |
32 | #include <qmultilineedit.h> | 32 | #include <qmultilineedit.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qfile.h> | 36 | #include <qfile.h> |
37 | #include <qaction.h> | 37 | #include <qaction.h> |
38 | #include <qheader.h> | 38 | #include <qheader.h> |
39 | #include <qlistview.h> | 39 | #include <qlistview.h> |
40 | #include <qwidget.h> | 40 | #include <qwidget.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qvariant.h> | 42 | #include <qvariant.h> |
43 | #include <qtooltip.h> | 43 | #include <qtooltip.h> |
44 | #include <qwhatsthis.h> | 44 | #include <qwhatsthis.h> |
45 | #include <qimage.h> | 45 | #include <qimage.h> |
46 | #include <qpixmap.h> | 46 | #include <qpixmap.h> |
47 | 47 | ||
48 | #include <fcntl.h> | 48 | #include <fcntl.h> |
49 | #include <unistd.h> | 49 | #include <unistd.h> |
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | #include <stdio.h> | 51 | #include <stdio.h> |
52 | #include <errno.h> | 52 | #include <errno.h> |
53 | 53 | ||
54 | 54 | ||
55 | Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) | 55 | Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) |
56 | : QMainWindow( parent, name, fl ) { | 56 | : QMainWindow( parent, name, fl ) { |
57 | if ( !name ) | 57 | if ( !name ) |
58 | setName( "Bartender" ); | 58 | setName( "Bartender" ); |
59 | QGridLayout *layout = new QGridLayout( this ); | 59 | QGridLayout *layout = new QGridLayout( this ); |
60 | layout->setSpacing( 2); | 60 | layout->setSpacing( 2); |
61 | layout->setMargin( 2); | 61 | layout->setMargin( 2); |
62 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 62 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
63 | 63 | ||
64 | setCaption( tr( "Bartender" ) ); | 64 | setCaption( tr( "Bartender" ) ); |
65 | 65 | ||
66 | ToolBar1 = new QPEToolBar( this, "ToolBar1" ); | 66 | ToolBar1 = new QPEToolBar( this, "ToolBar1" ); |
67 | ToolBar1->setFixedHeight(22); | 67 | ToolBar1->setFixedHeight(22); |
68 | layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 ); | 68 | layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 ); |
69 | 69 | ||
70 | QPEMenuBar *menuBar = new QPEMenuBar( ToolBar1 ); | 70 | QMenuBar *menuBar = new QMenuBar( ToolBar1 ); |
71 | QPopupMenu *fileMenu; | 71 | QPopupMenu *fileMenu; |
72 | fileMenu = new QPopupMenu( this); | 72 | fileMenu = new QPopupMenu( this); |
73 | menuBar->insertItem( tr("File"), fileMenu ); | 73 | menuBar->insertItem( tr("File"), fileMenu ); |
74 | 74 | ||
75 | fileMenu->insertItem(tr("New Drink")); | 75 | fileMenu->insertItem(tr("New Drink")); |
76 | fileMenu->insertItem(tr("Open Drink")); | 76 | fileMenu->insertItem(tr("Open Drink")); |
77 | fileMenu->insertItem(tr("Find by Drink Name")); | 77 | fileMenu->insertItem(tr("Find by Drink Name")); |
78 | fileMenu->insertItem(tr("Find by Alcohol")); | 78 | fileMenu->insertItem(tr("Find by Alcohol")); |
79 | 79 | ||
80 | QPopupMenu *editMenu; | 80 | QPopupMenu *editMenu; |
81 | editMenu = new QPopupMenu( this); | 81 | editMenu = new QPopupMenu( this); |
82 | menuBar->insertItem( tr("Edit"), editMenu ); | 82 | menuBar->insertItem( tr("Edit"), editMenu ); |
83 | editMenu->insertItem(tr("edit")); | 83 | editMenu->insertItem(tr("edit")); |
84 | 84 | ||
85 | connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); | 85 | connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); |
86 | connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); | 86 | connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); |
87 | 87 | ||
88 | 88 | ||
89 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); | 89 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); |
90 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 90 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
91 | a->addTo( ToolBar1 ); | 91 | a->addTo( ToolBar1 ); |
92 | 92 | ||
93 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); | 93 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); |
94 | connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); | 94 | connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); |
95 | a->addTo( ToolBar1 ); | 95 | a->addTo( ToolBar1 ); |
96 | 96 | ||
97 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); | 97 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); |
98 | connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); | 98 | connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); |
99 | a->addTo( ToolBar1 ); | 99 | a->addTo( ToolBar1 ); |
100 | 100 | ||
101 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); | 101 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); |
102 | connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); | 102 | connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); |
103 | a->addTo( ToolBar1 ); | 103 | a->addTo( ToolBar1 ); |
104 | 104 | ||
105 | QPushButton *t; | 105 | QPushButton *t; |
106 | t= new QPushButton( "BAC", ToolBar1, "bacButtin"); | 106 | t= new QPushButton( "BAC", ToolBar1, "bacButtin"); |
107 | connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) ); | 107 | connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) ); |
108 | 108 | ||
109 | DrinkView = new QListView( this, "DrinkView" ); | 109 | DrinkView = new QListView( this, "DrinkView" ); |
110 | DrinkView->addColumn( tr( "Name of Drink" ) ); | 110 | DrinkView->addColumn( tr( "Name of Drink" ) ); |
111 | // DrinkView->setRootIsDecorated( TRUE ); | 111 | // DrinkView->setRootIsDecorated( TRUE ); |
112 | DrinkView->header()->hide(); | 112 | DrinkView->header()->hide(); |
113 | 113 | ||
114 | QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); | 114 | QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); |
115 | 115 | ||
116 | connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink( QListViewItem*))); | 116 | connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink( QListViewItem*))); |
117 | connect(DrinkView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 117 | connect(DrinkView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
118 | this,SLOT( showDrink(int, QListViewItem *, const QPoint&, int))); | 118 | this,SLOT( showDrink(int, QListViewItem *, const QPoint&, int))); |
119 | 119 | ||
120 | layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 ); | 120 | layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 ); |
121 | if(QDir("db").exists()) { | 121 | if(QDir("db").exists()) { |
122 | dbFile.setName( "db/drinkdb.txt"); | 122 | dbFile.setName( "db/drinkdb.txt"); |
123 | } else | 123 | } else |
124 | dbFile.setName( QPEApplication::qpeDir()+"/etc/bartender/drinkdb.txt"); | 124 | dbFile.setName( QPEApplication::qpeDir()+"/etc/bartender/drinkdb.txt"); |
125 | initDrinkDb(); | 125 | initDrinkDb(); |
126 | } | 126 | } |
127 | 127 | ||
128 | Bartender::~Bartender() { | 128 | Bartender::~Bartender() { |
129 | } | 129 | } |
130 | 130 | ||
131 | /* | 131 | /* |
132 | this happens right before exit */ | 132 | this happens right before exit */ |
133 | void Bartender::cleanUp() { | 133 | void Bartender::cleanUp() { |
134 | dbFile.close(); | 134 | dbFile.close(); |
135 | 135 | ||
136 | } | 136 | } |
137 | 137 | ||
138 | void Bartender::initDrinkDb() { | 138 | void Bartender::initDrinkDb() { |
139 | 139 | ||
140 | if(!dbFile.isOpen()) | 140 | if(!dbFile.isOpen()) |
141 | if ( !dbFile.open( IO_ReadOnly)) { | 141 | if ( !dbFile.open( IO_ReadOnly)) { |
142 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); | 142 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); |
143 | return; | 143 | return; |
144 | } | 144 | } |
145 | fillList(); | 145 | fillList(); |
146 | } | 146 | } |
147 | 147 | ||
148 | void Bartender::fillList() { | 148 | void Bartender::fillList() { |
149 | dbFile.at(1); | 149 | dbFile.at(1); |
150 | DrinkView->clear(); | 150 | DrinkView->clear(); |
151 | int i=0; | 151 | int i=0; |
152 | QListViewItem * item ; | 152 | QListViewItem * item ; |
153 | QTextStream t( &dbFile); | 153 | QTextStream t( &dbFile); |
154 | QString s; | 154 | QString s; |
155 | while ( !t.eof()) { | 155 | while ( !t.eof()) { |
156 | s = t.readLine(); | 156 | s = t.readLine(); |
157 | if(s.find("#",0,TRUE) != -1) { | 157 | if(s.find("#",0,TRUE) != -1) { |
158 | // qDebug(s.right(s.length()-2)); | 158 | // qDebug(s.right(s.length()-2)); |
159 | item= new QListViewItem( DrinkView, 0 ); | 159 | item= new QListViewItem( DrinkView, 0 ); |
160 | item->setText( 0, s.right(s.length()-2)); | 160 | item->setText( 0, s.right(s.length()-2)); |
161 | i++; | 161 | i++; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | qDebug("there are currently %d of drinks", i); | 164 | qDebug("there are currently %d of drinks", i); |
165 | } | 165 | } |
166 | 166 | ||
167 | void Bartender::fileNew() { | 167 | void Bartender::fileNew() { |
168 | 168 | ||
169 | New_Drink *newDrinks; | 169 | New_Drink *newDrinks; |
170 | newDrinks = new New_Drink(this,"New Drink....", TRUE); | 170 | newDrinks = new New_Drink(this,"New Drink....", TRUE); |
171 | QString newName, newIng; | 171 | QString newName, newIng; |
172 | newDrinks->showMaximized(); | 172 | newDrinks->showMaximized(); |
173 | newDrinks->exec(); | 173 | newDrinks->exec(); |
174 | newName = newDrinks->LineEdit1->text(); | 174 | newName = newDrinks->LineEdit1->text(); |
175 | newIng= newDrinks->MultiLineEdit1->text(); | 175 | newIng= newDrinks->MultiLineEdit1->text(); |
176 | 176 | ||
177 | if(dbFile.isOpen()) | 177 | if(dbFile.isOpen()) |
178 | dbFile.close(); | 178 | dbFile.close(); |
179 | if ( !dbFile.open( IO_WriteOnly| IO_Append)) { | 179 | if ( !dbFile.open( IO_WriteOnly| IO_Append)) { |
180 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); | 180 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); |
181 | return; | 181 | return; |
182 | } | 182 | } |
183 | if(newDrinks ->result() == 1 ) { | 183 | if(newDrinks ->result() == 1 ) { |
184 | QString newDrink="\n# "+newName+"\n"; | 184 | QString newDrink="\n# "+newName+"\n"; |
185 | newDrink.append(newIng+"\n"); | 185 | newDrink.append(newIng+"\n"); |
186 | qDebug("writing "+newDrink); | 186 | qDebug("writing "+newDrink); |
187 | dbFile.writeBlock( newDrink.latin1(), newDrink.length()); | 187 | dbFile.writeBlock( newDrink.latin1(), newDrink.length()); |
188 | clearList(); | 188 | clearList(); |
189 | dbFile.close(); | 189 | dbFile.close(); |
190 | 190 | ||
191 | initDrinkDb(); | 191 | initDrinkDb(); |
192 | } | 192 | } |
193 | delete newDrinks; | 193 | delete newDrinks; |
194 | } | 194 | } |
195 | 195 | ||
196 | void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) { | 196 | void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) { |
197 | switch (mouse) { | 197 | switch (mouse) { |
198 | case 1: | 198 | case 1: |
199 | // showDrink(item); | 199 | // showDrink(item); |
200 | break; | 200 | break; |
201 | case 2: | 201 | case 2: |
202 | showDrink(item); | 202 | showDrink(item); |
203 | break; | 203 | break; |
204 | } | 204 | } |
205 | } | 205 | } |
206 | 206 | ||
207 | void Bartender::showDrink( QListViewItem *item) { | 207 | void Bartender::showDrink( QListViewItem *item) { |
208 | if(item==NULL) return; | 208 | if(item==NULL) return; |
209 | dbFile.at(0); | 209 | dbFile.at(0); |
210 | Show_Drink *showDrinks; | 210 | Show_Drink *showDrinks; |
211 | QString myDrink=item->text(0); | 211 | QString myDrink=item->text(0); |
212 | showDrinks = new Show_Drink(this, myDrink, TRUE); | 212 | showDrinks = new Show_Drink(this, myDrink, TRUE); |
213 | QTextStream t( &dbFile); | 213 | QTextStream t( &dbFile); |
214 | 214 | ||
215 | QString s, s2; | 215 | QString s, s2; |
216 | while ( !t.eof()) { | 216 | while ( !t.eof()) { |
217 | s = t.readLine(); | 217 | s = t.readLine(); |
218 | if(s.find( myDrink, 0, TRUE) != -1) { | 218 | if(s.find( myDrink, 0, TRUE) != -1) { |
219 | for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) { | 219 | for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) { |
220 | s2 = t.readLine(); | 220 | s2 = t.readLine(); |
221 | if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) { | 221 | if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) { |
222 | // qDebug(s2); | 222 | // qDebug(s2); |
223 | showDrinks->MultiLineEdit1->append(s2); | 223 | showDrinks->MultiLineEdit1->append(s2); |
224 | } | 224 | } |
225 | if( dbFile.atEnd() ) break; | 225 | if( dbFile.atEnd() ) break; |
226 | } | 226 | } |
227 | } | 227 | } |
228 | } | 228 | } |
229 | showDrinks->showMaximized(); | 229 | showDrinks->showMaximized(); |
230 | showDrinks->exec(); | 230 | showDrinks->exec(); |
231 | 231 | ||
232 | if(showDrinks ->result() ==0) { | 232 | if(showDrinks ->result() ==0) { |
233 | doEdit(); | 233 | doEdit(); |
234 | } | 234 | } |
235 | delete showDrinks; | 235 | delete showDrinks; |
236 | } | 236 | } |
237 | 237 | ||
238 | void Bartender::askSearch() { | 238 | void Bartender::askSearch() { |
239 | switch ( QMessageBox::warning(this,tr("Find"),tr("Search by drink name\n")+ | 239 | switch ( QMessageBox::warning(this,tr("Find"),tr("Search by drink name\n")+ |
240 | "\nor alcohol ?" | 240 | "\nor alcohol ?" |
241 | ,tr("Drink Name"),tr("Alcohol"),0,0,1) ) { | 241 | ,tr("Drink Name"),tr("Alcohol"),0,0,1) ) { |
242 | case 0: | 242 | case 0: |
243 | doSearchByName(); | 243 | doSearchByName(); |
244 | break; | 244 | break; |
245 | case 1: | 245 | case 1: |
246 | doSearchByDrink(); | 246 | doSearchByDrink(); |
247 | break; | 247 | break; |
248 | }; | 248 | }; |
249 | } | 249 | } |
250 | 250 | ||
251 | /* search by name */ | 251 | /* search by name */ |
252 | void Bartender::doSearchByName() { | 252 | void Bartender::doSearchByName() { |
253 | // if( DrinkView->currentItem() == NULL) return; | 253 | // if( DrinkView->currentItem() == NULL) return; |
254 | QStringList searchList; | 254 | QStringList searchList; |
255 | QString searchForDrinkName; | 255 | QString searchForDrinkName; |
256 | InputDialog *fileDlg; | 256 | InputDialog *fileDlg; |
257 | fileDlg = new InputDialog(this,tr("Find by Drink Name"),TRUE, 0); | 257 | fileDlg = new InputDialog(this,tr("Find by Drink Name"),TRUE, 0); |
258 | fileDlg->exec(); | 258 | fileDlg->exec(); |
259 | if( fileDlg->result() == 1 ) { | 259 | if( fileDlg->result() == 1 ) { |
260 | searchForDrinkName = fileDlg->LineEdit1->text(); | 260 | searchForDrinkName = fileDlg->LineEdit1->text(); |
261 | QListViewItemIterator it( DrinkView ); | 261 | QListViewItemIterator it( DrinkView ); |
262 | for ( ; it.current(); ++it ) { | 262 | for ( ; it.current(); ++it ) { |
263 | if ( it.current()->text(0).find( searchForDrinkName, 0, TRUE) != -1 ) { | 263 | if ( it.current()->text(0).find( searchForDrinkName, 0, TRUE) != -1 ) { |
264 | // qDebug( it.current()->text(0)); | 264 | // qDebug( it.current()->text(0)); |
265 | searchList.append(it.current()->text(0)); | 265 | searchList.append(it.current()->text(0)); |
266 | } | 266 | } |
267 | } | 267 | } |
268 | if(searchList.count() >0) | 268 | if(searchList.count() >0) |
269 | showSearchResult(searchList); | 269 | showSearchResult(searchList); |
270 | else | 270 | else |
271 | QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+searchForDrinkName); | 271 | QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+searchForDrinkName); |
272 | }//end Inputdialog | 272 | }//end Inputdialog |
273 | delete fileDlg; | 273 | delete fileDlg; |
274 | } | 274 | } |
275 | 275 | ||
276 | void Bartender::doSearchByDrink() { | 276 | void Bartender::doSearchByDrink() { |
277 | // if( DrinkView->currentItem() == NULL) return; | 277 | // if( DrinkView->currentItem() == NULL) return; |
278 | QStringList searchList; | 278 | QStringList searchList; |
279 | QString searchForDrinkName, lastDrinkName, tempName; | 279 | QString searchForDrinkName, lastDrinkName, tempName; |
280 | 280 | ||
281 | InputDialog *fileDlg; | 281 | InputDialog *fileDlg; |
282 | fileDlg = new InputDialog(this,tr("Find by Alcohol"),TRUE, 0); | 282 | fileDlg = new InputDialog(this,tr("Find by Alcohol"),TRUE, 0); |
283 | fileDlg->exec(); | 283 | fileDlg->exec(); |
284 | if( fileDlg->result() == 1 ) { | 284 | if( fileDlg->result() == 1 ) { |
285 | searchForDrinkName = fileDlg->LineEdit1->text(); | 285 | searchForDrinkName = fileDlg->LineEdit1->text(); |
286 | 286 | ||
287 | dbFile.at(0); | 287 | dbFile.at(0); |
288 | QTextStream t( &dbFile); | 288 | QTextStream t( &dbFile); |
289 | 289 | ||
290 | QString s, s2; | 290 | QString s, s2; |
291 | while ( !t.eof()) { | 291 | while ( !t.eof()) { |
292 | s = t.readLine(); | 292 | s = t.readLine(); |
293 | if(s.find("#",0,TRUE) != -1) { | 293 | if(s.find("#",0,TRUE) != -1) { |
294 | lastDrinkName=s.right(s.length()-2); | 294 | lastDrinkName=s.right(s.length()-2); |
295 | // qDebug("last drink name "+lastDrinkName); | 295 | // qDebug("last drink name "+lastDrinkName); |
296 | } | 296 | } |
297 | else if( s.find( searchForDrinkName ,0, FALSE) != -1 && lastDrinkName != tempName ) { | 297 | else if( s.find( searchForDrinkName ,0, FALSE) != -1 && lastDrinkName != tempName ) { |
298 | // qDebug("appending "+lastDrinkName); | 298 | // qDebug("appending "+lastDrinkName); |
299 | searchList.append( lastDrinkName); | 299 | searchList.append( lastDrinkName); |
300 | tempName=lastDrinkName; | 300 | tempName=lastDrinkName; |
301 | } | 301 | } |
302 | // if( dbFile.atEnd() ) break; | 302 | // if( dbFile.atEnd() ) break; |
303 | 303 | ||
304 | } //oef | 304 | } //oef |
305 | if(searchList.count() >0) | 305 | if(searchList.count() >0) |
306 | showSearchResult(searchList); | 306 | showSearchResult(searchList); |
307 | else | 307 | else |
308 | QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+ searchForDrinkName); | 308 | QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+ searchForDrinkName); |
309 | } | 309 | } |
310 | delete fileDlg; | 310 | delete fileDlg; |
311 | } | 311 | } |
312 | 312 | ||
313 | void Bartender::showSearchResult(QStringList &searchList) { | 313 | void Bartender::showSearchResult(QStringList &searchList) { |
314 | QString result; | 314 | QString result; |
315 | Search_Results *searchDlg; | 315 | Search_Results *searchDlg; |
316 | 316 | ||
317 | searchList.sort(); | 317 | searchList.sort(); |
318 | 318 | ||
319 | searchDlg = new Search_Results(this, "Search Results", TRUE); | 319 | searchDlg = new Search_Results(this, "Search Results", TRUE); |
320 | searchDlg->showMaximized(); | 320 | searchDlg->showMaximized(); |
321 | searchDlg->ListBox1->insertStringList( searchList,-1); | 321 | searchDlg->ListBox1->insertStringList( searchList,-1); |
322 | searchDlg->exec(); | 322 | searchDlg->exec(); |
323 | 323 | ||
324 | if( searchDlg->result() == 1 ) { | 324 | if( searchDlg->result() == 1 ) { |
325 | result= searchDlg->ListBox1->currentText(); | 325 | result= searchDlg->ListBox1->currentText(); |
326 | } | 326 | } |
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index 087ce00..8c0d138 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -29,513 +29,513 @@ | |||
29 | #include <qtoolbar.h> | 29 | #include <qtoolbar.h> |
30 | #ifdef USEQPE | 30 | #ifdef USEQPE |
31 | #include <qpe/menubutton.h> | 31 | #include <qpe/menubutton.h> |
32 | #include <qpe/fontdatabase.h> | 32 | #include <qpe/fontdatabase.h> |
33 | #endif | 33 | #endif |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qaction.h> | 36 | #include <qaction.h> |
37 | #include <qapplication.h> | 37 | #include <qapplication.h> |
38 | #include <qlineedit.h> | 38 | #include <qlineedit.h> |
39 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | #include <qobjectlist.h> | 41 | #include <qobjectlist.h> |
42 | #ifdef USEQPE | 42 | #ifdef USEQPE |
43 | #include <qpe/global.h> | 43 | #include <qpe/global.h> |
44 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
45 | #endif | 45 | #endif |
46 | #include <qfileinfo.h> | 46 | #include <qfileinfo.h> |
47 | #include <stdlib.h> //getenv | 47 | #include <stdlib.h> //getenv |
48 | #include <qprogressbar.h> | 48 | #include <qprogressbar.h> |
49 | #ifdef USEQPE | 49 | #ifdef USEQPE |
50 | #include <qpe/config.h> | 50 | #include <qpe/config.h> |
51 | #endif | 51 | #endif |
52 | #include <qbuttongroup.h> | 52 | #include <qbuttongroup.h> |
53 | #include <qradiobutton.h> | 53 | #include <qradiobutton.h> |
54 | #ifdef USEQPE | 54 | #ifdef USEQPE |
55 | #include <qpe/qcopenvelope_qws.h> | 55 | #include <qpe/qcopenvelope_qws.h> |
56 | #endif | 56 | #endif |
57 | #include "QTReader.h" | 57 | #include "QTReader.h" |
58 | #include "GraphicWin.h" | 58 | #include "GraphicWin.h" |
59 | #include "Bkmks.h" | 59 | #include "Bkmks.h" |
60 | #include "cbkmkselector.h" | 60 | #include "cbkmkselector.h" |
61 | #include "infowin.h" | 61 | #include "infowin.h" |
62 | #include "ToolbarPrefs.h" | 62 | #include "ToolbarPrefs.h" |
63 | #include "Prefs.h" | 63 | #include "Prefs.h" |
64 | #include "CAnnoEdit.h" | 64 | #include "CAnnoEdit.h" |
65 | #include "QFloatBar.h" | 65 | #include "QFloatBar.h" |
66 | #include "FixedFont.h" | 66 | #include "FixedFont.h" |
67 | #include "URLDialog.h" | 67 | #include "URLDialog.h" |
68 | //#include <qpe/fontdatabase.h> | 68 | //#include <qpe/fontdatabase.h> |
69 | 69 | ||
70 | #ifdef USEQPE | 70 | #ifdef USEQPE |
71 | #include <qpe/resource.h> | 71 | #include <qpe/resource.h> |
72 | #include <qpe/qpeapplication.h> | 72 | #include <qpe/qpeapplication.h> |
73 | #include "fileBrowser.h" | 73 | #include "fileBrowser.h" |
74 | #else | 74 | #else |
75 | #include "qfiledialog.h" | 75 | #include "qfiledialog.h" |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | #include "QTReaderApp.h" | 78 | #include "QTReaderApp.h" |
79 | #include "CDrawBuffer.h" | 79 | #include "CDrawBuffer.h" |
80 | #include "Filedata.h" | 80 | #include "Filedata.h" |
81 | #include "opie.h" | 81 | #include "opie.h" |
82 | #include "useqpe.h" | 82 | #include "useqpe.h" |
83 | #include "names.h" | 83 | #include "names.h" |
84 | #include "CEncoding_tables.h" | 84 | #include "CEncoding_tables.h" |
85 | #include "CloseDialog.h" | 85 | #include "CloseDialog.h" |
86 | 86 | ||
87 | bool CheckVersion(int&, int&, char&); | 87 | bool CheckVersion(int&, int&, char&); |
88 | 88 | ||
89 | #ifdef _WINDOWS | 89 | #ifdef _WINDOWS |
90 | #define PICDIR "c:\\uqtreader\\pics\\" | 90 | #define PICDIR "c:\\uqtreader\\pics\\" |
91 | #else | 91 | #else |
92 | #ifdef USEQPE | 92 | #ifdef USEQPE |
93 | #define PICDIR "opie-reader/" | 93 | #define PICDIR "opie-reader/" |
94 | #else | 94 | #else |
95 | #define PICDIR "/home/tim/uqtreader/pics/" | 95 | #define PICDIR "/home/tim/uqtreader/pics/" |
96 | #endif | 96 | #endif |
97 | #endif | 97 | #endif |
98 | 98 | ||
99 | unsigned long QTReaderApp::m_uid = 0; | 99 | unsigned long QTReaderApp::m_uid = 0; |
100 | 100 | ||
101 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } | 101 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } |
102 | 102 | ||
103 | #ifdef USEQPE | 103 | #ifdef USEQPE |
104 | #define geticon(iconname) Resource::loadPixmap( iconname ) | 104 | #define geticon(iconname) Resource::loadPixmap( iconname ) |
105 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) | 105 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) |
106 | #else | 106 | #else |
107 | #define geticon(iconname) QPixmap(PICDIR iconname ".png") | 107 | #define geticon(iconname) QPixmap(PICDIR iconname ".png") |
108 | #define getmyicon(iconname) geticon(iconname) | 108 | #define getmyicon(iconname) geticon(iconname) |
109 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) | 109 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) |
110 | #endif | 110 | #endif |
111 | 111 | ||
112 | #ifndef _WINDOWS | 112 | #ifndef _WINDOWS |
113 | #include <unistd.h> | 113 | #include <unistd.h> |
114 | #endif | 114 | #endif |
115 | #include <stddef.h> | 115 | #include <stddef.h> |
116 | #ifndef _WINDOWS | 116 | #ifndef _WINDOWS |
117 | #include <dirent.h> | 117 | #include <dirent.h> |
118 | #endif | 118 | #endif |
119 | 119 | ||
120 | void QTReaderApp::listBkmkFiles() | 120 | void QTReaderApp::listBkmkFiles() |
121 | { | 121 | { |
122 | bkmkselector->clear(); | 122 | bkmkselector->clear(); |
123 | bkmkselector->setText("Cancel"); | 123 | bkmkselector->setText("Cancel"); |
124 | #ifndef USEQPE | 124 | #ifndef USEQPE |
125 | int cnt = 0; | 125 | int cnt = 0; |
126 | 126 | ||
127 | QDir d = QDir::home(); // "/" | 127 | QDir d = QDir::home(); // "/" |
128 | if ( !d.cd(APPDIR) ) { // "/tmp" | 128 | if ( !d.cd(APPDIR) ) { // "/tmp" |
129 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 129 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
130 | d = QDir::home(); | 130 | d = QDir::home(); |
131 | d.mkdir(APPDIR); | 131 | d.mkdir(APPDIR); |
132 | d.cd(APPDIR); | 132 | d.cd(APPDIR); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | 136 | ||
137 | 137 | ||
138 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 138 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
139 | // d.setSorting( QDir::Size | QDir::Reversed ); | 139 | // d.setSorting( QDir::Size | QDir::Reversed ); |
140 | 140 | ||
141 | const QFileInfoList *list = d.entryInfoList(); | 141 | const QFileInfoList *list = d.entryInfoList(); |
142 | QFileInfoListIterator it( *list ); // create list iterator | 142 | QFileInfoListIterator it( *list ); // create list iterator |
143 | QFileInfo *fi; // pointer for traversing | 143 | QFileInfo *fi; // pointer for traversing |
144 | 144 | ||
145 | while ( (fi=it.current()) ) { // for each file... | 145 | while ( (fi=it.current()) ) { // for each file... |
146 | 146 | ||
147 | bkmkselector->insertItem(fi->fileName()); | 147 | bkmkselector->insertItem(fi->fileName()); |
148 | cnt++; | 148 | cnt++; |
149 | 149 | ||
150 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | 150 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); |
151 | ++it; // goto next list element | 151 | ++it; // goto next list element |
152 | } | 152 | } |
153 | 153 | ||
154 | #else /* USEQPE */ | 154 | #else /* USEQPE */ |
155 | int cnt = 0; | 155 | int cnt = 0; |
156 | DIR *d; | 156 | DIR *d; |
157 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); | 157 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); |
158 | 158 | ||
159 | while(1) | 159 | while(1) |
160 | { | 160 | { |
161 | struct dirent* de; | 161 | struct dirent* de; |
162 | struct stat buf; | 162 | struct stat buf; |
163 | de = readdir(d); | 163 | de = readdir(d); |
164 | if (de == NULL) break; | 164 | if (de == NULL) break; |
165 | 165 | ||
166 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 166 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) |
167 | { | 167 | { |
168 | bkmkselector->insertItem(de->d_name); | 168 | bkmkselector->insertItem(de->d_name); |
169 | cnt++; | 169 | cnt++; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | closedir(d); | 173 | closedir(d); |
174 | #endif | 174 | #endif |
175 | if (cnt > 0) | 175 | if (cnt > 0) |
176 | { | 176 | { |
177 | //tjw menu->hide(); | 177 | //tjw menu->hide(); |
178 | editorStack->raiseWidget( bkmkselector ); | 178 | editorStack->raiseWidget( bkmkselector ); |
179 | hidetoolbars(); | 179 | hidetoolbars(); |
180 | m_nBkmkAction = cRmBkmkFile; | 180 | m_nBkmkAction = cRmBkmkFile; |
181 | } | 181 | } |
182 | else | 182 | else |
183 | QMessageBox::information(this, PROGNAME, "No bookmark files"); | 183 | QMessageBox::information(this, PROGNAME, "No bookmark files"); |
184 | } | 184 | } |
185 | 185 | ||
186 | void QTReaderApp::hidetoolbars() | 186 | void QTReaderApp::hidetoolbars() |
187 | { | 187 | { |
188 | menubar->hide(); | 188 | menubar->hide(); |
189 | if (fileBar != NULL) fileBar->hide(); | 189 | if (fileBar != NULL) fileBar->hide(); |
190 | if (viewBar != NULL) viewBar->hide(); | 190 | if (viewBar != NULL) viewBar->hide(); |
191 | if (navBar != NULL) navBar->hide(); | 191 | if (navBar != NULL) navBar->hide(); |
192 | if (markBar != NULL) markBar->hide(); | 192 | if (markBar != NULL) markBar->hide(); |
193 | if (m_fontVisible) m_fontBar->hide(); | 193 | if (m_fontVisible) m_fontBar->hide(); |
194 | if (regVisible) | 194 | if (regVisible) |
195 | { | 195 | { |
196 | #ifdef USEQPE | 196 | #ifdef USEQPE |
197 | Global::hideInputMethod(); | 197 | Global::hideInputMethod(); |
198 | #endif | 198 | #endif |
199 | regBar->hide(); | 199 | regBar->hide(); |
200 | } | 200 | } |
201 | if (searchVisible) | 201 | if (searchVisible) |
202 | { | 202 | { |
203 | #ifdef USEQPE | 203 | #ifdef USEQPE |
204 | Global::hideInputMethod(); | 204 | Global::hideInputMethod(); |
205 | #endif | 205 | #endif |
206 | searchBar->hide(); | 206 | searchBar->hide(); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | 210 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) |
211 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false), | 211 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false), |
212 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL) | 212 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL) |
213 | { | 213 | { |
214 | m_url_clipboard = false; | 214 | m_url_clipboard = false; |
215 | m_url_localfile = false; | 215 | m_url_localfile = false; |
216 | m_url_globalfile = false; | 216 | m_url_globalfile = false; |
217 | ftime(&m_lastkeytime); | 217 | ftime(&m_lastkeytime); |
218 | //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); | 218 | //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); |
219 | //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); | 219 | //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); |
220 | 220 | ||
221 | m_bcloseDisabled = true; | 221 | m_bcloseDisabled = true; |
222 | m_disableesckey = false; | 222 | m_disableesckey = false; |
223 | pBkmklist = NULL; | 223 | pBkmklist = NULL; |
224 | pOpenlist = NULL; | 224 | pOpenlist = NULL; |
225 | // doc = 0; | 225 | // doc = 0; |
226 | 226 | ||
227 | m_fBkmksChanged = false; | 227 | m_fBkmksChanged = false; |
228 | 228 | ||
229 | QString lang = getenv( "LANG" ); | 229 | QString lang = getenv( "LANG" ); |
230 | QString rot = getenv( "QWS_DISPLAY" ); | 230 | QString rot = getenv( "QWS_DISPLAY" ); |
231 | 231 | ||
232 | /* | 232 | /* |
233 | int m_rot = 0; | 233 | int m_rot = 0; |
234 | if (rot.contains("Rot90")) | 234 | if (rot.contains("Rot90")) |
235 | { | 235 | { |
236 | m_rot = 90; | 236 | m_rot = 90; |
237 | } | 237 | } |
238 | else if (rot.contains("Rot180")) | 238 | else if (rot.contains("Rot180")) |
239 | { | 239 | { |
240 | m_rot = 180; | 240 | m_rot = 180; |
241 | } | 241 | } |
242 | else if (rot.contains("Rot270")) | 242 | else if (rot.contains("Rot270")) |
243 | { | 243 | { |
244 | m_rot = 270; | 244 | m_rot = 270; |
245 | } | 245 | } |
246 | 246 | ||
247 | // qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); | 247 | // qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); |
248 | */ | 248 | */ |
249 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; | 249 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; |
250 | 250 | ||
251 | #ifdef USEQPE | 251 | #ifdef USEQPE |
252 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); | 252 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); |
253 | #else | 253 | #else |
254 | setIcon( QPixmap (PICDIR "uqtreader.png") ); | 254 | setIcon( QPixmap (PICDIR "uqtreader.png") ); |
255 | #endif /* USEQPE */ | 255 | #endif /* USEQPE */ |
256 | 256 | ||
257 | // QPEToolBar *bar = new QPEToolBar( this ); | 257 | // QPEToolBar *bar = new QPEToolBar( this ); |
258 | // menubar = new QPEToolBar( this ); | 258 | // menubar = new QPEToolBar( this ); |
259 | #ifdef USEQPE | 259 | #ifdef USEQPE |
260 | Config config( APPDIR ); | 260 | Config config( APPDIR ); |
261 | #else | 261 | #else |
262 | QDir d = QDir::home(); // "/" | 262 | QDir d = QDir::home(); // "/" |
263 | if ( !d.cd(APPDIR) ) { // "/tmp" | 263 | if ( !d.cd(APPDIR) ) { // "/tmp" |
264 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 264 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
265 | d = QDir::home(); | 265 | d = QDir::home(); |
266 | d.mkdir(APPDIR); | 266 | d.mkdir(APPDIR); |
267 | d.cd(APPDIR); | 267 | d.cd(APPDIR); |
268 | } | 268 | } |
269 | QFileInfo fi(d, INIFILE); | 269 | QFileInfo fi(d, INIFILE); |
270 | // qDebug("Path:%s", (const char*)fi.absFilePath()); | 270 | // qDebug("Path:%s", (const char*)fi.absFilePath()); |
271 | Config config(fi.absFilePath()); | 271 | Config config(fi.absFilePath()); |
272 | #endif | 272 | #endif |
273 | config.setGroup("Toolbar"); | 273 | config.setGroup("Toolbar"); |
274 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); | 274 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); |
275 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); | 275 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); |
276 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | 276 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); |
277 | menubar = new QToolBar("Menus", this, m_tbposition); | 277 | menubar = new QToolBar("Menus", this, m_tbposition); |
278 | 278 | ||
279 | // fileBar = new QToolBar("File", this); | 279 | // fileBar = new QToolBar("File", this); |
280 | // QToolBar* viewBar = new QToolBar("File", this); | 280 | // QToolBar* viewBar = new QToolBar("File", this); |
281 | // QToolBar* navBar = new QToolBar("File", this); | 281 | // QToolBar* navBar = new QToolBar("File", this); |
282 | // QToolBar* markBar = new QToolBar("File", this); | 282 | // QToolBar* markBar = new QToolBar("File", this); |
283 | 283 | ||
284 | #ifdef USEQPE | 284 | #ifdef USEQPE |
285 | mb = new QPEMenuBar( menubar ); | 285 | mb = new QMenuBar( menubar ); |
286 | #else | 286 | #else |
287 | mb = new QMenuBar( menubar ); | 287 | mb = new QMenuBar( menubar ); |
288 | #endif | 288 | #endif |
289 | 289 | ||
290 | //#ifdef USEQPE | 290 | //#ifdef USEQPE |
291 | QPopupMenu* tmp = new QPopupMenu(mb); | 291 | QPopupMenu* tmp = new QPopupMenu(mb); |
292 | mb->insertItem( geticon( "AppsIcon" ), tmp ); | 292 | mb->insertItem( geticon( "AppsIcon" ), tmp ); |
293 | //#else | 293 | //#else |
294 | // QMenuBar* tmp = mb; | 294 | // QMenuBar* tmp = mb; |
295 | //#endif | 295 | //#endif |
296 | 296 | ||
297 | QPopupMenu *file = new QPopupMenu( mb ); | 297 | QPopupMenu *file = new QPopupMenu( mb ); |
298 | tmp->insertItem( tr( "File" ), file ); | 298 | tmp->insertItem( tr( "File" ), file ); |
299 | 299 | ||
300 | QPopupMenu *navigation = new QPopupMenu(mb); | 300 | QPopupMenu *navigation = new QPopupMenu(mb); |
301 | tmp->insertItem( tr( "Navigation" ), navigation ); | 301 | tmp->insertItem( tr( "Navigation" ), navigation ); |
302 | 302 | ||
303 | QPopupMenu *view = new QPopupMenu( mb ); | 303 | QPopupMenu *view = new QPopupMenu( mb ); |
304 | tmp->insertItem( tr( "View" ), view ); | 304 | tmp->insertItem( tr( "View" ), view ); |
305 | 305 | ||
306 | QPopupMenu *marks = new QPopupMenu( this ); | 306 | QPopupMenu *marks = new QPopupMenu( this ); |
307 | tmp->insertItem( tr( "Marks" ), marks ); | 307 | tmp->insertItem( tr( "Marks" ), marks ); |
308 | 308 | ||
309 | QPopupMenu *settings = new QPopupMenu( this ); | 309 | QPopupMenu *settings = new QPopupMenu( this ); |
310 | tmp->insertItem( tr( "Settings" ), settings ); | 310 | tmp->insertItem( tr( "Settings" ), settings ); |
311 | 311 | ||
312 | // addToolBar(menubar, "Menus",QMainWindow::Top); | 312 | // addToolBar(menubar, "Menus",QMainWindow::Top); |
313 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); | 313 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); |
314 | 314 | ||
315 | // QPopupMenu *edit = new QPopupMenu( this ); | 315 | // QPopupMenu *edit = new QPopupMenu( this ); |
316 | 316 | ||
317 | /* | 317 | /* |
318 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 318 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
319 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 319 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
320 | a->addTo( bar ); | 320 | a->addTo( bar ); |
321 | a->addTo( file ); | 321 | a->addTo( file ); |
322 | */ | 322 | */ |
323 | 323 | ||
324 | editorStack = new QWidgetStack( this ); | 324 | editorStack = new QWidgetStack( this ); |
325 | setCentralWidget( editorStack ); | 325 | setCentralWidget( editorStack ); |
326 | 326 | ||
327 | searchVisible = FALSE; | 327 | searchVisible = FALSE; |
328 | regVisible = FALSE; | 328 | regVisible = FALSE; |
329 | m_fontVisible = false; | 329 | m_fontVisible = false; |
330 | 330 | ||
331 | m_annoWin = new CAnnoEdit(editorStack); | 331 | m_annoWin = new CAnnoEdit(editorStack); |
332 | editorStack->addWidget(m_annoWin, get_unique_id()); | 332 | editorStack->addWidget(m_annoWin, get_unique_id()); |
333 | connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); | 333 | connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); |
334 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); | 334 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); |
335 | 335 | ||
336 | m_infoWin = new infowin(editorStack); | 336 | m_infoWin = new infowin(editorStack); |
337 | editorStack->addWidget(m_infoWin, get_unique_id()); | 337 | editorStack->addWidget(m_infoWin, get_unique_id()); |
338 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); | 338 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); |
339 | 339 | ||
340 | m_graphicwin = new GraphicWin(editorStack); | 340 | m_graphicwin = new GraphicWin(editorStack); |
341 | editorStack->addWidget(m_graphicwin, get_unique_id()); | 341 | editorStack->addWidget(m_graphicwin, get_unique_id()); |
342 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); | 342 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); |
343 | 343 | ||
344 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); | 344 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); |
345 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); | 345 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); |
346 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); | 346 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); |
347 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); | 347 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); |
348 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); | 348 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); |
349 | editorStack->addWidget( bkmkselector, get_unique_id() ); | 349 | editorStack->addWidget( bkmkselector, get_unique_id() ); |
350 | 350 | ||
351 | /* | 351 | /* |
352 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); | 352 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); |
353 | connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); | 353 | connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); |
354 | 354 | ||
355 | editorStack->addWidget( importSelector, get_unique_id() ); | 355 | editorStack->addWidget( importSelector, get_unique_id() ); |
356 | 356 | ||
357 | // don't need the close visible, it is redundant... | 357 | // don't need the close visible, it is redundant... |
358 | importSelector->setCloseVisible( FALSE ); | 358 | importSelector->setCloseVisible( FALSE ); |
359 | */ | 359 | */ |
360 | // qDebug("Reading file list"); | 360 | // qDebug("Reading file list"); |
361 | readfilelist(); | 361 | readfilelist(); |
362 | 362 | ||
363 | reader = new QTReader( editorStack ); | 363 | reader = new QTReader( editorStack ); |
364 | 364 | ||
365 | reader->bDoUpdates = false; | 365 | reader->bDoUpdates = false; |
366 | 366 | ||
367 | #ifdef USEQPE | 367 | #ifdef USEQPE |
368 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); | 368 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); |
369 | #endif | 369 | #endif |
370 | 370 | ||
371 | // qDebug("Reading config"); | 371 | // qDebug("Reading config"); |
372 | // Config config( APPDIR ); | 372 | // Config config( APPDIR ); |
373 | config.setGroup( "View" ); | 373 | config.setGroup( "View" ); |
374 | m_debounce = config.readNumEntry("Debounce", 0); | 374 | m_debounce = config.readNumEntry("Debounce", 0); |
375 | #ifdef USEQPE | 375 | #ifdef USEQPE |
376 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); | 376 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); |
377 | #else | 377 | #else |
378 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); | 378 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); |
379 | #endif | 379 | #endif |
380 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); | 380 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); |
381 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | 381 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); |
382 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); | 382 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); |
383 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); | 383 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); |
384 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | 384 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); |
385 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | 385 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); |
386 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | 386 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); |
387 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 387 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); |
388 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 388 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
389 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | 389 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); |
390 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); | 390 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); |
391 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | 391 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); |
392 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 392 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
393 | reader->brepara = config.readBoolEntry( "Repara", false ); | 393 | reader->brepara = config.readBoolEntry( "Repara", false ); |
394 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | 394 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); |
395 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | 395 | reader->bindenter = config.readNumEntry( "Indent", 0 ); |
396 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | 396 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); |
397 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | 397 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); |
398 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | 398 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); |
399 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 399 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
400 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 400 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
401 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 401 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); |
402 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); | 402 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); |
403 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 403 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
404 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 404 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); |
405 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 405 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
406 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 406 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
407 | reader->m_border = config.readNumEntry( "Margin", 6 ); | 407 | reader->m_border = config.readNumEntry( "Margin", 6 ); |
408 | #ifdef REPALM | 408 | #ifdef REPALM |
409 | reader->brepalm = config.readBoolEntry( "Repalm", true ); | 409 | reader->brepalm = config.readBoolEntry( "Repalm", true ); |
410 | #endif | 410 | #endif |
411 | reader->bremap = config.readBoolEntry( "Remap", true ); | 411 | reader->bremap = config.readBoolEntry( "Remap", true ); |
412 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | 412 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); |
413 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | 413 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); |
414 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 414 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
415 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 415 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
416 | #ifdef _SCROLLPIPE | 416 | #ifdef _SCROLLPIPE |
417 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); | 417 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); |
418 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); | 418 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); |
419 | #endif | 419 | #endif |
420 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | 420 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); |
421 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | 421 | m_doAnnotation = config.readBoolEntry( "Annotation", false); |
422 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | 422 | m_doDictionary = config.readBoolEntry( "Dictionary", false); |
423 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | 423 | m_doClipboard = config.readBoolEntry( "Clipboard", false); |
424 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | 424 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); |
425 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); | 425 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); |
426 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); | 426 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); |
427 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); | 427 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); |
428 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); | 428 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); |
429 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); | 429 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); |
430 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | 430 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); |
431 | 431 | ||
432 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | 432 | m_leftScroll = config.readBoolEntry("LeftScroll", false); |
433 | m_rightScroll = config.readBoolEntry("RightScroll", false); | 433 | m_rightScroll = config.readBoolEntry("RightScroll", false); |
434 | m_upScroll = config.readBoolEntry("UpScroll", true); | 434 | m_upScroll = config.readBoolEntry("UpScroll", true); |
435 | m_downScroll = config.readBoolEntry("DownScroll", true); | 435 | m_downScroll = config.readBoolEntry("DownScroll", true); |
436 | 436 | ||
437 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); | 437 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); |
438 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); | 438 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); |
439 | 439 | ||
440 | #ifndef USEQPE | 440 | #ifndef USEQPE |
441 | config.setGroup( "Geometry" ); | 441 | config.setGroup( "Geometry" ); |
442 | setGeometry(0,0, | 442 | setGeometry(0,0, |
443 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), | 443 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), |
444 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); | 444 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); |
445 | move( | 445 | move( |
446 | config.readNumEntry( "x", 20 ), | 446 | config.readNumEntry( "x", 20 ), |
447 | config.readNumEntry( "y", 20 )); | 447 | config.readNumEntry( "y", 20 )); |
448 | #endif | 448 | #endif |
449 | 449 | ||
450 | 450 | ||
451 | 451 | ||
452 | setTwoTouch(m_twoTouch); | 452 | setTwoTouch(m_twoTouch); |
453 | 453 | ||
454 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); | 454 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); |
455 | 455 | ||
456 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); | 456 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); |
457 | connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) ); | 457 | connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) ); |
458 | connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) ); | 458 | connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) ); |
459 | editorStack->addWidget( reader, get_unique_id() ); | 459 | editorStack->addWidget( reader, get_unique_id() ); |
460 | 460 | ||
461 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); | 461 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); |
462 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); | 462 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); |
463 | m_preferences_action->addTo( settings ); | 463 | m_preferences_action->addTo( settings ); |
464 | 464 | ||
465 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); | 465 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); |
466 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); | 466 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); |
467 | m_saveconfig_action->addTo( settings ); | 467 | m_saveconfig_action->addTo( settings ); |
468 | 468 | ||
469 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); | 469 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); |
470 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); | 470 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); |
471 | m_loadconfig_action->addTo( settings ); | 471 | m_loadconfig_action->addTo( settings ); |
472 | 472 | ||
473 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); | 473 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); |
474 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); | 474 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); |
475 | m_tidyconfig_action->addTo( settings ); | 475 | m_tidyconfig_action->addTo( settings ); |
476 | 476 | ||
477 | settings->insertSeparator(); | 477 | settings->insertSeparator(); |
478 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); | 478 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); |
479 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); | 479 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); |
480 | m_toolbarprefs_action->addTo( settings ); | 480 | m_toolbarprefs_action->addTo( settings ); |
481 | 481 | ||
482 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); | 482 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); |
483 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 483 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
484 | m_open_action->addTo( file ); | 484 | m_open_action->addTo( file ); |
485 | 485 | ||
486 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); | 486 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); |
487 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); | 487 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); |
488 | m_close_action->addTo( file ); | 488 | m_close_action->addTo( file ); |
489 | 489 | ||
490 | #ifdef _SCRIPT | 490 | #ifdef _SCRIPT |
491 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); | 491 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); |
492 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); | 492 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); |
493 | a->addTo( file ); | 493 | a->addTo( file ); |
494 | #endif | 494 | #endif |
495 | /* | 495 | /* |
496 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); | 496 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); |
497 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); | 497 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); |
498 | a->addTo( file ); | 498 | a->addTo( file ); |
499 | 499 | ||
500 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); | 500 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); |
501 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 501 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
502 | a->addTo( filebar() ); | 502 | a->addTo( filebar() ); |
503 | a->addTo( edit ); | 503 | a->addTo( edit ); |
504 | */ | 504 | */ |
505 | 505 | ||
506 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); | 506 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); |
507 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); | 507 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); |
508 | m_info_action->addTo( file ); | 508 | m_info_action->addTo( file ); |
509 | 509 | ||
510 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); | 510 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); |
511 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); | 511 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); |
512 | m_touch_action->setOn(m_twoTouch); | 512 | m_touch_action->setOn(m_twoTouch); |
513 | m_touch_action->addTo( file ); | 513 | m_touch_action->addTo( file ); |
514 | 514 | ||
515 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); | 515 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); |
516 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 516 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
517 | file->insertSeparator(); | 517 | file->insertSeparator(); |
518 | // a->addTo( bar ); | 518 | // a->addTo( bar ); |
519 | m_find_action->addTo( file ); | 519 | m_find_action->addTo( file ); |
520 | 520 | ||
521 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); | 521 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); |
522 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); | 522 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); |
523 | m_exportlinks_action->addTo( file ); | 523 | m_exportlinks_action->addTo( file ); |
524 | 524 | ||
525 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); | 525 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); |
526 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); | 526 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); |
527 | m_scrollButton->addTo(navigation); | 527 | m_scrollButton->addTo(navigation); |
528 | m_scrollButton->setOn(false); | 528 | m_scrollButton->setOn(false); |
529 | 529 | ||
530 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); | 530 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); |
531 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); | 531 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); |
532 | m_start_action->addTo(navigation); | 532 | m_start_action->addTo(navigation); |
533 | 533 | ||
534 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); | 534 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); |
535 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); | 535 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); |
536 | m_end_action->addTo(navigation); | 536 | m_end_action->addTo(navigation); |
537 | 537 | ||
538 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); | 538 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); |
539 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); | 539 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); |
540 | m_jump_action->addTo(navigation); | 540 | m_jump_action->addTo(navigation); |
541 | 541 | ||
diff --git a/noncore/apps/opie-reader/QTReaderApp.h b/noncore/apps/opie-reader/QTReaderApp.h index 2765d47..86c14b1 100644 --- a/noncore/apps/opie-reader/QTReaderApp.h +++ b/noncore/apps/opie-reader/QTReaderApp.h | |||
@@ -1,442 +1,442 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef __QTREADERAPP_H | 20 | #ifndef __QTREADERAPP_H |
21 | #define __QTREADERAPP_H | 21 | #define __QTREADERAPP_H |
22 | 22 | ||
23 | //#define _SCROLLPIPE | 23 | //#define _SCROLLPIPE |
24 | //#define __ISEARCH | 24 | //#define __ISEARCH |
25 | 25 | ||
26 | //#define MAX_ENCODING 6 | 26 | //#define MAX_ENCODING 6 |
27 | #define MAX_ACTIONS 5 | 27 | #define MAX_ACTIONS 5 |
28 | 28 | ||
29 | #include "useqpe.h" | 29 | #include "useqpe.h" |
30 | #include <sys/timeb.h> | 30 | #include <sys/timeb.h> |
31 | #include <qmainwindow.h> | 31 | #include <qmainwindow.h> |
32 | #include "CExpander.h" | 32 | #include "CExpander.h" |
33 | #include "CEncoding.h" | 33 | #include "CEncoding.h" |
34 | #include <qlist.h> | 34 | #include <qlist.h> |
35 | //#include <qpe/filemanager.h> | 35 | //#include <qpe/filemanager.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | #include <qstack.h> | 38 | #include <qstack.h> |
39 | #include <qlistbox.h> | 39 | #include <qlistbox.h> |
40 | //#include "Queue.h" | 40 | //#include "Queue.h" |
41 | 41 | ||
42 | class QWidgetStack; | 42 | class QWidgetStack; |
43 | class QToolButton; | 43 | class QToolButton; |
44 | class QPopupMenu; | 44 | class QPopupMenu; |
45 | class QToolBar; | 45 | class QToolBar; |
46 | #ifdef USEQPE | 46 | #ifdef USEQPE |
47 | class QPEToolBar; | 47 | class QPEToolBar; |
48 | class QPEMenuBar; | 48 | class QMenuBar; |
49 | #endif | 49 | #endif |
50 | class CBkmkSelector; | 50 | class CBkmkSelector; |
51 | class QProgressBar; | 51 | class QProgressBar; |
52 | class QAction; | 52 | class QAction; |
53 | class CAnnoEdit; | 53 | class CAnnoEdit; |
54 | class QFloatBar; | 54 | class QFloatBar; |
55 | class CDrawBuffer; | 55 | class CDrawBuffer; |
56 | class QTReader; | 56 | class QTReader; |
57 | class QImage; | 57 | class QImage; |
58 | class Config; | 58 | class Config; |
59 | 59 | ||
60 | enum ActionTypes | 60 | enum ActionTypes |
61 | { | 61 | { |
62 | cesNone = 0, | 62 | cesNone = 0, |
63 | cesOpenFile, | 63 | cesOpenFile, |
64 | cesAutoScroll, | 64 | cesAutoScroll, |
65 | cesActionMark, | 65 | cesActionMark, |
66 | cesActionAnno, | 66 | cesActionAnno, |
67 | cesFullScreen, | 67 | cesFullScreen, |
68 | cesZoomIn, | 68 | cesZoomIn, |
69 | cesZoomOut, | 69 | cesZoomOut, |
70 | cesBack, | 70 | cesBack, |
71 | cesForward, | 71 | cesForward, |
72 | cesHome, | 72 | cesHome, |
73 | cesPageUp, | 73 | cesPageUp, |
74 | cesPageDown, | 74 | cesPageDown, |
75 | cesLineUp, | 75 | cesLineUp, |
76 | cesLineDown, | 76 | cesLineDown, |
77 | cesStartDoc, | 77 | cesStartDoc, |
78 | cesEndDoc | 78 | cesEndDoc |
79 | }; | 79 | }; |
80 | /* | 80 | /* |
81 | *m_preferences_action, *m_close_action *m_info_action, *m_touch_action, | 81 | *m_preferences_action, *m_close_action *m_info_action, *m_touch_action, |
82 | *m_find_action, *m_jump_action, *m_setfont_action *m_goto_action, | 82 | *m_find_action, *m_jump_action, *m_setfont_action *m_goto_action, |
83 | *m_delete_action; *m_autogen_action, *m_clear_action, *m_save_action; | 83 | *m_delete_action; *m_autogen_action, *m_clear_action, *m_save_action; |
84 | *m_tidy_action, *m_startBlock_action, *m_endBlock_action; | 84 | *m_tidy_action, *m_startBlock_action, *m_endBlock_action; |
85 | *m_setenc_action, *m_setmono_action; | 85 | *m_setenc_action, *m_setmono_action; |
86 | */ | 86 | */ |
87 | enum ToolbarPolicy | 87 | enum ToolbarPolicy |
88 | { | 88 | { |
89 | cesSingle = 0, | 89 | cesSingle = 0, |
90 | cesMenuTool, | 90 | cesMenuTool, |
91 | cesMultiple | 91 | cesMultiple |
92 | }; | 92 | }; |
93 | 93 | ||
94 | enum regedit_type | 94 | enum regedit_type |
95 | { | 95 | { |
96 | cAutoGen, | 96 | cAutoGen, |
97 | cAddBkmk, | 97 | cAddBkmk, |
98 | cJump, | 98 | cJump, |
99 | cMonoSpace, | 99 | cMonoSpace, |
100 | cSetTarget, | 100 | cSetTarget, |
101 | #ifdef _SCROLLPIPE | 101 | #ifdef _SCROLLPIPE |
102 | cSetPipeTarget, | 102 | cSetPipeTarget, |
103 | #endif | 103 | #endif |
104 | cSetConfigName, | 104 | cSetConfigName, |
105 | cMargin, | 105 | cMargin, |
106 | cExtraSpace, | 106 | cExtraSpace, |
107 | cExtraLead | 107 | cExtraLead |
108 | }; | 108 | }; |
109 | 109 | ||
110 | enum bkmk_action | 110 | enum bkmk_action |
111 | { | 111 | { |
112 | cOpenFile, | 112 | cOpenFile, |
113 | cGotoBkmk, | 113 | cGotoBkmk, |
114 | cDelBkmk, | 114 | cDelBkmk, |
115 | cRmBkmkFile, | 115 | cRmBkmkFile, |
116 | cLdConfig, | 116 | cLdConfig, |
117 | cRmConfig, | 117 | cRmConfig, |
118 | cExportLinks | 118 | cExportLinks |
119 | }; | 119 | }; |
120 | 120 | ||
121 | enum fontselector_action | 121 | enum fontselector_action |
122 | { | 122 | { |
123 | cChooseFont, | 123 | cChooseFont, |
124 | cChooseEncoding | 124 | cChooseEncoding |
125 | }; | 125 | }; |
126 | 126 | ||
127 | #ifdef __ISEARCH | 127 | #ifdef __ISEARCH |
128 | struct searchrecord | 128 | struct searchrecord |
129 | { | 129 | { |
130 | QString s; | 130 | QString s; |
131 | size_t pos; | 131 | size_t pos; |
132 | searchrecord(const QString& _s, size_t _pos) : s(_s), pos(_pos) {} | 132 | searchrecord(const QString& _s, size_t _pos) : s(_s), pos(_pos) {} |
133 | }; | 133 | }; |
134 | #endif | 134 | #endif |
135 | 135 | ||
136 | class infowin; | 136 | class infowin; |
137 | class GraphicWin; | 137 | class GraphicWin; |
138 | 138 | ||
139 | class QTReaderApp : public QMainWindow | 139 | class QTReaderApp : public QMainWindow |
140 | { | 140 | { |
141 | Q_OBJECT | 141 | Q_OBJECT |
142 | 142 | ||
143 | unsigned long m_savedpos; | 143 | unsigned long m_savedpos; |
144 | int m_debounce; | 144 | int m_debounce; |
145 | timeb m_lastkeytime; | 145 | timeb m_lastkeytime; |
146 | bool m_annoIsEditing; | 146 | bool m_annoIsEditing; |
147 | bool m_propogatefontchange, m_bFloatingDialog; | 147 | bool m_propogatefontchange, m_bFloatingDialog; |
148 | bool m_url_clipboard, m_url_localfile, m_url_globalfile; | 148 | bool m_url_clipboard, m_url_localfile, m_url_globalfile; |
149 | fontselector_action m_fontAction; | 149 | fontselector_action m_fontAction; |
150 | void doAction(ActionTypes a, QKeyEvent* e); | 150 | void doAction(ActionTypes a, QKeyEvent* e); |
151 | 151 | ||
152 | public: | 152 | public: |
153 | QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 153 | QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
154 | ~QTReaderApp(); | 154 | ~QTReaderApp(); |
155 | 155 | ||
156 | void handlekey(QKeyEvent* e); | 156 | void handlekey(QKeyEvent* e); |
157 | void hideEvent(QHideEvent*) | 157 | void hideEvent(QHideEvent*) |
158 | { | 158 | { |
159 | suspend(); | 159 | suspend(); |
160 | } | 160 | } |
161 | 161 | ||
162 | void suspend(); | 162 | void suspend(); |
163 | void openFile( const QString & ); | 163 | void openFile( const QString & ); |
164 | 164 | ||
165 | void setScrollState(bool _b); | 165 | void setScrollState(bool _b); |
166 | 166 | ||
167 | protected: | 167 | protected: |
168 | void setfontHelper(const QString& lcn, int size = 0); | 168 | void setfontHelper(const QString& lcn, int size = 0); |
169 | QAction* m_bkmkAvail, *m_actFullscreen; | 169 | QAction* m_bkmkAvail, *m_actFullscreen; |
170 | CAnnoEdit* m_annoWin; | 170 | CAnnoEdit* m_annoWin; |
171 | Bkmk* m_anno; | 171 | Bkmk* m_anno; |
172 | // void resizeEvent(QResizeEvent* e); | 172 | // void resizeEvent(QResizeEvent* e); |
173 | void closeEvent( QCloseEvent *e ); | 173 | void closeEvent( QCloseEvent *e ); |
174 | void readbkmks(); | 174 | void readbkmks(); |
175 | void do_mono(const QString&); | 175 | void do_mono(const QString&); |
176 | void do_jump(const QString&); | 176 | void do_jump(const QString&); |
177 | void do_settarget(const QString&); | 177 | void do_settarget(const QString&); |
178 | #ifdef _SCROLLPIPE | 178 | #ifdef _SCROLLPIPE |
179 | //void do_setpipetarget(const QString&); | 179 | //void do_setpipetarget(const QString&); |
180 | #endif | 180 | #endif |
181 | void do_saveconfig(const QString&, bool); | 181 | void do_saveconfig(const QString&, bool); |
182 | bool readconfig(const QString&, bool); | 182 | bool readconfig(const QString&, bool); |
183 | bool PopulateConfig(const char*); | 183 | bool PopulateConfig(const char*); |
184 | ActionTypes ActNameToInt(const QString&); | 184 | ActionTypes ActNameToInt(const QString&); |
185 | bool m_doAnnotation; | 185 | bool m_doAnnotation; |
186 | bool m_doDictionary; | 186 | bool m_doDictionary; |
187 | bool m_doClipboard; | 187 | bool m_doClipboard; |
188 | bool m_fullscreen; | 188 | bool m_fullscreen; |
189 | bool m_loadedconfig; | 189 | bool m_loadedconfig; |
190 | public: | 190 | public: |
191 | void saveprefs(); | 191 | void saveprefs(); |
192 | public slots: | 192 | public slots: |
193 | void setDocument(const QString&); | 193 | void setDocument(const QString&); |
194 | private slots: | 194 | private slots: |
195 | #ifdef _SCRIPT | 195 | #ifdef _SCRIPT |
196 | // void RunScript(); | 196 | // void RunScript(); |
197 | #endif | 197 | #endif |
198 | void SaveConfig(); | 198 | void SaveConfig(); |
199 | void LoadConfig(); | 199 | void LoadConfig(); |
200 | void TidyConfig(); | 200 | void TidyConfig(); |
201 | void ExportLinks(); | 201 | void ExportLinks(); |
202 | void zoomin(); | 202 | void zoomin(); |
203 | void zoomout(); | 203 | void zoomout(); |
204 | void chooseencoding(); | 204 | void chooseencoding(); |
205 | void setfullscreen(bool sfs); | 205 | void setfullscreen(bool sfs); |
206 | // void setcontinuous(bool sfs); | 206 | // void setcontinuous(bool sfs); |
207 | void setTwoTouch(bool _b); | 207 | void setTwoTouch(bool _b); |
208 | void restoreFocus(); | 208 | void restoreFocus(); |
209 | void OnAnnotation(bool _b) | 209 | void OnAnnotation(bool _b) |
210 | { | 210 | { |
211 | m_doAnnotation = _b; | 211 | m_doAnnotation = _b; |
212 | } | 212 | } |
213 | void OnDictionary(bool _b) | 213 | void OnDictionary(bool _b) |
214 | { | 214 | { |
215 | m_doDictionary = _b; | 215 | m_doDictionary = _b; |
216 | } | 216 | } |
217 | void OnClipboard(bool _b) | 217 | void OnClipboard(bool _b) |
218 | { | 218 | { |
219 | m_doClipboard = _b; | 219 | m_doClipboard = _b; |
220 | } | 220 | } |
221 | void OnWordSelected(const QString&, size_t, const QString&); | 221 | void OnWordSelected(const QString&, size_t, const QString&); |
222 | void OnURLSelected(const QString& href); | 222 | void OnURLSelected(const QString& href); |
223 | void showgraphic(QImage&); | 223 | void showgraphic(QImage&); |
224 | void addAnno(const QString&, const QString&, size_t); | 224 | void addAnno(const QString&, const QString&, size_t); |
225 | void addAnno(const QString&, const QString&); | 225 | void addAnno(const QString&, const QString&); |
226 | void addanno(); | 226 | void addanno(); |
227 | void showAnnotation(); | 227 | void showAnnotation(); |
228 | void do_setencoding(int i); | 228 | void do_setencoding(int i); |
229 | void do_setfont(const QString&); | 229 | void do_setfont(const QString&); |
230 | void buttonActionSelected(QAction*); | 230 | void buttonActionSelected(QAction*); |
231 | //void msgHandler(const QCString&, const QByteArray&); | 231 | //void msgHandler(const QCString&, const QByteArray&); |
232 | void monospace(bool); | 232 | void monospace(bool); |
233 | void jump(); | 233 | void jump(); |
234 | void settarget(); | 234 | void settarget(); |
235 | #ifdef _SCROLLPIPE | 235 | #ifdef _SCROLLPIPE |
236 | //void setpipetarget(); | 236 | //void setpipetarget(); |
237 | //void setpause(bool); | 237 | //void setpause(bool); |
238 | #endif | 238 | #endif |
239 | //void setspacing(); | 239 | //void setspacing(); |
240 | void setfont(); | 240 | void setfont(); |
241 | void clearBkmkList(); | 241 | void clearBkmkList(); |
242 | void listBkmkFiles(); | 242 | void listBkmkFiles(); |
243 | void editMark(); | 243 | void editMark(); |
244 | void autoScroll(bool); | 244 | void autoScroll(bool); |
245 | void addbkmk(); | 245 | void addbkmk(); |
246 | void savebkmks(); | 246 | void savebkmks(); |
247 | //void importFiles(); | 247 | //void importFiles(); |
248 | void showprefs(); | 248 | void showprefs(); |
249 | void showtoolbarprefs(); | 249 | void showtoolbarprefs(); |
250 | void infoClose(); | 250 | void infoClose(); |
251 | // void oldFile(); | 251 | // void oldFile(); |
252 | void showinfo(); | 252 | void showinfo(); |
253 | 253 | ||
254 | // void indentplus(); | 254 | // void indentplus(); |
255 | // void indentminus(); | 255 | // void indentminus(); |
256 | 256 | ||
257 | void fileOpen(); | 257 | void fileOpen(); |
258 | void fileClose(); | 258 | void fileClose(); |
259 | 259 | ||
260 | void editCopy(); | 260 | void editCopy(); |
261 | void editFind(); | 261 | void editFind(); |
262 | 262 | ||
263 | void gotoStart(); | 263 | void gotoStart(); |
264 | void gotoEnd(); | 264 | void gotoEnd(); |
265 | 265 | ||
266 | void pageup(); | 266 | void pageup(); |
267 | void pagedn(); | 267 | void pagedn(); |
268 | 268 | ||
269 | void findNext(); | 269 | void findNext(); |
270 | void findClose(); | 270 | void findClose(); |
271 | 271 | ||
272 | void regClose(); | 272 | void regClose(); |
273 | 273 | ||
274 | #ifdef __ISEARCH | 274 | #ifdef __ISEARCH |
275 | // void search( const QString& ); | 275 | // void search( const QString& ); |
276 | #else | 276 | #else |
277 | void search(); | 277 | void search(); |
278 | #endif | 278 | #endif |
279 | 279 | ||
280 | void showEditTools(); | 280 | void showEditTools(); |
281 | 281 | ||
282 | // void stripcr(bool); | 282 | // void stripcr(bool); |
283 | // void setfulljust(bool); | 283 | // void setfulljust(bool); |
284 | // void onespace(bool); | 284 | // void onespace(bool); |
285 | #ifdef REPALM | 285 | #ifdef REPALM |
286 | // void repalm(bool); | 286 | // void repalm(bool); |
287 | #endif | 287 | #endif |
288 | // void peanut(bool _b); | 288 | // void peanut(bool _b); |
289 | // void remap(bool); | 289 | // void remap(bool); |
290 | // void embolden(bool); | 290 | // void embolden(bool); |
291 | // void autofmt(bool); | 291 | // void autofmt(bool); |
292 | // void textfmt(bool); | 292 | // void textfmt(bool); |
293 | // void striphtml(bool); | 293 | // void striphtml(bool); |
294 | // void dehyphen(bool); | 294 | // void dehyphen(bool); |
295 | // void depluck(bool); | 295 | // void depluck(bool); |
296 | // void dejpluck(bool); | 296 | // void dejpluck(bool); |
297 | // void unindent(bool); | 297 | // void unindent(bool); |
298 | // void repara(bool); | 298 | // void repara(bool); |
299 | // void dblspce(bool); | 299 | // void dblspce(bool); |
300 | void pagemode(bool); | 300 | void pagemode(bool); |
301 | // void gotobkmk(const QString& bm); | 301 | // void gotobkmk(const QString& bm); |
302 | void gotobkmk(int); | 302 | void gotobkmk(int); |
303 | void cancelbkmk(); | 303 | void cancelbkmk(); |
304 | void do_gotomark(); | 304 | void do_gotomark(); |
305 | void do_delmark(); | 305 | void do_delmark(); |
306 | void do_autogen(); | 306 | void do_autogen(); |
307 | void do_regaction(); | 307 | void do_regaction(); |
308 | void OnRedraw(); | 308 | void OnRedraw(); |
309 | 309 | ||
310 | private: | 310 | private: |
311 | void writeUrl(const QString& file, const QString& href); | 311 | void writeUrl(const QString& file, const QString& href); |
312 | QAction *m_preferences_action, *m_open_action, *m_close_action; | 312 | QAction *m_preferences_action, *m_open_action, *m_close_action; |
313 | QAction *m_info_action, *m_touch_action, *m_find_action, *m_start_action; | 313 | QAction *m_info_action, *m_touch_action, *m_find_action, *m_start_action; |
314 | QAction *m_end_action, *m_jump_action, *m_pageline_action; | 314 | QAction *m_end_action, *m_jump_action, *m_pageline_action; |
315 | QAction *m_pageup_action, *m_pagedn_action, *m_back_action; | 315 | QAction *m_pageup_action, *m_pagedn_action, *m_back_action; |
316 | QAction *m_home_action, *m_forward_action, *m_zoomin_action; | 316 | QAction *m_home_action, *m_forward_action, *m_zoomin_action; |
317 | QAction *m_zoomout_action, *m_setfont_action, *m_mark_action; | 317 | QAction *m_zoomout_action, *m_setfont_action, *m_mark_action; |
318 | QAction *m_annotate_action, *m_goto_action, *m_delete_action; | 318 | QAction *m_annotate_action, *m_goto_action, *m_delete_action; |
319 | QAction *m_autogen_action, *m_clear_action, *m_save_action; | 319 | QAction *m_autogen_action, *m_clear_action, *m_save_action; |
320 | QAction *m_tidy_action, *m_startBlock_action, *m_endBlock_action; | 320 | QAction *m_tidy_action, *m_startBlock_action, *m_endBlock_action; |
321 | QAction *m_setenc_action, *m_setmono_action, *m_saveconfig_action; | 321 | QAction *m_setenc_action, *m_setmono_action, *m_saveconfig_action; |
322 | QAction *m_loadconfig_action, *m_toolbarprefs_action, *m_tidyconfig_action; | 322 | QAction *m_loadconfig_action, *m_toolbarprefs_action, *m_tidyconfig_action; |
323 | QAction *m_exportlinks_action; | 323 | QAction *m_exportlinks_action; |
324 | void addtoolbars(Config* config); | 324 | void addtoolbars(Config* config); |
325 | ToolbarPolicy m_tbpol, m_tbpolsave; | 325 | ToolbarPolicy m_tbpol, m_tbpolsave; |
326 | ToolBarDock m_tbposition; | 326 | ToolBarDock m_tbposition; |
327 | bool m_tbmove, m_tbmovesave; | 327 | bool m_tbmove, m_tbmovesave; |
328 | QToolBar* filebar(); | 328 | QToolBar* filebar(); |
329 | QToolBar* viewbar(); | 329 | QToolBar* viewbar(); |
330 | QToolBar* navbar(); | 330 | QToolBar* navbar(); |
331 | QToolBar* markbar(); | 331 | QToolBar* markbar(); |
332 | void hidetoolbars(); | 332 | void hidetoolbars(); |
333 | void addfilebar(Config* _config, const QString& key, QAction* a); | 333 | void addfilebar(Config* _config, const QString& key, QAction* a); |
334 | void addviewbar(Config* _config, const QString& key, QAction* a); | 334 | void addviewbar(Config* _config, const QString& key, QAction* a); |
335 | void addnavbar(Config* _config, const QString& key, QAction* a); | 335 | void addnavbar(Config* _config, const QString& key, QAction* a); |
336 | void addmarkbar(Config* _config, const QString& key, QAction* a); | 336 | void addmarkbar(Config* _config, const QString& key, QAction* a); |
337 | bool checkbar(Config* _config, const QString& key); | 337 | bool checkbar(Config* _config, const QString& key); |
338 | #ifdef _SCRIPT | 338 | #ifdef _SCRIPT |
339 | void SaveScript(const char* sname); | 339 | void SaveScript(const char* sname); |
340 | #endif | 340 | #endif |
341 | /* | 341 | /* |
342 | void setstate(unsigned char* _sd, unsigned short _sdlen); | 342 | void setstate(unsigned char* _sd, unsigned short _sdlen); |
343 | void getstate(unsigned char*& data, unsigned short& len); | 343 | void getstate(unsigned char*& data, unsigned short& len); |
344 | */ | 344 | */ |
345 | void fileOpen2(); | 345 | void fileOpen2(); |
346 | void readfilelist(); | 346 | void readfilelist(); |
347 | void savefilelist(); | 347 | void savefilelist(); |
348 | void updatefileinfo(); | 348 | void updatefileinfo(); |
349 | bool openfrombkmk(Bkmk*); | 349 | bool openfrombkmk(Bkmk*); |
350 | QString m_targetapp, m_targetmsg; | 350 | QString m_targetapp, m_targetmsg; |
351 | bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null); | 351 | bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null); |
352 | QString usefilebrowser(); | 352 | QString usefilebrowser(); |
353 | void do_regedit(); | 353 | void do_regedit(); |
354 | void colorChanged( const QColor &c ); | 354 | void colorChanged( const QColor &c ); |
355 | void clear(); | 355 | void clear(); |
356 | void updateCaption(); | 356 | void updateCaption(); |
357 | void do_autogen(const QString&); | 357 | void do_autogen(const QString&); |
358 | void do_addbkmk(const QString&); | 358 | void do_addbkmk(const QString&); |
359 | bool findNextBookmark(size_t start); | 359 | bool findNextBookmark(size_t start); |
360 | 360 | ||
361 | private: | 361 | private: |
362 | 362 | ||
363 | QAction* m_scrollButton; | 363 | QAction* m_scrollButton; |
364 | 364 | ||
365 | QAction* m_buttonAction[MAX_ACTIONS]; | 365 | QAction* m_buttonAction[MAX_ACTIONS]; |
366 | 366 | ||
367 | CBkmkSelector* bkmkselector; | 367 | CBkmkSelector* bkmkselector; |
368 | 368 | ||
369 | ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget, | 369 | ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget, |
370 | m_upTarget, m_downTarget; | 370 | m_upTarget, m_downTarget; |
371 | bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll; | 371 | bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll; |
372 | bool m_bcloseDisabled, m_disableesckey; | 372 | bool m_bcloseDisabled, m_disableesckey; |
373 | size_t searchStart; | 373 | size_t searchStart; |
374 | #ifdef __ISEARCH | 374 | #ifdef __ISEARCH |
375 | QStack<searchrecord>* searchStack; | 375 | QStack<searchrecord>* searchStack; |
376 | bool dosearch(size_t start, CDrawBuffer& test, const QString& arg); | 376 | bool dosearch(size_t start, CDrawBuffer& test, const QString& arg); |
377 | #else | 377 | #else |
378 | bool dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg); | 378 | bool dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg); |
379 | #endif | 379 | #endif |
380 | QWidgetStack *editorStack; | 380 | QWidgetStack *editorStack; |
381 | QTReader* reader; | 381 | QTReader* reader; |
382 | QComboBox* m_fontSelector; | 382 | QComboBox* m_fontSelector; |
383 | // QPEToolBar /* *menu,*/ *fileBar; | 383 | // QPEToolBar /* *menu,*/ *fileBar; |
384 | QToolBar *menubar, *fileBar, *navBar, *viewBar, *markBar; | 384 | QToolBar *menubar, *fileBar, *navBar, *viewBar, *markBar; |
385 | #ifdef USEQPE | 385 | #ifdef USEQPE |
386 | QPEMenuBar *mb; | 386 | QMenuBar *mb; |
387 | #else | 387 | #else |
388 | QMenuBar *mb; | 388 | QMenuBar *mb; |
389 | #endif | 389 | #endif |
390 | QFloatBar *searchBar, *regBar/*, *m_fontBar*/; | 390 | QFloatBar *searchBar, *regBar/*, *m_fontBar*/; |
391 | QToolBar /* *searchBar, *regBar,*/ *m_fontBar; | 391 | QToolBar /* *searchBar, *regBar,*/ *m_fontBar; |
392 | QLineEdit *searchEdit, *regEdit; | 392 | QLineEdit *searchEdit, *regEdit; |
393 | bool searchVisible; | 393 | bool searchVisible; |
394 | bool regVisible; | 394 | bool regVisible; |
395 | bool m_fontVisible, m_twoTouch; | 395 | bool m_fontVisible, m_twoTouch; |
396 | bool bFromDocView; | 396 | bool bFromDocView; |
397 | static unsigned long m_uid; | 397 | static unsigned long m_uid; |
398 | long unsigned get_unique_id() { return m_uid++; } | 398 | long unsigned get_unique_id() { return m_uid++; } |
399 | /* | 399 | /* |
400 | void resizeEvent( QResizeEvent * r) | 400 | void resizeEvent( QResizeEvent * r) |
401 | { | 401 | { |
402 | // qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height()); | 402 | // qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height()); |
403 | // qDebug("resize:(%u,%u)", r->size().width(), r->size().height()); | 403 | // qDebug("resize:(%u,%u)", r->size().width(), r->size().height()); |
404 | // bgroup->move( width()-bgroup->width(), 0 ); | 404 | // bgroup->move( width()-bgroup->width(), 0 ); |
405 | } | 405 | } |
406 | */ | 406 | */ |
407 | CList<Bkmk>* pBkmklist; | 407 | CList<Bkmk>* pBkmklist; |
408 | CList<Bkmk>* pOpenlist; | 408 | CList<Bkmk>* pOpenlist; |
409 | infowin* m_infoWin; | 409 | infowin* m_infoWin; |
410 | GraphicWin* m_graphicwin; | 410 | GraphicWin* m_graphicwin; |
411 | QProgressBar* pbar; | 411 | QProgressBar* pbar; |
412 | bool m_fBkmksChanged; | 412 | bool m_fBkmksChanged; |
413 | // int m_nRegAction; | 413 | // int m_nRegAction; |
414 | regedit_type m_nRegAction; | 414 | regedit_type m_nRegAction; |
415 | bkmk_action m_nBkmkAction; | 415 | bkmk_action m_nBkmkAction; |
416 | QString m_autogenstr; | 416 | QString m_autogenstr; |
417 | bool m_dontSave; | 417 | bool m_dontSave; |
418 | }; | 418 | }; |
419 | 419 | ||
420 | //const int cAutoGen = 0; | 420 | //const int cAutoGen = 0; |
421 | //const int cAddBkmk = 1; | 421 | //const int cAddBkmk = 1; |
422 | //const int cDelBkmk = 2; | 422 | //const int cDelBkmk = 2; |
423 | //const int cGotoBkmk = 3; | 423 | //const int cGotoBkmk = 3; |
424 | //const int cRmBkmkFile = 4; | 424 | //const int cRmBkmkFile = 4; |
425 | //const int cJump = 5; | 425 | //const int cJump = 5; |
426 | //const int cMonoSpace = 6; | 426 | //const int cMonoSpace = 6; |
427 | //const int cOverlap = 7; | 427 | //const int cOverlap = 7; |
428 | //const int cSetTarget = 8; | 428 | //const int cSetTarget = 8; |
429 | //const int cOpenFile = 9; | 429 | //const int cOpenFile = 9; |
430 | //const int cSetPipeTarget = 10; | 430 | //const int cSetPipeTarget = 10; |
431 | //const int cSetConfigName = 11; | 431 | //const int cSetConfigName = 11; |
432 | //const int cMargin = 12; | 432 | //const int cMargin = 12; |
433 | //const int cExtraSpace = 14; | 433 | //const int cExtraSpace = 14; |
434 | //const int cExtraLead = 15; | 434 | //const int cExtraLead = 15; |
435 | //const int cGfxSize = 16; | 435 | //const int cGfxSize = 16; |
436 | //const int cChooseFont = 2; | 436 | //const int cChooseFont = 2; |
437 | //const int cChooseEncoding = 1; | 437 | //const int cChooseEncoding = 1; |
438 | 438 | ||
439 | #endif | 439 | #endif |
440 | 440 | ||
441 | 441 | ||
442 | 442 | ||
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index 3915e52..fb2ca79 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp | |||
@@ -108,513 +108,513 @@ void MainWindow::documentSave(DocLnk *lnkDoc) | |||
108 | documentModified=FALSE; | 108 | documentModified=FALSE; |
109 | } | 109 | } |
110 | 110 | ||
111 | void MainWindow::documentOpen(const DocLnk &lnkDoc) | 111 | void MainWindow::documentOpen(const DocLnk &lnkDoc) |
112 | { | 112 | { |
113 | FileManager fm; | 113 | FileManager fm; |
114 | QByteArray streamBuffer; | 114 | QByteArray streamBuffer; |
115 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) | 115 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) |
116 | { | 116 | { |
117 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); | 117 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); |
118 | documentModified=FALSE; | 118 | documentModified=FALSE; |
119 | selectorFileNew(DocLnk()); | 119 | selectorFileNew(DocLnk()); |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | QDataStream stream(streamBuffer, IO_ReadOnly); | 122 | QDataStream stream(streamBuffer, IO_ReadOnly); |
123 | 123 | ||
124 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; | 124 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; |
125 | typeSheet *newSheet; | 125 | typeSheet *newSheet; |
126 | typeCellData *newCell; | 126 | typeCellData *newCell; |
127 | 127 | ||
128 | char fileFormat[7]; | 128 | char fileFormat[7]; |
129 | stream.readRawBytes(fileFormat, 6); | 129 | stream.readRawBytes(fileFormat, 6); |
130 | fileFormat[6]=0; | 130 | fileFormat[6]=0; |
131 | if ((QString)fileFormat!="SQT100") | 131 | if ((QString)fileFormat!="SQT100") |
132 | { | 132 | { |
133 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); | 133 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); |
134 | documentModified=FALSE; | 134 | documentModified=FALSE; |
135 | selectorFileNew(DocLnk()); | 135 | selectorFileNew(DocLnk()); |
136 | return; | 136 | return; |
137 | } | 137 | } |
138 | 138 | ||
139 | stream >> countSheet; | 139 | stream >> countSheet; |
140 | for (i=0; i<countSheet; ++i) | 140 | for (i=0; i<countSheet; ++i) |
141 | { | 141 | { |
142 | newSheet=new typeSheet; | 142 | newSheet=new typeSheet; |
143 | newSheet->data.setAutoDelete(TRUE); | 143 | newSheet->data.setAutoDelete(TRUE); |
144 | stream >> newSheet->name >> countCell; | 144 | stream >> newSheet->name >> countCell; |
145 | comboSheets->insertItem(newSheet->name); | 145 | comboSheets->insertItem(newSheet->name); |
146 | 146 | ||
147 | for (j=0; j<countCell; ++j) | 147 | for (j=0; j<countCell; ++j) |
148 | { | 148 | { |
149 | newCell=new typeCellData; | 149 | newCell=new typeCellData; |
150 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; | 150 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; |
151 | newCell->col=col; | 151 | newCell->col=col; |
152 | newCell->row=row; | 152 | newCell->row=row; |
153 | newCell->alignment=(Qt::AlignmentFlags)alignment; | 153 | newCell->alignment=(Qt::AlignmentFlags)alignment; |
154 | newSheet->data.append(newCell); | 154 | newSheet->data.append(newCell); |
155 | } | 155 | } |
156 | listSheets.append(newSheet); | 156 | listSheets.append(newSheet); |
157 | 157 | ||
158 | if (i==0) | 158 | if (i==0) |
159 | { | 159 | { |
160 | sheet->setName(newSheet->name); | 160 | sheet->setName(newSheet->name); |
161 | sheet->setSheetData(&newSheet->data); | 161 | sheet->setSheetData(&newSheet->data); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | int MainWindow::saveCurrentFile(bool ask) | 166 | int MainWindow::saveCurrentFile(bool ask) |
167 | { | 167 | { |
168 | if (ask) | 168 | if (ask) |
169 | { | 169 | { |
170 | int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); | 170 | int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); |
171 | if (result!=QMessageBox::Yes) return result; | 171 | if (result!=QMessageBox::Yes) return result; |
172 | } | 172 | } |
173 | 173 | ||
174 | if (!currentDoc->isValid()) | 174 | if (!currentDoc->isValid()) |
175 | { | 175 | { |
176 | TextDialog dialogText(this); | 176 | TextDialog dialogText(this); |
177 | if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; | 177 | if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; |
178 | 178 | ||
179 | currentDoc->setName(dialogText.getValue()); | 179 | currentDoc->setName(dialogText.getValue()); |
180 | currentDoc->setFile(QString::null); | 180 | currentDoc->setFile(QString::null); |
181 | currentDoc->setLinkFile(QString::null); | 181 | currentDoc->setLinkFile(QString::null); |
182 | } | 182 | } |
183 | 183 | ||
184 | documentSave(currentDoc); | 184 | documentSave(currentDoc); |
185 | return QMessageBox::Yes; | 185 | return QMessageBox::Yes; |
186 | } | 186 | } |
187 | 187 | ||
188 | void MainWindow::selectorFileNew(const DocLnk &lnkDoc) | 188 | void MainWindow::selectorFileNew(const DocLnk &lnkDoc) |
189 | { | 189 | { |
190 | selectorHide(); | 190 | selectorHide(); |
191 | 191 | ||
192 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 192 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
193 | if (currentDoc) delete currentDoc; | 193 | if (currentDoc) delete currentDoc; |
194 | currentDoc = new DocLnk(lnkDoc); | 194 | currentDoc = new DocLnk(lnkDoc); |
195 | editData->clear(); | 195 | editData->clear(); |
196 | listSheets.clear(); | 196 | listSheets.clear(); |
197 | comboSheets->clear(); | 197 | comboSheets->clear(); |
198 | 198 | ||
199 | typeSheet *newSheet=createNewSheet(); | 199 | typeSheet *newSheet=createNewSheet(); |
200 | newSheet->data.setAutoDelete(TRUE); | 200 | newSheet->data.setAutoDelete(TRUE); |
201 | sheet->setName(newSheet->name); | 201 | sheet->setName(newSheet->name); |
202 | sheet->setSheetData(&newSheet->data); | 202 | sheet->setSheetData(&newSheet->data); |
203 | for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) | 203 | for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) |
204 | createNewSheet(); | 204 | createNewSheet(); |
205 | documentModified=FALSE; | 205 | documentModified=FALSE; |
206 | } | 206 | } |
207 | 207 | ||
208 | void MainWindow::closeEvent(QCloseEvent *e) | 208 | void MainWindow::closeEvent(QCloseEvent *e) |
209 | { | 209 | { |
210 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); | 210 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); |
211 | else e->accept(); | 211 | else e->accept(); |
212 | } | 212 | } |
213 | 213 | ||
214 | void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) | 214 | void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) |
215 | { | 215 | { |
216 | selectorHide(); | 216 | selectorHide(); |
217 | 217 | ||
218 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 218 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
219 | if (currentDoc) delete currentDoc; | 219 | if (currentDoc) delete currentDoc; |
220 | currentDoc = new DocLnk(lnkDoc); | 220 | currentDoc = new DocLnk(lnkDoc); |
221 | listSheets.clear(); | 221 | listSheets.clear(); |
222 | comboSheets->clear(); | 222 | comboSheets->clear(); |
223 | 223 | ||
224 | documentOpen(lnkDoc); | 224 | documentOpen(lnkDoc); |
225 | documentModified=FALSE; | 225 | documentModified=FALSE; |
226 | } | 226 | } |
227 | 227 | ||
228 | void MainWindow::selectorShow() | 228 | void MainWindow::selectorShow() |
229 | { | 229 | { |
230 | sheet->hide(); | 230 | sheet->hide(); |
231 | setCentralWidget(fileSelector); | 231 | setCentralWidget(fileSelector); |
232 | fileSelector->show(); | 232 | fileSelector->show(); |
233 | fileSelector->reread(); | 233 | fileSelector->reread(); |
234 | } | 234 | } |
235 | 235 | ||
236 | void MainWindow::selectorHide() | 236 | void MainWindow::selectorHide() |
237 | { | 237 | { |
238 | fileSelector->hide(); | 238 | fileSelector->hide(); |
239 | setCentralWidget(sheet); | 239 | setCentralWidget(sheet); |
240 | sheet->show(); | 240 | sheet->show(); |
241 | } | 241 | } |
242 | 242 | ||
243 | void MainWindow::slotFileNew() | 243 | void MainWindow::slotFileNew() |
244 | { | 244 | { |
245 | selectorFileNew(DocLnk()); | 245 | selectorFileNew(DocLnk()); |
246 | } | 246 | } |
247 | 247 | ||
248 | void MainWindow::slotFileOpen() | 248 | void MainWindow::slotFileOpen() |
249 | { | 249 | { |
250 | selectorShow(); | 250 | selectorShow(); |
251 | } | 251 | } |
252 | 252 | ||
253 | void MainWindow::slotFileSave() | 253 | void MainWindow::slotFileSave() |
254 | { | 254 | { |
255 | saveCurrentFile(FALSE); | 255 | saveCurrentFile(FALSE); |
256 | } | 256 | } |
257 | 257 | ||
258 | void MainWindow::setDocument(const QString &applnk_filename) | 258 | void MainWindow::setDocument(const QString &applnk_filename) |
259 | { | 259 | { |
260 | selectorFileOpen(DocLnk(applnk_filename)); | 260 | selectorFileOpen(DocLnk(applnk_filename)); |
261 | } | 261 | } |
262 | 262 | ||
263 | void MainWindow::initActions() | 263 | void MainWindow::initActions() |
264 | { | 264 | { |
265 | fileNew=new QAction(tr("New File"), Resource::loadPixmap( "new" ), tr("&New"), 0, this); | 265 | fileNew=new QAction(tr("New File"), Resource::loadPixmap( "new" ), tr("&New"), 0, this); |
266 | connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew())); | 266 | connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew())); |
267 | fileOpen=new QAction(tr("Open File"), Resource::loadPixmap( "fileopen" ), tr("&Open"), 0, this); | 267 | fileOpen=new QAction(tr("Open File"), Resource::loadPixmap( "fileopen" ), tr("&Open"), 0, this); |
268 | connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); | 268 | connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); |
269 | fileSave=new QAction(tr("Save File"),Resource::loadPixmap( "save" ), tr("&Save"), 0, this); | 269 | fileSave=new QAction(tr("Save File"),Resource::loadPixmap( "save" ), tr("&Save"), 0, this); |
270 | connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); | 270 | connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); |
271 | fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this); | 271 | fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this); |
272 | connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); | 272 | connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); |
273 | //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); | 273 | //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); |
274 | //connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); | 274 | //connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); |
275 | 275 | ||
276 | // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); | 276 | // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); |
277 | //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); | 277 | //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); |
278 | //helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this); | 278 | //helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this); |
279 | //connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout())); | 279 | //connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout())); |
280 | 280 | ||
281 | editAccept=new QAction(tr("Accept"),Resource::loadPixmap( "enter" ) , tr("&Accept"), 0, this); | 281 | editAccept=new QAction(tr("Accept"),Resource::loadPixmap( "enter" ) , tr("&Accept"), 0, this); |
282 | connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept())); | 282 | connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept())); |
283 | editCancel=new QAction(tr("Cancel"), Resource::loadPixmap( "close" ), tr("&Cancel"), 0, this); | 283 | editCancel=new QAction(tr("Cancel"), Resource::loadPixmap( "close" ), tr("&Cancel"), 0, this); |
284 | connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel())); | 284 | connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel())); |
285 | editCellSelect=new QAction(tr("Cell Selector"), QPixmap(cell_select_xpm), tr("Cell &Selector"), 0, this); | 285 | editCellSelect=new QAction(tr("Cell Selector"), QPixmap(cell_select_xpm), tr("Cell &Selector"), 0, this); |
286 | editCellSelect->setToggleAction(TRUE); | 286 | editCellSelect->setToggleAction(TRUE); |
287 | connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool))); | 287 | connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool))); |
288 | editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this); | 288 | editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this); |
289 | editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this); | 289 | editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this); |
290 | editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this); | 290 | editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this); |
291 | connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); | 291 | connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); |
292 | editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this); | 292 | editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this); |
293 | connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents())); | 293 | connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents())); |
294 | editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this); | 294 | editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this); |
295 | 295 | ||
296 | insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this); | 296 | insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this); |
297 | connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells())); | 297 | connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells())); |
298 | insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this); | 298 | insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this); |
299 | connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows())); | 299 | connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows())); |
300 | insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this); | 300 | insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this); |
301 | connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols())); | 301 | connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols())); |
302 | insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this); | 302 | insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this); |
303 | connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets())); | 303 | connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets())); |
304 | 304 | ||
305 | formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this); | 305 | formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this); |
306 | connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells())); | 306 | connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells())); |
307 | 307 | ||
308 | rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this); | 308 | rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this); |
309 | connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight())); | 309 | connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight())); |
310 | rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this); | 310 | rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this); |
311 | connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust())); | 311 | connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust())); |
312 | rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this); | 312 | rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this); |
313 | connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow())); | 313 | connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow())); |
314 | rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this); | 314 | rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this); |
315 | connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide())); | 315 | connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide())); |
316 | 316 | ||
317 | colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this); | 317 | colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this); |
318 | connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth())); | 318 | connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth())); |
319 | colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this); | 319 | colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this); |
320 | connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust())); | 320 | connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust())); |
321 | colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this); | 321 | colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this); |
322 | connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow())); | 322 | connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow())); |
323 | colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this); | 323 | colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this); |
324 | connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide())); | 324 | connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide())); |
325 | 325 | ||
326 | sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this); | 326 | sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this); |
327 | connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename())); | 327 | connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename())); |
328 | sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this); | 328 | sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this); |
329 | connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove())); | 329 | connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove())); |
330 | 330 | ||
331 | dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this); | 331 | dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this); |
332 | connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort())); | 332 | connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort())); |
333 | dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this); | 333 | dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this); |
334 | connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace())); | 334 | connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace())); |
335 | 335 | ||
336 | funcEqual=new QAction(tr("Equal To"), QPixmap(func_equal_xpm), tr("&Equal To"), 0, this); | 336 | funcEqual=new QAction(tr("Equal To"), QPixmap(func_equal_xpm), tr("&Equal To"), 0, this); |
337 | funcEqual->setToolTip("="); | 337 | funcEqual->setToolTip("="); |
338 | connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 338 | connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
339 | funcPlus=new QAction(tr("Addition"), QPixmap(func_plus_xpm), tr("&Addition"), 0, this); | 339 | funcPlus=new QAction(tr("Addition"), QPixmap(func_plus_xpm), tr("&Addition"), 0, this); |
340 | funcPlus->setToolTip("+"); | 340 | funcPlus->setToolTip("+"); |
341 | connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 341 | connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
342 | funcMinus=new QAction(tr("Subtraction"), QPixmap(func_minus_xpm), tr("&Subtraction"), 0, this); | 342 | funcMinus=new QAction(tr("Subtraction"), QPixmap(func_minus_xpm), tr("&Subtraction"), 0, this); |
343 | funcMinus->setToolTip("-"); | 343 | funcMinus->setToolTip("-"); |
344 | connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 344 | connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
345 | funcCross=new QAction(tr("Multiplication"), QPixmap(func_cross_xpm), tr("&Multiplication"), 0, this); | 345 | funcCross=new QAction(tr("Multiplication"), QPixmap(func_cross_xpm), tr("&Multiplication"), 0, this); |
346 | funcCross->setToolTip("*"); | 346 | funcCross->setToolTip("*"); |
347 | connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 347 | connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
348 | funcDivide=new QAction(tr("Division"), QPixmap(func_divide_xpm), tr("&Division"), 0, this); | 348 | funcDivide=new QAction(tr("Division"), QPixmap(func_divide_xpm), tr("&Division"), 0, this); |
349 | funcDivide->setToolTip("/"); | 349 | funcDivide->setToolTip("/"); |
350 | connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 350 | connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
351 | funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), QPixmap(func_paran_open_xpm), tr("&Open Paranthesis"), 0, this); | 351 | funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), QPixmap(func_paran_open_xpm), tr("&Open Paranthesis"), 0, this); |
352 | funcParanOpen->setToolTip("("); | 352 | funcParanOpen->setToolTip("("); |
353 | connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 353 | connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
354 | funcParanClose=new QAction(tr("Close Paranthesis"), QPixmap(func_paran_close_xpm), tr("&Close Paranthesis"), 0, this); | 354 | funcParanClose=new QAction(tr("Close Paranthesis"), QPixmap(func_paran_close_xpm), tr("&Close Paranthesis"), 0, this); |
355 | funcParanClose->setToolTip(")"); | 355 | funcParanClose->setToolTip(")"); |
356 | connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 356 | connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
357 | funcComma=new QAction(tr("Comma"), QPixmap(func_comma_xpm), tr("&Comma"), 0, this); | 357 | funcComma=new QAction(tr("Comma"), QPixmap(func_comma_xpm), tr("&Comma"), 0, this); |
358 | funcComma->setToolTip(","); | 358 | funcComma->setToolTip(","); |
359 | connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 359 | connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
360 | } | 360 | } |
361 | 361 | ||
362 | void MainWindow::initMenu() | 362 | void MainWindow::initMenu() |
363 | { | 363 | { |
364 | menu=new QPEMenuBar(this); | 364 | menu=new QMenuBar(this); |
365 | 365 | ||
366 | menuFile=new QPopupMenu; | 366 | menuFile=new QPopupMenu; |
367 | fileNew->addTo(menuFile); | 367 | fileNew->addTo(menuFile); |
368 | fileOpen->addTo(menuFile); | 368 | fileOpen->addTo(menuFile); |
369 | fileSave->addTo(menuFile); | 369 | fileSave->addTo(menuFile); |
370 | fileSaveAs->addTo(menuFile); | 370 | fileSaveAs->addTo(menuFile); |
371 | // menuFile->insertSeparator(); | 371 | // menuFile->insertSeparator(); |
372 | // fileQuit->addTo(menuFile); | 372 | // fileQuit->addTo(menuFile); |
373 | menu->insertItem(tr("&File"), menuFile); | 373 | menu->insertItem(tr("&File"), menuFile); |
374 | 374 | ||
375 | menuEdit=new QPopupMenu; | 375 | menuEdit=new QPopupMenu; |
376 | editAccept->addTo(menuEdit); | 376 | editAccept->addTo(menuEdit); |
377 | editCancel->addTo(menuEdit); | 377 | editCancel->addTo(menuEdit); |
378 | editCellSelect->addTo(menuEdit); | 378 | editCellSelect->addTo(menuEdit); |
379 | menuEdit->insertSeparator(); | 379 | menuEdit->insertSeparator(); |
380 | editCut->addTo(menuEdit); | 380 | editCut->addTo(menuEdit); |
381 | editCopy->addTo(menuEdit); | 381 | editCopy->addTo(menuEdit); |
382 | editPaste->addTo(menuEdit); | 382 | editPaste->addTo(menuEdit); |
383 | editPasteContents->addTo(menuEdit); | 383 | editPasteContents->addTo(menuEdit); |
384 | editClear->addTo(menuEdit); | 384 | editClear->addTo(menuEdit); |
385 | menu->insertItem(tr("&Edit"), menuEdit); | 385 | menu->insertItem(tr("&Edit"), menuEdit); |
386 | 386 | ||
387 | menuInsert=new QPopupMenu; | 387 | menuInsert=new QPopupMenu; |
388 | menu->insertItem(tr("&Insert"), menuInsert); | 388 | menu->insertItem(tr("&Insert"), menuInsert); |
389 | 389 | ||
390 | menuFormat=new QPopupMenu; | 390 | menuFormat=new QPopupMenu; |
391 | formatCells->addTo(menuFormat); | 391 | formatCells->addTo(menuFormat); |
392 | menu->insertItem(tr("&Format"), menuFormat); | 392 | menu->insertItem(tr("&Format"), menuFormat); |
393 | 393 | ||
394 | menuData=new QPopupMenu; | 394 | menuData=new QPopupMenu; |
395 | dataSort->addTo(menuData); | 395 | dataSort->addTo(menuData); |
396 | dataFindReplace->addTo(menuData); | 396 | dataFindReplace->addTo(menuData); |
397 | menu->insertItem(tr("&Data"), menuData); | 397 | menu->insertItem(tr("&Data"), menuData); |
398 | 398 | ||
399 | // menuHelp=new QPopupMenu; | 399 | // menuHelp=new QPopupMenu; |
400 | // helpGeneral->addTo(menuHelp); | 400 | // helpGeneral->addTo(menuHelp); |
401 | // helpAbout->addTo(menuHelp); | 401 | // helpAbout->addTo(menuHelp); |
402 | // menu->insertItem(tr("&Help"), menuHelp); | 402 | // menu->insertItem(tr("&Help"), menuHelp); |
403 | 403 | ||
404 | submenuRow=new QPopupMenu; | 404 | submenuRow=new QPopupMenu; |
405 | rowHeight->addTo(submenuRow); | 405 | rowHeight->addTo(submenuRow); |
406 | rowAdjust->addTo(submenuRow); | 406 | rowAdjust->addTo(submenuRow); |
407 | rowShow->addTo(submenuRow); | 407 | rowShow->addTo(submenuRow); |
408 | rowHide->addTo(submenuRow); | 408 | rowHide->addTo(submenuRow); |
409 | menuFormat->insertItem(tr("&Row"), submenuRow); | 409 | menuFormat->insertItem(tr("&Row"), submenuRow); |
410 | 410 | ||
411 | submenuCol=new QPopupMenu; | 411 | submenuCol=new QPopupMenu; |
412 | colWidth->addTo(submenuCol); | 412 | colWidth->addTo(submenuCol); |
413 | colAdjust->addTo(submenuCol); | 413 | colAdjust->addTo(submenuCol); |
414 | colShow->addTo(submenuCol); | 414 | colShow->addTo(submenuCol); |
415 | colHide->addTo(submenuCol); | 415 | colHide->addTo(submenuCol); |
416 | menuFormat->insertItem(tr("Colum&n"), submenuCol); | 416 | menuFormat->insertItem(tr("Colum&n"), submenuCol); |
417 | 417 | ||
418 | submenuSheet=new QPopupMenu; | 418 | submenuSheet=new QPopupMenu; |
419 | sheetRename->addTo(submenuSheet); | 419 | sheetRename->addTo(submenuSheet); |
420 | sheetRemove->addTo(submenuSheet); | 420 | sheetRemove->addTo(submenuSheet); |
421 | menuFormat->insertItem(tr("&Sheet"), submenuSheet); | 421 | menuFormat->insertItem(tr("&Sheet"), submenuSheet); |
422 | 422 | ||
423 | submenuFunc=new QPopupMenu; | 423 | submenuFunc=new QPopupMenu; |
424 | menuInsert->insertItem(tr("&Function"), submenuFunc); | 424 | menuInsert->insertItem(tr("&Function"), submenuFunc); |
425 | 425 | ||
426 | submenuFuncStd=new QPopupMenu; | 426 | submenuFuncStd=new QPopupMenu; |
427 | funcPlus->addTo(submenuFuncStd); | 427 | funcPlus->addTo(submenuFuncStd); |
428 | funcMinus->addTo(submenuFuncStd); | 428 | funcMinus->addTo(submenuFuncStd); |
429 | funcCross->addTo(submenuFuncStd); | 429 | funcCross->addTo(submenuFuncStd); |
430 | funcDivide->addTo(submenuFuncStd); | 430 | funcDivide->addTo(submenuFuncStd); |
431 | submenuFunc->insertItem(tr("&Standard"), submenuFuncStd); | 431 | submenuFunc->insertItem(tr("&Standard"), submenuFuncStd); |
432 | 432 | ||
433 | submenuFuncMath=new QPopupMenu; | 433 | submenuFuncMath=new QPopupMenu; |
434 | addFlyAction(tr("Summation"), tr("&Summation"), "SUM(", submenuFuncMath); | 434 | addFlyAction(tr("Summation"), tr("&Summation"), "SUM(", submenuFuncMath); |
435 | addFlyAction(tr("Absolute Value"), tr("&Absolute"), "ABS(", submenuFuncMath); | 435 | addFlyAction(tr("Absolute Value"), tr("&Absolute"), "ABS(", submenuFuncMath); |
436 | submenuFuncMath->insertSeparator(); | 436 | submenuFuncMath->insertSeparator(); |
437 | addFlyAction(tr("Sine"), tr("Si&ne"), "SIN(", submenuFuncMath); | 437 | addFlyAction(tr("Sine"), tr("Si&ne"), "SIN(", submenuFuncMath); |
438 | addFlyAction(tr("Arc Sine"), tr("A&rc Sine"), "ASIN(", submenuFuncMath); | 438 | addFlyAction(tr("Arc Sine"), tr("A&rc Sine"), "ASIN(", submenuFuncMath); |
439 | addFlyAction(tr("Cosine"), tr("&Cosine"), "COS(", submenuFuncMath); | 439 | addFlyAction(tr("Cosine"), tr("&Cosine"), "COS(", submenuFuncMath); |
440 | addFlyAction(tr("ArcCosine"), tr("Arc Cos&ine"), "COS(", submenuFuncMath); | 440 | addFlyAction(tr("ArcCosine"), tr("Arc Cos&ine"), "COS(", submenuFuncMath); |
441 | addFlyAction(tr("Tangent"), tr("&Tangent"), "TAN(", submenuFuncMath); | 441 | addFlyAction(tr("Tangent"), tr("&Tangent"), "TAN(", submenuFuncMath); |
442 | addFlyAction(tr("Arc Tangent"), tr("Arc Tan&gent"), "ATAN(", submenuFuncMath); | 442 | addFlyAction(tr("Arc Tangent"), tr("Arc Tan&gent"), "ATAN(", submenuFuncMath); |
443 | addFlyAction(tr("Arc Tangent of Coordinates"), tr("C&oor. Arc Tangent"), "ATAN2(", submenuFuncMath); | 443 | addFlyAction(tr("Arc Tangent of Coordinates"), tr("C&oor. Arc Tangent"), "ATAN2(", submenuFuncMath); |
444 | submenuFuncMath->insertSeparator(); | 444 | submenuFuncMath->insertSeparator(); |
445 | addFlyAction(tr("Exponential"), tr("&Exponential"), "EXP(", submenuFuncMath); | 445 | addFlyAction(tr("Exponential"), tr("&Exponential"), "EXP(", submenuFuncMath); |
446 | addFlyAction(tr("Logarithm"), tr("&Logarithm"), "LOG(", submenuFuncMath); | 446 | addFlyAction(tr("Logarithm"), tr("&Logarithm"), "LOG(", submenuFuncMath); |
447 | addFlyAction(tr("Power"), tr("&Power"), "POW(", submenuFuncMath); | 447 | addFlyAction(tr("Power"), tr("&Power"), "POW(", submenuFuncMath); |
448 | submenuFunc->insertItem(tr("&Mathematical"), submenuFuncMath); | 448 | submenuFunc->insertItem(tr("&Mathematical"), submenuFuncMath); |
449 | 449 | ||
450 | submenuFuncStat=new QPopupMenu; | 450 | submenuFuncStat=new QPopupMenu; |
451 | addFlyAction(tr("Average"), tr("&Average"), "AVG(", submenuFuncStat); | 451 | addFlyAction(tr("Average"), tr("&Average"), "AVG(", submenuFuncStat); |
452 | addFlyAction(tr("Maximum"), tr("Ma&ximum"), "MAX(", submenuFuncStat); | 452 | addFlyAction(tr("Maximum"), tr("Ma&ximum"), "MAX(", submenuFuncStat); |
453 | addFlyAction(tr("Minimum"), tr("&Minimum"), "MIN(", submenuFuncStat); | 453 | addFlyAction(tr("Minimum"), tr("&Minimum"), "MIN(", submenuFuncStat); |
454 | addFlyAction(tr("Count"), tr("&Count"), "COUNT(", submenuFuncStat); | 454 | addFlyAction(tr("Count"), tr("&Count"), "COUNT(", submenuFuncStat); |
455 | submenuFunc->insertItem(tr("&Statistical"), submenuFuncStat); | 455 | submenuFunc->insertItem(tr("&Statistical"), submenuFuncStat); |
456 | 456 | ||
457 | menuInsert->insertSeparator(); | 457 | menuInsert->insertSeparator(); |
458 | insertCells->addTo(menuInsert); | 458 | insertCells->addTo(menuInsert); |
459 | insertRows->addTo(menuInsert); | 459 | insertRows->addTo(menuInsert); |
460 | insertCols->addTo(menuInsert); | 460 | insertCols->addTo(menuInsert); |
461 | insertSheets->addTo(menuInsert); | 461 | insertSheets->addTo(menuInsert); |
462 | } | 462 | } |
463 | 463 | ||
464 | void MainWindow::initStandardToolbar() | 464 | void MainWindow::initStandardToolbar() |
465 | { | 465 | { |
466 | toolbarStandard=new QPEToolBar(this); | 466 | toolbarStandard=new QPEToolBar(this); |
467 | toolbarStandard->setHorizontalStretchable(TRUE); | 467 | toolbarStandard->setHorizontalStretchable(TRUE); |
468 | moveToolBar(toolbarStandard, Top); | 468 | moveToolBar(toolbarStandard, Top); |
469 | 469 | ||
470 | fileNew->addTo(toolbarStandard); | 470 | fileNew->addTo(toolbarStandard); |
471 | fileOpen->addTo(toolbarStandard); | 471 | fileOpen->addTo(toolbarStandard); |
472 | fileSave->addTo(toolbarStandard); | 472 | fileSave->addTo(toolbarStandard); |
473 | 473 | ||
474 | comboSheets=new QComboBox(toolbarStandard); | 474 | comboSheets=new QComboBox(toolbarStandard); |
475 | toolbarStandard->setStretchableWidget(comboSheets); | 475 | toolbarStandard->setStretchableWidget(comboSheets); |
476 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); | 476 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); |
477 | } | 477 | } |
478 | 478 | ||
479 | void MainWindow::initFunctionsToolbar() | 479 | void MainWindow::initFunctionsToolbar() |
480 | { | 480 | { |
481 | toolbarFunctions=new QPEToolBar(this); | 481 | toolbarFunctions=new QPEToolBar(this); |
482 | toolbarFunctions->setHorizontalStretchable(TRUE); | 482 | toolbarFunctions->setHorizontalStretchable(TRUE); |
483 | moveToolBar(toolbarFunctions, Bottom); | 483 | moveToolBar(toolbarFunctions, Bottom); |
484 | 484 | ||
485 | funcEqual->addTo(toolbarFunctions); | 485 | funcEqual->addTo(toolbarFunctions); |
486 | funcPlus->addTo(toolbarFunctions); | 486 | funcPlus->addTo(toolbarFunctions); |
487 | funcMinus->addTo(toolbarFunctions); | 487 | funcMinus->addTo(toolbarFunctions); |
488 | funcCross->addTo(toolbarFunctions); | 488 | funcCross->addTo(toolbarFunctions); |
489 | funcDivide->addTo(toolbarFunctions); | 489 | funcDivide->addTo(toolbarFunctions); |
490 | funcParanOpen->addTo(toolbarFunctions); | 490 | funcParanOpen->addTo(toolbarFunctions); |
491 | funcParanClose->addTo(toolbarFunctions); | 491 | funcParanClose->addTo(toolbarFunctions); |
492 | funcComma->addTo(toolbarFunctions); | 492 | funcComma->addTo(toolbarFunctions); |
493 | 493 | ||
494 | toolFunction=new QToolButton(toolbarFunctions); | 494 | toolFunction=new QToolButton(toolbarFunctions); |
495 | toolFunction->setPixmap(func_func_xpm); | 495 | toolFunction->setPixmap(func_func_xpm); |
496 | toolFunction->setTextLabel(tr("Functions")); | 496 | toolFunction->setTextLabel(tr("Functions")); |
497 | toolFunction->setPopup(submenuFunc); | 497 | toolFunction->setPopup(submenuFunc); |
498 | toolFunction->setPopupDelay(0); | 498 | toolFunction->setPopupDelay(0); |
499 | } | 499 | } |
500 | 500 | ||
501 | void MainWindow::initEditToolbar() | 501 | void MainWindow::initEditToolbar() |
502 | { | 502 | { |
503 | toolbarEdit=new QPEToolBar(this); | 503 | toolbarEdit=new QPEToolBar(this); |
504 | toolbarEdit->setHorizontalStretchable(TRUE); | 504 | toolbarEdit->setHorizontalStretchable(TRUE); |
505 | moveToolBar(toolbarEdit, Bottom); | 505 | moveToolBar(toolbarEdit, Bottom); |
506 | 506 | ||
507 | editAccept->addTo(toolbarEdit); | 507 | editAccept->addTo(toolbarEdit); |
508 | editCancel->addTo(toolbarEdit); | 508 | editCancel->addTo(toolbarEdit); |
509 | 509 | ||
510 | editData=new QLineEdit(toolbarEdit); | 510 | editData=new QLineEdit(toolbarEdit); |
511 | toolbarEdit->setStretchableWidget(editData); | 511 | toolbarEdit->setStretchableWidget(editData); |
512 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); | 512 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); |
513 | 513 | ||
514 | editCellSelect->addTo(toolbarEdit); | 514 | editCellSelect->addTo(toolbarEdit); |
515 | } | 515 | } |
516 | 516 | ||
517 | void MainWindow::slotHelpAbout() | 517 | void MainWindow::slotHelpAbout() |
518 | { | 518 | { |
519 | QDialog dialogAbout(this, 0, TRUE); | 519 | QDialog dialogAbout(this, 0, TRUE); |
520 | dialogAbout.resize(width()-40, height()-80); | 520 | dialogAbout.resize(width()-40, height()-80); |
521 | dialogAbout.setCaption(tr("About Opie Sheet")); | 521 | dialogAbout.setCaption(tr("About Opie Sheet")); |
522 | 522 | ||
523 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); | 523 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); |
524 | label.setGeometry(dialogAbout.rect()); | 524 | label.setGeometry(dialogAbout.rect()); |
525 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); | 525 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); |
526 | 526 | ||
527 | dialogAbout.exec(); | 527 | dialogAbout.exec(); |
528 | } | 528 | } |
529 | 529 | ||
530 | void MainWindow::initSheet() | 530 | void MainWindow::initSheet() |
531 | { | 531 | { |
532 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); | 532 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); |
533 | setCentralWidget(sheet); | 533 | setCentralWidget(sheet); |
534 | 534 | ||
535 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); | 535 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); |
536 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); | 536 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); |
537 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); | 537 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); |
538 | 538 | ||
539 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); | 539 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); |
540 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); | 540 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); |
541 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); | 541 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); |
542 | } | 542 | } |
543 | 543 | ||
544 | void MainWindow::slotEditAccept() | 544 | void MainWindow::slotEditAccept() |
545 | { | 545 | { |
546 | sheet->setData(editData->text()); | 546 | sheet->setData(editData->text()); |
547 | } | 547 | } |
548 | 548 | ||
549 | void MainWindow::slotEditCancel() | 549 | void MainWindow::slotEditCancel() |
550 | { | 550 | { |
551 | editData->setText(sheet->getData()); | 551 | editData->setText(sheet->getData()); |
552 | } | 552 | } |
553 | 553 | ||
554 | void MainWindow::slotCellSelect(bool lock) | 554 | void MainWindow::slotCellSelect(bool lock) |
555 | { | 555 | { |
556 | sheet->lockClicks(lock); | 556 | sheet->lockClicks(lock); |
557 | } | 557 | } |
558 | 558 | ||
559 | void MainWindow::addToData(const QString &data) | 559 | void MainWindow::addToData(const QString &data) |
560 | { | 560 | { |
561 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); | 561 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); |
562 | } | 562 | } |
563 | 563 | ||
564 | void MainWindow::slotFuncOutput() | 564 | void MainWindow::slotFuncOutput() |
565 | { | 565 | { |
566 | if (sender()->isA("QAction")) | 566 | if (sender()->isA("QAction")) |
567 | addToData(((QAction *)sender())->toolTip()); | 567 | addToData(((QAction *)sender())->toolTip()); |
568 | } | 568 | } |
569 | 569 | ||
570 | void MainWindow::slotInsertRows() | 570 | void MainWindow::slotInsertRows() |
571 | { | 571 | { |
572 | NumberDialog dialogNumber(this); | 572 | NumberDialog dialogNumber(this); |
573 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) | 573 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) |
574 | sheet->insertRows(dialogNumber.getValue()); | 574 | sheet->insertRows(dialogNumber.getValue()); |
575 | } | 575 | } |
576 | 576 | ||
577 | void MainWindow::slotInsertCols() | 577 | void MainWindow::slotInsertCols() |
578 | { | 578 | { |
579 | NumberDialog dialogNumber(this); | 579 | NumberDialog dialogNumber(this); |
580 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) | 580 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) |
581 | sheet->insertColumns(dialogNumber.getValue()); | 581 | sheet->insertColumns(dialogNumber.getValue()); |
582 | } | 582 | } |
583 | 583 | ||
584 | void MainWindow::slotInsertSheets() | 584 | void MainWindow::slotInsertSheets() |
585 | { | 585 | { |
586 | NumberDialog dialogNumber(this); | 586 | NumberDialog dialogNumber(this); |
587 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) | 587 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) |
588 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); | 588 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); |
589 | } | 589 | } |
590 | 590 | ||
591 | void MainWindow::slotCellClicked(const QString &cell) | 591 | void MainWindow::slotCellClicked(const QString &cell) |
592 | { | 592 | { |
593 | editCellSelect->setOn(FALSE); | 593 | editCellSelect->setOn(FALSE); |
594 | addToData(cell); | 594 | addToData(cell); |
595 | } | 595 | } |
596 | 596 | ||
597 | typeSheet *MainWindow::createNewSheet() | 597 | typeSheet *MainWindow::createNewSheet() |
598 | { | 598 | { |
599 | typeSheet *newSheet=new typeSheet; | 599 | typeSheet *newSheet=new typeSheet; |
600 | int currentNo=1, tempNo; | 600 | int currentNo=1, tempNo; |
601 | bool ok; | 601 | bool ok; |
602 | 602 | ||
603 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 603 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
604 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) | 604 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) |
605 | currentNo=tempNo+1; | 605 | currentNo=tempNo+1; |
606 | 606 | ||
607 | newSheet->name=tr("Sheet")+QString::number(currentNo); | 607 | newSheet->name=tr("Sheet")+QString::number(currentNo); |
608 | newSheet->data.setAutoDelete(TRUE); | 608 | newSheet->data.setAutoDelete(TRUE); |
609 | 609 | ||
610 | comboSheets->insertItem(newSheet->name); | 610 | comboSheets->insertItem(newSheet->name); |
611 | listSheets.append(newSheet); | 611 | listSheets.append(newSheet); |
612 | return newSheet; | 612 | return newSheet; |
613 | } | 613 | } |
614 | 614 | ||
615 | typeSheet *MainWindow::findSheet(const QString &name) | 615 | typeSheet *MainWindow::findSheet(const QString &name) |
616 | { | 616 | { |
617 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 617 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
618 | if (tempSheet->name==name) | 618 | if (tempSheet->name==name) |
619 | return tempSheet; | 619 | return tempSheet; |
620 | return NULL; | 620 | return NULL; |
diff --git a/noncore/apps/opie-sheet/mainwindow.h b/noncore/apps/opie-sheet/mainwindow.h index 370d82e..4007f88 100644 --- a/noncore/apps/opie-sheet/mainwindow.h +++ b/noncore/apps/opie-sheet/mainwindow.h | |||
@@ -1,133 +1,133 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 11 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 12 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #ifndef MAINWINDOW_H | 15 | #ifndef MAINWINDOW_H |
16 | #define MAINWINDOW_H | 16 | #define MAINWINDOW_H |
17 | 17 | ||
18 | #include <qpe/applnk.h> | 18 | #include <qpe/applnk.h> |
19 | #include <qpe/fileselector.h> | 19 | #include <qpe/fileselector.h> |
20 | #include <qpe/qpemenubar.h> | 20 | #include <qmenubar.h> |
21 | #include <qpe/qpetoolbar.h> | 21 | #include <qpe/qpetoolbar.h> |
22 | #include <qmainwindow.h> | 22 | #include <qmainwindow.h> |
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include <qlineedit.h> | 24 | #include <qlineedit.h> |
25 | #include <qbutton.h> | 25 | #include <qbutton.h> |
26 | #include <qcombobox.h> | 26 | #include <qcombobox.h> |
27 | #include <qtoolbutton.h> | 27 | #include <qtoolbutton.h> |
28 | 28 | ||
29 | #include "sheet.h" | 29 | #include "sheet.h" |
30 | 30 | ||
31 | typedef struct typeSheet | 31 | typedef struct typeSheet |
32 | { | 32 | { |
33 | QString name; | 33 | QString name; |
34 | QList<typeCellData> data; | 34 | QList<typeCellData> data; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | class MainWindow: public QMainWindow | 37 | class MainWindow: public QMainWindow |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | 40 | ||
41 | // QPE objects | 41 | // QPE objects |
42 | DocLnk* currentDoc; | 42 | DocLnk* currentDoc; |
43 | QPEMenuBar *menu; | 43 | QMenuBar *menu; |
44 | QPEToolBar *toolbarFunctions, *toolbarEdit, *toolbarStandard; | 44 | QPEToolBar *toolbarFunctions, *toolbarEdit, *toolbarStandard; |
45 | FileSelector *fileSelector; | 45 | FileSelector *fileSelector; |
46 | 46 | ||
47 | // QT objects | 47 | // QT objects |
48 | QPopupMenu *menuFile, *menuEdit, *menuInsert, *menuFormat, *menuData, *menuHelp, | 48 | QPopupMenu *menuFile, *menuEdit, *menuInsert, *menuFormat, *menuData, *menuHelp, |
49 | *submenuFunc, *submenuFuncStd, *submenuFuncMath, *submenuFuncStat, | 49 | *submenuFunc, *submenuFuncStd, *submenuFuncMath, *submenuFuncStat, |
50 | *submenuRow, *submenuCol, *submenuSheet; | 50 | *submenuRow, *submenuCol, *submenuSheet; |
51 | QAction *fileNew, *fileOpen, *fileSave, *fileSaveAs, *fileQuit, *helpAbout, *editAccept, *editCancel, *formatCells, | 51 | QAction *fileNew, *fileOpen, *fileSave, *fileSaveAs, *fileQuit, *helpAbout, *editAccept, *editCancel, *formatCells, |
52 | *funcPlus, *funcMinus, *funcCross, *funcDivide, *funcParanOpen, *funcParanClose, *funcComma, *funcEqual, | 52 | *funcPlus, *funcMinus, *funcCross, *funcDivide, *funcParanOpen, *funcParanClose, *funcComma, *funcEqual, |
53 | *editCut, *editCopy, *editPaste, *editPasteContents, *editClear, *insertCols, *insertRows, *insertSheets, *insertCells, | 53 | *editCut, *editCopy, *editPaste, *editPasteContents, *editClear, *insertCols, *insertRows, *insertSheets, *insertCells, |
54 | *rowHeight, *rowShow, *rowHide, *rowAdjust, *colWidth, *colShow, *colHide, *colAdjust, *sheetRename, *sheetRemove, | 54 | *rowHeight, *rowShow, *rowHide, *rowAdjust, *colWidth, *colShow, *colHide, *colAdjust, *sheetRename, *sheetRemove, |
55 | *dataSort, *dataFindReplace, *editCellSelect, *helpGeneral; | 55 | *dataSort, *dataFindReplace, *editCellSelect, *helpGeneral; |
56 | QLineEdit *editData; | 56 | QLineEdit *editData; |
57 | QButton *buttonUp, *buttonDown, *buttonLeft, *buttonRight; | 57 | QButton *buttonUp, *buttonDown, *buttonLeft, *buttonRight; |
58 | QComboBox *comboSheets; | 58 | QComboBox *comboSheets; |
59 | QToolButton *toolFunction; | 59 | QToolButton *toolFunction; |
60 | QList<typeSheet> listSheets; | 60 | QList<typeSheet> listSheets; |
61 | QString helpFile; | 61 | QString helpFile; |
62 | 62 | ||
63 | // Other objects | 63 | // Other objects |
64 | Sheet *sheet; | 64 | Sheet *sheet; |
65 | 65 | ||
66 | // Variables | 66 | // Variables |
67 | bool documentModified; | 67 | bool documentModified; |
68 | 68 | ||
69 | // Private functions | 69 | // Private functions |
70 | void initMenu(); | 70 | void initMenu(); |
71 | void initActions(); | 71 | void initActions(); |
72 | void initFunctionsToolbar(); | 72 | void initFunctionsToolbar(); |
73 | void initEditToolbar(); | 73 | void initEditToolbar(); |
74 | void initStandardToolbar(); | 74 | void initStandardToolbar(); |
75 | void initSheet(); | 75 | void initSheet(); |
76 | void addToData(const QString &data); | 76 | void addToData(const QString &data); |
77 | int saveCurrentFile(bool ask=TRUE); | 77 | int saveCurrentFile(bool ask=TRUE); |
78 | void documentOpen(const DocLnk &lnkDoc); | 78 | void documentOpen(const DocLnk &lnkDoc); |
79 | void documentSave(DocLnk *lnkDoc); | 79 | void documentSave(DocLnk *lnkDoc); |
80 | void closeEvent(QCloseEvent *e); | 80 | void closeEvent(QCloseEvent *e); |
81 | void addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w); | 81 | void addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w); |
82 | typeSheet *createNewSheet(); | 82 | typeSheet *createNewSheet(); |
83 | typeSheet *findSheet(const QString &name); | 83 | typeSheet *findSheet(const QString &name); |
84 | 84 | ||
85 | private slots: | 85 | private slots: |
86 | void slotFileNew(); | 86 | void slotFileNew(); |
87 | void slotFileOpen(); | 87 | void slotFileOpen(); |
88 | void slotFileSave(); | 88 | void slotFileSave(); |
89 | void slotFileSaveAs(); | 89 | void slotFileSaveAs(); |
90 | void slotHelpAbout(); | 90 | void slotHelpAbout(); |
91 | void slotEditAccept(); | 91 | void slotEditAccept(); |
92 | void slotEditCancel(); | 92 | void slotEditCancel(); |
93 | void slotEditPaste(); | 93 | void slotEditPaste(); |
94 | void slotEditPasteContents(); | 94 | void slotEditPasteContents(); |
95 | void slotFormatCells(); | 95 | void slotFormatCells(); |
96 | void slotInsertCells(); | 96 | void slotInsertCells(); |
97 | void slotInsertRows(); | 97 | void slotInsertRows(); |
98 | void slotInsertCols(); | 98 | void slotInsertCols(); |
99 | void slotInsertSheets(); | 99 | void slotInsertSheets(); |
100 | void slotDataSort(); | 100 | void slotDataSort(); |
101 | void slotDataFindReplace(); | 101 | void slotDataFindReplace(); |
102 | void slotRowHeight(); | 102 | void slotRowHeight(); |
103 | void slotRowAdjust(); | 103 | void slotRowAdjust(); |
104 | void slotRowShow(); | 104 | void slotRowShow(); |
105 | void slotRowHide(); | 105 | void slotRowHide(); |
106 | void slotColumnWidth(); | 106 | void slotColumnWidth(); |
107 | void slotColumnAdjust(); | 107 | void slotColumnAdjust(); |
108 | void slotColumnShow(); | 108 | void slotColumnShow(); |
109 | void slotColumnHide(); | 109 | void slotColumnHide(); |
110 | void slotSheetRename(); | 110 | void slotSheetRename(); |
111 | void slotSheetRemove(); | 111 | void slotSheetRemove(); |
112 | void slotFuncOutput(); | 112 | void slotFuncOutput(); |
113 | void slotCellSelect(bool lock); | 113 | void slotCellSelect(bool lock); |
114 | void slotCellClicked(const QString &cell); | 114 | void slotCellClicked(const QString &cell); |
115 | void slotSheetChanged(const QString &name); | 115 | void slotSheetChanged(const QString &name); |
116 | void slotDocModified(); | 116 | void slotDocModified(); |
117 | void selectorShow(); | 117 | void selectorShow(); |
118 | void selectorHide(); | 118 | void selectorHide(); |
119 | void selectorFileNew(const DocLnk &lnkDoc); | 119 | void selectorFileNew(const DocLnk &lnkDoc); |
120 | void selectorFileOpen(const DocLnk &lnkDoc); | 120 | void selectorFileOpen(const DocLnk &lnkDoc); |
121 | 121 | ||
122 | public: | 122 | public: |
123 | static QString appName() { return QString::fromLatin1("sheetqt"); } | 123 | static QString appName() { return QString::fromLatin1("sheetqt"); } |
124 | MainWindow(QWidget *p, const char*, WFlags); | 124 | MainWindow(QWidget *p, const char*, WFlags); |
125 | ~MainWindow(); | 125 | ~MainWindow(); |
126 | 126 | ||
127 | void setHelpFile(const QString &help_filename) { helpFile=help_filename; } | 127 | void setHelpFile(const QString &help_filename) { helpFile=help_filename; } |
128 | 128 | ||
129 | public slots: | 129 | public slots: |
130 | void setDocument(const QString &applnk_filename); | 130 | void setDocument(const QString &applnk_filename); |
131 | }; | 131 | }; |
132 | 132 | ||
133 | #endif | 133 | #endif |
diff --git a/noncore/apps/qashmoney/budgetdisplay.cpp b/noncore/apps/qashmoney/budgetdisplay.cpp index afc6a2d..492595a 100755 --- a/noncore/apps/qashmoney/budgetdisplay.cpp +++ b/noncore/apps/qashmoney/budgetdisplay.cpp | |||
@@ -1,292 +1,292 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | #include <qheader.h> | 2 | #include <qheader.h> |
3 | #include <qfont.h> | 3 | #include <qfont.h> |
4 | #include <sqlite.h> | 4 | #include <sqlite.h> |
5 | 5 | ||
6 | #include "budgetdisplay.h" | 6 | #include "budgetdisplay.h" |
7 | #include "budget.h" | 7 | #include "budget.h" |
8 | #include "newaccount.h" | 8 | #include "newaccount.h" |
9 | #include "datepicker.h" | 9 | #include "datepicker.h" |
10 | #include "preferences.h" | 10 | #include "preferences.h" |
11 | #include "transaction.h" | 11 | #include "transaction.h" |
12 | 12 | ||
13 | extern Preferences *preferences; | 13 | extern Preferences *preferences; |
14 | extern Budget *budget; | 14 | extern Budget *budget; |
15 | extern Transaction *transaction; | 15 | extern Transaction *transaction; |
16 | 16 | ||
17 | BudgetDisplay::BudgetDisplay ( QWidget *parent ) : QWidget ( parent ) | 17 | BudgetDisplay::BudgetDisplay ( QWidget *parent ) : QWidget ( parent ) |
18 | { | 18 | { |
19 | QFont font = this->font(); | 19 | QFont font = this->font(); |
20 | font.setWeight ( QFont::Bold ); | 20 | font.setWeight ( QFont::Bold ); |
21 | 21 | ||
22 | //set the default date to today | 22 | //set the default date to today |
23 | newDate = QDate::currentDate (); | 23 | newDate = QDate::currentDate (); |
24 | year = newDate.year(); | 24 | year = newDate.year(); |
25 | month = newDate.month(); | 25 | month = newDate.month(); |
26 | day = newDate.day(); | 26 | day = newDate.day(); |
27 | datelabel = preferences->getDate ( year, month ); | 27 | datelabel = preferences->getDate ( year, month ); |
28 | 28 | ||
29 | setCaption ( "Budget" ); | 29 | setCaption ( "Budget" ); |
30 | 30 | ||
31 | firstline = new QHBox ( this ); | 31 | firstline = new QHBox ( this ); |
32 | firstline->setSpacing ( 2 ); | 32 | firstline->setSpacing ( 2 ); |
33 | secondline = new QHBox ( this ); | 33 | secondline = new QHBox ( this ); |
34 | secondline->setSpacing ( 10 ); | 34 | secondline->setSpacing ( 10 ); |
35 | 35 | ||
36 | menu = new QPEMenuBar ( this ); | 36 | menu = new QMenuBar ( this ); |
37 | menu->setFrameStyle ( QFrame::Box | QFrame::Sunken ); | 37 | menu->setFrameStyle ( QFrame::Box | QFrame::Sunken ); |
38 | budgetmenu = new QPopupMenu ( this ); | 38 | budgetmenu = new QPopupMenu ( this ); |
39 | lineitemsmenu = new QPopupMenu ( this ); | 39 | lineitemsmenu = new QPopupMenu ( this ); |
40 | datemenu = new QPopupMenu ( this ); | 40 | datemenu = new QPopupMenu ( this ); |
41 | menu->insertItem ( "Budget", budgetmenu ); | 41 | menu->insertItem ( "Budget", budgetmenu ); |
42 | menu->insertItem ( "Line Item", lineitemsmenu ); | 42 | menu->insertItem ( "Line Item", lineitemsmenu ); |
43 | menu->insertItem ( "Date", datemenu ); | 43 | menu->insertItem ( "Date", datemenu ); |
44 | budgetmenu->insertItem ( "New", this, SLOT ( newBudget () ), 0, 1 ); | 44 | budgetmenu->insertItem ( "New", this, SLOT ( newBudget () ), 0, 1 ); |
45 | budgetmenu->insertItem ( "Edit", this, SLOT ( editBudget () ), 0, 2 ); | 45 | budgetmenu->insertItem ( "Edit", this, SLOT ( editBudget () ), 0, 2 ); |
46 | budgetmenu->insertItem ( "Delete", this, SLOT ( deleteBudget () ), 0, 3 ); | 46 | budgetmenu->insertItem ( "Delete", this, SLOT ( deleteBudget () ), 0, 3 ); |
47 | lineitemsmenu->insertItem ( "New", this, SLOT ( newLineItem () ), 0, 1 ); | 47 | lineitemsmenu->insertItem ( "New", this, SLOT ( newLineItem () ), 0, 1 ); |
48 | lineitemsmenu->insertItem ( "Edit", this, SLOT ( editLineItem () ), 0, 2 ); | 48 | lineitemsmenu->insertItem ( "Edit", this, SLOT ( editLineItem () ), 0, 2 ); |
49 | lineitemsmenu->insertItem ( "Delete", this, SLOT ( deleteLineItem () ), 0, 3 ); | 49 | lineitemsmenu->insertItem ( "Delete", this, SLOT ( deleteLineItem () ), 0, 3 ); |
50 | datemenu->insertItem ( "Change", this, SLOT ( showCalendar() ) ); | 50 | datemenu->insertItem ( "Change", this, SLOT ( showCalendar() ) ); |
51 | 51 | ||
52 | budgetbox = new QComboBox ( firstline ); | 52 | budgetbox = new QComboBox ( firstline ); |
53 | connect ( budgetbox, SIGNAL ( activated ( int ) ), this, SLOT ( setCurrentBudget ( int ) ) ); | 53 | connect ( budgetbox, SIGNAL ( activated ( int ) ), this, SLOT ( setCurrentBudget ( int ) ) ); |
54 | 54 | ||
55 | budgetview = new QComboBox ( firstline ); | 55 | budgetview = new QComboBox ( firstline ); |
56 | budgetview->insertItem ( "Month" ); | 56 | budgetview->insertItem ( "Month" ); |
57 | budgetview->insertItem ( "Year" ); | 57 | budgetview->insertItem ( "Year" ); |
58 | connect ( budgetview, SIGNAL ( activated ( int ) ), this, SLOT ( setCurrentView ( int ) ) ); | 58 | connect ( budgetview, SIGNAL ( activated ( int ) ), this, SLOT ( setCurrentView ( int ) ) ); |
59 | 59 | ||
60 | budgeted = new QLabel ( secondline ); | 60 | budgeted = new QLabel ( secondline ); |
61 | budgeted->setFont ( font ); | 61 | budgeted->setFont ( font ); |
62 | actual = new QLabel ( secondline ); | 62 | actual = new QLabel ( secondline ); |
63 | actual->setFont ( font ); | 63 | actual->setFont ( font ); |
64 | date = new QLabel ( secondline ); | 64 | date = new QLabel ( secondline ); |
65 | date->setFont ( font ); | 65 | date->setFont ( font ); |
66 | 66 | ||
67 | listview = new QListView ( this ); | 67 | listview = new QListView ( this ); |
68 | listview->setAllColumnsShowFocus ( TRUE ); | 68 | listview->setAllColumnsShowFocus ( TRUE ); |
69 | listview->setShowSortIndicator ( TRUE ); | 69 | listview->setShowSortIndicator ( TRUE ); |
70 | listview->setRootIsDecorated ( TRUE ); | 70 | listview->setRootIsDecorated ( TRUE ); |
71 | listview->setMultiSelection ( FALSE ); | 71 | listview->setMultiSelection ( FALSE ); |
72 | listview->addColumn ( "Line Item", preferences->getColumnPreference ( 13 ) ); // column id 13 | 72 | listview->addColumn ( "Line Item", preferences->getColumnPreference ( 13 ) ); // column id 13 |
73 | listview->addColumn ( "Budget", preferences->getColumnPreference ( 14 ) ); // column id 14 | 73 | listview->addColumn ( "Budget", preferences->getColumnPreference ( 14 ) ); // column id 14 |
74 | listview->addColumn ( "Actual", preferences->getColumnPreference ( 15 ) ); // column id 15 | 74 | listview->addColumn ( "Actual", preferences->getColumnPreference ( 15 ) ); // column id 15 |
75 | listview->addColumn ( "", 0 ); // line item ids | 75 | listview->addColumn ( "", 0 ); // line item ids |
76 | listview->setColumnWidthMode ( 0, QListView::Manual ); | 76 | listview->setColumnWidthMode ( 0, QListView::Manual ); |
77 | listview->setColumnWidthMode ( 1, QListView::Manual ); | 77 | listview->setColumnWidthMode ( 1, QListView::Manual ); |
78 | listview->setColumnWidthMode ( 2, QListView::Manual ); | 78 | listview->setColumnWidthMode ( 2, QListView::Manual ); |
79 | listview->setColumnAlignment ( 1, Qt::AlignRight ); | 79 | listview->setColumnAlignment ( 1, Qt::AlignRight ); |
80 | listview->setColumnAlignment ( 2, Qt::AlignRight ); | 80 | listview->setColumnAlignment ( 2, Qt::AlignRight ); |
81 | listview->setColumnWidthMode ( 3, QListView::Manual ); | 81 | listview->setColumnWidthMode ( 3, QListView::Manual ); |
82 | 82 | ||
83 | listview->header()->setTracking ( FALSE ); | 83 | listview->header()->setTracking ( FALSE ); |
84 | connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) ); | 84 | connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) ); |
85 | connect ( listview->header(), SIGNAL ( clicked ( int ) ), this, SLOT ( saveSortingPreference ( int ) ) ); | 85 | connect ( listview->header(), SIGNAL ( clicked ( int ) ), this, SLOT ( saveSortingPreference ( int ) ) ); |
86 | 86 | ||
87 | // pull the column sorting preference from the preferences table, and configure the listview accordingly | 87 | // pull the column sorting preference from the preferences table, and configure the listview accordingly |
88 | int column = 0; | 88 | int column = 0; |
89 | int direction = 0; | 89 | int direction = 0; |
90 | preferences->getSortingPreference ( 3, &column, &direction ); | 90 | preferences->getSortingPreference ( 3, &column, &direction ); |
91 | listview->setSorting ( column, direction ); | 91 | listview->setSorting ( column, direction ); |
92 | 92 | ||
93 | displayBudgetNames(); | 93 | displayBudgetNames(); |
94 | 94 | ||
95 | layout = new QVBoxLayout ( this, 2, 2 ); | 95 | layout = new QVBoxLayout ( this, 2, 2 ); |
96 | layout->setMenuBar ( menu ); | 96 | layout->setMenuBar ( menu ); |
97 | layout->addWidget ( firstline ); | 97 | layout->addWidget ( firstline ); |
98 | layout->addWidget ( secondline ); | 98 | layout->addWidget ( secondline ); |
99 | layout->addWidget ( listview ); | 99 | layout->addWidget ( listview ); |
100 | } | 100 | } |
101 | 101 | ||
102 | void BudgetDisplay::deleteBudget () | 102 | void BudgetDisplay::deleteBudget () |
103 | { | 103 | { |
104 | listview->clear(); | 104 | listview->clear(); |
105 | transaction->clearBudgetIDs ( currentbudget ); | 105 | transaction->clearBudgetIDs ( currentbudget ); |
106 | budget->deleteBudget ( currentbudget ); | 106 | budget->deleteBudget ( currentbudget ); |
107 | if ( budgetbox->count() != 0 ) | 107 | if ( budgetbox->count() != 0 ) |
108 | displayBudgetNames(); | 108 | displayBudgetNames(); |
109 | checkBudgets(); | 109 | checkBudgets(); |
110 | } | 110 | } |
111 | 111 | ||
112 | void BudgetDisplay::saveColumnSize ( int column, int oldsize, int newsize ) | 112 | void BudgetDisplay::saveColumnSize ( int column, int oldsize, int newsize ) |
113 | { | 113 | { |
114 | switch ( column ) | 114 | switch ( column ) |
115 | { | 115 | { |
116 | case 0: | 116 | case 0: |
117 | preferences->changeColumnPreference ( 13, newsize ); | 117 | preferences->changeColumnPreference ( 13, newsize ); |
118 | break; | 118 | break; |
119 | case 1: | 119 | case 1: |
120 | preferences->changeColumnPreference ( 14, newsize ); | 120 | preferences->changeColumnPreference ( 14, newsize ); |
121 | break; | 121 | break; |
122 | case 2: | 122 | case 2: |
123 | preferences->changeColumnPreference ( 15, newsize ); | 123 | preferences->changeColumnPreference ( 15, newsize ); |
124 | break; | 124 | break; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | void BudgetDisplay::saveSortingPreference ( int column ) | 128 | void BudgetDisplay::saveSortingPreference ( int column ) |
129 | { | 129 | { |
130 | preferences->changeSortingPreference ( 3, column ); | 130 | preferences->changeSortingPreference ( 3, column ); |
131 | } | 131 | } |
132 | 132 | ||
133 | int BudgetDisplay::getIDColumn () | 133 | int BudgetDisplay::getIDColumn () |
134 | { | 134 | { |
135 | int counter; | 135 | int counter; |
136 | int columns = listview->columns(); | 136 | int columns = listview->columns(); |
137 | for ( counter = 0; counter <= columns; counter++ ) | 137 | for ( counter = 0; counter <= columns; counter++ ) |
138 | if ( listview->header()->label ( counter ).length() == 0 ) | 138 | if ( listview->header()->label ( counter ).length() == 0 ) |
139 | return counter; | 139 | return counter; |
140 | } | 140 | } |
141 | 141 | ||
142 | void BudgetDisplay::newBudget () | 142 | void BudgetDisplay::newBudget () |
143 | { | 143 | { |
144 | constructBudgetWindow(); | 144 | constructBudgetWindow(); |
145 | int response = nb->exec(); | 145 | int response = nb->exec(); |
146 | if ( response == 1 ) | 146 | if ( response == 1 ) |
147 | { | 147 | { |
148 | // open a new budget object | 148 | // open a new budget object |
149 | int addedbudget = budget->addBudget ( budgetname->text(), 0, description->text(), currencybox->currencybox->currentText(), day, month, year, day, month, year, 0 ); | 149 | int addedbudget = budget->addBudget ( budgetname->text(), 0, description->text(), currencybox->currencybox->currentText(), day, month, year, day, month, year, 0 ); |
150 | transaction->clearBudgetIDs ( addedbudget ); | 150 | transaction->clearBudgetIDs ( addedbudget ); |
151 | displayBudgetNames(); | 151 | displayBudgetNames(); |
152 | } | 152 | } |
153 | checkBudgets(); | 153 | checkBudgets(); |
154 | } | 154 | } |
155 | 155 | ||
156 | void BudgetDisplay::constructBudgetWindow () | 156 | void BudgetDisplay::constructBudgetWindow () |
157 | { | 157 | { |
158 | //construct and format the new budget window | 158 | //construct and format the new budget window |
159 | nb = new QDialog ( this, 0, TRUE ); | 159 | nb = new QDialog ( this, 0, TRUE ); |
160 | nb->setCaption ( "Budget" ); | 160 | nb->setCaption ( "Budget" ); |
161 | QLabel *namelabel = new QLabel ( "Budget Name", nb ); | 161 | QLabel *namelabel = new QLabel ( "Budget Name", nb ); |
162 | budgetname = new QLineEdit ( nb ); | 162 | budgetname = new QLineEdit ( nb ); |
163 | QLabel *descriptionlabel = new QLabel ( "Description", nb ); | 163 | QLabel *descriptionlabel = new QLabel ( "Description", nb ); |
164 | description = new QLineEdit ( nb ); | 164 | description = new QLineEdit ( nb ); |
165 | currencybox = new Currency ( nb ); | 165 | currencybox = new Currency ( nb ); |
166 | QBoxLayout *layout = new QVBoxLayout ( nb, 2, 2 ); | 166 | QBoxLayout *layout = new QVBoxLayout ( nb, 2, 2 ); |
167 | layout->addWidget ( namelabel ); | 167 | layout->addWidget ( namelabel ); |
168 | layout->addWidget ( budgetname ); | 168 | layout->addWidget ( budgetname ); |
169 | layout->addWidget ( descriptionlabel ); | 169 | layout->addWidget ( descriptionlabel ); |
170 | layout->addWidget ( description ); | 170 | layout->addWidget ( description ); |
171 | layout->addWidget ( currencybox ); | 171 | layout->addWidget ( currencybox ); |
172 | } | 172 | } |
173 | 173 | ||
174 | void BudgetDisplay::displayBudgetNames () | 174 | void BudgetDisplay::displayBudgetNames () |
175 | { | 175 | { |
176 | budgetbox->clear(); | 176 | budgetbox->clear(); |
177 | if ( budget->getNumberOfBudgets() != 0 ) | 177 | if ( budget->getNumberOfBudgets() != 0 ) |
178 | { | 178 | { |
179 | ids = budget->getBudgetIDs(); | 179 | ids = budget->getBudgetIDs(); |
180 | for ( QStringList::Iterator it = ids->begin(); it != ids->end(); ++it ) | 180 | for ( QStringList::Iterator it = ids->begin(); it != ids->end(); ++it ) |
181 | { | 181 | { |
182 | QString flag = "/opt/QtPalmtop/pics/flags/"; | 182 | QString flag = "/opt/QtPalmtop/pics/flags/"; |
183 | flag.append ( budget->getCurrency ( (*it).toInt() ) ); | 183 | flag.append ( budget->getCurrency ( (*it).toInt() ) ); |
184 | flag.append ( ".png" ); | 184 | flag.append ( ".png" ); |
185 | budgetbox->insertItem ( QPixmap ( flag ), budget->getBudgetName ( (*it).toInt() ) ); | 185 | budgetbox->insertItem ( QPixmap ( flag ), budget->getBudgetName ( (*it).toInt() ) ); |
186 | } | 186 | } |
187 | setCurrentBudget ( 0 ); | 187 | setCurrentBudget ( 0 ); |
188 | } | 188 | } |
189 | else | 189 | else |
190 | checkBudgets(); | 190 | checkBudgets(); |
191 | } | 191 | } |
192 | 192 | ||
193 | void BudgetDisplay::setCurrentBudget ( int index ) | 193 | void BudgetDisplay::setCurrentBudget ( int index ) |
194 | { | 194 | { |
195 | currentbudget = ( ids->operator[] ( index ).toInt() ); | 195 | currentbudget = ( ids->operator[] ( index ).toInt() ); |
196 | displayLineItems(); | 196 | displayLineItems(); |
197 | } | 197 | } |
198 | 198 | ||
199 | void BudgetDisplay::setCurrentView ( int index ) | 199 | void BudgetDisplay::setCurrentView ( int index ) |
200 | { | 200 | { |
201 | displayLineItems(); | 201 | displayLineItems(); |
202 | } | 202 | } |
203 | 203 | ||
204 | void BudgetDisplay::showCalendar () | 204 | void BudgetDisplay::showCalendar () |
205 | { | 205 | { |
206 | // create new calendar object and show it | 206 | // create new calendar object and show it |
207 | DatePicker *dp = new DatePicker ( QDate ( year, month, day ) ); | 207 | DatePicker *dp = new DatePicker ( QDate ( year, month, day ) ); |
208 | dp->daylabel->hide(); | 208 | dp->daylabel->hide(); |
209 | dp->daybox->hide(); | 209 | dp->daybox->hide(); |
210 | if ( budgetview->currentItem() == 1 ) | 210 | if ( budgetview->currentItem() == 1 ) |
211 | { | 211 | { |
212 | dp->monthlabel->hide(); | 212 | dp->monthlabel->hide(); |
213 | dp->monthbox->hide(); | 213 | dp->monthbox->hide(); |
214 | } | 214 | } |
215 | dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) ); | 215 | dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) ); |
216 | 216 | ||
217 | int response = dp->exec(); | 217 | int response = dp->exec(); |
218 | if ( response == 1 ) | 218 | if ( response == 1 ) |
219 | { | 219 | { |
220 | // Set date integers | 220 | // Set date integers |
221 | year = dp->getYear(); | 221 | year = dp->getYear(); |
222 | if ( budgetview->currentItem() == 0 ) | 222 | if ( budgetview->currentItem() == 0 ) |
223 | month = dp->getMonth(); | 223 | month = dp->getMonth(); |
224 | else | 224 | else |
225 | month = newDate.month(); | 225 | month = newDate.month(); |
226 | datelabel = preferences->getDate ( year, month ); | 226 | datelabel = preferences->getDate ( year, month ); |
227 | displayLineItems(); | 227 | displayLineItems(); |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | void BudgetDisplay::newLineItem () | 231 | void BudgetDisplay::newLineItem () |
232 | { | 232 | { |
233 | //construct and format the new line item window | 233 | //construct and format the new line item window |
234 | constructLineItemWindow (); | 234 | constructLineItemWindow (); |
235 | 235 | ||
236 | int response = newlineitem->exec(); | 236 | int response = newlineitem->exec(); |
237 | if ( response == 1 ) | 237 | if ( response == 1 ) |
238 | { | 238 | { |
239 | float amount; | 239 | float amount; |
240 | if ( lineitemtime->currentItem() == 0 ) | 240 | if ( lineitemtime->currentItem() == 0 ) |
241 | amount = lineitemamount->text().toFloat(); | 241 | amount = lineitemamount->text().toFloat(); |
242 | else if ( lineitemtime->currentItem() == 1 ) | 242 | else if ( lineitemtime->currentItem() == 1 ) |
243 | amount = lineitemamount->text().toFloat() * 12; | 243 | amount = lineitemamount->text().toFloat() * 12; |
244 | else | 244 | else |
245 | amount = lineitemamount->text().toFloat() * 52; | 245 | amount = lineitemamount->text().toFloat() * 52; |
246 | int lineitemadded = budget->addLineItem ( currentbudget, lineitemname->text(), amount, lineitemtime->currentItem() ); | 246 | int lineitemadded = budget->addLineItem ( currentbudget, lineitemname->text(), amount, lineitemtime->currentItem() ); |
247 | transaction->clearBudgetIDs ( currentbudget, lineitemadded ); | 247 | transaction->clearBudgetIDs ( currentbudget, lineitemadded ); |
248 | displayLineItems(); | 248 | displayLineItems(); |
249 | } | 249 | } |
250 | checkBudgets(); | 250 | checkBudgets(); |
251 | } | 251 | } |
252 | 252 | ||
253 | void BudgetDisplay::constructLineItemWindow () | 253 | void BudgetDisplay::constructLineItemWindow () |
254 | { | 254 | { |
255 | //construct and format the new budget window | 255 | //construct and format the new budget window |
256 | newlineitem = new QDialog ( this, 0, TRUE ); | 256 | newlineitem = new QDialog ( this, 0, TRUE ); |
257 | newlineitem->setCaption ( "Line Item" ); | 257 | newlineitem->setCaption ( "Line Item" ); |
258 | QLabel *namelabel = new QLabel ( "Line Item Name", newlineitem ); | 258 | QLabel *namelabel = new QLabel ( "Line Item Name", newlineitem ); |
259 | lineitemname = new QLineEdit ( newlineitem ); | 259 | lineitemname = new QLineEdit ( newlineitem ); |
260 | QLabel *budgetamountlabel = new QLabel ( "Budget Amount", newlineitem ); | 260 | QLabel *budgetamountlabel = new QLabel ( "Budget Amount", newlineitem ); |
261 | lineitemamount = new QLineEdit ( newlineitem ); | 261 | lineitemamount = new QLineEdit ( newlineitem ); |
262 | QLabel *lineitemtimelabel = new QLabel ( "Per:", newlineitem ); | 262 | QLabel *lineitemtimelabel = new QLabel ( "Per:", newlineitem ); |
263 | lineitemtime = new QComboBox ( newlineitem ); | 263 | lineitemtime = new QComboBox ( newlineitem ); |
264 | lineitemtime->insertItem ( "Year" ); // type 0 | 264 | lineitemtime->insertItem ( "Year" ); // type 0 |
265 | lineitemtime->insertItem ( "Month" ); // type 1 | 265 | lineitemtime->insertItem ( "Month" ); // type 1 |
266 | lineitemtime->insertItem ( "Week" ); // type 2 | 266 | lineitemtime->insertItem ( "Week" ); // type 2 |
267 | QBoxLayout *layout = new QVBoxLayout ( newlineitem, 2, 2 ); | 267 | QBoxLayout *layout = new QVBoxLayout ( newlineitem, 2, 2 ); |
268 | layout->addWidget ( namelabel ); | 268 | layout->addWidget ( namelabel ); |
269 | layout->addWidget ( lineitemname ); | 269 | layout->addWidget ( lineitemname ); |
270 | layout->addWidget ( budgetamountlabel ); | 270 | layout->addWidget ( budgetamountlabel ); |
271 | layout->addWidget ( lineitemamount ); | 271 | layout->addWidget ( lineitemamount ); |
272 | layout->addWidget ( lineitemtimelabel ); | 272 | layout->addWidget ( lineitemtimelabel ); |
273 | layout->addWidget ( lineitemtime ); | 273 | layout->addWidget ( lineitemtime ); |
274 | } | 274 | } |
275 | 275 | ||
276 | void BudgetDisplay::deleteLineItem () | 276 | void BudgetDisplay::deleteLineItem () |
277 | { | 277 | { |
278 | if ( listview->selectedItem() != 0 ) | 278 | if ( listview->selectedItem() != 0 ) |
279 | { | 279 | { |
280 | int lineitemid = listview->selectedItem()->text ( getIDColumn() ).toInt(); | 280 | int lineitemid = listview->selectedItem()->text ( getIDColumn() ).toInt(); |
281 | transaction->clearBudgetIDs ( currentbudget, lineitemid ); | 281 | transaction->clearBudgetIDs ( currentbudget, lineitemid ); |
282 | budget->deleteLineItem ( currentbudget, lineitemid ); | 282 | budget->deleteLineItem ( currentbudget, lineitemid ); |
283 | displayBudgetNames(); | 283 | displayBudgetNames(); |
284 | } | 284 | } |
285 | else | 285 | else |
286 | QMessageBox::warning ( this, "QashMoney", "Please select a line item to delete." ); | 286 | QMessageBox::warning ( this, "QashMoney", "Please select a line item to delete." ); |
287 | checkBudgets(); | 287 | checkBudgets(); |
288 | } | 288 | } |
289 | 289 | ||
290 | void BudgetDisplay::displayLineItems () | 290 | void BudgetDisplay::displayLineItems () |
291 | { | 291 | { |
292 | listview->clear(); | 292 | listview->clear(); |
diff --git a/noncore/apps/qashmoney/budgetdisplay.h b/noncore/apps/qashmoney/budgetdisplay.h index 3976ce1..a4e806c 100755 --- a/noncore/apps/qashmoney/budgetdisplay.h +++ b/noncore/apps/qashmoney/budgetdisplay.h | |||
@@ -1,86 +1,86 @@ | |||
1 | #ifndef BUDGETDISPLAY_H | 1 | #ifndef BUDGETDISPLAY_H |
2 | #define BUDGETDISPLAY_H | 2 | #define BUDGETDISPLAY_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qlineedit.h> | 5 | #include <qlineedit.h> |
6 | #include <qpushbutton.h> | 6 | #include <qpushbutton.h> |
7 | #include <qcombobox.h> | 7 | #include <qcombobox.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | #include <qlabel.h> | 9 | #include <qlabel.h> |
10 | #include <qstringlist.h> | 10 | #include <qstringlist.h> |
11 | #include <qdatetime.h> | 11 | #include <qdatetime.h> |
12 | #include <qpe/qpemenubar.h> | 12 | #include <qmenubar.h> |
13 | #include <qpopupmenu.h> | 13 | #include <qpopupmenu.h> |
14 | #include <qhbox.h> | 14 | #include <qhbox.h> |
15 | 15 | ||
16 | #include "currency.h" | 16 | #include "currency.h" |
17 | 17 | ||
18 | class BudgetDisplay : public QWidget | 18 | class BudgetDisplay : public QWidget |
19 | { | 19 | { |
20 | Q_OBJECT | 20 | Q_OBJECT |
21 | 21 | ||
22 | public: | 22 | public: |
23 | BudgetDisplay ( QWidget *parent ); | 23 | BudgetDisplay ( QWidget *parent ); |
24 | 24 | ||
25 | QPEMenuBar *menu; | 25 | QMenuBar *menu; |
26 | QPopupMenu *budgetmenu; | 26 | QPopupMenu *budgetmenu; |
27 | QPopupMenu *lineitemsmenu; | 27 | QPopupMenu *lineitemsmenu; |
28 | QPopupMenu *datemenu; | 28 | QPopupMenu *datemenu; |
29 | 29 | ||
30 | QHBox *firstline; | 30 | QHBox *firstline; |
31 | QHBox *secondline; | 31 | QHBox *secondline; |
32 | 32 | ||
33 | QLabel *budgeted; | 33 | QLabel *budgeted; |
34 | QLabel *actual; | 34 | QLabel *actual; |
35 | QLabel *date; | 35 | QLabel *date; |
36 | 36 | ||
37 | QLineEdit *budgetname; | 37 | QLineEdit *budgetname; |
38 | QLineEdit *description; | 38 | QLineEdit *description; |
39 | Currency *currencybox; | 39 | Currency *currencybox; |
40 | 40 | ||
41 | QLineEdit *lineitemname; | 41 | QLineEdit *lineitemname; |
42 | QLineEdit *lineitemamount; | 42 | QLineEdit *lineitemamount; |
43 | QComboBox *lineitemtime; | 43 | QComboBox *lineitemtime; |
44 | 44 | ||
45 | QListView *listview; | 45 | QListView *listview; |
46 | QComboBox *budgetbox; | 46 | QComboBox *budgetbox; |
47 | QComboBox *budgetview; | 47 | QComboBox *budgetview; |
48 | 48 | ||
49 | QBoxLayout *layout; | 49 | QBoxLayout *layout; |
50 | 50 | ||
51 | int getIDColumn (); | 51 | int getIDColumn (); |
52 | 52 | ||
53 | public slots: | 53 | public slots: |
54 | void displayBudgetNames (); | 54 | void displayBudgetNames (); |
55 | void displayLineItems (); | 55 | void displayLineItems (); |
56 | void updateBudgetInformation (); | 56 | void updateBudgetInformation (); |
57 | 57 | ||
58 | private slots: | 58 | private slots: |
59 | void saveColumnSize ( int column, int oldsize, int newsize ); | 59 | void saveColumnSize ( int column, int oldsize, int newsize ); |
60 | void newBudget (); | 60 | void newBudget (); |
61 | void deleteBudget (); | 61 | void deleteBudget (); |
62 | void setCurrentBudget ( int ); | 62 | void setCurrentBudget ( int ); |
63 | void setCurrentView ( int ); | 63 | void setCurrentView ( int ); |
64 | void showCalendar (); | 64 | void showCalendar (); |
65 | void newLineItem (); | 65 | void newLineItem (); |
66 | void deleteLineItem (); | 66 | void deleteLineItem (); |
67 | void checkBudgets (); | 67 | void checkBudgets (); |
68 | void editBudget (); | 68 | void editBudget (); |
69 | void editLineItem (); | 69 | void editLineItem (); |
70 | void constructBudgetWindow (); | 70 | void constructBudgetWindow (); |
71 | void constructLineItemWindow (); | 71 | void constructLineItemWindow (); |
72 | void saveSortingPreference ( int column ); | 72 | void saveSortingPreference ( int column ); |
73 | 73 | ||
74 | private: | 74 | private: |
75 | QStringList *names; | 75 | QStringList *names; |
76 | QStringList *ids; | 76 | QStringList *ids; |
77 | int currentbudget, year, month, day; | 77 | int currentbudget, year, month, day; |
78 | QDate newDate; | 78 | QDate newDate; |
79 | QString totalbudget, totalactual; | 79 | QString totalbudget, totalactual; |
80 | QString datelabel; | 80 | QString datelabel; |
81 | QDialog *nb; | 81 | QDialog *nb; |
82 | QDialog *newlineitem; | 82 | QDialog *newlineitem; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | #endif // BUDGETDISPLAY_H | 85 | #endif // BUDGETDISPLAY_H |
86 | 86 | ||
diff --git a/noncore/apps/qashmoney/qashmoney.cpp b/noncore/apps/qashmoney/qashmoney.cpp index 20e8d32..e985f0b 100755 --- a/noncore/apps/qashmoney/qashmoney.cpp +++ b/noncore/apps/qashmoney/qashmoney.cpp | |||
@@ -1,282 +1,282 @@ | |||
1 | #include "qashmoney.h" | 1 | #include "qashmoney.h" |
2 | #include "preferencedialogs.h" | 2 | #include "preferencedialogs.h" |
3 | #include "memorydialog.h" | 3 | #include "memorydialog.h" |
4 | 4 | ||
5 | #include <qheader.h> | 5 | #include <qheader.h> |
6 | #include <iostream.h> | 6 | #include <iostream.h> |
7 | 7 | ||
8 | Budget *budget = new Budget (); | 8 | Budget *budget = new Budget (); |
9 | Preferences *preferences = new Preferences (); | 9 | Preferences *preferences = new Preferences (); |
10 | Account *account = new Account (); | 10 | Account *account = new Account (); |
11 | Transaction *transaction = new Transaction (); | 11 | Transaction *transaction = new Transaction (); |
12 | Transfer *transfer = new Transfer (); | 12 | Transfer *transfer = new Transfer (); |
13 | Memory *memory = new Memory (); | 13 | Memory *memory = new Memory (); |
14 | 14 | ||
15 | QashMoney::QashMoney () : QWidget () | 15 | QashMoney::QashMoney () : QWidget () |
16 | { | 16 | { |
17 | preferences->addPreferences (); | 17 | preferences->addPreferences (); |
18 | preferences->initializeColumnPreferences (); | 18 | preferences->initializeColumnPreferences (); |
19 | preferences->initializeSortingPreferences (); | 19 | preferences->initializeSortingPreferences (); |
20 | 20 | ||
21 | // set the text in the upper part of the frame | 21 | // set the text in the upper part of the frame |
22 | setCaption ( tr ( "QashMoney" ) ); | 22 | setCaption ( tr ( "QashMoney" ) ); |
23 | 23 | ||
24 | // Create new menubar for our mainwindow | 24 | // Create new menubar for our mainwindow |
25 | // and add menu items | 25 | // and add menu items |
26 | mainmenu = new QPEMenuBar ( this ); | 26 | mainmenu = new QMenuBar ( this ); |
27 | mainmenu->setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); | 27 | mainmenu->setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); |
28 | preferencesmenu = new QPopupMenu ( this ); | 28 | preferencesmenu = new QPopupMenu ( this ); |
29 | utilitiesmenu = new QPopupMenu ( this ); | 29 | utilitiesmenu = new QPopupMenu ( this ); |
30 | mainmenu->insertItem ( "Preferences", preferencesmenu ); | 30 | mainmenu->insertItem ( "Preferences", preferencesmenu ); |
31 | mainmenu->insertItem ( "Utilities", utilitiesmenu ); | 31 | mainmenu->insertItem ( "Utilities", utilitiesmenu ); |
32 | preferencesmenu->insertItem ( "Date", this, SLOT ( displayDatePreferencesDialog () ) ); | 32 | preferencesmenu->insertItem ( "Date", this, SLOT ( displayDatePreferencesDialog () ) ); |
33 | preferencesmenu->insertItem ( "Account", this, SLOT ( displayAccountPreferencesDialog () ) ); | 33 | preferencesmenu->insertItem ( "Account", this, SLOT ( displayAccountPreferencesDialog () ) ); |
34 | preferencesmenu->insertItem ( "Transaction", this, SLOT ( displayTransactionPreferencesDialog () ) ); | 34 | preferencesmenu->insertItem ( "Transaction", this, SLOT ( displayTransactionPreferencesDialog () ) ); |
35 | utilitiesmenu->insertItem ( "Memory", this, SLOT ( displayMemoryDialog () ) ); | 35 | utilitiesmenu->insertItem ( "Memory", this, SLOT ( displayMemoryDialog () ) ); |
36 | 36 | ||
37 | // create the main tabwidget for displaying accounts and transactions | 37 | // create the main tabwidget for displaying accounts and transactions |
38 | maintabs = new QTabWidget ( this ); | 38 | maintabs = new QTabWidget ( this ); |
39 | tab = new QWidget ( this ); | 39 | tab = new QWidget ( this ); |
40 | tab_2 = new QWidget ( this ); | 40 | tab_2 = new QWidget ( this ); |
41 | tab_3 = new QWidget ( this ); | 41 | tab_3 = new QWidget ( this ); |
42 | maintabs->addTab ( tab, "Accounts" ); | 42 | maintabs->addTab ( tab, "Accounts" ); |
43 | maintabs->addTab ( tab_2, "Transactions" ); | 43 | maintabs->addTab ( tab_2, "Transactions" ); |
44 | maintabs->addTab ( tab_3, "Budgets" ); | 44 | maintabs->addTab ( tab_3, "Budgets" ); |
45 | tabheight = tab->height(); | 45 | tabheight = tab->height(); |
46 | maintabs->setTabEnabled ( tab_2, FALSE ); | 46 | maintabs->setTabEnabled ( tab_2, FALSE ); |
47 | 47 | ||
48 | // create a new account display object | 48 | // create a new account display object |
49 | accountdisplay = new AccountDisplay ( maintabs ); | 49 | accountdisplay = new AccountDisplay ( maintabs ); |
50 | accountdisplay->setTabs ( tab_2, maintabs ); | 50 | accountdisplay->setTabs ( tab_2, maintabs ); |
51 | connect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( setTransactionTab () ) ); | 51 | connect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( setTransactionTab () ) ); |
52 | 52 | ||
53 | // set the connection to disable the one touch account viewing if we are transfering money | 53 | // set the connection to disable the one touch account viewing if we are transfering money |
54 | connect ( accountdisplay->transferbutton, SIGNAL ( toggled ( bool ) ), this, SLOT ( toggleOneTouchViewing ( bool ) ) ); | 54 | connect ( accountdisplay->transferbutton, SIGNAL ( toggled ( bool ) ), this, SLOT ( toggleOneTouchViewing ( bool ) ) ); |
55 | 55 | ||
56 | // create a new transactiondisplay object | 56 | // create a new transactiondisplay object |
57 | transactiondisplay = new TransactionDisplay ( maintabs ); | 57 | transactiondisplay = new TransactionDisplay ( maintabs ); |
58 | transactiondisplay->hide(); | 58 | transactiondisplay->hide(); |
59 | 59 | ||
60 | // create new budgetdisplay object | 60 | // create new budgetdisplay object |
61 | budgetdisplay = new BudgetDisplay ( maintabs ); | 61 | budgetdisplay = new BudgetDisplay ( maintabs ); |
62 | budgetdisplay->hide(); | 62 | budgetdisplay->hide(); |
63 | 63 | ||
64 | tabslayout = new QVBoxLayout ( maintabs, 4, 2 ); | 64 | tabslayout = new QVBoxLayout ( maintabs, 4, 2 ); |
65 | tabslayout->addSpacing ( tabheight ); | 65 | tabslayout->addSpacing ( tabheight ); |
66 | tabslayout->addWidget ( accountdisplay ); | 66 | tabslayout->addWidget ( accountdisplay ); |
67 | tabslayout->addWidget ( transactiondisplay ); | 67 | tabslayout->addWidget ( transactiondisplay ); |
68 | tabslayout->addWidget ( budgetdisplay ); | 68 | tabslayout->addWidget ( budgetdisplay ); |
69 | 69 | ||
70 | // connect a change in the maintabs with changing the tab display | 70 | // connect a change in the maintabs with changing the tab display |
71 | connect ( maintabs, SIGNAL ( currentChanged ( QWidget * ) ), this, SLOT ( changeTabDisplay () ) ); | 71 | connect ( maintabs, SIGNAL ( currentChanged ( QWidget * ) ), this, SLOT ( changeTabDisplay () ) ); |
72 | 72 | ||
73 | // create layout that will contain the menubar and the maintabs | 73 | // create layout that will contain the menubar and the maintabs |
74 | layout = new QVBoxLayout ( this, 2, 2 ); | 74 | layout = new QVBoxLayout ( this, 2, 2 ); |
75 | layout->setMenuBar ( mainmenu ); | 75 | layout->setMenuBar ( mainmenu ); |
76 | layout->addWidget ( maintabs ); | 76 | layout->addWidget ( maintabs ); |
77 | } | 77 | } |
78 | 78 | ||
79 | QashMoney::~QashMoney () | 79 | QashMoney::~QashMoney () |
80 | { | 80 | { |
81 | delete budget; | 81 | delete budget; |
82 | delete preferences; | 82 | delete preferences; |
83 | delete account; | 83 | delete account; |
84 | delete transaction; | 84 | delete transaction; |
85 | delete transfer; | 85 | delete transfer; |
86 | delete memory; | 86 | delete memory; |
87 | } | 87 | } |
88 | 88 | ||
89 | void QashMoney::changeTabDisplay () | 89 | void QashMoney::changeTabDisplay () |
90 | { | 90 | { |
91 | // if the user pressed the transactions tab, hide the account display | 91 | // if the user pressed the transactions tab, hide the account display |
92 | // object and create a new transaction display | 92 | // object and create a new transaction display |
93 | if ( maintabs->currentPageIndex() == 1 ) | 93 | if ( maintabs->currentPageIndex() == 1 ) |
94 | { | 94 | { |
95 | // initialize variables | 95 | // initialize variables |
96 | bool children = FALSE; | 96 | bool children = FALSE; |
97 | 97 | ||
98 | // hide the account display and define accountid | 98 | // hide the account display and define accountid |
99 | int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt(); | 99 | int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt(); |
100 | 100 | ||
101 | //remove all the columns from the transactiondisplay | 101 | //remove all the columns from the transactiondisplay |
102 | int columns = transactiondisplay->listview->columns(); | 102 | int columns = transactiondisplay->listview->columns(); |
103 | int counter; | 103 | int counter; |
104 | for ( counter = 0; counter <= columns; counter++ ) | 104 | for ( counter = 0; counter <= columns; counter++ ) |
105 | transactiondisplay->listview->removeColumn ( 0 ); | 105 | transactiondisplay->listview->removeColumn ( 0 ); |
106 | 106 | ||
107 | // set the account name and account balance | 107 | // set the account name and account balance |
108 | QString name = account->getAccountName ( accountid ); | 108 | QString name = account->getAccountName ( accountid ); |
109 | QString balance = account->getAccountBalance ( accountid ); | 109 | QString balance = account->getAccountBalance ( accountid ); |
110 | transactiondisplay->name->setText ( name ); | 110 | transactiondisplay->name->setText ( name ); |
111 | transactiondisplay->balance->setText ( balance ); | 111 | transactiondisplay->balance->setText ( balance ); |
112 | 112 | ||
113 | // clear the limitbox | 113 | // clear the limitbox |
114 | transactiondisplay->limitbox->clear(); | 114 | transactiondisplay->limitbox->clear(); |
115 | 115 | ||
116 | // get parent account id | 116 | // get parent account id |
117 | int parentaccountid = account->getParentAccountID ( accountid ); | 117 | int parentaccountid = account->getParentAccountID ( accountid ); |
118 | 118 | ||
119 | // add columns based on which account is selected | 119 | // add columns based on which account is selected |
120 | // this first if determines if we selected a parent with no children or a child | 120 | // this first if determines if we selected a parent with no children or a child |
121 | // in these cases, we add standard three columns for date, transaction, amount | 121 | // in these cases, we add standard three columns for date, transaction, amount |
122 | transactiondisplay->listview->addColumn ( "Date", 0 ); | 122 | transactiondisplay->listview->addColumn ( "Date", 0 ); |
123 | transactiondisplay->listview->addColumn ( "Transaction", 0 ); | 123 | transactiondisplay->listview->addColumn ( "Transaction", 0 ); |
124 | transactiondisplay->listview->addColumn ( "Amt", 0); | 124 | transactiondisplay->listview->addColumn ( "Amt", 0); |
125 | transactiondisplay->listview->setColumnAlignment ( 2, Qt::AlignRight ); | 125 | transactiondisplay->listview->setColumnAlignment ( 2, Qt::AlignRight ); |
126 | transactiondisplay->listview->addColumn ( "", 0 ); | 126 | transactiondisplay->listview->addColumn ( "", 0 ); |
127 | 127 | ||
128 | if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) // we selected a parent with children | 128 | if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) // we selected a parent with children |
129 | { | 129 | { |
130 | // add an extra column for the account name for eac child transaction | 130 | // add an extra column for the account name for eac child transaction |
131 | transactiondisplay->listview->addColumn ( "Acct", 0 ); | 131 | transactiondisplay->listview->addColumn ( "Acct", 0 ); |
132 | children = TRUE; | 132 | children = TRUE; |
133 | 133 | ||
134 | // hide the new transaction button | 134 | // hide the new transaction button |
135 | transactiondisplay->newtransaction->setEnabled ( FALSE ); | 135 | transactiondisplay->newtransaction->setEnabled ( FALSE ); |
136 | } | 136 | } |
137 | else //we selected a parent without children or a child | 137 | else //we selected a parent without children or a child |
138 | transactiondisplay->newtransaction->setEnabled ( TRUE ); | 138 | transactiondisplay->newtransaction->setEnabled ( TRUE ); |
139 | 139 | ||
140 | // disable the transactionid column so it can't be red | 140 | // disable the transactionid column so it can't be red |
141 | transactiondisplay->listview->header()->setResizeEnabled ( FALSE, 3 ); | 141 | transactiondisplay->listview->header()->setResizeEnabled ( FALSE, 3 ); |
142 | 142 | ||
143 | // set the accountid and children variables | 143 | // set the accountid and children variables |
144 | transactiondisplay->setChildren ( children ); | 144 | transactiondisplay->setChildren ( children ); |
145 | transactiondisplay->setAccountID ( accountid ); | 145 | transactiondisplay->setAccountID ( accountid ); |
146 | 146 | ||
147 | setTransactionDisplayDate (); | 147 | setTransactionDisplayDate (); |
148 | 148 | ||
149 | // display transactions | 149 | // display transactions |
150 | transactiondisplay->listview->clear(); | 150 | transactiondisplay->listview->clear(); |
151 | QString displaytext = "%"; | 151 | QString displaytext = "%"; |
152 | displaytext.prepend ( transactiondisplay->limitbox->text() ); | 152 | displaytext.prepend ( transactiondisplay->limitbox->text() ); |
153 | if ( transaction->getNumberOfTransactions() > 0 ) | 153 | if ( transaction->getNumberOfTransactions() > 0 ) |
154 | transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate ); | 154 | transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate ); |
155 | 155 | ||
156 | // display transfers | 156 | // display transfers |
157 | transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate ); | 157 | transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate ); |
158 | 158 | ||
159 | // open a new preferences object and resize the transaction display columns | 159 | // open a new preferences object and resize the transaction display columns |
160 | // each column will have a different size based on whether we are looking at a child | 160 | // each column will have a different size based on whether we are looking at a child |
161 | // account or children through a parent | 161 | // account or children through a parent |
162 | if ( parentaccountid != -1 || accountdisplay->listview->selectedItem()->childCount() == 0 ) // a parent with no children or a child - three columns | 162 | if ( parentaccountid != -1 || accountdisplay->listview->selectedItem()->childCount() == 0 ) // a parent with no children or a child - three columns |
163 | { | 163 | { |
164 | transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 3 ) ); // normal transaction date width | 164 | transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 3 ) ); // normal transaction date width |
165 | transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual ); | 165 | transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual ); |
166 | transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 4 ) ); // normal transaction name width | 166 | transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 4 ) ); // normal transaction name width |
167 | transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual ); | 167 | transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual ); |
168 | transactiondisplay->listview->setColumnWidth ( 2, preferences->getColumnPreference ( 5 ) ); // normal transaction amount width | 168 | transactiondisplay->listview->setColumnWidth ( 2, preferences->getColumnPreference ( 5 ) ); // normal transaction amount width |
169 | transactiondisplay->listview->setColumnWidthMode ( 2, QListView::Manual ); | 169 | transactiondisplay->listview->setColumnWidthMode ( 2, QListView::Manual ); |
170 | } | 170 | } |
171 | else | 171 | else |
172 | { | 172 | { |
173 | transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 6 ) ); // extended transaction date width | 173 | transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 6 ) ); // extended transaction date width |
174 | transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual ); | 174 | transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual ); |
175 | transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 7 ) ); // extended transaction name width | 175 | transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 7 ) ); // extended transaction name width |
176 | transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual ); | 176 | transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual ); |
177 | transactiondisplay->listview->setColumnWidth ( 2, preferences->getColumnPreference ( 8 ) ); // extended transaction amount width | 177 | transactiondisplay->listview->setColumnWidth ( 2, preferences->getColumnPreference ( 8 ) ); // extended transaction amount width |
178 | transactiondisplay->listview->setColumnWidthMode ( 2, QListView::Manual ); | 178 | transactiondisplay->listview->setColumnWidthMode ( 2, QListView::Manual ); |
179 | transactiondisplay->listview->setColumnWidth ( 4, preferences->getColumnPreference ( 9 ) ); // transaction account width | 179 | transactiondisplay->listview->setColumnWidth ( 4, preferences->getColumnPreference ( 9 ) ); // transaction account width |
180 | transactiondisplay->listview->setColumnWidthMode ( 4, QListView::Manual ); | 180 | transactiondisplay->listview->setColumnWidthMode ( 4, QListView::Manual ); |
181 | } | 181 | } |
182 | 182 | ||
183 | // pull the column sorting preference from the preferences table, and configure the listview accordingly | 183 | // pull the column sorting preference from the preferences table, and configure the listview accordingly |
184 | int column = 0; | 184 | int column = 0; |
185 | int direction = 0; | 185 | int direction = 0; |
186 | preferences->getSortingPreference ( 2, &column, &direction ); | 186 | preferences->getSortingPreference ( 2, &column, &direction ); |
187 | transactiondisplay->listview->setSorting ( column, direction ); | 187 | transactiondisplay->listview->setSorting ( column, direction ); |
188 | 188 | ||
189 | // show the window | 189 | // show the window |
190 | transactiondisplay->show(); | 190 | transactiondisplay->show(); |
191 | // hide the account display and define accountid | 191 | // hide the account display and define accountid |
192 | accountdisplay->hide(); | 192 | accountdisplay->hide(); |
193 | // hide the budget display | 193 | // hide the budget display |
194 | budgetdisplay->hide(); | 194 | budgetdisplay->hide(); |
195 | } | 195 | } |
196 | else if ( maintabs->currentPageIndex() == 0 ) | 196 | else if ( maintabs->currentPageIndex() == 0 ) |
197 | { | 197 | { |
198 | disableOneTouchViewing(); | 198 | disableOneTouchViewing(); |
199 | 199 | ||
200 | // clear the account display selection | 200 | // clear the account display selection |
201 | accountdisplay->listview->clearSelection(); | 201 | accountdisplay->listview->clearSelection(); |
202 | 202 | ||
203 | // resize the account display columns | 203 | // resize the account display columns |
204 | accountdisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 1 ) ); | 204 | accountdisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 1 ) ); |
205 | accountdisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 2 ) ); | 205 | accountdisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 2 ) ); |
206 | 206 | ||
207 | // set sorting preference on account display columns | 207 | // set sorting preference on account display columns |
208 | int column = 0; | 208 | int column = 0; |
209 | int direction = 0; | 209 | int direction = 0; |
210 | preferences->getSortingPreference ( 1, &column, &direction ); | 210 | preferences->getSortingPreference ( 1, &column, &direction ); |
211 | accountdisplay->listview->setSorting ( column, direction ); | 211 | accountdisplay->listview->setSorting ( column, direction ); |
212 | 212 | ||
213 | // display the accounts | 213 | // display the accounts |
214 | if ( account->getNumberOfAccounts() != 0 ) | 214 | if ( account->getNumberOfAccounts() != 0 ) |
215 | account->displayAccounts ( accountdisplay->listview ); | 215 | account->displayAccounts ( accountdisplay->listview ); |
216 | maintabs->setTabEnabled ( tab_2, FALSE ); | 216 | maintabs->setTabEnabled ( tab_2, FALSE ); |
217 | 217 | ||
218 | // set the toggle button | 218 | // set the toggle button |
219 | accountdisplay->setToggleButton (); | 219 | accountdisplay->setToggleButton (); |
220 | 220 | ||
221 | // show the account display | 221 | // show the account display |
222 | accountdisplay->show(); | 222 | accountdisplay->show(); |
223 | 223 | ||
224 | // hide the transaction display | 224 | // hide the transaction display |
225 | transactiondisplay->hide(); | 225 | transactiondisplay->hide(); |
226 | 226 | ||
227 | // hide the budget display | 227 | // hide the budget display |
228 | budgetdisplay->hide(); | 228 | budgetdisplay->hide(); |
229 | 229 | ||
230 | 230 | ||
231 | enableOneTouchViewing (); | 231 | enableOneTouchViewing (); |
232 | } | 232 | } |
233 | else | 233 | else |
234 | { | 234 | { |
235 | budgetdisplay->displayLineItems(); | 235 | budgetdisplay->displayLineItems(); |
236 | budgetdisplay->show(); | 236 | budgetdisplay->show(); |
237 | transactiondisplay->hide(); | 237 | transactiondisplay->hide(); |
238 | accountdisplay->hide(); | 238 | accountdisplay->hide(); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | void QashMoney::setTransactionTab () | 242 | void QashMoney::setTransactionTab () |
243 | { | 243 | { |
244 | if ( accountdisplay->listview->selectedItem() == 0 ) | 244 | if ( accountdisplay->listview->selectedItem() == 0 ) |
245 | maintabs->setTabEnabled ( tab_2, FALSE ); | 245 | maintabs->setTabEnabled ( tab_2, FALSE ); |
246 | else | 246 | else |
247 | maintabs->setTabEnabled ( tab_2, TRUE ); | 247 | maintabs->setTabEnabled ( tab_2, TRUE ); |
248 | } | 248 | } |
249 | 249 | ||
250 | void QashMoney::displayDatePreferencesDialog () | 250 | void QashMoney::displayDatePreferencesDialog () |
251 | { | 251 | { |
252 | // this shows a dialog to set preferences for formatting the date | 252 | // this shows a dialog to set preferences for formatting the date |
253 | DatePreferences *pd = new DatePreferences ( this ); | 253 | DatePreferences *pd = new DatePreferences ( this ); |
254 | pd->exec (); | 254 | pd->exec (); |
255 | if ( transactiondisplay->isVisible() ) | 255 | if ( transactiondisplay->isVisible() ) |
256 | { | 256 | { |
257 | // set the account id | 257 | // set the account id |
258 | int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt(); | 258 | int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt(); |
259 | 259 | ||
260 | // set children so we can let displayTransfers know if there are children for the selected account | 260 | // set children so we can let displayTransfers know if there are children for the selected account |
261 | bool children; | 261 | bool children; |
262 | if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) | 262 | if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) |
263 | children = TRUE; | 263 | children = TRUE; |
264 | else | 264 | else |
265 | children = FALSE; | 265 | children = FALSE; |
266 | 266 | ||
267 | // redisplay transactions if they are visible incorporating | 267 | // redisplay transactions if they are visible incorporating |
268 | // any changes to the date format | 268 | // any changes to the date format |
269 | transactiondisplay->listview->clear(); | 269 | transactiondisplay->listview->clear(); |
270 | QString displaytext = "%"; | 270 | QString displaytext = "%"; |
271 | displaytext.prepend ( transactiondisplay->limitbox->text() ); | 271 | displaytext.prepend ( transactiondisplay->limitbox->text() ); |
272 | 272 | ||
273 | setTransactionDisplayDate(); | 273 | setTransactionDisplayDate(); |
274 | if ( transaction->getNumberOfTransactions() > 0 ) | 274 | if ( transaction->getNumberOfTransactions() > 0 ) |
275 | transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate ); | 275 | transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate ); |
276 | 276 | ||
277 | if ( transfer->getNumberOfTransfers() != 0 ) | 277 | if ( transfer->getNumberOfTransfers() != 0 ) |
278 | transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate ); | 278 | transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate ); |
279 | } | 279 | } |
280 | else if ( accountdisplay->isVisible() ) | 280 | else if ( accountdisplay->isVisible() ) |
281 | { | 281 | { |
282 | accountdisplay->listview->clearSelection(); | 282 | accountdisplay->listview->clearSelection(); |
diff --git a/noncore/apps/qashmoney/qashmoney.h b/noncore/apps/qashmoney/qashmoney.h index ec2c7ec..f2c456c 100755 --- a/noncore/apps/qashmoney/qashmoney.h +++ b/noncore/apps/qashmoney/qashmoney.h | |||
@@ -1,64 +1,64 @@ | |||
1 | #ifndef QASHMONEY_H | 1 | #ifndef QASHMONEY_H |
2 | #define QASHMONEY_H | 2 | #define QASHMONEY_H |
3 | 3 | ||
4 | #include <qpe/qpemenubar.h> | 4 | #include <qmenubar.h> |
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qlayout.h> | 6 | #include <qlayout.h> |
7 | #include <qtabwidget.h> | 7 | #include <qtabwidget.h> |
8 | #include <qdatetime.h> | 8 | #include <qdatetime.h> |
9 | 9 | ||
10 | #include "accountdisplay.h" | 10 | #include "accountdisplay.h" |
11 | #include "transactiondisplay.h" | 11 | #include "transactiondisplay.h" |
12 | #include "budgetdisplay.h" | 12 | #include "budgetdisplay.h" |
13 | #include "account.h" | 13 | #include "account.h" |
14 | #include "preferences.h" | 14 | #include "preferences.h" |
15 | #include "transaction.h" | 15 | #include "transaction.h" |
16 | #include "transfer.h" | 16 | #include "transfer.h" |
17 | #include "memory.h" | 17 | #include "memory.h" |
18 | #include "budget.h" | 18 | #include "budget.h" |
19 | 19 | ||
20 | class QashMoney : public QWidget | 20 | class QashMoney : public QWidget |
21 | { | 21 | { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | 23 | ||
24 | public: | 24 | public: |
25 | QashMoney (); | 25 | QashMoney (); |
26 | ~QashMoney(); | 26 | ~QashMoney(); |
27 | 27 | ||
28 | QTabWidget* maintabs; | 28 | QTabWidget* maintabs; |
29 | QWidget* tab; | 29 | QWidget* tab; |
30 | QWidget* tab_2; | 30 | QWidget* tab_2; |
31 | QWidget* tab_3; | 31 | QWidget* tab_3; |
32 | 32 | ||
33 | QPEMenuBar *mainmenu; | 33 | QMenuBar *mainmenu; |
34 | QPopupMenu *preferencesmenu; | 34 | QPopupMenu *preferencesmenu; |
35 | QPopupMenu *utilitiesmenu; | 35 | QPopupMenu *utilitiesmenu; |
36 | 36 | ||
37 | public slots: | 37 | public slots: |
38 | void displayDatePreferencesDialog (); | 38 | void displayDatePreferencesDialog (); |
39 | void displayTransactionPreferencesDialog (); | 39 | void displayTransactionPreferencesDialog (); |
40 | void displayAccountPreferencesDialog (); | 40 | void displayAccountPreferencesDialog (); |
41 | void displayMemoryDialog (); | 41 | void displayMemoryDialog (); |
42 | void setTransactionTab (); | 42 | void setTransactionTab (); |
43 | 43 | ||
44 | private slots: | 44 | private slots: |
45 | void changeTabDisplay (); | 45 | void changeTabDisplay (); |
46 | void showTransactions (); | 46 | void showTransactions (); |
47 | void enableOneTouchViewing (); | 47 | void enableOneTouchViewing (); |
48 | void disableOneTouchViewing (); | 48 | void disableOneTouchViewing (); |
49 | void toggleOneTouchViewing ( bool ); | 49 | void toggleOneTouchViewing ( bool ); |
50 | void setTransactionDisplayDate (); | 50 | void setTransactionDisplayDate (); |
51 | 51 | ||
52 | private: | 52 | private: |
53 | QVBoxLayout *layout; | 53 | QVBoxLayout *layout; |
54 | QVBoxLayout *tabslayout; | 54 | QVBoxLayout *tabslayout; |
55 | AccountDisplay *accountdisplay; | 55 | AccountDisplay *accountdisplay; |
56 | TransactionDisplay *transactiondisplay; | 56 | TransactionDisplay *transactiondisplay; |
57 | BudgetDisplay *budgetdisplay; | 57 | BudgetDisplay *budgetdisplay; |
58 | int tabheight; | 58 | int tabheight; |
59 | QDate newdate; | 59 | QDate newdate; |
60 | 60 | ||
61 | }; | 61 | }; |
62 | 62 | ||
63 | #endif | 63 | #endif |
64 | 64 | ||
diff --git a/noncore/apps/tableviewer/tableviewer.cpp b/noncore/apps/tableviewer/tableviewer.cpp index fbb5c24..fdf0072 100644 --- a/noncore/apps/tableviewer/tableviewer.cpp +++ b/noncore/apps/tableviewer/tableviewer.cpp | |||
@@ -1,325 +1,325 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | /* local includes */ | 21 | /* local includes */ |
22 | #include "tableviewer.h" | 22 | #include "tableviewer.h" |
23 | #include "ui/tvbrowseview.h" | 23 | #include "ui/tvbrowseview.h" |
24 | #include "ui/tvfilterview.h" | 24 | #include "ui/tvfilterview.h" |
25 | #include "ui/tvlistview.h" | 25 | #include "ui/tvlistview.h" |
26 | #include "ui/tveditview.h" | 26 | #include "ui/tveditview.h" |
27 | #include "ui/tvkeyedit.h" | 27 | #include "ui/tvkeyedit.h" |
28 | #include "db/datacache.h" | 28 | #include "db/datacache.h" |
29 | 29 | ||
30 | /* QPE includes */ | 30 | /* QPE includes */ |
31 | #include <qpe/fileselector.h> | 31 | #include <qpe/fileselector.h> |
32 | #include <qpe/resource.h> | 32 | #include <qpe/resource.h> |
33 | #include <qpe/qpetoolbar.h> | 33 | #include <qpe/qpetoolbar.h> |
34 | 34 | ||
35 | /* QTE includes */ | 35 | /* QTE includes */ |
36 | #include <qpe/qpemenubar.h> | 36 | #include <qpe/qpemenubar.h> |
37 | #include <qpe/qpetoolbar.h> | 37 | #include <qpe/qpetoolbar.h> |
38 | #include <qpopupmenu.h> | 38 | #include <qpopupmenu.h> |
39 | #include <qapplication.h> | 39 | #include <qapplication.h> |
40 | #include <qwidgetstack.h> | 40 | #include <qwidgetstack.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qbuffer.h> | 42 | #include <qbuffer.h> |
43 | /*! | 43 | /*! |
44 | \class TableViewerWindow | 44 | \class TableViewerWindow |
45 | \brief The main window widget of the application | 45 | \brief The main window widget of the application |
46 | 46 | ||
47 | This is the main widget of the table viewer application. | 47 | This is the main widget of the table viewer application. |
48 | It is the co-ordination point. | 48 | It is the co-ordination point. |
49 | */ | 49 | */ |
50 | 50 | ||
51 | /*! | 51 | /*! |
52 | Constructs a new TableViewerWindow | 52 | Constructs a new TableViewerWindow |
53 | */ | 53 | */ |
54 | TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f) | 54 | TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f) |
55 | : QMainWindow(parent, name, f) | 55 | : QMainWindow(parent, name, f) |
56 | { | 56 | { |
57 | setCaption(tr("Table Viewer")); | 57 | setCaption(tr("Table Viewer")); |
58 | 58 | ||
59 | /* Build data */ | 59 | /* Build data */ |
60 | ds = new DBStore(); | 60 | ds = new DBStore(); |
61 | doc.setType("text/x-xml-tableviewer"); | 61 | doc.setType("text/x-xml-tableviewer"); |
62 | doc.setName("table"); | 62 | doc.setName("table"); |
63 | 63 | ||
64 | dirty = FALSE; | 64 | dirty = FALSE; |
65 | ts.current_column = 0; | 65 | ts.current_column = 0; |
66 | ts.kRep = ds->getKeys(); | 66 | ts.kRep = ds->getKeys(); |
67 | 67 | ||
68 | /* build menus */ | 68 | /* build menus */ |
69 | menu = new QPEMenuBar(this, 0); | 69 | menu = new QMenuBar(this, 0); |
70 | 70 | ||
71 | QPopupMenu *file_menu = new QPopupMenu; | 71 | QPopupMenu *file_menu = new QPopupMenu; |
72 | file_menu->insertItem("New", this, SLOT(newDocument())); | 72 | file_menu->insertItem("New", this, SLOT(newDocument())); |
73 | 73 | ||
74 | file_menu->insertItem("Open", this, SLOT(selectDocument())); | 74 | file_menu->insertItem("Open", this, SLOT(selectDocument())); |
75 | file_menu->insertSeparator(); | 75 | file_menu->insertSeparator(); |
76 | file_menu->insertItem("Properties"); | 76 | file_menu->insertItem("Properties"); |
77 | 77 | ||
78 | /* later will want to set this up to clean up first via this, SLOT(quit) */ | 78 | /* later will want to set this up to clean up first via this, SLOT(quit) */ |
79 | menu->insertItem("Document", file_menu); | 79 | menu->insertItem("Document", file_menu); |
80 | 80 | ||
81 | QPopupMenu *edit_menu = new QPopupMenu; | 81 | QPopupMenu *edit_menu = new QPopupMenu; |
82 | edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot())); | 82 | edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot())); |
83 | edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot())); | 83 | edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot())); |
84 | edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot())); | 84 | edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot())); |
85 | menu->insertItem("Edit", edit_menu); | 85 | menu->insertItem("Edit", edit_menu); |
86 | 86 | ||
87 | QPopupMenu *view_menu = new QPopupMenu; | 87 | QPopupMenu *view_menu = new QPopupMenu; |
88 | view_menu->insertItem("Browse View", this, SLOT(browseViewSlot())); | 88 | view_menu->insertItem("Browse View", this, SLOT(browseViewSlot())); |
89 | view_menu->insertItem("List View", this, SLOT(listViewSlot())); | 89 | view_menu->insertItem("List View", this, SLOT(listViewSlot())); |
90 | menu->insertItem("View", view_menu); | 90 | menu->insertItem("View", view_menu); |
91 | 91 | ||
92 | QVBoxLayout *main_layout = new QVBoxLayout; | 92 | QVBoxLayout *main_layout = new QVBoxLayout; |
93 | 93 | ||
94 | /* Build tool bar */ | 94 | /* Build tool bar */ |
95 | navigation = new QPEToolBar(this, "navigation"); | 95 | navigation = new QPEToolBar(this, "navigation"); |
96 | QToolButton *newItemButton = new QToolButton( | 96 | QToolButton *newItemButton = new QToolButton( |
97 | QIconSet(Resource::loadPixmap("new")), "New Item", QString::null, | 97 | QIconSet(Resource::loadPixmap("new")), "New Item", QString::null, |
98 | this, SLOT(newItemSlot()), navigation, "New Item"); | 98 | this, SLOT(newItemSlot()), navigation, "New Item"); |
99 | QToolButton *editItemButton = new QToolButton( | 99 | QToolButton *editItemButton = new QToolButton( |
100 | QIconSet(Resource::loadPixmap("edit")), "Edit Item", QString::null, | 100 | QIconSet(Resource::loadPixmap("edit")), "Edit Item", QString::null, |
101 | this, SLOT(editItemSlot()), navigation, "Edit Item"); | 101 | this, SLOT(editItemSlot()), navigation, "Edit Item"); |
102 | QToolButton *deleteItemButton = new QToolButton( | 102 | QToolButton *deleteItemButton = new QToolButton( |
103 | QIconSet(Resource::loadPixmap("trash")), "Delete Item", | 103 | QIconSet(Resource::loadPixmap("trash")), "Delete Item", |
104 | QString::null, this, | 104 | QString::null, this, |
105 | SLOT(deleteItemSlot()), navigation, "Delete Item"); | 105 | SLOT(deleteItemSlot()), navigation, "Delete Item"); |
106 | 106 | ||
107 | navigation->addSeparator(); | 107 | navigation->addSeparator(); |
108 | 108 | ||
109 | QToolButton *firstItemButton = new QToolButton( | 109 | QToolButton *firstItemButton = new QToolButton( |
110 | QIconSet(Resource::loadPixmap("fastback")), "First Item", | 110 | QIconSet(Resource::loadPixmap("fastback")), "First Item", |
111 | QString::null, this, | 111 | QString::null, this, |
112 | SLOT(firstItem()), navigation, "First Item"); | 112 | SLOT(firstItem()), navigation, "First Item"); |
113 | QToolButton *previousItemButton = new QToolButton( | 113 | QToolButton *previousItemButton = new QToolButton( |
114 | QIconSet(Resource::loadPixmap("back")), "Previous Item", | 114 | QIconSet(Resource::loadPixmap("back")), "Previous Item", |
115 | QString::null, this, | 115 | QString::null, this, |
116 | SLOT(previousItem()), navigation, "Previous Item"); | 116 | SLOT(previousItem()), navigation, "Previous Item"); |
117 | QToolButton *nextItemButton = new QToolButton( | 117 | QToolButton *nextItemButton = new QToolButton( |
118 | QIconSet(Resource::loadPixmap("forward")), "Next Item", | 118 | QIconSet(Resource::loadPixmap("forward")), "Next Item", |
119 | QString::null, this, | 119 | QString::null, this, |
120 | SLOT(nextItem()), navigation, "Next Item"); | 120 | SLOT(nextItem()), navigation, "Next Item"); |
121 | QToolButton *lastItemButton = new QToolButton( | 121 | QToolButton *lastItemButton = new QToolButton( |
122 | QIconSet(Resource::loadPixmap("fastforward")), "Last Item", | 122 | QIconSet(Resource::loadPixmap("fastforward")), "Last Item", |
123 | QString::null, this, | 123 | QString::null, this, |
124 | SLOT(lastItem()), navigation, "Last Item"); | 124 | SLOT(lastItem()), navigation, "Last Item"); |
125 | 125 | ||
126 | navigation->addSeparator(); | 126 | navigation->addSeparator(); |
127 | QToolButton *browseButton = new QToolButton( | 127 | QToolButton *browseButton = new QToolButton( |
128 | QIconSet(Resource::loadPixmap("day")), "View Single Item", | 128 | QIconSet(Resource::loadPixmap("day")), "View Single Item", |
129 | QString::null, this, | 129 | QString::null, this, |
130 | SLOT(browseViewSlot()), navigation, "View Single Item"); | 130 | SLOT(browseViewSlot()), navigation, "View Single Item"); |
131 | QToolButton *listButton = new QToolButton( | 131 | QToolButton *listButton = new QToolButton( |
132 | QIconSet(Resource::loadPixmap("month")), "View Multiple Items", | 132 | QIconSet(Resource::loadPixmap("month")), "View Multiple Items", |
133 | QString::null, this, | 133 | QString::null, this, |
134 | SLOT(listViewSlot()), navigation, "View Multiple Items"); | 134 | SLOT(listViewSlot()), navigation, "View Multiple Items"); |
135 | 135 | ||
136 | setToolBarsMovable(FALSE); | 136 | setToolBarsMovable(FALSE); |
137 | setToolBarsMovable(FALSE); | 137 | setToolBarsMovable(FALSE); |
138 | setToolBarsMovable(FALSE); | 138 | setToolBarsMovable(FALSE); |
139 | 139 | ||
140 | /* Build widgets */ | 140 | /* Build widgets */ |
141 | browseView = new TVBrowseView(&ts, this, 0); | 141 | browseView = new TVBrowseView(&ts, this, 0); |
142 | listView = new TVListView(&ts, this, 0); | 142 | listView = new TVListView(&ts, this, 0); |
143 | filterView = new TVFilterView(&ts, this, 0); | 143 | filterView = new TVFilterView(&ts, this, 0); |
144 | fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer", | 144 | fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer", |
145 | this, "fileselector"); | 145 | this, "fileselector"); |
146 | fileSelector->setNewVisible(FALSE); | 146 | fileSelector->setNewVisible(FALSE); |
147 | fileSelector->setCloseVisible(FALSE); | 147 | fileSelector->setCloseVisible(FALSE); |
148 | 148 | ||
149 | cw = new QWidgetStack(this, 0); | 149 | cw = new QWidgetStack(this, 0); |
150 | cw->addWidget(listView, ListState); | 150 | cw->addWidget(listView, ListState); |
151 | cw->addWidget(browseView, BrowseState); | 151 | cw->addWidget(browseView, BrowseState); |
152 | cw->addWidget(filterView, FilterState); | 152 | cw->addWidget(filterView, FilterState); |
153 | cw->addWidget(fileSelector, FileState); | 153 | cw->addWidget(fileSelector, FileState); |
154 | 154 | ||
155 | current_view = FileState; | 155 | current_view = FileState; |
156 | cw->raiseWidget(current_view); | 156 | cw->raiseWidget(current_view); |
157 | fileSelector->reread(); | 157 | fileSelector->reread(); |
158 | 158 | ||
159 | connect(browseView, SIGNAL(searchOnKey(int, TVVariant)), | 159 | connect(browseView, SIGNAL(searchOnKey(int, TVVariant)), |
160 | this, SLOT(searchOnKey(int, TVVariant))); | 160 | this, SLOT(searchOnKey(int, TVVariant))); |
161 | connect(browseView, SIGNAL(sortChanged(int)), | 161 | connect(browseView, SIGNAL(sortChanged(int)), |
162 | this, SLOT(setPrimaryKey(int))); | 162 | this, SLOT(setPrimaryKey(int))); |
163 | 163 | ||
164 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot())); | 164 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot())); |
165 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), | 165 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), |
166 | this, SLOT(openDocument(const DocLnk &))); | 166 | this, SLOT(openDocument(const DocLnk &))); |
167 | 167 | ||
168 | main_layout->addWidget(menu); | 168 | main_layout->addWidget(menu); |
169 | main_layout->addWidget(cw); | 169 | main_layout->addWidget(cw); |
170 | 170 | ||
171 | setCentralWidget(cw); | 171 | setCentralWidget(cw); |
172 | 172 | ||
173 | } | 173 | } |
174 | 174 | ||
175 | /*! | 175 | /*! |
176 | Destroys the TableViewerWindow | 176 | Destroys the TableViewerWindow |
177 | */ | 177 | */ |
178 | TableViewerWindow::~TableViewerWindow() | 178 | TableViewerWindow::~TableViewerWindow() |
179 | { | 179 | { |
180 | if(dirty) | 180 | if(dirty) |
181 | saveDocument(); | 181 | saveDocument(); |
182 | } | 182 | } |
183 | 183 | ||
184 | /*! | 184 | /*! |
185 | Opens a file dialog and loads the file specified by the dialog | 185 | Opens a file dialog and loads the file specified by the dialog |
186 | */ | 186 | */ |
187 | void TableViewerWindow::selectDocument() | 187 | void TableViewerWindow::selectDocument() |
188 | { | 188 | { |
189 | if(dirty) | 189 | if(dirty) |
190 | saveDocument(); | 190 | saveDocument(); |
191 | current_view = FileState; | 191 | current_view = FileState; |
192 | cw->raiseWidget(current_view); | 192 | cw->raiseWidget(current_view); |
193 | fileSelector->reread(); | 193 | fileSelector->reread(); |
194 | } | 194 | } |
195 | 195 | ||
196 | void TableViewerWindow::saveDocument() | 196 | void TableViewerWindow::saveDocument() |
197 | { | 197 | { |
198 | if(!dirty) | 198 | if(!dirty) |
199 | return; | 199 | return; |
200 | 200 | ||
201 | FileManager fm; | 201 | FileManager fm; |
202 | QIODevice *dev = fm.saveFile(doc); | 202 | QIODevice *dev = fm.saveFile(doc); |
203 | 203 | ||
204 | if(!ds->saveSource(dev, doc.type())){ | 204 | if(!ds->saveSource(dev, doc.type())){ |
205 | qWarning("Save unsuccessful"); | 205 | qWarning("Save unsuccessful"); |
206 | return; | 206 | return; |
207 | } | 207 | } |
208 | dev->close(); | 208 | dev->close(); |
209 | dirty = FALSE; | 209 | dirty = FALSE; |
210 | } | 210 | } |
211 | 211 | ||
212 | void TableViewerWindow::newDocument() | 212 | void TableViewerWindow::newDocument() |
213 | { | 213 | { |
214 | DocLnk nf; | 214 | DocLnk nf; |
215 | nf.setType("text/x-xml-tableviewer"); | 215 | nf.setType("text/x-xml-tableviewer"); |
216 | nf.setName("table"); | 216 | nf.setName("table"); |
217 | 217 | ||
218 | delete ds; | 218 | delete ds; |
219 | ds = new DBStore(); | 219 | ds = new DBStore(); |
220 | 220 | ||
221 | ts.current_column = 0; | 221 | ts.current_column = 0; |
222 | ts.kRep = ds->getKeys(); | 222 | ts.kRep = ds->getKeys(); |
223 | browseView->reset(); | 223 | browseView->reset(); |
224 | listView->reset(); | 224 | listView->reset(); |
225 | filterView->reset(); | 225 | filterView->reset(); |
226 | 226 | ||
227 | doc = nf; | 227 | doc = nf; |
228 | dirty = FALSE; | 228 | dirty = FALSE; |
229 | 229 | ||
230 | current_view = BrowseState; | 230 | current_view = BrowseState; |
231 | cw->raiseWidget(current_view); | 231 | cw->raiseWidget(current_view); |
232 | 232 | ||
233 | /* now set up for editing the keys */ | 233 | /* now set up for editing the keys */ |
234 | ts.kRep->addKey("key", TVVariant::String); | 234 | ts.kRep->addKey("key", TVVariant::String); |
235 | editKeysSlot(); | 235 | editKeysSlot(); |
236 | } | 236 | } |
237 | 237 | ||
238 | void TableViewerWindow::setDocument(const QString &f) | 238 | void TableViewerWindow::setDocument(const QString &f) |
239 | { | 239 | { |
240 | openDocument(DocLnk(f, TRUE)); | 240 | openDocument(DocLnk(f, TRUE)); |
241 | } | 241 | } |
242 | 242 | ||
243 | void TableViewerWindow::openDocument(const DocLnk &f) | 243 | void TableViewerWindow::openDocument(const DocLnk &f) |
244 | { | 244 | { |
245 | 245 | ||
246 | if (!f.isValid()) | 246 | if (!f.isValid()) |
247 | return; | 247 | return; |
248 | 248 | ||
249 | FileManager fm; | 249 | FileManager fm; |
250 | QIODevice *dev = fm.openFile(f); | 250 | QIODevice *dev = fm.openFile(f); |
251 | doc = f; | 251 | doc = f; |
252 | 252 | ||
253 | if(ds->openSource(dev, doc.type())) { | 253 | if(ds->openSource(dev, doc.type())) { |
254 | DataElem *d; | 254 | DataElem *d; |
255 | 255 | ||
256 | browseView->reset(); | 256 | browseView->reset(); |
257 | listView->reset(); | 257 | listView->reset(); |
258 | filterView->reset(); | 258 | filterView->reset(); |
259 | 259 | ||
260 | current_view = BrowseState; | 260 | current_view = BrowseState; |
261 | cw->raiseWidget(current_view); | 261 | cw->raiseWidget(current_view); |
262 | 262 | ||
263 | /* set up new table state and ensure sub widgets have a reference */ | 263 | /* set up new table state and ensure sub widgets have a reference */ |
264 | ts.current_column = 0; | 264 | ts.current_column = 0; |
265 | ts.kRep = ds->getKeys(); | 265 | ts.kRep = ds->getKeys(); |
266 | browseView->rebuildKeys(); | 266 | browseView->rebuildKeys(); |
267 | listView->rebuildKeys(); | 267 | listView->rebuildKeys(); |
268 | filterView->rebuildKeys(); | 268 | filterView->rebuildKeys(); |
269 | 269 | ||
270 | ds->first(); | 270 | ds->first(); |
271 | /* set up the list view */ | 271 | /* set up the list view */ |
272 | listView->clearItems(); | 272 | listView->clearItems(); |
273 | do { | 273 | do { |
274 | d = ds->getCurrentData(); | 274 | d = ds->getCurrentData(); |
275 | if(d) | 275 | if(d) |
276 | listView->addItem(d); | 276 | listView->addItem(d); |
277 | } while(ds->next()); | 277 | } while(ds->next()); |
278 | 278 | ||
279 | /* Set up browse view, Will be based of structure of listView */ | 279 | /* Set up browse view, Will be based of structure of listView */ |
280 | listView->first(); | 280 | listView->first(); |
281 | ts.current_elem = listView->getCurrentData(); | 281 | ts.current_elem = listView->getCurrentData(); |
282 | browseView->rebuildData(); | 282 | browseView->rebuildData(); |
283 | listView->rebuildData(); | 283 | listView->rebuildData(); |
284 | 284 | ||
285 | QString scratch = "Table Viewer";/* later take from constant */ | 285 | QString scratch = "Table Viewer";/* later take from constant */ |
286 | scratch += " - "; | 286 | scratch += " - "; |
287 | scratch += ds->getName(); | 287 | scratch += ds->getName(); |
288 | setCaption(tr(scratch)); | 288 | setCaption(tr(scratch)); |
289 | 289 | ||
290 | dirty = FALSE; | 290 | dirty = FALSE; |
291 | } else { | 291 | } else { |
292 | qWarning(tr("could not load Document")); | 292 | qWarning(tr("could not load Document")); |
293 | } | 293 | } |
294 | dev->close(); | 294 | dev->close(); |
295 | } | 295 | } |
296 | 296 | ||
297 | /*! | 297 | /*! |
298 | Moves to the first item of the current table | 298 | Moves to the first item of the current table |
299 | */ | 299 | */ |
300 | void TableViewerWindow::firstItem() | 300 | void TableViewerWindow::firstItem() |
301 | { | 301 | { |
302 | listView->first(); | 302 | listView->first(); |
303 | ts.current_elem = listView->getCurrentData(); | 303 | ts.current_elem = listView->getCurrentData(); |
304 | browseView->rebuildData(); | 304 | browseView->rebuildData(); |
305 | } | 305 | } |
306 | 306 | ||
307 | /*! | 307 | /*! |
308 | Moves to the lat item of the current table | 308 | Moves to the lat item of the current table |
309 | */ | 309 | */ |
310 | void TableViewerWindow::lastItem() | 310 | void TableViewerWindow::lastItem() |
311 | { | 311 | { |
312 | listView->last(); | 312 | listView->last(); |
313 | ts.current_elem = listView->getCurrentData(); | 313 | ts.current_elem = listView->getCurrentData(); |
314 | browseView->rebuildData(); | 314 | browseView->rebuildData(); |
315 | } | 315 | } |
316 | 316 | ||
317 | /*! | 317 | /*! |
318 | Moves to the next item of the current table | 318 | Moves to the next item of the current table |
319 | */ | 319 | */ |
320 | void TableViewerWindow::nextItem() | 320 | void TableViewerWindow::nextItem() |
321 | { | 321 | { |
322 | listView->next(); | 322 | listView->next(); |
323 | ts.current_elem = listView->getCurrentData(); | 323 | ts.current_elem = listView->getCurrentData(); |
324 | browseView->rebuildData(); | 324 | browseView->rebuildData(); |
325 | } | 325 | } |
diff --git a/noncore/games/backgammon/backgammon.cpp b/noncore/games/backgammon/backgammon.cpp index 06523f1..755ed10 100644 --- a/noncore/games/backgammon/backgammon.cpp +++ b/noncore/games/backgammon/backgammon.cpp | |||
@@ -1,361 +1,361 @@ | |||
1 | #include "backgammon.h" | 1 | #include "backgammon.h" |
2 | 2 | ||
3 | #include "aidialog.h" | 3 | #include "aidialog.h" |
4 | #include "filedialog.h" | 4 | #include "filedialog.h" |
5 | #include "playerdialog.h" | 5 | #include "playerdialog.h" |
6 | #include "rulesdialog.h" | 6 | #include "rulesdialog.h" |
7 | #include "themedialog.h" | 7 | #include "themedialog.h" |
8 | 8 | ||
9 | #include <qdatetime.h> | 9 | #include <qdatetime.h> |
10 | #include <qfile.h> | 10 | #include <qfile.h> |
11 | #include <qlayout.h> | 11 | #include <qlayout.h> |
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qstring.h> | 13 | #include <qstring.h> |
14 | #include <qtimer.h> | 14 | #include <qtimer.h> |
15 | #include <qmainwindow.h> | 15 | #include <qmainwindow.h> |
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | #include <qpe/config.h> | 17 | #include <qpe/config.h> |
18 | #include <qpe/qpemenubar.h> | 18 | #include <qpe/qpemenubar.h> |
19 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
20 | 20 | ||
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | 22 | ||
23 | 23 | ||
24 | BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) | 24 | BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) |
25 | : QMainWindow(parent, name, fl) | 25 | : QMainWindow(parent, name, fl) |
26 | { | 26 | { |
27 | if (!name) setName("BackGammon"); | 27 | if (!name) setName("BackGammon"); |
28 | setCaption(tr( "Backgammon") ); | 28 | setCaption(tr( "Backgammon") ); |
29 | setIcon( Resource::loadPixmap( "backgammon" ) ); | 29 | setIcon( Resource::loadPixmap( "backgammon" ) ); |
30 | //general counter varaible | 30 | //general counter varaible |
31 | int a=0; | 31 | int a=0; |
32 | //the game engine | 32 | //the game engine |
33 | move=new MoveEngine(); | 33 | move=new MoveEngine(); |
34 | 34 | ||
35 | //load the default theme | 35 | //load the default theme |
36 | Config conf("backgammon"); | 36 | Config conf("backgammon"); |
37 | if(!conf.isValid()) | 37 | if(!conf.isValid()) |
38 | { | 38 | { |
39 | qDebug("config file does not exist"); | 39 | qDebug("config file does not exist"); |
40 | conf.setGroup("general"); | 40 | conf.setGroup("general"); |
41 | conf.writeEntry("theme","default"); | 41 | conf.writeEntry("theme","default"); |
42 | conf.setGroup("rules"); | 42 | conf.setGroup("rules"); |
43 | conf.writeEntry("move_with_pieces_out",false); | 43 | conf.writeEntry("move_with_pieces_out",false); |
44 | conf.writeEntry("nice_dice",false); | 44 | conf.writeEntry("nice_dice",false); |
45 | conf.setGroup("display"); | 45 | conf.setGroup("display"); |
46 | conf.writeEntry("small",false); | 46 | conf.writeEntry("small",false); |
47 | conf.writeEntry("warning",true); | 47 | conf.writeEntry("warning",true); |
48 | conf.setGroup("ai"); | 48 | conf.setGroup("ai"); |
49 | conf.writeEntry("rescue",6); | 49 | conf.writeEntry("rescue",6); |
50 | conf.writeEntry("eliminate",4); | 50 | conf.writeEntry("eliminate",4); |
51 | conf.writeEntry("expose",1); | 51 | conf.writeEntry("expose",1); |
52 | conf.writeEntry("protect",5); | 52 | conf.writeEntry("protect",5); |
53 | conf.writeEntry("safe",3); | 53 | conf.writeEntry("safe",3); |
54 | conf.writeEntry("empty",2); | 54 | conf.writeEntry("empty",2); |
55 | 55 | ||
56 | } | 56 | } |
57 | conf.setGroup("general"); | 57 | conf.setGroup("general"); |
58 | theme_name=conf.readEntry("theme","default"); | 58 | theme_name=conf.readEntry("theme","default"); |
59 | QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; | 59 | QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; |
60 | 60 | ||
61 | //the rules | 61 | //the rules |
62 | conf.setGroup("rules"); | 62 | conf.setGroup("rules"); |
63 | rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false); | 63 | rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false); |
64 | rules.generous_dice=conf.readBoolEntry("nice_dice",false); | 64 | rules.generous_dice=conf.readBoolEntry("nice_dice",false); |
65 | 65 | ||
66 | move->setRules(rules); | 66 | move->setRules(rules); |
67 | 67 | ||
68 | //get the AI settings | 68 | //get the AI settings |
69 | AISettings ai; | 69 | AISettings ai; |
70 | conf.setGroup("ai"); | 70 | conf.setGroup("ai"); |
71 | ai.rescue=conf.readNumEntry("rescue",6); | 71 | ai.rescue=conf.readNumEntry("rescue",6); |
72 | ai.eliminate=conf.readNumEntry("eliminate",4); | 72 | ai.eliminate=conf.readNumEntry("eliminate",4); |
73 | ai.expose=conf.readNumEntry("expose",1); | 73 | ai.expose=conf.readNumEntry("expose",1); |
74 | ai.protect=conf.readNumEntry("protect",5); | 74 | ai.protect=conf.readNumEntry("protect",5); |
75 | ai.safe=conf.readNumEntry("safe",3); | 75 | ai.safe=conf.readNumEntry("safe",3); |
76 | ai.empty=conf.readNumEntry("empty",2); | 76 | ai.empty=conf.readNumEntry("empty",2); |
77 | move->setAISettings(ai); | 77 | move->setAISettings(ai); |
78 | 78 | ||
79 | 79 | ||
80 | //get the theme component names | 80 | //get the theme component names |
81 | Config theme(theme_file,Config::File); | 81 | Config theme(theme_file,Config::File); |
82 | if(!theme.isValid()) | 82 | if(!theme.isValid()) |
83 | { | 83 | { |
84 | qDebug("theme file does not exist"); | 84 | qDebug("theme file does not exist"); |
85 | theme.setGroup("theme"); | 85 | theme.setGroup("theme"); |
86 | theme.writeEntry("board","casino_board_1"); | 86 | theme.writeEntry("board","casino_board_1"); |
87 | theme.writeEntry("pieces1","casino_pieces_blue"); | 87 | theme.writeEntry("pieces1","casino_pieces_blue"); |
88 | theme.writeEntry("pieces2","casino_pieces_white"); | 88 | theme.writeEntry("pieces2","casino_pieces_white"); |
89 | theme.writeEntry("dice1","casino_dice"); | 89 | theme.writeEntry("dice1","casino_dice"); |
90 | theme.writeEntry("dice2","casino_dice"); | 90 | theme.writeEntry("dice2","casino_dice"); |
91 | theme.writeEntry("table","casino_table_green"); | 91 | theme.writeEntry("table","casino_table_green"); |
92 | theme.writeEntry("odds","casino_odds"); | 92 | theme.writeEntry("odds","casino_odds"); |
93 | } | 93 | } |
94 | theme.setGroup("theme"); | 94 | theme.setGroup("theme"); |
95 | board_name=theme.readEntry("board","casino_board_1"); | 95 | board_name=theme.readEntry("board","casino_board_1"); |
96 | piecesA_name=theme.readEntry("pieces1","casino_pieces_blue"); | 96 | piecesA_name=theme.readEntry("pieces1","casino_pieces_blue"); |
97 | piecesB_name=theme.readEntry("pieces2","casino_pieces_white"); | 97 | piecesB_name=theme.readEntry("pieces2","casino_pieces_white"); |
98 | diceA_name=theme.readEntry("dice1","casino_dice"); | 98 | diceA_name=theme.readEntry("dice1","casino_dice"); |
99 | diceB_name=theme.readEntry("dice2","casino_dice"); | 99 | diceB_name=theme.readEntry("dice2","casino_dice"); |
100 | table_name=theme.readEntry("table","casino_table_green"); | 100 | table_name=theme.readEntry("table","casino_table_green"); |
101 | odds_name=theme.readEntry("odds","casino_odds"); | 101 | odds_name=theme.readEntry("odds","casino_odds"); |
102 | 102 | ||
103 | 103 | ||
104 | //the menu | 104 | //the menu |
105 | QPEMenuBar* menuBar = new QPEMenuBar(this); | 105 | QMenuBar* menuBar = new QMenuBar(this); |
106 | 106 | ||
107 | QPopupMenu* gamemenu= new QPopupMenu(this); | 107 | QPopupMenu* gamemenu= new QPopupMenu(this); |
108 | gamemenu->insertItem(tr( "New" ),this,SLOT(newgame())); | 108 | gamemenu->insertItem(tr( "New" ),this,SLOT(newgame())); |
109 | gamemenu->insertSeparator(); | 109 | gamemenu->insertSeparator(); |
110 | gamemenu->insertItem(tr( "Load" ),this,SLOT(loadgame())); | 110 | gamemenu->insertItem(tr( "Load" ),this,SLOT(loadgame())); |
111 | gamemenu->insertItem(tr( "Save" ),this,SLOT(savegame())); | 111 | gamemenu->insertItem(tr( "Save" ),this,SLOT(savegame())); |
112 | gamemenu->insertSeparator(); | 112 | gamemenu->insertSeparator(); |
113 | gamemenu->insertItem(tr( "Delete" ),this,SLOT(deletegame())); | 113 | gamemenu->insertItem(tr( "Delete" ),this,SLOT(deletegame())); |
114 | menuBar->insertItem(tr( "Game" ),gamemenu); | 114 | menuBar->insertItem(tr( "Game" ),gamemenu); |
115 | 115 | ||
116 | QPopupMenu* thememenu= new QPopupMenu(this); | 116 | QPopupMenu* thememenu= new QPopupMenu(this); |
117 | thememenu->insertItem(tr( "New" ),this,SLOT(newtheme())); | 117 | thememenu->insertItem(tr( "New" ),this,SLOT(newtheme())); |
118 | thememenu->insertSeparator(); | 118 | thememenu->insertSeparator(); |
119 | thememenu->insertItem(tr( "Load"),this,SLOT(loadtheme())); | 119 | thememenu->insertItem(tr( "Load"),this,SLOT(loadtheme())); |
120 | thememenu->insertItem(tr( "Save" ),this,SLOT(savetheme())); | 120 | thememenu->insertItem(tr( "Save" ),this,SLOT(savetheme())); |
121 | thememenu->insertSeparator(); | 121 | thememenu->insertSeparator(); |
122 | thememenu->insertItem(tr( "Default"),this,SLOT(themedefault())); | 122 | thememenu->insertItem(tr( "Default"),this,SLOT(themedefault())); |
123 | thememenu->insertItem(tr( "Delete" ),this,SLOT(deletetheme())); | 123 | thememenu->insertItem(tr( "Delete" ),this,SLOT(deletetheme())); |
124 | menuBar->insertItem(tr( "Theme" ),thememenu); | 124 | menuBar->insertItem(tr( "Theme" ),thememenu); |
125 | 125 | ||
126 | QPopupMenu* optionmenu=new QPopupMenu(this); | 126 | QPopupMenu* optionmenu=new QPopupMenu(this); |
127 | optionmenu->insertItem(tr( "Player" ),this,SLOT(playerselect())); | 127 | optionmenu->insertItem(tr( "Player" ),this,SLOT(playerselect())); |
128 | optionmenu->insertSeparator(); | 128 | optionmenu->insertSeparator(); |
129 | optionmenu->insertItem(tr( "AI" ),this,SLOT(modify_AI())); | 129 | optionmenu->insertItem(tr( "AI" ),this,SLOT(modify_AI())); |
130 | optionmenu->insertItem(tr( "Rules" ),this,SLOT(setrules())); | 130 | optionmenu->insertItem(tr( "Rules" ),this,SLOT(setrules())); |
131 | menuBar->insertItem(tr( "Options"),optionmenu); | 131 | menuBar->insertItem(tr( "Options"),optionmenu); |
132 | 132 | ||
133 | QWidget* mainarea=new QWidget(this); | 133 | QWidget* mainarea=new QWidget(this); |
134 | setCentralWidget(mainarea); | 134 | setCentralWidget(mainarea); |
135 | //the main area | 135 | //the main area |
136 | QBoxLayout* layout=new QBoxLayout(mainarea,QBoxLayout::TopToBottom); | 136 | QBoxLayout* layout=new QBoxLayout(mainarea,QBoxLayout::TopToBottom); |
137 | area=new QCanvas(235,235); | 137 | area=new QCanvas(235,235); |
138 | boardview=new BackGammonView(area,mainarea); | 138 | boardview=new BackGammonView(area,mainarea); |
139 | boardview->setMaximumHeight(240); | 139 | boardview->setMaximumHeight(240); |
140 | layout->addWidget(boardview); | 140 | layout->addWidget(boardview); |
141 | connect(boardview,SIGNAL(mouse(int,int)),this,SLOT(mouse(int,int))); | 141 | connect(boardview,SIGNAL(mouse(int,int)),this,SLOT(mouse(int,int))); |
142 | //status bar | 142 | //status bar |
143 | message=new QLabel("<b>Backgammon</b>",mainarea); | 143 | message=new QLabel("<b>Backgammon</b>",mainarea); |
144 | message->setAlignment(AlignHCenter); | 144 | message->setAlignment(AlignHCenter); |
145 | layout->addWidget(message); | 145 | layout->addWidget(message); |
146 | 146 | ||
147 | //the marker | 147 | //the marker |
148 | marker_current=new QCanvasRectangle(area); | 148 | marker_current=new QCanvasRectangle(area); |
149 | marker_current->setBrush(QColor(0,0,255)); | 149 | marker_current->setBrush(QColor(0,0,255)); |
150 | marker_current->setSize(15,5); | 150 | marker_current->setSize(15,5); |
151 | marker_current->setZ(1); | 151 | marker_current->setZ(1); |
152 | 152 | ||
153 | for(a=0;a<4;a++) | 153 | for(a=0;a<4;a++) |
154 | { | 154 | { |
155 | marker_next[a]=new QCanvasRectangle(area); | 155 | marker_next[a]=new QCanvasRectangle(area); |
156 | marker_next[a]->setBrush(QColor(0,255,0)); | 156 | marker_next[a]->setBrush(QColor(0,255,0)); |
157 | marker_next[a]->setSize(15,5); | 157 | marker_next[a]->setSize(15,5); |
158 | marker_next[a]->setZ(1); | 158 | marker_next[a]->setZ(1); |
159 | } | 159 | } |
160 | 160 | ||
161 | connect(move,SIGNAL(done_dice1()),this,SLOT(done_dice1())); | 161 | connect(move,SIGNAL(done_dice1()),this,SLOT(done_dice1())); |
162 | connect(move,SIGNAL(done_dice2()),this,SLOT(done_dice2())); | 162 | connect(move,SIGNAL(done_dice2()),this,SLOT(done_dice2())); |
163 | connect(move,SIGNAL(done_dice3()),this,SLOT(done_dice3())); | 163 | connect(move,SIGNAL(done_dice3()),this,SLOT(done_dice3())); |
164 | connect(move,SIGNAL(done_dice4()),this,SLOT(done_dice4())); | 164 | connect(move,SIGNAL(done_dice4()),this,SLOT(done_dice4())); |
165 | connect(move,SIGNAL(nomove()),this,SLOT(nomove())); | 165 | connect(move,SIGNAL(nomove()),this,SLOT(nomove())); |
166 | connect(move,SIGNAL(player_finished(int)),this,SLOT(finished(int))); | 166 | connect(move,SIGNAL(player_finished(int)),this,SLOT(finished(int))); |
167 | 167 | ||
168 | //the pieces | 168 | //the pieces |
169 | p1=new CanvasImageItem*[15]; | 169 | p1=new CanvasImageItem*[15]; |
170 | p1_side=new CanvasImageItem*[15]; | 170 | p1_side=new CanvasImageItem*[15]; |
171 | QImage piece_1_all(Resource::loadImage("backgammon/pieces/"+piecesA_name)); | 171 | QImage piece_1_all(Resource::loadImage("backgammon/pieces/"+piecesA_name)); |
172 | QImage piece_1_front=piece_1_all.copy(0,0,15,15); | 172 | QImage piece_1_front=piece_1_all.copy(0,0,15,15); |
173 | QImage piece_1_side=piece_1_all.copy(0,15,15,5); | 173 | QImage piece_1_side=piece_1_all.copy(0,15,15,5); |
174 | 174 | ||
175 | p2=new CanvasImageItem*[15]; | 175 | p2=new CanvasImageItem*[15]; |
176 | p2_side=new CanvasImageItem*[15]; | 176 | p2_side=new CanvasImageItem*[15]; |
177 | QImage piece_2_all(Resource::loadImage("backgammon/pieces/"+piecesB_name)); | 177 | QImage piece_2_all(Resource::loadImage("backgammon/pieces/"+piecesB_name)); |
178 | QImage piece_2_front=piece_2_all.copy(0,0,15,15); | 178 | QImage piece_2_front=piece_2_all.copy(0,0,15,15); |
179 | QImage piece_2_side=piece_2_all.copy(0,15,15,5); | 179 | QImage piece_2_side=piece_2_all.copy(0,15,15,5); |
180 | 180 | ||
181 | 181 | ||
182 | for(a=0;a<15;a++) | 182 | for(a=0;a<15;a++) |
183 | { | 183 | { |
184 | p1[a]=new CanvasImageItem(piece_1_front,area); | 184 | p1[a]=new CanvasImageItem(piece_1_front,area); |
185 | p1[a]->setSize(15,15); | 185 | p1[a]->setSize(15,15); |
186 | p1_side[a]=new CanvasImageItem(piece_1_side,area); | 186 | p1_side[a]=new CanvasImageItem(piece_1_side,area); |
187 | p1_side[a]->setSize(15,5); | 187 | p1_side[a]->setSize(15,5); |
188 | 188 | ||
189 | p2[a]=new CanvasImageItem(piece_2_front,area); | 189 | p2[a]=new CanvasImageItem(piece_2_front,area); |
190 | p2[a]->setSize(15,15); | 190 | p2[a]->setSize(15,15); |
191 | p2_side[a]=new CanvasImageItem(piece_2_side,area); | 191 | p2_side[a]=new CanvasImageItem(piece_2_side,area); |
192 | p2_side[a]->setSize(15,5); | 192 | p2_side[a]->setSize(15,5); |
193 | } | 193 | } |
194 | draw(); | 194 | draw(); |
195 | 195 | ||
196 | //the dice | 196 | //the dice |
197 | QImage dicebgA_all(Resource::loadImage("backgammon/dice/"+diceA_name)); | 197 | QImage dicebgA_all(Resource::loadImage("backgammon/dice/"+diceA_name)); |
198 | diceA1=new CanvasImageItem*[7]; | 198 | diceA1=new CanvasImageItem*[7]; |
199 | diceA2=new CanvasImageItem*[7]; | 199 | diceA2=new CanvasImageItem*[7]; |
200 | QImage dicebgB_all(Resource::loadImage("backgammon/dice/"+diceB_name)); | 200 | QImage dicebgB_all(Resource::loadImage("backgammon/dice/"+diceB_name)); |
201 | diceB1=new CanvasImageItem*[7]; | 201 | diceB1=new CanvasImageItem*[7]; |
202 | diceB2=new CanvasImageItem*[7]; | 202 | diceB2=new CanvasImageItem*[7]; |
203 | QImage oddsbg_all=(Resource::loadImage("backgammon/odds/"+odds_name)); | 203 | QImage oddsbg_all=(Resource::loadImage("backgammon/odds/"+odds_name)); |
204 | //oddsDice=new CanvasImageItem*[6]; | 204 | //oddsDice=new CanvasImageItem*[6]; |
205 | 205 | ||
206 | 206 | ||
207 | for(a=0;a<7;a++) | 207 | for(a=0;a<7;a++) |
208 | { | 208 | { |
209 | QImage dicebgA=dicebgA_all.copy(a*25,0,25,25); | 209 | QImage dicebgA=dicebgA_all.copy(a*25,0,25,25); |
210 | diceA1[a]=new CanvasImageItem(dicebgA,area); | 210 | diceA1[a]=new CanvasImageItem(dicebgA,area); |
211 | diceA1[a]->setX(5); | 211 | diceA1[a]->setX(5); |
212 | diceA1[a]->setY(205-2); | 212 | diceA1[a]->setY(205-2); |
213 | diceA1[a]->setZ(1); | 213 | diceA1[a]->setZ(1); |
214 | diceA1[a]->setSize(25,25); | 214 | diceA1[a]->setSize(25,25); |
215 | diceA2[a]=new CanvasImageItem(dicebgA,area); | 215 | diceA2[a]=new CanvasImageItem(dicebgA,area); |
216 | diceA2[a]->setX(35); | 216 | diceA2[a]->setX(35); |
217 | diceA2[a]->setY(205-2); | 217 | diceA2[a]->setY(205-2); |
218 | diceA2[a]->setZ(1); | 218 | diceA2[a]->setZ(1); |
219 | diceA2[a]->setSize(25,25); | 219 | diceA2[a]->setSize(25,25); |
220 | 220 | ||
221 | QImage dicebgB=dicebgB_all.copy(a*25,0,25,25); | 221 | QImage dicebgB=dicebgB_all.copy(a*25,0,25,25); |
222 | diceB1[a]=new CanvasImageItem(dicebgB,area); | 222 | diceB1[a]=new CanvasImageItem(dicebgB,area); |
223 | diceB1[a]->setX(175); | 223 | diceB1[a]->setX(175); |
224 | diceB1[a]->setY(205-2); | 224 | diceB1[a]->setY(205-2); |
225 | diceB1[a]->setZ(1); | 225 | diceB1[a]->setZ(1); |
226 | diceB1[a]->setSize(25,25); | 226 | diceB1[a]->setSize(25,25); |
227 | diceB2[a]=new CanvasImageItem(dicebgB,area); | 227 | diceB2[a]=new CanvasImageItem(dicebgB,area); |
228 | diceB2[a]->setX(205); | 228 | diceB2[a]->setX(205); |
229 | diceB2[a]->setY(205-2); | 229 | diceB2[a]->setY(205-2); |
230 | diceB2[a]->setZ(1); | 230 | diceB2[a]->setZ(1); |
231 | diceB2[a]->setSize(25,25); | 231 | diceB2[a]->setSize(25,25); |
232 | 232 | ||
233 | /* | 233 | /* |
234 | if(a<6) | 234 | if(a<6) |
235 | { | 235 | { |
236 | QImage oddsbg=oddsbg_all.copy(a*15,0,15,15); | 236 | QImage oddsbg=oddsbg_all.copy(a*15,0,15,15); |
237 | oddsDice[a]=new CanvasImageItem(oddsbg,area); | 237 | oddsDice[a]=new CanvasImageItem(oddsbg,area); |
238 | oddsDice[a]->setX(110); | 238 | oddsDice[a]->setX(110); |
239 | oddsDice[a]->setY(210-2); | 239 | oddsDice[a]->setY(210-2); |
240 | oddsDice[a]->setZ(1); | 240 | oddsDice[a]->setZ(1); |
241 | oddsDice[a]->setSize(15,15); | 241 | oddsDice[a]->setSize(15,15); |
242 | oddsDice[a]->hide(); | 242 | oddsDice[a]->hide(); |
243 | } | 243 | } |
244 | */ | 244 | */ |
245 | } | 245 | } |
246 | //oddsDice[0]->show(); | 246 | //oddsDice[0]->show(); |
247 | 247 | ||
248 | //set the board | 248 | //set the board |
249 | QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name)); | 249 | QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name)); |
250 | board=new CanvasImageItem(boardbg,area); | 250 | board=new CanvasImageItem(boardbg,area); |
251 | board->setX(0); | 251 | board->setX(0); |
252 | board->setY(0); | 252 | board->setY(0); |
253 | board->setZ(0); | 253 | board->setZ(0); |
254 | board->setSize(235-2,200-2); | 254 | board->setSize(235-2,200-2); |
255 | board->show(); | 255 | board->show(); |
256 | 256 | ||
257 | //the table | 257 | //the table |
258 | QImage tablebg(Resource::loadImage("backgammon/table/"+table_name)); | 258 | QImage tablebg(Resource::loadImage("backgammon/table/"+table_name)); |
259 | table=new CanvasImageItem(tablebg,area); | 259 | table=new CanvasImageItem(tablebg,area); |
260 | table->setX(0); | 260 | table->setX(0); |
261 | table->setY(200-2); | 261 | table->setY(200-2); |
262 | table->setZ(0); | 262 | table->setZ(0); |
263 | table->setSize(235-2,20); | 263 | table->setSize(235-2,20); |
264 | table->show(); | 264 | table->show(); |
265 | 265 | ||
266 | //the no move marker | 266 | //the no move marker |
267 | QImage nomovebg(Resource::loadImage("backgammon/no_move")); | 267 | QImage nomovebg(Resource::loadImage("backgammon/no_move")); |
268 | nomove_marker=new CanvasImageItem(nomovebg,area); | 268 | nomove_marker=new CanvasImageItem(nomovebg,area); |
269 | nomove_marker->setX(0); | 269 | nomove_marker->setX(0); |
270 | nomove_marker->setY(200); | 270 | nomove_marker->setY(200); |
271 | nomove_marker->setZ(2); | 271 | nomove_marker->setZ(2); |
272 | nomove_marker->hide(); | 272 | nomove_marker->hide(); |
273 | 273 | ||
274 | //default human against computer | 274 | //default human against computer |
275 | player1_auto=false; | 275 | player1_auto=false; |
276 | player2_auto=true; | 276 | player2_auto=true; |
277 | //start new game | 277 | //start new game |
278 | newgame(); | 278 | newgame(); |
279 | } | 279 | } |
280 | 280 | ||
281 | BackGammon::~BackGammon() | 281 | BackGammon::~BackGammon() |
282 | { | 282 | { |
283 | //DESTRUCTOR | 283 | //DESTRUCTOR |
284 | } | 284 | } |
285 | 285 | ||
286 | void BackGammon::newgame() | 286 | void BackGammon::newgame() |
287 | { | 287 | { |
288 | gameFinished=false; | 288 | gameFinished=false; |
289 | QDateTime now=QDateTime::currentDateTime(); | 289 | QDateTime now=QDateTime::currentDateTime(); |
290 | game_name=now.date().toString()+"_"+now.time().toString(); | 290 | game_name=now.date().toString()+"_"+now.time().toString(); |
291 | move->reset(); | 291 | move->reset(); |
292 | draw(); | 292 | draw(); |
293 | diceA1_value=7; | 293 | diceA1_value=7; |
294 | diceA2_value=7; | 294 | diceA2_value=7; |
295 | diceA3_value=7; | 295 | diceA3_value=7; |
296 | diceA4_value=7; | 296 | diceA4_value=7; |
297 | diceB1_value=7; | 297 | diceB1_value=7; |
298 | diceB2_value=7; | 298 | diceB2_value=7; |
299 | diceB3_value=7; | 299 | diceB3_value=7; |
300 | diceB4_value=7; | 300 | diceB4_value=7; |
301 | showdice(); | 301 | showdice(); |
302 | player=2; | 302 | player=2; |
303 | dice1_played=true; | 303 | dice1_played=true; |
304 | dice2_played=true; | 304 | dice2_played=true; |
305 | dice3_played=true; | 305 | dice3_played=true; |
306 | dice4_played=true; | 306 | dice4_played=true; |
307 | dice_rolled=false; | 307 | dice_rolled=false; |
308 | setplayer(); | 308 | setplayer(); |
309 | area->update(); | 309 | area->update(); |
310 | } | 310 | } |
311 | 311 | ||
312 | void BackGammon::playerselect() | 312 | void BackGammon::playerselect() |
313 | { | 313 | { |
314 | PlayerDialog* playerdialog=new PlayerDialog(this); | 314 | PlayerDialog* playerdialog=new PlayerDialog(this); |
315 | playerdialog->setAuto1(player1_auto); | 315 | playerdialog->setAuto1(player1_auto); |
316 | playerdialog->setAuto2(player2_auto); | 316 | playerdialog->setAuto2(player2_auto); |
317 | if(!playerdialog->exec()) | 317 | if(!playerdialog->exec()) |
318 | return; | 318 | return; |
319 | player1_auto=playerdialog->getAuto1(); | 319 | player1_auto=playerdialog->getAuto1(); |
320 | player2_auto=playerdialog->getAuto2(); | 320 | player2_auto=playerdialog->getAuto2(); |
321 | } | 321 | } |
322 | 322 | ||
323 | void BackGammon::loadgame() | 323 | void BackGammon::loadgame() |
324 | { | 324 | { |
325 | FileDialog* file=new FileDialog(this,"Load Game",".game"); | 325 | FileDialog* file=new FileDialog(this,"Load Game",".game"); |
326 | if(!file->exec()) | 326 | if(!file->exec()) |
327 | return; | 327 | return; |
328 | 328 | ||
329 | game_name=file->filename(); | 329 | game_name=file->filename(); |
330 | QString game_file=QPEApplication::qpeDir()+"/backgammon/"+game_name+".game"; | 330 | QString game_file=QPEApplication::qpeDir()+"/backgammon/"+game_name+".game"; |
331 | 331 | ||
332 | Config game(game_file,Config::File); | 332 | Config game(game_file,Config::File); |
333 | game.setGroup("dice"); | 333 | game.setGroup("dice"); |
334 | diceA1_value=game.readNumEntry("diceA1_value"); | 334 | diceA1_value=game.readNumEntry("diceA1_value"); |
335 | diceA2_value=game.readNumEntry("diceA2_value"); | 335 | diceA2_value=game.readNumEntry("diceA2_value"); |
336 | diceA3_value=game.readNumEntry("diceA3_value"); | 336 | diceA3_value=game.readNumEntry("diceA3_value"); |
337 | diceA4_value=game.readNumEntry("diceA4_value"); | 337 | diceA4_value=game.readNumEntry("diceA4_value"); |
338 | diceB1_value=game.readNumEntry("diceB1_value"); | 338 | diceB1_value=game.readNumEntry("diceB1_value"); |
339 | diceB2_value=game.readNumEntry("diceB2_value"); | 339 | diceB2_value=game.readNumEntry("diceB2_value"); |
340 | diceB3_value=game.readNumEntry("diceB3_value"); | 340 | diceB3_value=game.readNumEntry("diceB3_value"); |
341 | diceB4_value=game.readNumEntry("diceB4_value"); | 341 | diceB4_value=game.readNumEntry("diceB4_value"); |
342 | player=game.readNumEntry("player"); | 342 | player=game.readNumEntry("player"); |
343 | dice1_played=game.readBoolEntry("dice1_played"); | 343 | dice1_played=game.readBoolEntry("dice1_played"); |
344 | dice2_played=game.readBoolEntry("dice2_played"); | 344 | dice2_played=game.readBoolEntry("dice2_played"); |
345 | dice3_played=game.readBoolEntry("dice3_played"); | 345 | dice3_played=game.readBoolEntry("dice3_played"); |
346 | dice4_played=game.readBoolEntry("dice4_played"); | 346 | dice4_played=game.readBoolEntry("dice4_played"); |
347 | dice_rolled=game.readBoolEntry("dice_rolled"); | 347 | dice_rolled=game.readBoolEntry("dice_rolled"); |
348 | player1_auto=game.readBoolEntry("player1_auto"); | 348 | player1_auto=game.readBoolEntry("player1_auto"); |
349 | player2_auto=game.readBoolEntry("player2_auto"); | 349 | player2_auto=game.readBoolEntry("player2_auto"); |
350 | 350 | ||
351 | game.setGroup("pieces"); | 351 | game.setGroup("pieces"); |
352 | QString label; | 352 | QString label; |
353 | LoadSave load; | 353 | LoadSave load; |
354 | for(int a=0;a<28;a++) | 354 | for(int a=0;a<28;a++) |
355 | { | 355 | { |
356 | label.setNum(a); | 356 | label.setNum(a); |
357 | load.pop[a].total = game.readNumEntry(label,0); | 357 | load.pop[a].total = game.readNumEntry(label,0); |
358 | } | 358 | } |
359 | 359 | ||
360 | move->loadGame(load); | 360 | move->loadGame(load); |
361 | setplayer(); | 361 | setplayer(); |
diff --git a/noncore/games/fifteen/fifteen.cpp b/noncore/games/fifteen/fifteen.cpp index 293cd65..212f7b1 100644 --- a/noncore/games/fifteen/fifteen.cpp +++ b/noncore/games/fifteen/fifteen.cpp | |||
@@ -1,311 +1,311 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "fifteen.h" | 21 | #include "fifteen.h" |
22 | 22 | ||
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | 25 | ||
26 | #include <qvbox.h> | 26 | #include <qvbox.h> |
27 | #include <qaction.h> | 27 | #include <qaction.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qpopupmenu.h> | 30 | #include <qpopupmenu.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qpe/qpetoolbar.h> | 32 | #include <qpe/qpetoolbar.h> |
33 | #include <qpe/qpemenubar.h> | 33 | #include <qpe/qpemenubar.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | 36 | ||
37 | #include <stdlib.h> | 37 | #include <stdlib.h> |
38 | #include <time.h> | 38 | #include <time.h> |
39 | 39 | ||
40 | FifteenMainWindow::FifteenMainWindow(QWidget *parent, const char* name) | 40 | FifteenMainWindow::FifteenMainWindow(QWidget *parent, const char* name) |
41 | : QMainWindow( parent, name ) | 41 | : QMainWindow( parent, name ) |
42 | { | 42 | { |
43 | // random seed | 43 | // random seed |
44 | srand(time(0)); | 44 | srand(time(0)); |
45 | 45 | ||
46 | setToolBarsMovable( FALSE ); | 46 | setToolBarsMovable( FALSE ); |
47 | QVBox *vbox = new QVBox( this ); | 47 | QVBox *vbox = new QVBox( this ); |
48 | PiecesTable *table = new PiecesTable( vbox ); | 48 | PiecesTable *table = new PiecesTable( vbox ); |
49 | setCentralWidget(vbox); | 49 | setCentralWidget(vbox); |
50 | 50 | ||
51 | QPEToolBar *toolbar = new QPEToolBar(this); | 51 | QPEToolBar *toolbar = new QPEToolBar(this); |
52 | toolbar->setHorizontalStretchable( TRUE ); | 52 | toolbar->setHorizontalStretchable( TRUE ); |
53 | addToolBar(toolbar); | 53 | addToolBar(toolbar); |
54 | 54 | ||
55 | QPEMenuBar *menubar = new QPEMenuBar( toolbar ); | 55 | QMenuBar *menubar = new QMenuBar( toolbar ); |
56 | menubar->setMargin(0); | 56 | menubar->setMargin(0); |
57 | 57 | ||
58 | QPopupMenu *game = new QPopupMenu( this ); | 58 | QPopupMenu *game = new QPopupMenu( this ); |
59 | 59 | ||
60 | QWidget *spacer = new QWidget( toolbar ); | 60 | QWidget *spacer = new QWidget( toolbar ); |
61 | spacer->setBackgroundMode( PaletteButton ); | 61 | spacer->setBackgroundMode( PaletteButton ); |
62 | toolbar->setStretchableWidget( spacer ); | 62 | toolbar->setStretchableWidget( spacer ); |
63 | 63 | ||
64 | QAction *a = new QAction( tr( "Randomize" ), Resource::loadPixmap( "new" ), | 64 | QAction *a = new QAction( tr( "Randomize" ), Resource::loadPixmap( "new" ), |
65 | QString::null, 0, this, 0 ); | 65 | QString::null, 0, this, 0 ); |
66 | connect( a, SIGNAL( activated() ), table, SLOT( slotRandomize() ) ); | 66 | connect( a, SIGNAL( activated() ), table, SLOT( slotRandomize() ) ); |
67 | a->addTo( game ); | 67 | a->addTo( game ); |
68 | a->addTo( toolbar ); | 68 | a->addTo( toolbar ); |
69 | 69 | ||
70 | a = new QAction( tr( "Solve" ), Resource::loadPixmap( "repeat" ), | 70 | a = new QAction( tr( "Solve" ), Resource::loadPixmap( "repeat" ), |
71 | QString::null, 0, this, 0 ); | 71 | QString::null, 0, this, 0 ); |
72 | connect( a, SIGNAL( activated() ), table, SLOT( slotReset() ) ); | 72 | connect( a, SIGNAL( activated() ), table, SLOT( slotReset() ) ); |
73 | a->addTo( game ); | 73 | a->addTo( game ); |
74 | a->addTo( toolbar ); | 74 | a->addTo( toolbar ); |
75 | 75 | ||
76 | menubar->insertItem( tr( "Game" ), game ); | 76 | menubar->insertItem( tr( "Game" ), game ); |
77 | } | 77 | } |
78 | 78 | ||
79 | PiecesTable::PiecesTable(QWidget* parent, const char* name ) | 79 | PiecesTable::PiecesTable(QWidget* parent, const char* name ) |
80 | : QTableView(parent, name), _menu(0), _randomized(false) | 80 | : QTableView(parent, name), _menu(0), _randomized(false) |
81 | { | 81 | { |
82 | // setup table view | 82 | // setup table view |
83 | setFrameStyle(StyledPanel | Sunken); | 83 | setFrameStyle(StyledPanel | Sunken); |
84 | setBackgroundMode(NoBackground); | 84 | setBackgroundMode(NoBackground); |
85 | setMouseTracking(true); | 85 | setMouseTracking(true); |
86 | 86 | ||
87 | setNumRows(4); | 87 | setNumRows(4); |
88 | setNumCols(4); | 88 | setNumCols(4); |
89 | 89 | ||
90 | // init arrays | 90 | // init arrays |
91 | initMap(); | 91 | initMap(); |
92 | readConfig(); | 92 | readConfig(); |
93 | initColors(); | 93 | initColors(); |
94 | 94 | ||
95 | // set font | 95 | // set font |
96 | QFont f = font(); | 96 | QFont f = font(); |
97 | f.setPixelSize(18); | 97 | f.setPixelSize(18); |
98 | f.setBold( TRUE ); | 98 | f.setBold( TRUE ); |
99 | setFont(f); | 99 | setFont(f); |
100 | } | 100 | } |
101 | 101 | ||
102 | PiecesTable::~PiecesTable() | 102 | PiecesTable::~PiecesTable() |
103 | { | 103 | { |
104 | writeConfig(); | 104 | writeConfig(); |
105 | } | 105 | } |
106 | 106 | ||
107 | void PiecesTable::writeConfig() | 107 | void PiecesTable::writeConfig() |
108 | { | 108 | { |
109 | Config cfg("Fifteen"); | 109 | Config cfg("Fifteen"); |
110 | cfg.setGroup("Game"); | 110 | cfg.setGroup("Game"); |
111 | QStringList map; | 111 | QStringList map; |
112 | for (unsigned int i = 0; i < 16; i++) | 112 | for (unsigned int i = 0; i < 16; i++) |
113 | map.append( QString::number( _map[i] ) ); | 113 | map.append( QString::number( _map[i] ) ); |
114 | cfg.writeEntry("Map", map, '-'); | 114 | cfg.writeEntry("Map", map, '-'); |
115 | cfg.writeEntry("Randomized", _randomized ); | 115 | cfg.writeEntry("Randomized", _randomized ); |
116 | } | 116 | } |
117 | 117 | ||
118 | void PiecesTable::readConfig() | 118 | void PiecesTable::readConfig() |
119 | { | 119 | { |
120 | Config cfg("Fifteen"); | 120 | Config cfg("Fifteen"); |
121 | cfg.setGroup("Game"); | 121 | cfg.setGroup("Game"); |
122 | QStringList map = cfg.readListEntry("Map", '-'); | 122 | QStringList map = cfg.readListEntry("Map", '-'); |
123 | _randomized = cfg.readBoolEntry( "Randomized", FALSE ); | 123 | _randomized = cfg.readBoolEntry( "Randomized", FALSE ); |
124 | unsigned int i = 0; | 124 | unsigned int i = 0; |
125 | for ( QStringList::Iterator it = map.begin(); it != map.end(); ++it ) { | 125 | for ( QStringList::Iterator it = map.begin(); it != map.end(); ++it ) { |
126 | _map[i] = (*it).toInt(); | 126 | _map[i] = (*it).toInt(); |
127 | i++; | 127 | i++; |
128 | if ( i > 15 ) break; | 128 | if ( i > 15 ) break; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | void PiecesTable::paintCell(QPainter *p, int row, int col) | 132 | void PiecesTable::paintCell(QPainter *p, int row, int col) |
133 | { | 133 | { |
134 | int w = cellWidth(); | 134 | int w = cellWidth(); |
135 | int h = cellHeight(); | 135 | int h = cellHeight(); |
136 | int x2 = w - 1; | 136 | int x2 = w - 1; |
137 | int y2 = h - 1; | 137 | int y2 = h - 1; |
138 | 138 | ||
139 | int number = _map[col + row * numCols()] + 1; | 139 | int number = _map[col + row * numCols()] + 1; |
140 | 140 | ||
141 | // draw cell background | 141 | // draw cell background |
142 | if(number == 16) | 142 | if(number == 16) |
143 | p->setBrush(colorGroup().background()); | 143 | p->setBrush(colorGroup().background()); |
144 | else | 144 | else |
145 | p->setBrush(_colors[number-1]); | 145 | p->setBrush(_colors[number-1]); |
146 | p->setPen(NoPen); | 146 | p->setPen(NoPen); |
147 | p->drawRect(0, 0, w, h); | 147 | p->drawRect(0, 0, w, h); |
148 | 148 | ||
149 | // draw borders | 149 | // draw borders |
150 | if (height() > 40) { | 150 | if (height() > 40) { |
151 | p->setPen(colorGroup().text()); | 151 | p->setPen(colorGroup().text()); |
152 | if(col < numCols()-1) | 152 | if(col < numCols()-1) |
153 | p->drawLine(x2, 0, x2, y2); // right border line | 153 | p->drawLine(x2, 0, x2, y2); // right border line |
154 | 154 | ||
155 | if(row < numRows()-1) | 155 | if(row < numRows()-1) |
156 | p->drawLine(0, y2, x2, y2); // bottom boder line | 156 | p->drawLine(0, y2, x2, y2); // bottom boder line |
157 | } | 157 | } |
158 | 158 | ||
159 | // draw number | 159 | // draw number |
160 | if (number == 16) return; | 160 | if (number == 16) return; |
161 | p->setPen(black); | 161 | p->setPen(black); |
162 | p->drawText(0, 0, x2, y2, AlignHCenter | AlignVCenter, QString::number(number)); | 162 | p->drawText(0, 0, x2, y2, AlignHCenter | AlignVCenter, QString::number(number)); |
163 | } | 163 | } |
164 | 164 | ||
165 | void PiecesTable::resizeEvent(QResizeEvent *e) | 165 | void PiecesTable::resizeEvent(QResizeEvent *e) |
166 | { | 166 | { |
167 | QTableView::resizeEvent(e); | 167 | QTableView::resizeEvent(e); |
168 | 168 | ||
169 | setCellWidth(contentsRect().width()/ numRows()); | 169 | setCellWidth(contentsRect().width()/ numRows()); |
170 | setCellHeight(contentsRect().height() / numCols()); | 170 | setCellHeight(contentsRect().height() / numCols()); |
171 | } | 171 | } |
172 | 172 | ||
173 | void PiecesTable::initColors() | 173 | void PiecesTable::initColors() |
174 | { | 174 | { |
175 | _colors.resize(numRows() * numCols()); | 175 | _colors.resize(numRows() * numCols()); |
176 | for (int r = 0; r < numRows(); r++) | 176 | for (int r = 0; r < numRows(); r++) |
177 | for (int c = 0; c < numCols(); c++) | 177 | for (int c = 0; c < numCols(); c++) |
178 | _colors[c + r *numCols()] = QColor(255 - 70 * c,255 - 70 * r, 150); | 178 | _colors[c + r *numCols()] = QColor(255 - 70 * c,255 - 70 * r, 150); |
179 | } | 179 | } |
180 | 180 | ||
181 | void PiecesTable::initMap() | 181 | void PiecesTable::initMap() |
182 | { | 182 | { |
183 | _map.resize(16); | 183 | _map.resize(16); |
184 | for (unsigned int i = 0; i < 16; i++) | 184 | for (unsigned int i = 0; i < 16; i++) |
185 | _map[i] = i; | 185 | _map[i] = i; |
186 | 186 | ||
187 | _randomized = false; | 187 | _randomized = false; |
188 | } | 188 | } |
189 | 189 | ||
190 | void PiecesTable::randomizeMap() | 190 | void PiecesTable::randomizeMap() |
191 | { | 191 | { |
192 | initMap(); | 192 | initMap(); |
193 | _randomized = true; | 193 | _randomized = true; |
194 | // find the free position | 194 | // find the free position |
195 | int pos = _map.find(15); | 195 | int pos = _map.find(15); |
196 | 196 | ||
197 | int move = 0; | 197 | int move = 0; |
198 | while ( move < 333 ) { | 198 | while ( move < 333 ) { |
199 | 199 | ||
200 | int frow = pos / numCols(); | 200 | int frow = pos / numCols(); |
201 | int fcol = pos - frow * numCols(); | 201 | int fcol = pos - frow * numCols(); |
202 | 202 | ||
203 | // find click position | 203 | // find click position |
204 | int row = rand()%4; | 204 | int row = rand()%4; |
205 | int col = rand()%4; | 205 | int col = rand()%4; |
206 | 206 | ||
207 | // sanity check | 207 | // sanity check |
208 | if ( row < 0 || row >= numRows() ) continue; | 208 | if ( row < 0 || row >= numRows() ) continue; |
209 | if ( col < 0 || col >= numCols() ) continue; | 209 | if ( col < 0 || col >= numCols() ) continue; |
210 | if ( row != frow && col != fcol ) continue; | 210 | if ( row != frow && col != fcol ) continue; |
211 | 211 | ||
212 | move++; | 212 | move++; |
213 | 213 | ||
214 | // rows match -> shift pieces | 214 | // rows match -> shift pieces |
215 | if(row == frow) { | 215 | if(row == frow) { |
216 | 216 | ||
217 | if (col < fcol) { | 217 | if (col < fcol) { |
218 | for(int c = fcol; c > col; c--) { | 218 | for(int c = fcol; c > col; c--) { |
219 | _map[c + row * numCols()] = _map[ c-1 + row *numCols()]; | 219 | _map[c + row * numCols()] = _map[ c-1 + row *numCols()]; |
220 | } | 220 | } |
221 | } | 221 | } |
222 | else if (col > fcol) { | 222 | else if (col > fcol) { |
223 | for(int c = fcol; c < col; c++) { | 223 | for(int c = fcol; c < col; c++) { |
224 | _map[c + row * numCols()] = _map[ c+1 + row *numCols()]; | 224 | _map[c + row * numCols()] = _map[ c+1 + row *numCols()]; |
225 | } | 225 | } |
226 | } | 226 | } |
227 | } | 227 | } |
228 | // cols match -> shift pieces | 228 | // cols match -> shift pieces |
229 | else if (col == fcol) { | 229 | else if (col == fcol) { |
230 | 230 | ||
231 | if (row < frow) { | 231 | if (row < frow) { |
232 | for(int r = frow; r > row; r--) { | 232 | for(int r = frow; r > row; r--) { |
233 | _map[col + r * numCols()] = _map[ col + (r-1) *numCols()]; | 233 | _map[col + r * numCols()] = _map[ col + (r-1) *numCols()]; |
234 | } | 234 | } |
235 | } | 235 | } |
236 | else if (row > frow) { | 236 | else if (row > frow) { |
237 | for(int r = frow; r < row; r++) { | 237 | for(int r = frow; r < row; r++) { |
238 | _map[col + r * numCols()] = _map[ col + (r+1) *numCols()]; | 238 | _map[col + r * numCols()] = _map[ col + (r+1) *numCols()]; |
239 | } | 239 | } |
240 | } | 240 | } |
241 | } | 241 | } |
242 | // move free cell to click position | 242 | // move free cell to click position |
243 | _map[pos=(col + row * numCols())] = 15; | 243 | _map[pos=(col + row * numCols())] = 15; |
244 | repaint(); | 244 | repaint(); |
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | void PiecesTable::checkwin() | 248 | void PiecesTable::checkwin() |
249 | { | 249 | { |
250 | if(!_randomized) return; | 250 | if(!_randomized) return; |
251 | 251 | ||
252 | int i; | 252 | int i; |
253 | for (i = 0; i < 16; i++) | 253 | for (i = 0; i < 16; i++) |
254 | if(i != _map[i]) | 254 | if(i != _map[i]) |
255 | break; | 255 | break; |
256 | 256 | ||
257 | if (i == 16) { | 257 | if (i == 16) { |
258 | QMessageBox::information(this, tr("Fifteen Pieces"), | 258 | QMessageBox::information(this, tr("Fifteen Pieces"), |
259 | tr("Congratulations!\nYou win the game!")); | 259 | tr("Congratulations!\nYou win the game!")); |
260 | _randomized = FALSE; | 260 | _randomized = FALSE; |
261 | } | 261 | } |
262 | 262 | ||
263 | } | 263 | } |
264 | 264 | ||
265 | void PiecesTable::slotRandomize() | 265 | void PiecesTable::slotRandomize() |
266 | { | 266 | { |
267 | randomizeMap(); | 267 | randomizeMap(); |
268 | } | 268 | } |
269 | 269 | ||
270 | void PiecesTable::slotReset() | 270 | void PiecesTable::slotReset() |
271 | { | 271 | { |
272 | initMap(); | 272 | initMap(); |
273 | repaint(); | 273 | repaint(); |
274 | } | 274 | } |
275 | 275 | ||
276 | void PiecesTable::mousePressEvent(QMouseEvent* e) | 276 | void PiecesTable::mousePressEvent(QMouseEvent* e) |
277 | { | 277 | { |
278 | QTableView::mousePressEvent(e); | 278 | QTableView::mousePressEvent(e); |
279 | 279 | ||
280 | if (e->button() == RightButton) { | 280 | if (e->button() == RightButton) { |
281 | 281 | ||
282 | // setup RMB pupup menu | 282 | // setup RMB pupup menu |
283 | if(!_menu) { | 283 | if(!_menu) { |
284 | _menu = new QPopupMenu(this); | 284 | _menu = new QPopupMenu(this); |
285 | _menu->insertItem(tr("R&andomize Pieces"), mRandomize); | 285 | _menu->insertItem(tr("R&andomize Pieces"), mRandomize); |
286 | _menu->insertItem(tr("&Reset Pieces"), mReset); | 286 | _menu->insertItem(tr("&Reset Pieces"), mReset); |
287 | _menu->adjustSize(); | 287 | _menu->adjustSize(); |
288 | } | 288 | } |
289 | 289 | ||
290 | // execute RMB popup and check result | 290 | // execute RMB popup and check result |
291 | switch(_menu->exec(mapToGlobal(e->pos()))) { | 291 | switch(_menu->exec(mapToGlobal(e->pos()))) { |
292 | case mRandomize: | 292 | case mRandomize: |
293 | randomizeMap(); | 293 | randomizeMap(); |
294 | break; | 294 | break; |
295 | case mReset: | 295 | case mReset: |
296 | initMap(); | 296 | initMap(); |
297 | repaint(); | 297 | repaint(); |
298 | break; | 298 | break; |
299 | default: | 299 | default: |
300 | break; | 300 | break; |
301 | } | 301 | } |
302 | } | 302 | } |
303 | else { | 303 | else { |
304 | // GAME LOGIC | 304 | // GAME LOGIC |
305 | 305 | ||
306 | // find the free position | 306 | // find the free position |
307 | int pos = _map.find(15); | 307 | int pos = _map.find(15); |
308 | if(pos < 0) return; | 308 | if(pos < 0) return; |
309 | 309 | ||
310 | int frow = pos / numCols(); | 310 | int frow = pos / numCols(); |
311 | int fcol = pos - frow * numCols(); | 311 | int fcol = pos - frow * numCols(); |
diff --git a/noncore/games/go/gowidget.cpp b/noncore/games/go/gowidget.cpp index 1d38c9f..476f7ce1 100644 --- a/noncore/games/go/gowidget.cpp +++ b/noncore/games/go/gowidget.cpp | |||
@@ -1,321 +1,321 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "gowidget.h" | 21 | #include "gowidget.h" |
22 | 22 | ||
23 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | #include <qpe/qpetoolbar.h> | 28 | #include <qpe/qpetoolbar.h> |
29 | #include <qpe/qpemenubar.h> | 29 | #include <qpe/qpemenubar.h> |
30 | #include <qpopupmenu.h> | 30 | #include <qpopupmenu.h> |
31 | #include <qaction.h> | 31 | #include <qaction.h> |
32 | #include <qapplication.h> //processEvents() | 32 | #include <qapplication.h> //processEvents() |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | 34 | ||
35 | //#include <stdio.h> | 35 | //#include <stdio.h> |
36 | 36 | ||
37 | #include "amigo.h" | 37 | #include "amigo.h" |
38 | #include "goplayutils.h" | 38 | #include "goplayutils.h" |
39 | 39 | ||
40 | static const enum bVal computer_color = BLACK; | 40 | static const enum bVal computer_color = BLACK; |
41 | 41 | ||
42 | static int current_handicap = 1; | 42 | static int current_handicap = 1; |
43 | 43 | ||
44 | static QBrush *goBrush; | 44 | static QBrush *goBrush; |
45 | //static QImage *newBlackStone; | 45 | //static QImage *newBlackStone; |
46 | //static QImage *blackStone; | 46 | //static QImage *blackStone; |
47 | //static QImage *whiteStone; | 47 | //static QImage *whiteStone; |
48 | static QPixmap *newBlackStone; | 48 | static QPixmap *newBlackStone; |
49 | static QPixmap *blackStone; | 49 | static QPixmap *blackStone; |
50 | static QPixmap *whiteStone; | 50 | static QPixmap *whiteStone; |
51 | 51 | ||
52 | static bool smallStones = FALSE; | 52 | static bool smallStones = FALSE; |
53 | 53 | ||
54 | GoMainWidget::GoMainWidget( QWidget *parent, const char* name) : | 54 | GoMainWidget::GoMainWidget( QWidget *parent, const char* name) : |
55 | QMainWindow( parent, name ) | 55 | QMainWindow( parent, name ) |
56 | { | 56 | { |
57 | setToolBarsMovable( FALSE ); | 57 | setToolBarsMovable( FALSE ); |
58 | GoWidget *go = new GoWidget(this); | 58 | GoWidget *go = new GoWidget(this); |
59 | 59 | ||
60 | setCentralWidget(go); | 60 | setCentralWidget(go); |
61 | toolbar = new QPEToolBar(this); | 61 | toolbar = new QPEToolBar(this); |
62 | toolbar->setHorizontalStretchable( TRUE ); | 62 | toolbar->setHorizontalStretchable( TRUE ); |
63 | addToolBar(toolbar); | 63 | addToolBar(toolbar); |
64 | 64 | ||
65 | QPEMenuBar *mb = new QPEMenuBar( toolbar ); | 65 | QMenuBar *mb = new QMenuBar( toolbar ); |
66 | mb->setMargin(0); | 66 | mb->setMargin(0); |
67 | QPopupMenu *file = new QPopupMenu( this ); | 67 | QPopupMenu *file = new QPopupMenu( this ); |
68 | 68 | ||
69 | QAction *a = new QAction( tr( "New Game" ), QString::null, 0, this, 0 ); | 69 | QAction *a = new QAction( tr( "New Game" ), QString::null, 0, this, 0 ); |
70 | connect( a, SIGNAL( activated() ), go, SLOT( newGame() ) ); | 70 | connect( a, SIGNAL( activated() ), go, SLOT( newGame() ) ); |
71 | a->addTo( file ); | 71 | a->addTo( file ); |
72 | 72 | ||
73 | a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 ); | 73 | a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 ); |
74 | connect( a, SIGNAL( activated() ), go, SLOT( pass() ) ); | 74 | connect( a, SIGNAL( activated() ), go, SLOT( pass() ) ); |
75 | a->addTo( file ); | 75 | a->addTo( file ); |
76 | a->addTo( toolbar ); | 76 | a->addTo( toolbar ); |
77 | 77 | ||
78 | 78 | ||
79 | a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 ); | 79 | a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 ); |
80 | connect( a, SIGNAL( activated() ), go, SLOT( resign() ) ); | 80 | connect( a, SIGNAL( activated() ), go, SLOT( resign() ) ); |
81 | a->addTo( file ); | 81 | a->addTo( file ); |
82 | 82 | ||
83 | a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 ); | 83 | a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 ); |
84 | a->setToggleAction( TRUE ); | 84 | a->setToggleAction( TRUE ); |
85 | connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) ); | 85 | connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) ); |
86 | a->addTo( file ); | 86 | a->addTo( file ); |
87 | 87 | ||
88 | mb->insertItem( tr( "Game" ), file ); | 88 | mb->insertItem( tr( "Game" ), file ); |
89 | 89 | ||
90 | QLabel *turnLabel = new QLabel( toolbar ); | 90 | QLabel *turnLabel = new QLabel( toolbar ); |
91 | turnLabel->setBackgroundMode( PaletteButton ); | 91 | turnLabel->setBackgroundMode( PaletteButton ); |
92 | connect( go, SIGNAL(showTurn(const QPixmap&)), | 92 | connect( go, SIGNAL(showTurn(const QPixmap&)), |
93 | turnLabel, SLOT(setPixmap(const QPixmap&)) ); | 93 | turnLabel, SLOT(setPixmap(const QPixmap&)) ); |
94 | 94 | ||
95 | 95 | ||
96 | QLabel * scoreLabel = new QLabel( toolbar ); | 96 | QLabel * scoreLabel = new QLabel( toolbar ); |
97 | scoreLabel->setBackgroundMode( PaletteButton ); | 97 | scoreLabel->setBackgroundMode( PaletteButton ); |
98 | connect( go, SIGNAL(showScore(const QString&)), | 98 | connect( go, SIGNAL(showScore(const QString&)), |
99 | scoreLabel, SLOT(setText(const QString&)) ); | 99 | scoreLabel, SLOT(setText(const QString&)) ); |
100 | 100 | ||
101 | toolbar->setStretchableWidget( scoreLabel ); | 101 | toolbar->setStretchableWidget( scoreLabel ); |
102 | 102 | ||
103 | go->readConfig(); | 103 | go->readConfig(); |
104 | } | 104 | } |
105 | 105 | ||
106 | void GoMainWidget::resizeEvent( QResizeEvent * ) | 106 | void GoMainWidget::resizeEvent( QResizeEvent * ) |
107 | { | 107 | { |
108 | //### this won't work because of the text label... | 108 | //### this won't work because of the text label... |
109 | /* | 109 | /* |
110 | if ( width() > height() ) | 110 | if ( width() > height() ) |
111 | moveToolBar( toolbar, Left ); | 111 | moveToolBar( toolbar, Left ); |
112 | else | 112 | else |
113 | moveToolBar( toolbar, Top ); | 113 | moveToolBar( toolbar, Top ); |
114 | */ | 114 | */ |
115 | } | 115 | } |
116 | 116 | ||
117 | GoWidget *GoWidget::self = 0; | 117 | GoWidget *GoWidget::self = 0; |
118 | 118 | ||
119 | GoWidget::GoWidget( QWidget *parent, const char* name) : | 119 | GoWidget::GoWidget( QWidget *parent, const char* name) : |
120 | QWidget( parent, name ) | 120 | QWidget( parent, name ) |
121 | { | 121 | { |
122 | if ( self ) | 122 | if ( self ) |
123 | fatal( "Only one Go widget allowed" ); | 123 | fatal( "Only one Go widget allowed" ); |
124 | self = this; | 124 | self = this; |
125 | twoplayer = FALSE; | 125 | twoplayer = FALSE; |
126 | 126 | ||
127 | 127 | ||
128 | d = bx = by = 1; | 128 | d = bx = by = 1; |
129 | 129 | ||
130 | QPixmap pix = Resource::loadPixmap( "go/pine" ); | 130 | QPixmap pix = Resource::loadPixmap( "go/pine" ); |
131 | goBrush = new QBrush( black, pix ); | 131 | goBrush = new QBrush( black, pix ); |
132 | /* | 132 | /* |
133 | QString fn = Resource::findPixmap("Go-black"); | 133 | QString fn = Resource::findPixmap("Go-black"); |
134 | blackStone = new QImage( fn ); | 134 | blackStone = new QImage( fn ); |
135 | fn = Resource::findPixmap("Go-black-highlight"); | 135 | fn = Resource::findPixmap("Go-black-highlight"); |
136 | newBlackStone = new QImage( fn ); | 136 | newBlackStone = new QImage( fn ); |
137 | fn = Resource::findPixmap("Go-white"); | 137 | fn = Resource::findPixmap("Go-white"); |
138 | whiteStone = new QImage( fn ); | 138 | whiteStone = new QImage( fn ); |
139 | */ | 139 | */ |
140 | blackStone = new QPixmap(Resource::loadPixmap( "Go-black" )); | 140 | blackStone = new QPixmap(Resource::loadPixmap( "Go-black" )); |
141 | whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" )); | 141 | whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" )); |
142 | newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" )); | 142 | newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" )); |
143 | 143 | ||
144 | init(); | 144 | init(); |
145 | } | 145 | } |
146 | 146 | ||
147 | GoWidget::~GoWidget() | 147 | GoWidget::~GoWidget() |
148 | { | 148 | { |
149 | writeConfig(); | 149 | writeConfig(); |
150 | } | 150 | } |
151 | 151 | ||
152 | void GoWidget::writeConfig() | 152 | void GoWidget::writeConfig() |
153 | { | 153 | { |
154 | Config cfg("Go"); | 154 | Config cfg("Go"); |
155 | cfg.setGroup("Game"); | 155 | cfg.setGroup("Game"); |
156 | cfg.writeEntry("TwoPlayer", twoplayer); | 156 | cfg.writeEntry("TwoPlayer", twoplayer); |
157 | cfg.writeEntry("CurrentPlayer", currentPlayer); | 157 | cfg.writeEntry("CurrentPlayer", currentPlayer); |
158 | cfg.writeEntry("NPassed", nPassed); | 158 | cfg.writeEntry("NPassed", nPassed); |
159 | QString b; | 159 | QString b; |
160 | for (int i=0; i<19; i++) | 160 | for (int i=0; i<19; i++) |
161 | for (int j=0; j<19; j++) | 161 | for (int j=0; j<19; j++) |
162 | b += board[i][j] == BLACK ? 'B' : board[i][j] == WHITE ? 'W' : '.'; | 162 | b += board[i][j] == BLACK ? 'B' : board[i][j] == WHITE ? 'W' : '.'; |
163 | cfg.writeEntry("Board", b); | 163 | cfg.writeEntry("Board", b); |
164 | cfg.writeEntry("LastX", lastX); | 164 | cfg.writeEntry("LastX", lastX); |
165 | cfg.writeEntry("LastY", lastY); | 165 | cfg.writeEntry("LastY", lastY); |
166 | extern int blackPrisoners, whitePrisoners; | 166 | extern int blackPrisoners, whitePrisoners; |
167 | cfg.writeEntry("BlackPrisoners", blackPrisoners); | 167 | cfg.writeEntry("BlackPrisoners", blackPrisoners); |
168 | cfg.writeEntry("WhitePrisoners", whitePrisoners); | 168 | cfg.writeEntry("WhitePrisoners", whitePrisoners); |
169 | } | 169 | } |
170 | 170 | ||
171 | void GoWidget::readConfig() | 171 | void GoWidget::readConfig() |
172 | { | 172 | { |
173 | init(); | 173 | init(); |
174 | Config cfg("Go"); | 174 | Config cfg("Go"); |
175 | cfg.setGroup("Game"); | 175 | cfg.setGroup("Game"); |
176 | twoplayer = cfg.readBoolEntry("TwoPlayer"); | 176 | twoplayer = cfg.readBoolEntry("TwoPlayer"); |
177 | currentPlayer = (bVal)cfg.readNumEntry("CurrentPlayer",1); | 177 | currentPlayer = (bVal)cfg.readNumEntry("CurrentPlayer",1); |
178 | nPassed = cfg.readNumEntry("NPassed",0); | 178 | nPassed = cfg.readNumEntry("NPassed",0); |
179 | QString b = cfg.readEntry("Board"); | 179 | QString b = cfg.readEntry("Board"); |
180 | if ( b.length() == 19*19 ) | 180 | if ( b.length() == 19*19 ) |
181 | for (int i=0; i<19; i++) | 181 | for (int i=0; i<19; i++) |
182 | for (int j=0; j<19; j++) { | 182 | for (int j=0; j<19; j++) { |
183 | QChar ch = b[j+19*i]; | 183 | QChar ch = b[j+19*i]; |
184 | if ( ch != '.' ) | 184 | if ( ch != '.' ) |
185 | GoPlaceStone( ch == 'B' ? BLACK : WHITE, i, j ); | 185 | GoPlaceStone( ch == 'B' ? BLACK : WHITE, i, j ); |
186 | } | 186 | } |
187 | lastX = cfg.readNumEntry("LastX"); | 187 | lastX = cfg.readNumEntry("LastX"); |
188 | lastY = cfg.readNumEntry("LastY"); | 188 | lastY = cfg.readNumEntry("LastY"); |
189 | extern int blackPrisoners, whitePrisoners; | 189 | extern int blackPrisoners, whitePrisoners; |
190 | blackPrisoners = cfg.readNumEntry("BlackPrisoners",0); | 190 | blackPrisoners = cfg.readNumEntry("BlackPrisoners",0); |
191 | whitePrisoners = cfg.readNumEntry("WhitePrisoners",0); | 191 | whitePrisoners = cfg.readNumEntry("WhitePrisoners",0); |
192 | reportPrisoners(blackPrisoners,whitePrisoners); | 192 | reportPrisoners(blackPrisoners,whitePrisoners); |
193 | emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); | 193 | emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); |
194 | } | 194 | } |
195 | 195 | ||
196 | void GoWidget::resizeEvent( QResizeEvent * ) | 196 | void GoWidget::resizeEvent( QResizeEvent * ) |
197 | { | 197 | { |
198 | d = QMIN(width(),height())/19; | 198 | d = QMIN(width(),height())/19; |
199 | // int r = (d/2-1); | 199 | // int r = (d/2-1); |
200 | bx = (width() - 18*d)/2 ; | 200 | bx = (width() - 18*d)/2 ; |
201 | by = (height() - 18*d)/2 ; | 201 | by = (height() - 18*d)/2 ; |
202 | 202 | ||
203 | if ( d < 10 && !smallStones ) { | 203 | if ( d < 10 && !smallStones ) { |
204 | blackStone->convertFromImage( blackStone->convertToImage().smoothScale(8,8) ); | 204 | blackStone->convertFromImage( blackStone->convertToImage().smoothScale(8,8) ); |
205 | whiteStone->convertFromImage( whiteStone->convertToImage().smoothScale(8,8) ); | 205 | whiteStone->convertFromImage( whiteStone->convertToImage().smoothScale(8,8) ); |
206 | newBlackStone->convertFromImage( newBlackStone->convertToImage().smoothScale(8,8) ); | 206 | newBlackStone->convertFromImage( newBlackStone->convertToImage().smoothScale(8,8) ); |
207 | 207 | ||
208 | smallStones = TRUE; | 208 | smallStones = TRUE; |
209 | } else if ( d >= 10 && smallStones ) { | 209 | } else if ( d >= 10 && smallStones ) { |
210 | blackStone = new QPixmap(Resource::loadPixmap( "Go-black" )); | 210 | blackStone = new QPixmap(Resource::loadPixmap( "Go-black" )); |
211 | whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" )); | 211 | whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" )); |
212 | newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" )); | 212 | newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" )); |
213 | smallStones = FALSE; | 213 | smallStones = FALSE; |
214 | } | 214 | } |
215 | } | 215 | } |
216 | 216 | ||
217 | void GoWidget::init() | 217 | void GoWidget::init() |
218 | { | 218 | { |
219 | lastX = lastY = newX = newY = -1; | 219 | lastX = lastY = newX = newY = -1; |
220 | nPassed = 0; | 220 | nPassed = 0; |
221 | for ( int i = 0; i < 19; i++ ) | 221 | for ( int i = 0; i < 19; i++ ) |
222 | for ( int j = 0; j < 19; j++ ) | 222 | for ( int j = 0; j < 19; j++ ) |
223 | board[i][j]=-1; | 223 | board[i][j]=-1; |
224 | gameActive = TRUE; | 224 | gameActive = TRUE; |
225 | goRestart(current_handicap); | 225 | goRestart(current_handicap); |
226 | 226 | ||
227 | if ( twoplayer ) { | 227 | if ( twoplayer ) { |
228 | currentPlayer = BLACK; | 228 | currentPlayer = BLACK; |
229 | } else { | 229 | } else { |
230 | doComputerMove(); | 230 | doComputerMove(); |
231 | currentPlayer = WHITE; | 231 | currentPlayer = WHITE; |
232 | } | 232 | } |
233 | emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); | 233 | emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); |
234 | } | 234 | } |
235 | 235 | ||
236 | void GoWidget::paintEvent( QPaintEvent *e ) | 236 | void GoWidget::paintEvent( QPaintEvent *e ) |
237 | { | 237 | { |
238 | int i,j; | 238 | int i,j; |
239 | 239 | ||
240 | int r = whiteStone->width()/2; | 240 | int r = whiteStone->width()/2; |
241 | 241 | ||
242 | QPainter p(this); | 242 | QPainter p(this); |
243 | p.fillRect( bx - d/2, by - d/2, 19*d, 19*d, *goBrush ); | 243 | p.fillRect( bx - d/2, by - d/2, 19*d, 19*d, *goBrush ); |
244 | 244 | ||
245 | int xMin = QMAX( x2board(e->rect().left()), 0 ); | 245 | int xMin = QMAX( x2board(e->rect().left()), 0 ); |
246 | int xMax = QMIN( x2board(e->rect().right()), 18 ); | 246 | int xMax = QMIN( x2board(e->rect().right()), 18 ); |
247 | int yMin = QMAX( y2board(e->rect().top()), 0 ); | 247 | int yMin = QMAX( y2board(e->rect().top()), 0 ); |
248 | int yMax = QMIN( y2board(e->rect().bottom()), 18 ); | 248 | int yMax = QMIN( y2board(e->rect().bottom()), 18 ); |
249 | 249 | ||
250 | QColor pine( 255, 186, 89 ); | 250 | QColor pine( 255, 186, 89 ); |
251 | p.setPen( pine.dark() ); | 251 | p.setPen( pine.dark() ); |
252 | 252 | ||
253 | for ( i = xMin; i < xMax+1 ; i ++ ) { | 253 | for ( i = xMin; i < xMax+1 ; i ++ ) { |
254 | p.drawLine( bx+i*d, by, bx+i*d, by+18*d ); | 254 | p.drawLine( bx+i*d, by, bx+i*d, by+18*d ); |
255 | } | 255 | } |
256 | for ( j = yMin; j < yMax+1 ; j ++ ) { | 256 | for ( j = yMin; j < yMax+1 ; j ++ ) { |
257 | p.drawLine( bx, by+j*d, bx+18*d, by+j*d); | 257 | p.drawLine( bx, by+j*d, bx+18*d, by+j*d); |
258 | } | 258 | } |
259 | 259 | ||
260 | // dots are at (3,3), (3,9), (3,15) and so on | 260 | // dots are at (3,3), (3,9), (3,15) and so on |
261 | p.setBrush( black ); | 261 | p.setBrush( black ); |
262 | for ( i = 3; i < xMax+1; i+=6 ) | 262 | for ( i = 3; i < xMax+1; i+=6 ) |
263 | for ( j = 3; j < yMax+1; j+=6 ) | 263 | for ( j = 3; j < yMax+1; j+=6 ) |
264 | p.drawEllipse( bx+i*d-2, by+j*d-2, 5, 5 ); | 264 | p.drawEllipse( bx+i*d-2, by+j*d-2, 5, 5 ); |
265 | 265 | ||
266 | 266 | ||
267 | for ( i = xMin; i < xMax+1; i++ ) | 267 | for ( i = xMin; i < xMax+1; i++ ) |
268 | for ( j = yMin; j < yMax+1; j++ ) { | 268 | for ( j = yMin; j < yMax+1; j++ ) { |
269 | if ( board[i][j] == WHITE || | 269 | if ( board[i][j] == WHITE || |
270 | currentPlayer==WHITE && newX == i && newY == j ) | 270 | currentPlayer==WHITE && newX == i && newY == j ) |
271 | p.drawPixmap( bx+i*d - r, by+j*d - r, *whiteStone ); | 271 | p.drawPixmap( bx+i*d - r, by+j*d - r, *whiteStone ); |
272 | else if ( i == lastX && j == lastY ) | 272 | else if ( i == lastX && j == lastY ) |
273 | p.drawPixmap( bx+i*d - r, by+j*d - r, *newBlackStone ); | 273 | p.drawPixmap( bx+i*d - r, by+j*d - r, *newBlackStone ); |
274 | else if ( board[i][j] == BLACK || | 274 | else if ( board[i][j] == BLACK || |
275 | currentPlayer==BLACK && newX == i && newY == j) | 275 | currentPlayer==BLACK && newX == i && newY == j) |
276 | p.drawPixmap( bx+i*d - r, by+j*d - r, *blackStone ); | 276 | p.drawPixmap( bx+i*d - r, by+j*d - r, *blackStone ); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | void GoWidget::doMove( int x, int y ) | 280 | void GoWidget::doMove( int x, int y ) |
281 | { | 281 | { |
282 | 282 | ||
283 | if ( !GoPlaceStone( currentPlayer, x, y ) ) { | 283 | if ( !GoPlaceStone( currentPlayer, x, y ) ) { |
284 | //printf( "Illegal move (%d,%d)\n", x, y ); | 284 | //printf( "Illegal move (%d,%d)\n", x, y ); |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | //printf( "you do (%d,%d)\n", x, y ); | 287 | //printf( "you do (%d,%d)\n", x, y ); |
288 | nPassed = 0; | 288 | nPassed = 0; |
289 | if ( twoplayer ) | 289 | if ( twoplayer ) |
290 | currentPlayer = (currentPlayer==WHITE) ? BLACK : WHITE; | 290 | currentPlayer = (currentPlayer==WHITE) ? BLACK : WHITE; |
291 | else | 291 | else |
292 | doComputerMove(); | 292 | doComputerMove(); |
293 | 293 | ||
294 | emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); | 294 | emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); |
295 | 295 | ||
296 | } | 296 | } |
297 | 297 | ||
298 | void GoWidget::pass() | 298 | void GoWidget::pass() |
299 | { | 299 | { |
300 | if ( !gameActive ) | 300 | if ( !gameActive ) |
301 | return; | 301 | return; |
302 | nPassed++; | 302 | nPassed++; |
303 | if ( nPassed >= 2 ) | 303 | if ( nPassed >= 2 ) |
304 | endGame(); | 304 | endGame(); |
305 | else if ( !twoplayer ) | 305 | else if ( !twoplayer ) |
306 | doComputerMove(); | 306 | doComputerMove(); |
307 | } | 307 | } |
308 | 308 | ||
309 | void GoWidget::resign() | 309 | void GoWidget::resign() |
310 | { | 310 | { |
311 | if ( gameActive ) | 311 | if ( gameActive ) |
312 | endGame(); | 312 | endGame(); |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | void GoWidget::newGame() | 316 | void GoWidget::newGame() |
317 | { | 317 | { |
318 | init(); | 318 | init(); |
319 | update(); | 319 | update(); |
320 | } | 320 | } |
321 | 321 | ||
diff --git a/noncore/games/minesweep/minesweep.cpp b/noncore/games/minesweep/minesweep.cpp index c84fe53..814070b 100644 --- a/noncore/games/minesweep/minesweep.cpp +++ b/noncore/games/minesweep/minesweep.cpp | |||
@@ -1,405 +1,405 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "minesweep.h" | 21 | #include "minesweep.h" |
22 | #include "minefield.h" | 22 | #include "minefield.h" |
23 | 23 | ||
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | 26 | ||
27 | #include <qpe/qpetoolbar.h> | 27 | #include <qpe/qpetoolbar.h> |
28 | #include <qpe/qpemenubar.h> | 28 | #include <qpe/qpemenubar.h> |
29 | #include <qpopupmenu.h> | 29 | #include <qpopupmenu.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qlcdnumber.h> | 31 | #include <qlcdnumber.h> |
32 | #include <qmessagebox.h> | 32 | #include <qmessagebox.h> |
33 | #include <qtimer.h> | 33 | #include <qtimer.h> |
34 | #include <qpalette.h> | 34 | #include <qpalette.h> |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | 38 | ||
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | #include <time.h> | 40 | #include <time.h> |
41 | 41 | ||
42 | 42 | ||
43 | 43 | ||
44 | 44 | ||
45 | static const char *pix_new[]={ | 45 | static const char *pix_new[]={ |
46 | "20 20 3 1", | 46 | "20 20 3 1", |
47 | " c None", | 47 | " c None", |
48 | "# c #00FF00", | 48 | "# c #00FF00", |
49 | ". c #000000", | 49 | ". c #000000", |
50 | " ", | 50 | " ", |
51 | " ...... ", | 51 | " ...... ", |
52 | " ..######.. ", | 52 | " ..######.. ", |
53 | " .##########. ", | 53 | " .##########. ", |
54 | " .############. ", | 54 | " .############. ", |
55 | " .##############. ", | 55 | " .##############. ", |
56 | " .##############. ", | 56 | " .##############. ", |
57 | " .################. ", | 57 | " .################. ", |
58 | " .################. ", | 58 | " .################. ", |
59 | " .################. ", | 59 | " .################. ", |
60 | " .################. ", | 60 | " .################. ", |
61 | " .################. ", | 61 | " .################. ", |
62 | " .################. ", | 62 | " .################. ", |
63 | " .##############. ", | 63 | " .##############. ", |
64 | " .##############. ", | 64 | " .##############. ", |
65 | " .############. ", | 65 | " .############. ", |
66 | " .##########. ", | 66 | " .##########. ", |
67 | " ..######.. ", | 67 | " ..######.. ", |
68 | " ...... ", | 68 | " ...... ", |
69 | " "}; | 69 | " "}; |
70 | 70 | ||
71 | 71 | ||
72 | /* XPM */ | 72 | /* XPM */ |
73 | static const char * happy_xpm[] = { | 73 | static const char * happy_xpm[] = { |
74 | "20 20 3 1", | 74 | "20 20 3 1", |
75 | " c None", | 75 | " c None", |
76 | ".c #ffff3f ", | 76 | ".c #ffff3f ", |
77 | "#c #000000", | 77 | "#c #000000", |
78 | " ", | 78 | " ", |
79 | " ###### ", | 79 | " ###### ", |
80 | " ##......## ", | 80 | " ##......## ", |
81 | " #..........# ", | 81 | " #..........# ", |
82 | " #............# ", | 82 | " #............# ", |
83 | " #..............# ", | 83 | " #..............# ", |
84 | " #..............# ", | 84 | " #..............# ", |
85 | " #....##....##....# ", | 85 | " #....##....##....# ", |
86 | " #....##....##....# ", | 86 | " #....##....##....# ", |
87 | " #................# ", | 87 | " #................# ", |
88 | " #................# ", | 88 | " #................# ", |
89 | " #................# ", | 89 | " #................# ", |
90 | " #...#........#...# ", | 90 | " #...#........#...# ", |
91 | " #.##........##.# ", | 91 | " #.##........##.# ", |
92 | " #...########...# ", | 92 | " #...########...# ", |
93 | " #...######...# ", | 93 | " #...######...# ", |
94 | " #..........# ", | 94 | " #..........# ", |
95 | " ##......## ", | 95 | " ##......## ", |
96 | " ###### ", | 96 | " ###### ", |
97 | " "}; | 97 | " "}; |
98 | 98 | ||
99 | 99 | ||
100 | /* XPM */ | 100 | /* XPM */ |
101 | static const char * worried_xpm[] = { | 101 | static const char * worried_xpm[] = { |
102 | "20 20 3 1", | 102 | "20 20 3 1", |
103 | " c None", | 103 | " c None", |
104 | ".c #ffff3f", | 104 | ".c #ffff3f", |
105 | "#c #000000", | 105 | "#c #000000", |
106 | " ", | 106 | " ", |
107 | " ###### ", | 107 | " ###### ", |
108 | " ##......## ", | 108 | " ##......## ", |
109 | " #..........# ", | 109 | " #..........# ", |
110 | " #............# ", | 110 | " #............# ", |
111 | " #..............# ", | 111 | " #..............# ", |
112 | " #..............# ", | 112 | " #..............# ", |
113 | " #....##....##....# ", | 113 | " #....##....##....# ", |
114 | " #....##....##....# ", | 114 | " #....##....##....# ", |
115 | " #................# ", | 115 | " #................# ", |
116 | " #................# ", | 116 | " #................# ", |
117 | " #................# ", | 117 | " #................# ", |
118 | " #................# ", | 118 | " #................# ", |
119 | " #....######....# ", | 119 | " #....######....# ", |
120 | " #..............# ", | 120 | " #..............# ", |
121 | " #............# ", | 121 | " #............# ", |
122 | " #..........# ", | 122 | " #..........# ", |
123 | " ##......## ", | 123 | " ##......## ", |
124 | " ###### ", | 124 | " ###### ", |
125 | " "}; | 125 | " "}; |
126 | 126 | ||
127 | 127 | ||
128 | /* XPM */ | 128 | /* XPM */ |
129 | static const char * dead_xpm[] = { | 129 | static const char * dead_xpm[] = { |
130 | "20 20 3 1", | 130 | "20 20 3 1", |
131 | " c None", | 131 | " c None", |
132 | ".c #ffff3f", | 132 | ".c #ffff3f", |
133 | "#c #000000", | 133 | "#c #000000", |
134 | " ", | 134 | " ", |
135 | " ###### ", | 135 | " ###### ", |
136 | " ##......## ", | 136 | " ##......## ", |
137 | " #..........# ", | 137 | " #..........# ", |
138 | " #............# ", | 138 | " #............# ", |
139 | " #..............# ", | 139 | " #..............# ", |
140 | " #..#.#...#.#...# ", | 140 | " #..#.#...#.#...# ", |
141 | " #....#.....#.....# ", | 141 | " #....#.....#.....# ", |
142 | " #...#.#...#.#....# ", | 142 | " #...#.#...#.#....# ", |
143 | " #................# ", | 143 | " #................# ", |
144 | " #................# ", | 144 | " #................# ", |
145 | " #................# ", | 145 | " #................# ", |
146 | " #......####......# ", | 146 | " #......####......# ", |
147 | " #....# #....# ", | 147 | " #....# #....# ", |
148 | " #...#......#...# ", | 148 | " #...#......#...# ", |
149 | " #............# ", | 149 | " #............# ", |
150 | " #..........# ", | 150 | " #..........# ", |
151 | " ##......## ", | 151 | " ##......## ", |
152 | " ###### ", | 152 | " ###### ", |
153 | " "}; | 153 | " "}; |
154 | 154 | ||
155 | 155 | ||
156 | class ResultIndicator : private QLabel | 156 | class ResultIndicator : private QLabel |
157 | { | 157 | { |
158 | public: | 158 | public: |
159 | static void showResult( QWidget *ref, bool won ); | 159 | static void showResult( QWidget *ref, bool won ); |
160 | private: | 160 | private: |
161 | ResultIndicator( QWidget *parent, const char *name, WFlags f) | 161 | ResultIndicator( QWidget *parent, const char *name, WFlags f) |
162 | :QLabel( parent, name, f ) {} | 162 | :QLabel( parent, name, f ) {} |
163 | 163 | ||
164 | void timerEvent( QTimerEvent *); | 164 | void timerEvent( QTimerEvent *); |
165 | void center(); | 165 | void center(); |
166 | bool twoStage; | 166 | bool twoStage; |
167 | int timerId; | 167 | int timerId; |
168 | }; | 168 | }; |
169 | 169 | ||
170 | void ResultIndicator::showResult( QWidget *ref, bool won ) | 170 | void ResultIndicator::showResult( QWidget *ref, bool won ) |
171 | { | 171 | { |
172 | ResultIndicator *r = new ResultIndicator( ref, 0, WStyle_Customize | WStyle_Tool | WType_TopLevel ); | 172 | ResultIndicator *r = new ResultIndicator( ref, 0, WStyle_Customize | WStyle_Tool | WType_TopLevel ); |
173 | 173 | ||
174 | r->setAlignment( AlignCenter ); | 174 | r->setAlignment( AlignCenter ); |
175 | r->setFrameStyle( Sunken|StyledPanel ); | 175 | r->setFrameStyle( Sunken|StyledPanel ); |
176 | if ( won ) { | 176 | if ( won ) { |
177 | r->setText( MineSweep::tr("You won!") ); | 177 | r->setText( MineSweep::tr("You won!") ); |
178 | r->center(); | 178 | r->center(); |
179 | r->show(); | 179 | r->show(); |
180 | r->twoStage = FALSE; | 180 | r->twoStage = FALSE; |
181 | r->timerId = r->startTimer(1500); | 181 | r->timerId = r->startTimer(1500); |
182 | } else { | 182 | } else { |
183 | QPalette p( red ); | 183 | QPalette p( red ); |
184 | r->setPalette( p ); | 184 | r->setPalette( p ); |
185 | r->setText( MineSweep::tr("You exploded!") ); | 185 | r->setText( MineSweep::tr("You exploded!") ); |
186 | r->resize( ref->size() ); | 186 | r->resize( ref->size() ); |
187 | r->move( ref->mapToGlobal(QPoint(0,0)) ); | 187 | r->move( ref->mapToGlobal(QPoint(0,0)) ); |
188 | r->show(); | 188 | r->show(); |
189 | r->twoStage = TRUE; | 189 | r->twoStage = TRUE; |
190 | r->timerId =r->startTimer(200); | 190 | r->timerId =r->startTimer(200); |
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
194 | void ResultIndicator::center() | 194 | void ResultIndicator::center() |
195 | { | 195 | { |
196 | QWidget *w = parentWidget(); | 196 | QWidget *w = parentWidget(); |
197 | 197 | ||
198 | QPoint pp = w->mapToGlobal( QPoint(0,0) ); | 198 | QPoint pp = w->mapToGlobal( QPoint(0,0) ); |
199 | QSize s = sizeHint()*3; | 199 | QSize s = sizeHint()*3; |
200 | pp = QPoint( pp.x() + w->width()/2 - s.width()/2, | 200 | pp = QPoint( pp.x() + w->width()/2 - s.width()/2, |
201 | pp.y() + w->height()/ 2 - s.height()/2 ); | 201 | pp.y() + w->height()/ 2 - s.height()/2 ); |
202 | 202 | ||
203 | setGeometry( QRect(pp, s) ); | 203 | setGeometry( QRect(pp, s) ); |
204 | 204 | ||
205 | } | 205 | } |
206 | 206 | ||
207 | void ResultIndicator::timerEvent( QTimerEvent *te ) | 207 | void ResultIndicator::timerEvent( QTimerEvent *te ) |
208 | { | 208 | { |
209 | if ( te->timerId() != timerId ) | 209 | if ( te->timerId() != timerId ) |
210 | return; | 210 | return; |
211 | killTimer( timerId ); | 211 | killTimer( timerId ); |
212 | if ( twoStage ) { | 212 | if ( twoStage ) { |
213 | center(); | 213 | center(); |
214 | twoStage = FALSE; | 214 | twoStage = FALSE; |
215 | timerId = startTimer( 1000 ); | 215 | timerId = startTimer( 1000 ); |
216 | } else { | 216 | } else { |
217 | delete this; | 217 | delete this; |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | 221 | ||
222 | class MineFrame : public QFrame | 222 | class MineFrame : public QFrame |
223 | { | 223 | { |
224 | public: | 224 | public: |
225 | MineFrame( QWidget *parent, const char *name = 0 ) | 225 | MineFrame( QWidget *parent, const char *name = 0 ) |
226 | :QFrame( parent, name ) {} | 226 | :QFrame( parent, name ) {} |
227 | void setField( MineField *f ) { field = f; } | 227 | void setField( MineField *f ) { field = f; } |
228 | protected: | 228 | protected: |
229 | void resizeEvent( QResizeEvent *e ) { | 229 | void resizeEvent( QResizeEvent *e ) { |
230 | field->setAvailableRect( contentsRect()); | 230 | field->setAvailableRect( contentsRect()); |
231 | QFrame::resizeEvent(e); | 231 | QFrame::resizeEvent(e); |
232 | } | 232 | } |
233 | private: | 233 | private: |
234 | MineField *field; | 234 | MineField *field; |
235 | }; | 235 | }; |
236 | 236 | ||
237 | 237 | ||
238 | 238 | ||
239 | MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f ) | 239 | MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f ) |
240 | : QMainWindow( parent, name, f ) | 240 | : QMainWindow( parent, name, f ) |
241 | { | 241 | { |
242 | srand(::time(0)); | 242 | srand(::time(0)); |
243 | setCaption( tr("Mine Hunt") ); | 243 | setCaption( tr("Mine Hunt") ); |
244 | setIcon( Resource::loadPixmap( "minesweep_icon" ) ); | 244 | setIcon( Resource::loadPixmap( "minesweep_icon" ) ); |
245 | 245 | ||
246 | QPEToolBar *toolBar = new QPEToolBar( this ); | 246 | QPEToolBar *toolBar = new QPEToolBar( this ); |
247 | toolBar->setHorizontalStretchable( TRUE ); | 247 | toolBar->setHorizontalStretchable( TRUE ); |
248 | 248 | ||
249 | QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); | 249 | QMenuBar *menuBar = new QMenuBar( toolBar ); |
250 | 250 | ||
251 | QPopupMenu *gameMenu = new QPopupMenu( this ); | 251 | QPopupMenu *gameMenu = new QPopupMenu( this ); |
252 | gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) ); | 252 | gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) ); |
253 | gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) ); | 253 | gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) ); |
254 | gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) ); | 254 | gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) ); |
255 | 255 | ||
256 | menuBar->insertItem( tr("Game"), gameMenu ); | 256 | menuBar->insertItem( tr("Game"), gameMenu ); |
257 | 257 | ||
258 | guessLCD = new QLCDNumber( toolBar ); | 258 | guessLCD = new QLCDNumber( toolBar ); |
259 | toolBar->setStretchableWidget( guessLCD ); | 259 | toolBar->setStretchableWidget( guessLCD ); |
260 | 260 | ||
261 | QPalette lcdPal( red ); | 261 | QPalette lcdPal( red ); |
262 | lcdPal.setColor( QColorGroup::Background, QApplication::palette().active().background() ); | 262 | lcdPal.setColor( QColorGroup::Background, QApplication::palette().active().background() ); |
263 | lcdPal.setColor( QColorGroup::Button, QApplication::palette().active().button() ); | 263 | lcdPal.setColor( QColorGroup::Button, QApplication::palette().active().button() ); |
264 | 264 | ||
265 | // guessLCD->setPalette( lcdPal ); | 265 | // guessLCD->setPalette( lcdPal ); |
266 | guessLCD->setSegmentStyle( QLCDNumber::Flat ); | 266 | guessLCD->setSegmentStyle( QLCDNumber::Flat ); |
267 | guessLCD->setFrameStyle( QFrame::NoFrame ); | 267 | guessLCD->setFrameStyle( QFrame::NoFrame ); |
268 | guessLCD->setNumDigits( 2 ); | 268 | guessLCD->setNumDigits( 2 ); |
269 | guessLCD->setBackgroundMode( PaletteButton ); | 269 | guessLCD->setBackgroundMode( PaletteButton ); |
270 | newGameButton = new QPushButton( toolBar ); | 270 | newGameButton = new QPushButton( toolBar ); |
271 | newGameButton->setPixmap( QPixmap( pix_new ) ); | 271 | newGameButton->setPixmap( QPixmap( pix_new ) ); |
272 | newGameButton->setFocusPolicy(QWidget::NoFocus); | 272 | newGameButton->setFocusPolicy(QWidget::NoFocus); |
273 | connect( newGameButton, SIGNAL(clicked()), this, SLOT(newGame()) ); | 273 | connect( newGameButton, SIGNAL(clicked()), this, SLOT(newGame()) ); |
274 | 274 | ||
275 | timeLCD = new QLCDNumber( toolBar ); | 275 | timeLCD = new QLCDNumber( toolBar ); |
276 | // timeLCD->setPalette( lcdPal ); | 276 | // timeLCD->setPalette( lcdPal ); |
277 | timeLCD->setSegmentStyle( QLCDNumber::Flat ); | 277 | timeLCD->setSegmentStyle( QLCDNumber::Flat ); |
278 | timeLCD->setFrameStyle( QFrame::NoFrame ); | 278 | timeLCD->setFrameStyle( QFrame::NoFrame ); |
279 | timeLCD->setNumDigits( 5 ); // "mm:ss" | 279 | timeLCD->setNumDigits( 5 ); // "mm:ss" |
280 | timeLCD->setBackgroundMode( PaletteButton ); | 280 | timeLCD->setBackgroundMode( PaletteButton ); |
281 | 281 | ||
282 | setToolBarsMovable ( FALSE ); | 282 | setToolBarsMovable ( FALSE ); |
283 | 283 | ||
284 | addToolBar( toolBar ); | 284 | addToolBar( toolBar ); |
285 | 285 | ||
286 | MineFrame *mainframe = new MineFrame( this ); | 286 | MineFrame *mainframe = new MineFrame( this ); |
287 | mainframe->setFrameShape( QFrame::Box ); | 287 | mainframe->setFrameShape( QFrame::Box ); |
288 | mainframe->setFrameShadow( QFrame::Raised ); | 288 | mainframe->setFrameShadow( QFrame::Raised ); |
289 | 289 | ||
290 | mainframe->setLineWidth(2); | 290 | mainframe->setLineWidth(2); |
291 | 291 | ||
292 | field = new MineField( mainframe ); | 292 | field = new MineField( mainframe ); |
293 | mainframe->setField( field ); | 293 | mainframe->setField( field ); |
294 | QFont fnt = field->font(); | 294 | QFont fnt = field->font(); |
295 | fnt.setBold( TRUE ); | 295 | fnt.setBold( TRUE ); |
296 | field->setFont( QFont( fnt ) ); | 296 | field->setFont( QFont( fnt ) ); |
297 | field->setFocus(); | 297 | field->setFocus(); |
298 | setCentralWidget( mainframe ); | 298 | setCentralWidget( mainframe ); |
299 | 299 | ||
300 | connect( field, SIGNAL( gameOver( bool ) ), this, SLOT( gameOver( bool ) ) ); | 300 | connect( field, SIGNAL( gameOver( bool ) ), this, SLOT( gameOver( bool ) ) ); |
301 | connect( field, SIGNAL( mineCount( int ) ), this, SLOT( setCounter( int ) ) ); | 301 | connect( field, SIGNAL( mineCount( int ) ), this, SLOT( setCounter( int ) ) ); |
302 | connect( field, SIGNAL( gameStarted()), this, SLOT( startPlaying() ) ); | 302 | connect( field, SIGNAL( gameStarted()), this, SLOT( startPlaying() ) ); |
303 | 303 | ||
304 | timer = new QTimer( this ); | 304 | timer = new QTimer( this ); |
305 | 305 | ||
306 | connect( timer, SIGNAL( timeout() ), this, SLOT( updateTime() ) ); | 306 | connect( timer, SIGNAL( timeout() ), this, SLOT( updateTime() ) ); |
307 | 307 | ||
308 | readConfig(); | 308 | readConfig(); |
309 | } | 309 | } |
310 | 310 | ||
311 | MineSweep::~MineSweep() | 311 | MineSweep::~MineSweep() |
312 | { | 312 | { |
313 | writeConfig(); | 313 | writeConfig(); |
314 | } | 314 | } |
315 | 315 | ||
316 | void MineSweep::gameOver( bool won ) | 316 | void MineSweep::gameOver( bool won ) |
317 | { | 317 | { |
318 | field->showMines(); | 318 | field->showMines(); |
319 | if ( won ) { | 319 | if ( won ) { |
320 | newGameButton->setPixmap( QPixmap( happy_xpm ) ); | 320 | newGameButton->setPixmap( QPixmap( happy_xpm ) ); |
321 | } else { | 321 | } else { |
322 | newGameButton->setPixmap( QPixmap( dead_xpm ) ); | 322 | newGameButton->setPixmap( QPixmap( dead_xpm ) ); |
323 | } | 323 | } |
324 | ResultIndicator::showResult( this, won ); | 324 | ResultIndicator::showResult( this, won ); |
325 | timer->stop(); | 325 | timer->stop(); |
326 | } | 326 | } |
327 | 327 | ||
328 | void MineSweep::newGame() | 328 | void MineSweep::newGame() |
329 | { | 329 | { |
330 | newGame(field->level()); | 330 | newGame(field->level()); |
331 | } | 331 | } |
332 | 332 | ||
333 | void MineSweep::newGame(int level) | 333 | void MineSweep::newGame(int level) |
334 | { | 334 | { |
335 | timeLCD->display( "0:00" ); | 335 | timeLCD->display( "0:00" ); |
336 | field->setup( level ); | 336 | field->setup( level ); |
337 | newGameButton->setPixmap( QPixmap( pix_new ) ); | 337 | newGameButton->setPixmap( QPixmap( pix_new ) ); |
338 | timer->stop(); | 338 | timer->stop(); |
339 | } | 339 | } |
340 | 340 | ||
341 | void MineSweep::startPlaying() | 341 | void MineSweep::startPlaying() |
342 | { | 342 | { |
343 | newGameButton->setPixmap( QPixmap( worried_xpm ) ); | 343 | newGameButton->setPixmap( QPixmap( worried_xpm ) ); |
344 | starttime = QDateTime::currentDateTime(); | 344 | starttime = QDateTime::currentDateTime(); |
345 | timer->start( 1000 ); | 345 | timer->start( 1000 ); |
346 | } | 346 | } |
347 | 347 | ||
348 | void MineSweep::beginner() | 348 | void MineSweep::beginner() |
349 | { | 349 | { |
350 | newGame(1); | 350 | newGame(1); |
351 | } | 351 | } |
352 | 352 | ||
353 | void MineSweep::advanced() | 353 | void MineSweep::advanced() |
354 | { | 354 | { |
355 | newGame(2); | 355 | newGame(2); |
356 | } | 356 | } |
357 | 357 | ||
358 | void MineSweep::expert() | 358 | void MineSweep::expert() |
359 | { | 359 | { |
360 | newGame(3); | 360 | newGame(3); |
361 | } | 361 | } |
362 | 362 | ||
363 | void MineSweep::setCounter( int c ) | 363 | void MineSweep::setCounter( int c ) |
364 | { | 364 | { |
365 | if ( !guessLCD ) | 365 | if ( !guessLCD ) |
366 | return; | 366 | return; |
367 | 367 | ||
368 | guessLCD->display( c ); | 368 | guessLCD->display( c ); |
369 | } | 369 | } |
370 | 370 | ||
371 | void MineSweep::updateTime() | 371 | void MineSweep::updateTime() |
372 | { | 372 | { |
373 | if ( !timeLCD ) | 373 | if ( !timeLCD ) |
374 | return; | 374 | return; |
375 | 375 | ||
376 | int s = starttime.secsTo(QDateTime::currentDateTime()); | 376 | int s = starttime.secsTo(QDateTime::currentDateTime()); |
377 | if ( s/60 > 99 ) | 377 | if ( s/60 > 99 ) |
378 | timeLCD->display( "-----" ); | 378 | timeLCD->display( "-----" ); |
379 | else | 379 | else |
380 | timeLCD->display( QString().sprintf("%2d:%02d",s/60,s%60) ); | 380 | timeLCD->display( QString().sprintf("%2d:%02d",s/60,s%60) ); |
381 | } | 381 | } |
382 | 382 | ||
383 | void MineSweep::writeConfig() const | 383 | void MineSweep::writeConfig() const |
384 | { | 384 | { |
385 | Config cfg("MineSweep"); | 385 | Config cfg("MineSweep"); |
386 | cfg.setGroup("Panel"); | 386 | cfg.setGroup("Panel"); |
387 | cfg.writeEntry("Time", | 387 | cfg.writeEntry("Time", |
388 | timer->isActive() ? starttime.secsTo(QDateTime::currentDateTime()) : -1); | 388 | timer->isActive() ? starttime.secsTo(QDateTime::currentDateTime()) : -1); |
389 | field->writeConfig(cfg); | 389 | field->writeConfig(cfg); |
390 | } | 390 | } |
391 | 391 | ||
392 | void MineSweep::readConfig() | 392 | void MineSweep::readConfig() |
393 | { | 393 | { |
394 | Config cfg("MineSweep"); | 394 | Config cfg("MineSweep"); |
395 | field->readConfig(cfg); | 395 | field->readConfig(cfg); |
396 | cfg.setGroup("Panel"); | 396 | cfg.setGroup("Panel"); |
397 | int s = cfg.readNumEntry("Time",-1); | 397 | int s = cfg.readNumEntry("Time",-1); |
398 | if ( s<0 ) { | 398 | if ( s<0 ) { |
399 | newGame(); | 399 | newGame(); |
400 | } else { | 400 | } else { |
401 | startPlaying(); | 401 | startPlaying(); |
402 | starttime = QDateTime::currentDateTime().addSecs(-s); | 402 | starttime = QDateTime::currentDateTime().addSecs(-s); |
403 | updateTime(); | 403 | updateTime(); |
404 | } | 404 | } |
405 | } | 405 | } |
diff --git a/noncore/games/solitaire/canvascardgame.h b/noncore/games/solitaire/canvascardgame.h index d159de6..b93cfbf 100644 --- a/noncore/games/solitaire/canvascardgame.h +++ b/noncore/games/solitaire/canvascardgame.h | |||
@@ -1,97 +1,97 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef CANVAS_CARD_GAME_H | 20 | #ifndef CANVAS_CARD_GAME_H |
21 | #define CANVAS_CARD_GAME_H | 21 | #define CANVAS_CARD_GAME_H |
22 | 22 | ||
23 | #include "cardgame.h" | 23 | #include "cardgame.h" |
24 | #include "canvasshapes.h" | 24 | #include "canvasshapes.h" |
25 | #include "canvascard.h" | 25 | #include "canvascard.h" |
26 | 26 | ||
27 | #include <qpe/resource.h> | 27 | #include <qpe/resource.h> |
28 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
29 | 29 | ||
30 | #include <qmainwindow.h> | 30 | #include <qmainwindow.h> |
31 | #include <qpe/qpemenubar.h> | 31 | #include <qmenubar.h> |
32 | #include <qpainter.h> | 32 | #include <qpainter.h> |
33 | 33 | ||
34 | #include <stdlib.h> | 34 | #include <stdlib.h> |
35 | #include <time.h> | 35 | #include <time.h> |
36 | 36 | ||
37 | 37 | ||
38 | class CanvasCardPile; | 38 | class CanvasCardPile; |
39 | 39 | ||
40 | 40 | ||
41 | class CanvasCardGame : public QCanvasView, public CardGame | 41 | class CanvasCardGame : public QCanvasView, public CardGame |
42 | { | 42 | { |
43 | public: | 43 | public: |
44 | CanvasCardGame(QCanvas &c, bool snap, QWidget *parent = 0, int numOfDecks = 1, const char *name = 0, WFlags f = 0) : | 44 | CanvasCardGame(QCanvas &c, bool snap, QWidget *parent = 0, int numOfDecks = 1, const char *name = 0, WFlags f = 0) : |
45 | QCanvasView( &c, parent, name, f ), | 45 | QCanvasView( &c, parent, name, f ), |
46 | CardGame(0,numOfDecks), | 46 | CardGame(0,numOfDecks), |
47 | moved(FALSE), | 47 | moved(FALSE), |
48 | moving(NULL), | 48 | moving(NULL), |
49 | alphaCardPile( NULL ), | 49 | alphaCardPile( NULL ), |
50 | cardXOff(0), cardYOff(0), | 50 | cardXOff(0), cardYOff(0), |
51 | snapOn(snap), | 51 | snapOn(snap), |
52 | numberToDraw(1) { } | 52 | numberToDraw(1) { } |
53 | 53 | ||
54 | virtual ~CanvasCardGame(); | 54 | virtual ~CanvasCardGame(); |
55 | 55 | ||
56 | virtual Card *newCard( eValue v, eSuit s, bool f ) { | 56 | virtual Card *newCard( eValue v, eSuit s, bool f ) { |
57 | return new CanvasCard( v, s, f, canvas() ); | 57 | return new CanvasCard( v, s, f, canvas() ); |
58 | } | 58 | } |
59 | 59 | ||
60 | virtual void readConfig( Config& cfg ) { Q_UNUSED( cfg ); } | 60 | virtual void readConfig( Config& cfg ) { Q_UNUSED( cfg ); } |
61 | virtual void writeConfig( Config& cfg ) { Q_UNUSED( cfg ); } | 61 | virtual void writeConfig( Config& cfg ) { Q_UNUSED( cfg ); } |
62 | 62 | ||
63 | virtual void gameWon(); | 63 | virtual void gameWon(); |
64 | virtual bool haveWeWon() { return FALSE; } | 64 | virtual bool haveWeWon() { return FALSE; } |
65 | 65 | ||
66 | virtual bool mousePressCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); return FALSE; } | 66 | virtual bool mousePressCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); return FALSE; } |
67 | virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } | 67 | virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } |
68 | 68 | ||
69 | void cancelMoving() { moving = NULL; } | 69 | void cancelMoving() { moving = NULL; } |
70 | void toggleSnap() { snapOn = (snapOn == TRUE) ? FALSE : TRUE; } | 70 | void toggleSnap() { snapOn = (snapOn == TRUE) ? FALSE : TRUE; } |
71 | void toggleCardsDrawn() { numberToDraw = (numberToDraw == 1) ? 3 : 1; } | 71 | void toggleCardsDrawn() { numberToDraw = (numberToDraw == 1) ? 3 : 1; } |
72 | int cardsDrawn() { return numberToDraw; } | 72 | int cardsDrawn() { return numberToDraw; } |
73 | void setNumberToDraw(int numToDraw) { this->numberToDraw = numToDraw; } | 73 | void setNumberToDraw(int numToDraw) { this->numberToDraw = numToDraw; } |
74 | 74 | ||
75 | void readPile( Config& cfg, CardPile *pile, QString name, int& highestZ ); | 75 | void readPile( Config& cfg, CardPile *pile, QString name, int& highestZ ); |
76 | 76 | ||
77 | protected: | 77 | protected: |
78 | void contentsMousePressEvent(QMouseEvent *e); | 78 | void contentsMousePressEvent(QMouseEvent *e); |
79 | void contentsMouseReleaseEvent(QMouseEvent *e); | 79 | void contentsMouseReleaseEvent(QMouseEvent *e); |
80 | void contentsMouseMoveEvent(QMouseEvent *e); | 80 | void contentsMouseMoveEvent(QMouseEvent *e); |
81 | virtualvoid checkUnusable() { } //added for freecell | 81 | virtualvoid checkUnusable() { } //added for freecell |
82 | 82 | ||
83 | protected: | 83 | protected: |
84 | // Mouse event state variables | 84 | // Mouse event state variables |
85 | bool moved; | 85 | bool moved; |
86 | CanvasCard *moving; | 86 | CanvasCard *moving; |
87 | CanvasCardPile *alphaCardPile; | 87 | CanvasCardPile *alphaCardPile; |
88 | int cardXOff, cardYOff; | 88 | int cardXOff, cardYOff; |
89 | 89 | ||
90 | private: | 90 | private: |
91 | bool snapOn; | 91 | bool snapOn; |
92 | int numberToDraw; | 92 | int numberToDraw; |
93 | }; | 93 | }; |
94 | 94 | ||
95 | 95 | ||
96 | #endif | 96 | #endif |
97 | 97 | ||
diff --git a/noncore/games/solitaire/canvascardwindow.cpp b/noncore/games/solitaire/canvascardwindow.cpp index 317a02d..dec5591 100644 --- a/noncore/games/solitaire/canvascardwindow.cpp +++ b/noncore/games/solitaire/canvascardwindow.cpp | |||
@@ -1,314 +1,314 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "canvascardwindow.h" | 21 | #include "canvascardwindow.h" |
22 | #include "patiencecardgame.h" | 22 | #include "patiencecardgame.h" |
23 | #include "freecellcardgame.h" | 23 | #include "freecellcardgame.h" |
24 | #include "chicanecardgame.h" | 24 | #include "chicanecardgame.h" |
25 | #include "harpcardgame.h" | 25 | #include "harpcardgame.h" |
26 | #include "teeclubcardgame.h" | 26 | #include "teeclubcardgame.h" |
27 | 27 | ||
28 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
29 | 29 | ||
30 | #include <qmainwindow.h> | 30 | #include <qmainwindow.h> |
31 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
32 | #include <qstyle.h> | 32 | #include <qstyle.h> |
33 | 33 | ||
34 | 34 | ||
35 | CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) : | 35 | CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) : |
36 | QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0), | 36 | QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0), |
37 | cardGame(NULL) | 37 | cardGame(NULL) |
38 | { | 38 | { |
39 | setIcon( Resource::loadPixmap( "cards" ) ); | 39 | setIcon( Resource::loadPixmap( "cards" ) ); |
40 | 40 | ||
41 | // Create Playing Area for Games | 41 | // Create Playing Area for Games |
42 | if ( QPixmap::defaultDepth() < 12 ) { | 42 | if ( QPixmap::defaultDepth() < 12 ) { |
43 | // canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B)); | 43 | // canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B)); |
44 | // canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50)); | 44 | // canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50)); |
45 | canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D)); | 45 | canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D)); |
46 | } else { | 46 | } else { |
47 | QPixmap bg; | 47 | QPixmap bg; |
48 | bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither ); | 48 | bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither ); |
49 | canvas.setBackgroundPixmap(bg); | 49 | canvas.setBackgroundPixmap(bg); |
50 | } | 50 | } |
51 | 51 | ||
52 | #if defined( QT_QWS_CASSIOPEIA ) | 52 | #if defined( QT_QWS_CASSIOPEIA ) |
53 | canvas.setAdvancePeriod(70); | 53 | canvas.setAdvancePeriod(70); |
54 | #else | 54 | #else |
55 | canvas.setAdvancePeriod(30); | 55 | canvas.setAdvancePeriod(30); |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | 58 | ||
59 | #ifdef _PATIENCE_USE_ACCELS_ | 59 | #ifdef _PATIENCE_USE_ACCELS_ |
60 | QPEMenuBar* menu = menuBar(); | 60 | QMenuBar* menu = menuBar(); |
61 | 61 | ||
62 | QPopupMenu* file = new QPopupMenu; | 62 | QPopupMenu* file = new QPopupMenu; |
63 | file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F); | 63 | file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F); |
64 | file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F); | 64 | file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F); |
65 | file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F); | 65 | file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F); |
66 | file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F); | 66 | file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F); |
67 | file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F); | 67 | file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F); |
68 | menu->insertItem(tr("&Game"), file); | 68 | menu->insertItem(tr("&Game"), file); |
69 | 69 | ||
70 | menu->insertSeparator(); | 70 | menu->insertSeparator(); |
71 | 71 | ||
72 | settings = new QPopupMenu; | 72 | settings = new QPopupMenu; |
73 | settings->insertItem(tr("&Change card backs"), this, SLOT(changeCardBacks()), Key_F2); | 73 | settings->insertItem(tr("&Change card backs"), this, SLOT(changeCardBacks()), Key_F2); |
74 | snap_id = settings->insertItem(tr("&Snap to position"), this, SLOT(snapToggle()), Key_F3); | 74 | snap_id = settings->insertItem(tr("&Snap to position"), this, SLOT(snapToggle()), Key_F3); |
75 | settings->setCheckable(TRUE); | 75 | settings->setCheckable(TRUE); |
76 | menu->insertItem(tr("&Settings"),settings); | 76 | menu->insertItem(tr("&Settings"),settings); |
77 | 77 | ||
78 | menu->insertSeparator(); | 78 | menu->insertSeparator(); |
79 | 79 | ||
80 | QPopupMenu* help = new QPopupMenu; | 80 | QPopupMenu* help = new QPopupMenu; |
81 | help->insertItem(tr("&About"), this, SLOT(help()), Key_F1); | 81 | help->insertItem(tr("&About"), this, SLOT(help()), Key_F1); |
82 | help->setItemChecked(dbf_id, TRUE); | 82 | help->setItemChecked(dbf_id, TRUE); |
83 | menu->insertItem(tr("&Help"),help); | 83 | menu->insertItem(tr("&Help"),help); |
84 | #else | 84 | #else |
85 | QMenuBar* menu = menuBar(); | 85 | QMenuBar* menu = menuBar(); |
86 | 86 | ||
87 | QPopupMenu* file = new QPopupMenu; | 87 | QPopupMenu* file = new QPopupMenu; |
88 | file->insertItem(tr("Patience"), this, SLOT(initPatience())); | 88 | file->insertItem(tr("Patience"), this, SLOT(initPatience())); |
89 | file->insertItem(tr("Freecell"), this, SLOT(initFreecell())); | 89 | file->insertItem(tr("Freecell"), this, SLOT(initFreecell())); |
90 | file->insertItem(tr("Chicane"), this, SLOT(initChicane())); | 90 | file->insertItem(tr("Chicane"), this, SLOT(initChicane())); |
91 | file->insertItem(tr("Harp"), this, SLOT(initHarp())); | 91 | file->insertItem(tr("Harp"), this, SLOT(initHarp())); |
92 | file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub())); | 92 | file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub())); |
93 | menu->insertItem(tr("Play"), file); | 93 | menu->insertItem(tr("Play"), file); |
94 | 94 | ||
95 | menu->insertSeparator(); | 95 | menu->insertSeparator(); |
96 | 96 | ||
97 | settings = new QPopupMenu; | 97 | settings = new QPopupMenu; |
98 | settings->setCheckable(TRUE); | 98 | settings->setCheckable(TRUE); |
99 | settings->insertItem(tr("Change card backs"), this, SLOT(changeCardBacks())); | 99 | settings->insertItem(tr("Change card backs"), this, SLOT(changeCardBacks())); |
100 | snap_id = settings->insertItem(tr("Snap to position"), this, SLOT(snapToggle())); | 100 | snap_id = settings->insertItem(tr("Snap to position"), this, SLOT(snapToggle())); |
101 | QString m; | 101 | QString m; |
102 | 102 | ||
103 | drawId = settings->insertItem(tr("Turn one card"), this, SLOT(drawnToggle())); | 103 | drawId = settings->insertItem(tr("Turn one card"), this, SLOT(drawnToggle())); |
104 | menu->insertItem(tr("Settings"),settings); | 104 | menu->insertItem(tr("Settings"),settings); |
105 | settings->setCheckable(TRUE); | 105 | settings->setCheckable(TRUE); |
106 | 106 | ||
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | menu->show(); | 109 | menu->show(); |
110 | 110 | ||
111 | Config cfg( "Patience" ); | 111 | Config cfg( "Patience" ); |
112 | cfg.setGroup( "GlobalSettings" ); | 112 | cfg.setGroup( "GlobalSettings" ); |
113 | snapOn = cfg.readBoolEntry( "SnapOn", TRUE); | 113 | snapOn = cfg.readBoolEntry( "SnapOn", TRUE); |
114 | settings->setItemChecked(snap_id, snapOn); | 114 | settings->setItemChecked(snap_id, snapOn); |
115 | 115 | ||
116 | gameType = cfg.readNumEntry( "GameType", -1 ); | 116 | gameType = cfg.readNumEntry( "GameType", -1 ); |
117 | drawThree = cfg.readBoolEntry( "DrawThree", FALSE); | 117 | drawThree = cfg.readBoolEntry( "DrawThree", FALSE); |
118 | if ( gameType == 0 ) { | 118 | if ( gameType == 0 ) { |
119 | cardGame = new PatienceCardGame( &canvas, snapOn, this ); | 119 | cardGame = new PatienceCardGame( &canvas, snapOn, this ); |
120 | cardGame->setNumberToDraw(drawThree ? 3 : 1); | 120 | cardGame->setNumberToDraw(drawThree ? 3 : 1); |
121 | 121 | ||
122 | setCaption(tr("Patience")); | 122 | setCaption(tr("Patience")); |
123 | setCentralWidget(cardGame); | 123 | setCentralWidget(cardGame); |
124 | cardGame->readConfig( cfg ); | 124 | cardGame->readConfig( cfg ); |
125 | setCardBacks(); | 125 | setCardBacks(); |
126 | } else if ( gameType == 1 ) { | 126 | } else if ( gameType == 1 ) { |
127 | cardGame = new FreecellCardGame( &canvas, snapOn, this ); | 127 | cardGame = new FreecellCardGame( &canvas, snapOn, this ); |
128 | setCaption(tr("Freecell")); | 128 | setCaption(tr("Freecell")); |
129 | setCentralWidget(cardGame); | 129 | setCentralWidget(cardGame); |
130 | //cardGame->newGame(); // Until we know how to handle reading freecell config | 130 | //cardGame->newGame(); // Until we know how to handle reading freecell config |
131 | cardGame->readConfig( cfg ); | 131 | cardGame->readConfig( cfg ); |
132 | setCardBacks(); | 132 | setCardBacks(); |
133 | } else if ( gameType == 2 ) { | 133 | } else if ( gameType == 2 ) { |
134 | cardGame = new ChicaneCardGame( &canvas, snapOn, this ); | 134 | cardGame = new ChicaneCardGame( &canvas, snapOn, this ); |
135 | cardGame->setNumberToDraw(1); | 135 | cardGame->setNumberToDraw(1); |
136 | setCaption(tr("Chicane")); | 136 | setCaption(tr("Chicane")); |
137 | setCentralWidget(cardGame); | 137 | setCentralWidget(cardGame); |
138 | cardGame->readConfig( cfg ); | 138 | cardGame->readConfig( cfg ); |
139 | setCardBacks(); | 139 | setCardBacks(); |
140 | } else if ( gameType == 3 ) { | 140 | } else if ( gameType == 3 ) { |
141 | cardGame = new HarpCardGame( &canvas, snapOn, this ); | 141 | cardGame = new HarpCardGame( &canvas, snapOn, this ); |
142 | cardGame->setNumberToDraw(1); | 142 | cardGame->setNumberToDraw(1); |
143 | setCaption(tr("Harp")); | 143 | setCaption(tr("Harp")); |
144 | setCentralWidget(cardGame); | 144 | setCentralWidget(cardGame); |
145 | cardGame->readConfig( cfg ); | 145 | cardGame->readConfig( cfg ); |
146 | setCardBacks(); | 146 | setCardBacks(); |
147 | } else if ( gameType == 4 ) { | 147 | } else if ( gameType == 4 ) { |
148 | cardGame = new TeeclubCardGame( &canvas, snapOn, this ); | 148 | cardGame = new TeeclubCardGame( &canvas, snapOn, this ); |
149 | cardGame->setNumberToDraw(1); | 149 | cardGame->setNumberToDraw(1); |
150 | setCaption(tr("Teeclub")); | 150 | setCaption(tr("Teeclub")); |
151 | setCentralWidget(cardGame); | 151 | setCentralWidget(cardGame); |
152 | cardGame->readConfig( cfg ); | 152 | cardGame->readConfig( cfg ); |
153 | setCardBacks(); | 153 | setCardBacks(); |
154 | } else { | 154 | } else { |
155 | // Probably there isn't a config file or it is broken | 155 | // Probably there isn't a config file or it is broken |
156 | // Start a new game | 156 | // Start a new game |
157 | initPatience(); | 157 | initPatience(); |
158 | } | 158 | } |
159 | 159 | ||
160 | updateDraw(); | 160 | updateDraw(); |
161 | } | 161 | } |
162 | 162 | ||
163 | 163 | ||
164 | CanvasCardWindow::~CanvasCardWindow() | 164 | CanvasCardWindow::~CanvasCardWindow() |
165 | { | 165 | { |
166 | if (cardGame) { | 166 | if (cardGame) { |
167 | Config cfg("Patience"); | 167 | Config cfg("Patience"); |
168 | cfg.setGroup( "GlobalSettings" ); | 168 | cfg.setGroup( "GlobalSettings" ); |
169 | cfg.writeEntry( "GameType", gameType ); | 169 | cfg.writeEntry( "GameType", gameType ); |
170 | cfg.writeEntry( "SnapOn", snapOn ); | 170 | cfg.writeEntry( "SnapOn", snapOn ); |
171 | cfg.writeEntry( "DrawThree", drawThree); | 171 | cfg.writeEntry( "DrawThree", drawThree); |
172 | cfg.write(); | 172 | cfg.write(); |
173 | cardGame->writeConfig( cfg ); | 173 | cardGame->writeConfig( cfg ); |
174 | delete cardGame; | 174 | delete cardGame; |
175 | } | 175 | } |
176 | } | 176 | } |
177 | 177 | ||
178 | 178 | ||
179 | void CanvasCardWindow::resizeEvent(QResizeEvent *) | 179 | void CanvasCardWindow::resizeEvent(QResizeEvent *) |
180 | { | 180 | { |
181 | QSize s = centralWidget()->size(); | 181 | QSize s = centralWidget()->size(); |
182 | int fw = style().defaultFrameWidth(); | 182 | int fw = style().defaultFrameWidth(); |
183 | canvas.resize( s.width() - fw - 2, s.height() - fw - 2); | 183 | canvas.resize( s.width() - fw - 2, s.height() - fw - 2); |
184 | } | 184 | } |
185 | 185 | ||
186 | 186 | ||
187 | void CanvasCardWindow::initPatience() | 187 | void CanvasCardWindow::initPatience() |
188 | { | 188 | { |
189 | // Create New Game | 189 | // Create New Game |
190 | if ( cardGame ) | 190 | if ( cardGame ) |
191 | delete cardGame; | 191 | delete cardGame; |
192 | cardGame = new PatienceCardGame( &canvas, snapOn, this ); | 192 | cardGame = new PatienceCardGame( &canvas, snapOn, this ); |
193 | cardGame->setNumberToDraw(drawThree ? 3 : 1); | 193 | cardGame->setNumberToDraw(drawThree ? 3 : 1); |
194 | gameType = 0; | 194 | gameType = 0; |
195 | setCaption(tr("Patience")); | 195 | setCaption(tr("Patience")); |
196 | setCentralWidget(cardGame); | 196 | setCentralWidget(cardGame); |
197 | cardGame->newGame(); | 197 | cardGame->newGame(); |
198 | setCardBacks(); | 198 | setCardBacks(); |
199 | updateDraw(); | 199 | updateDraw(); |
200 | } | 200 | } |
201 | 201 | ||
202 | 202 | ||
203 | void CanvasCardWindow::initFreecell() | 203 | void CanvasCardWindow::initFreecell() |
204 | { | 204 | { |
205 | // Create New Game | 205 | // Create New Game |
206 | if ( cardGame ) { | 206 | if ( cardGame ) { |
207 | delete cardGame; | 207 | delete cardGame; |
208 | } | 208 | } |
209 | cardGame = new FreecellCardGame( &canvas, snapOn, this ); | 209 | cardGame = new FreecellCardGame( &canvas, snapOn, this ); |
210 | gameType = 1; | 210 | gameType = 1; |
211 | setCaption(tr("Freecell")); | 211 | setCaption(tr("Freecell")); |
212 | setCentralWidget(cardGame); | 212 | setCentralWidget(cardGame); |
213 | cardGame->newGame(); | 213 | cardGame->newGame(); |
214 | setCardBacks(); | 214 | setCardBacks(); |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | void CanvasCardWindow::initChicane() | 218 | void CanvasCardWindow::initChicane() |
219 | { | 219 | { |
220 | // Create New Game | 220 | // Create New Game |
221 | if ( cardGame ) { | 221 | if ( cardGame ) { |
222 | delete cardGame; | 222 | delete cardGame; |
223 | } | 223 | } |
224 | cardGame = new ChicaneCardGame( &canvas, snapOn, this ); | 224 | cardGame = new ChicaneCardGame( &canvas, snapOn, this ); |
225 | cardGame->setNumberToDraw(1); | 225 | cardGame->setNumberToDraw(1); |
226 | gameType = 2; | 226 | gameType = 2; |
227 | setCaption(tr("Chicane")); | 227 | setCaption(tr("Chicane")); |
228 | setCentralWidget(cardGame); | 228 | setCentralWidget(cardGame); |
229 | cardGame->newGame(); | 229 | cardGame->newGame(); |
230 | setCardBacks(); | 230 | setCardBacks(); |
231 | } | 231 | } |
232 | 232 | ||
233 | void CanvasCardWindow::initHarp() | 233 | void CanvasCardWindow::initHarp() |
234 | { | 234 | { |
235 | // Create New Game | 235 | // Create New Game |
236 | if ( cardGame ) { | 236 | if ( cardGame ) { |
237 | delete cardGame; | 237 | delete cardGame; |
238 | } | 238 | } |
239 | cardGame = new HarpCardGame( &canvas, snapOn, this ); | 239 | cardGame = new HarpCardGame( &canvas, snapOn, this ); |
240 | cardGame->setNumberToDraw(1); | 240 | cardGame->setNumberToDraw(1); |
241 | gameType = 3; | 241 | gameType = 3; |
242 | setCaption(tr("Harp")); | 242 | setCaption(tr("Harp")); |
243 | setCentralWidget(cardGame); | 243 | setCentralWidget(cardGame); |
244 | cardGame->newGame(); | 244 | cardGame->newGame(); |
245 | setCardBacks(); | 245 | setCardBacks(); |
246 | } | 246 | } |
247 | 247 | ||
248 | 248 | ||
249 | void CanvasCardWindow::initTeeclub() | 249 | void CanvasCardWindow::initTeeclub() |
250 | { | 250 | { |
251 | // Create New Game | 251 | // Create New Game |
252 | if ( cardGame ) { | 252 | if ( cardGame ) { |
253 | delete cardGame; | 253 | delete cardGame; |
254 | } | 254 | } |
255 | cardGame = new TeeclubCardGame( &canvas, snapOn, this ); | 255 | cardGame = new TeeclubCardGame( &canvas, snapOn, this ); |
256 | cardGame->setNumberToDraw(1); | 256 | cardGame->setNumberToDraw(1); |
257 | gameType = 4; | 257 | gameType = 4; |
258 | setCaption(tr("Teeclub")); | 258 | setCaption(tr("Teeclub")); |
259 | setCentralWidget(cardGame); | 259 | setCentralWidget(cardGame); |
260 | cardGame->newGame(); | 260 | cardGame->newGame(); |
261 | setCardBacks(); | 261 | setCardBacks(); |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | void CanvasCardWindow::snapToggle() | 265 | void CanvasCardWindow::snapToggle() |
266 | { | 266 | { |
267 | snapOn = !snapOn; | 267 | snapOn = !snapOn; |
268 | settings->setItemChecked(snap_id, snapOn); | 268 | settings->setItemChecked(snap_id, snapOn); |
269 | cardGame->toggleSnap(); | 269 | cardGame->toggleSnap(); |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | void CanvasCardWindow::drawnToggle() | 273 | void CanvasCardWindow::drawnToggle() |
274 | { | 274 | { |
275 | drawThree=!drawThree; | 275 | drawThree=!drawThree; |
276 | Config cfg( "Patience" ); | 276 | Config cfg( "Patience" ); |
277 | cfg.setGroup( "GlobalSettings" ); | 277 | cfg.setGroup( "GlobalSettings" ); |
278 | cardGame->toggleCardsDrawn(); | 278 | cardGame->toggleCardsDrawn(); |
279 | updateDraw(); | 279 | updateDraw(); |
280 | cfg.writeEntry( "DrawThree", drawThree); | 280 | cfg.writeEntry( "DrawThree", drawThree); |
281 | cfg.write(); | 281 | cfg.write(); |
282 | } | 282 | } |
283 | 283 | ||
284 | void CanvasCardWindow::updateDraw() { | 284 | void CanvasCardWindow::updateDraw() { |
285 | if(cardGame->cardsDrawn() == 3){ | 285 | if(cardGame->cardsDrawn() == 3){ |
286 | settings->changeItem(drawId, tr("Turn one card")); | 286 | settings->changeItem(drawId, tr("Turn one card")); |
287 | } else { | 287 | } else { |
288 | settings->changeItem(drawId, tr("Turn three cards")); | 288 | settings->changeItem(drawId, tr("Turn three cards")); |
289 | } | 289 | } |
290 | } | 290 | } |
291 | 291 | ||
292 | 292 | ||
293 | void CanvasCardWindow::setCardBacks() | 293 | void CanvasCardWindow::setCardBacks() |
294 | { | 294 | { |
295 | QCanvasItemList l = canvas.allItems(); | 295 | QCanvasItemList l = canvas.allItems(); |
296 | 296 | ||
297 | for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { | 297 | for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { |
298 | if ( (*it)->rtti() == canvasCardId ) | 298 | if ( (*it)->rtti() == canvasCardId ) |
299 | ((CanvasCard *)(*it))->setCardBack( cardBack ); | 299 | ((CanvasCard *)(*it))->setCardBack( cardBack ); |
300 | } | 300 | } |
301 | } | 301 | } |
302 | 302 | ||
303 | 303 | ||
304 | void CanvasCardWindow::changeCardBacks() | 304 | void CanvasCardWindow::changeCardBacks() |
305 | { | 305 | { |
306 | cardBack++; | 306 | cardBack++; |
307 | 307 | ||
308 | if (cardBack == 5) | 308 | if (cardBack == 5) |
309 | cardBack = 0; | 309 | cardBack = 0; |
310 | 310 | ||
311 | setCardBacks(); | 311 | setCardBacks(); |
312 | } | 312 | } |
313 | 313 | ||
314 | 314 | ||
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index ac08e15..feae237 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -1,324 +1,324 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * DrawPad - a drawing program for Opie Environment * | 3 | * DrawPad - a drawing program for Opie Environment * |
4 | * * | 4 | * * |
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | 5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * |
6 | * * | 6 | * * |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | * * | 11 | * * |
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
13 | 13 | ||
14 | #include "drawpad.h" | 14 | #include "drawpad.h" |
15 | 15 | ||
16 | #include "drawpadcanvas.h" | 16 | #include "drawpadcanvas.h" |
17 | #include "ellipsetool.h" | 17 | #include "ellipsetool.h" |
18 | #include "erasetool.h" | 18 | #include "erasetool.h" |
19 | #include "exportdialog.h" | 19 | #include "exportdialog.h" |
20 | #include "filledellipsetool.h" | 20 | #include "filledellipsetool.h" |
21 | #include "filledrectangletool.h" | 21 | #include "filledrectangletool.h" |
22 | #include "filltool.h" | 22 | #include "filltool.h" |
23 | #include "importdialog.h" | 23 | #include "importdialog.h" |
24 | #include "linetool.h" | 24 | #include "linetool.h" |
25 | #include "newpagedialog.h" | 25 | #include "newpagedialog.h" |
26 | #include "page.h" | 26 | #include "page.h" |
27 | #include "pageinformationdialog.h" | 27 | #include "pageinformationdialog.h" |
28 | #include "pointtool.h" | 28 | #include "pointtool.h" |
29 | #include "rectangletool.h" | 29 | #include "rectangletool.h" |
30 | #include "texttool.h" | 30 | #include "texttool.h" |
31 | #include "thumbnailview.h" | 31 | #include "thumbnailview.h" |
32 | 32 | ||
33 | #include <opie/colordialog.h> | 33 | #include <opie/colordialog.h> |
34 | #include <opie/colorpopupmenu.h> | 34 | #include <opie/colorpopupmenu.h> |
35 | 35 | ||
36 | #include <qpe/applnk.h> | 36 | #include <qpe/applnk.h> |
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/qpemenubar.h> | 39 | #include <qpe/qpemenubar.h> |
40 | #include <qpe/qpetoolbar.h> | 40 | #include <qpe/qpetoolbar.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | 42 | ||
43 | #include <qaction.h> | 43 | #include <qaction.h> |
44 | #include <qfile.h> | 44 | #include <qfile.h> |
45 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
46 | #include <qpainter.h> | 46 | #include <qpainter.h> |
47 | #include <qspinbox.h> | 47 | #include <qspinbox.h> |
48 | #include <qtoolbutton.h> | 48 | #include <qtoolbutton.h> |
49 | #include <qtooltip.h> | 49 | #include <qtooltip.h> |
50 | #include <qwhatsthis.h> | 50 | #include <qwhatsthis.h> |
51 | 51 | ||
52 | DrawPad::DrawPad(QWidget* parent, const char* name, WFlags fl ) | 52 | DrawPad::DrawPad(QWidget* parent, const char* name, WFlags fl ) |
53 | : QMainWindow(parent, name, WStyle_ContextHelp) | 53 | : QMainWindow(parent, name, WStyle_ContextHelp) |
54 | { | 54 | { |
55 | // init members | 55 | // init members |
56 | 56 | ||
57 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); | 57 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); |
58 | 58 | ||
59 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); | 59 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); |
60 | 60 | ||
61 | setCentralWidget(m_pDrawPadCanvas); | 61 | setCentralWidget(m_pDrawPadCanvas); |
62 | 62 | ||
63 | // init menu | 63 | // init menu |
64 | 64 | ||
65 | setToolBarsMovable(false); | 65 | setToolBarsMovable(false); |
66 | 66 | ||
67 | QPEToolBar* menuToolBar = new QPEToolBar(this); | 67 | QPEToolBar* menuToolBar = new QPEToolBar(this); |
68 | QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); | 68 | QMenuBar* menuBar = new QMenuBar(menuToolBar); |
69 | 69 | ||
70 | QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); | 70 | QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); |
71 | 71 | ||
72 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); | 72 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); |
73 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); | 73 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); |
74 | deleteAllAction->addTo(toolsPopupMenu); | 74 | deleteAllAction->addTo(toolsPopupMenu); |
75 | 75 | ||
76 | toolsPopupMenu->insertSeparator(); | 76 | toolsPopupMenu->insertSeparator(); |
77 | 77 | ||
78 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); | 78 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); |
79 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); | 79 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); |
80 | importPageAction->addTo(toolsPopupMenu); | 80 | importPageAction->addTo(toolsPopupMenu); |
81 | 81 | ||
82 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); | 82 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); |
83 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); | 83 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); |
84 | exportPageAction->addTo(toolsPopupMenu); | 84 | exportPageAction->addTo(toolsPopupMenu); |
85 | 85 | ||
86 | toolsPopupMenu->insertSeparator(); | 86 | toolsPopupMenu->insertSeparator(); |
87 | 87 | ||
88 | QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); | 88 | QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); |
89 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); | 89 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); |
90 | thumbnailViewAction->addTo(toolsPopupMenu); | 90 | thumbnailViewAction->addTo(toolsPopupMenu); |
91 | 91 | ||
92 | QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); | 92 | QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); |
93 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); | 93 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); |
94 | pageInformationAction->addTo(toolsPopupMenu); | 94 | pageInformationAction->addTo(toolsPopupMenu); |
95 | 95 | ||
96 | toolsPopupMenu->insertSeparator(); | 96 | toolsPopupMenu->insertSeparator(); |
97 | 97 | ||
98 | m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); | 98 | m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); |
99 | m_pAntiAliasingAction->setToggleAction(true); | 99 | m_pAntiAliasingAction->setToggleAction(true); |
100 | m_pAntiAliasingAction->addTo(toolsPopupMenu); | 100 | m_pAntiAliasingAction->addTo(toolsPopupMenu); |
101 | 101 | ||
102 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); | 102 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); |
103 | 103 | ||
104 | // init page toolbar | 104 | // init page toolbar |
105 | 105 | ||
106 | QPEToolBar* pageToolBar = new QPEToolBar(this); | 106 | QPEToolBar* pageToolBar = new QPEToolBar(this); |
107 | 107 | ||
108 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this); | 108 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this); |
109 | connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); | 109 | connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); |
110 | newPageAction->addTo(pageToolBar); | 110 | newPageAction->addTo(pageToolBar); |
111 | newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) ); | 111 | newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) ); |
112 | 112 | ||
113 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this); | 113 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this); |
114 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); | 114 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); |
115 | clearPageAction->addTo(pageToolBar); | 115 | clearPageAction->addTo(pageToolBar); |
116 | clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) ); | 116 | clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) ); |
117 | 117 | ||
118 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this); | 118 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this); |
119 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); | 119 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); |
120 | deletePageAction->addTo(pageToolBar); | 120 | deletePageAction->addTo(pageToolBar); |
121 | deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) ); | 121 | deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) ); |
122 | 122 | ||
123 | QPEToolBar* emptyToolBar = new QPEToolBar(this); | 123 | QPEToolBar* emptyToolBar = new QPEToolBar(this); |
124 | emptyToolBar->setHorizontalStretchable(true); | 124 | emptyToolBar->setHorizontalStretchable(true); |
125 | 125 | ||
126 | // init navigation toolbar | 126 | // init navigation toolbar |
127 | 127 | ||
128 | QPEToolBar* navigationToolBar = new QPEToolBar(this); | 128 | QPEToolBar* navigationToolBar = new QPEToolBar(this); |
129 | 129 | ||
130 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this); | 130 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this); |
131 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); | 131 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); |
132 | m_pUndoAction->addTo(navigationToolBar); | 132 | m_pUndoAction->addTo(navigationToolBar); |
133 | m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) ); | 133 | m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) ); |
134 | 134 | ||
135 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this); | 135 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this); |
136 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); | 136 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); |
137 | m_pRedoAction->addTo(navigationToolBar); | 137 | m_pRedoAction->addTo(navigationToolBar); |
138 | m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) ); | 138 | m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) ); |
139 | 139 | ||
140 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); | 140 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); |
141 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); | 141 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); |
142 | m_pFirstPageAction->addTo(navigationToolBar); | 142 | m_pFirstPageAction->addTo(navigationToolBar); |
143 | m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) ); | 143 | m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) ); |
144 | 144 | ||
145 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); | 145 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); |
146 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); | 146 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); |
147 | m_pPreviousPageAction->addTo(navigationToolBar); | 147 | m_pPreviousPageAction->addTo(navigationToolBar); |
148 | m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) ); | 148 | m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) ); |
149 | 149 | ||
150 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); | 150 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); |
151 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); | 151 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); |
152 | m_pNextPageAction->addTo(navigationToolBar); | 152 | m_pNextPageAction->addTo(navigationToolBar); |
153 | m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) ); | 153 | m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) ); |
154 | 154 | ||
155 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); | 155 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); |
156 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); | 156 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); |
157 | m_pLastPageAction->addTo(navigationToolBar); | 157 | m_pLastPageAction->addTo(navigationToolBar); |
158 | m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) ); | 158 | m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) ); |
159 | 159 | ||
160 | // init draw mode toolbar | 160 | // init draw mode toolbar |
161 | 161 | ||
162 | QPEToolBar* drawModeToolBar = new QPEToolBar(this); | 162 | QPEToolBar* drawModeToolBar = new QPEToolBar(this); |
163 | 163 | ||
164 | m_pLineToolButton = new QToolButton(drawModeToolBar); | 164 | m_pLineToolButton = new QToolButton(drawModeToolBar); |
165 | m_pLineToolButton->setToggleButton(true); | 165 | m_pLineToolButton->setToggleButton(true); |
166 | QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) ); | 166 | QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) ); |
167 | 167 | ||
168 | 168 | ||
169 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); | 169 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); |
170 | 170 | ||
171 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this); | 171 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this); |
172 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); | 172 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); |
173 | m_pPointToolAction->addTo(linePopupMenu); | 173 | m_pPointToolAction->addTo(linePopupMenu); |
174 | 174 | ||
175 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this); | 175 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this); |
176 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); | 176 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); |
177 | m_pLineToolAction->addTo(linePopupMenu); | 177 | m_pLineToolAction->addTo(linePopupMenu); |
178 | 178 | ||
179 | m_pLineToolButton->setPopup(linePopupMenu); | 179 | m_pLineToolButton->setPopup(linePopupMenu); |
180 | m_pLineToolButton->setPopupDelay(0); | 180 | m_pLineToolButton->setPopupDelay(0); |
181 | 181 | ||
182 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); | 182 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); |
183 | m_pRectangleToolButton->setToggleButton(true); | 183 | m_pRectangleToolButton->setToggleButton(true); |
184 | QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) ); | 184 | QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) ); |
185 | 185 | ||
186 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); | 186 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); |
187 | 187 | ||
188 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 0, this); | 188 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 0, this); |
189 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); | 189 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); |
190 | m_pRectangleToolAction->addTo(rectanglePopupMenu); | 190 | m_pRectangleToolAction->addTo(rectanglePopupMenu); |
191 | 191 | ||
192 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 0, this); | 192 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 0, this); |
193 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); | 193 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); |
194 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); | 194 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); |
195 | 195 | ||
196 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); | 196 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); |
197 | m_pRectangleToolButton->setPopupDelay(0); | 197 | m_pRectangleToolButton->setPopupDelay(0); |
198 | 198 | ||
199 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); | 199 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); |
200 | m_pEllipseToolButton->setToggleButton(true); | 200 | m_pEllipseToolButton->setToggleButton(true); |
201 | QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) ); | 201 | QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) ); |
202 | 202 | ||
203 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); | 203 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); |
204 | 204 | ||
205 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 0, this); | 205 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 0, this); |
206 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); | 206 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); |
207 | m_pEllipseToolAction->addTo(ellipsePopupMenu); | 207 | m_pEllipseToolAction->addTo(ellipsePopupMenu); |
208 | 208 | ||
209 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this); | 209 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this); |
210 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); | 210 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); |
211 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); | 211 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); |
212 | 212 | ||
213 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); | 213 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); |
214 | m_pEllipseToolButton->setPopupDelay(0); | 214 | m_pEllipseToolButton->setPopupDelay(0); |
215 | 215 | ||
216 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this); | 216 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this); |
217 | m_pTextToolAction->setToggleAction(true); | 217 | m_pTextToolAction->setToggleAction(true); |
218 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); | 218 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); |
219 | m_pTextToolAction->addTo(drawModeToolBar); | 219 | m_pTextToolAction->addTo(drawModeToolBar); |
220 | m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) ); | 220 | m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) ); |
221 | 221 | ||
222 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this); | 222 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this); |
223 | m_pFillToolAction->setToggleAction(true); | 223 | m_pFillToolAction->setToggleAction(true); |
224 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); | 224 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); |
225 | m_pFillToolAction->addTo(drawModeToolBar); | 225 | m_pFillToolAction->addTo(drawModeToolBar); |
226 | m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) ); | 226 | m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) ); |
227 | 227 | ||
228 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this); | 228 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this); |
229 | m_pEraseToolAction->setToggleAction(true); | 229 | m_pEraseToolAction->setToggleAction(true); |
230 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); | 230 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); |
231 | m_pEraseToolAction->addTo(drawModeToolBar); | 231 | m_pEraseToolAction->addTo(drawModeToolBar); |
232 | m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) ); | 232 | m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) ); |
233 | 233 | ||
234 | m_pTool = 0; | 234 | m_pTool = 0; |
235 | setRectangleTool(); | 235 | setRectangleTool(); |
236 | setEllipseTool(); | 236 | setEllipseTool(); |
237 | setPointTool(); | 237 | setPointTool(); |
238 | 238 | ||
239 | emptyToolBar = new QPEToolBar(this); | 239 | emptyToolBar = new QPEToolBar(this); |
240 | emptyToolBar->setHorizontalStretchable(true); | 240 | emptyToolBar->setHorizontalStretchable(true); |
241 | emptyToolBar->addSeparator(); | 241 | emptyToolBar->addSeparator(); |
242 | 242 | ||
243 | // init draw parameters toolbar | 243 | // init draw parameters toolbar |
244 | 244 | ||
245 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); | 245 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); |
246 | 246 | ||
247 | m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); | 247 | m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); |
248 | connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); | 248 | connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); |
249 | 249 | ||
250 | QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); | 250 | QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); |
251 | m_pPenWidthSpinBox->setValue(1); | 251 | m_pPenWidthSpinBox->setValue(1); |
252 | m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus); | 252 | m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus); |
253 | QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) ); | 253 | QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) ); |
254 | 254 | ||
255 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); | 255 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); |
256 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor")); | 256 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor")); |
257 | QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) ); | 257 | QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) ); |
258 | 258 | ||
259 | OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, m_pPenColorToolButton); | 259 | OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, m_pPenColorToolButton); |
260 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); | 260 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); |
261 | 261 | ||
262 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); | 262 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); |
263 | m_pPenColorToolButton->setPopup(penColorPopupMenu); | 263 | m_pPenColorToolButton->setPopup(penColorPopupMenu); |
264 | m_pPenColorToolButton->setPopupDelay(0); | 264 | m_pPenColorToolButton->setPopupDelay(0); |
265 | 265 | ||
266 | changePenColor(Qt::black); | 266 | changePenColor(Qt::black); |
267 | 267 | ||
268 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); | 268 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); |
269 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor")); | 269 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor")); |
270 | QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) ); | 270 | QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) ); |
271 | 271 | ||
272 | OColorPopupMenu* brushColorPopupMenu = new OColorPopupMenu(Qt::white, m_pBrushColorToolButton); | 272 | OColorPopupMenu* brushColorPopupMenu = new OColorPopupMenu(Qt::white, m_pBrushColorToolButton); |
273 | connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); | 273 | connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); |
274 | 274 | ||
275 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); | 275 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); |
276 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); | 276 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); |
277 | m_pBrushColorToolButton->setPopupDelay(0); | 277 | m_pBrushColorToolButton->setPopupDelay(0); |
278 | 278 | ||
279 | changeBrushColor(Qt::white); | 279 | changeBrushColor(Qt::white); |
280 | 280 | ||
281 | finishStartup(); | 281 | finishStartup(); |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | void DrawPad::finishStartup() | 285 | void DrawPad::finishStartup() |
286 | { | 286 | { |
287 | // init pages | 287 | // init pages |
288 | 288 | ||
289 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 289 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
290 | 290 | ||
291 | if (file.open(IO_ReadOnly)) { | 291 | if (file.open(IO_ReadOnly)) { |
292 | m_pDrawPadCanvas->load(&file); | 292 | m_pDrawPadCanvas->load(&file); |
293 | file.close(); | 293 | file.close(); |
294 | } else { | 294 | } else { |
295 | m_pDrawPadCanvas->initialPage(); | 295 | m_pDrawPadCanvas->initialPage(); |
296 | } | 296 | } |
297 | 297 | ||
298 | loadConfig(); | 298 | loadConfig(); |
299 | 299 | ||
300 | } | 300 | } |
301 | 301 | ||
302 | DrawPad::~DrawPad() | 302 | DrawPad::~DrawPad() |
303 | { | 303 | { |
304 | saveConfig(); | 304 | saveConfig(); |
305 | 305 | ||
306 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 306 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
307 | 307 | ||
308 | if (file.open(IO_WriteOnly)) { | 308 | if (file.open(IO_WriteOnly)) { |
309 | m_pDrawPadCanvas->save(&file); | 309 | m_pDrawPadCanvas->save(&file); |
310 | file.close(); | 310 | file.close(); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
314 | bool DrawPad::antiAliasing() | 314 | bool DrawPad::antiAliasing() |
315 | { | 315 | { |
316 | return (m_pAntiAliasingAction->isOn()); | 316 | return (m_pAntiAliasingAction->isOn()); |
317 | } | 317 | } |
318 | 318 | ||
319 | void DrawPad::newPage() | 319 | void DrawPad::newPage() |
320 | { | 320 | { |
321 | QRect rect = m_pDrawPadCanvas->contentsRect(); | 321 | QRect rect = m_pDrawPadCanvas->contentsRect(); |
322 | 322 | ||
323 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); | 323 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); |
324 | 324 | ||
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp index 56bdecf..b7754f7 100644 --- a/noncore/multimedia/showimg/showimg.cpp +++ b/noncore/multimedia/showimg/showimg.cpp | |||
@@ -1,490 +1,490 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | // | 21 | // |
22 | // Full-screen and rotation options contributed by Robert Wittams <robert@wittams.com> | 22 | // Full-screen and rotation options contributed by Robert Wittams <robert@wittams.com> |
23 | // | 23 | // |
24 | 24 | ||
25 | #include "showimg.h" | 25 | #include "showimg.h" |
26 | #include "ImageFileSelector.h" | 26 | #include "ImageFileSelector.h" |
27 | #include "settingsdialog.h" | 27 | #include "settingsdialog.h" |
28 | 28 | ||
29 | 29 | ||
30 | #include <opie/ofiledialog.h> | 30 | #include <opie/ofiledialog.h> |
31 | 31 | ||
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/fileselector.h> | 35 | #include <qpe/fileselector.h> |
36 | #include <qpe/applnk.h> | 36 | #include <qpe/applnk.h> |
37 | #include <qfileinfo.h> | 37 | #include <qfileinfo.h> |
38 | #include <math.h> | 38 | #include <math.h> |
39 | #include <qpe/qpemenubar.h> | 39 | #include <qpe/qpemenubar.h> |
40 | #include <qwidgetstack.h> | 40 | #include <qwidgetstack.h> |
41 | #include <qpe/qpetoolbar.h> | 41 | #include <qpe/qpetoolbar.h> |
42 | #include <qaction.h> | 42 | #include <qaction.h> |
43 | #include <qfiledialog.h> | 43 | #include <qfiledialog.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qpopupmenu.h> | 45 | #include <qpopupmenu.h> |
46 | #include <qscrollview.h> | 46 | #include <qscrollview.h> |
47 | #include <qlabel.h> | 47 | #include <qlabel.h> |
48 | #include <qpainter.h> | 48 | #include <qpainter.h> |
49 | #include <qkeycode.h> | 49 | #include <qkeycode.h> |
50 | #include <qapplication.h> | 50 | #include <qapplication.h> |
51 | #include <qclipboard.h> | 51 | #include <qclipboard.h> |
52 | #include <qtimer.h> | 52 | #include <qtimer.h> |
53 | #include <qspinbox.h> | 53 | #include <qspinbox.h> |
54 | 54 | ||
55 | 55 | ||
56 | 56 | ||
57 | ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) | 57 | ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) |
58 | : QDialog(parent,0,true) | 58 | : QDialog(parent,0,true) |
59 | { | 59 | { |
60 | setCaption(caption); | 60 | setCaption(caption); |
61 | 61 | ||
62 | if ( parent ) { | 62 | if ( parent ) { |
63 | setPalette(parent->palette()); | 63 | setPalette(parent->palette()); |
64 | } | 64 | } |
65 | 65 | ||
66 | b=brightness; | 66 | b=brightness; |
67 | img=image; | 67 | img=image; |
68 | 68 | ||
69 | setMinimumSize(140,80); | 69 | setMinimumSize(140,80); |
70 | 70 | ||
71 | QGridLayout *gl= new QGridLayout(this,2,2,4,4); | 71 | QGridLayout *gl= new QGridLayout(this,2,2,4,4); |
72 | 72 | ||
73 | pixmap =new ImageWidget(this);; | 73 | pixmap =new ImageWidget(this);; |
74 | QPixmap pm; | 74 | QPixmap pm; |
75 | pm.convertFromImage(img); | 75 | pm.convertFromImage(img); |
76 | pixmap->setPixmap(pm); | 76 | pixmap->setPixmap(pm); |
77 | pixmap->setMinimumSize(pm.width(),pm.height()); | 77 | pixmap->setMinimumSize(pm.width(),pm.height()); |
78 | gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); | 78 | gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); |
79 | QLabel *l=new QLabel(tr("Brightness")+":",this); | 79 | QLabel *l=new QLabel(tr("Brightness")+":",this); |
80 | gl->addWidget(l,1,0,AlignLeft); | 80 | gl->addWidget(l,1,0,AlignLeft); |
81 | spb=new QSpinBox(-100,100,2,this); | 81 | spb=new QSpinBox(-100,100,2,this); |
82 | gl->addWidget(spb,1,1,AlignRight); | 82 | gl->addWidget(spb,1,1,AlignRight); |
83 | 83 | ||
84 | spb->setValue(0); | 84 | spb->setValue(0); |
85 | 85 | ||
86 | connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int))); | 86 | connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int))); |
87 | 87 | ||
88 | } | 88 | } |
89 | 89 | ||
90 | void ControlsDialog::bValueChanged(int value) | 90 | void ControlsDialog::bValueChanged(int value) |
91 | { | 91 | { |
92 | QImage nImage=img; | 92 | QImage nImage=img; |
93 | nImage.detach(); | 93 | nImage.detach(); |
94 | ImageViewer::intensity(nImage, (float)value/100); | 94 | ImageViewer::intensity(nImage, (float)value/100); |
95 | QPixmap pm; | 95 | QPixmap pm; |
96 | pm.convertFromImage(nImage); | 96 | pm.convertFromImage(nImage); |
97 | pixmap->setPixmap(pm); | 97 | pixmap->setPixmap(pm); |
98 | pixmap->repaint(false); | 98 | pixmap->repaint(false); |
99 | 99 | ||
100 | 100 | ||
101 | } | 101 | } |
102 | 102 | ||
103 | void ControlsDialog::accept() | 103 | void ControlsDialog::accept() |
104 | { | 104 | { |
105 | *b=spb->value(); | 105 | *b=spb->value(); |
106 | done(1); | 106 | done(1); |
107 | } | 107 | } |
108 | 108 | ||
109 | //=========================================================================== | 109 | //=========================================================================== |
110 | 110 | ||
111 | InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent) | 111 | InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent) |
112 | : QDialog(parent,0,true) | 112 | : QDialog(parent,0,true) |
113 | { | 113 | { |
114 | setCaption(caption); | 114 | setCaption(caption); |
115 | 115 | ||
116 | if ( parent ) | 116 | if ( parent ) |
117 | { | 117 | { |
118 | setPalette(parent->palette()); | 118 | setPalette(parent->palette()); |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | 122 | ||
123 | QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") }; | 123 | QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") }; |
124 | 124 | ||
125 | setMinimumSize(180,80); | 125 | setMinimumSize(180,80); |
126 | int num=ImageViewer::LAST+1; | 126 | int num=ImageViewer::LAST+1; |
127 | if ( text[ImageViewer::ALPHA].isEmpty() ) | 127 | if ( text[ImageViewer::ALPHA].isEmpty() ) |
128 | num--; | 128 | num--; |
129 | QGridLayout *gl= new QGridLayout(this,num,2,4,2); | 129 | QGridLayout *gl= new QGridLayout(this,num,2,4,2); |
130 | QLabel *l; | 130 | QLabel *l; |
131 | int count=0; | 131 | int count=0; |
132 | for ( int i=0;i<num;i++ ) | 132 | for ( int i=0;i<num;i++ ) |
133 | { | 133 | { |
134 | if ( i==1 ) | 134 | if ( i==1 ) |
135 | { | 135 | { |
136 | QFrame *frm=new QFrame(this); | 136 | QFrame *frm=new QFrame(this); |
137 | frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); | 137 | frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); |
138 | gl->addMultiCellWidget(frm,i,i,0,1); | 138 | gl->addMultiCellWidget(frm,i,i,0,1); |
139 | } | 139 | } |
140 | else | 140 | else |
141 | { | 141 | { |
142 | l=new QLabel( tr( labels[count] )+":",this); | 142 | l=new QLabel( tr( labels[count] )+":",this); |
143 | gl->addWidget(l,i,0,AlignLeft); | 143 | gl->addWidget(l,i,0,AlignLeft); |
144 | l=new QLabel(text[count],this); | 144 | l=new QLabel(text[count],this); |
145 | gl->addWidget(l,i,1,AlignRight); | 145 | gl->addWidget(l,i,1,AlignRight); |
146 | count++; | 146 | count++; |
147 | } | 147 | } |
148 | 148 | ||
149 | } | 149 | } |
150 | 150 | ||
151 | } | 151 | } |
152 | 152 | ||
153 | void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) | 153 | void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) |
154 | { | 154 | { |
155 | InfoDialog *dlg=new InfoDialog(caption,text,parent); | 155 | InfoDialog *dlg=new InfoDialog(caption,text,parent); |
156 | dlg->exec(); | 156 | dlg->exec(); |
157 | delete dlg; | 157 | delete dlg; |
158 | } | 158 | } |
159 | 159 | ||
160 | //=========================================================================== | 160 | //=========================================================================== |
161 | 161 | ||
162 | 162 | ||
163 | ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) | 163 | ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) |
164 | { | 164 | { |
165 | vb = new QVBoxLayout( this ); | 165 | vb = new QVBoxLayout( this ); |
166 | 166 | ||
167 | image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); | 167 | image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); |
168 | pic=new ImageWidget(image); | 168 | pic=new ImageWidget(image); |
169 | image->addChild(pic); | 169 | image->addChild(pic); |
170 | 170 | ||
171 | connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); | 171 | connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); |
172 | 172 | ||
173 | vb->addWidget( image ); | 173 | vb->addWidget( image ); |
174 | 174 | ||
175 | } | 175 | } |
176 | 176 | ||
177 | void ImagePane::setPixmap( const QPixmap &pm ) | 177 | void ImagePane::setPixmap( const QPixmap &pm ) |
178 | { | 178 | { |
179 | pic->setPixmap( pm ); | 179 | pic->setPixmap( pm ); |
180 | pic->resize(pm.width(),pm.height()); | 180 | pic->resize(pm.width(),pm.height()); |
181 | image->updateScrollBars (); | 181 | image->updateScrollBars (); |
182 | pic->repaint(false); | 182 | pic->repaint(false); |
183 | } | 183 | } |
184 | 184 | ||
185 | void ImagePane::imageClicked() | 185 | void ImagePane::imageClicked() |
186 | { | 186 | { |
187 | emit clicked(); | 187 | emit clicked(); |
188 | } | 188 | } |
189 | //=========================================================================== | 189 | //=========================================================================== |
190 | /* | 190 | /* |
191 | Draws the portion of the scaled pixmap that needs to be updated | 191 | Draws the portion of the scaled pixmap that needs to be updated |
192 | */ | 192 | */ |
193 | 193 | ||
194 | void ImageWidget::paintEvent( QPaintEvent *e ) | 194 | void ImageWidget::paintEvent( QPaintEvent *e ) |
195 | { | 195 | { |
196 | QPainter painter(this); | 196 | QPainter painter(this); |
197 | 197 | ||
198 | painter.setClipRect(e->rect()); | 198 | painter.setClipRect(e->rect()); |
199 | painter.fillRect(0,0,width(),height(),QColor(0,0,0)); | 199 | painter.fillRect(0,0,width(),height(),QColor(0,0,0)); |
200 | 200 | ||
201 | if ( pixmap.size() != QSize( 0, 0 ) ) | 201 | if ( pixmap.size() != QSize( 0, 0 ) ) |
202 | { // is an image loaded? | 202 | { // is an image loaded? |
203 | painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); | 203 | painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); |
204 | } | 204 | } |
205 | } | 205 | } |
206 | 206 | ||
207 | void ImageWidget::mouseReleaseEvent(QMouseEvent *) | 207 | void ImageWidget::mouseReleaseEvent(QMouseEvent *) |
208 | { | 208 | { |
209 | emit clicked(); | 209 | emit clicked(); |
210 | } | 210 | } |
211 | 211 | ||
212 | //=========================================================================== | 212 | //=========================================================================== |
213 | 213 | ||
214 | ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) | 214 | ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) |
215 | : QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE ) | 215 | : QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE ) |
216 | { | 216 | { |
217 | setCaption( tr("Image Viewer") ); | 217 | setCaption( tr("Image Viewer") ); |
218 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); | 218 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); |
219 | 219 | ||
220 | 220 | ||
221 | Config cfg("Image Viewer"); | 221 | Config cfg("Image Viewer"); |
222 | cfg.setGroup("Image Viewer"); | 222 | cfg.setGroup("Image Viewer"); |
223 | 223 | ||
224 | showThumbView=cfg.readBoolEntry("ShowThumbnails",false); | 224 | showThumbView=cfg.readBoolEntry("ShowThumbnails",false); |
225 | isSized=cfg.readBoolEntry("SizeToScreen",true); | 225 | isSized=cfg.readBoolEntry("SizeToScreen",true); |
226 | 226 | ||
227 | isFullScreen = FALSE; | 227 | isFullScreen = FALSE; |
228 | 228 | ||
229 | setToolBarsMovable( FALSE ); | 229 | setToolBarsMovable( FALSE ); |
230 | 230 | ||
231 | toolBar = new QPEToolBar( this ); | 231 | toolBar = new QPEToolBar( this ); |
232 | toolBar->setHorizontalStretchable( TRUE ); | 232 | toolBar->setHorizontalStretchable( TRUE ); |
233 | 233 | ||
234 | menuBar = new QPEMenuBar( toolBar ); | 234 | menuBar = new QMenuBar( toolBar ); |
235 | 235 | ||
236 | current=menuBar; | 236 | current=menuBar; |
237 | 237 | ||
238 | 238 | ||
239 | 239 | ||
240 | fileMenuFile = new QPopupMenu(this); | 240 | fileMenuFile = new QPopupMenu(this); |
241 | //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); | 241 | //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); |
242 | fileMenuFile->insertItem(tr("Open"), | 242 | fileMenuFile->insertItem(tr("Open"), |
243 | this, SLOT(openFile()), 0); | 243 | this, SLOT(openFile()), 0); |
244 | 244 | ||
245 | viewMenuFile = new QPopupMenu( this ); | 245 | viewMenuFile = new QPopupMenu( this ); |
246 | //menubarFile->insertItem( tr("View"), viewMenu ); | 246 | //menubarFile->insertItem( tr("View"), viewMenu ); |
247 | viewMenuFile->insertItem( tr("Thumbnail View"), | 247 | viewMenuFile->insertItem( tr("Thumbnail View"), |
248 | this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); | 248 | this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); |
249 | 249 | ||
250 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); | 250 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); |
251 | 251 | ||
252 | 252 | ||
253 | 253 | ||
254 | 254 | ||
255 | optionsMenuFile = new QPopupMenu( this); | 255 | optionsMenuFile = new QPopupMenu( this); |
256 | //menubarFile->insertItem( tr("Options"),optionsMenu ); | 256 | //menubarFile->insertItem( tr("Options"),optionsMenu ); |
257 | slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), | 257 | slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), |
258 | QString::null, 0, this, 0 ); | 258 | QString::null, 0, this, 0 ); |
259 | slideAction->setToggleAction( TRUE ); | 259 | slideAction->setToggleAction( TRUE ); |
260 | connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); | 260 | connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); |
261 | slideAction->addTo( optionsMenuFile); | 261 | slideAction->addTo( optionsMenuFile); |
262 | // slideAction->addTo( toolBar ); | 262 | // slideAction->addTo( toolBar ); |
263 | 263 | ||
264 | 264 | ||
265 | // optionsMenuFile->insertItem( tr("Slideshow") ); | 265 | // optionsMenuFile->insertItem( tr("Slideshow") ); |
266 | optionsMenuFile->insertSeparator(); | 266 | optionsMenuFile->insertSeparator(); |
267 | optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); | 267 | optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); |
268 | // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); | 268 | // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); |
269 | 269 | ||
270 | QStrList fmt = QImage::outputFormats(); | 270 | QStrList fmt = QImage::outputFormats(); |
271 | 271 | ||
272 | 272 | ||
273 | fileMenuView = new QPopupMenu( this ); | 273 | fileMenuView = new QPopupMenu( this ); |
274 | //menubarView->insertItem( tr("File"),fileMenu ); | 274 | //menubarView->insertItem( tr("File"),fileMenu ); |
275 | fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); | 275 | fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); |
276 | fileMenuView->insertSeparator(); | 276 | fileMenuView->insertSeparator(); |
277 | 277 | ||
278 | viewMenuView = new QPopupMenu(this ); | 278 | viewMenuView = new QPopupMenu(this ); |
279 | viewMenuView->setCheckable ( true ); | 279 | viewMenuView->setCheckable ( true ); |
280 | 280 | ||
281 | //menubarView->insertItem( tr("View"),viewMenu ); | 281 | //menubarView->insertItem( tr("View"),viewMenu ); |
282 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); | 282 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); |
283 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); | 283 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); |
284 | 284 | ||
285 | stack = new QWidgetStack( this ); | 285 | stack = new QWidgetStack( this ); |
286 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 286 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
287 | setCentralWidget( stack ); | 287 | setCentralWidget( stack ); |
288 | 288 | ||
289 | 289 | ||
290 | imagePanel = new ImagePane( stack ); | 290 | imagePanel = new ImagePane( stack ); |
291 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); | 291 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); |
292 | 292 | ||
293 | 293 | ||
294 | ImageFileSelector::CURRENT_VIEW cv; | 294 | ImageFileSelector::CURRENT_VIEW cv; |
295 | if(showThumbView) | 295 | if(showThumbView) |
296 | cv=ImageFileSelector::THUMBNAIL; | 296 | cv=ImageFileSelector::THUMBNAIL; |
297 | else | 297 | else |
298 | cv=ImageFileSelector::DETAILED; | 298 | cv=ImageFileSelector::DETAILED; |
299 | 299 | ||
300 | qDebug("cv = %d",cv); | 300 | qDebug("cv = %d",cv); |
301 | 301 | ||
302 | fileSelector = new ImageFileSelector( cv,stack, "fs"); | 302 | fileSelector = new ImageFileSelector( cv,stack, "fs"); |
303 | 303 | ||
304 | //switchThumbView(); | 304 | //switchThumbView(); |
305 | 305 | ||
306 | 306 | ||
307 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); | 307 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); |
308 | //fileSelector->setNewVisible(FALSE); | 308 | //fileSelector->setNewVisible(FALSE); |
309 | //fileSelector->setCloseVisible(FALSE); | 309 | //fileSelector->setCloseVisible(FALSE); |
310 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); | 310 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); |
311 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), | 311 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), |
312 | this, SLOT( openFile( const DocLnk & ) ) ); | 312 | this, SLOT( openFile( const DocLnk & ) ) ); |
313 | 313 | ||
314 | imageList = fileSelector->fileList(); | 314 | imageList = fileSelector->fileList(); |
315 | slideAction->setEnabled( imageList.count() != 0); | 315 | slideAction->setEnabled( imageList.count() != 0); |
316 | 316 | ||
317 | iconToolBar = new QPEToolBar(this); | 317 | iconToolBar = new QPEToolBar(this); |
318 | 318 | ||
319 | QAction *a; | 319 | QAction *a; |
320 | 320 | ||
321 | a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 321 | a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
322 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); | 322 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); |
323 | a->addTo( fileMenuView); | 323 | a->addTo( fileMenuView); |
324 | a->addTo( iconToolBar ); | 324 | a->addTo( iconToolBar ); |
325 | 325 | ||
326 | 326 | ||
327 | a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); | 327 | a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); |
328 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); | 328 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); |
329 | a->addTo( iconToolBar ); | 329 | a->addTo( iconToolBar ); |
330 | a->addTo( viewMenuView ); | 330 | a->addTo( viewMenuView ); |
331 | 331 | ||
332 | a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); | 332 | a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); |
333 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); | 333 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); |
334 | a->addTo( iconToolBar ); | 334 | a->addTo( iconToolBar ); |
335 | a->addTo( viewMenuView ); | 335 | a->addTo( viewMenuView ); |
336 | 336 | ||
337 | 337 | ||
338 | a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); | 338 | a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); |
339 | connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); | 339 | connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); |
340 | //a->addTo( iconToolBar ); | 340 | //a->addTo( iconToolBar ); |
341 | a->addTo( viewMenuView ); | 341 | a->addTo( viewMenuView ); |
342 | 342 | ||
343 | 343 | ||
344 | 344 | ||
345 | viewMenuView->insertSeparator(); | 345 | viewMenuView->insertSeparator(); |
346 | viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); | 346 | viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); |
347 | viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); | 347 | viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); |
348 | viewMenuView->insertSeparator(); | 348 | viewMenuView->insertSeparator(); |
349 | 349 | ||
350 | 350 | ||
351 | sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); | 351 | sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); |
352 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); | 352 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); |
353 | sss->addTo( iconToolBar ); | 353 | sss->addTo( iconToolBar ); |
354 | sss->addTo( viewMenuView ); | 354 | sss->addTo( viewMenuView ); |
355 | 355 | ||
356 | sss->setOn(isSized); | 356 | sss->setOn(isSized); |
357 | viewMenuView->insertSeparator(); | 357 | viewMenuView->insertSeparator(); |
358 | 358 | ||
359 | 359 | ||
360 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), | 360 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), |
361 | QString::null, 0, this, 0 ); | 361 | QString::null, 0, this, 0 ); |
362 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); | 362 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); |
363 | a->addTo( iconToolBar ); | 363 | a->addTo( iconToolBar ); |
364 | a->addTo( viewMenuView); | 364 | a->addTo( viewMenuView); |
365 | 365 | ||
366 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), | 366 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), |
367 | QString::null, 0, this, 0 ); | 367 | QString::null, 0, this, 0 ); |
368 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); | 368 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); |
369 | a->addTo( iconToolBar ); | 369 | a->addTo( iconToolBar ); |
370 | a->addTo( viewMenuView); | 370 | a->addTo( viewMenuView); |
371 | 371 | ||
372 | 372 | ||
373 | Config config( "ImageViewer" ); | 373 | Config config( "ImageViewer" ); |
374 | config.setGroup( "SlideShow" ); | 374 | config.setGroup( "SlideShow" ); |
375 | slideDelay = config.readNumEntry( "Delay", 2); | 375 | slideDelay = config.readNumEntry( "Delay", 2); |
376 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); | 376 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); |
377 | slideReverse = config.readBoolEntry("Reverse", FALSE); | 377 | slideReverse = config.readBoolEntry("Reverse", FALSE); |
378 | 378 | ||
379 | config.setGroup("Default"); | 379 | config.setGroup("Default"); |
380 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); | 380 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); |
381 | fastLoad = config.readBoolEntry("FastLoad", TRUE); | 381 | fastLoad = config.readBoolEntry("FastLoad", TRUE); |
382 | slideTimer = new QTimer( this ); | 382 | slideTimer = new QTimer( this ); |
383 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); | 383 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); |
384 | 384 | ||
385 | switchToFileSelector(); | 385 | switchToFileSelector(); |
386 | 386 | ||
387 | setMouseTracking( TRUE ); | 387 | setMouseTracking( TRUE ); |
388 | 388 | ||
389 | 389 | ||
390 | } | 390 | } |
391 | 391 | ||
392 | ImageViewer::~ImageViewer() | 392 | ImageViewer::~ImageViewer() |
393 | { | 393 | { |
394 | Config cfg("Image Viewer"); | 394 | Config cfg("Image Viewer"); |
395 | cfg.setGroup("Image Viewer"); | 395 | cfg.setGroup("Image Viewer"); |
396 | 396 | ||
397 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); | 397 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); |
398 | cfg.writeEntry("SizeToScreen",(int)isSized); | 398 | cfg.writeEntry("SizeToScreen",(int)isSized); |
399 | 399 | ||
400 | cfg.setGroup( "SlideShow" ); | 400 | cfg.setGroup( "SlideShow" ); |
401 | cfg.writeEntry( "Delay", slideDelay); | 401 | cfg.writeEntry( "Delay", slideDelay); |
402 | cfg.writeEntry( "Repeat", slideRepeat ); | 402 | cfg.writeEntry( "Repeat", slideRepeat ); |
403 | cfg.writeEntry("Reverse", slideReverse); | 403 | cfg.writeEntry("Reverse", slideReverse); |
404 | 404 | ||
405 | cfg.setGroup("Default"); | 405 | cfg.setGroup("Default"); |
406 | cfg.writeEntry("Rotate", rotateOnLoad); | 406 | cfg.writeEntry("Rotate", rotateOnLoad); |
407 | cfg.writeEntry("FastLoad", fastLoad); | 407 | cfg.writeEntry("FastLoad", fastLoad); |
408 | 408 | ||
409 | delete imagePanel; // in case it is fullscreen | 409 | delete imagePanel; // in case it is fullscreen |
410 | } | 410 | } |
411 | 411 | ||
412 | void ImageViewer::help() { | 412 | void ImageViewer::help() { |
413 | 413 | ||
414 | } | 414 | } |
415 | 415 | ||
416 | 416 | ||
417 | void ImageViewer::settings() | 417 | void ImageViewer::settings() |
418 | { | 418 | { |
419 | SettingsDialog dlg( this, 0, TRUE ); | 419 | SettingsDialog dlg( this, 0, TRUE ); |
420 | dlg.setDelay( slideDelay ); | 420 | dlg.setDelay( slideDelay ); |
421 | dlg.setRepeat( slideRepeat ); | 421 | dlg.setRepeat( slideRepeat ); |
422 | dlg.setReverse( slideReverse ); | 422 | dlg.setReverse( slideReverse ); |
423 | dlg.setRotate(rotateOnLoad); | 423 | dlg.setRotate(rotateOnLoad); |
424 | dlg.setFastLoad(fastLoad); | 424 | dlg.setFastLoad(fastLoad); |
425 | 425 | ||
426 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { | 426 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { |
427 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); | 427 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); |
428 | slideDelay = dlg.delay(); | 428 | slideDelay = dlg.delay(); |
429 | slideRepeat = dlg.repeat(); | 429 | slideRepeat = dlg.repeat(); |
430 | slideReverse = dlg.reverse(); | 430 | slideReverse = dlg.reverse(); |
431 | rotateOnLoad = dlg.rotate(); | 431 | rotateOnLoad = dlg.rotate(); |
432 | fastLoad = dlg.fastLoad(); | 432 | fastLoad = dlg.fastLoad(); |
433 | 433 | ||
434 | Config config( "ImageViewer" ); | 434 | Config config( "ImageViewer" ); |
435 | config.setGroup( "SlideShow" ); | 435 | config.setGroup( "SlideShow" ); |
436 | config.writeEntry( "Delay", slideDelay ); | 436 | config.writeEntry( "Delay", slideDelay ); |
437 | config.writeEntry( "Repeat", slideRepeat ); | 437 | config.writeEntry( "Repeat", slideRepeat ); |
438 | config.writeEntry("Reverse", slideReverse); | 438 | config.writeEntry("Reverse", slideReverse); |
439 | 439 | ||
440 | config.setGroup("Default"); | 440 | config.setGroup("Default"); |
441 | config.writeEntry("Rotate", rotateOnLoad); | 441 | config.writeEntry("Rotate", rotateOnLoad); |
442 | config.writeEntry("FastLoad", fastLoad); | 442 | config.writeEntry("FastLoad", fastLoad); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | void ImageViewer::switchSizeToScreen() | 446 | void ImageViewer::switchSizeToScreen() |
447 | { | 447 | { |
448 | isSized=!isSized; | 448 | isSized=!isSized; |
449 | sss->setOn(isSized); | 449 | sss->setOn(isSized); |
450 | updateImage(); | 450 | updateImage(); |
451 | } | 451 | } |
452 | 452 | ||
453 | void ImageViewer::updateImage() | 453 | void ImageViewer::updateImage() |
454 | { | 454 | { |
455 | if ( isSized ) { | 455 | if ( isSized ) { |
456 | imagePanel->setPixmap(pmScaled); | 456 | imagePanel->setPixmap(pmScaled); |
457 | } else { | 457 | } else { |
458 | imagePanel->setPixmap(pm); | 458 | imagePanel->setPixmap(pm); |
459 | } | 459 | } |
460 | } | 460 | } |
461 | 461 | ||
462 | void ImageViewer::switchThumbView() | 462 | void ImageViewer::switchThumbView() |
463 | { | 463 | { |
464 | 464 | ||
465 | showThumbView=!showThumbView; | 465 | showThumbView=!showThumbView; |
466 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); | 466 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); |
467 | fileSelector->switchView(); | 467 | fileSelector->switchView(); |
468 | 468 | ||
469 | } | 469 | } |
470 | 470 | ||
471 | void ImageViewer::switchToFileSelector() | 471 | void ImageViewer::switchToFileSelector() |
472 | { | 472 | { |
473 | stack->raiseWidget(fileSelector); | 473 | stack->raiseWidget(fileSelector); |
474 | menuBar->clear(); | 474 | menuBar->clear(); |
475 | menuBar->insertItem( tr("File"), fileMenuFile ); | 475 | menuBar->insertItem( tr("File"), fileMenuFile ); |
476 | menuBar->insertItem( tr("View"), viewMenuFile ); | 476 | menuBar->insertItem( tr("View"), viewMenuFile ); |
477 | menuBar->insertItem( tr("Options"), optionsMenuFile ); | 477 | menuBar->insertItem( tr("Options"), optionsMenuFile ); |
478 | iconToolBar->hide(); | 478 | iconToolBar->hide(); |
479 | imagePanel->disable(); | 479 | imagePanel->disable(); |
480 | slideShow(false); | 480 | slideShow(false); |
481 | 481 | ||
482 | } | 482 | } |
483 | 483 | ||
484 | void ImageViewer::switchToImageView() | 484 | void ImageViewer::switchToImageView() |
485 | { | 485 | { |
486 | stack->raiseWidget(imagePanel); | 486 | stack->raiseWidget(imagePanel); |
487 | 487 | ||
488 | menuBar->clear(); | 488 | menuBar->clear(); |
489 | menuBar->insertItem( tr("File"), fileMenuView ); | 489 | menuBar->insertItem( tr("File"), fileMenuView ); |
490 | menuBar->insertItem( tr("View"), viewMenuView ); | 490 | menuBar->insertItem( tr("View"), viewMenuView ); |
diff --git a/noncore/multimedia/showimg/showimg.h b/noncore/multimedia/showimg/showimg.h index abbd976..da4c0b6 100644 --- a/noncore/multimedia/showimg/showimg.h +++ b/noncore/multimedia/showimg/showimg.h | |||
@@ -1,289 +1,289 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef SHOWIMG_H | 21 | #ifndef SHOWIMG_H |
22 | #define SHOWIMG_H | 22 | #define SHOWIMG_H |
23 | 23 | ||
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | #include <qimage.h> | 26 | #include <qimage.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qscrollview.h> | 29 | #include <qscrollview.h> |
30 | #include <qdialog.h> | 30 | #include <qdialog.h> |
31 | #include <qstringlist.h> | 31 | #include <qstringlist.h> |
32 | #include <qvaluelist.h> | 32 | #include <qvaluelist.h> |
33 | #include <qwmatrix.h> | 33 | #include <qwmatrix.h> |
34 | 34 | ||
35 | 35 | ||
36 | class QAction; | 36 | class QAction; |
37 | class QPEToolBar; | 37 | class QPEToolBar; |
38 | class QPEMenuBar; | 38 | class QMenuBar; |
39 | class QPopupMenu; | 39 | class QPopupMenu; |
40 | class QWidgetStack; | 40 | class QWidgetStack; |
41 | class FileSelector; | 41 | class FileSelector; |
42 | class DocLnk; | 42 | class DocLnk; |
43 | class QLabel; | 43 | class QLabel; |
44 | class QAction; | 44 | class QAction; |
45 | class QSpinBox; | 45 | class QSpinBox; |
46 | class ImageFileSelector; | 46 | class ImageFileSelector; |
47 | class QTimer; | 47 | class QTimer; |
48 | 48 | ||
49 | 49 | ||
50 | class ImageWidget : public QWidget | 50 | class ImageWidget : public QWidget |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | public: | 53 | public: |
54 | ImageWidget( QWidget *parent=0 ) | 54 | ImageWidget( QWidget *parent=0 ) |
55 | : QWidget( parent ) { | 55 | : QWidget( parent ) { |
56 | setBackgroundMode(NoBackground); | 56 | setBackgroundMode(NoBackground); |
57 | } | 57 | } |
58 | ~ImageWidget() { } | 58 | ~ImageWidget() { } |
59 | 59 | ||
60 | void setPixmap( const QPixmap &pm ) { | 60 | void setPixmap( const QPixmap &pm ) { |
61 | pixmap = pm; | 61 | pixmap = pm; |
62 | show(); | 62 | show(); |
63 | } | 63 | } |
64 | 64 | ||
65 | signals: | 65 | signals: |
66 | void clicked(); | 66 | void clicked(); |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | void paintEvent( QPaintEvent * ); | 69 | void paintEvent( QPaintEvent * ); |
70 | void mouseReleaseEvent(QMouseEvent* event); | 70 | void mouseReleaseEvent(QMouseEvent* event); |
71 | 71 | ||
72 | private: | 72 | private: |
73 | QPixmap pixmap; | 73 | QPixmap pixmap; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | class InfoDialog:public QDialog | 76 | class InfoDialog:public QDialog |
77 | { | 77 | { |
78 | Q_OBJECT | 78 | Q_OBJECT |
79 | 79 | ||
80 | public: | 80 | public: |
81 | 81 | ||
82 | static void displayInfo(const QString &caption, const QStringList text, QWidget *parent); | 82 | static void displayInfo(const QString &caption, const QStringList text, QWidget *parent); |
83 | 83 | ||
84 | private: | 84 | private: |
85 | 85 | ||
86 | InfoDialog(const QString &caption,const QStringList text, QWidget *parent); | 86 | InfoDialog(const QString &caption,const QStringList text, QWidget *parent); |
87 | 87 | ||
88 | }; | 88 | }; |
89 | 89 | ||
90 | class ControlsDialog:public QDialog | 90 | class ControlsDialog:public QDialog |
91 | { | 91 | { |
92 | Q_OBJECT | 92 | Q_OBJECT |
93 | 93 | ||
94 | public: | 94 | public: |
95 | ControlsDialog(const QString &caption,const QImage image,int *brightness, QWidget *parent); | 95 | ControlsDialog(const QString &caption,const QImage image,int *brightness, QWidget *parent); |
96 | 96 | ||
97 | 97 | ||
98 | private slots: | 98 | private slots: |
99 | 99 | ||
100 | void bValueChanged(int); | 100 | void bValueChanged(int); |
101 | void accept(); | 101 | void accept(); |
102 | 102 | ||
103 | 103 | ||
104 | private: | 104 | private: |
105 | ImageWidget *pixmap; | 105 | ImageWidget *pixmap; |
106 | QSpinBox *spb; | 106 | QSpinBox *spb; |
107 | QImage img; | 107 | QImage img; |
108 | int *b; | 108 | int *b; |
109 | }; | 109 | }; |
110 | 110 | ||
111 | 111 | ||
112 | class ImagePane : public QWidget | 112 | class ImagePane : public QWidget |
113 | { | 113 | { |
114 | Q_OBJECT | 114 | Q_OBJECT |
115 | public: | 115 | public: |
116 | ImagePane( QWidget *parent=0 ); | 116 | ImagePane( QWidget *parent=0 ); |
117 | ~ImagePane() { } | 117 | ~ImagePane() { } |
118 | 118 | ||
119 | //void showStatus(); | 119 | //void showStatus(); |
120 | //void hideStatus(); | 120 | //void hideStatus(); |
121 | //QLabel *statusLabel() | 121 | //QLabel *statusLabel() |
122 | //{ | 122 | //{ |
123 | // return status; | 123 | // return status; |
124 | //} | 124 | //} |
125 | void setPixmap( const QPixmap &pm ); | 125 | void setPixmap( const QPixmap &pm ); |
126 | 126 | ||
127 | 127 | ||
128 | int paneWidth() const { | 128 | int paneWidth() const { |
129 | return image->visibleWidth(); | 129 | return image->visibleWidth(); |
130 | } | 130 | } |
131 | 131 | ||
132 | int paneHeight() const { | 132 | int paneHeight() const { |
133 | return image->visibleHeight(); | 133 | return image->visibleHeight(); |
134 | } | 134 | } |
135 | 135 | ||
136 | void setPosition(int x, int y) { | 136 | void setPosition(int x, int y) { |
137 | image->setContentsPos (x,y ); | 137 | image->setContentsPos (x,y ); |
138 | } | 138 | } |
139 | 139 | ||
140 | void disable() { | 140 | void disable() { |
141 | pic->hide(); | 141 | pic->hide(); |
142 | } | 142 | } |
143 | 143 | ||
144 | signals: | 144 | signals: |
145 | void clicked(); | 145 | void clicked(); |
146 | 146 | ||
147 | private: | 147 | private: |
148 | QScrollView *image; | 148 | QScrollView *image; |
149 | ImageWidget *pic; | 149 | ImageWidget *pic; |
150 | QVBoxLayout *vb; | 150 | QVBoxLayout *vb; |
151 | 151 | ||
152 | private slots: | 152 | private slots: |
153 | void imageClicked(); | 153 | void imageClicked(); |
154 | }; | 154 | }; |
155 | 155 | ||
156 | 156 | ||
157 | class ImageViewer : public QMainWindow | 157 | class ImageViewer : public QMainWindow |
158 | { | 158 | { |
159 | Q_OBJECT | 159 | Q_OBJECT |
160 | public: | 160 | public: |
161 | static QString appName() { return QString::fromLatin1("showimg"); } | 161 | static QString appName() { return QString::fromLatin1("showimg"); } |
162 | ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 ); | 162 | ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 ); |
163 | ~ImageViewer(); | 163 | ~ImageViewer(); |
164 | 164 | ||
165 | void loadImage( const char *fileName ); | 165 | void loadImage( const char *fileName ); |
166 | void show(const QString& fileref); | 166 | void show(const QString& fileref); |
167 | void show(); | 167 | void show(); |
168 | 168 | ||
169 | 169 | ||
170 | enum INFO_STRINGS { | 170 | enum INFO_STRINGS { |
171 | PATH, | 171 | PATH, |
172 | FORMAT, | 172 | FORMAT, |
173 | FILE_SIZE, | 173 | FILE_SIZE, |
174 | SIZE, | 174 | SIZE, |
175 | COLORS, | 175 | COLORS, |
176 | ALPHA, | 176 | ALPHA, |
177 | LAST | 177 | LAST |
178 | }; | 178 | }; |
179 | 179 | ||
180 | enum RotateDirection { | 180 | enum RotateDirection { |
181 | Rotate90, Rotate180, Rotate270 | 181 | Rotate90, Rotate180, Rotate270 |
182 | }; | 182 | }; |
183 | 183 | ||
184 | 184 | ||
185 | static QImage rotate(QImage &img, RotateDirection r); | 185 | static QImage rotate(QImage &img, RotateDirection r); |
186 | static QImage& intensity(QImage &image, float percent); | 186 | static QImage& intensity(QImage &image, float percent); |
187 | static QImage& toGray(QImage &image, bool fast = false); | 187 | static QImage& toGray(QImage &image, bool fast = false); |
188 | bool showThumbView; // a flag to indicate if FileSelector should be initialized with thumbnail view | 188 | bool showThumbView; // a flag to indicate if FileSelector should be initialized with thumbnail view |
189 | 189 | ||
190 | protected: | 190 | protected: |
191 | void resizeEvent( QResizeEvent * ); | 191 | void resizeEvent( QResizeEvent * ); |
192 | void closeEvent( QCloseEvent * ); | 192 | void closeEvent( QCloseEvent * ); |
193 | 193 | ||
194 | private: | 194 | private: |
195 | int imageIndex(void); | 195 | int imageIndex(void); |
196 | 196 | ||
197 | void updateCaption( QString name ); | 197 | void updateCaption( QString name ); |
198 | bool loadSelected(); | 198 | bool loadSelected(); |
199 | void scale(); | 199 | void scale(); |
200 | bool reconvertImage(); | 200 | bool reconvertImage(); |
201 | int calcHeight(); | 201 | int calcHeight(); |
202 | void setImage(const QImage& newimage); | 202 | void setImage(const QImage& newimage); |
203 | void updateImageInfo(QString &filePath); | 203 | void updateImageInfo(QString &filePath); |
204 | void switchToFileSelector(); | 204 | void switchToFileSelector(); |
205 | void switchToImageView(); | 205 | void switchToImageView(); |
206 | 206 | ||
207 | void updateImage(); | 207 | void updateImage(); |
208 | 208 | ||
209 | private slots: | 209 | private slots: |
210 | 210 | ||
211 | void slideShow( bool on ); | 211 | void slideShow( bool on ); |
212 | void help(); | 212 | void help(); |
213 | void slideUpdate(); | 213 | void slideUpdate(); |
214 | bool nextImage(); | 214 | bool nextImage(); |
215 | bool prevImage(); | 215 | bool prevImage(); |
216 | void settings(); | 216 | void settings(); |
217 | 217 | ||
218 | void switchThumbView(); | 218 | void switchThumbView(); |
219 | void switchSizeToScreen(); | 219 | void switchSizeToScreen(); |
220 | void setDocument(const QString& fileref); | 220 | void setDocument(const QString& fileref); |
221 | void doDelayedLoad(); | 221 | void doDelayedLoad(); |
222 | void openFile( const DocLnk &file ); | 222 | void openFile( const DocLnk &file ); |
223 | void openFile(); | 223 | void openFile(); |
224 | void open(); | 224 | void open(); |
225 | void closeFileSelector(); | 225 | void closeFileSelector(); |
226 | void hFlip(); | 226 | void hFlip(); |
227 | void vFlip(); | 227 | void vFlip(); |
228 | void rot180(); | 228 | void rot180(); |
229 | void rot90(); | 229 | void rot90(); |
230 | void rot270(); | 230 | void rot270(); |
231 | void normalView(); | 231 | void normalView(); |
232 | void fullScreen(); | 232 | void fullScreen(); |
233 | void stopSlideShow(); | 233 | void stopSlideShow(); |
234 | void blackAndWhite(); | 234 | void blackAndWhite(); |
235 | void displayInfoDialog(); | 235 | void displayInfoDialog(); |
236 | void displayControlsDialog(); | 236 | void displayControlsDialog(); |
237 | private: | 237 | private: |
238 | QWMatrix matrix; | 238 | QWMatrix matrix; |
239 | bool rotated90; | 239 | bool rotated90; |
240 | enum MENU_ITEMS { | 240 | enum MENU_ITEMS { |
241 | SHOW_THUMBNAILS, | 241 | SHOW_THUMBNAILS, |
242 | SIZE_TO_SCREEN, | 242 | SIZE_TO_SCREEN, |
243 | BLACKANDWHITE | 243 | BLACKANDWHITE |
244 | }; | 244 | }; |
245 | 245 | ||
246 | QString filename; | 246 | QString filename; |
247 | QString delayLoad; | 247 | QString delayLoad; |
248 | QImage image; // the loaded image | 248 | QImage image; // the loaded image |
249 | QPixmap pm; // the converted pixmap | 249 | QPixmap pm; // the converted pixmap |
250 | QPixmap pmScaled; // the scaled pixmap | 250 | QPixmap pmScaled; // the scaled pixmap |
251 | QPEToolBar *toolBar; | 251 | QPEToolBar *toolBar; |
252 | QPEToolBar *iconToolBar; | 252 | QPEToolBar *iconToolBar; |
253 | QPEMenuBar *menuBar; | 253 | QMenuBar *menuBar; |
254 | QPEMenuBar *current; | 254 | QMenuBar *current; |
255 | 255 | ||
256 | 256 | ||
257 | QPopupMenu *fileMenuFile; | 257 | QPopupMenu *fileMenuFile; |
258 | QPopupMenu *viewMenuFile; | 258 | QPopupMenu *viewMenuFile; |
259 | QPopupMenu *optionsMenuFile; | 259 | QPopupMenu *optionsMenuFile; |
260 | QPopupMenu *fileMenuView; | 260 | QPopupMenu *fileMenuView; |
261 | QPopupMenu *viewMenuView; | 261 | QPopupMenu *viewMenuView; |
262 | 262 | ||
263 | QAction *sss; // scale to screen size | 263 | QAction *sss; // scale to screen size |
264 | 264 | ||
265 | QLabel *lab; | 265 | QLabel *lab; |
266 | ImagePane *imagePanel; | 266 | ImagePane *imagePanel; |
267 | QWidgetStack *stack; | 267 | QWidgetStack *stack; |
268 | //FileSelector *fileSelector; | 268 | //FileSelector *fileSelector; |
269 | ImageFileSelector *fileSelector; | 269 | ImageFileSelector *fileSelector; |
270 | bool isFullScreen; | 270 | bool isFullScreen; |
271 | bool isSized; // true if image is to be resized to fit the window size | 271 | bool isSized; // true if image is to be resized to fit the window size |
272 | bool bFromDocView; // a flag to indicate whether or not we were | 272 | bool bFromDocView; // a flag to indicate whether or not we were |
273 | // launched from the document view... | 273 | // launched from the document view... |
274 | 274 | ||
275 | int slideDelay; | 275 | int slideDelay; |
276 | bool slideRepeat; | 276 | bool slideRepeat; |
277 | bool slideReverse; // show slideshow in reverse order | 277 | bool slideReverse; // show slideshow in reverse order |
278 | bool rotateOnLoad; // rotate by 90 degrees on loading | 278 | bool rotateOnLoad; // rotate by 90 degrees on loading |
279 | bool fastLoad; | 279 | bool fastLoad; |
280 | QTimer *slideTimer; | 280 | QTimer *slideTimer; |
281 | QValueList<DocLnk> imageList; | 281 | QValueList<DocLnk> imageList; |
282 | QAction *slideAction; | 282 | QAction *slideAction; |
283 | 283 | ||
284 | 284 | ||
285 | QString imageInfo[LAST]; | 285 | QString imageInfo[LAST]; |
286 | }; | 286 | }; |
287 | 287 | ||
288 | 288 | ||
289 | #endif // SHOWIMG_H | 289 | #endif // SHOWIMG_H |
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index ee7d32f..48629bf 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -1,327 +1,327 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | opieftp.cpp | 2 | opieftp.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | //#define DEVELOPERS_VERSION | 12 | //#define DEVELOPERS_VERSION |
13 | 13 | ||
14 | #include "opieftp.h" | 14 | #include "opieftp.h" |
15 | 15 | ||
16 | extern "C" { | 16 | extern "C" { |
17 | #include "../ftplib/ftplib.h" | 17 | #include "../ftplib/ftplib.h" |
18 | } | 18 | } |
19 | 19 | ||
20 | #include "inputDialog.h" | 20 | #include "inputDialog.h" |
21 | 21 | ||
22 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qpe/mimetype.h> | 26 | #include <qpe/mimetype.h> |
27 | 27 | ||
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qtoolbutton.h> | 30 | #include <qtoolbutton.h> |
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qlistview.h> | 32 | #include <qlistview.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qprogressbar.h> | 34 | #include <qprogressbar.h> |
35 | #include <qspinbox.h> | 35 | #include <qspinbox.h> |
36 | #include <qtabwidget.h> | 36 | #include <qtabwidget.h> |
37 | #include <qlayout.h> | 37 | #include <qlayout.h> |
38 | #include <qmessagebox.h> | 38 | #include <qmessagebox.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qlistbox.h> | 40 | #include <qlistbox.h> |
41 | 41 | ||
42 | #include <unistd.h> | 42 | #include <unistd.h> |
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | 44 | ||
45 | 45 | ||
46 | QProgressBar *ProgressBar; | 46 | QProgressBar *ProgressBar; |
47 | static netbuf *conn=NULL; | 47 | static netbuf *conn=NULL; |
48 | 48 | ||
49 | static int log_progress(netbuf *, int xfered, void *) | 49 | static int log_progress(netbuf *, int xfered, void *) |
50 | { | 50 | { |
51 | // int fsz = *(int *)arg; | 51 | // int fsz = *(int *)arg; |
52 | // int pct = (xfered * 100) / fsz; | 52 | // int pct = (xfered * 100) / fsz; |
53 | // printf("%3d%%\r", pct); | 53 | // printf("%3d%%\r", pct); |
54 | // fflush(stdout); | 54 | // fflush(stdout); |
55 | ProgressBar->setProgress(xfered); | 55 | ProgressBar->setProgress(xfered); |
56 | qApp->processEvents(); | 56 | qApp->processEvents(); |
57 | return 1; | 57 | return 1; |
58 | } | 58 | } |
59 | 59 | ||
60 | OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl) | 60 | OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl) |
61 | : QMainWindow( parent, name, fl ) | 61 | : QMainWindow( parent, name, fl ) |
62 | { | 62 | { |
63 | setCaption( tr( "OpieFtp" ) ); | 63 | setCaption( tr( "OpieFtp" ) ); |
64 | fuckeduphack=FALSE; | 64 | fuckeduphack=FALSE; |
65 | QGridLayout *layout = new QGridLayout( this ); | 65 | QGridLayout *layout = new QGridLayout( this ); |
66 | layout->setSpacing( 2); | 66 | layout->setSpacing( 2); |
67 | layout->setMargin( 2); | 67 | layout->setMargin( 2); |
68 | 68 | ||
69 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 69 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
70 | 70 | ||
71 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 71 | QMenuBar *menuBar = new QMenuBar(this); |
72 | // QPEToolBar *menuBar = new QPEToolBar(this); | 72 | // QPEToolBar *menuBar = new QPEToolBar(this); |
73 | // menuBar->setHorizontalStretchable( TRUE ); | 73 | // menuBar->setHorizontalStretchable( TRUE ); |
74 | 74 | ||
75 | QWMatrix matrix; | 75 | QWMatrix matrix; |
76 | QPixmap pix(Resource::loadPixmap( "UnknownDocument" )); | 76 | QPixmap pix(Resource::loadPixmap( "UnknownDocument" )); |
77 | matrix.scale( .4, .4); | 77 | matrix.scale( .4, .4); |
78 | unknownXpm = pix.xForm(matrix); | 78 | unknownXpm = pix.xForm(matrix); |
79 | 79 | ||
80 | connectionMenu = new QPopupMenu( this ); | 80 | connectionMenu = new QPopupMenu( this ); |
81 | localMenu = new QPopupMenu( this ); | 81 | localMenu = new QPopupMenu( this ); |
82 | remoteMenu = new QPopupMenu( this ); | 82 | remoteMenu = new QPopupMenu( this ); |
83 | tabMenu = new QPopupMenu( this ); | 83 | tabMenu = new QPopupMenu( this ); |
84 | 84 | ||
85 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); | 85 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); |
86 | 86 | ||
87 | menuBar->insertItem( tr( "Connection" ), connectionMenu); | 87 | menuBar->insertItem( tr( "Connection" ), connectionMenu); |
88 | // menuBar->insertItem( tr( "Local" ), localMenu); | 88 | // menuBar->insertItem( tr( "Local" ), localMenu); |
89 | // menuBar->insertItem( tr( "Remote" ), remoteMenu); | 89 | // menuBar->insertItem( tr( "Remote" ), remoteMenu); |
90 | menuBar->insertItem( tr( "View" ), tabMenu); | 90 | menuBar->insertItem( tr( "View" ), tabMenu); |
91 | 91 | ||
92 | tabMenu->insertItem( tr( "Local" ), localMenu); | 92 | tabMenu->insertItem( tr( "Local" ), localMenu); |
93 | tabMenu->insertItem( tr( "Remote" ), remoteMenu); | 93 | tabMenu->insertItem( tr( "Remote" ), remoteMenu); |
94 | 94 | ||
95 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); | 95 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); |
96 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); | 96 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); |
97 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); | 97 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); |
98 | 98 | ||
99 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 99 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
100 | localMenu->insertSeparator(); | 100 | localMenu->insertSeparator(); |
101 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 101 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
102 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 102 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
103 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 103 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
104 | localMenu->insertSeparator(); | 104 | localMenu->insertSeparator(); |
105 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 105 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
106 | localMenu->setCheckable(TRUE); | 106 | localMenu->setCheckable(TRUE); |
107 | 107 | ||
108 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 108 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
109 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 109 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
110 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 110 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
111 | remoteMenu->insertSeparator(); | 111 | remoteMenu->insertSeparator(); |
112 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 112 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
113 | 113 | ||
114 | tabMenu->insertSeparator(); | 114 | tabMenu->insertSeparator(); |
115 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 115 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
116 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 116 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
117 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); | 117 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); |
118 | tabMenu->insertSeparator(); | 118 | tabMenu->insertSeparator(); |
119 | // tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 119 | // tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
120 | tabMenu->setCheckable(TRUE); | 120 | tabMenu->setCheckable(TRUE); |
121 | 121 | ||
122 | 122 | ||
123 | 123 | ||
124 | cdUpButton = new QToolButton( this,"cdUpButton"); | 124 | cdUpButton = new QToolButton( this,"cdUpButton"); |
125 | cdUpButton->setPixmap(Resource::loadPixmap("up")); | 125 | cdUpButton->setPixmap(Resource::loadPixmap("up")); |
126 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); | 126 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); |
127 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 127 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
128 | layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 ); | 128 | layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 ); |
129 | cdUpButton->hide(); | 129 | cdUpButton->hide(); |
130 | 130 | ||
131 | // docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 131 | // docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
132 | // docButton->setFixedSize( QSize( 20, 20 ) ); | 132 | // docButton->setFixedSize( QSize( 20, 20 ) ); |
133 | // connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 133 | // connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
134 | // docButton->setFlat(TRUE); | 134 | // docButton->setFlat(TRUE); |
135 | // layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); | 135 | // layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); |
136 | 136 | ||
137 | homeButton = new QToolButton(this,"homeButton"); | 137 | homeButton = new QToolButton(this,"homeButton"); |
138 | homeButton->setPixmap( Resource::loadPixmap("home")); | 138 | homeButton->setPixmap( Resource::loadPixmap("home")); |
139 | homeButton->setFixedSize( QSize( 20, 20 ) ); | 139 | homeButton->setFixedSize( QSize( 20, 20 ) ); |
140 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 140 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
141 | layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); | 141 | layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); |
142 | homeButton->hide(); | 142 | homeButton->hide(); |
143 | 143 | ||
144 | TabWidget = new QTabWidget( this, "TabWidget" ); | 144 | TabWidget = new QTabWidget( this, "TabWidget" ); |
145 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); | 145 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); |
146 | 146 | ||
147 | // TabWidget->setTabShape(QTabWidget::Triangular); | 147 | // TabWidget->setTabShape(QTabWidget::Triangular); |
148 | 148 | ||
149 | tab = new QWidget( TabWidget, "tab" ); | 149 | tab = new QWidget( TabWidget, "tab" ); |
150 | tabLayout = new QGridLayout( tab ); | 150 | tabLayout = new QGridLayout( tab ); |
151 | tabLayout->setSpacing( 2); | 151 | tabLayout->setSpacing( 2); |
152 | tabLayout->setMargin( 2); | 152 | tabLayout->setMargin( 2); |
153 | 153 | ||
154 | Local_View = new QListView( tab, "Local_View" ); | 154 | Local_View = new QListView( tab, "Local_View" ); |
155 | // Local_View->setResizePolicy( QListView::AutoOneFit ); | 155 | // Local_View->setResizePolicy( QListView::AutoOneFit ); |
156 | Local_View->addColumn( tr("File"),150); | 156 | Local_View->addColumn( tr("File"),150); |
157 | Local_View->addColumn( tr("Date"),-1); | 157 | Local_View->addColumn( tr("Date"),-1); |
158 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 158 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
159 | Local_View->addColumn( tr("Size"),-1); | 159 | Local_View->addColumn( tr("Size"),-1); |
160 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 160 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
161 | Local_View->setAllColumnsShowFocus(TRUE); | 161 | Local_View->setAllColumnsShowFocus(TRUE); |
162 | 162 | ||
163 | Local_View->setMultiSelection( TRUE); | 163 | Local_View->setMultiSelection( TRUE); |
164 | Local_View->setSelectionMode(QListView::Extended); | 164 | Local_View->setSelectionMode(QListView::Extended); |
165 | Local_View->setFocusPolicy(QWidget::ClickFocus); | 165 | Local_View->setFocusPolicy(QWidget::ClickFocus); |
166 | 166 | ||
167 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 167 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
168 | 168 | ||
169 | tabLayout->addWidget( Local_View, 0, 0 ); | 169 | tabLayout->addWidget( Local_View, 0, 0 ); |
170 | 170 | ||
171 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 171 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
172 | this,SLOT( localListClicked(QListViewItem *)) ); | 172 | this,SLOT( localListClicked(QListViewItem *)) ); |
173 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), | 173 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), |
174 | // this,SLOT( localListClicked(QListViewItem *)) ); | 174 | // this,SLOT( localListClicked(QListViewItem *)) ); |
175 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 175 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
176 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 176 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
177 | 177 | ||
178 | TabWidget->insertTab( tab, tr( "Local" ) ); | 178 | TabWidget->insertTab( tab, tr( "Local" ) ); |
179 | 179 | ||
180 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 180 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
181 | tabLayout_2 = new QGridLayout( tab_2 ); | 181 | tabLayout_2 = new QGridLayout( tab_2 ); |
182 | tabLayout_2->setSpacing( 2); | 182 | tabLayout_2->setSpacing( 2); |
183 | tabLayout_2->setMargin( 2); | 183 | tabLayout_2->setMargin( 2); |
184 | 184 | ||
185 | Remote_View = new QListView( tab_2, "Remote_View" ); | 185 | Remote_View = new QListView( tab_2, "Remote_View" ); |
186 | Remote_View->addColumn( tr("File"),150); | 186 | Remote_View->addColumn( tr("File"),150); |
187 | Remote_View->addColumn( tr("Date"),-1); | 187 | Remote_View->addColumn( tr("Date"),-1); |
188 | // Remote_View->setColumnAlignment(1,QListView::AlignRight); | 188 | // Remote_View->setColumnAlignment(1,QListView::AlignRight); |
189 | Remote_View->addColumn( tr("Size"),-1); | 189 | Remote_View->addColumn( tr("Size"),-1); |
190 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 190 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
191 | Remote_View->setColumnAlignment(3,QListView::AlignCenter); | 191 | Remote_View->setColumnAlignment(3,QListView::AlignCenter); |
192 | Remote_View->addColumn( tr("Dir"),-1); | 192 | Remote_View->addColumn( tr("Dir"),-1); |
193 | Remote_View->setColumnAlignment(4,QListView::AlignRight); | 193 | Remote_View->setColumnAlignment(4,QListView::AlignRight); |
194 | Remote_View->setAllColumnsShowFocus(TRUE); | 194 | Remote_View->setAllColumnsShowFocus(TRUE); |
195 | 195 | ||
196 | Remote_View->setMultiSelection( FALSE); | 196 | Remote_View->setMultiSelection( FALSE); |
197 | Remote_View->setSelectionMode(QListView::Extended); | 197 | Remote_View->setSelectionMode(QListView::Extended); |
198 | Remote_View->setFocusPolicy(QWidget::ClickFocus); | 198 | Remote_View->setFocusPolicy(QWidget::ClickFocus); |
199 | 199 | ||
200 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 200 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
201 | 201 | ||
202 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 202 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
203 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 203 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
204 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 204 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
205 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 205 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
206 | 206 | ||
207 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 207 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
208 | 208 | ||
209 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); | 209 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); |
210 | 210 | ||
211 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 211 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
212 | tabLayout_3 = new QGridLayout( tab_3 ); | 212 | tabLayout_3 = new QGridLayout( tab_3 ); |
213 | tabLayout_3->setSpacing( 2); | 213 | tabLayout_3->setSpacing( 2); |
214 | tabLayout_3->setMargin( 2); | 214 | tabLayout_3->setMargin( 2); |
215 | 215 | ||
216 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); | 216 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); |
217 | TextLabel1->setText( tr( "Username" ) ); | 217 | TextLabel1->setText( tr( "Username" ) ); |
218 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); | 218 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); |
219 | 219 | ||
220 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); | 220 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); |
221 | UsernameComboBox->setEditable(TRUE); | 221 | UsernameComboBox->setEditable(TRUE); |
222 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); | 222 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); |
223 | 223 | ||
224 | connect( UsernameComboBox,SIGNAL(textChanged(const QString &)),this, | 224 | connect( UsernameComboBox,SIGNAL(textChanged(const QString &)),this, |
225 | SLOT( UsernameComboBoxEdited(const QString & ) )); | 225 | SLOT( UsernameComboBoxEdited(const QString & ) )); |
226 | 226 | ||
227 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); | 227 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); |
228 | TextLabel2->setText( tr( "Password" ) ); | 228 | TextLabel2->setText( tr( "Password" ) ); |
229 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); | 229 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); |
230 | 230 | ||
231 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); | 231 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); |
232 | PasswordEdit->setEchoMode(QLineEdit::Password); | 232 | PasswordEdit->setEchoMode(QLineEdit::Password); |
233 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); | 233 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); |
234 | 234 | ||
235 | connect( PasswordEdit,SIGNAL(textChanged(const QString &)),this, | 235 | connect( PasswordEdit,SIGNAL(textChanged(const QString &)),this, |
236 | SLOT( PasswordEditEdited(const QString & ) )); | 236 | SLOT( PasswordEditEdited(const QString & ) )); |
237 | 237 | ||
238 | //PasswordEdit->setFixedWidth(85); | 238 | //PasswordEdit->setFixedWidth(85); |
239 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); | 239 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); |
240 | TextLabel3->setText( tr( "Remote server" ) ); | 240 | TextLabel3->setText( tr( "Remote server" ) ); |
241 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); | 241 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); |
242 | 242 | ||
243 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); | 243 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); |
244 | ServerComboBox->setEditable(TRUE); | 244 | ServerComboBox->setEditable(TRUE); |
245 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); | 245 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); |
246 | 246 | ||
247 | connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); | 247 | connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); |
248 | connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this, | 248 | connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this, |
249 | SLOT(serverComboEdited(const QString & ) )); | 249 | SLOT(serverComboEdited(const QString & ) )); |
250 | 250 | ||
251 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); | 251 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); |
252 | TextLabel5->setText( tr( "Remote path" ) ); | 252 | TextLabel5->setText( tr( "Remote path" ) ); |
253 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); | 253 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); |
254 | 254 | ||
255 | 255 | ||
256 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); | 256 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); |
257 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); | 257 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); |
258 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); | 258 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); |
259 | TextLabel4->setText( tr( "Port" ) ); | 259 | TextLabel4->setText( tr( "Port" ) ); |
260 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); | 260 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); |
261 | 261 | ||
262 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); | 262 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); |
263 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); | 263 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); |
264 | PortSpinBox->setMaxValue(32786); | 264 | PortSpinBox->setMaxValue(32786); |
265 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); | 265 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); |
266 | 266 | ||
267 | serverListView = new QListBox( tab_3, "ServerListView" ); | 267 | serverListView = new QListBox( tab_3, "ServerListView" ); |
268 | tabLayout_3->addMultiCellWidget( serverListView , 5, 5, 0, 5); | 268 | tabLayout_3->addMultiCellWidget( serverListView , 5, 5, 0, 5); |
269 | 269 | ||
270 | connect( serverListView, SIGNAL( highlighted( const QString &)), | 270 | connect( serverListView, SIGNAL( highlighted( const QString &)), |
271 | this,SLOT( serverListClicked( const QString &) ) ); | 271 | this,SLOT( serverListClicked( const QString &) ) ); |
272 | 272 | ||
273 | connectServerBtn = new QPushButton( tr("Connect"), tab_3 , "ConnectButton" ); | 273 | connectServerBtn = new QPushButton( tr("Connect"), tab_3 , "ConnectButton" ); |
274 | tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1); | 274 | tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1); |
275 | connectServerBtn->setToggleButton(TRUE); | 275 | connectServerBtn->setToggleButton(TRUE); |
276 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); | 276 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); |
277 | 277 | ||
278 | newServerButton= new QPushButton( tr("Add"), tab_3 , "NewServerButton" ); | 278 | newServerButton= new QPushButton( tr("Add"), tab_3 , "NewServerButton" ); |
279 | tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2); | 279 | tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2); |
280 | connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() )); | 280 | connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() )); |
281 | 281 | ||
282 | QPushButton *deleteServerBtn; | 282 | QPushButton *deleteServerBtn; |
283 | deleteServerBtn = new QPushButton( tr("Delete"), tab_3 , "OpenButton" ); | 283 | deleteServerBtn = new QPushButton( tr("Delete"), tab_3 , "OpenButton" ); |
284 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3); | 284 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3); |
285 | 285 | ||
286 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); | 286 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); |
287 | 287 | ||
288 | 288 | ||
289 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 289 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
290 | tabLayout_3->addItem( spacer, 5, 0 ); | 290 | tabLayout_3->addItem( spacer, 5, 0 ); |
291 | 291 | ||
292 | TabWidget->insertTab( tab_3, tr( "Config" ) ); | 292 | TabWidget->insertTab( tab_3, tr( "Config" ) ); |
293 | 293 | ||
294 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 294 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
295 | this,SLOT(tabChanged(QWidget*))); | 295 | this,SLOT(tabChanged(QWidget*))); |
296 | 296 | ||
297 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 297 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
298 | currentDir.setPath( QDir::currentDirPath()); | 298 | currentDir.setPath( QDir::currentDirPath()); |
299 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 299 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
300 | 300 | ||
301 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 301 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
302 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); | 302 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); |
303 | currentPathCombo ->setFixedWidth(220); | 303 | currentPathCombo ->setFixedWidth(220); |
304 | currentPathCombo->setEditable(TRUE); | 304 | currentPathCombo->setEditable(TRUE); |
305 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 305 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
306 | 306 | ||
307 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 307 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
308 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 308 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
309 | 309 | ||
310 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 310 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
311 | this,SLOT(currentPathComboChanged())); | 311 | this,SLOT(currentPathComboChanged())); |
312 | 312 | ||
313 | ProgressBar = new QProgressBar( this, "ProgressBar" ); | 313 | ProgressBar = new QProgressBar( this, "ProgressBar" ); |
314 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); | 314 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); |
315 | ProgressBar->setMaximumHeight(10); | 315 | ProgressBar->setMaximumHeight(10); |
316 | filterStr="*"; | 316 | filterStr="*"; |
317 | b=FALSE; | 317 | b=FALSE; |
318 | populateLocalView(); | 318 | populateLocalView(); |
319 | readConfig(); | 319 | readConfig(); |
320 | 320 | ||
321 | // ServerComboBox->setCurrentItem(currentServerConfig); | 321 | // ServerComboBox->setCurrentItem(currentServerConfig); |
322 | 322 | ||
323 | TabWidget->setCurrentPage(2); | 323 | TabWidget->setCurrentPage(2); |
324 | } | 324 | } |
325 | 325 | ||
326 | OpieFtp::~OpieFtp() | 326 | OpieFtp::~OpieFtp() |
327 | { | 327 | { |
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h index 7bd615a..f58778a 100644 --- a/noncore/net/opieftp/opieftp.h +++ b/noncore/net/opieftp/opieftp.h | |||
@@ -1,143 +1,143 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | opieftp.h | 2 | opieftp.h |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #ifndef OPIEFTP_H | 12 | #ifndef OPIEFTP_H |
13 | #define OPIEFTP_H | 13 | #define OPIEFTP_H |
14 | 14 | ||
15 | #include <qvariant.h> | 15 | #include <qvariant.h> |
16 | #include <qdialog.h> | 16 | #include <qdialog.h> |
17 | #include <qmainwindow.h> | 17 | #include <qmainwindow.h> |
18 | #include <qdir.h> | 18 | #include <qdir.h> |
19 | #include <qstring.h> | 19 | #include <qstring.h> |
20 | #include <qpoint.h> | 20 | #include <qpoint.h> |
21 | #include <qpixmap.h> | 21 | #include <qpixmap.h> |
22 | 22 | ||
23 | class QVBoxLayout; | 23 | class QVBoxLayout; |
24 | class QHBoxLayout; | 24 | class QHBoxLayout; |
25 | class QGridLayout; | 25 | class QGridLayout; |
26 | class QComboBox; | 26 | class QComboBox; |
27 | class QListView; | 27 | class QListView; |
28 | class QListViewItem; | 28 | class QListViewItem; |
29 | class QLabel; | 29 | class QLabel; |
30 | class QProgressBar; | 30 | class QProgressBar; |
31 | class QSpinBox; | 31 | class QSpinBox; |
32 | class QTabWidget; | 32 | class QTabWidget; |
33 | class QWidget; | 33 | class QWidget; |
34 | class QPEToolBar; | 34 | class QPEToolBar; |
35 | class QPEMenuBar; | 35 | class QMenuBar; |
36 | class QPopupMenu; | 36 | class QPopupMenu; |
37 | class QFile; | 37 | class QFile; |
38 | class QLineEdit; | 38 | class QLineEdit; |
39 | class QPushButton; | 39 | class QPushButton; |
40 | class QToolButton; | 40 | class QToolButton; |
41 | class QStringList; | 41 | class QStringList; |
42 | class QListBox; | 42 | class QListBox; |
43 | class QTimer; | 43 | class QTimer; |
44 | 44 | ||
45 | class OpieFtp : public QMainWindow | 45 | class OpieFtp : public QMainWindow |
46 | { | 46 | { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | 48 | ||
49 | public: | 49 | public: |
50 | OpieFtp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 50 | OpieFtp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
51 | ~OpieFtp(); | 51 | ~OpieFtp(); |
52 | 52 | ||
53 | static QString appName() { return QString::fromLatin1("opieftp"); } | 53 | static QString appName() { return QString::fromLatin1("opieftp"); } |
54 | QTabWidget *TabWidget; | 54 | QTabWidget *TabWidget; |
55 | QWidget *tab, *tab_2, *tab_3; | 55 | QWidget *tab, *tab_2, *tab_3; |
56 | QListView *Local_View, *Remote_View; | 56 | QListView *Local_View, *Remote_View; |
57 | QListBox *serverListView; | 57 | QListBox *serverListView; |
58 | 58 | ||
59 | QComboBox *UsernameComboBox, *ServerComboBox, *currentPathCombo; | 59 | QComboBox *UsernameComboBox, *ServerComboBox, *currentPathCombo; |
60 | QLineEdit *PasswordEdit, *remotePath; | 60 | QLineEdit *PasswordEdit, *remotePath; |
61 | QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;; | 61 | QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;; |
62 | QSpinBox* PortSpinBox; | 62 | QSpinBox* PortSpinBox; |
63 | QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu, *aboutMenu; | 63 | QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu, *aboutMenu; |
64 | QDir currentDir; | 64 | QDir currentDir; |
65 | QString currentRemoteDir; | 65 | QString currentRemoteDir; |
66 | QString filterStr; | 66 | QString filterStr; |
67 | QListViewItem * item; | 67 | QListViewItem * item; |
68 | QPushButton *connectServerBtn, *newServerButton;// | 68 | QPushButton *connectServerBtn, *newServerButton;// |
69 | QToolButton *cdUpButton, *homeButton, *docButton; | 69 | QToolButton *cdUpButton, *homeButton, *docButton; |
70 | bool b; | 70 | bool b; |
71 | int currentServerConfig; | 71 | int currentServerConfig; |
72 | protected slots: | 72 | protected slots: |
73 | void timerOut(); | 73 | void timerOut(); |
74 | void upDir(); | 74 | void upDir(); |
75 | void homeButtonPushed(); | 75 | void homeButtonPushed(); |
76 | void docButtonPushed(); | 76 | void docButtonPushed(); |
77 | void doAbout(); | 77 | void doAbout(); |
78 | 78 | ||
79 | void serverComboEdited(const QString & ); | 79 | void serverComboEdited(const QString & ); |
80 | void UsernameComboBoxEdited(const QString & ); | 80 | void UsernameComboBoxEdited(const QString & ); |
81 | void PasswordEditEdited(const QString & ); | 81 | void PasswordEditEdited(const QString & ); |
82 | 82 | ||
83 | void showLocalMenu( QListViewItem *); | 83 | void showLocalMenu( QListViewItem *); |
84 | void showRemoteMenu( QListViewItem *); | 84 | void showRemoteMenu( QListViewItem *); |
85 | void doLocalCd(); | 85 | void doLocalCd(); |
86 | void doRemoteCd(); | 86 | void doRemoteCd(); |
87 | void localUpload(); | 87 | void localUpload(); |
88 | void remoteDownload(); | 88 | void remoteDownload(); |
89 | void newConnection(); | 89 | void newConnection(); |
90 | void connector(); | 90 | void connector(); |
91 | void disConnector(); | 91 | void disConnector(); |
92 | void populateLocalView(); | 92 | void populateLocalView(); |
93 | bool populateRemoteView(); | 93 | bool populateRemoteView(); |
94 | void showHidden(); | 94 | void showHidden(); |
95 | void writeConfig(); | 95 | void writeConfig(); |
96 | void readConfig(); | 96 | void readConfig(); |
97 | void localListClicked(QListViewItem *); | 97 | void localListClicked(QListViewItem *); |
98 | void remoteListClicked(QListViewItem *); | 98 | void remoteListClicked(QListViewItem *); |
99 | void ListPressed( int, QListViewItem *, const QPoint&, int); | 99 | void ListPressed( int, QListViewItem *, const QPoint&, int); |
100 | void RemoteListPressed( int, QListViewItem *, const QPoint&, int); | 100 | void RemoteListPressed( int, QListViewItem *, const QPoint&, int); |
101 | void localMakDir(); | 101 | void localMakDir(); |
102 | void localDelete(); | 102 | void localDelete(); |
103 | void remoteMakDir(); | 103 | void remoteMakDir(); |
104 | void remoteDelete(); | 104 | void remoteDelete(); |
105 | 105 | ||
106 | bool remoteDirList(const QString &); | 106 | bool remoteDirList(const QString &); |
107 | bool remoteChDir(const QString &); | 107 | bool remoteChDir(const QString &); |
108 | 108 | ||
109 | void tabChanged(QWidget*); | 109 | void tabChanged(QWidget*); |
110 | void cleanUp(); | 110 | void cleanUp(); |
111 | 111 | ||
112 | void remoteRename(); | 112 | void remoteRename(); |
113 | void localRename(); | 113 | void localRename(); |
114 | 114 | ||
115 | void currentPathComboChanged(); | 115 | void currentPathComboChanged(); |
116 | void currentPathComboActivated(const QString &); | 116 | void currentPathComboActivated(const QString &); |
117 | void switchToLocalTab(); | 117 | void switchToLocalTab(); |
118 | void switchToRemoteTab(); | 118 | void switchToRemoteTab(); |
119 | void switchToConfigTab(); | 119 | void switchToConfigTab(); |
120 | 120 | ||
121 | void fillCombos(); | 121 | void fillCombos(); |
122 | void clearCombos(); | 122 | void clearCombos(); |
123 | void fillRemoteCombo(const QString&); | 123 | void fillRemoteCombo(const QString&); |
124 | void fillCombo(const QString &); | 124 | void fillCombo(const QString &); |
125 | void serverComboSelected(int); | 125 | void serverComboSelected(int); |
126 | void deleteServer(); | 126 | void deleteServer(); |
127 | void connectorBtnToggled(bool); | 127 | void connectorBtnToggled(bool); |
128 | void NewServer(); | 128 | void NewServer(); |
129 | void serverListClicked( const QString &); | 129 | void serverListClicked( const QString &); |
130 | 130 | ||
131 | protected: | 131 | protected: |
132 | QPixmap unknownXpm; | 132 | QPixmap unknownXpm; |
133 | bool fuckeduphack; | 133 | bool fuckeduphack; |
134 | QStringList remoteDirPathStringList, localDirPathStringList; | 134 | QStringList remoteDirPathStringList, localDirPathStringList; |
135 | QString newServerName; | 135 | QString newServerName; |
136 | void nullifyCallBack(); | 136 | void nullifyCallBack(); |
137 | QGridLayout* tabLayout; | 137 | QGridLayout* tabLayout; |
138 | QGridLayout* tabLayout_2; | 138 | QGridLayout* tabLayout_2; |
139 | QGridLayout* tabLayout_3; | 139 | QGridLayout* tabLayout_3; |
140 | 140 | ||
141 | }; | 141 | }; |
142 | 142 | ||
143 | #endif // OPIEFTP_H | 143 | #endif // OPIEFTP_H |
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp index 8f76cdd..95fbdcd 100644 --- a/noncore/net/opieirc/mainwindow.cpp +++ b/noncore/net/opieirc/mainwindow.cpp | |||
@@ -1,93 +1,93 @@ | |||
1 | #include <qpe/qpemenubar.h> | 1 | #include <qpe/qpemenubar.h> |
2 | #include <qpe/resource.h> | 2 | #include <qpe/resource.h> |
3 | #include <qpe/config.h> | 3 | #include <qpe/config.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qwhatsthis.h> | 5 | #include <qwhatsthis.h> |
6 | 6 | ||
7 | #include "mainwindow.h" | 7 | #include "mainwindow.h" |
8 | #include "ircservertab.h" | 8 | #include "ircservertab.h" |
9 | #include "ircserverlist.h" | 9 | #include "ircserverlist.h" |
10 | #include "ircsettings.h" | 10 | #include "ircsettings.h" |
11 | 11 | ||
12 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 12 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
13 | setCaption(tr("IRC Client")); | 13 | setCaption(tr("IRC Client")); |
14 | m_tabWidget = new IRCTabWidget(this); | 14 | m_tabWidget = new IRCTabWidget(this); |
15 | QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here")); | 15 | QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here")); |
16 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(selected(QWidget *))); | 16 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(selected(QWidget *))); |
17 | setCentralWidget(m_tabWidget); | 17 | setCentralWidget(m_tabWidget); |
18 | setToolBarsMovable(FALSE); | 18 | setToolBarsMovable(FALSE); |
19 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 19 | QMenuBar *menuBar = new QMenuBar(this); |
20 | QPopupMenu *irc = new QPopupMenu(this); | 20 | QPopupMenu *irc = new QPopupMenu(this); |
21 | menuBar->insertItem(tr("IRC"), irc); | 21 | menuBar->insertItem(tr("IRC"), irc); |
22 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); | 22 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); |
23 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); | 23 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); |
24 | a->setWhatsThis(tr("Create a new connection to an IRC server")); | 24 | a->setWhatsThis(tr("Create a new connection to an IRC server")); |
25 | a->addTo(irc); | 25 | a->addTo(irc); |
26 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); | 26 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); |
27 | a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); | 27 | a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); |
28 | connect(a, SIGNAL(activated()), this, SLOT(settings())); | 28 | connect(a, SIGNAL(activated()), this, SLOT(settings())); |
29 | a->addTo(irc); | 29 | a->addTo(irc); |
30 | loadSettings(); | 30 | loadSettings(); |
31 | } | 31 | } |
32 | 32 | ||
33 | /*IRCTabWidget MainWindow::getTabWidget(){ | 33 | /*IRCTabWidget MainWindow::getTabWidget(){ |
34 | return m_tabWidget; | 34 | return m_tabWidget; |
35 | } */ | 35 | } */ |
36 | 36 | ||
37 | void MainWindow::loadSettings() { | 37 | void MainWindow::loadSettings() { |
38 | Config config("OpieIRC"); | 38 | Config config("OpieIRC"); |
39 | config.setGroup("OpieIRC"); | 39 | config.setGroup("OpieIRC"); |
40 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); | 40 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); |
41 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); | 41 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); |
42 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); | 42 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); |
43 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); | 43 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); |
44 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); | 44 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); |
45 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); | 45 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); |
46 | IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); | 46 | IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); |
47 | IRCTab::m_maxLines = config.readNumEntry("Lines", 100); | 47 | IRCTab::m_maxLines = config.readNumEntry("Lines", 100); |
48 | } | 48 | } |
49 | 49 | ||
50 | void MainWindow::selected(QWidget *) { | 50 | void MainWindow::selected(QWidget *) { |
51 | m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); | 51 | m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); |
52 | emit updateScroll(); | 52 | emit updateScroll(); |
53 | } | 53 | } |
54 | 54 | ||
55 | void MainWindow::addTab(IRCTab *tab) { | 55 | void MainWindow::addTab(IRCTab *tab) { |
56 | connect(tab, SIGNAL(changed(IRCTab *)), this, SLOT(changeEvent(IRCTab *))); | 56 | connect(tab, SIGNAL(changed(IRCTab *)), this, SLOT(changeEvent(IRCTab *))); |
57 | m_tabWidget->addTab(tab, tab->title()); | 57 | m_tabWidget->addTab(tab, tab->title()); |
58 | m_tabWidget->showPage(tab); | 58 | m_tabWidget->showPage(tab); |
59 | tab->setID(m_tabWidget->currentPageIndex()); | 59 | tab->setID(m_tabWidget->currentPageIndex()); |
60 | m_tabs.append(tab); | 60 | m_tabs.append(tab); |
61 | } | 61 | } |
62 | 62 | ||
63 | void MainWindow::changeEvent(IRCTab *tab) { | 63 | void MainWindow::changeEvent(IRCTab *tab) { |
64 | if (tab->id() != m_tabWidget->currentPageIndex()) | 64 | if (tab->id() != m_tabWidget->currentPageIndex()) |
65 | m_tabWidget->setTabColor(tab->id(), blue); | 65 | m_tabWidget->setTabColor(tab->id(), blue); |
66 | } | 66 | } |
67 | 67 | ||
68 | void MainWindow::killTab(IRCTab *tab) { | 68 | void MainWindow::killTab(IRCTab *tab) { |
69 | m_tabWidget->removePage(tab); | 69 | m_tabWidget->removePage(tab); |
70 | m_tabs.remove(tab); | 70 | m_tabs.remove(tab); |
71 | /* there might be nicer ways to do this .. */ | 71 | /* there might be nicer ways to do this .. */ |
72 | delete tab; | 72 | delete tab; |
73 | } | 73 | } |
74 | 74 | ||
75 | void MainWindow::newConnection() { | 75 | void MainWindow::newConnection() { |
76 | IRCServerList list(this, "ServerList", TRUE); | 76 | IRCServerList list(this, "ServerList", TRUE); |
77 | if (list.exec() == QDialog::Accepted && list.hasServer()) { | 77 | if (list.exec() == QDialog::Accepted && list.hasServer()) { |
78 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); | 78 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); |
79 | addTab(serverTab); | 79 | addTab(serverTab); |
80 | serverTab->doConnect(); | 80 | serverTab->doConnect(); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | void MainWindow::settings() { | 84 | void MainWindow::settings() { |
85 | IRCSettings settings(this, "Settings", TRUE); | 85 | IRCSettings settings(this, "Settings", TRUE); |
86 | if (settings.exec() == QDialog::Accepted) { | 86 | if (settings.exec() == QDialog::Accepted) { |
87 | QListIterator<IRCTab> it(m_tabs); | 87 | QListIterator<IRCTab> it(m_tabs); |
88 | for (; it.current(); ++it) { | 88 | for (; it.current(); ++it) { |
89 | /* Inform all tabs about the new settings */ | 89 | /* Inform all tabs about the new settings */ |
90 | it.current()->settingsChanged(); | 90 | it.current()->settingsChanged(); |
91 | } | 91 | } |
92 | } | 92 | } |
93 | } | 93 | } |
diff --git a/noncore/net/wellenreiter/TODO b/noncore/net/wellenreiter/TODO index a1d5bee..0336417 100644 --- a/noncore/net/wellenreiter/TODO +++ b/noncore/net/wellenreiter/TODO | |||
@@ -1,4 +1,15 @@ | |||
1 | - save configuration settings | ||
2 | - beep over headphone / customizable | 1 | - beep over headphone / customizable |
3 | - autoshow new nets - maybe in other color or more contrast | ||
4 | 2 | ||
3 | - identification of probe requests | ||
4 | i.e. other sniffers around | ||
5 | |||
6 | - decloaking of falsely reported zero-length SSIDs | ||
7 | |||
8 | - option to run skript on | ||
9 | - new net | ||
10 | - new station | ||
11 | - <whatever> | ||
12 | |||
13 | - adaptive hopping scheme ! | ||
14 | |||
15 | - | ||
diff --git a/noncore/unsupported/filebrowser/filebrowser.cpp b/noncore/unsupported/filebrowser/filebrowser.cpp index d16e771..114ebfa 100644 --- a/noncore/unsupported/filebrowser/filebrowser.cpp +++ b/noncore/unsupported/filebrowser/filebrowser.cpp | |||
@@ -1,296 +1,296 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | 21 | ||
22 | #include "inlineedit.h" | 22 | #include "inlineedit.h" |
23 | #include "filebrowser.h" | 23 | #include "filebrowser.h" |
24 | #include "filePermissions.h" | 24 | #include "filePermissions.h" |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/global.h> | 26 | #include <qpe/global.h> |
27 | #include <qpe/mimetype.h> | 27 | #include <qpe/mimetype.h> |
28 | #include <qpe/applnk.h> | 28 | #include <qpe/applnk.h> |
29 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
30 | 30 | ||
31 | #include <qcopchannel_qws.h> | 31 | #include <qcopchannel_qws.h> |
32 | #include <qpe/qcopenvelope_qws.h> | 32 | #include <qpe/qcopenvelope_qws.h> |
33 | 33 | ||
34 | #include <qmessagebox.h> | 34 | #include <qmessagebox.h> |
35 | #include <qdir.h> | 35 | #include <qdir.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qheader.h> | 37 | #include <qheader.h> |
38 | #include <qpe/qpetoolbar.h> | 38 | #include <qpe/qpetoolbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpe/qpemenubar.h> | 40 | #include <qmenubar.h> |
41 | #include <qaction.h> | 41 | #include <qaction.h> |
42 | #include <qstringlist.h> | 42 | #include <qstringlist.h> |
43 | #include <qcursor.h> | 43 | #include <qcursor.h> |
44 | #include <qmultilineedit.h> | 44 | #include <qmultilineedit.h> |
45 | #include <qfont.h> | 45 | #include <qfont.h> |
46 | #include <qpainter.h> | 46 | #include <qpainter.h> |
47 | #include <qprogressbar.h> | 47 | #include <qprogressbar.h> |
48 | 48 | ||
49 | #include <unistd.h> | 49 | #include <unistd.h> |
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | #include <sys/stat.h> | 51 | #include <sys/stat.h> |
52 | #include <qpe/qpeapplication.h> | 52 | #include <qpe/qpeapplication.h> |
53 | 53 | ||
54 | // | 54 | // |
55 | // FileItem | 55 | // FileItem |
56 | // | 56 | // |
57 | FileItem::FileItem( QListView * parent, const QFileInfo & fi ) | 57 | FileItem::FileItem( QListView * parent, const QFileInfo & fi ) |
58 | : QListViewItem( parent ), | 58 | : QListViewItem( parent ), |
59 | fileInfo( fi ) | 59 | fileInfo( fi ) |
60 | { | 60 | { |
61 | QDate d = fi.lastModified().date(); | 61 | QDate d = fi.lastModified().date(); |
62 | 62 | ||
63 | setText( 0, fi.fileName() ); | 63 | setText( 0, fi.fileName() ); |
64 | setText( 1, sizeString( fi.size() ) + " " ); | 64 | setText( 1, sizeString( fi.size() ) + " " ); |
65 | setText( 2, QString().sprintf("%4d-%02d-%02d",d.year(), d.month(), d.day() ) ); | 65 | setText( 2, QString().sprintf("%4d-%02d-%02d",d.year(), d.month(), d.day() ) ); |
66 | 66 | ||
67 | MimeType mt(fi.filePath()); | 67 | MimeType mt(fi.filePath()); |
68 | 68 | ||
69 | if ( fi.isSymLink() ) | 69 | if ( fi.isSymLink() ) |
70 | setText( 3, "symlink" ); | 70 | setText( 3, "symlink" ); |
71 | else if( fi.isDir() ) | 71 | else if( fi.isDir() ) |
72 | setText( 3, "directory" ); | 72 | setText( 3, "directory" ); |
73 | else if( isLib() ) | 73 | else if( isLib() ) |
74 | setText( 3, "library" ); | 74 | setText( 3, "library" ); |
75 | else | 75 | else |
76 | setText( 3, mt.description() ); | 76 | setText( 3, mt.description() ); |
77 | 77 | ||
78 | QPixmap pm; | 78 | QPixmap pm; |
79 | if( fi.isDir() ){ | 79 | if( fi.isDir() ){ |
80 | if( !QDir( fi.filePath() ).isReadable() ) | 80 | if( !QDir( fi.filePath() ).isReadable() ) |
81 | pm = Resource::loadPixmap( "lockedfolder" ); | 81 | pm = Resource::loadPixmap( "lockedfolder" ); |
82 | else | 82 | else |
83 | pm = Resource::loadPixmap( "folder" ); | 83 | pm = Resource::loadPixmap( "folder" ); |
84 | } | 84 | } |
85 | else if( !fi.isReadable() ) | 85 | else if( !fi.isReadable() ) |
86 | pm = Resource::loadPixmap( "locked" ); | 86 | pm = Resource::loadPixmap( "locked" ); |
87 | else if( isLib() ) | 87 | else if( isLib() ) |
88 | pm = Resource::loadPixmap( "library" ); | 88 | pm = Resource::loadPixmap( "library" ); |
89 | else if( ((FileView* )parent)->getShowThumbnails() && mt.id().contains(QRegExp("^image/", FALSE, FALSE)) ) | 89 | else if( ((FileView* )parent)->getShowThumbnails() && mt.id().contains(QRegExp("^image/", FALSE, FALSE)) ) |
90 | pm = drawThumbnail(fi); | 90 | pm = drawThumbnail(fi); |
91 | else | 91 | else |
92 | pm = mt.pixmap(); | 92 | pm = mt.pixmap(); |
93 | if ( pm.isNull() ) | 93 | if ( pm.isNull() ) |
94 | pm = Resource::loadPixmap("UnknownDocument-14"); | 94 | pm = Resource::loadPixmap("UnknownDocument-14"); |
95 | 95 | ||
96 | if( fi.isSymLink() ){ | 96 | if( fi.isSymLink() ){ |
97 | // overlay link image | 97 | // overlay link image |
98 | QPixmap lnk = Resource::loadPixmap( "filebrowser/symlink" ); | 98 | QPixmap lnk = Resource::loadPixmap( "filebrowser/symlink" ); |
99 | QPainter painter( &pm ); | 99 | QPainter painter( &pm ); |
100 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 100 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
101 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 101 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
102 | } | 102 | } |
103 | setPixmap(0,pm); | 103 | setPixmap(0,pm); |
104 | } | 104 | } |
105 | 105 | ||
106 | QString FileItem::sizeString( unsigned int s ) | 106 | QString FileItem::sizeString( unsigned int s ) |
107 | { | 107 | { |
108 | double size = s; | 108 | double size = s; |
109 | 109 | ||
110 | if ( size > 1024 * 1024 * 1024 ) | 110 | if ( size > 1024 * 1024 * 1024 ) |
111 | return QString().sprintf( "%.1f", size / ( 1024 * 1024 * 1024 ) ) + "G"; | 111 | return QString().sprintf( "%.1f", size / ( 1024 * 1024 * 1024 ) ) + "G"; |
112 | else if ( size > 1024 * 1024 ) | 112 | else if ( size > 1024 * 1024 ) |
113 | return QString().sprintf( "%.1f", size / ( 1024 * 1024 ) ) + "M"; | 113 | return QString().sprintf( "%.1f", size / ( 1024 * 1024 ) ) + "M"; |
114 | else if ( size > 1024 ) | 114 | else if ( size > 1024 ) |
115 | return QString().sprintf( "%.1f", size / ( 1024 ) ) + "K"; | 115 | return QString().sprintf( "%.1f", size / ( 1024 ) ) + "K"; |
116 | else | 116 | else |
117 | return QString::number( size ) + "B"; | 117 | return QString::number( size ) + "B"; |
118 | } | 118 | } |
119 | 119 | ||
120 | QString FileItem::key( int column, bool ascending ) const | 120 | QString FileItem::key( int column, bool ascending ) const |
121 | { | 121 | { |
122 | QString tmp; | 122 | QString tmp; |
123 | 123 | ||
124 | ascending = ascending; | 124 | ascending = ascending; |
125 | 125 | ||
126 | if( (column == 0) && fileInfo.isDir() ){ // Sort by name | 126 | if( (column == 0) && fileInfo.isDir() ){ // Sort by name |
127 | // We want the directories to appear at the top of the list | 127 | // We want the directories to appear at the top of the list |
128 | tmp = (char) 0; | 128 | tmp = (char) 0; |
129 | return (tmp + text( column ).lower()); | 129 | return (tmp + text( column ).lower()); |
130 | } | 130 | } |
131 | else if( column == 2 ) { // Sort by date | 131 | else if( column == 2 ) { // Sort by date |
132 | QDateTime epoch( QDate( 1980, 1, 1 ) ); | 132 | QDateTime epoch( QDate( 1980, 1, 1 ) ); |
133 | tmp.sprintf( "%08d", epoch.secsTo( fileInfo.lastModified() ) ); | 133 | tmp.sprintf( "%08d", epoch.secsTo( fileInfo.lastModified() ) ); |
134 | return tmp; | 134 | return tmp; |
135 | } | 135 | } |
136 | else if( column == 1 ) { // Sort by size | 136 | else if( column == 1 ) { // Sort by size |
137 | return tmp.sprintf( "%08d", fileInfo.size() ); | 137 | return tmp.sprintf( "%08d", fileInfo.size() ); |
138 | } | 138 | } |
139 | 139 | ||
140 | return text( column ).lower(); | 140 | return text( column ).lower(); |
141 | } | 141 | } |
142 | 142 | ||
143 | bool FileItem::isLib() | 143 | bool FileItem::isLib() |
144 | { | 144 | { |
145 | // This is of course not foolproof | 145 | // This is of course not foolproof |
146 | if( !qstrncmp("lib", fileInfo.baseName(), 3) && | 146 | if( !qstrncmp("lib", fileInfo.baseName(), 3) && |
147 | ( fileInfo.extension().contains( "so" ) || | 147 | ( fileInfo.extension().contains( "so" ) || |
148 | fileInfo.extension().contains( "a" ) ) ) | 148 | fileInfo.extension().contains( "a" ) ) ) |
149 | return TRUE; | 149 | return TRUE; |
150 | else | 150 | else |
151 | return FALSE; | 151 | return FALSE; |
152 | } | 152 | } |
153 | 153 | ||
154 | int FileItem::launch() | 154 | int FileItem::launch() |
155 | { | 155 | { |
156 | DocLnk doc( fileInfo.filePath(), FALSE ); | 156 | DocLnk doc( fileInfo.filePath(), FALSE ); |
157 | doc.execute(); | 157 | doc.execute(); |
158 | listView()->clearSelection(); | 158 | listView()->clearSelection(); |
159 | return 1; | 159 | return 1; |
160 | } | 160 | } |
161 | 161 | ||
162 | bool FileItem::rename( const QString & name ) | 162 | bool FileItem::rename( const QString & name ) |
163 | { | 163 | { |
164 | QString oldpath, newpath; | 164 | QString oldpath, newpath; |
165 | 165 | ||
166 | if ( name.isEmpty() ) | 166 | if ( name.isEmpty() ) |
167 | return FALSE; | 167 | return FALSE; |
168 | 168 | ||
169 | if ( name.contains( QRegExp("[/\\$\"\'\\*\\?]") ) ) | 169 | if ( name.contains( QRegExp("[/\\$\"\'\\*\\?]") ) ) |
170 | return FALSE; | 170 | return FALSE; |
171 | 171 | ||
172 | oldpath = fileInfo.filePath(); | 172 | oldpath = fileInfo.filePath(); |
173 | newpath = fileInfo.dirPath() + "/" + name; | 173 | newpath = fileInfo.dirPath() + "/" + name; |
174 | 174 | ||
175 | if ( ::rename( (const char *) oldpath, (const char *) newpath ) != 0 ) | 175 | if ( ::rename( (const char *) oldpath, (const char *) newpath ) != 0 ) |
176 | return FALSE; | 176 | return FALSE; |
177 | else | 177 | else |
178 | return TRUE; | 178 | return TRUE; |
179 | } | 179 | } |
180 | 180 | ||
181 | QPixmap FileItem::drawThumbnail(const QFileInfo &file) { | 181 | QPixmap FileItem::drawThumbnail(const QFileInfo &file) { |
182 | 182 | ||
183 | /* | 183 | /* |
184 | * this thing is sloooooow, and it also doesn't load | 184 | * this thing is sloooooow, and it also doesn't load |
185 | * dynamicly (like a web browser). if anyone knows how to | 185 | * dynamicly (like a web browser). if anyone knows how to |
186 | * do that, please do! | 186 | * do that, please do! |
187 | */ | 187 | */ |
188 | QString cacheDir = "/tmp/filebrowserThumbnailCache"; | 188 | QString cacheDir = "/tmp/filebrowserThumbnailCache"; |
189 | QFileInfo cachedFile (cacheDir + file.filePath()); | 189 | QFileInfo cachedFile (cacheDir + file.filePath()); |
190 | 190 | ||
191 | if (cachedFile.exists() && cachedFile.lastModified() == file.lastModified()) { | 191 | if (cachedFile.exists() && cachedFile.lastModified() == file.lastModified()) { |
192 | 192 | ||
193 | QPixmap cachedImage (cachedFile.filePath()); | 193 | QPixmap cachedImage (cachedFile.filePath()); |
194 | return cachedImage; | 194 | return cachedImage; |
195 | } | 195 | } |
196 | else { | 196 | else { |
197 | 197 | ||
198 | QImage image (file.filePath()); | 198 | QImage image (file.filePath()); |
199 | 199 | ||
200 | // if inside of cache dir, don't render thumbnails! recursive error! | 200 | // if inside of cache dir, don't render thumbnails! recursive error! |
201 | if (image.isNull() || file.filePath().contains(QRegExp("^" + cacheDir))) { | 201 | if (image.isNull() || file.filePath().contains(QRegExp("^" + cacheDir))) { |
202 | DocLnk doc (file.filePath()); | 202 | DocLnk doc (file.filePath()); |
203 | return doc.pixmap(); | 203 | return doc.pixmap(); |
204 | } | 204 | } |
205 | Config cfg("Filebrowser"); | 205 | Config cfg("Filebrowser"); |
206 | cfg.setGroup("View"); | 206 | cfg.setGroup("View"); |
207 | int size; | 207 | int size; |
208 | size =cfg.readNumEntry("ThumbSize", 72); | 208 | size =cfg.readNumEntry("ThumbSize", 72); |
209 | QPixmap thumb (size, size); | 209 | QPixmap thumb (size, size); |
210 | 210 | ||
211 | double scale = (double)image.height() / (double)image.width(); | 211 | double scale = (double)image.height() / (double)image.width(); |
212 | int newHeight = int(size * scale); | 212 | int newHeight = int(size * scale); |
213 | thumb.convertFromImage (image.smoothScale(size, newHeight)); | 213 | thumb.convertFromImage (image.smoothScale(size, newHeight)); |
214 | 214 | ||
215 | if (!cachedFile.dir().exists()) { | 215 | if (!cachedFile.dir().exists()) { |
216 | QString cmd = "/bin/mkdir -p \"" + cachedFile.dirPath() +"\""; | 216 | QString cmd = "/bin/mkdir -p \"" + cachedFile.dirPath() +"\""; |
217 | system( (const char *) cmd ); | 217 | system( (const char *) cmd ); |
218 | } | 218 | } |
219 | 219 | ||
220 | if (thumb.save(cachedFile.filePath(), QPixmap::imageFormat(file.filePath()), 70)) { | 220 | if (thumb.save(cachedFile.filePath(), QPixmap::imageFormat(file.filePath()), 70)) { |
221 | // make thumbnail modify time the same as the image | 221 | // make thumbnail modify time the same as the image |
222 | QString cmd = "/bin/touch -r \"" + file.filePath() +"\" " + | 222 | QString cmd = "/bin/touch -r \"" + file.filePath() +"\" " + |
223 | "\"" + cachedFile.filePath() + "\""; | 223 | "\"" + cachedFile.filePath() + "\""; |
224 | system( (const char *) cmd ); | 224 | system( (const char *) cmd ); |
225 | 225 | ||
226 | } | 226 | } |
227 | 227 | ||
228 | return thumb; | 228 | return thumb; |
229 | } | 229 | } |
230 | } | 230 | } |
231 | 231 | ||
232 | // | 232 | // |
233 | // FileView | 233 | // FileView |
234 | // | 234 | // |
235 | FileView::FileView( const QString & dir, QWidget * parent, | 235 | FileView::FileView( const QString & dir, QWidget * parent, |
236 | const char * name, | 236 | const char * name, |
237 | bool hidden, bool symlinks, bool thumbnails ) | 237 | bool hidden, bool symlinks, bool thumbnails ) |
238 | : QListView( parent, name ), | 238 | : QListView( parent, name ), |
239 | menuTimer( this ), | 239 | menuTimer( this ), |
240 | le( NULL ), | 240 | le( NULL ), |
241 | itemToRename( NULL ), | 241 | itemToRename( NULL ), |
242 | showHidden( hidden ), | 242 | showHidden( hidden ), |
243 | showSymlinks( symlinks ), | 243 | showSymlinks( symlinks ), |
244 | showThumbnails( thumbnails ), | 244 | showThumbnails( thumbnails ), |
245 | menuKeepsOpen( FALSE ) | 245 | menuKeepsOpen( FALSE ) |
246 | { | 246 | { |
247 | addColumn( "Name" ); | 247 | addColumn( "Name" ); |
248 | addColumn( "Size" ); | 248 | addColumn( "Size" ); |
249 | addColumn( "Date" ); | 249 | addColumn( "Date" ); |
250 | addColumn( "Type" ); | 250 | addColumn( "Type" ); |
251 | 251 | ||
252 | setMultiSelection( TRUE ); | 252 | setMultiSelection( TRUE ); |
253 | //header()->hide(); | 253 | //header()->hide(); |
254 | 254 | ||
255 | setColumnWidthMode( 0, Manual ); | 255 | setColumnWidthMode( 0, Manual ); |
256 | setColumnWidthMode( 3, Manual ); | 256 | setColumnWidthMode( 3, Manual ); |
257 | 257 | ||
258 | // right align yize column | 258 | // right align yize column |
259 | setColumnAlignment( 1, AlignRight ); | 259 | setColumnAlignment( 1, AlignRight ); |
260 | 260 | ||
261 | generateDir( dir ); | 261 | generateDir( dir ); |
262 | 262 | ||
263 | connect( this, SIGNAL( clicked( QListViewItem * )), | 263 | connect( this, SIGNAL( clicked( QListViewItem * )), |
264 | SLOT( itemClicked( QListViewItem * )) ); | 264 | SLOT( itemClicked( QListViewItem * )) ); |
265 | connect( this, SIGNAL( doubleClicked( QListViewItem * )), | 265 | connect( this, SIGNAL( doubleClicked( QListViewItem * )), |
266 | SLOT( itemDblClicked( QListViewItem * )) ); | 266 | SLOT( itemDblClicked( QListViewItem * )) ); |
267 | connect( this, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); | 267 | connect( this, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); |
268 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); | 268 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); |
269 | } | 269 | } |
270 | 270 | ||
271 | void FileView::resizeEvent( QResizeEvent *e ) | 271 | void FileView::resizeEvent( QResizeEvent *e ) |
272 | { | 272 | { |
273 | setColumnWidth( 0, width() - 2 * lineWidth() - 20 - columnWidth( 1 ) - columnWidth( 2 ) ); | 273 | setColumnWidth( 0, width() - 2 * lineWidth() - 20 - columnWidth( 1 ) - columnWidth( 2 ) ); |
274 | 274 | ||
275 | // hide type column, we use it for "sort by type" only | 275 | // hide type column, we use it for "sort by type" only |
276 | //setColumnWidth( 3, 0 ); | 276 | //setColumnWidth( 3, 0 ); |
277 | QListView::resizeEvent( e ); | 277 | QListView::resizeEvent( e ); |
278 | } | 278 | } |
279 | 279 | ||
280 | void FileView::updateDir() | 280 | void FileView::updateDir() |
281 | { | 281 | { |
282 | generateDir( currentDir ); | 282 | generateDir( currentDir ); |
283 | } | 283 | } |
284 | 284 | ||
285 | void FileView::setDir( const QString & dir ) | 285 | void FileView::setDir( const QString & dir ) |
286 | { | 286 | { |
287 | if ( dir.startsWith( "/dev" ) ) { | 287 | if ( dir.startsWith( "/dev" ) ) { |
288 | QMessageBox::warning( this, tr( "File Manager" ), | 288 | QMessageBox::warning( this, tr( "File Manager" ), |
289 | tr( "Can't show /dev/ directory." ), tr( "&Ok" ) ); | 289 | tr( "Can't show /dev/ directory." ), tr( "&Ok" ) ); |
290 | return; | 290 | return; |
291 | } | 291 | } |
292 | dirHistory += currentDir; | 292 | dirHistory += currentDir; |
293 | generateDir( dir ); | 293 | generateDir( dir ); |
294 | } | 294 | } |
295 | 295 | ||
296 | void FileView::generateDir( const QString & dir ) | 296 | void FileView::generateDir( const QString & dir ) |
@@ -589,503 +589,503 @@ void FileView::del() | |||
589 | QString cmd; | 589 | QString cmd; |
590 | int err; | 590 | int err; |
591 | 591 | ||
592 | if((i = (FileItem *) firstChild()) == 0) return; | 592 | if((i = (FileItem *) firstChild()) == 0) return; |
593 | 593 | ||
594 | while( i ){ | 594 | while( i ){ |
595 | if( i->isSelected() ){ | 595 | if( i->isSelected() ){ |
596 | fl += i->getFilePath(); | 596 | fl += i->getFilePath(); |
597 | } | 597 | } |
598 | i = (FileItem *) i->nextSibling(); | 598 | i = (FileItem *) i->nextSibling(); |
599 | } | 599 | } |
600 | if( fl.count() < 1 ) return; | 600 | if( fl.count() < 1 ) return; |
601 | 601 | ||
602 | if( QMessageBox::warning( this, tr("Delete"), tr("Are you sure?"), | 602 | if( QMessageBox::warning( this, tr("Delete"), tr("Are you sure?"), |
603 | tr("Yes"), tr("No") ) == 0) | 603 | tr("Yes"), tr("No") ) == 0) |
604 | { | 604 | { |
605 | // | 605 | // |
606 | // Dependant upon the "rm" command - will probably have to be replaced | 606 | // Dependant upon the "rm" command - will probably have to be replaced |
607 | // | 607 | // |
608 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { | 608 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { |
609 | cmd = "/bin/rm -rf \"" + (*it) + "\""; | 609 | cmd = "/bin/rm -rf \"" + (*it) + "\""; |
610 | err = system( (const char *) cmd ); | 610 | err = system( (const char *) cmd ); |
611 | if ( err != 0 ) { | 611 | if ( err != 0 ) { |
612 | QMessageBox::warning( this, tr("Delete"), tr("Delete failed!"), | 612 | QMessageBox::warning( this, tr("Delete"), tr("Delete failed!"), |
613 | tr("Ok") ); | 613 | tr("Ok") ); |
614 | break; | 614 | break; |
615 | } | 615 | } |
616 | } | 616 | } |
617 | updateDir(); | 617 | updateDir(); |
618 | } | 618 | } |
619 | } | 619 | } |
620 | 620 | ||
621 | void FileView::newFolder() | 621 | void FileView::newFolder() |
622 | { | 622 | { |
623 | int t = 1; | 623 | int t = 1; |
624 | FileItem * i; | 624 | FileItem * i; |
625 | QString nd = currentDir + "/NewFolder"; | 625 | QString nd = currentDir + "/NewFolder"; |
626 | 626 | ||
627 | while( QFile( nd ).exists() ){ | 627 | while( QFile( nd ).exists() ){ |
628 | nd.sprintf( "%s/NewFolder (%d)", (const char *) currentDir, t++ ); | 628 | nd.sprintf( "%s/NewFolder (%d)", (const char *) currentDir, t++ ); |
629 | } | 629 | } |
630 | 630 | ||
631 | if( mkdir( (const char *) nd, 0777 ) != 0){ | 631 | if( mkdir( (const char *) nd, 0777 ) != 0){ |
632 | QMessageBox::warning( this, tr( "New folder" ), | 632 | QMessageBox::warning( this, tr( "New folder" ), |
633 | tr( "Folder creation failed!" ), | 633 | tr( "Folder creation failed!" ), |
634 | tr( "Ok" ) ); | 634 | tr( "Ok" ) ); |
635 | return; | 635 | return; |
636 | } | 636 | } |
637 | updateDir(); | 637 | updateDir(); |
638 | 638 | ||
639 | if((i = (FileItem *) firstChild()) == 0) return; | 639 | if((i = (FileItem *) firstChild()) == 0) return; |
640 | 640 | ||
641 | while( i ){ | 641 | while( i ){ |
642 | if( i->isDir() && ( i->getFilePath() == nd ) ){ | 642 | if( i->isDir() && ( i->getFilePath() == nd ) ){ |
643 | setCurrentItem( i ); | 643 | setCurrentItem( i ); |
644 | rename(); | 644 | rename(); |
645 | break; | 645 | break; |
646 | } | 646 | } |
647 | i = (FileItem *) i->nextSibling(); | 647 | i = (FileItem *) i->nextSibling(); |
648 | } | 648 | } |
649 | } | 649 | } |
650 | 650 | ||
651 | void FileView::viewAsText() | 651 | void FileView::viewAsText() |
652 | { | 652 | { |
653 | FileItem * i = (FileItem *) currentItem(); | 653 | FileItem * i = (FileItem *) currentItem(); |
654 | QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); | 654 | QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); |
655 | e << i->getFilePath(); | 655 | e << i->getFilePath(); |
656 | // Global::execute( "textedit -f ", i->getFilePath() ); | 656 | // Global::execute( "textedit -f ", i->getFilePath() ); |
657 | } | 657 | } |
658 | 658 | ||
659 | void FileView::itemClicked( QListViewItem * i) | 659 | void FileView::itemClicked( QListViewItem * i) |
660 | { | 660 | { |
661 | FileItem * t = (FileItem *) i; | 661 | FileItem * t = (FileItem *) i; |
662 | 662 | ||
663 | if( t == NULL ) return; | 663 | if( t == NULL ) return; |
664 | if( t->isDir() ){ | 664 | if( t->isDir() ){ |
665 | setDir( t->getFilePath() ); | 665 | setDir( t->getFilePath() ); |
666 | } | 666 | } |
667 | } | 667 | } |
668 | 668 | ||
669 | void FileView::itemDblClicked( QListViewItem * i) | 669 | void FileView::itemDblClicked( QListViewItem * i) |
670 | { | 670 | { |
671 | if(menuKeepsOpen){ | 671 | if(menuKeepsOpen){ |
672 | cancelMenuTimer(); | 672 | cancelMenuTimer(); |
673 | } | 673 | } |
674 | 674 | ||
675 | FileItem * t = (FileItem *) i; | 675 | FileItem * t = (FileItem *) i; |
676 | 676 | ||
677 | if(t == NULL) return; | 677 | if(t == NULL) return; |
678 | if(t->launch() == -1){ | 678 | if(t->launch() == -1){ |
679 | QMessageBox::warning( this, tr( "Launch Application" ), | 679 | QMessageBox::warning( this, tr( "Launch Application" ), |
680 | tr( "Launch failed!" ), tr( "Ok" ) ); | 680 | tr( "Launch failed!" ), tr( "Ok" ) ); |
681 | } | 681 | } |
682 | } | 682 | } |
683 | 683 | ||
684 | void FileView::parentDir() | 684 | void FileView::parentDir() |
685 | { | 685 | { |
686 | setDir( currentDir + "./.." ); | 686 | setDir( currentDir + "./.." ); |
687 | } | 687 | } |
688 | 688 | ||
689 | void FileView::lastDir() | 689 | void FileView::lastDir() |
690 | { | 690 | { |
691 | if( dirHistory.count() == 0 ) return; | 691 | if( dirHistory.count() == 0 ) return; |
692 | 692 | ||
693 | QString newDir = dirHistory.last(); | 693 | QString newDir = dirHistory.last(); |
694 | dirHistory.remove( dirHistory.last() ); | 694 | dirHistory.remove( dirHistory.last() ); |
695 | generateDir( newDir ); | 695 | generateDir( newDir ); |
696 | } | 696 | } |
697 | 697 | ||
698 | void FileView::contentsMousePressEvent( QMouseEvent * e ) | 698 | void FileView::contentsMousePressEvent( QMouseEvent * e ) |
699 | { | 699 | { |
700 | QListView::contentsMousePressEvent( e ); | 700 | QListView::contentsMousePressEvent( e ); |
701 | menuTimer.start( 750, TRUE ); | 701 | menuTimer.start( 750, TRUE ); |
702 | } | 702 | } |
703 | 703 | ||
704 | void FileView::contentsMouseReleaseEvent( QMouseEvent * e ) | 704 | void FileView::contentsMouseReleaseEvent( QMouseEvent * e ) |
705 | { | 705 | { |
706 | QListView::contentsMouseReleaseEvent( e ); | 706 | QListView::contentsMouseReleaseEvent( e ); |
707 | if(!menuKeepsOpen){ | 707 | if(!menuKeepsOpen){ |
708 | menuTimer.stop(); | 708 | menuTimer.stop(); |
709 | } | 709 | } |
710 | 710 | ||
711 | } | 711 | } |
712 | 712 | ||
713 | void FileView::cancelMenuTimer() | 713 | void FileView::cancelMenuTimer() |
714 | { | 714 | { |
715 | if( menuTimer.isActive() ) | 715 | if( menuTimer.isActive() ) |
716 | menuTimer.stop(); | 716 | menuTimer.stop(); |
717 | } | 717 | } |
718 | 718 | ||
719 | void FileView::addToDocuments() | 719 | void FileView::addToDocuments() |
720 | { | 720 | { |
721 | FileItem * i = (FileItem *) currentItem(); | 721 | FileItem * i = (FileItem *) currentItem(); |
722 | DocLnk f; | 722 | DocLnk f; |
723 | QString n = i->text(0); | 723 | QString n = i->text(0); |
724 | n.replace(QRegExp("\\..*"),""); | 724 | n.replace(QRegExp("\\..*"),""); |
725 | f.setName( n ); | 725 | f.setName( n ); |
726 | f.setFile( i->getFilePath() ); | 726 | f.setFile( i->getFilePath() ); |
727 | f.writeLink(); | 727 | f.writeLink(); |
728 | } | 728 | } |
729 | 729 | ||
730 | void FileView::run() | 730 | void FileView::run() |
731 | { | 731 | { |
732 | FileItem * i = (FileItem *) currentItem(); | 732 | FileItem * i = (FileItem *) currentItem(); |
733 | i->launch(); | 733 | i->launch(); |
734 | } | 734 | } |
735 | 735 | ||
736 | void FileView::showFileMenu() | 736 | void FileView::showFileMenu() |
737 | { | 737 | { |
738 | FileItem * i = (FileItem *) currentItem(); | 738 | FileItem * i = (FileItem *) currentItem(); |
739 | if ( !i ) | 739 | if ( !i ) |
740 | return; | 740 | return; |
741 | 741 | ||
742 | QPopupMenu * m = new QPopupMenu( this ); | 742 | QPopupMenu * m = new QPopupMenu( this ); |
743 | 743 | ||
744 | if ( !i->isDir() ) { | 744 | if ( !i->isDir() ) { |
745 | m->insertItem( tr( "Add to Documents" ), this, SLOT( addToDocuments() ) ); | 745 | m->insertItem( tr( "Add to Documents" ), this, SLOT( addToDocuments() ) ); |
746 | m->insertSeparator(); | 746 | m->insertSeparator(); |
747 | } | 747 | } |
748 | 748 | ||
749 | MimeType mt(i->getFilePath()); | 749 | MimeType mt(i->getFilePath()); |
750 | const AppLnk* app = mt.application(); | 750 | const AppLnk* app = mt.application(); |
751 | 751 | ||
752 | if ( !i->isDir() ) { | 752 | if ( !i->isDir() ) { |
753 | if ( app ) | 753 | if ( app ) |
754 | m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( run() ) ); | 754 | m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( run() ) ); |
755 | else if( i->isExecutable() ) | 755 | else if( i->isExecutable() ) |
756 | m->insertItem( Resource::loadPixmap( i->text( 0 ) ), tr( "Run" ), this, SLOT( run() ) ); | 756 | m->insertItem( Resource::loadPixmap( i->text( 0 ) ), tr( "Run" ), this, SLOT( run() ) ); |
757 | 757 | ||
758 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "View as text" ), | 758 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "View as text" ), |
759 | this, SLOT( viewAsText() ) ); | 759 | this, SLOT( viewAsText() ) ); |
760 | 760 | ||
761 | m->insertSeparator(); | 761 | m->insertSeparator(); |
762 | } | 762 | } |
763 | 763 | ||
764 | m->insertItem( tr( "Rename" ), this, SLOT( rename() ) ); | 764 | m->insertItem( tr( "Rename" ), this, SLOT( rename() ) ); |
765 | m->insertItem( Resource::loadPixmap("cut"), | 765 | m->insertItem( Resource::loadPixmap("cut"), |
766 | tr( "Cut" ), this, SLOT( cut() ) ); | 766 | tr( "Cut" ), this, SLOT( cut() ) ); |
767 | m->insertItem( Resource::loadPixmap("copy"), | 767 | m->insertItem( Resource::loadPixmap("copy"), |
768 | 768 | ||
769 | tr( "Copy" ), this, SLOT( copy() ) ); | 769 | tr( "Copy" ), this, SLOT( copy() ) ); |
770 | m->insertItem( Resource::loadPixmap("paste"), | 770 | m->insertItem( Resource::loadPixmap("paste"), |
771 | tr( "Paste" ), this, SLOT( paste() ) ); | 771 | tr( "Paste" ), this, SLOT( paste() ) ); |
772 | m->insertItem( tr( "Change Permissions" ), this, SLOT( chPerm() ) ); | 772 | m->insertItem( tr( "Change Permissions" ), this, SLOT( chPerm() ) ); |
773 | m->insertItem(Resource::loadPixmap( "close" ), tr( "Delete" ), this, SLOT( del() ) ); | 773 | m->insertItem(Resource::loadPixmap( "close" ), tr( "Delete" ), this, SLOT( del() ) ); |
774 | m->insertSeparator(); | 774 | m->insertSeparator(); |
775 | m->insertItem( tr( "Select all" ), this, SLOT( selectAll() ) ); | 775 | m->insertItem( tr( "Select all" ), this, SLOT( selectAll() ) ); |
776 | m->insertItem( tr( "Deselect all" ), this, SLOT( deselectAll() ) ); | 776 | m->insertItem( tr( "Deselect all" ), this, SLOT( deselectAll() ) ); |
777 | m->popup( QCursor::pos() ); | 777 | m->popup( QCursor::pos() ); |
778 | } | 778 | } |
779 | 779 | ||
780 | // | 780 | // |
781 | // FileBrowser | 781 | // FileBrowser |
782 | // | 782 | // |
783 | 783 | ||
784 | void FileView::setShowHidden(bool hidden) | 784 | void FileView::setShowHidden(bool hidden) |
785 | { | 785 | { |
786 | showHidden=hidden; | 786 | showHidden=hidden; |
787 | } | 787 | } |
788 | 788 | ||
789 | void FileView::setShowSymlinks(bool symlinks) | 789 | void FileView::setShowSymlinks(bool symlinks) |
790 | { | 790 | { |
791 | showSymlinks=symlinks; | 791 | showSymlinks=symlinks; |
792 | } | 792 | } |
793 | 793 | ||
794 | void FileView::setShowThumbnails(bool thumbnails) | 794 | void FileView::setShowThumbnails(bool thumbnails) |
795 | { | 795 | { |
796 | showThumbnails=thumbnails; | 796 | showThumbnails=thumbnails; |
797 | } | 797 | } |
798 | 798 | ||
799 | void FileView::setMenuKeepsOpen(bool keepOpen) | 799 | void FileView::setMenuKeepsOpen(bool keepOpen) |
800 | { | 800 | { |
801 | menuKeepsOpen=keepOpen; | 801 | menuKeepsOpen=keepOpen; |
802 | } | 802 | } |
803 | 803 | ||
804 | FileBrowser::FileBrowser( QWidget * parent, | 804 | FileBrowser::FileBrowser( QWidget * parent, |
805 | const char * name, WFlags f ) : | 805 | const char * name, WFlags f ) : |
806 | QMainWindow( parent, name, f ) | 806 | QMainWindow( parent, name, f ) |
807 | { | 807 | { |
808 | init( QDir::current().canonicalPath() ); | 808 | init( QDir::current().canonicalPath() ); |
809 | } | 809 | } |
810 | 810 | ||
811 | FileBrowser::FileBrowser( const QString & dir, QWidget * parent, | 811 | FileBrowser::FileBrowser( const QString & dir, QWidget * parent, |
812 | const char * name, WFlags f ) : | 812 | const char * name, WFlags f ) : |
813 | QMainWindow( parent, name, f ) | 813 | QMainWindow( parent, name, f ) |
814 | { | 814 | { |
815 | init( dir ); | 815 | init( dir ); |
816 | } | 816 | } |
817 | 817 | ||
818 | void FileBrowser::init(const QString & dir) | 818 | void FileBrowser::init(const QString & dir) |
819 | { | 819 | { |
820 | setCaption( tr("File Manager") ); | 820 | setCaption( tr("File Manager") ); |
821 | setIcon( Resource::loadPixmap( "filebrowser_icon" ) ); | 821 | setIcon( Resource::loadPixmap( "filebrowser_icon" ) ); |
822 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 822 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
823 | 823 | ||
824 | 824 | ||
825 | Config cfg("Filebrowser"); | 825 | Config cfg("Filebrowser"); |
826 | cfg.setGroup("View"); | 826 | cfg.setGroup("View"); |
827 | bool showHidden=(cfg.readEntry("Hidden","FALSE") == "TRUE"); | 827 | bool showHidden=(cfg.readEntry("Hidden","FALSE") == "TRUE"); |
828 | bool showSymlinks=(cfg.readEntry("Symlinks","FALSE") == "TRUE"); | 828 | bool showSymlinks=(cfg.readEntry("Symlinks","FALSE") == "TRUE"); |
829 | bool showThumbnails=(cfg.readEntry("Thumbnails","FALSE") == "TRUE"); | 829 | bool showThumbnails=(cfg.readEntry("Thumbnails","FALSE") == "TRUE"); |
830 | 830 | ||
831 | cfg.setGroup("Menu"); | 831 | cfg.setGroup("Menu"); |
832 | bool menuKeepsOpen=(cfg.readEntry("KeepOpen", "FALSE") == "TRUE"); | 832 | bool menuKeepsOpen=(cfg.readEntry("KeepOpen", "FALSE") == "TRUE"); |
833 | 833 | ||
834 | 834 | ||
835 | fileView = new FileView( dir, this, 0, showHidden, showSymlinks, showThumbnails ); | 835 | fileView = new FileView( dir, this, 0, showHidden, showSymlinks, showThumbnails ); |
836 | fileView->setAllColumnsShowFocus( TRUE ); | 836 | fileView->setAllColumnsShowFocus( TRUE ); |
837 | fileView->setMenuKeepsOpen(menuKeepsOpen); | 837 | fileView->setMenuKeepsOpen(menuKeepsOpen); |
838 | 838 | ||
839 | setCentralWidget( fileView ); | 839 | setCentralWidget( fileView ); |
840 | setToolBarsMovable( FALSE ); | 840 | setToolBarsMovable( FALSE ); |
841 | 841 | ||
842 | QPEToolBar* toolBar = new QPEToolBar( this ); | 842 | QPEToolBar* toolBar = new QPEToolBar( this ); |
843 | toolBar->setHorizontalStretchable( TRUE ); | 843 | toolBar->setHorizontalStretchable( TRUE ); |
844 | 844 | ||
845 | QPEMenuBar* menuBar = new QPEMenuBar( toolBar ); | 845 | QMenuBar* menuBar = new QMenuBar( toolBar ); |
846 | 846 | ||
847 | dirMenu = new QPopupMenu( this ); | 847 | dirMenu = new QPopupMenu( this ); |
848 | menuBar->insertItem( tr( "Dir" ), dirMenu ); | 848 | menuBar->insertItem( tr( "Dir" ), dirMenu ); |
849 | 849 | ||
850 | sortMenu = new QPopupMenu( this ); | 850 | sortMenu = new QPopupMenu( this ); |
851 | menuBar->insertItem( tr( "Sort" ), sortMenu ); | 851 | menuBar->insertItem( tr( "Sort" ), sortMenu ); |
852 | sortMenu->insertItem( tr( "by Name "), this, SLOT( sortName() ) ); | 852 | sortMenu->insertItem( tr( "by Name "), this, SLOT( sortName() ) ); |
853 | sortMenu->insertItem( tr( "by Size "), this, SLOT( sortSize() ) ); | 853 | sortMenu->insertItem( tr( "by Size "), this, SLOT( sortSize() ) ); |
854 | sortMenu->insertItem( tr( "by Date "), this, SLOT( sortDate() ) ); | 854 | sortMenu->insertItem( tr( "by Date "), this, SLOT( sortDate() ) ); |
855 | sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) ); | 855 | sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) ); |
856 | sortMenu->insertSeparator(); | 856 | sortMenu->insertSeparator(); |
857 | sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) ); | 857 | sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) ); |
858 | 858 | ||
859 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE ); | 859 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE ); |
860 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); | 860 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); |
861 | 861 | ||
862 | viewMenu = new QPopupMenu( this); | 862 | viewMenu = new QPopupMenu( this); |
863 | viewMenu->insertItem( tr( "Hidden"), this, SLOT( updateShowHidden() ) ); | 863 | viewMenu->insertItem( tr( "Hidden"), this, SLOT( updateShowHidden() ) ); |
864 | viewMenu->insertItem( tr( "Symlinks"), this, SLOT( updateShowSymlinks() ) ); | 864 | viewMenu->insertItem( tr( "Symlinks"), this, SLOT( updateShowSymlinks() ) ); |
865 | viewMenu->insertItem( tr( "Thumbnails"), this, SLOT( updateShowThumbnails() ) ); | 865 | viewMenu->insertItem( tr( "Thumbnails"), this, SLOT( updateShowThumbnails() ) ); |
866 | viewMenu->setItemChecked( viewMenu->idAt( 0 ), showHidden ); | 866 | viewMenu->setItemChecked( viewMenu->idAt( 0 ), showHidden ); |
867 | viewMenu->setItemChecked( viewMenu->idAt( 1 ), showSymlinks ); | 867 | viewMenu->setItemChecked( viewMenu->idAt( 1 ), showSymlinks ); |
868 | viewMenu->setItemChecked( viewMenu->idAt( 2 ), showThumbnails ); | 868 | viewMenu->setItemChecked( viewMenu->idAt( 2 ), showThumbnails ); |
869 | 869 | ||
870 | menuBar->insertItem( tr("View"), viewMenu ); | 870 | menuBar->insertItem( tr("View"), viewMenu ); |
871 | 871 | ||
872 | toolBar = new QPEToolBar( this ); | 872 | toolBar = new QPEToolBar( this ); |
873 | 873 | ||
874 | lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), | 874 | lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), |
875 | QString::null, 0, this, 0 ); | 875 | QString::null, 0, this, 0 ); |
876 | connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); | 876 | connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); |
877 | lastAction->addTo( toolBar ); | 877 | lastAction->addTo( toolBar ); |
878 | lastAction->setEnabled( FALSE ); | 878 | lastAction->setEnabled( FALSE ); |
879 | 879 | ||
880 | upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ), | 880 | upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ), |
881 | QString::null, 0, this, 0 ); | 881 | QString::null, 0, this, 0 ); |
882 | connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) ); | 882 | connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) ); |
883 | upAction->addTo( toolBar ); | 883 | upAction->addTo( toolBar ); |
884 | 884 | ||
885 | QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ), | 885 | QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ), |
886 | QString::null, 0, this, 0 ); | 886 | QString::null, 0, this, 0 ); |
887 | connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) ); | 887 | connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) ); |
888 | a->addTo( toolBar ); | 888 | a->addTo( toolBar ); |
889 | 889 | ||
890 | a = new QAction( tr("Cut"), Resource::loadPixmap( "cut" ), | 890 | a = new QAction( tr("Cut"), Resource::loadPixmap( "cut" ), |
891 | QString::null, 0, this, 0 ); | 891 | QString::null, 0, this, 0 ); |
892 | connect( a, SIGNAL( activated() ), fileView, SLOT( cut() ) ); | 892 | connect( a, SIGNAL( activated() ), fileView, SLOT( cut() ) ); |
893 | a->addTo( toolBar ); | 893 | a->addTo( toolBar ); |
894 | 894 | ||
895 | a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ), | 895 | a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ), |
896 | QString::null, 0, this, 0 ); | 896 | QString::null, 0, this, 0 ); |
897 | connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) ); | 897 | connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) ); |
898 | a->addTo( toolBar ); | 898 | a->addTo( toolBar ); |
899 | 899 | ||
900 | pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), | 900 | pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), |
901 | QString::null, 0, this, 0 ); | 901 | QString::null, 0, this, 0 ); |
902 | connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) ); | 902 | connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) ); |
903 | pasteAction->addTo( toolBar ); | 903 | pasteAction->addTo( toolBar ); |
904 | 904 | ||
905 | // dirLabel = new QLabel(this, "DirLabel"); | 905 | // dirLabel = new QLabel(this, "DirLabel"); |
906 | 906 | ||
907 | connect( fileView, SIGNAL( dirChanged() ), SLOT( updateDirMenu() ) ); | 907 | connect( fileView, SIGNAL( dirChanged() ), SLOT( updateDirMenu() ) ); |
908 | updateDirMenu(); | 908 | updateDirMenu(); |
909 | 909 | ||
910 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 910 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
911 | connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 911 | connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
912 | this, SLOT(pcmciaMessage( const QCString &, const QByteArray &)) ); | 912 | this, SLOT(pcmciaMessage( const QCString &, const QByteArray &)) ); |
913 | } | 913 | } |
914 | 914 | ||
915 | void FileBrowser::pcmciaMessage( const QCString &msg, const QByteArray &) | 915 | void FileBrowser::pcmciaMessage( const QCString &msg, const QByteArray &) |
916 | { | 916 | { |
917 | if ( msg == "mtabChanged()" ) { | 917 | if ( msg == "mtabChanged()" ) { |
918 | // ## Only really needed if current dir is on a card | 918 | // ## Only really needed if current dir is on a card |
919 | fileView->updateDir(); | 919 | fileView->updateDir(); |
920 | } | 920 | } |
921 | } | 921 | } |
922 | 922 | ||
923 | void FileBrowser::changeCaption(const QString & dir) { | 923 | void FileBrowser::changeCaption(const QString & dir) { |
924 | setCaption( dir); | 924 | setCaption( dir); |
925 | } | 925 | } |
926 | 926 | ||
927 | void FileBrowser::dirSelected( int id ) | 927 | void FileBrowser::dirSelected( int id ) |
928 | { | 928 | { |
929 | int i = 0, j; | 929 | int i = 0, j; |
930 | QString dir; | 930 | QString dir; |
931 | 931 | ||
932 | // Bulid target dir from menu | 932 | // Bulid target dir from menu |
933 | while( (j = dirMenu->idAt( i )) != id ){ | 933 | while( (j = dirMenu->idAt( i )) != id ){ |
934 | dir += dirMenu->text( j ).stripWhiteSpace(); | 934 | dir += dirMenu->text( j ).stripWhiteSpace(); |
935 | if( dirMenu->text( j ) != "/" ) dir += "/"; | 935 | if( dirMenu->text( j ) != "/" ) dir += "/"; |
936 | i++; | 936 | i++; |
937 | } | 937 | } |
938 | dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace(); | 938 | dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace(); |
939 | 939 | ||
940 | fileView->setDir( dir ); | 940 | fileView->setDir( dir ); |
941 | } | 941 | } |
942 | 942 | ||
943 | void FileBrowser::updateDirMenu() | 943 | void FileBrowser::updateDirMenu() |
944 | { | 944 | { |
945 | QString spc, cd = fileView->cd(); | 945 | QString spc, cd = fileView->cd(); |
946 | QStringList l = QStringList::split( "/", cd ); | 946 | QStringList l = QStringList::split( "/", cd ); |
947 | int i = 0; | 947 | int i = 0; |
948 | 948 | ||
949 | dirMenu->clear(); | 949 | dirMenu->clear(); |
950 | dirMenu->insertItem( tr( "/" ), this, SLOT( dirSelected(int) ) ); | 950 | dirMenu->insertItem( tr( "/" ), this, SLOT( dirSelected(int) ) ); |
951 | 951 | ||
952 | for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) { | 952 | for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) { |
953 | spc.fill( ' ', i++); | 953 | spc.fill( ' ', i++); |
954 | dirMenu->insertItem( spc + (*it), this, | 954 | dirMenu->insertItem( spc + (*it), this, |
955 | SLOT( dirSelected(int) ) ); | 955 | SLOT( dirSelected(int) ) ); |
956 | } | 956 | } |
957 | dirMenu->setItemChecked( dirMenu->idAt( l.count() ), TRUE ); | 957 | dirMenu->setItemChecked( dirMenu->idAt( l.count() ), TRUE ); |
958 | 958 | ||
959 | lastAction->setEnabled( fileView->history().count() != 0 ); | 959 | lastAction->setEnabled( fileView->history().count() != 0 ); |
960 | upAction->setEnabled( cd != "/" ); | 960 | upAction->setEnabled( cd != "/" ); |
961 | } | 961 | } |
962 | 962 | ||
963 | void FileBrowser::sortName() | 963 | void FileBrowser::sortName() |
964 | { | 964 | { |
965 | fileView->setSorting( 0, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 965 | fileView->setSorting( 0, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
966 | fileView->sort(); | 966 | fileView->sort(); |
967 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); | 967 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); |
968 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); | 968 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); |
969 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); | 969 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); |
970 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); | 970 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); |
971 | } | 971 | } |
972 | 972 | ||
973 | void FileBrowser::sortSize() | 973 | void FileBrowser::sortSize() |
974 | { | 974 | { |
975 | fileView->setSorting( 1, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 975 | fileView->setSorting( 1, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
976 | fileView->sort(); | 976 | fileView->sort(); |
977 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); | 977 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); |
978 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), TRUE ); | 978 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), TRUE ); |
979 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); | 979 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); |
980 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); | 980 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); |
981 | } | 981 | } |
982 | 982 | ||
983 | void FileBrowser::sortDate() | 983 | void FileBrowser::sortDate() |
984 | { | 984 | { |
985 | fileView->setSorting( 2, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 985 | fileView->setSorting( 2, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
986 | fileView->sort(); | 986 | fileView->sort(); |
987 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); | 987 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); |
988 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); | 988 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); |
989 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), TRUE ); | 989 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), TRUE ); |
990 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); | 990 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); |
991 | } | 991 | } |
992 | 992 | ||
993 | void FileBrowser::sortType() | 993 | void FileBrowser::sortType() |
994 | { | 994 | { |
995 | fileView->setSorting( 3, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 995 | fileView->setSorting( 3, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
996 | fileView->sort(); | 996 | fileView->sort(); |
997 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); | 997 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); |
998 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); | 998 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); |
999 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); | 999 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); |
1000 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), TRUE ); | 1000 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), TRUE ); |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | void FileBrowser::updateSorting() | 1003 | void FileBrowser::updateSorting() |
1004 | { | 1004 | { |
1005 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 1005 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
1006 | 1006 | ||
1007 | if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) | 1007 | if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) |
1008 | sortName(); | 1008 | sortName(); |
1009 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) ) | 1009 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) ) |
1010 | sortSize(); | 1010 | sortSize(); |
1011 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) ) | 1011 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) ) |
1012 | sortDate(); | 1012 | sortDate(); |
1013 | else | 1013 | else |
1014 | sortType(); | 1014 | sortType(); |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | void FileView::chPerm() { | 1017 | void FileView::chPerm() { |
1018 | FileItem * i; | 1018 | FileItem * i; |
1019 | QStringList fl; | 1019 | QStringList fl; |
1020 | QString cmd; | 1020 | QString cmd; |
1021 | 1021 | ||
1022 | if((i = (FileItem *) firstChild()) == 0) return; | 1022 | if((i = (FileItem *) firstChild()) == 0) return; |
1023 | 1023 | ||
1024 | while( i ){ | 1024 | while( i ){ |
1025 | if( i->isSelected() ){ | 1025 | if( i->isSelected() ){ |
1026 | fl += i->getFilePath(); | 1026 | fl += i->getFilePath(); |
1027 | } | 1027 | } |
1028 | i = (FileItem *) i->nextSibling(); | 1028 | i = (FileItem *) i->nextSibling(); |
1029 | } | 1029 | } |
1030 | if( fl.count() < 1 ) return; | 1030 | if( fl.count() < 1 ) return; |
1031 | if( QMessageBox::warning( this, tr("Change permissions"), tr("Are you sure?"), | 1031 | if( QMessageBox::warning( this, tr("Change permissions"), tr("Are you sure?"), |
1032 | tr("Yes"), tr("No") ) == 0) { | 1032 | tr("Yes"), tr("No") ) == 0) { |
1033 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { | 1033 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { |
1034 | filePermissions *filePerm; | 1034 | filePermissions *filePerm; |
1035 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(*it)); | 1035 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(*it)); |
1036 | filePerm->exec(); | 1036 | filePerm->exec(); |
1037 | if( filePerm) | 1037 | if( filePerm) |
1038 | delete filePerm; | 1038 | delete filePerm; |
1039 | break; | 1039 | break; |
1040 | } | 1040 | } |
1041 | updateDir(); | 1041 | updateDir(); |
1042 | } | 1042 | } |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | void FileBrowser::updateShowHidden() | 1045 | void FileBrowser::updateShowHidden() |
1046 | { | 1046 | { |
1047 | bool valShowHidden=viewMenu->isItemChecked( viewMenu->idAt( 0 ) ); | 1047 | bool valShowHidden=viewMenu->isItemChecked( viewMenu->idAt( 0 ) ); |
1048 | valShowHidden=!valShowHidden; | 1048 | valShowHidden=!valShowHidden; |
1049 | viewMenu->setItemChecked( viewMenu->idAt( 0 ), valShowHidden ); | 1049 | viewMenu->setItemChecked( viewMenu->idAt( 0 ), valShowHidden ); |
1050 | fileView->setShowHidden(valShowHidden); | 1050 | fileView->setShowHidden(valShowHidden); |
1051 | 1051 | ||
1052 | Config cfg("Filebrowser"); | 1052 | Config cfg("Filebrowser"); |
1053 | cfg.setGroup("View"); | 1053 | cfg.setGroup("View"); |
1054 | cfg.writeEntry("Hidden",valShowHidden?"TRUE":"FALSE"); | 1054 | cfg.writeEntry("Hidden",valShowHidden?"TRUE":"FALSE"); |
1055 | 1055 | ||
1056 | fileView->updateDir(); | 1056 | fileView->updateDir(); |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | void FileBrowser::updateShowSymlinks() | 1059 | void FileBrowser::updateShowSymlinks() |
1060 | { | 1060 | { |
1061 | bool valShowSymlinks=viewMenu->isItemChecked( viewMenu->idAt( 1 ) ); | 1061 | bool valShowSymlinks=viewMenu->isItemChecked( viewMenu->idAt( 1 ) ); |
1062 | valShowSymlinks=!valShowSymlinks; | 1062 | valShowSymlinks=!valShowSymlinks; |
1063 | viewMenu->setItemChecked( viewMenu->idAt( 1 ), valShowSymlinks ); | 1063 | viewMenu->setItemChecked( viewMenu->idAt( 1 ), valShowSymlinks ); |
1064 | fileView->setShowSymlinks(valShowSymlinks); | 1064 | fileView->setShowSymlinks(valShowSymlinks); |
1065 | 1065 | ||
1066 | Config cfg("Filebrowser"); | 1066 | Config cfg("Filebrowser"); |
1067 | cfg.setGroup("View"); | 1067 | cfg.setGroup("View"); |
1068 | cfg.writeEntry("Symlinks",valShowSymlinks?"TRUE":"FALSE"); | 1068 | cfg.writeEntry("Symlinks",valShowSymlinks?"TRUE":"FALSE"); |
1069 | 1069 | ||
1070 | fileView->updateDir(); | 1070 | fileView->updateDir(); |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | void FileBrowser::updateShowThumbnails() | 1073 | void FileBrowser::updateShowThumbnails() |
1074 | { | 1074 | { |
1075 | bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) ); | 1075 | bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) ); |
1076 | valShowThumbnails=!valShowThumbnails; | 1076 | valShowThumbnails=!valShowThumbnails; |
1077 | viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails ); | 1077 | viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails ); |
1078 | fileView->setShowThumbnails(valShowThumbnails); | 1078 | fileView->setShowThumbnails(valShowThumbnails); |
1079 | 1079 | ||
1080 | Config cfg("Filebrowser"); | 1080 | Config cfg("Filebrowser"); |
1081 | cfg.setGroup("View"); | 1081 | cfg.setGroup("View"); |
1082 | cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE"); | 1082 | cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE"); |
1083 | 1083 | ||
1084 | fileView->updateDir(); | 1084 | fileView->updateDir(); |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | void FileBrowser::cleanUp() { | 1087 | void FileBrowser::cleanUp() { |
1088 | QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache"; | 1088 | QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache"; |
1089 | // qDebug("exit"); | 1089 | // qDebug("exit"); |
1090 | system(cmdr.latin1()); | 1090 | system(cmdr.latin1()); |
1091 | } | 1091 | } |
diff --git a/noncore/unsupported/mail2/composerbase.cpp b/noncore/unsupported/mail2/composerbase.cpp index 6f6ab8e..34d6eb6 100644 --- a/noncore/unsupported/mail2/composerbase.cpp +++ b/noncore/unsupported/mail2/composerbase.cpp | |||
@@ -1,205 +1,205 @@ | |||
1 | #include <qmultilineedit.h> | 1 | #include <qmultilineedit.h> |
2 | #include <qpopupmenu.h> | 2 | #include <qpopupmenu.h> |
3 | #include <qcombobox.h> | 3 | #include <qcombobox.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qlayout.h> | 5 | #include <qlayout.h> |
6 | #include <qaction.h> | 6 | #include <qaction.h> |
7 | #include <qlabel.h> | 7 | #include <qlabel.h> |
8 | #include <qvbox.h> | 8 | #include <qvbox.h> |
9 | 9 | ||
10 | #include <qpe/qpetoolbar.h> | 10 | #include <qpe/qpetoolbar.h> |
11 | #include <qpe/qpemenubar.h> | 11 | #include <qpe/qpemenubar.h> |
12 | #include <qpe/resource.h> | 12 | #include <qpe/resource.h> |
13 | 13 | ||
14 | #include "mailstatusbar.h" | 14 | #include "mailstatusbar.h" |
15 | #include "listviewplus.h" | 15 | #include "listviewplus.h" |
16 | #include "composerbase.h" | 16 | #include "composerbase.h" |
17 | 17 | ||
18 | ComposerBase::ComposerBase(QWidget *parent, const char *name, WFlags fl) | 18 | ComposerBase::ComposerBase(QWidget *parent, const char *name, WFlags fl) |
19 | : QMainWindow(parent, name, fl) | 19 | : QMainWindow(parent, name, fl) |
20 | { | 20 | { |
21 | setCaption(tr("Compose Message")); | 21 | setCaption(tr("Compose Message")); |
22 | setToolBarsMovable(false); | 22 | setToolBarsMovable(false); |
23 | 23 | ||
24 | toolbar = new QPEToolBar(this); | 24 | toolbar = new QPEToolBar(this); |
25 | menubar = new QPEMenuBar( toolbar ); | 25 | menubar = new QMenuBar( toolbar ); |
26 | mailmenu = new QPopupMenu( menubar ); | 26 | mailmenu = new QPopupMenu( menubar ); |
27 | menubar->insertItem( tr( "Mail" ), mailmenu ); | 27 | menubar->insertItem( tr( "Mail" ), mailmenu ); |
28 | addToolBar(toolbar); | 28 | addToolBar(toolbar); |
29 | toolbar->setHorizontalStretchable(true); | 29 | toolbar->setHorizontalStretchable(true); |
30 | 30 | ||
31 | QLabel *spacer = new QLabel(toolbar); | 31 | QLabel *spacer = new QLabel(toolbar); |
32 | spacer->setBackgroundMode(QWidget::PaletteButton); | 32 | spacer->setBackgroundMode(QWidget::PaletteButton); |
33 | toolbar->setStretchableWidget(spacer); | 33 | toolbar->setStretchableWidget(spacer); |
34 | 34 | ||
35 | sendmail = new QAction(tr("Send the mail"), QIconSet(Resource::loadPixmap("mail/sendmail")), 0, 0, this); | 35 | sendmail = new QAction(tr("Send the mail"), QIconSet(Resource::loadPixmap("mail/sendmail")), 0, 0, this); |
36 | sendmail->addTo(toolbar); | 36 | sendmail->addTo(toolbar); |
37 | sendmail->addTo(mailmenu); | 37 | sendmail->addTo(mailmenu); |
38 | 38 | ||
39 | queuemail = new QAction(tr("Queue the mail"), QIconSet(Resource::loadPixmap("mail/sendall")), 0, 0, this); | 39 | queuemail = new QAction(tr("Queue the mail"), QIconSet(Resource::loadPixmap("mail/sendall")), 0, 0, this); |
40 | queuemail->addTo(toolbar); | 40 | queuemail->addTo(toolbar); |
41 | queuemail->addTo(mailmenu); | 41 | queuemail->addTo(mailmenu); |
42 | 42 | ||
43 | attachfile = new QAction(tr("Attach a file"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); | 43 | attachfile = new QAction(tr("Attach a file"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); |
44 | attachfile->addTo(toolbar); | 44 | attachfile->addTo(toolbar); |
45 | attachfile->addTo(mailmenu); | 45 | attachfile->addTo(mailmenu); |
46 | connect(attachfile, SIGNAL(toggled(bool)), SLOT(slotAttachfileChanged(bool))); | 46 | connect(attachfile, SIGNAL(toggled(bool)), SLOT(slotAttachfileChanged(bool))); |
47 | 47 | ||
48 | addressbook = new QAction(tr("Addressbook"), QIconSet(Resource::loadPixmap("mail/addbook")), 0, 0, this); | 48 | addressbook = new QAction(tr("Addressbook"), QIconSet(Resource::loadPixmap("mail/addbook")), 0, 0, this); |
49 | addressbook->addTo(toolbar); | 49 | addressbook->addTo(toolbar); |
50 | addressbook->addTo(mailmenu); | 50 | addressbook->addTo(mailmenu); |
51 | 51 | ||
52 | QWidget *main = new QWidget(this); | 52 | QWidget *main = new QWidget(this); |
53 | setCentralWidget(main); | 53 | setCentralWidget(main); |
54 | 54 | ||
55 | QGridLayout *layout = new QGridLayout(main); | 55 | QGridLayout *layout = new QGridLayout(main); |
56 | 56 | ||
57 | fromBox = new QComboBox(main); | 57 | fromBox = new QComboBox(main); |
58 | fromBox->insertItem(tr("From"), POPUP_FROM_FROM); | 58 | fromBox->insertItem(tr("From"), POPUP_FROM_FROM); |
59 | fromBox->insertItem(tr("Reply"), POPUP_FROM_REPLYTO); | 59 | fromBox->insertItem(tr("Reply"), POPUP_FROM_REPLYTO); |
60 | layout->addWidget(fromBox, 0, 0); | 60 | layout->addWidget(fromBox, 0, 0); |
61 | 61 | ||
62 | connect(fromBox, SIGNAL(activated(int)), SLOT(slotFromMenuChanged(int))); | 62 | connect(fromBox, SIGNAL(activated(int)), SLOT(slotFromMenuChanged(int))); |
63 | 63 | ||
64 | QHBoxLayout *fromLayout = new QHBoxLayout(); | 64 | QHBoxLayout *fromLayout = new QHBoxLayout(); |
65 | layout->addLayout(fromLayout, 0, 1); | 65 | layout->addLayout(fromLayout, 0, 1); |
66 | 66 | ||
67 | from = new QComboBox(main); | 67 | from = new QComboBox(main); |
68 | fromLayout->addWidget(from); | 68 | fromLayout->addWidget(from); |
69 | 69 | ||
70 | replyto = new QLineEdit(main); | 70 | replyto = new QLineEdit(main); |
71 | replyto->hide(); | 71 | replyto->hide(); |
72 | fromLayout->addWidget(replyto); | 72 | fromLayout->addWidget(replyto); |
73 | 73 | ||
74 | receiversBox = new QComboBox(main); | 74 | receiversBox = new QComboBox(main); |
75 | receiversBox->insertItem(tr("To"), POPUP_RECV_TO); | 75 | receiversBox->insertItem(tr("To"), POPUP_RECV_TO); |
76 | receiversBox->insertItem(tr("Cc"), POPUP_RECV_CC); | 76 | receiversBox->insertItem(tr("Cc"), POPUP_RECV_CC); |
77 | receiversBox->insertItem(tr("Bcc"), POPUP_RECV_BCC); | 77 | receiversBox->insertItem(tr("Bcc"), POPUP_RECV_BCC); |
78 | layout->addWidget(receiversBox, 1, 0); | 78 | layout->addWidget(receiversBox, 1, 0); |
79 | 79 | ||
80 | connect(receiversBox, SIGNAL(activated(int)), SLOT(slotReceiverMenuChanged(int))); | 80 | connect(receiversBox, SIGNAL(activated(int)), SLOT(slotReceiverMenuChanged(int))); |
81 | 81 | ||
82 | QHBoxLayout *receiverLayout = new QHBoxLayout(); | 82 | QHBoxLayout *receiverLayout = new QHBoxLayout(); |
83 | layout->addLayout(receiverLayout, 1, 1); | 83 | layout->addLayout(receiverLayout, 1, 1); |
84 | 84 | ||
85 | to = new QLineEdit(main); | 85 | to = new QLineEdit(main); |
86 | receiverLayout->addWidget(to); | 86 | receiverLayout->addWidget(to); |
87 | 87 | ||
88 | cc = new QLineEdit(main); | 88 | cc = new QLineEdit(main); |
89 | cc->hide(); | 89 | cc->hide(); |
90 | receiverLayout->addWidget(cc); | 90 | receiverLayout->addWidget(cc); |
91 | 91 | ||
92 | bcc = new QLineEdit(main); | 92 | bcc = new QLineEdit(main); |
93 | bcc->hide(); | 93 | bcc->hide(); |
94 | receiverLayout->addWidget(bcc); | 94 | receiverLayout->addWidget(bcc); |
95 | 95 | ||
96 | subjectBox = new QComboBox(main); | 96 | subjectBox = new QComboBox(main); |
97 | subjectBox->insertItem(tr("Subj."), POPUP_SUBJ_SUBJECT); | 97 | subjectBox->insertItem(tr("Subj."), POPUP_SUBJ_SUBJECT); |
98 | subjectBox->insertItem(tr("Prio."), POPUP_SUBJ_PRIORITY); | 98 | subjectBox->insertItem(tr("Prio."), POPUP_SUBJ_PRIORITY); |
99 | layout->addWidget(subjectBox, 2, 0); | 99 | layout->addWidget(subjectBox, 2, 0); |
100 | connect(subjectBox, SIGNAL(activated(int)), SLOT(slotSubjectMenuChanged(int))); | 100 | connect(subjectBox, SIGNAL(activated(int)), SLOT(slotSubjectMenuChanged(int))); |
101 | 101 | ||
102 | QHBoxLayout *subjectLayout = new QHBoxLayout(); | 102 | QHBoxLayout *subjectLayout = new QHBoxLayout(); |
103 | layout->addLayout(subjectLayout, 2, 1); | 103 | layout->addLayout(subjectLayout, 2, 1); |
104 | 104 | ||
105 | subject = new QLineEdit(main); | 105 | subject = new QLineEdit(main); |
106 | subjectLayout->addWidget(subject); | 106 | subjectLayout->addWidget(subject); |
107 | 107 | ||
108 | priority = new QComboBox(main); | 108 | priority = new QComboBox(main); |
109 | priority->insertItem(tr("Low"), POPUP_PRIO_LOW); | 109 | priority->insertItem(tr("Low"), POPUP_PRIO_LOW); |
110 | priority->insertItem(tr("Normal"), POPUP_PRIO_NORMAL); | 110 | priority->insertItem(tr("Normal"), POPUP_PRIO_NORMAL); |
111 | priority->insertItem(tr("High"), POPUP_PRIO_HIGH); | 111 | priority->insertItem(tr("High"), POPUP_PRIO_HIGH); |
112 | priority->setCurrentItem(POPUP_PRIO_NORMAL); | 112 | priority->setCurrentItem(POPUP_PRIO_NORMAL); |
113 | priority->hide(); | 113 | priority->hide(); |
114 | subjectLayout->addWidget(priority); | 114 | subjectLayout->addWidget(priority); |
115 | 115 | ||
116 | QVBox *view = new QVBox(main); | 116 | QVBox *view = new QVBox(main); |
117 | layout->addMultiCellWidget(view, 3, 3, 0, 1); | 117 | layout->addMultiCellWidget(view, 3, 3, 0, 1); |
118 | 118 | ||
119 | message = new QMultiLineEdit(view); | 119 | message = new QMultiLineEdit(view); |
120 | message->setMinimumHeight(30); | 120 | message->setMinimumHeight(30); |
121 | 121 | ||
122 | attachWindow = new QMainWindow(view, 0, 0); | 122 | attachWindow = new QMainWindow(view, 0, 0); |
123 | attachWindow->setMinimumHeight(80); | 123 | attachWindow->setMinimumHeight(80); |
124 | attachWindow->setMaximumHeight(80); | 124 | attachWindow->setMaximumHeight(80); |
125 | attachWindow->setToolBarsMovable(false); | 125 | attachWindow->setToolBarsMovable(false); |
126 | attachWindow->hide(); | 126 | attachWindow->hide(); |
127 | 127 | ||
128 | attachToolbar = new QPEToolBar(attachWindow); | 128 | attachToolbar = new QPEToolBar(attachWindow); |
129 | attachToolbar->setVerticalStretchable(true); | 129 | attachToolbar->setVerticalStretchable(true); |
130 | 130 | ||
131 | addattach = new QAction(tr("Add an Attachement"), QIconSet(Resource::loadPixmap("mail/newmail")), 0, 0, this); | 131 | addattach = new QAction(tr("Add an Attachement"), QIconSet(Resource::loadPixmap("mail/newmail")), 0, 0, this); |
132 | addattach->addTo(attachToolbar); | 132 | addattach->addTo(attachToolbar); |
133 | 133 | ||
134 | delattach = new QAction(tr("Remove Attachement"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); | 134 | delattach = new QAction(tr("Remove Attachement"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); |
135 | delattach->addTo(attachToolbar); | 135 | delattach->addTo(attachToolbar); |
136 | 136 | ||
137 | QLabel *attachSpacer = new QLabel(attachToolbar); | 137 | QLabel *attachSpacer = new QLabel(attachToolbar); |
138 | attachSpacer->setBackgroundMode(QWidget::PaletteButton); | 138 | attachSpacer->setBackgroundMode(QWidget::PaletteButton); |
139 | attachToolbar->setStretchableWidget(attachSpacer); | 139 | attachToolbar->setStretchableWidget(attachSpacer); |
140 | 140 | ||
141 | attachWindow->addToolBar(attachToolbar, QMainWindow::Left); | 141 | attachWindow->addToolBar(attachToolbar, QMainWindow::Left); |
142 | 142 | ||
143 | attachView = new ListViewPlus(attachWindow); | 143 | attachView = new ListViewPlus(attachWindow); |
144 | attachView->addColumn(tr("Name"), 80); | 144 | attachView->addColumn(tr("Name"), 80); |
145 | attachView->addColumn(tr("Description"), 110); | 145 | attachView->addColumn(tr("Description"), 110); |
146 | attachView->setAllColumnsShowFocus(true); | 146 | attachView->setAllColumnsShowFocus(true); |
147 | attachWindow->setCentralWidget(attachView); | 147 | attachWindow->setCentralWidget(attachView); |
148 | 148 | ||
149 | attachPopup = new QPopupMenu(attachView); | 149 | attachPopup = new QPopupMenu(attachView); |
150 | attachPopup->insertItem(tr("Rename"), POPUP_ATTACH_RENAME); | 150 | attachPopup->insertItem(tr("Rename"), POPUP_ATTACH_RENAME); |
151 | attachPopup->insertItem(tr("Change Description"), POPUP_ATTACH_DESC); | 151 | attachPopup->insertItem(tr("Change Description"), POPUP_ATTACH_DESC); |
152 | attachPopup->insertSeparator(); | 152 | attachPopup->insertSeparator(); |
153 | attachPopup->insertItem(tr("Remove"), POPUP_ATTACH_REMOVE); | 153 | attachPopup->insertItem(tr("Remove"), POPUP_ATTACH_REMOVE); |
154 | attachView->setPopup(attachPopup); | 154 | attachView->setPopup(attachPopup); |
155 | 155 | ||
156 | status = new MailStatusBar(view); | 156 | status = new MailStatusBar(view); |
157 | } | 157 | } |
158 | 158 | ||
159 | void ComposerBase::slotAttachfileChanged(bool toggled) | 159 | void ComposerBase::slotAttachfileChanged(bool toggled) |
160 | { | 160 | { |
161 | if (toggled) { | 161 | if (toggled) { |
162 | if (attachWindow->isHidden()) attachWindow->show(); | 162 | if (attachWindow->isHidden()) attachWindow->show(); |
163 | } else { | 163 | } else { |
164 | if (!attachWindow->isHidden()) attachWindow->hide(); | 164 | if (!attachWindow->isHidden()) attachWindow->hide(); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | void ComposerBase::slotFromMenuChanged(int id) | 168 | void ComposerBase::slotFromMenuChanged(int id) |
169 | { | 169 | { |
170 | if (POPUP_FROM_FROM == id) { | 170 | if (POPUP_FROM_FROM == id) { |
171 | if (from->isHidden()) from->show(); | 171 | if (from->isHidden()) from->show(); |
172 | if (!replyto->isHidden()) replyto->hide(); | 172 | if (!replyto->isHidden()) replyto->hide(); |
173 | } else if (POPUP_FROM_REPLYTO == id) { | 173 | } else if (POPUP_FROM_REPLYTO == id) { |
174 | if (!from->isHidden()) from->hide(); | 174 | if (!from->isHidden()) from->hide(); |
175 | if (replyto->isHidden()) replyto->show(); | 175 | if (replyto->isHidden()) replyto->show(); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
179 | void ComposerBase::slotReceiverMenuChanged(int id) | 179 | void ComposerBase::slotReceiverMenuChanged(int id) |
180 | { | 180 | { |
181 | if (POPUP_RECV_TO == id) { | 181 | if (POPUP_RECV_TO == id) { |
182 | if (to->isHidden()) to->show(); | 182 | if (to->isHidden()) to->show(); |
183 | if (!cc->isHidden()) cc->hide(); | 183 | if (!cc->isHidden()) cc->hide(); |
184 | if (!bcc->isHidden()) bcc->hide(); | 184 | if (!bcc->isHidden()) bcc->hide(); |
185 | } else if (POPUP_RECV_CC == id) { | 185 | } else if (POPUP_RECV_CC == id) { |
186 | if (!to->isHidden()) to->hide(); | 186 | if (!to->isHidden()) to->hide(); |
187 | if (cc->isHidden()) cc->show(); | 187 | if (cc->isHidden()) cc->show(); |
188 | if (!bcc->isHidden()) bcc->hide(); | 188 | if (!bcc->isHidden()) bcc->hide(); |
189 | } else if (POPUP_RECV_BCC == id) { | 189 | } else if (POPUP_RECV_BCC == id) { |
190 | if (!to->isHidden()) to->hide(); | 190 | if (!to->isHidden()) to->hide(); |
191 | if (!cc->isHidden()) cc->hide(); | 191 | if (!cc->isHidden()) cc->hide(); |
192 | if (bcc->isHidden()) bcc->show(); | 192 | if (bcc->isHidden()) bcc->show(); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | void ComposerBase::slotSubjectMenuChanged(int id) | 196 | void ComposerBase::slotSubjectMenuChanged(int id) |
197 | { | 197 | { |
198 | if (POPUP_SUBJ_SUBJECT == id) { | 198 | if (POPUP_SUBJ_SUBJECT == id) { |
199 | if (subject->isHidden()) subject->show(); | 199 | if (subject->isHidden()) subject->show(); |
200 | if (!priority->isHidden()) priority->hide(); | 200 | if (!priority->isHidden()) priority->hide(); |
201 | } else if (POPUP_SUBJ_PRIORITY == id) { | 201 | } else if (POPUP_SUBJ_PRIORITY == id) { |
202 | if (!subject->isHidden()) subject->hide(); | 202 | if (!subject->isHidden()) subject->hide(); |
203 | if (priority->isHidden()) priority->show(); | 203 | if (priority->isHidden()) priority->show(); |
204 | } | 204 | } |
205 | } | 205 | } |
diff --git a/noncore/unsupported/mail2/composerbase.h b/noncore/unsupported/mail2/composerbase.h index 58f1157..2c832d6 100644 --- a/noncore/unsupported/mail2/composerbase.h +++ b/noncore/unsupported/mail2/composerbase.h | |||
@@ -1,61 +1,61 @@ | |||
1 | #ifndef COMPOSERBASE_H | 1 | #ifndef COMPOSERBASE_H |
2 | #define COMPOSERBASE_H | 2 | #define COMPOSERBASE_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | 5 | ||
6 | class QMultiLineEdit; | 6 | class QMultiLineEdit; |
7 | class MailStatusBar; | 7 | class MailStatusBar; |
8 | class ListViewPlus; | 8 | class ListViewPlus; |
9 | class QPopupMenu; | 9 | class QPopupMenu; |
10 | class QPEToolBar; | 10 | class QPEToolBar; |
11 | class QPEMenuBar; | 11 | class QMenuBar; |
12 | class QPopupMenu; | 12 | class QPopupMenu; |
13 | class QComboBox; | 13 | class QComboBox; |
14 | class QLineEdit; | 14 | class QLineEdit; |
15 | class QAction; | 15 | class QAction; |
16 | class QLabel; | 16 | class QLabel; |
17 | 17 | ||
18 | class ComposerBase : public QMainWindow | 18 | class ComposerBase : public QMainWindow |
19 | { | 19 | { |
20 | Q_OBJECT | 20 | Q_OBJECT |
21 | 21 | ||
22 | public: | 22 | public: |
23 | ComposerBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); | 23 | ComposerBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); |
24 | 24 | ||
25 | protected: | 25 | protected: |
26 | static const int POPUP_FROM_FROM = 0; | 26 | static const int POPUP_FROM_FROM = 0; |
27 | static const int POPUP_FROM_REPLYTO = 1; | 27 | static const int POPUP_FROM_REPLYTO = 1; |
28 | static const int POPUP_RECV_TO = 0; | 28 | static const int POPUP_RECV_TO = 0; |
29 | static const int POPUP_RECV_CC = 1; | 29 | static const int POPUP_RECV_CC = 1; |
30 | static const int POPUP_RECV_BCC = 2; | 30 | static const int POPUP_RECV_BCC = 2; |
31 | static const int POPUP_SUBJ_SUBJECT = 0; | 31 | static const int POPUP_SUBJ_SUBJECT = 0; |
32 | static const int POPUP_SUBJ_PRIORITY = 1; | 32 | static const int POPUP_SUBJ_PRIORITY = 1; |
33 | static const int POPUP_PRIO_LOW = 0; | 33 | static const int POPUP_PRIO_LOW = 0; |
34 | static const int POPUP_PRIO_NORMAL = 1; | 34 | static const int POPUP_PRIO_NORMAL = 1; |
35 | static const int POPUP_PRIO_HIGH = 2; | 35 | static const int POPUP_PRIO_HIGH = 2; |
36 | static const int POPUP_ATTACH_RENAME = 0; | 36 | static const int POPUP_ATTACH_RENAME = 0; |
37 | static const int POPUP_ATTACH_DESC = 1; | 37 | static const int POPUP_ATTACH_DESC = 1; |
38 | static const int POPUP_ATTACH_REMOVE = 2; | 38 | static const int POPUP_ATTACH_REMOVE = 2; |
39 | 39 | ||
40 | QMultiLineEdit *message; | 40 | QMultiLineEdit *message; |
41 | MailStatusBar *status; | 41 | MailStatusBar *status; |
42 | ListViewPlus *attachView; | 42 | ListViewPlus *attachView; |
43 | QMainWindow *attachWindow; | 43 | QMainWindow *attachWindow; |
44 | QPopupMenu *attachPopup; | 44 | QPopupMenu *attachPopup; |
45 | QPEToolBar *toolbar, *attachToolbar; | 45 | QPEToolBar *toolbar, *attachToolbar; |
46 | QPEMenuBar *menubar; | 46 | QMenuBar *menubar; |
47 | QPopupMenu *mailmenu; | 47 | QPopupMenu *mailmenu; |
48 | QComboBox *fromBox, *from, *receiversBox, *subjectBox, *priority; | 48 | QComboBox *fromBox, *from, *receiversBox, *subjectBox, *priority; |
49 | QLineEdit *replyto, *to, *cc, *bcc, *subject; | 49 | QLineEdit *replyto, *to, *cc, *bcc, *subject; |
50 | QAction *sendmail, *queuemail, *attachfile, *addressbook, *abort, *addattach, *delattach; | 50 | QAction *sendmail, *queuemail, *attachfile, *addressbook, *abort, *addattach, *delattach; |
51 | QLabel *fromLabel; | 51 | QLabel *fromLabel; |
52 | 52 | ||
53 | protected slots: | 53 | protected slots: |
54 | void slotAttachfileChanged(bool toggled); | 54 | void slotAttachfileChanged(bool toggled); |
55 | void slotFromMenuChanged(int id); | 55 | void slotFromMenuChanged(int id); |
56 | void slotReceiverMenuChanged(int id); | 56 | void slotReceiverMenuChanged(int id); |
57 | void slotSubjectMenuChanged(int id); | 57 | void slotSubjectMenuChanged(int id); |
58 | 58 | ||
59 | }; | 59 | }; |
60 | 60 | ||
61 | #endif | 61 | #endif |
diff --git a/noncore/unsupported/mail2/mainwindowbase.cpp b/noncore/unsupported/mail2/mainwindowbase.cpp index e35d489..119acfb 100644 --- a/noncore/unsupported/mail2/mainwindowbase.cpp +++ b/noncore/unsupported/mail2/mainwindowbase.cpp | |||
@@ -1,75 +1,75 @@ | |||
1 | #include <qpopupmenu.h> | 1 | #include <qpopupmenu.h> |
2 | #include <qaction.h> | 2 | #include <qaction.h> |
3 | #include <qheader.h> | 3 | #include <qheader.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qvbox.h> | 5 | #include <qvbox.h> |
6 | 6 | ||
7 | #include <qpe/qpetoolbar.h> | 7 | #include <qpe/qpetoolbar.h> |
8 | #include <qpe/qpemenubar.h> | 8 | #include <qpe/qpemenubar.h> |
9 | #include <qpe/resource.h> | 9 | #include <qpe/resource.h> |
10 | 10 | ||
11 | #include "mainwindowbase.h" | 11 | #include "mainwindowbase.h" |
12 | #include "mailstatusbar.h" | 12 | #include "mailstatusbar.h" |
13 | #include "folderwidget.h" | 13 | #include "folderwidget.h" |
14 | #include "mailtable.h" | 14 | #include "mailtable.h" |
15 | 15 | ||
16 | MainWindowBase::MainWindowBase(QWidget *parent, const char *name, WFlags fl) | 16 | MainWindowBase::MainWindowBase(QWidget *parent, const char *name, WFlags fl) |
17 | : QMainWindow(parent, name, fl) | 17 | : QMainWindow(parent, name, fl) |
18 | { | 18 | { |
19 | setCaption(tr("E-Mail")); | 19 | setCaption(tr("E-Mail")); |
20 | setToolBarsMovable(false); | 20 | setToolBarsMovable(false); |
21 | 21 | ||
22 | toolbar = new QPEToolBar(this); | 22 | toolbar = new QPEToolBar(this); |
23 | menubar = new QPEMenuBar( toolbar ); | 23 | menubar = new QMenuBar( toolbar ); |
24 | mailmenu = new QPopupMenu( menubar ); | 24 | mailmenu = new QPopupMenu( menubar ); |
25 | servermenu = new QPopupMenu( menubar ); | 25 | servermenu = new QPopupMenu( menubar ); |
26 | menubar->insertItem( tr( "Mail" ), mailmenu ); | 26 | menubar->insertItem( tr( "Mail" ), mailmenu ); |
27 | menubar->insertItem( tr( "Servers" ), servermenu ); | 27 | menubar->insertItem( tr( "Servers" ), servermenu ); |
28 | 28 | ||
29 | addToolBar(toolbar); | 29 | addToolBar(toolbar); |
30 | toolbar->setHorizontalStretchable(true); | 30 | toolbar->setHorizontalStretchable(true); |
31 | 31 | ||
32 | QLabel *spacer = new QLabel(toolbar); | 32 | QLabel *spacer = new QLabel(toolbar); |
33 | spacer->setBackgroundMode(QWidget::PaletteButton); | 33 | spacer->setBackgroundMode(QWidget::PaletteButton); |
34 | toolbar->setStretchableWidget(spacer); | 34 | toolbar->setStretchableWidget(spacer); |
35 | 35 | ||
36 | compose = new QAction(tr("Compose new mail"), QIconSet(Resource::loadPixmap("mail/newmail")), 0, 0, this); | 36 | compose = new QAction(tr("Compose new mail"), QIconSet(Resource::loadPixmap("mail/newmail")), 0, 0, this); |
37 | compose->addTo(toolbar); | 37 | compose->addTo(toolbar); |
38 | compose->addTo(mailmenu); | 38 | compose->addTo(mailmenu); |
39 | 39 | ||
40 | sendQueue = new QAction(tr("Send queued mails"), QIconSet(Resource::loadPixmap("mail/sendqueue")), 0, 0, this); | 40 | sendQueue = new QAction(tr("Send queued mails"), QIconSet(Resource::loadPixmap("mail/sendqueue")), 0, 0, this); |
41 | sendQueue->addTo(toolbar); | 41 | sendQueue->addTo(toolbar); |
42 | sendQueue->addTo(mailmenu); | 42 | sendQueue->addTo(mailmenu); |
43 | 43 | ||
44 | folders = new QAction(tr("Show/hide folders"), QIconSet(Resource::loadPixmap("mail/folder")), 0, 0, this, 0, true); | 44 | folders = new QAction(tr("Show/hide folders"), QIconSet(Resource::loadPixmap("mail/folder")), 0, 0, this, 0, true); |
45 | folders->addTo(toolbar); | 45 | folders->addTo(toolbar); |
46 | folders->addTo(servermenu); | 46 | folders->addTo(servermenu); |
47 | connect(folders, SIGNAL(toggled(bool)), SLOT(slotFoldersToggled(bool))); | 47 | connect(folders, SIGNAL(toggled(bool)), SLOT(slotFoldersToggled(bool))); |
48 | 48 | ||
49 | findmails = new QAction(tr("Search mails"), QIconSet(Resource::loadPixmap("mail/find")), 0, 0, this); | 49 | findmails = new QAction(tr("Search mails"), QIconSet(Resource::loadPixmap("mail/find")), 0, 0, this); |
50 | findmails->addTo(toolbar); | 50 | findmails->addTo(toolbar); |
51 | findmails->addTo(mailmenu); | 51 | findmails->addTo(mailmenu); |
52 | 52 | ||
53 | configure = new QAction(tr("Configuration"), QIconSet(Resource::loadPixmap("mail/configure")), 0, 0, this); | 53 | configure = new QAction(tr("Configuration"), QIconSet(Resource::loadPixmap("mail/configure")), 0, 0, this); |
54 | configure->addTo(servermenu); | 54 | configure->addTo(servermenu); |
55 | 55 | ||
56 | QVBox *view = new QVBox(this); | 56 | QVBox *view = new QVBox(this); |
57 | setCentralWidget(view); | 57 | setCentralWidget(view); |
58 | 58 | ||
59 | folderView = new FolderWidget(view); | 59 | folderView = new FolderWidget(view); |
60 | folderView->setMinimumHeight(90); | 60 | folderView->setMinimumHeight(90); |
61 | folderView->setMaximumHeight(90); | 61 | folderView->setMaximumHeight(90); |
62 | folderView->hide(); | 62 | folderView->hide(); |
63 | 63 | ||
64 | mailView = new MailTable(view); | 64 | mailView = new MailTable(view); |
65 | mailView->setMinimumHeight(50); | 65 | mailView->setMinimumHeight(50); |
66 | 66 | ||
67 | status = new MailStatusBar(view); | 67 | status = new MailStatusBar(view); |
68 | } | 68 | } |
69 | 69 | ||
70 | void MainWindowBase::slotFoldersToggled(bool toggled) | 70 | void MainWindowBase::slotFoldersToggled(bool toggled) |
71 | { | 71 | { |
72 | if (folderView->isHidden() && toggled) folderView->show(); | 72 | if (folderView->isHidden() && toggled) folderView->show(); |
73 | if (!folderView->isHidden() && !toggled) folderView->hide(); | 73 | if (!folderView->isHidden() && !toggled) folderView->hide(); |
74 | } | 74 | } |
75 | 75 | ||
diff --git a/noncore/unsupported/mail2/mainwindowbase.h b/noncore/unsupported/mail2/mainwindowbase.h index 11c5ea0..b2e1dc5 100644 --- a/noncore/unsupported/mail2/mainwindowbase.h +++ b/noncore/unsupported/mail2/mainwindowbase.h | |||
@@ -1,37 +1,37 @@ | |||
1 | #ifndef MAINWINDOWBASE_H | 1 | #ifndef MAINWINDOWBASE_H |
2 | #define MAINWINDOWBASE_H | 2 | #define MAINWINDOWBASE_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | 5 | ||
6 | class ServerConnection; | 6 | class ServerConnection; |
7 | class MailStatusBar; | 7 | class MailStatusBar; |
8 | class FolderWidget; | 8 | class FolderWidget; |
9 | class QPEToolBar; | 9 | class QPEToolBar; |
10 | class QPEMenuBar; | 10 | class QMenuBar; |
11 | class QPopupMenu; | 11 | class QPopupMenu; |
12 | class MailTable; | 12 | class MailTable; |
13 | class QAction; | 13 | class QAction; |
14 | 14 | ||
15 | class MainWindowBase : public QMainWindow | 15 | class MainWindowBase : public QMainWindow |
16 | { | 16 | { |
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | 18 | ||
19 | public: | 19 | public: |
20 | MainWindowBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); | 20 | MainWindowBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); |
21 | 21 | ||
22 | protected slots: | 22 | protected slots: |
23 | void slotFoldersToggled(bool toggled); | 23 | void slotFoldersToggled(bool toggled); |
24 | 24 | ||
25 | protected: | 25 | protected: |
26 | ServerConnection *serverConnection; | 26 | ServerConnection *serverConnection; |
27 | MailStatusBar *status; | 27 | MailStatusBar *status; |
28 | FolderWidget *folderView; | 28 | FolderWidget *folderView; |
29 | QPEToolBar *toolbar; | 29 | QPEToolBar *toolbar; |
30 | QPEMenuBar *menubar; | 30 | QMenuBar *menubar; |
31 | QPopupMenu *mailmenu, *servermenu; | 31 | QPopupMenu *mailmenu, *servermenu; |
32 | MailTable *mailView; | 32 | MailTable *mailView; |
33 | QAction *compose, *sendQueue, *folders, *findmails, *configure; | 33 | QAction *compose, *sendQueue, *folders, *findmails, *configure; |
34 | 34 | ||
35 | }; | 35 | }; |
36 | 36 | ||
37 | #endif | 37 | #endif |
diff --git a/noncore/unsupported/mail2/viewmailbase.cpp b/noncore/unsupported/mail2/viewmailbase.cpp index a02f73a..10aa14d 100644 --- a/noncore/unsupported/mail2/viewmailbase.cpp +++ b/noncore/unsupported/mail2/viewmailbase.cpp | |||
@@ -1,75 +1,75 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qlistview.h> | 2 | #include <qlistview.h> |
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qvbox.h> | 5 | #include <qvbox.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | 7 | ||
8 | #include <qpe/qpetoolbar.h> | 8 | #include <qpe/qpetoolbar.h> |
9 | #include <qpe/qpemenubar.h> | 9 | #include <qpe/qpemenubar.h> |
10 | #include <qpe/resource.h> | 10 | #include <qpe/resource.h> |
11 | 11 | ||
12 | #include "viewmailbase.h" | 12 | #include "viewmailbase.h" |
13 | #include "opendiag.h" | 13 | #include "opendiag.h" |
14 | 14 | ||
15 | ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) | 15 | ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) |
16 | : QMainWindow(parent, name, fl) | 16 | : QMainWindow(parent, name, fl) |
17 | { | 17 | { |
18 | setCaption(tr("E-Mail by %1")); | 18 | setCaption(tr("E-Mail by %1")); |
19 | setToolBarsMovable(false); | 19 | setToolBarsMovable(false); |
20 | 20 | ||
21 | toolbar = new QPEToolBar(this); | 21 | toolbar = new QPEToolBar(this); |
22 | menubar = new QPEMenuBar( toolbar ); | 22 | menubar = new QMenuBar( toolbar ); |
23 | mailmenu = new QPopupMenu( menubar ); | 23 | mailmenu = new QPopupMenu( menubar ); |
24 | menubar->insertItem( tr( "Mail" ), mailmenu ); | 24 | menubar->insertItem( tr( "Mail" ), mailmenu ); |
25 | 25 | ||
26 | toolbar->setHorizontalStretchable(true); | 26 | toolbar->setHorizontalStretchable(true); |
27 | addToolBar(toolbar); | 27 | addToolBar(toolbar); |
28 | 28 | ||
29 | QLabel *spacer = new QLabel(toolbar); | 29 | QLabel *spacer = new QLabel(toolbar); |
30 | spacer->setBackgroundMode(QWidget::PaletteButton); | 30 | spacer->setBackgroundMode(QWidget::PaletteButton); |
31 | toolbar->setStretchableWidget(spacer); | 31 | toolbar->setStretchableWidget(spacer); |
32 | 32 | ||
33 | reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this); | 33 | reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this); |
34 | reply->addTo(toolbar); | 34 | reply->addTo(toolbar); |
35 | reply->addTo(mailmenu); | 35 | reply->addTo(mailmenu); |
36 | 36 | ||
37 | forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this); | 37 | forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this); |
38 | forward->addTo(toolbar); | 38 | forward->addTo(toolbar); |
39 | forward->addTo(mailmenu); | 39 | forward->addTo(mailmenu); |
40 | 40 | ||
41 | attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); | 41 | attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); |
42 | attachbutton->addTo(toolbar); | 42 | attachbutton->addTo(toolbar); |
43 | attachbutton->addTo(mailmenu); | 43 | attachbutton->addTo(mailmenu); |
44 | connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); | 44 | connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); |
45 | 45 | ||
46 | deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); | 46 | deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); |
47 | deleteMail->addTo(toolbar); | 47 | deleteMail->addTo(toolbar); |
48 | deleteMail->addTo(mailmenu); | 48 | deleteMail->addTo(mailmenu); |
49 | 49 | ||
50 | QVBox *view = new QVBox(this); | 50 | QVBox *view = new QVBox(this); |
51 | setCentralWidget(view); | 51 | setCentralWidget(view); |
52 | 52 | ||
53 | attachments = new QListView(view); | 53 | attachments = new QListView(view); |
54 | attachments->setMinimumHeight(90); | 54 | attachments->setMinimumHeight(90); |
55 | attachments->setMaximumHeight(90); | 55 | attachments->setMaximumHeight(90); |
56 | attachments->setAllColumnsShowFocus(true); | 56 | attachments->setAllColumnsShowFocus(true); |
57 | attachments->addColumn("Mime Type", 100); | 57 | attachments->addColumn("Mime Type", 100); |
58 | attachments->addColumn("Filename", 100); | 58 | attachments->addColumn("Filename", 100); |
59 | attachments->addColumn("Description", 100); | 59 | attachments->addColumn("Description", 100); |
60 | attachments->hide(); | 60 | attachments->hide(); |
61 | 61 | ||
62 | browser = new QTextBrowser(view); | 62 | browser = new QTextBrowser(view); |
63 | 63 | ||
64 | openDiag = new OpenDiag(view); | 64 | openDiag = new OpenDiag(view); |
65 | openDiag->hide(); | 65 | openDiag->hide(); |
66 | 66 | ||
67 | } | 67 | } |
68 | 68 | ||
69 | void ViewMailBase::slotChangeAttachview(bool state) | 69 | void ViewMailBase::slotChangeAttachview(bool state) |
70 | { | 70 | { |
71 | if (state) attachments->show(); | 71 | if (state) attachments->show(); |
72 | else attachments->hide(); | 72 | else attachments->hide(); |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
diff --git a/noncore/unsupported/mail2/viewmailbase.h b/noncore/unsupported/mail2/viewmailbase.h index ba82017..6e55021 100644 --- a/noncore/unsupported/mail2/viewmailbase.h +++ b/noncore/unsupported/mail2/viewmailbase.h | |||
@@ -1,36 +1,36 @@ | |||
1 | #ifndef VIEWMAILBASE_H | 1 | #ifndef VIEWMAILBASE_H |
2 | #define VIEWMAILBASE_H | 2 | #define VIEWMAILBASE_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | 5 | ||
6 | class QAction; | 6 | class QAction; |
7 | class OpenDiag; | 7 | class OpenDiag; |
8 | class QListView; | 8 | class QListView; |
9 | class QPEToolBar; | 9 | class QPEToolBar; |
10 | class QTextBrowser; | 10 | class QTextBrowser; |
11 | class QPEMenuBar; | 11 | class QMenuBar; |
12 | class QPopupMenu; | 12 | class QPopupMenu; |
13 | 13 | ||
14 | class ViewMailBase : public QMainWindow | 14 | class ViewMailBase : public QMainWindow |
15 | { | 15 | { |
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | 17 | ||
18 | public: | 18 | public: |
19 | ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); | 19 | ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); |
20 | 20 | ||
21 | protected: | 21 | protected: |
22 | QAction *reply, *forward, *attachbutton, *deleteMail; | 22 | QAction *reply, *forward, *attachbutton, *deleteMail; |
23 | QListView *attachments; | 23 | QListView *attachments; |
24 | QPEToolBar *toolbar; | 24 | QPEToolBar *toolbar; |
25 | QTextBrowser *browser; | 25 | QTextBrowser *browser; |
26 | OpenDiag *openDiag; | 26 | OpenDiag *openDiag; |
27 | QPEMenuBar *menubar; | 27 | QMenuBar *menubar; |
28 | QPopupMenu *mailmenu; | 28 | QPopupMenu *mailmenu; |
29 | 29 | ||
30 | protected slots: | 30 | protected slots: |
31 | void slotChangeAttachview(bool state); | 31 | void slotChangeAttachview(bool state); |
32 | 32 | ||
33 | }; | 33 | }; |
34 | 34 | ||
35 | #endif | 35 | #endif |
36 | 36 | ||
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp index 04362d3..6930d60 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp | |||
@@ -1,342 +1,342 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | // Copyright (C) 2000 Trolltech AS. | 9 | // Copyright (C) 2000 Trolltech AS. |
10 | // adadpted form qpe/qipkg | 10 | // adadpted form qpe/qipkg |
11 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 11 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
12 | 12 | ||
13 | 13 | ||
14 | #include "mainwindow.h" | 14 | #include "mainwindow.h" |
15 | 15 | ||
16 | #include <qpe/qpemenubar.h> | 16 | #include <qmenubar.h> |
17 | #include <qpe/qpemessagebox.h> | 17 | #include <qpe/qpemessagebox.h> |
18 | #include <qpe/resource.h> | 18 | #include <qpe/resource.h> |
19 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
20 | #include <qpe/qpetoolbar.h> | 20 | #include <qpe/qpetoolbar.h> |
21 | #include <qpe/qcopenvelope_qws.h> | 21 | #include <qpe/qcopenvelope_qws.h> |
22 | #include <qaction.h> | 22 | #include <qaction.h> |
23 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
24 | #include <qpopupmenu.h> | 24 | #include <qpopupmenu.h> |
25 | #include <qtoolbutton.h> | 25 | #include <qtoolbutton.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qfile.h> | 28 | #include <qfile.h> |
29 | #include <qlistview.h> | 29 | #include <qlistview.h> |
30 | #include <qtextview.h> | 30 | #include <qtextview.h> |
31 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qtabwidget.h> | 33 | #include <qtabwidget.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #include <qpushbutton.h> | 36 | #include <qpushbutton.h> |
37 | #include <qlayout.h> | 37 | #include <qlayout.h> |
38 | 38 | ||
39 | #include "pksettingsbase.h" | 39 | #include "pksettingsbase.h" |
40 | #include "utils.h" | 40 | #include "utils.h" |
41 | #include "packagelistitem.h" | 41 | #include "packagelistitem.h" |
42 | 42 | ||
43 | 43 | ||
44 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | 44 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : |
45 | QMainWindow( parent, name, f ) | 45 | QMainWindow( parent, name, f ) |
46 | // packageListServers( QObject(parent), name ), | 46 | // packageListServers( QObject(parent), name ), |
47 | // packageListSearch( parent, name ), | 47 | // packageListSearch( parent, name ), |
48 | // packageListDocLnk( parent, name ) | 48 | // packageListDocLnk( parent, name ) |
49 | { | 49 | { |
50 | setCaption( tr("Package Manager") ); | 50 | setCaption( tr("Package Manager") ); |
51 | settings = new PackageManagerSettings(this,0,TRUE); | 51 | settings = new PackageManagerSettings(this,0,TRUE); |
52 | listViewPackages = new PackageListView( this,"listViewPackages",settings ); | 52 | listViewPackages = new PackageListView( this,"listViewPackages",settings ); |
53 | setCentralWidget( listViewPackages ); | 53 | setCentralWidget( listViewPackages ); |
54 | listViewPackages->addList( tr("feeds"), &packageListServers ); | 54 | listViewPackages->addList( tr("feeds"), &packageListServers ); |
55 | listViewPackages->addList( tr("ipkgfind&killefiz"), &packageListSearch ); | 55 | listViewPackages->addList( tr("ipkgfind&killefiz"), &packageListSearch ); |
56 | listViewPackages->addList( tr("documents"), &packageListDocLnk ); | 56 | listViewPackages->addList( tr("documents"), &packageListDocLnk ); |
57 | ipkg = new PmIpkg( settings, this ); | 57 | ipkg = new PmIpkg( settings, this ); |
58 | packageListServers.setSettings( settings ); | 58 | packageListServers.setSettings( settings ); |
59 | packageListSearch.setSettings( settings ); | 59 | packageListSearch.setSettings( settings ); |
60 | packageListDocLnk.setSettings( settings ); | 60 | packageListDocLnk.setSettings( settings ); |
61 | pvDebug(9,"packageListServers.update"); | 61 | pvDebug(9,"packageListServers.update"); |
62 | packageListServers.update(); | 62 | packageListServers.update(); |
63 | pvDebug(9,"packageListDocLnk.update"); | 63 | pvDebug(9,"packageListDocLnk.update"); |
64 | packageListDocLnk.update(); | 64 | packageListDocLnk.update(); |
65 | pvDebug(9,"makeMenu"); | 65 | pvDebug(9,"makeMenu"); |
66 | makeMenu(); | 66 | makeMenu(); |
67 | makeChannel(); | 67 | makeChannel(); |
68 | 68 | ||
69 | 69 | ||
70 | connect( section, SIGNAL(activated(int)), SLOT(sectionChanged()) ); | 70 | connect( section, SIGNAL(activated(int)), SLOT(sectionChanged()) ); |
71 | connect( subsection, SIGNAL(activated(int)), SLOT(subSectionChanged()) ); | 71 | connect( subsection, SIGNAL(activated(int)), SLOT(subSectionChanged()) ); |
72 | 72 | ||
73 | connect( settings->removeLinksButton, SIGNAL( clicked()), | 73 | connect( settings->removeLinksButton, SIGNAL( clicked()), |
74 | SLOT(removeLinks()) ); | 74 | SLOT(removeLinks()) ); |
75 | connect( settings->createLinksButton, SIGNAL( clicked()), | 75 | connect( settings->createLinksButton, SIGNAL( clicked()), |
76 | SLOT(createLinks()) ); | 76 | SLOT(createLinks()) ); |
77 | 77 | ||
78 | pvDebug(9,"displayList"); | 78 | pvDebug(9,"displayList"); |
79 | displayList(); | 79 | displayList(); |
80 | } | 80 | } |
81 | 81 | ||
82 | void MainWindow::makeMenu() | 82 | void MainWindow::makeMenu() |
83 | { | 83 | { |
84 | 84 | ||
85 | QPEToolBar *toolBar = new QPEToolBar( this ); | 85 | QPEToolBar *toolBar = new QPEToolBar( this ); |
86 | QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); | 86 | QMenuBar *menuBar = new QMenuBar( toolBar ); |
87 | QPopupMenu *srvMenu = new QPopupMenu( menuBar ); | 87 | QPopupMenu *srvMenu = new QPopupMenu( menuBar ); |
88 | QPopupMenu *viewMenu = new QPopupMenu( menuBar ); | 88 | QPopupMenu *viewMenu = new QPopupMenu( menuBar ); |
89 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); | 89 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); |
90 | QPopupMenu *helpMenu = new QPopupMenu( menuBar ); | 90 | QPopupMenu *helpMenu = new QPopupMenu( menuBar ); |
91 | 91 | ||
92 | setToolBarsMovable( false ); | 92 | setToolBarsMovable( false ); |
93 | toolBar->setHorizontalStretchable( true ); | 93 | toolBar->setHorizontalStretchable( true ); |
94 | menuBar->insertItem( tr( "Package" ), srvMenu ); | 94 | menuBar->insertItem( tr( "Package" ), srvMenu ); |
95 | menuBar->insertItem( tr( "View" ), viewMenu ); | 95 | menuBar->insertItem( tr( "View" ), viewMenu ); |
96 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); | 96 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); |
97 | menuBar->insertItem( tr( "Help" ), helpMenu ); | 97 | menuBar->insertItem( tr( "Help" ), helpMenu ); |
98 | 98 | ||
99 | // QLabel *spacer; | 99 | // QLabel *spacer; |
100 | // spacer = new QLabel( "", toolBar ); | 100 | // spacer = new QLabel( "", toolBar ); |
101 | // spacer->setBackgroundColor( toolBar->backgroundColor() ); | 101 | // spacer->setBackgroundColor( toolBar->backgroundColor() ); |
102 | // toolBar->setStretchableWidget( spacer ); | 102 | // toolBar->setStretchableWidget( spacer ); |
103 | 103 | ||
104 | 104 | ||
105 | runAction = new QAction( tr( "Apply" ), | 105 | runAction = new QAction( tr( "Apply" ), |
106 | Resource::loadPixmap( "oipkg/install" ), | 106 | Resource::loadPixmap( "oipkg/install" ), |
107 | QString::null, 0, this, 0 ); | 107 | QString::null, 0, this, 0 ); |
108 | connect( runAction, SIGNAL( activated() ), | 108 | connect( runAction, SIGNAL( activated() ), |
109 | this, SLOT( runIpkg() ) ); | 109 | this, SLOT( runIpkg() ) ); |
110 | runAction->addTo( toolBar ); | 110 | runAction->addTo( toolBar ); |
111 | runAction->addTo( srvMenu ); | 111 | runAction->addTo( srvMenu ); |
112 | 112 | ||
113 | srvMenu->insertSeparator(); | 113 | srvMenu->insertSeparator(); |
114 | 114 | ||
115 | updateAction = new QAction( tr( "Update" ), | 115 | updateAction = new QAction( tr( "Update" ), |
116 | Resource::loadIconSet( "oipkg/update" ), | 116 | Resource::loadIconSet( "oipkg/update" ), |
117 | QString::null, 0, this, 0 ); | 117 | QString::null, 0, this, 0 ); |
118 | connect( updateAction, SIGNAL( activated() ), | 118 | connect( updateAction, SIGNAL( activated() ), |
119 | this , SLOT( updateList() ) ); | 119 | this , SLOT( updateList() ) ); |
120 | updateAction->addTo( toolBar ); | 120 | updateAction->addTo( toolBar ); |
121 | updateAction->addTo( srvMenu ); | 121 | updateAction->addTo( srvMenu ); |
122 | 122 | ||
123 | QAction *cfgact; | 123 | QAction *cfgact; |
124 | 124 | ||
125 | cfgact = new QAction( tr( "Setups" ), | 125 | cfgact = new QAction( tr( "Setups" ), |
126 | QString::null, 0, this, 0 ); | 126 | QString::null, 0, this, 0 ); |
127 | connect( cfgact, SIGNAL( activated() ), | 127 | connect( cfgact, SIGNAL( activated() ), |
128 | SLOT( showSettingsSetup() ) ); | 128 | SLOT( showSettingsSetup() ) ); |
129 | cfgact->addTo( cfgMenu ); | 129 | cfgact->addTo( cfgMenu ); |
130 | 130 | ||
131 | cfgact = new QAction( tr( "Servers" ), | 131 | cfgact = new QAction( tr( "Servers" ), |
132 | QString::null, 0, this, 0 ); | 132 | QString::null, 0, this, 0 ); |
133 | connect( cfgact, SIGNAL( activated() ), | 133 | connect( cfgact, SIGNAL( activated() ), |
134 | SLOT( showSettingsSrv() ) ); | 134 | SLOT( showSettingsSrv() ) ); |
135 | cfgact->addTo( cfgMenu ); | 135 | cfgact->addTo( cfgMenu ); |
136 | cfgact = new QAction( tr( "Destinations" ), | 136 | cfgact = new QAction( tr( "Destinations" ), |
137 | QString::null, 0, this, 0 ); | 137 | QString::null, 0, this, 0 ); |
138 | connect( cfgact, SIGNAL( activated() ), | 138 | connect( cfgact, SIGNAL( activated() ), |
139 | SLOT( showSettingsDst() ) ); | 139 | SLOT( showSettingsDst() ) ); |
140 | cfgact->addTo( cfgMenu ); | 140 | cfgact->addTo( cfgMenu ); |
141 | 141 | ||
142 | QAction *a; | 142 | QAction *a; |
143 | 143 | ||
144 | // SECTIONS | 144 | // SECTIONS |
145 | sectionBar = new QPEToolBar( this ); | 145 | sectionBar = new QPEToolBar( this ); |
146 | addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); | 146 | addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); |
147 | sectionBar->setHorizontalStretchable( true ); | 147 | sectionBar->setHorizontalStretchable( true ); |
148 | QLabel *label = new QLabel( sectionBar, "section" ); | 148 | QLabel *label = new QLabel( sectionBar, "section" ); |
149 | // label->setBackgroundMode( NoBackground ); | 149 | // label->setBackgroundMode( NoBackground ); |
150 | label->font().setPointSize( 8 ); | 150 | label->font().setPointSize( 8 ); |
151 | label->setText( tr( "Section:" ) ); | 151 | label->setText( tr( "Section:" ) ); |
152 | sectionBar->setStretchableWidget( label ); | 152 | sectionBar->setStretchableWidget( label ); |
153 | section = new QComboBox( false, sectionBar ); | 153 | section = new QComboBox( false, sectionBar ); |
154 | section->font().setPointSize( 8 ); | 154 | section->font().setPointSize( 8 ); |
155 | label = new QLabel( " / ", sectionBar ); | 155 | label = new QLabel( " / ", sectionBar ); |
156 | label->font().setPointSize( 8 ); | 156 | label->font().setPointSize( 8 ); |
157 | // label->setBackgroundMode( PaletteForeground ); | 157 | // label->setBackgroundMode( PaletteForeground ); |
158 | subsection = new QComboBox( false, sectionBar ); | 158 | subsection = new QComboBox( false, sectionBar ); |
159 | subsection->font().setPointSize( 8 ); | 159 | subsection->font().setPointSize( 8 ); |
160 | a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 160 | a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
161 | connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); | 161 | connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); |
162 | a->addTo( sectionBar ); | 162 | a->addTo( sectionBar ); |
163 | setSections(); | 163 | setSections(); |
164 | setSubSections(); | 164 | setSubSections(); |
165 | sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); | 165 | sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); |
166 | connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); | 166 | connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); |
167 | sectionAction->setToggleAction( true ); | 167 | sectionAction->setToggleAction( true ); |
168 | sectionAction->addTo( viewMenu ); | 168 | sectionAction->addTo( viewMenu ); |
169 | // sectionBar->setStretchableWidget( section ); | 169 | // sectionBar->setStretchableWidget( section ); |
170 | 170 | ||
171 | //FIND | 171 | //FIND |
172 | findBar = new QPEToolBar(this); | 172 | findBar = new QPEToolBar(this); |
173 | addToolBar( findBar, "Filter", QMainWindow::Top, TRUE ); | 173 | addToolBar( findBar, "Filter", QMainWindow::Top, TRUE ); |
174 | label = new QLabel( tr("Filter: "), findBar ); | 174 | label = new QLabel( tr("Filter: "), findBar ); |
175 | // label->setBackgroundMode( PaletteForeground ); | 175 | // label->setBackgroundMode( PaletteForeground ); |
176 | findBar->setHorizontalStretchable( TRUE ); | 176 | findBar->setHorizontalStretchable( TRUE ); |
177 | findEdit = new QLineEdit( findBar, "findEdit" ); | 177 | findEdit = new QLineEdit( findBar, "findEdit" ); |
178 | findBar->setStretchableWidget( findEdit ); | 178 | findBar->setStretchableWidget( findEdit ); |
179 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), | 179 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), |
180 | this, SLOT( displayList() ) ); | 180 | this, SLOT( displayList() ) ); |
181 | a = new QAction( tr( "Clear Find" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 181 | a = new QAction( tr( "Clear Find" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
182 | connect( a, SIGNAL( activated() ), findEdit, SLOT( clear() ) ); | 182 | connect( a, SIGNAL( activated() ), findEdit, SLOT( clear() ) ); |
183 | a->addTo( findBar ); | 183 | a->addTo( findBar ); |
184 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 184 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
185 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 185 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
186 | a->addTo( findBar ); | 186 | a->addTo( findBar ); |
187 | findAction = new QAction( tr( "Filter" ), QString::null, 0, this, 0 ); | 187 | findAction = new QAction( tr( "Filter" ), QString::null, 0, this, 0 ); |
188 | connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); | 188 | connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); |
189 | findAction->setToggleAction( true ); | 189 | findAction->setToggleAction( true ); |
190 | findAction->addTo( viewMenu ); | 190 | findAction->addTo( viewMenu ); |
191 | 191 | ||
192 | //SEARCH | 192 | //SEARCH |
193 | searchBar = new QPEToolBar(this); | 193 | searchBar = new QPEToolBar(this); |
194 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 194 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
195 | label = new QLabel( tr("Search: "), searchBar ); | 195 | label = new QLabel( tr("Search: "), searchBar ); |
196 | // label->setBackgroundMode( PaletteForeground ); | 196 | // label->setBackgroundMode( PaletteForeground ); |
197 | searchBar->setHorizontalStretchable( TRUE ); | 197 | searchBar->setHorizontalStretchable( TRUE ); |
198 | searchEdit = new QLineEdit( searchBar, "seachEdit" ); | 198 | searchEdit = new QLineEdit( searchBar, "seachEdit" ); |
199 | searchBar->setStretchableWidget( searchEdit ); | 199 | searchBar->setStretchableWidget( searchEdit ); |
200 | // connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 200 | // connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
201 | // this, SLOT( displayList() ) ); | 201 | // this, SLOT( displayList() ) ); |
202 | a = new QAction( tr( "Clear Search" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 202 | a = new QAction( tr( "Clear Search" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
203 | connect( a, SIGNAL( activated() ), searchEdit, SLOT( clear() ) ); | 203 | connect( a, SIGNAL( activated() ), searchEdit, SLOT( clear() ) ); |
204 | a->addTo( searchBar ); | 204 | a->addTo( searchBar ); |
205 | searchCommit = new QAction( tr( "Do Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 205 | searchCommit = new QAction( tr( "Do Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
206 | connect( searchCommit, SIGNAL( activated() ), SLOT( remotePackageQuery() ) ); | 206 | connect( searchCommit, SIGNAL( activated() ), SLOT( remotePackageQuery() ) ); |
207 | searchCommit->addTo( searchBar ); | 207 | searchCommit->addTo( searchBar ); |
208 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 208 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
209 | connect( a, SIGNAL( activated() ), this, SLOT( searchClose() ) ); | 209 | connect( a, SIGNAL( activated() ), this, SLOT( searchClose() ) ); |
210 | a->addTo( searchBar ); | 210 | a->addTo( searchBar ); |
211 | searchAction = new QAction( tr( "Search" ), QString::null, 0, this, 0 ); | 211 | searchAction = new QAction( tr( "Search" ), QString::null, 0, this, 0 ); |
212 | connect( searchAction, SIGNAL( toggled(bool) ), this, SLOT( searchShow(bool) ) ); | 212 | connect( searchAction, SIGNAL( toggled(bool) ), this, SLOT( searchShow(bool) ) ); |
213 | searchAction->setToggleAction( true ); | 213 | searchAction->setToggleAction( true ); |
214 | searchAction->addTo( viewMenu ); | 214 | searchAction->addTo( viewMenu ); |
215 | 215 | ||
216 | //DEST | 216 | //DEST |
217 | destBar = new QPEToolBar(this); | 217 | destBar = new QPEToolBar(this); |
218 | addToolBar( destBar, "Destination", QMainWindow::Top, TRUE ); | 218 | addToolBar( destBar, "Destination", QMainWindow::Top, TRUE ); |
219 | label = new QLabel( tr("Destination: "), destBar ); | 219 | label = new QLabel( tr("Destination: "), destBar ); |
220 | // label->setBackgroundMode( PaletteForeground ); | 220 | // label->setBackgroundMode( PaletteForeground ); |
221 | destBar->setHorizontalStretchable( TRUE ); | 221 | destBar->setHorizontalStretchable( TRUE ); |
222 | destination = new QComboBox( false, destBar ); | 222 | destination = new QComboBox( false, destBar ); |
223 | destination->insertStringList( settings->getDestinationNames() ); | 223 | destination->insertStringList( settings->getDestinationNames() ); |
224 | setComboName(destination,settings->getDestinationName()); | 224 | setComboName(destination,settings->getDestinationName()); |
225 | connect( destination, SIGNAL(activated(int)), | 225 | connect( destination, SIGNAL(activated(int)), |
226 | settings, SLOT(activeDestinationChange(int)) ); | 226 | settings, SLOT(activeDestinationChange(int)) ); |
227 | // space->setBackgroundMode( PaletteForeground ); | 227 | // space->setBackgroundMode( PaletteForeground ); |
228 | CheckBoxLink = new QCheckBox( tr("Link"), destBar); | 228 | CheckBoxLink = new QCheckBox( tr("Link"), destBar); |
229 | // CheckBoxLink->setBackgroundMode( PaletteForeground ); | 229 | // CheckBoxLink->setBackgroundMode( PaletteForeground ); |
230 | CheckBoxLink->setChecked( settings->createLinks() ); | 230 | CheckBoxLink->setChecked( settings->createLinks() ); |
231 | connect( CheckBoxLink, SIGNAL(toggled(bool)), | 231 | connect( CheckBoxLink, SIGNAL(toggled(bool)), |
232 | settings, SLOT(linkEnabled(bool)) ); | 232 | settings, SLOT(linkEnabled(bool)) ); |
233 | destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); | 233 | destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); |
234 | connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) ); | 234 | connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) ); |
235 | a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 235 | a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
236 | connect( a, SIGNAL( activated() ), SLOT( destClose() ) ); | 236 | connect( a, SIGNAL( activated() ), SLOT( destClose() ) ); |
237 | a->addTo( destBar ); | 237 | a->addTo( destBar ); |
238 | destBar->setStretchableWidget( CheckBoxLink ); | 238 | destBar->setStretchableWidget( CheckBoxLink ); |
239 | destAction->setToggleAction( true ); | 239 | destAction->setToggleAction( true ); |
240 | destAction->addTo( viewMenu ); | 240 | destAction->addTo( viewMenu ); |
241 | 241 | ||
242 | // helpMenu | 242 | // helpMenu |
243 | helpMenu->insertSeparator(); | 243 | helpMenu->insertSeparator(); |
244 | a = new QAction( tr( "Package Actions" ), QString::null, 0, this, 0 ); | 244 | a = new QAction( tr( "Package Actions" ), QString::null, 0, this, 0 ); |
245 | a->addTo( helpMenu ); | 245 | a->addTo( helpMenu ); |
246 | helpMenu->insertSeparator(); | 246 | helpMenu->insertSeparator(); |
247 | a = new QAction( tr( "Install" ), | 247 | a = new QAction( tr( "Install" ), |
248 | Resource::loadPixmap( "oipkg/install" ), QString::null, 0, this, 0 ); | 248 | Resource::loadPixmap( "oipkg/install" ), QString::null, 0, this, 0 ); |
249 | a->addTo( helpMenu ); | 249 | a->addTo( helpMenu ); |
250 | a = new QAction( tr( "Remove" ), | 250 | a = new QAction( tr( "Remove" ), |
251 | Resource::loadPixmap( "oipkg/uninstall" ), QString::null, 0, this, 0 ); | 251 | Resource::loadPixmap( "oipkg/uninstall" ), QString::null, 0, this, 0 ); |
252 | a->addTo( helpMenu ); | 252 | a->addTo( helpMenu ); |
253 | helpMenu->insertSeparator(); | 253 | helpMenu->insertSeparator(); |
254 | a = new QAction( tr( "Package Status" ), QString::null, 0, this, 0 ); | 254 | a = new QAction( tr( "Package Status" ), QString::null, 0, this, 0 ); |
255 | a->addTo( helpMenu ); | 255 | a->addTo( helpMenu ); |
256 | helpMenu->insertSeparator(); | 256 | helpMenu->insertSeparator(); |
257 | a = new QAction( tr( "New version, installed" ), | 257 | a = new QAction( tr( "New version, installed" ), |
258 | Resource::loadPixmap( "oipkg/installed" ), QString::null, 0, this, 0 ); | 258 | Resource::loadPixmap( "oipkg/installed" ), QString::null, 0, this, 0 ); |
259 | a->addTo( helpMenu ); | 259 | a->addTo( helpMenu ); |
260 | a = new QAction( tr( "New version, not installed" ), | 260 | a = new QAction( tr( "New version, not installed" ), |
261 | Resource::loadPixmap( "oipkg/uninstalled" ), QString::null, 0, this, 0 ); | 261 | Resource::loadPixmap( "oipkg/uninstalled" ), QString::null, 0, this, 0 ); |
262 | a->addTo( helpMenu ); | 262 | a->addTo( helpMenu ); |
263 | a = new QAction( tr( "Old version, installed" ), | 263 | a = new QAction( tr( "Old version, installed" ), |
264 | Resource::loadPixmap( "oipkg/installedOld" ), QString::null, 0, this, 0 ); | 264 | Resource::loadPixmap( "oipkg/installedOld" ), QString::null, 0, this, 0 ); |
265 | a->addTo( helpMenu ); | 265 | a->addTo( helpMenu ); |
266 | a = new QAction( tr( "Old version, not installed" ), | 266 | a = new QAction( tr( "Old version, not installed" ), |
267 | Resource::loadPixmap( "oipkg/uninstalledOld" ), QString::null, 0, this, 0 ); | 267 | Resource::loadPixmap( "oipkg/uninstalledOld" ), QString::null, 0, this, 0 ); |
268 | a->addTo( helpMenu ); | 268 | a->addTo( helpMenu ); |
269 | a = new QAction( tr( "Old version, new version installed" ), | 269 | a = new QAction( tr( "Old version, new version installed" ), |
270 | Resource::loadPixmap( "oipkg/uninstalledOldinstalledNew" ), QString::null, 0, this, 0 ); | 270 | Resource::loadPixmap( "oipkg/uninstalledOldinstalledNew" ), QString::null, 0, this, 0 ); |
271 | a->addTo( helpMenu ); | 271 | a->addTo( helpMenu ); |
272 | a = new QAction( tr( "New version, old version installed" ), | 272 | a = new QAction( tr( "New version, old version installed" ), |
273 | Resource::loadPixmap( "oipkg/uninstalledInstalledOld" ), QString::null, 0, this, 0 ); | 273 | Resource::loadPixmap( "oipkg/uninstalledInstalledOld" ), QString::null, 0, this, 0 ); |
274 | a->addTo( helpMenu ); | 274 | a->addTo( helpMenu ); |
275 | //a = new QAction( tr( "" ), | 275 | //a = new QAction( tr( "" ), |
276 | // Resource::loadPixmap( "oipkg/" ), QString::null, 0, this, 0 ); | 276 | // Resource::loadPixmap( "oipkg/" ), QString::null, 0, this, 0 ); |
277 | // a->addTo( helpMenu ); | 277 | // a->addTo( helpMenu ); |
278 | 278 | ||
279 | // configure the menus | 279 | // configure the menus |
280 | Config cfg( "oipkg", Config::User ); | 280 | Config cfg( "oipkg", Config::User ); |
281 | cfg.setGroup( "gui" ); | 281 | cfg.setGroup( "gui" ); |
282 | 282 | ||
283 | findShow( cfg.readBoolEntry( "findBar", true ) ); | 283 | findShow( cfg.readBoolEntry( "findBar", true ) ); |
284 | searchShow( cfg.readBoolEntry( "searchBar", true ) ); | 284 | searchShow( cfg.readBoolEntry( "searchBar", true ) ); |
285 | sectionShow( cfg.readBoolEntry( "sectionBar", true ) ); | 285 | sectionShow( cfg.readBoolEntry( "sectionBar", true ) ); |
286 | destShow( cfg.readBoolEntry( "destBar", false ) ); | 286 | destShow( cfg.readBoolEntry( "destBar", false ) ); |
287 | setComboName(section,cfg.readEntry("default_section")); | 287 | setComboName(section,cfg.readEntry("default_section")); |
288 | sectionChanged(); | 288 | sectionChanged(); |
289 | } | 289 | } |
290 | 290 | ||
291 | MainWindow::~MainWindow() | 291 | MainWindow::~MainWindow() |
292 | { | 292 | { |
293 | Config cfg( "oipkg", Config::User ); | 293 | Config cfg( "oipkg", Config::User ); |
294 | cfg.setGroup( "gui" ); | 294 | cfg.setGroup( "gui" ); |
295 | cfg.writeEntry( "findBar", !findBar->isHidden() ); | 295 | cfg.writeEntry( "findBar", !findBar->isHidden() ); |
296 | cfg.writeEntry( "searchBar", !searchBar->isHidden() ); | 296 | cfg.writeEntry( "searchBar", !searchBar->isHidden() ); |
297 | cfg.writeEntry( "sectionBar", !sectionBar->isHidden() ); | 297 | cfg.writeEntry( "sectionBar", !sectionBar->isHidden() ); |
298 | cfg.writeEntry( "destBar", !destBar->isHidden() ); | 298 | cfg.writeEntry( "destBar", !destBar->isHidden() ); |
299 | cfg.writeEntry( "default_section", section->currentText() ); | 299 | cfg.writeEntry( "default_section", section->currentText() ); |
300 | 300 | ||
301 | } | 301 | } |
302 | 302 | ||
303 | void MainWindow::runIpkg() | 303 | void MainWindow::runIpkg() |
304 | { | 304 | { |
305 | packageListServers.allPackages(); | 305 | packageListServers.allPackages(); |
306 | ipkg->loadList( &packageListSearch ); | 306 | ipkg->loadList( &packageListSearch ); |
307 | ipkg->loadList( &packageListDocLnk ); | 307 | ipkg->loadList( &packageListDocLnk ); |
308 | ipkg->loadList( &packageListServers ); | 308 | ipkg->loadList( &packageListServers ); |
309 | ipkg->commit(); | 309 | ipkg->commit(); |
310 | ipkg->clearLists(); | 310 | ipkg->clearLists(); |
311 | // ##### If we looked in the list of files, we could send out accurate | 311 | // ##### If we looked in the list of files, we could send out accurate |
312 | // ##### messages. But we don't bother yet, and just do an "all". | 312 | // ##### messages. But we don't bother yet, and just do an "all". |
313 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 313 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
314 | QString lf = QString::null; | 314 | QString lf = QString::null; |
315 | e << lf; | 315 | e << lf; |
316 | displayList(); | 316 | displayList(); |
317 | } | 317 | } |
318 | 318 | ||
319 | void MainWindow::updateList() | 319 | void MainWindow::updateList() |
320 | { | 320 | { |
321 | packageListServers.clear(); | 321 | packageListServers.clear(); |
322 | packageListSearch.clear(); | 322 | packageListSearch.clear(); |
323 | 323 | ||
324 | packageListDocLnk.clear(); | 324 | packageListDocLnk.clear(); |
325 | ipkg->update(); | 325 | ipkg->update(); |
326 | packageListServers.update(); | 326 | packageListServers.update(); |
327 | packageListSearch.update(); | 327 | packageListSearch.update(); |
328 | packageListDocLnk.update(); | 328 | packageListDocLnk.update(); |
329 | } | 329 | } |
330 | 330 | ||
331 | void MainWindow::filterList() | 331 | void MainWindow::filterList() |
332 | { | 332 | { |
333 | QString f = ""; | 333 | QString f = ""; |
334 | if ( findAction->isOn() ) f = findEdit->text(); | 334 | if ( findAction->isOn() ) f = findEdit->text(); |
335 | packageListServers.filterPackages( f ); | 335 | packageListServers.filterPackages( f ); |
336 | } | 336 | } |
337 | 337 | ||
338 | void MainWindow::displayList() | 338 | void MainWindow::displayList() |
339 | { | 339 | { |
340 | filterList(); | 340 | filterList(); |
341 | listViewPackages->display(); | 341 | listViewPackages->display(); |
342 | } | 342 | } |