63
70
// reloadBlogList();
64
71
optionsDate->setDate( QDateTime::currentDateTime().date() );
65
72
optionsTime->setTime( QDateTime::currentDateTime().time() );
66
// connect( btnBlogAdd, SIGNAL( clicked() ), this, SLOT( sltAddBlog() ) );
67
// connect( btnBlogEdit, SIGNAL( clicked() ), this, SLOT( sltEditBlog() ) );
68
// connect( btnBlogRemove, SIGNAL( clicked() ), this, SLOT( sltRemoveBlog() ) );
73
// connect( btnBlogAdd, SIGNAL( clicked() ), this, SLOT( slotAddBlog() ) );
74
// connect( btnBlogEdit, SIGNAL( clicked() ), this, SLOT( slotEditBlog() ) );
75
// connect( btnBlogRemove, SIGNAL( clicked() ), this, SLOT( slotRemoveBlog() ) );
70
connect( btnCatReload, SIGNAL( clicked() ), this, SLOT( sltReloadCategoryList() ) );
71
connect( btnEntriesUpdate, SIGNAL( clicked() ), this, SLOT( sltUpdateEntries() ) );
77
connect( btnCatReload, SIGNAL( clicked() ), this, SLOT( slotReloadCategoryList() ) );
78
connect( btnEntriesUpdate, SIGNAL( clicked() ), this, SLOT( slotUpdateEntries() ) );
72
79
connect( btnEntriesClear, SIGNAL( clicked(bool) ), this, SLOT( clearEntries()) );
74
// connect( this, SIGNAL( sigCurrentBlogChanged( int ) ), this, SLOT( sltCurrentBlogChanged( int ) ) );
75
// connect( &listBlogRadioButtons, SIGNAL( buttonClicked( int ) ), this, SLOT( sltSetCurrentBlog() ) );
81
// connect( this, SIGNAL( sigCurrentBlogChanged( int ) ), this, SLOT( slotCurrentBlogChanged( int ) ) );
82
// connect( &listBlogRadioButtons, SIGNAL( buttonClicked( int ) ), this, SLOT( slotSetCurrentBlog() ) );
77
84
connect( lstEntriesList, SIGNAL( itemDoubleClicked( QListWidgetItem* ) ),
78
this, SLOT( sltEntrySelected( QListWidgetItem* ) ) );
79
// connect( btnEntriesCopyUrl, SIGNAL( clicked( bool ) ), this, SLOT( sltEntriesCopyUrl() ) );
80
connect( btnEntriesRemove, SIGNAL( clicked(bool) ), this, SLOT( sltRemoveSelectedEntryFromServer() ) );
85
this, SLOT( slotEntrySelected( QListWidgetItem* ) ) );
86
// connect( btnEntriesCopyUrl, SIGNAL( clicked( bool ) ), this, SLOT( slotEntriesCopyUrl() ) );
87
connect( btnEntriesRemove, SIGNAL( clicked(bool) ), this, SLOT( slotRemoveSelectedEntryFromServer() ) );
82
89
connect( btnOptionsNow, SIGNAL( clicked(bool)), this, SLOT( setDateTimeNow() ) );
83
90
connect( localEntriesTable, SIGNAL( cellDoubleClicked(int,int) ),
84
this, SLOT(sltLocalEntrySelected(int,int)) );
85
connect( btnLocalRemove, SIGNAL( clicked( bool ) ) , this, SLOT( sltRemoveLocalEntry() ) );
91
this, SLOT(slotLocalEntrySelected(int,int)) );
92
connect( btnLocalRemove, SIGNAL( clicked( bool ) ) , this, SLOT( slotRemoveLocalEntry() ) );
87
94
lblOptionsTrackBack->setVisible( false );
88
95
txtOptionsTrackback->setVisible( false );
98
105
void Toolbox::setCurrentBlogId( int blog_id )
100
107
kDebug()<<blog_id;
101
if( mCurrentBlogId == blog_id )
108
if( d->mCurrentBlogId == blog_id )
103
110
// btnBlogEdit->setEnabled( true );
104
111
// btnBlogRemove->setEnabled( true );
105
mCurrentBlogId = blog_id;
112
d->mCurrentBlogId = blog_id;
106
113
if( blog_id <= 0 )
108
sltLoadCategoryListFromDB( blog_id );
109
sltLoadEntriesFromDB( blog_id );
115
slotLoadCategoryListFromDB( blog_id );
116
slotLoadEntriesFromDB( blog_id );
110
117
Qt::LayoutDirection ll = DBMan::self()->blogList().value( blog_id )->direction();
111
118
frameCat->setLayoutDirection( ll );
112
119
lstEntriesList->setLayoutDirection( ll );
115
void Toolbox::sltReloadCategoryList()
122
void Toolbox::slotReloadCategoryList()
118
125
// QAbstractButton *btn = listBlogRadioButtons.checkedButton();
119
if ( mCurrentBlogId == -1 ) {
126
if ( d->mCurrentBlogId == -1 ) {
120
127
KMessageBox::sorry( this, i18n( "No blog has been selected: \
121
128
you have to select a blog from the Blogs page before asking for the list of categories." ) );
125
Backend *b = new Backend( mCurrentBlogId );
132
Backend *b = new Backend( d->mCurrentBlogId );
133
connect( b, SIGNAL( sigCategoryListFetched( int ) ), this, SLOT( slotLoadCategoryListFromDB( int ) ) );
134
connect( b, SIGNAL( sigError( const QString& ) ), this, SIGNAL( sigError( const QString& ) ) );
135
emit sigBusy( true );
136
d->statusbar->showMessage( i18n( "Requesting list of categories..." ) );
126
137
b->getCategoryListFromServer();
127
connect( b, SIGNAL( sigCategoryListFetched( int ) ), this, SLOT( sltLoadCategoryListFromDB( int ) ) );
128
connect( b, SIGNAL( sigError( const QString& ) ), this, SIGNAL( sigError( const QString& ) ) );
129
statusbar->showMessage( i18n( "Requesting list of categories..." ) );
130
this->setCursor( Qt::BusyCursor );
131
emit sigBusy( true );
138
// this->setCursor( Qt::BusyCursor );
134
void Toolbox::sltUpdateEntries(int count)
141
void Toolbox::slotUpdateEntries(int count)
137
if ( mCurrentBlogId == -1 ) {
144
if ( d->mCurrentBlogId == -1 ) {
138
145
KMessageBox::sorry( this, i18n( "No blog has been selected: \
139
146
you have to select a blog from the Blogs page before asking for the list of entries." ) );
140
147
kDebug() << "There isn't any selected blog.";
151
158
dia->deleteLater();
154
Backend *entryB = new Backend( mCurrentBlogId, this);
161
Backend *entryB = new Backend( d->mCurrentBlogId, this);
155
162
entryB->getEntriesListFromServer( count );
156
connect( entryB, SIGNAL( sigEntriesListFetched( int ) ), this, SLOT( sltLoadEntriesFromDB( int ) ) );
163
connect( entryB, SIGNAL( sigEntriesListFetched( int ) ), this, SLOT( slotLoadEntriesFromDB( int ) ) );
157
164
connect( entryB, SIGNAL( sigError( const QString& ) ), this, SIGNAL( sigError( const QString& ) ) );
158
statusbar->showMessage( i18n( "Requesting list of entries..." ) );
165
d->statusbar->showMessage( i18n( "Requesting list of entries..." ) );
159
166
this->setCursor( Qt::BusyCursor );
160
167
emit sigBusy( true );
163
void Toolbox::sltLoadEntriesFromDB( int blog_id )
170
void Toolbox::slotLoadEntriesFromDB( int blog_id )
166
173
if ( blog_id == -1 ) {
202
209
for ( i = listCategories.constBegin(); i != endIt; ++i ) {
203
210
CatCheckBox *cb = new CatCheckBox( i->name, this );
204
211
cb->setCategory( *i );
205
listCategoryCheckBoxes.append( cb );
212
d->listCategoryCheckBoxes.append( cb );
206
213
frameCat->layout()->addWidget( cb );
208
statusbar->showMessage( i18n( "List of categories received." ), STATUSTIMEOUT );
215
d->statusbar->showMessage( i18n( "List of categories received." ), STATUSTIMEOUT );
209
216
this->unsetCursor();
210
217
emit sigBusy( false );
213
void Toolbox::sltRemoveSelectedEntryFromServer()
220
void Toolbox::slotRemoveSelectedEntryFromServer()
215
222
if(lstEntriesList->selectedItems().count() < 1)
217
224
if( KMessageBox::warningYesNoCancel(this, i18n( "Removing a post from your blog cannot be undone.\
218
225
\nAre you sure you want to remove the post with title \"%1\" from your blog?", lstEntriesList->currentItem()->text() ))
219
226
== KMessageBox::Yes) {
220
BilboPost post = DBMan::self()->getPostInfo( lstEntriesList->currentItem()->data(32).toInt() );
221
Backend *b = new Backend( mCurrentBlogId, this);
227
BilboPost *post = new BilboPost( DBMan::self()->getPostInfo( lstEntriesList->currentItem()->
228
data(32).toInt() ) );
229
Backend *b = new Backend( d->mCurrentBlogId, this);
222
230
connect(b, SIGNAL(sigPostRemoved(int,const BilboPost&)), this, SLOT(slotPostRemoved(int,const BilboPost&)) );
223
231
connect(b, SIGNAL(sigError(const QString&)), this, SLOT(slotError(const QString&)));
224
232
b->removePost(post);
225
statusbar->showMessage( i18n( "Removing post..." ) );
233
d->statusbar->showMessage( i18n( "Removing post..." ) );
231
239
KMessageBox::information( this, i18nc( "Post removed from Blog", "Post with title \"%1\" removed from \"%2\".",
232
240
post.title(), DBMan::self()->blogList().value(blog_id)->title() ) );
233
sltLoadEntriesFromDB( blog_id );
234
statusbar->showMessage( i18n( "Post removed" ), STATUSTIMEOUT );
241
slotLoadEntriesFromDB( blog_id );
242
d->statusbar->showMessage( i18n( "Post removed" ), STATUSTIMEOUT );
235
243
sender()->deleteLater();
239
246
void Toolbox::slotError(const QString& errorMessage)
241
248
KMessageBox::detailedError( this, i18n( "An error occurred in the latest transaction." ), errorMessage );
242
statusbar->showMessage( i18nc( "Operation failed", "Failed" ), STATUSTIMEOUT );
249
d->statusbar->showMessage( i18nc( "Operation failed", "Failed" ), STATUSTIMEOUT );
243
250
sender()->deleteLater();
279
286
void Toolbox::clearCatList()
282
foreach( CatCheckBox* cat, listCategoryCheckBoxes ){
289
foreach( CatCheckBox* cat, d->listCategoryCheckBoxes ){
283
290
cat->deleteLater();
285
listCategoryCheckBoxes.clear();
292
d->listCategoryCheckBoxes.clear();
288
void Toolbox::getFieldsValue( BilboPost ¤tPost )
295
void Toolbox::getFieldsValue( BilboPost* currentPost )
291
currentPost.setCategoryList( this->selectedCategories() );
292
currentPost.setTags( this->currentTags() );
293
currentPost.setModifyTimeStamp( this->chkOptionsTime->isChecked() );
294
if ( currentPost.status() == KBlog::BlogPost::New ) {
298
currentPost->setCategoryList( this->selectedCategories() );
299
currentPost->setTags( this->currentTags() );
300
currentPost->setModifyTimeStamp( this->chkOptionsTime->isChecked() );
301
if ( currentPost->status() == KBlog::BlogPost::New ) {
295
302
if ( chkOptionsTime->isChecked() ) {
296
currentPost.setModificationDateTime( KDateTime( optionsDate->date(), optionsTime->time() ) );
297
currentPost.setCreationDateTime( KDateTime( optionsDate->date(), optionsTime->time() ) );
303
currentPost->setModificationDateTime( KDateTime( optionsDate->date(), optionsTime->time() ) );
304
currentPost->setCreationDateTime( KDateTime( optionsDate->date(), optionsTime->time() ) );
299
currentPost.setCreationDateTime( KDateTime::currentLocalDateTime() );
300
currentPost.setModificationDateTime( KDateTime::currentLocalDateTime() );
306
currentPost->setCreationDateTime( KDateTime::currentLocalDateTime() );
307
currentPost->setModificationDateTime( KDateTime::currentLocalDateTime() );
303
currentPost.setCreationDateTime( KDateTime( optionsDate->date(), optionsTime->time() ) );
304
currentPost.setModificationDateTime( KDateTime( optionsDate->date(), optionsTime->time() ) );
310
currentPost->setCreationDateTime( KDateTime( optionsDate->date(), optionsTime->time() ) );
311
currentPost->setModificationDateTime( KDateTime( optionsDate->date(), optionsTime->time() ) );
306
if( currentPost.creationDateTime().isUtc() || currentPost.modificationDateTime().isUtc() ){
313
if( currentPost->creationDateTime().isUtc() || currentPost->modificationDateTime().isUtc() ){
307
314
kDebug()<<"creationDateTime was UTC!";
308
currentPost.setCreationDateTime( KDateTime( currentPost.creationDateTime().dateTime(),
315
currentPost->setCreationDateTime( KDateTime( currentPost->creationDateTime().dateTime(),
309
316
KDateTime::LocalZone ) );
310
currentPost.setModificationDateTime( KDateTime( currentPost.modificationDateTime().dateTime(),
317
currentPost->setModificationDateTime( KDateTime( currentPost->modificationDateTime().dateTime(),
311
318
KDateTime::LocalZone ) );
313
currentPost.setSlug( txtSlug->text() );
314
currentPost.setPrivate(( comboOptionsStatus->currentIndex() == 1 ) ? true : false );
315
currentPost.setCommentAllowed( chkOptionsComments->isChecked() );
316
currentPost.setTrackBackAllowed( chkOptionsTrackback->isChecked() );
317
currentPost.setSummary( txtSummary->toPlainText() );
320
currentPost->setSlug( txtSlug->text() );
321
currentPost->setPrivate(( comboOptionsStatus->currentIndex() == 1 ) ? true : false );
322
currentPost->setCommentAllowed( chkOptionsComments->isChecked() );
323
currentPost->setTrackBackAllowed( chkOptionsTrackback->isChecked() );
324
currentPost->setSummary( txtSummary->toPlainText() );
320
327
void Toolbox::setFieldsValue( BilboPost* post )
369
376
QStringList list;
370
int count = listCategoryCheckBoxes.count();
377
int count = d->listCategoryCheckBoxes.count();
371
378
for ( int i = 0; i < count; ++i ) {
372
if ( listCategoryCheckBoxes[i]->isChecked() )
373
list.append( listCategoryCheckBoxes[i]->category().name );
379
if ( d->listCategoryCheckBoxes[i]->isChecked() )
380
list.append( d->listCategoryCheckBoxes[i]->category().name );
378
QList< int > Toolbox::selectedCategoriesId()
381
kDebug() << "NOT IMPLEMENTED YET!";
385
385
void Toolbox::setSelectedCategories( const QStringList &list )
387
387
unCheckCatList();
388
int count = listCategoryCheckBoxes.count();
388
int count = d->listCategoryCheckBoxes.count();
389
389
for ( int i = 0; i < count; ++i ) {
390
if ( list.contains( listCategoryCheckBoxes[i]->category().name, Qt::CaseInsensitive ) )
391
listCategoryCheckBoxes[i]->setChecked( true );
390
if ( list.contains( d->listCategoryCheckBoxes[i]->category().name, Qt::CaseInsensitive ) )
391
d->listCategoryCheckBoxes[i]->setChecked( true );
395
void Toolbox::setSelectedCategories( const QList< int > & )
398
kDebug() << "NOT IMPLEMENTED YET!";
401
395
QStringList Toolbox::currentTags()
552
547
connect( actEntriesOpenInBrowser, SIGNAL( triggered() ), this, SLOT( openPostInBrowser() ) );
553
548
KAction *actEntriesCopyUrl = new KAction( KIcon("edit-copy"),
554
549
i18n("Copy URL"), entriesContextMenu );
555
connect( actEntriesCopyUrl, SIGNAL( triggered(bool) ), this, SLOT( sltEntriesCopyUrl() ) );
550
connect( actEntriesCopyUrl, SIGNAL( triggered(bool) ), this, SLOT( slotEntriesCopyUrl() ) );
556
551
KAction *actEntriesCopyTitle = new KAction( KIcon("edit-copy"),
557
552
i18n("Copy title"), entriesContextMenu );
558
553
connect( actEntriesCopyTitle, SIGNAL( triggered(bool) ), this, SLOT( copyPostTitle() ) );