This is my first middle size patch. I compiled it and it seems to work allright. I've tried to follow some rules that I've seen spread in KDE source code when adding d-pointers.
If any comments, please tell me.
Bye,
Rafael Fernández López.
Index: kopete/kopete/addaccountwizard/addaccountwizard.cpp
===================================================================
--- kopete/kopete/addaccountwizard/addaccountwizard.cpp (revisión: 594695)
+++ kopete/kopete/addaccountwizard/addaccountwizard.cpp (copia de trabajo)
@@ -36,49 +36,80 @@
#include "kopeteprotocol.h"
#include "kopetepluginmanager.h"
+
+class AddAccountWizard::Private {
+ public:
+
+ Private()
+ :
+ m_accountPage(0),
+ m_proto(0)
+ {
+ }
+
+ QMap<QTreeWidgetItem *, KPluginInfo *> m_protocolItems;
+ #define _m_protocolItems d->m_protocolItems
+ KopeteEditAccountWidget *m_accountPage;
+ #define _m_accountPage d->m_accountPage
+ KVBox *m_accountPageWidget;
+ #define _m_accountPageWidget d->m_accountPageWidget
+ QWidget *m_selectService;
+ #define _m_selectService d->m_selectService
+ QWidget *m_finish;
+ #define _m_finish d->m_finish
+ Ui::AddAccountWizardPage1 m_uiSelectService;
+ #define _m_uiSelectService d->m_uiSelectService
+ Ui::AddAccountWizardPage2 m_uiFinish;
+ #define _m_uiFinish d->m_uiFinish
+ Kopete::Protocol *m_proto;
+ #define _m_proto d->m_proto
+ KPageWidgetItem *m_selectServiceItem;
+ #define _m_selectServiceItem d->m_selectServiceItem
+};
+
AddAccountWizard::AddAccountWizard( QWidget *parent, bool firstRun )
:
KAssistantDialog(parent),
- m_accountPage(0),
- m_proto(0)
+ d (new Private)
{
// setup the select service page
- m_selectService = new QWidget(this);
- m_uiSelectService.setupUi(m_selectService);
- m_uiSelectService.protocolListView->setColumnCount( 2 );
+ _m_selectService = new QWidget(this);
+ _m_uiSelectService.setupUi(_m_selectService);
+ _m_uiSelectService.protocolListView->setColumnCount( 2 );
QStringList header;
header << i18n("Name") << i18n("Description");
- m_uiSelectService.protocolListView->setHeaderLabels( header );
+ _m_uiSelectService.protocolListView->setHeaderLabels( header );
if ( firstRun )
- m_uiSelectService.m_header->setText( i18nc( "1st message shown
to users on first run of Kopete. Please keep the formatting.", "<h2>Welcome to
Kopete</h2><p>Which messaging service do you want to connect to?</p>") );
+ _m_uiSelectService.m_header->setText( i18nc( "1st message shown
to users on first run of Kopete. Please keep the formatting.", "<h2>Welcome to
Kopete</h2><p>Which messaging service do you want to connect to?</p>") );
- m_selectServiceItem =
addPage(m_selectService,m_selectService->windowTitle());
- setValid(m_selectServiceItem, false);
+ _m_selectServiceItem =
addPage(_m_selectService,_m_selectService->windowTitle());
+ setValid(_m_selectServiceItem, false);
- m_accountPageWidget = new KVBox(this);
- addPage(m_accountPageWidget,i18n("Step Two: Account Information"));
+ _m_accountPageWidget = new KVBox(this);
+ addPage(_m_accountPageWidget,i18n("Step Two: Account Information"));
// setup the final page
- m_finish = new QWidget(this);
- m_uiFinish.setupUi(m_finish);
+ _m_finish = new QWidget(this);
+ _m_uiFinish.setupUi(_m_finish);
if ( firstRun )
- m_uiFinish.m_header->setText( i18nc( "2nd message shown to
users on first run of Kopete. Please keep the formatting.",
"<h2>Congratulations</h2><p>You have finished configuring the account. You can
add more accounts with <i>Settings->Configure</i>. Please click the \"Finish\"
button.</p>") );
- addPage(m_finish,m_finish->windowTitle());
+ _m_uiFinish.m_header->setText( i18nc( "2nd message shown to
users on first run of Kopete. Please keep the formatting.",
"<h2>Congratulations</h2><p>You have finished configuring the account. You can
add more accounts with <i>Settings->Configure</i>. Please click the \"Finish\"
button.</p>") );
+ addPage(_m_finish,_m_finish->windowTitle());
+
// add the available messenger services to the dialogs list
QList<KPluginInfo *> protocols =
Kopete::PluginManager::self()->availablePlugins("Protocols");
for (QList<KPluginInfo *>::Iterator it = protocols.begin(); it !=
protocols.end(); ++it)
{
- QTreeWidgetItem *pluginItem = new
QTreeWidgetItem(m_uiSelectService.protocolListView);
+ QTreeWidgetItem *pluginItem = new
QTreeWidgetItem(_m_uiSelectService.protocolListView);
pluginItem->setIcon(0, QIcon(SmallIcon((*it)->icon())));
pluginItem->setText(0, (*it)->name());
pluginItem->setText(1, (*it)->comment());
- m_protocolItems.insert(pluginItem, *it);
+ _m_protocolItems.insert(pluginItem, *it);
}
// focus the ListView and select the first item
- QTreeWidget *protocol_list = m_uiSelectService.protocolListView;
+ QTreeWidget *protocol_list = _m_uiSelectService.protocolListView;
protocol_list->setFocus();
if (protocol_list->topLevelItemCount() > 0)
protocol_list->setItemSelected( protocol_list->topLevelItem(0),
true );
@@ -88,17 +119,17 @@
// hook up the user input
- connect(m_uiSelectService.protocolListView,
SIGNAL(itemClicked(QTreeWidgetItem *, int)),
+ connect(_m_uiSelectService.protocolListView,
SIGNAL(itemClicked(QTreeWidgetItem *, int)),
this, SLOT(slotProtocolListClicked()));
- connect(m_uiSelectService.protocolListView,
SIGNAL(itemSelectionChanged()),
+ connect(_m_uiSelectService.protocolListView,
SIGNAL(itemSelectionChanged()),
this, SLOT( slotProtocolListClicked()));
- connect(m_uiSelectService.protocolListView,
SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
+ connect(_m_uiSelectService.protocolListView,
SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
this, SLOT(slotProtocolListDoubleClicked()));
}
QTreeWidgetItem* AddAccountWizard::selectedProtocol()
{
- QList<QTreeWidgetItem*> selectedItems =
m_uiSelectService.protocolListView->selectedItems();
+ QList<QTreeWidgetItem*> selectedItems =
_m_uiSelectService.protocolListView->selectedItems();
if(!selectedItems.empty())
return selectedItems.first();
return 0;
@@ -107,7 +138,7 @@
void AddAccountWizard::slotProtocolListClicked()
{
// Make sure a protocol is selected before allowing the user to continue
- setValid(m_selectServiceItem, selectedProtocol() != 0);
+ setValid(_m_selectServiceItem, selectedProtocol() != 0);
}
void AddAccountWizard::slotProtocolListDoubleClicked()
@@ -118,13 +149,13 @@
void AddAccountWizard::back()
{
- if (currentPage()->widget() == m_accountPageWidget)
+ if (currentPage()->widget() == _m_accountPageWidget)
{
// Deletes the accountPage, K3Wizard does not like deleting
pages
// using different pointers, it only seems to watch its own
pointer
- delete m_accountPage;
- m_accountPage = 0;
- m_proto = 0;
+ delete _m_accountPage;
+ _m_accountPage = 0;
+ _m_proto = 0;
// removePage() already goes back to previous page, no back()
needed
}
@@ -133,24 +164,24 @@
void AddAccountWizard::next()
{
- if (currentPage()->widget() == m_selectService)
+ if (currentPage()->widget() == _m_selectService)
{
QTreeWidgetItem *lvi = selectedProtocol();
- if(!m_protocolItems[lvi])
+ if(!_m_protocolItems[lvi])
{ //no item selected
return;
}
- m_proto = qobject_cast<Kopete::Protocol
*>(Kopete::PluginManager::self()->loadPlugin(m_protocolItems[lvi]->pluginName()));
- if (!m_proto)
+ _m_proto = qobject_cast<Kopete::Protocol
*>(Kopete::PluginManager::self()->loadPlugin(_m_protocolItems[lvi]->pluginName()));
+ if (!_m_proto)
{
KMessageBox::queuedMessageBox(this, KMessageBox::Error,
- i18n("Cannot load the %1 protocol plugin.",
m_protocolItems[lvi]->name()),
+ i18n("Cannot load the %1 protocol plugin.",
_m_protocolItems[lvi]->name()),
i18n("Error While Adding Account"));
return;
}
- m_accountPage = m_proto->createEditAccountWidget(0,
m_accountPageWidget);
- if (!m_accountPage)
+ _m_accountPage = _m_proto->createEditAccountWidget(0,
_m_accountPageWidget);
+ if (!_m_accountPage)
{
KMessageBox::queuedMessageBox(this, KMessageBox::Error,
i18n("This protocol does not currently support
adding accounts."),
@@ -160,18 +191,18 @@
KAssistantDialog::next();
}
- else if (currentPage()->widget() == m_accountPageWidget)
+ else if (currentPage()->widget() == _m_accountPageWidget)
{
// check the data of the page is valid
- if (!m_accountPage->validateData())
+ if (!_m_accountPage->validateData())
{
return;
}
- QColor col =
Kopete::AccountManager::self()->guessColor(m_proto);
+ QColor col =
Kopete::AccountManager::self()->guessColor(_m_proto);
- m_uiFinish.mColorButton->setColor(col);
- m_uiFinish.mUseColor->setChecked(col.isValid());
+ _m_uiFinish.mColorButton->setColor(col);
+ _m_uiFinish.mUseColor->setChecked(col.isValid());
KAssistantDialog::next();
}
else
@@ -187,7 +218,7 @@
// registeredAccount shouldn't probably be called here. Anyway, if the
account is already registered,
// it won't be registered twice
Kopete::AccountManager *manager = Kopete::AccountManager::self();
- Kopete::Account *account =
manager->registerAccount(m_accountPage->apply());
+ Kopete::Account *account =
manager->registerAccount(_m_accountPage->apply());
// if the account wasn't created correctly then leave
if (!account)
@@ -196,17 +227,17 @@
}
// Make sure the protocol is correctly enabled. This is not really
needed, but still good
- const QString PROTO_NAME =
m_proto->pluginId().remove("Protocol").toLower();
+ const QString PROTO_NAME =
_m_proto->pluginId().remove("Protocol").toLower();
Kopete::PluginManager::self()->setPluginEnabled(PROTO_NAME , true);
// setup the custom colour
- if (m_uiFinish.mUseColor->isChecked())
+ if (_m_uiFinish.mUseColor->isChecked())
{
- account->setColor(m_uiFinish.mColorButton->color());
+ account->setColor(_m_uiFinish.mColorButton->color());
}
// connect if necessary
- if (m_uiFinish.mConnectNow->isChecked())
+ if (_m_uiFinish.mConnectNow->isChecked())
{
account->connect();
}
@@ -217,12 +248,12 @@
void AddAccountWizard::reject()
{
// if we have a protocol plugin loaded and its not being used, unload it
- if (m_proto)
+ if (_m_proto)
{
bool hasAccount=false;
foreach( Kopete::Account *act,
Kopete::AccountManager::self()->accounts() )
{
- if( act->protocol() == m_proto )
+ if( act->protocol() == _m_proto )
{
hasAccount=true;
break;
@@ -230,7 +261,7 @@
}
if(hasAccount)
{
- const QString PROTO_NAME =
m_proto->pluginId().remove("Protocol").toLower();
+ const QString PROTO_NAME =
_m_proto->pluginId().remove("Protocol").toLower();
Kopete::PluginManager::self()->unloadPlugin(PROTO_NAME);
}
}
Index: kopete/kopete/addaccountwizard/addaccountwizard.h
===================================================================
--- kopete/kopete/addaccountwizard/addaccountwizard.h (revisión: 594695)
+++ kopete/kopete/addaccountwizard/addaccountwizard.h (copia de trabajo)
@@ -63,17 +63,10 @@
virtual void reject();
private:
- QTreeWidgetItem* selectedProtocol();
+ QTreeWidgetItem* selectedProtocol();
- QMap<QTreeWidgetItem *, KPluginInfo *> m_protocolItems;
- KopeteEditAccountWidget *m_accountPage;
- KVBox *m_accountPageWidget;
- QWidget *m_selectService;
- QWidget *m_finish;
- Ui::AddAccountWizardPage1 m_uiSelectService;
- Ui::AddAccountWizardPage2 m_uiFinish;
- Kopete::Protocol *m_proto;
- KPageWidgetItem *m_selectServiceItem;
+ class Private;
+ Private *d;
};
#endif
_______________________________________________ kopete-devel mailing list [email protected] https://mail.kde.org/mailman/listinfo/kopete-devel
