Commit 2b57c947 authored by Laurent Montel's avatar Laurent Montel 😁

Cleanup

parent 0ce62b36
......@@ -220,9 +220,9 @@ void AddEditBlog::gotHtml( KJob *job )
while (textUrl.endsWith(QChar('/'))) {
textUrl.remove(textUrl.length()-1, 1);
}
d->ui.txtUrl->setText( textUrl + "/xmlrpc.php" );
fetchBlogId();
return;
d->ui.txtUrl->setText( textUrl + "/xmlrpc.php" );
fetchBlogId();
return;
}
// add MT for WordpressBuggy -> URL/xmlrpc.php exists
......@@ -484,11 +484,11 @@ AddEditBlog::~AddEditBlog()
void AddEditBlog::setSupportedFeatures( BilboBlog::ApiType api )
{
QString yesStyle = "QLabel{color: green;}";
QString yesText = i18nc( "Supported feature or Not", "Yes" );
QString noStyle = "QLabel{color: red;}";
QString noText = i18nc( "Supported feature or Not", "No, API does not support it" );
QString notYetText = i18nc( "Supported feature or Not", "No, Blogilo does not yet support it" );
const QString yesStyle = "QLabel{color: green;}";
const QString yesText = i18nc( "Supported feature or Not", "Yes" );
const QString noStyle = "QLabel{color: red;}";
const QString noText = i18nc( "Supported feature or Not", "No, API does not support it" );
const QString notYetText = i18nc( "Supported feature or Not", "No, Blogilo does not yet support it" );
d->ui.featureCreatePost->setText( yesText );
d->ui.featureCreatePost->setStyleSheet( yesStyle );
......
......@@ -60,7 +60,7 @@ public:
};
Backend::Backend( int blog_id, QObject* parent )
: QObject( parent ), d(new Private)
: QObject( parent ), d(new Private)
{
kDebug() << "with blog id: " << blog_id;
d->bBlog = DBMan::self()->blog( blog_id );
......@@ -86,9 +86,10 @@ Backend::~Backend()
void Backend::getCategoryListFromServer()
{
kDebug() << "Blog Id: " << d->bBlog->id();
if ( d->bBlog->api() == BilboBlog::METAWEBLOG_API || d->bBlog->api() == BilboBlog::MOVABLETYPE_API ||
if ( d->bBlog->api() == BilboBlog::METAWEBLOG_API ||
d->bBlog->api() == BilboBlog::MOVABLETYPE_API ||
d->bBlog->api() == BilboBlog::WORDPRESSBUGGY_API ) {
KBlog::MetaWeblog *tmp = dynamic_cast<KBlog::MetaWeblog*>( d->kBlog );
KBlog::MetaWeblog *tmp = static_cast<KBlog::MetaWeblog*>( d->kBlog );
connect( tmp, SIGNAL(listedCategories(QList<QMap<QString,QString> >)),
this, SLOT(categoriesListed(QList<QMap<QString,QString> >)) );
tmp->listCategories();
......@@ -103,15 +104,14 @@ void Backend::categoriesListed( const QList< QMap < QString , QString > > & cate
DBMan::self()->clearCategories( d->bBlog->id() );
for ( int i = 0; i < categories.count(); ++i ) {
QString name, description, htmlUrl, rssUrl, categoryId, parentId;
const QMap<QString, QString> &category = categories.at( i );
name = category.value( "name", QString() );
description = category.value( "description", QString() );
htmlUrl = category.value( "htmlUrl", QString() );
rssUrl = category.value( "rssUrl", QString() );
categoryId = category.value( "categoryId", QString() );
parentId = category.value( "parentId", QString() );
const QString name = category.value( "name", QString() );
const QString description = category.value( "description", QString() );
const QString htmlUrl = category.value( "htmlUrl", QString() );
const QString rssUrl = category.value( "rssUrl", QString() );
QString categoryId = category.value( "categoryId", QString() );
const QString parentId = category.value( "parentId", QString() );
if(categoryId.isEmpty()) {
categoryId = QString::number(i);
......
......@@ -41,6 +41,7 @@ int main( int argc, char *argv[] )
KLocalizedString(), "http://blogilo.gnufolks.org" );
about.addAuthor( ki18n( "Mehrdad Momeny" ), ki18n( "Core Developer" ), "mehrdad.momeny@gmail.com" );
about.addAuthor( ki18n( "Golnaz Nilieh" ), ki18n( "Core Developer" ), "g382nilieh@gmail.com" );
about.addAuthor( ki18n( "Laurent Montel" ), ki18n( "Core Developer" ), "montel@kde.org" );
about.addCredit( ki18n( "Roozbeh Shafiee" ), ki18n( "Icon designer" ), "roozbeh@roozbehonline.com");
about.addCredit( ki18n( "Sajjad Baroodkoo" ), ki18n( "Icon designer" ), "sajjad@graphit.ir");
......
......@@ -32,9 +32,7 @@
#include "bilbomedia.h"
#include "settings.h"
#include "bilboblog.h"
// #include "composer/multilinetextedit.h"
#include "blogsettings.h"
// #include "htmleditor.h"
#include "ui_advancedsettingsbase.h"
#include "ui_settingsbase.h"
......@@ -319,8 +317,8 @@ void MainWindow::slotSettingsChanged()
void MainWindow::slotDialogDestroyed( QObject *win )
{
QSize size = qobject_cast<QWidget *>(win)->size();
QString name = win->objectName();
const QSize size = qobject_cast<QWidget *>(win)->size();
const QString name = win->objectName();
if(name == "settings") {
Settings::setConfigWindowSize( size );
}
......@@ -350,7 +348,7 @@ void MainWindow::slotBlogAdded( const BilboBlog &blog )
void MainWindow::slotBlogEdited( const BilboBlog &blog )
{
int count = blogs->actions().count();
const int count = blogs->actions().count();
for(int i=0; i< count; ++i){
if( blogs->action( i )->data().toInt() == blog.id() ) {
blogs->action( i )->setText( blog.title() );
......@@ -446,12 +444,10 @@ void MainWindow::slotPublishPost()
kDebug();
if ( mCurrentBlogId == -1 ) {
KMessageBox::sorry( this, i18n( "You have to select a blog to publish this post to." ) );
kDebug() << "Blog id not sets correctly.";
return;
}
if( !activePost || tabPosts->currentIndex() == -1) {
KMessageBox::sorry( this, i18n( "There is no open post to submit." ) );
kDebug() << "There isn't any post";
return;
}
toolbox->getFieldsValue( activePost->currentPost() );
......
......@@ -197,7 +197,8 @@ void PostEntry::slotSyncEditors(int index)
if ( index == 0 ) {
if ( d->prev_index == 2 ) {
d->previewer->stop();
goto SyncEnd;
d->prev_index = index;
return;
}//An else clause can do the job of goto, No? -Mehrdad :D
d->wysiwygEditor->setHtmlContent(d->htmlEditor->document()->text());
d->wysiwygEditor->setFocus();
......@@ -205,7 +206,8 @@ void PostEntry::slotSyncEditors(int index)
} else if ( index == 1 ) {
if ( d->prev_index == 2 ) {
d->previewer->stop();
goto SyncEnd;
d->prev_index = index;
return;
}
d->htmlEditor->document()->setText( d->wysiwygEditor->htmlContent() );
d->htmlEditor->setFocus();
......@@ -217,7 +219,6 @@ void PostEntry::slotSyncEditors(int index)
}
d->previewer->setHtml( d->txtTitle->text(), d->htmlEditor->document()->text() );
}
SyncEnd:
d->prev_index = index;
}
......@@ -228,7 +229,7 @@ void PostEntry::slotSetPostPreview()
}
}
QString PostEntry::htmlContent()
QString PostEntry::htmlContent() const
{
if ( d->tabWidget->currentIndex() == 1 ) {
d->wysiwygEditor->setHtmlContent( d->htmlEditor->document()->text() );
......@@ -359,7 +360,7 @@ bool PostEntry::uploadMediaFiles( Backend *backend )
backend = new Backend( d->mCurrentPostBlogId, this );
}
QList<BilboMedia*> lImages = localImages();
if( lImages.size()>0 ) {
if( !lImages.isEmpty() ) {
showProgressBar();
QList<BilboMedia*>::iterator it = lImages.begin();
QList<BilboMedia*>::iterator endIt = lImages.end();
......@@ -486,8 +487,8 @@ void PostEntry::deleteProgressBar()
if(d->progress){
this->layout()->removeWidget( d->progress );
d->progress->deleteLater();
d->progress = 0L;
}
d->progress = 0L;
}
void PostEntry::saveLocally()
......
......@@ -142,7 +142,7 @@ protected:
* then copies the content of HtmlEditor into the variable mHtmlContent, and returns it.
* @return an String which contains html text
*/
QString htmlContent();
QString htmlContent() const;
QString plainTextContent() const;
......
......@@ -47,6 +47,7 @@ SyncUploader::SyncUploader( QObject *parent )
:QObject(parent),d(new Private)
{
}
SyncUploader::~SyncUploader()
{
delete d;
......
......@@ -38,7 +38,6 @@
#include "backend.h"
#include "bilbopost.h"
#include "bilboblog.h"
// #include "blogradiobutton.h"
#include "catcheckbox.h"
#include <KMenu>
#include <KAction>
......@@ -55,7 +54,7 @@ public:
KStatusBar *statusbar;
};
Toolbox::Toolbox( QWidget *parent )
: QWidget( parent ), d(new Private)
: QWidget( parent ), d(new Private)
{
kDebug();
d->mCurrentBlogId = -1;
......@@ -102,6 +101,13 @@ Toolbox::Toolbox( QWidget *parent )
QTimer::singleShot(1000, this, SLOT(reloadLocalPosts()));
}
Toolbox::~Toolbox()
{
kDebug();
delete d;
}
void Toolbox::setCurrentBlogId( int blog_id )
{
kDebug()<<blog_id;
......@@ -124,8 +130,7 @@ void Toolbox::slotReloadCategoryList()
kDebug();
// QAbstractButton *btn = listBlogRadioButtons.checkedButton();
if ( d->mCurrentBlogId == -1 ) {
KMessageBox::sorry( this, i18n( "No blog has been selected: \
you have to select a blog from the Blogs page before asking for the list of categories." ) );
KMessageBox::sorry( this, i18n( "No blog has been selected: you have to select a blog from the Blogs page before asking for the list of categories." ) );
return;
}
......@@ -142,9 +147,7 @@ void Toolbox::slotUpdateEntries(int count)
{
kDebug();
if ( d->mCurrentBlogId == -1 ) {
KMessageBox::sorry( this, i18n( "No blog has been selected: \
you have to select a blog from the Blogs page before asking for the list of entries." ) );
kDebug() << "There isn't any selected blog.";
KMessageBox::sorry( this, i18n( "No blog has been selected: you have to select a blog from the Blogs page before asking for the list of entries." ) );
return;
}
if(count == 0) {
......@@ -223,8 +226,7 @@ void Toolbox::slotRemoveSelectedEntryFromServer()
{
if(lstEntriesList->selectedItems().count() < 1)
return;
if( KMessageBox::warningYesNoCancel(this, i18n( "Removing a post from your blog cannot be undone.\
\nAre you sure you want to remove the post with title \"%1\" from your blog?", lstEntriesList->currentItem()->text() ))
if( KMessageBox::warningYesNoCancel(this, i18n( "Removing a post from your blog cannot be undone.\nAre you sure you want to remove the post with title \"%1\" from your blog?", lstEntriesList->currentItem()->text() ))
== KMessageBox::Yes) {
BilboPost *post = new BilboPost( DBMan::self()->getPostInfo( lstEntriesList->currentItem()->
data(32).toInt() ) );
......@@ -364,7 +366,7 @@ QList< Category > Toolbox::selectedCategories()
{
kDebug();
QList<Category> list;
int count = d->listCategoryCheckBoxes.count();
const int count = d->listCategoryCheckBoxes.count();
for ( int i = 0; i < count; ++i ) {
if ( d->listCategoryCheckBoxes.at(i)->isChecked() )
list.append( d->listCategoryCheckBoxes.at(i)->category() );
......@@ -397,8 +399,7 @@ void Toolbox::setSelectedCategories( const QStringList &list )
QStringList Toolbox::currentTags()
{
kDebug();
QStringList t;
t = txtCatTags->text().split( QRegExp( QString::fromUtf8(",|،") ), QString::SkipEmptyParts );
QStringList t = txtCatTags->text().split( QRegExp( QString::fromUtf8(",|،") ), QString::SkipEmptyParts );
for ( int i = 0; i < t.count() ; ++i ) {
t[i] = t[i].trimmed();
}
......@@ -433,15 +434,9 @@ void Toolbox::slotEntriesCopyUrl()
KMessageBox::sorry(this, i18n( "No link field is available in the database for this entry." ) );
}
Toolbox::~Toolbox()
{
kDebug();
delete d;
}
void Toolbox::unCheckCatList()
{
int count = d->listCategoryCheckBoxes.count();
const int count = d->listCategoryCheckBoxes.count();
for ( int j = 0; j < count; ++j ) {
d->listCategoryCheckBoxes.at(j)->setChecked( false );
}
......@@ -479,15 +474,15 @@ void Toolbox::reloadLocalPosts()
for (int i=0; i < count; ++i){
int newRow = localEntriesTable->rowCount();
localEntriesTable->insertRow(newRow);
QString postTitle = localList[i].value( "post_title" ).toString();
QString postTitle = localList.at(i).value( "post_title" ).toString();
QTableWidgetItem *item1 = new QTableWidgetItem( postTitle );
item1->setToolTip( postTitle );
item1->setData(32, localList[i].value( "local_id" ).toInt());//Post_id
item1->setData(32, localList.at(i).value( "local_id" ).toInt());//Post_id
localEntriesTable->setItem( newRow, 0, item1 );
QString blogTitle = localList[i].value( "blog_title" ).toString();
QString blogTitle = localList.at(i).value( "blog_title" ).toString();
QTableWidgetItem *item2 = new QTableWidgetItem( blogTitle );
item2->setToolTip( blogTitle );
item2->setData(32, localList[i].value( "blog_id" ).toInt());//blog_id
item2->setData(32, localList.at(i).value( "blog_id" ).toInt());//blog_id
localEntriesTable->setItem( newRow, 1, item2 );
}
}
......
......@@ -40,14 +40,15 @@
#include <kio/jobclasses.h>
#include <kio/job.h>
UploadMediaDialog::UploadMediaDialog( QWidget *parent ) :
KDialog(parent), mCurrentBlog(0)
UploadMediaDialog::UploadMediaDialog( QWidget *parent )
: KDialog(parent), mCurrentBlog(0)
{
kDebug();
QWidget *widget = new QWidget;
ui.setupUi(widget);
this->setMainWidget(widget);
this->setAttribute(Qt::WA_DeleteOnClose);
setMainWidget(widget);
setAttribute(Qt::WA_DeleteOnClose);
setButtonText(KDialog::Ok, i18n("Upload") );
setWindowTitle( i18n( "Upload Media..." ) );
ui.kcfg_FtpPath->setText(Settings::ftpServerPath());
......@@ -111,7 +112,7 @@ bool UploadMediaDialog::selectNewFile()
void UploadMediaDialog::slotUploadTypeChanged(int index)
{
UploadType type = (UploadType)ui.kcfg_uploadType->itemData(index).toInt();
UploadType type = static_cast<UploadType>(ui.kcfg_uploadType->itemData(index).toInt());
if(type == FTP) {
ui.kcfg_ftpBox->setEnabled(true);
} else {
......@@ -122,7 +123,7 @@ void UploadMediaDialog::slotUploadTypeChanged(int index)
void UploadMediaDialog::slotButtonClicked(int button)
{
if(button == KDialog::Ok) {
UploadType type = (UploadType)ui.kcfg_uploadType->itemData(ui.kcfg_uploadType->currentIndex()).toInt();
UploadType type = static_cast<UploadType>(ui.kcfg_uploadType->itemData(ui.kcfg_uploadType->currentIndex()).toInt());
if( type == BlogAPI ) {///Using API!
BilboMedia *media = new BilboMedia(this);
KUrl mediaUrl( ui.kcfg_urlLineEdit->text() );
......@@ -146,7 +147,7 @@ void UploadMediaDialog::slotButtonClicked(int button)
KUrl dest;
dest.setUrl(ui.kcfg_FtpPath->text() , QUrl::TolerantMode);
if( dest.isValid() ) {
if( dest.scheme() == "ftp" || dest.scheme() == "sftp" ) {
if( dest.scheme() == QLatin1String("ftp") || dest.scheme() == QLatin1String("sftp") ) {
KUrl src(ui.kcfg_urlLineEdit->text());
dest.addPath( ui.kcfg_Name->text().isEmpty() ? src.fileName() :
ui.kcfg_Name->text() );
......
......@@ -26,7 +26,8 @@
#include <kdebug.h>
WaitWidget::WaitWidget(QWidget* parent ): QDialog(parent)
WaitWidget::WaitWidget(QWidget* parent )
: QDialog(parent)
{
kDebug();
setupUi(this);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment