author | ulf69 <ulf69> | 2004-09-15 17:53:22 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-15 17:53:22 (UTC) |
commit | d3925ba5bd25224bc4a60d3d6a107c464994a1ea (patch) (side-by-side diff) | |
tree | 60f69da1d2b79ee3081e7ef5c09a46470ca6eda0 /pwmanager/pwmanager/pwmviewstyle_1.cpp | |
parent | ce83a3479d23b9e8a59c745ccd0a0b14f64ef4e8 (diff) | |
download | kdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.zip kdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.tar.gz kdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.tar.bz2 |
initial revision
Diffstat (limited to 'pwmanager/pwmanager/pwmviewstyle_1.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle_1.cpp | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/pwmanager/pwmanager/pwmviewstyle_1.cpp b/pwmanager/pwmanager/pwmviewstyle_1.cpp new file mode 100644 index 0000000..4c24bc4 --- a/dev/null +++ b/pwmanager/pwmanager/pwmviewstyle_1.cpp @@ -0,0 +1,130 @@ +/*************************************************************************** + * * + * copyright (C) 2004 by Michael Buesch * + * email: mbuesch@freenet.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2 * + * as published by the Free Software Foundation. * + * * + ***************************************************************************/ + +/*************************************************************************** + * copyright (C) 2004 by Ulf Schenk + * This file is originaly based on version 1.0.1 of pwmanager + * and was modified to run on embedded devices that run microkde + * + * $Id$ + **************************************************************************/ + +#include "pwmviewstyle_1.h" +#include "pwmview.h" +#include "listviewpwm.h" +#include "commentbox.h" + +#include <klocale.h> + +#define INITIAL_CATEGORIES_WIDTH 100 + +PwMViewStyle_1::PwMViewStyle_1(PwMView *view) + : QObject() +{ +#ifndef PWM_EMBEDDED + splitter = new QSplitter(view); +#else + splitter = new KDGanttMinimizeSplitter( Qt::Horizontal, view); + splitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); + + //US topLayout->addWidget(mMiniSplitter ); +#endif + + vbox1 = new QVBox(splitter); + categoriesTitle = new QLabel(vbox1); + categoriesList = new QListBox(vbox1); +#ifndef PWM_EMBEDDED + splitter2 = new QSplitter(splitter); + splitter2->setOrientation(Qt::Vertical); +#else + splitter2 = new KDGanttMinimizeSplitter( Qt::Vertical, splitter); + splitter2->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); + + //US topLayout->addWidget(mMiniSplitter ); +#endif + lv = new ListViewPwM(splitter2); + commentBox = new CommentBox(splitter2); + // set sizes and styles + commentBox->resize(commentBox->size().width(), 60); + QValueList<int> sizes; +#ifndef PWM_EMBEDDED + sizes.push_back(INITIAL_CATEGORIES_WIDTH); + sizes.push_back(view->height() - INITIAL_CATEGORIES_WIDTH); +#else + sizes.append(INITIAL_CATEGORIES_WIDTH); + sizes.append(view->height() - INITIAL_CATEGORIES_WIDTH); +#endif + splitter->setSizes(sizes); + categoriesTitle->setAlignment(Qt::AlignHCenter); +#ifndef PWM_EMBEDDED + categoriesTitle->setFrameShape(QFrame::MenuBarPanel); +#else + categoriesTitle->setFrameShape(QFrame::StyledPanel); +#endif + categoriesTitle->setText(i18n("Categories:")); + catCtxMenu = new QPopupMenu(view); + catCtxMenu->insertItem(i18n("&Rename"), + view, SLOT(renCatButton_slot())); + catCtxMenu->insertItem(i18n("&Delete"), + view, SLOT(delCatButton_slot())); + // connections + connect(categoriesList, SIGNAL(highlighted(int)), + view, SLOT(shiftToView())); + connect(categoriesList, + SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)), + this, + SLOT(catRightClick(QListBoxItem *, const QPoint &))); +} + +PwMViewStyle_1::~PwMViewStyle_1() +{ + delete catCtxMenu; + delete splitter; +} + +void PwMViewStyle_1::catRightClick(QListBoxItem *item, const QPoint &point) +{ + if (!item) + return; + catCtxMenu->move(point); + catCtxMenu->show(); +} + +void PwMViewStyle_1::delCategory(const QString &cat) +{ + PWM_ASSERT(categoriesList); + int i, count = categoriesList->count(); + for (i = 0; i < count; ++i) { + if (categoriesList->text(i) == cat) { + categoriesList->removeItem(i); + return; + } + } + BUG(); +} + +void PwMViewStyle_1::selectCategory(const QString &cat) +{ + PWM_ASSERT(categoriesList); + int i, count = categoriesList->count(); + for (i = 0; i < count; ++i) { + if (categoriesList->text(i) == cat) { + categoriesList->setCurrentItem(i); + return; + } + } + // fall back to 0 + categoriesList->setCurrentItem(0); +} + +#ifndef PWM_EMBEDDED +#include "pwmviewstyle_1.moc" +#endif |