30 #include <KMessageBox>
38 connect( btnAdd, SIGNAL(clicked()),
this, SLOT(
addBlog()) );
39 connect( btnEdit, SIGNAL(clicked()),
this, SLOT(
editBlog()) );
40 connect( btnRemove, SIGNAL(clicked()),
this, SLOT(
removeBlog()) );
41 connect( blogsTable, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
42 this, SLOT(blogsTablestateChanged()) );
43 connect (blogsTable, SIGNAL(doubleClicked(QModelIndex)), SLOT(
editBlog()));
45 blogsTable->setHeaderLabels(QStringList()<<i18n(
"Title")<<i18n(
"URL"));
46 btnAdd->setIcon( KIcon( QLatin1String(
"list-add") ) );
47 btnEdit->setIcon( KIcon( QLatin1String(
"edit-rename") ) );
48 btnRemove->setIcon( KIcon( QLatin1String(
"list-remove") ) );
59 addEditBlogWindow->setWindowModality( Qt::ApplicationModal );
60 addEditBlogWindow->setAttribute( Qt::WA_DeleteOnClose );
61 connect( addEditBlogWindow, SIGNAL(sigBlogAdded(
BilboBlog)),
63 connect( addEditBlogWindow, SIGNAL(sigBlogAdded(
BilboBlog)),
65 addEditBlogWindow->show();
68 void BlogSettings::slotBlogAdded(
const BilboBlog &blog )
70 addBlogToList( blog );
75 QTreeWidgetItem * item = blogsTable->currentItem();
77 const int blog_id = item->data( 0, BlogId ).toInt();
79 addEditBlogWindow->setAttribute( Qt::WA_DeleteOnClose );
80 addEditBlogWindow->setWindowModality( Qt::ApplicationModal );
81 connect( addEditBlogWindow, SIGNAL(sigBlogEdited(
BilboBlog)),
83 connect( addEditBlogWindow, SIGNAL(sigBlogEdited(
BilboBlog)),
85 addEditBlogWindow->show();
89 void BlogSettings::slotBlogEdited(
const BilboBlog &blog )
91 QTreeWidgetItem * item = blogsTable->currentItem();
93 item->setText(0,blog.
title());
94 item->setText(1,blog.
blogUrl());
100 QTreeWidgetItem * item = blogsTable->currentItem();
102 if(KMessageBox::warningYesNo(
this, i18n(
"Are you sure you want to remove the selected blog?"))
105 const int blog_id = item->data( 0, BlogId ).toInt();
107 delete blogsTable->currentItem();
111 kError()<<
"Cannot remove blog with id "<<blog_id;
119 const int count = list.count();
120 for(
int i=0; i<count; ++i) {
121 addBlogToList( *list[i] );
125 void BlogSettings::blogsTablestateChanged()
127 if ( blogsTable->currentItem() ) {
128 btnEdit->setEnabled(
true );
129 btnRemove->setEnabled(
true );
131 btnEdit->setEnabled(
false );
132 btnRemove->setEnabled(
false );
136 void BlogSettings::addBlogToList(
const BilboBlog &blog )
138 QTreeWidgetItem *item =
new QTreeWidgetItem( blogsTable, QStringList()<<blog.
title()<<blog.
blogUrl() );
139 item->setData(0, BlogId, blog.
id());
142 #include "blogsettings.moc"
void blogEdited(const BilboBlog &blog)
static DBMan * self()
Retrieve the instance of DataBase Manager.
BlogSettings(QWidget *parent=0)
void blogAdded(const BilboBlog &blog)
const QMap< int, BilboBlog * > & blogList() const
QString blogUrl() const
return Blog Actual Url! For http://bilbo.wordpress.com : it's url() is http://bilbo.wordpress.com/xmlrpc.php and it's blogUrl() is http://bilbo.wordpress.com/
void blogRemoved(int blog_id)