summaryrefslogtreecommitdiff
path: root/library
Unidiff
Diffstat (limited to 'library') (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
@@ -96,70 +96,73 @@ void CategoryEdit::setCategories( const QArray<int> &recCats,
96 } 96 }
97 lvView->setSorting( 0, TRUE ); 97 lvView->setSorting( 0, TRUE );
98 lvView->sort(); 98 lvView->sort();
99 if ( lvView->childCount() < 1 ) 99 if ( lvView->childCount() < 1 )
100 txtCat->setEnabled( FALSE ); 100 txtCat->setEnabled( FALSE );
101 else { 101 else {
102 lvView->setSelected( lvView->firstChild(), true ); 102 lvView->setSelected( lvView->firstChild(), true );
103 } 103 }
104} 104}
105 105
106CategoryEdit::~CategoryEdit() 106CategoryEdit::~CategoryEdit()
107{ 107{
108 if ( d ) 108 if ( d )
109 delete d; 109 delete d;
110} 110}
111 111
112void CategoryEdit::slotSetText( QListViewItem *selected ) 112void CategoryEdit::slotSetText( QListViewItem *selected )
113{ 113{
114 d->editItem = selected; 114 d->editItem = selected;
115 if ( !d->editItem ) 115 if ( !d->editItem )
116 return; 116 return;
117 txtCat->setText( d->editItem->text(0) ); 117 txtCat->setText( d->editItem->text(0) );
118 txtCat->setEnabled( true ); 118 txtCat->setEnabled( true );
119 if ( d->editItem->text(1) == tr("All") ) 119 if ( d->editItem->text(1) == tr("All") )
120 chkGlobal->setChecked( true ); 120 chkGlobal->setChecked( true );
121 else 121 else
122 chkGlobal->setChecked( false ); 122 chkGlobal->setChecked( false );
123} 123}
124 124
125void CategoryEdit::slotAdd() 125void CategoryEdit::slotAdd()
126{ 126{
127 QString name = tr( "New Category" ); 127 QString name = tr( "New Category" );
128 bool insertOk = FALSE; 128 int uid = 0;
129 int num = 0; 129 int num = 0;
130 while ( !insertOk ) { 130 while ( !uid ) {
131 if ( num++ > 0 ) 131 if ( num++ > 0 )
132 name = tr("New Category ") + QString::number(num); 132 name = tr("New Category ") + QString::number(num);
133 insertOk = d->mCategories.addCategory( d->mStrApp, name ); 133 if ( chkGlobal->isChecked() )
134 uid = d->mCategories.addGlobalCategory( name );
135 else
136 uid = d->mCategories.addCategory( d->mStrApp, name );
134 } 137 }
135 QCheckListItem *chk; 138 QCheckListItem *chk;
136 chk = new QCheckListItem( lvView, name, QCheckListItem::CheckBox ); 139 chk = new QCheckListItem( lvView, name, QCheckListItem::CheckBox );
137 if ( !chkGlobal->isChecked() ) 140 if ( !chkGlobal->isChecked() )
138 chk->setText( 1, tr(d->mVisible) ); 141 chk->setText( 1, tr(d->mVisible) );
139 else 142 else
140 chk->setText( 1, tr("All") ); 143 chk->setText( 1, tr("All") );
141 144
142 lvView->setSelected( chk, TRUE ); 145 lvView->setSelected( chk, TRUE );
143 txtCat->selectAll(); 146 txtCat->selectAll();
144 txtCat->setFocus(); 147 txtCat->setFocus();
145} 148}
146 149
147void CategoryEdit::slotRemove() 150void CategoryEdit::slotRemove()
148{ 151{
149 d->editItem = lvView->selectedItem(); 152 d->editItem = lvView->selectedItem();
150 if ( d->editItem ) { 153 if ( d->editItem ) {
151 QListViewItem *sibling = d->editItem->nextSibling(); 154 QListViewItem *sibling = d->editItem->nextSibling();
152 155
153 d->mCategories.removeCategory( d->mStrApp, d->editItem->text(0) ); 156 d->mCategories.removeCategory( d->mStrApp, d->editItem->text(0) );
154 157
155 delete d->editItem; 158 delete d->editItem;
156 d->editItem = 0; 159 d->editItem = 0;
157 160
158 if ( sibling ) 161 if ( sibling )
159 lvView->setSelected( sibling, TRUE ); 162 lvView->setSelected( sibling, TRUE );
160 } 163 }
161 if ( lvView->childCount() < 1 ) { 164 if ( lvView->childCount() < 1 ) {
162 txtCat->clear(); 165 txtCat->clear();
163 txtCat->setEnabled( FALSE ); 166 txtCat->setEnabled( FALSE );
164 } 167 }
165} 168}