summaryrefslogtreecommitdiff
authorerik <erik>2007-01-10 16:52:08 (UTC)
committer erik <erik>2007-01-10 16:52:08 (UTC)
commit51bd5e8d542372ad54898ce642fe9b82b8ba83f3 (patch) (side-by-side diff)
treef2d6649a26347239e992082b22deca343939fc33
parent3c4c894bcdb1e49ce4d3e8167c8a21b1c617037d (diff)
downloadopie-51bd5e8d542372ad54898ce642fe9b82b8ba83f3.zip
opie-51bd5e8d542372ad54898ce642fe9b82b8ba83f3.tar.gz
opie-51bd5e8d542372ad54898ce642fe9b82b8ba83f3.tar.bz2
BUG: If the global category is checked in the category dialog the
'New Category' entry is still in local application scope. This means that the 'New Category' entry is in the wrong scope and all hell breaks loose. Actually the user will probably get confused that the category they are wanting to change is not in the right scope. FIX: Check to see that the global checkbox is checked before trying to add the new category. NOTE: This patch was originally submitted by Paul Eggleton (Blue Lightning). Thanks for the fix!
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/categoryedit_p.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/library/categoryedit_p.cpp b/library/categoryedit_p.cpp
index 14ac2e1..ee0da22 100644
--- a/library/categoryedit_p.cpp
+++ b/library/categoryedit_p.cpp
@@ -80,102 +80,105 @@ void CategoryEdit::setCategories( const QArray<int> &recCats,
QStringList::ConstIterator it;
int i, j;
for ( i = 0, it = appCats.begin(); it != appCats.end(); i++, ++it ) {
QCheckListItem *chk;
chk = new QCheckListItem( lvView, (*it), QCheckListItem::CheckBox );
if ( !d->mCategories.isGlobal((*it)) )
chk->setText( 1, tr(d->mVisible) );
else
chk->setText( 1, tr("All") );
// Is this record using this category, then we should check it
for ( j = 0; j < int(recCats.count()); j++ ) {
if ( cats[i] == recCats[j] ) {
chk->setOn( true );
break;
}
}
}
lvView->setSorting( 0, TRUE );
lvView->sort();
if ( lvView->childCount() < 1 )
txtCat->setEnabled( FALSE );
else {
lvView->setSelected( lvView->firstChild(), true );
}
}
CategoryEdit::~CategoryEdit()
{
if ( d )
delete d;
}
void CategoryEdit::slotSetText( QListViewItem *selected )
{
d->editItem = selected;
if ( !d->editItem )
return;
txtCat->setText( d->editItem->text(0) );
txtCat->setEnabled( true );
if ( d->editItem->text(1) == tr("All") )
chkGlobal->setChecked( true );
else
chkGlobal->setChecked( false );
}
void CategoryEdit::slotAdd()
{
QString name = tr( "New Category" );
- bool insertOk = FALSE;
+ int uid = 0;
int num = 0;
- while ( !insertOk ) {
+ while ( !uid ) {
if ( num++ > 0 )
name = tr("New Category ") + QString::number(num);
- insertOk = d->mCategories.addCategory( d->mStrApp, name );
+ if ( chkGlobal->isChecked() )
+ uid = d->mCategories.addGlobalCategory( name );
+ else
+ uid = d->mCategories.addCategory( d->mStrApp, name );
}
QCheckListItem *chk;
chk = new QCheckListItem( lvView, name, QCheckListItem::CheckBox );
if ( !chkGlobal->isChecked() )
chk->setText( 1, tr(d->mVisible) );
else
chk->setText( 1, tr("All") );
lvView->setSelected( chk, TRUE );
txtCat->selectAll();
txtCat->setFocus();
}
void CategoryEdit::slotRemove()
{
d->editItem = lvView->selectedItem();
if ( d->editItem ) {
QListViewItem *sibling = d->editItem->nextSibling();
d->mCategories.removeCategory( d->mStrApp, d->editItem->text(0) );
delete d->editItem;
d->editItem = 0;
if ( sibling )
lvView->setSelected( sibling, TRUE );
}
if ( lvView->childCount() < 1 ) {
txtCat->clear();
txtCat->setEnabled( FALSE );
}
}
void CategoryEdit::slotSetGlobal( bool isChecked )
{
if ( d->editItem ) {
if ( isChecked )
d->editItem->setText( 1, tr("All") );
else
d->editItem->setText( 1, tr(d->mVisible) );
d->mCategories.setGlobal( d->mStrApp, d->editItem->text( 0 ), isChecked );
}
}
void CategoryEdit::slotTextChanged( const QString &strNew )
{
if ( d->editItem ) {