-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle_1.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/pwmanager/pwmanager/pwmviewstyle_1.cpp b/pwmanager/pwmanager/pwmviewstyle_1.cpp index 6b9def3..27ad40e 100644 --- a/pwmanager/pwmanager/pwmviewstyle_1.cpp +++ b/pwmanager/pwmanager/pwmviewstyle_1.cpp | |||
@@ -1,139 +1,149 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2004 by Michael Buesch * | 3 | * copyright (C) 2004 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License version 2 * | 7 | * it under the terms of the GNU General Public License version 2 * |
8 | * as published by the Free Software Foundation. * | 8 | * as published by the Free Software Foundation. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | /*************************************************************************** | 12 | /*************************************************************************** |
13 | * copyright (C) 2004 by Ulf Schenk | 13 | * copyright (C) 2004 by Ulf Schenk |
14 | * This file is originaly based on version 1.0.1 of pwmanager | 14 | * This file is originaly based on version 1.0.1 of pwmanager |
15 | * and was modified to run on embedded devices that run microkde | 15 | * and was modified to run on embedded devices that run microkde |
16 | * | 16 | * |
17 | * $Id$ | 17 | * $Id$ |
18 | **************************************************************************/ | 18 | **************************************************************************/ |
19 | 19 | ||
20 | #include "pwmviewstyle_1.h" | 20 | #include "pwmviewstyle_1.h" |
21 | #include "pwmview.h" | 21 | #include "pwmview.h" |
22 | #include "listviewpwm.h" | 22 | #include "listviewpwm.h" |
23 | #include "commentbox.h" | 23 | #include "commentbox.h" |
24 | 24 | ||
25 | #include <klocale.h> | 25 | #include <klocale.h> |
26 | #include "pwmprefs.h" | 26 | #include "pwmprefs.h" |
27 | 27 | ||
28 | #ifndef DESKTOP_VERSION | 28 | #ifndef DESKTOP_VERSION |
29 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
30 | #else | 30 | #else |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | #endif | 32 | #endif |
33 | #define INITIAL_CATEGORIES_WIDTH100 | 33 | #define INITIAL_CATEGORIES_WIDTH100 |
34 | 34 | ||
35 | PwMViewStyle_1::PwMViewStyle_1(PwMView *view) | 35 | PwMViewStyle_1::PwMViewStyle_1(PwMView *view) |
36 | : QObject() | 36 | : QObject() |
37 | { | 37 | { |
38 | #ifndef PWM_EMBEDDED | 38 | #ifndef PWM_EMBEDDED |
39 | splitter = new QSplitter(view); | 39 | splitter = new QSplitter(view); |
40 | #else | 40 | #else |
41 | splitter = new KDGanttMinimizeSplitter( Qt::Horizontal, view); | 41 | if ( QApplication::desktop()->width() > 240 ) { |
42 | splitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Left ); | 42 | splitter = new KDGanttMinimizeSplitter( Qt::Horizontal, view); |
43 | 43 | splitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Left ); | |
44 | // topLayout = new QHBoxLayout( this ); | ||
45 | // mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | ||
46 | // mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | ||
47 | } else { | ||
48 | splitter = new KDGanttMinimizeSplitter( Qt::Vertical, view); | ||
49 | splitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | ||
50 | // topLayout = new QHBoxLayout( this ); | ||
51 | // mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | ||
52 | // mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | ||
53 | } | ||
44 | //US topLayout->addWidget(mMiniSplitter ); | 54 | //US topLayout->addWidget(mMiniSplitter ); |
45 | #endif | 55 | #endif |
46 | 56 | ||
47 | vbox1 = new QVBox(splitter); | 57 | vbox1 = new QVBox(splitter); |
48 | categoriesTitle = new QLabel(vbox1); | 58 | categoriesTitle = new QLabel(vbox1); |
49 | categoriesList = new QListBox(vbox1); | 59 | categoriesList = new QListBox(vbox1); |
50 | #ifndef PWM_EMBEDDED | 60 | #ifndef PWM_EMBEDDED |
51 | splitter2 = new QSplitter(splitter); | 61 | splitter2 = new QSplitter(splitter); |
52 | splitter2->setOrientation(Qt::Vertical); | 62 | splitter2->setOrientation(Qt::Vertical); |
53 | #else | 63 | #else |
54 | splitter2 = new KDGanttMinimizeSplitter( Qt::Vertical, splitter); | 64 | splitter2 = new KDGanttMinimizeSplitter( Qt::Vertical, splitter); |
55 | splitter2->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 65 | splitter2->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
56 | 66 | ||
57 | //US topLayout->addWidget(mMiniSplitter ); | 67 | //US topLayout->addWidget(mMiniSplitter ); |
58 | #endif | 68 | #endif |
59 | lv = new ListViewPwM(splitter2); | 69 | lv = new ListViewPwM(splitter2); |
60 | commentBox = new CommentBox(splitter2); | 70 | commentBox = new CommentBox(splitter2); |
61 | // set sizes and styles | 71 | // set sizes and styles |
62 | //UScommentBox->resize(commentBox->size().width(), 60); | 72 | //UScommentBox->resize(commentBox->size().width(), 60); |
63 | QValueList<int> sizes; | 73 | QValueList<int> sizes; |
64 | #ifndef PWM_EMBEDDED | 74 | #ifndef PWM_EMBEDDED |
65 | sizes.push_back(INITIAL_CATEGORIES_WIDTH); | 75 | sizes.push_back(INITIAL_CATEGORIES_WIDTH); |
66 | sizes.push_back(view->height() - INITIAL_CATEGORIES_WIDTH); | 76 | sizes.push_back(view->height() - INITIAL_CATEGORIES_WIDTH); |
67 | #else | 77 | #else |
68 | sizes.append(INITIAL_CATEGORIES_WIDTH); | 78 | sizes.append(INITIAL_CATEGORIES_WIDTH); |
69 | sizes.append(view->height() - INITIAL_CATEGORIES_WIDTH); | 79 | sizes.append(view->height() - INITIAL_CATEGORIES_WIDTH); |
70 | #endif | 80 | #endif |
71 | //USsplitter->setSizes(sizes); | 81 | //USsplitter->setSizes(sizes); |
72 | categoriesTitle->setAlignment(Qt::AlignHCenter); | 82 | categoriesTitle->setAlignment(Qt::AlignHCenter); |
73 | #ifndef PWM_EMBEDDED | 83 | #ifndef PWM_EMBEDDED |
74 | categoriesTitle->setFrameShape(QFrame::MenuBarPanel); | 84 | categoriesTitle->setFrameShape(QFrame::MenuBarPanel); |
75 | #else | 85 | #else |
76 | categoriesTitle->setFrameShape(QFrame::StyledPanel); | 86 | categoriesTitle->setFrameShape(QFrame::StyledPanel); |
77 | #endif | 87 | #endif |
78 | categoriesTitle->setText(i18n("Categories:")); | 88 | categoriesTitle->setText(i18n("Categories:")); |
79 | catCtxMenu = new QPopupMenu(view); | 89 | catCtxMenu = new QPopupMenu(view); |
80 | catCtxMenu->insertItem(i18n("&Rename"), | 90 | catCtxMenu->insertItem(i18n("&Rename"), |
81 | view, SLOT(renCatButton_slot())); | 91 | view, SLOT(renCatButton_slot())); |
82 | catCtxMenu->insertItem(i18n("&Delete"), | 92 | catCtxMenu->insertItem(i18n("&Delete"), |
83 | view, SLOT(delCatButton_slot())); | 93 | view, SLOT(delCatButton_slot())); |
84 | 94 | ||
85 | #ifndef DESKTOP_VERSION | 95 | #ifndef DESKTOP_VERSION |
86 | QPEApplication::setStylusOperation( categoriesList->viewport(), QPEApplication::RightOnHold ); | 96 | QPEApplication::setStylusOperation( categoriesList->viewport(), QPEApplication::RightOnHold ); |
87 | #endif | 97 | #endif |
88 | 98 | ||
89 | // connections | 99 | // connections |
90 | connect(categoriesList, SIGNAL(highlighted(int)), | 100 | connect(categoriesList, SIGNAL(highlighted(int)), |
91 | view, SLOT(shiftToView())); | 101 | view, SLOT(shiftToView())); |
92 | connect(categoriesList, | 102 | connect(categoriesList, |
93 | SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)), | 103 | SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)), |
94 | this, | 104 | this, |
95 | SLOT(catRightClick(QListBoxItem *, const QPoint &))); | 105 | SLOT(catRightClick(QListBoxItem *, const QPoint &))); |
96 | } | 106 | } |
97 | 107 | ||
98 | PwMViewStyle_1::~PwMViewStyle_1() | 108 | PwMViewStyle_1::~PwMViewStyle_1() |
99 | { | 109 | { |
100 | delete catCtxMenu; | 110 | delete catCtxMenu; |
101 | delete splitter; | 111 | delete splitter; |
102 | } | 112 | } |
103 | 113 | ||
104 | void PwMViewStyle_1::catRightClick(QListBoxItem *item, const QPoint &point) | 114 | void PwMViewStyle_1::catRightClick(QListBoxItem *item, const QPoint &point) |
105 | { | 115 | { |
106 | if (!item) | 116 | if (!item) |
107 | return; | 117 | return; |
108 | catCtxMenu->move(point); | 118 | catCtxMenu->move(point); |
109 | catCtxMenu->show(); | 119 | catCtxMenu->show(); |
110 | } | 120 | } |
111 | 121 | ||
112 | void PwMViewStyle_1::delCategory(const QString &cat) | 122 | void PwMViewStyle_1::delCategory(const QString &cat) |
113 | { | 123 | { |
114 | PWM_ASSERT(categoriesList); | 124 | PWM_ASSERT(categoriesList); |
115 | int i, count = categoriesList->count(); | 125 | int i, count = categoriesList->count(); |
116 | for (i = 0; i < count; ++i) { | 126 | for (i = 0; i < count; ++i) { |
117 | if (categoriesList->text(i) == cat) { | 127 | if (categoriesList->text(i) == cat) { |
118 | categoriesList->removeItem(i); | 128 | categoriesList->removeItem(i); |
119 | return; | 129 | return; |
120 | } | 130 | } |
121 | } | 131 | } |
122 | BUG(); | 132 | BUG(); |
123 | } | 133 | } |
124 | 134 | ||
125 | void PwMViewStyle_1::selectCategory(const QString &cat) | 135 | void PwMViewStyle_1::selectCategory(const QString &cat) |
126 | { | 136 | { |
127 | PWM_ASSERT(categoriesList); | 137 | PWM_ASSERT(categoriesList); |
128 | int i, count = categoriesList->count(); | 138 | int i, count = categoriesList->count(); |
129 | for (i = 0; i < count; ++i) { | 139 | for (i = 0; i < count; ++i) { |
130 | if (categoriesList->text(i) == cat) { | 140 | if (categoriesList->text(i) == cat) { |
131 | categoriesList->setCurrentItem(i); | 141 | categoriesList->setCurrentItem(i); |
132 | return; | 142 | return; |
133 | } | 143 | } |
134 | } | 144 | } |
135 | // fall back to 0 | 145 | // fall back to 0 |
136 | categoriesList->setCurrentItem(0); | 146 | categoriesList->setCurrentItem(0); |
137 | } | 147 | } |
138 | 148 | ||
139 | //US ENH: I need a place to load the view dependend settings. Eg. splittersize | 149 | //US ENH: I need a place to load the view dependend settings. Eg. splittersize |