summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-02-06 18:00:15 (UTC)
committer zautrix <zautrix>2005-02-06 18:00:15 (UTC)
commit282c7fc5b72f8a6ff78a408e10a6018c290ed9f0 (patch) (side-by-side diff)
tree95291ead32969e45a6e4e405f15532c9f29543f7
parent002a447671cdec6a2ee7940bc183c630c61121fa (diff)
downloadkdepimpi-282c7fc5b72f8a6ff78a408e10a6018c290ed9f0.zip
kdepimpi-282c7fc5b72f8a6ff78a408e10a6018c290ed9f0.tar.gz
kdepimpi-282c7fc5b72f8a6ff78a408e10a6018c290ed9f0.tar.bz2
cat color better
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt4
-rw-r--r--korganizer/koeditorgeneral.cpp1
-rw-r--r--korganizer/kotodoview.cpp7
-rw-r--r--libkdepim/categoryselectdialog.cpp70
-rw-r--r--libkdepim/categoryselectdialog.h8
-rw-r--r--libkdepim/categoryselectdialog_base.cpp9
-rw-r--r--libkdepim/categoryselectdialog_base.h1
7 files changed, 94 insertions, 6 deletions
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt
index 523c054..ee37492 100644
--- a/bin/kdepim/korganizer/germantranslation.txt
+++ b/bin/kdepim/korganizer/germantranslation.txt
@@ -1203,28 +1203,32 @@
{ "Display all opened","Zeige alle geöffnet" },
{ "Display all closed","Zeige alle geschlossen" },
{ "Display all flat","Zeige alle flach" },
{ "<p><i>Completed on %1</i></p>","<p><i>Erledigt am %1</i></p>" },
{ "Default todo done color:","Standard Todo erledigt Farbe" },
{ "Select week %1-%2","Wähle Woche %1-%2" },
{ "Select Week","Wähle Woche" },
{ "Set alarm for selected...","Setze Alarm für Selekt..." },
{ "Set Alarm!","Setze Alarm!" },
{ "Canged alarm for %1 items","Alarm für %1 Items geändert" },
{ " and "," und " },
{ "<IMG src="%1"> only )","nur <IMG src="%1"> )" },
{ "Mail to selected","Mail an Ausgewählte" },
{ "Mail to all","Mail an Alle" },
{ "Week view mode uses bigger font","Wochenansicht Modus nutzt größeren Font" },
{ "Set reminder ON with offset to:","Alarm AN mit Offset auf:" },
{ " on"," am" },
{ " completed on "," erledigt am " },
{ "Save as Event template","Speichere als Vorlage" },
{ "Load Event template","Lade Termin Vorlage" },
{ "Save as Journal template","Speichere als Journal Vorlage" },
{ "Insert Journal template","Füge Journal Vorlage ein" },
{ "Sub todos:<br>","Unter Todos:<br>" },
{ "Parent todo:<br>","Über Todo:<br>" },
+{ "Set current as color category","Setze Gewählte als Farbkategorie" },
+{ "","" },
+{ "","" },
+{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index f5eb52e..496f125 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -100,48 +100,49 @@ void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
// mLocationEdit = new QLineEdit(parent);
connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
headerLayout->addWidget(mLocationEdit,2,1);
headerLayout->setColStretch( 1, 10);
}
void KOEditorGeneral::setFocusOn( int i )
{
qApp->processEvents();
if ( i == 1 ) {
mDescriptionEdit->setFocus();
mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
}
if ( i == 2 ) {
mSummaryEdit->setFocus();
}
}
void KOEditorGeneral::editCategories()
{
// qDebug("KOEditorGeneral::editCategories() ");
KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
//KOGlobals::fitDialogToScreen( csd );
+ csd->setColorEnabled();
csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
csd->exec();
delete csd;
}
void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
{
QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
mCategoriesButton = new QPushButton(parent);
mCategoriesButton->setText(i18n("Categories..."));
connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
categoriesLayout->addWidget(mCategoriesButton);
mCategoriesLabel = new QLabel(parent);
mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
categoriesLayout->addWidget(mCategoriesLabel,1);
}
void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
{
QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 1a1bce5..3011458 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -940,53 +940,60 @@ void KOTodoView::setNewPercentage(int index)
QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
{
QPopupMenu* tempMenu = new QPopupMenu (this);
QStringList checkedCategories = todoItem->todo()->categories ();
tempMenu->setCheckable (true);
for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
it != KOPrefs::instance()->mCustomCategories.end ();
++it) {
int index = tempMenu->insertItem (*it);
mCategory[index] = *it;
if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
}
connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
return tempMenu;
}
void KOTodoView::changedCategories(int index)
{
if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
QStringList categories = mActiveItem->todo()->categories ();
+ QString colcat = categories.first();
if (categories.find (mCategory[index]) != categories.end ())
categories.remove (mCategory[index]);
else
categories.insert (categories.end(), mCategory[index]);
categories.sort ();
+ if ( !colcat.isEmpty() ) {
+ if ( categories.find ( colcat ) != categories.end () ) {
+ categories.remove( colcat );
+ categories.prepend( colcat );
+ }
+ }
mActiveItem->todo()->setCategories (categories);
mActiveItem->construct();
mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
}
}
void KOTodoView::itemDoubleClicked(QListViewItem *item)
{
if ( pendingSubtodo != 0 ) {
topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
}
pendingSubtodo = 0;
if (!item) {
newTodo();
return;
}
if ( KOPrefs::instance()->mEditOnDoubleClick )
editItem( item );
else
showItem( item , QPoint(), 0 );
}
void KOTodoView::itemClicked(QListViewItem *item)
{
diff --git a/libkdepim/categoryselectdialog.cpp b/libkdepim/categoryselectdialog.cpp
index 7df9154..8b2bc4e 100644
--- a/libkdepim/categoryselectdialog.cpp
+++ b/libkdepim/categoryselectdialog.cpp
@@ -5,147 +5,213 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qlistview.h>
#include <qpushbutton.h>
#include <qheader.h>
#include <qapp.h>
#include <qmessagebox.h>
+#include <kmessagebox.h>
#include "categoryeditdialog.h"
#include "categoryselectdialog.h"
#include "kpimprefs.h"
using namespace KPIM;
CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent,
const char* name,
bool modal, WFlags fl )
: CategorySelectDialog_base( parent, name, true, fl ),
mPrefs( prefs )
{
+ mColorItem = 0;
+ mColorEnabled = false;
mCategories->header()->hide();
setCategories();
connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog()));
if ( QApplication::desktop()->width() > 460 )
resize( 300, 360 );
else
showMaximized();
+ connect( mSetColorCat, SIGNAL( clicked() ), this, SLOT( setColorCat() ) );
+ connect( mCategories, SIGNAL( clicked(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) );
}
void CategorySelectDialog::editCategoriesDialog()
{
KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this );
ced->exec();
delete ced;
setCategories();
}
void CategorySelectDialog::setCategories()
{
+ mColorItem = 0;
mCategories->clear();
mCategoryList.clear();
QStringList::Iterator it;
-
for (it = mPrefs->mCustomCategories.begin();
it != mPrefs->mCustomCategories.end(); ++it ) {
new QCheckListItem(mCategories,*it,QCheckListItem::CheckBox);
}
}
CategorySelectDialog::~CategorySelectDialog()
{
}
void CategorySelectDialog::setSelected(const QStringList &selList)
{
clear();
QStringList::ConstIterator it;
QStringList notFound;
bool found = false;
for (it=selList.begin();it!=selList.end();++it) {
//qDebug(" CategorySelectDialog::setSelected(");
QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
while (item) {
if (item->text() == *it) {
item->setOn(true);
+ if ( ! found )
+ setColorItem( item );
found = true;
break;
}
item = (QCheckListItem *)item->nextSibling();
}
// if ( ! found ) {
//emit updateCategoriesGlobal();
// QMessageBox::information( this, "KO/E: Information!",
// "Categories found, which were not\n"
// "in list of categories!\n"
// "message",
// "OK", "", 0,
// 0, 1 );
// setSelected(selList);
// return;
// }
}
}
QStringList CategorySelectDialog::selectedCategories() const
{
return mCategoryList;
}
+void CategorySelectDialog::setColorEnabled()
+{
+ mColorEnabled = true;
+ mSetColorCat->show();
+}
+void CategorySelectDialog::setColorCat()
+{
+ QCheckListItem * newColorItem = (QCheckListItem * )mCategories->currentItem ();
+ if ( !newColorItem ) {
+ KMessageBox::error(this,i18n("There is no current item."));
+ return;
+ }
+ if ( !newColorItem->isOn() )
+ newColorItem->setOn( true );
+ setColorItem( newColorItem );
+}
+void CategorySelectDialog::clicked ( QListViewItem * it )
+{
+ if ( ! it )
+ return;
+ QCheckListItem *i = (QCheckListItem *) it;
+ qDebug("click %d ", i->isOn());
+ if ( !i->isOn() && i==mColorItem) {
+ setColorItem( 0);
+ QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
+ while (item) {
+ if (item->isOn()) {
+ setColorItem( item );
+ break;
+ }
+ item = (QCheckListItem *)item->nextSibling();
+ }
+ } else if ( i->isOn() && !mColorItem) {
+ setColorItem( i);
+ }
+}
+void CategorySelectDialog::setColorItem( QCheckListItem * newColorItem )
+{
+ if ( !mColorEnabled )
+ return;
+ if ( mColorItem == newColorItem)
+ return;
+ if ( mColorItem ) {
+ mColorItem->setPixmap ( 0, QPixmap() );
+ mColorItem = 0;
+ }
+ if ( newColorItem ) {
+ QPixmap pix (newColorItem->height()/2, newColorItem->height()/2 );
+ pix.fill(Qt::blue );
+ newColorItem->setPixmap ( 0, pix );
+ mColorItem = newColorItem;
+ }
+}
void CategorySelectDialog::slotApply()
{
QStringList categories;
QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
+ QString colcat;
while (item) {
if (item->isOn()) {
+ if ( item == mColorItem)
+ colcat = item->text();
+ else
categories.append(item->text());
}
item = (QCheckListItem *)item->nextSibling();
}
-
+ categories.sort();
+ if ( ! colcat.isEmpty() )
+ categories.prepend( colcat );
QString categoriesStr = categories.join(",");
mCategoryList = categories;
emit categoriesSelected(categories);
emit categoriesSelected(categoriesStr);
}
void CategorySelectDialog::accept()
{
slotOk();
}
void CategorySelectDialog::slotOk()
{
slotApply();
QDialog::accept();
}
void CategorySelectDialog::clear()
{
QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
while (item) {
item->setOn(false);
item = (QCheckListItem *)item->nextSibling();
diff --git a/libkdepim/categoryselectdialog.h b/libkdepim/categoryselectdialog.h
index 9b6261c..680a093 100644
--- a/libkdepim/categoryselectdialog.h
+++ b/libkdepim/categoryselectdialog.h
@@ -5,65 +5,71 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef KPIM_CATEGORYSELECTDIALOG_H
#define KPIM_CATEGORYSELECTDIALOG_H
#include <categoryselectdialog_base.h>
class KPimPrefs;
+class QCheckListItem;
namespace KPIM {
class CategorySelectDialog : public CategorySelectDialog_base
{
Q_OBJECT
public:
CategorySelectDialog( KPimPrefs *prefs, QWidget* parent = 0,
const char* name = 0,
bool modal = FALSE, WFlags fl = 0 );
~CategorySelectDialog();
void setCategories();
+ void setColorEnabled();
void setSelected(const QStringList &selList);
QStringList selectedCategories() const;
public slots:
void slotOk();
void slotApply();
void clear();
void accept();
void editCategoriesDialog();
void updateCategoryConfig();
-
+ void setColorCat();
+ void clicked ( QListViewItem * );
signals:
void categoriesSelected(const QString &);
void categoriesSelected(const QStringList &);
void editCategories();
private:
+ bool mColorEnabled;
KPimPrefs *mPrefs;
QStringList mCategoryList;
+ QCheckListItem *mColorItem;
+ void setColorItem( QCheckListItem * );
class CategorySelectDialogPrivate;
CategorySelectDialogPrivate *d;
};
}
#endif
diff --git a/libkdepim/categoryselectdialog_base.cpp b/libkdepim/categoryselectdialog_base.cpp
index 3f050cf..4793fd7 100644
--- a/libkdepim/categoryselectdialog_base.cpp
+++ b/libkdepim/categoryselectdialog_base.cpp
@@ -15,114 +15,117 @@
#include <qlistview.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
/*
* Constructs a CategorySelectDialog_base as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
CategorySelectDialog_base::CategorySelectDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "CategorySelectDialog_base" );
CategorySelectDialog_baseLayout = new QVBoxLayout( this, 11, 6, "CategorySelectDialog_baseLayout");
mCategories = new QListView( this, "mCategories" );
mCategories->addColumn( i18n( "Category" ) );
CategorySelectDialog_baseLayout->addWidget( mCategories );
-
- Layout12 = new QHBoxLayout( 0, 0, 6, "Layout12");
+ mSetColorCat = new QPushButton( this, "msetColor" );
+ CategorySelectDialog_baseLayout->addWidget( mSetColorCat );
+ Layout12 = new QHBoxLayout( 0, 0, 4, "Layout12");
mClear = new QPushButton( this, "mClear" );
Layout12->addWidget( mClear );
// QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
//Layout12->addItem( spacer );
mButtonEdit = new QPushButton( this, "mButtonEdit" );
Layout12->addWidget( mButtonEdit );
CategorySelectDialog_baseLayout->addLayout( Layout12 );
- Layout11 = new QHBoxLayout( 0, 0, 6, "Layout11");
+ Layout11 = new QHBoxLayout( 0, 0, 4, "Layout11");
//mButtonHelp = new QPushButton( this, "mButtonHelp" );
//Layout11->addWidget( mButtonHelp );
//QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
// Layout11->addItem( spacer_2 );
//mApply = new QPushButton( this, "mApply" );
// Layout11->addWidget( mApply );
mButtonOk = new QPushButton( this, "mButtonOk" );
mButtonOk->setOn( FALSE );
mButtonOk->setDefault( TRUE );
Layout11->addWidget( mButtonOk );
mButtonCancel = new QPushButton( this, "mButtonCancel" );
Layout11->addWidget( mButtonCancel );
CategorySelectDialog_baseLayout->addLayout( Layout11 );
languageChange();
// resize( sizeHint() );
// signals and slots connections
connect( mButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
connect( mButtonOk, SIGNAL( clicked() ), this, SLOT( slotOk() ) );
connect( mClear, SIGNAL( clicked() ), this, SLOT( clear() ) );
//connect( mApply, SIGNAL( clicked() ), this, SLOT( slotApply() ) );
// tab order
setTabOrder( mCategories, mClear );
setTabOrder( mClear, mButtonEdit );
setTabOrder( mButtonEdit, mButtonOk );//mButtonHelp );
// setTabOrder( mButtonHelp, mApply );
// setTabOrder( mApply, mButtonOk );
setTabOrder( mButtonOk, mButtonCancel );
// showMaximized();
//raise();
+ mSetColorCat->hide();
}
/*
* Destroys the object and frees any allocated resources
*/
CategorySelectDialog_base::~CategorySelectDialog_base()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void CategorySelectDialog_base::languageChange()
{
setCaption( i18n( "Select Categories" ) );
mCategories->header()->setLabel( 0, tr2i18n( "Category" ) );
mClear->setText( i18n( " &Deselect All " ) );
mButtonEdit->setText( i18n( " &Edit Categories " ) );
// mButtonHelp->setText( tr2i18n( "&Help" ) );
//mApply->setText( i18n( "&Apply" ) );
mButtonOk->setText( i18n( "&OK" ) );
+ mSetColorCat->setText( i18n( "Set current as color category" ) );
mButtonCancel->setText( i18n( "&Cancel" ) );
}
void CategorySelectDialog_base::clear()
{
qWarning( "CategorySelectDialog_base::clear(): Not implemented yet" );
}
void CategorySelectDialog_base::slotApply()
{
qWarning( "CategorySelectDialog_base::slotApply(): Not implemented yet" );
}
void CategorySelectDialog_base::slotOk()
{
qWarning( "CategorySelectDialog_base::slotOk(): Not implemented yet" );
}
//US#include "categoryselectdialog_base.moc"
diff --git a/libkdepim/categoryselectdialog_base.h b/libkdepim/categoryselectdialog_base.h
index af905ed..59ffa22 100644
--- a/libkdepim/categoryselectdialog_base.h
+++ b/libkdepim/categoryselectdialog_base.h
@@ -14,40 +14,41 @@
#include <qdialog.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QListView;
class QListViewItem;
class QPushButton;
class CategorySelectDialog_base : public QDialog
{
Q_OBJECT
public:
CategorySelectDialog_base( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~CategorySelectDialog_base();
QListView* mCategories;
QPushButton* mClear;
QPushButton* mButtonEdit;
QPushButton* mButtonHelp;
QPushButton* mApply;
QPushButton* mButtonOk;
QPushButton* mButtonCancel;
+ QPushButton* mSetColorCat;
public slots:
virtual void clear();
virtual void slotApply();
virtual void slotOk();
protected:
QVBoxLayout* CategorySelectDialog_baseLayout;
QHBoxLayout* Layout12;
QHBoxLayout* Layout11;
protected slots:
virtual void languageChange();
};
#endif // CATEGORYSELECTDIALOG_BASE_H