Source Code (Use browser search to find items of interest.)

Class Index

kbiff'KBiffSetup (./kdenetwork/kbiff/setupdlg.h:45)

class KBiffSetup : public QDialog
{
	Q_OBJECT
public:
	KBiffSetup(const QString& name = QString::null, bool secure = false);
	virtual ~KBiffSetup();

	const QString getProfile() const;
	const KBiffURL getCurrentMailbox() const;
	const QList<KBiffURL> getMailboxList() const;

	const QString getMailClient() const;
	const QString getRunCommandPath() const;
	const QString getPlaySoundPath() const;
	const QString getNoMailIcon() const;
	const QString getNewMailIcon() const;
	const QString getOldMailIcon() const;
	const QString getNoConnIcon() const;
	const bool getSystemBeep() const;
	const bool getRunCommand() const;
	const bool getPlaySound() const;
	const bool getNotify() const;
	const bool getStatus() const;
	const bool getDock() const;
	const bool getSessionManagement() const;
	const bool getCheckStartup() const;
	const bool getSecure() const;
	const unsigned int getPoll() const;

signals:
	void signalPlaySound(const QString&);

public slots:
	void invokeHelp();

	void readConfig(const QString& profile);
	void saveConfig();

protected:
	QString getSomeProfile() const;

protected slots:
	void slotDone();
	void slotAddNewProfile();
	void slotRenameProfile();
	void slotDeleteProfile();
	void slotPlaySoundRelay(const QString&);

private:
	bool isSecure;

	// "outer" dialog
	QComboBox   *comboProfile;

	// tabs
	KBiffGeneralTab *generalTab;
	KBiffNewMailTab *newmailTab;
	KBiffMailboxTab *mailboxTab;
	KBiffAboutTab   *aboutTab;
};


kbiff'KBiffSetup::KBiffSetup() (./kdenetwork/kbiff/setupdlg.cpp:65)

KBiffSetup::KBiffSetup(const QString& profile, bool secure)
	: QDialog(0, 0, true, 0)
{
TRACEINIT("KBiffSetup::KBiffSetup()");
	// set the icon just to be cute
	setIcon(kapp->miniIcon());

	// make sure the profile is *something*
	QString the_profile;
	if (profile.isEmpty())
		the_profile = getSomeProfile();
	else
		the_profile = profile;

	setCaption(i18n("KBiff Setup"));

	// The profile combo box and buttons all go in this groupbox
	QGroupBox* profile_groupbox = new QGroupBox(i18n("Profile"), this);

	// combo box to hold the profile names
	comboProfile = new QComboBox(false, profile_groupbox);
	comboProfile->setSizeLimit(10);

    QString whatsthis = i18n(
        "This is a list of all of the KBiff <b>profiles</b><p>"
        "A profile is a logical grouping of settings for either one "
        "mailbox or several mailboxes.  Each profile gets one icon "
        "and one new mail sound and one... well, everything");
    QWhatsThis::add(comboProfile, whatsthis);

	// Add New Profile button
	QPushButton *new_profile_button = new QPushButton(i18n("&New..."),
	                                                  profile_groupbox);
    whatsthis = i18n("Create a new profile");
    QWhatsThis::add(new_profile_button, whatsthis);
	connect(new_profile_button, SIGNAL(clicked()),
	                            SLOT(slotAddNewProfile()));

	// Renam Profile button
	QPushButton *rename_profile_button = new QPushButton(i18n("&Rename..."),
	                                                     profile_groupbox);
    whatsthis = i18n("Rename the current profile");
    QWhatsThis::add(rename_profile_button, whatsthis);
	connect(rename_profile_button, SIGNAL(clicked()),
	                               SLOT(slotRenameProfile()));

	// Delete Profile button
	QPushButton *delete_profile_button = new QPushButton(i18n("&Delete"),
	                                                     profile_groupbox);
    whatsthis = i18n("Delete the current profile");
    QWhatsThis::add(delete_profile_button, whatsthis);
	connect(delete_profile_button, SIGNAL(clicked()),
	                               SLOT(slotDeleteProfile()));

	// setup the tabs
	QTabWidget *tabctl = new QTabWidget(this);
	generalTab = new KBiffGeneralTab(the_profile, tabctl);
	newmailTab = new KBiffNewMailTab(the_profile, tabctl);
	mailboxTab = new KBiffMailboxTab(the_profile, tabctl);
	aboutTab   = new KBiffAboutTab(tabctl); 

	connect(comboProfile, SIGNAL(highlighted(const QString&)),
	        generalTab, SLOT(readConfig(const QString&)));
	connect(comboProfile, SIGNAL(highlighted(const QString&)),
	        newmailTab, SLOT(readConfig(const QString&)));
	connect(comboProfile, SIGNAL(highlighted(const QString&)),
	        mailboxTab, SLOT(readConfig(const QString&)));

	// add the tabs
	tabctl->addTab(generalTab, i18n("General"));
	tabctl->addTab(newmailTab, i18n("New Mail"));
	tabctl->addTab(mailboxTab, i18n("Mailbox"));
	tabctl->addTab(aboutTab, i18n("About"));

	// help button
	QPushButton *help_button = new QPushButton(i18n("&Help"), this);
	connect(help_button, SIGNAL(clicked()), SLOT(invokeHelp()));

	// ok button
	QPushButton *ok_button = new QPushButton(i18n("&OK"), this);
	ok_button->setDefault(true);
	connect(ok_button, SIGNAL(clicked()), SLOT(slotDone()));

	// cancel button
	QPushButton *cancel_button = new QPushButton(i18n("&Cancel"), this);
	connect(cancel_button, SIGNAL(clicked()), SLOT(reject()));

	// are we secure?
	isSecure = secure;

	// NOW, SETUP ALL THE LAYOUTS!
	// This layout handles the buttons for the profile combobox
	QBoxLayout *pro_button_layout = new QBoxLayout(QBoxLayout::LeftToRight, 12);
	pro_button_layout->addWidget(new_profile_button);
	pro_button_layout->addWidget(rename_profile_button);
	pro_button_layout->addWidget(delete_profile_button);

	// This layout handles the upper profile groupbox
	QBoxLayout *profile_layout = new QBoxLayout(profile_groupbox,
	                                            QBoxLayout::Down, 12);
	profile_layout->addSpacing(8);
	profile_layout->addWidget(comboProfile);
	profile_layout->addLayout(pro_button_layout);

	// This layout handles the dialog buttons
	QBoxLayout *dialog_button_layout = new QBoxLayout(QBoxLayout::LeftToRight,
													  12);
	dialog_button_layout->addWidget(help_button);
	dialog_button_layout->addStretch(1);
	dialog_button_layout->addWidget(ok_button);
	dialog_button_layout->addWidget(cancel_button);

	// This is the outermost layout
	QBoxLayout *top_layout = new QBoxLayout(this, QBoxLayout::Down, 12);
	top_layout->addWidget(profile_groupbox);
	top_layout->addWidget(tabctl, 1);
	top_layout->addLayout(dialog_button_layout);

	// Read in the config for this profile
	readConfig(the_profile);
}


kbiff'KBiffSetup::~KBiffSetup() (./kdenetwork/kbiff/setupdlg.cpp:187)

KBiffSetup::~KBiffSetup()
{
}


kbiff'KBiffSetup::slotPlaySoundRelay() (./kdenetwork/kbiff/setupdlg.cpp:191)

void KBiffSetup::slotPlaySoundRelay(const QString& play_sound)
{
	emit(signalPlaySound(play_sound));
}


kbiff'KBiffSetup::getSecure() (./kdenetwork/kbiff/setupdlg.cpp:196)

const bool KBiffSetup::getSecure() const
{
	return isSecure;
}


kbiff'KBiffSetup::getProfile() (./kdenetwork/kbiff/setupdlg.cpp:201)

const QString KBiffSetup::getProfile() const
{
	return comboProfile->currentText();
}


kbiff'KBiffSetup::getCurrentMailbox() (./kdenetwork/kbiff/setupdlg.cpp:206)

const KBiffURL KBiffSetup::getCurrentMailbox() const
{
	return mailboxTab->getMailbox();
}


kbiff'KBiffSetup::getMailboxList() (./kdenetwork/kbiff/setupdlg.cpp:211)

const QList<KBiffURL> KBiffSetup::getMailboxList() const
{
	return mailboxTab->getMailboxList();
}


kbiff'KBiffSetup::getMailClient() (./kdenetwork/kbiff/setupdlg.cpp:216)

const QString KBiffSetup::getMailClient() const
{
	return generalTab->getMailClient();
}


kbiff'KBiffSetup::getNoMailIcon() (./kdenetwork/kbiff/setupdlg.cpp:221)

const QString KBiffSetup::getNoMailIcon() const
{
	return generalTab->getButtonNoMail();
}


kbiff'KBiffSetup::getNewMailIcon() (./kdenetwork/kbiff/setupdlg.cpp:226)

const QString KBiffSetup::getNewMailIcon() const
{
	return generalTab->getButtonNewMail();
}


kbiff'KBiffSetup::getOldMailIcon() (./kdenetwork/kbiff/setupdlg.cpp:231)

const QString KBiffSetup::getOldMailIcon() const
{
	return generalTab->getButtonOldMail();
}


kbiff'KBiffSetup::getNoConnIcon() (./kdenetwork/kbiff/setupdlg.cpp:236)

const QString KBiffSetup::getNoConnIcon() const
{
	return generalTab->getButtonNoConn();
}


kbiff'KBiffSetup::getSessionManagement() (./kdenetwork/kbiff/setupdlg.cpp:241)

const bool KBiffSetup::getSessionManagement() const
{
	return generalTab->getSessionManagement();
}


kbiff'KBiffSetup::getCheckStartup() (./kdenetwork/kbiff/setupdlg.cpp:246)

const bool KBiffSetup::getCheckStartup() const
{
	return generalTab->getCheckStartup();
}



kbiff'KBiffSetup::getDock() (./kdenetwork/kbiff/setupdlg.cpp:252)

const bool KBiffSetup::getDock() const
{
	return generalTab->getDock();
}


kbiff'KBiffSetup::getPoll() (./kdenetwork/kbiff/setupdlg.cpp:257)

const unsigned int KBiffSetup::getPoll() const
{
	return generalTab->getPoll();
}


kbiff'KBiffSetup::getRunCommandPath() (./kdenetwork/kbiff/setupdlg.cpp:262)

const QString KBiffSetup::getRunCommandPath() const
{
	return newmailTab->getRunCommandPath();
}


kbiff'KBiffSetup::getPlaySoundPath() (./kdenetwork/kbiff/setupdlg.cpp:267)

const QString KBiffSetup::getPlaySoundPath() const
{
	return newmailTab->getPlaySoundPath();
}


kbiff'KBiffSetup::getRunCommand() (./kdenetwork/kbiff/setupdlg.cpp:272)

const bool KBiffSetup::getRunCommand() const
{
	return newmailTab->getRunCommand();
}


kbiff'KBiffSetup::getPlaySound() (./kdenetwork/kbiff/setupdlg.cpp:277)

const bool KBiffSetup::getPlaySound() const
{
	return newmailTab->getPlaySound();
}


kbiff'KBiffSetup::getSystemBeep() (./kdenetwork/kbiff/setupdlg.cpp:282)

const bool KBiffSetup::getSystemBeep() const
{
	return newmailTab->getSystemBeep();
}


kbiff'KBiffSetup::getNotify() (./kdenetwork/kbiff/setupdlg.cpp:287)

const bool KBiffSetup::getNotify() const
{
	return newmailTab->getNotify();
}


kbiff'KBiffSetup::getStatus() (./kdenetwork/kbiff/setupdlg.cpp:292)

const bool KBiffSetup::getStatus() const
{
	return newmailTab->getStatus();
}


kbiff'KBiffSetup::invokeHelp() (./kdenetwork/kbiff/setupdlg.cpp:297)

void KBiffSetup::invokeHelp()
{
	kapp->invokeHTMLHelp("kbiff/kbiff.html", "");
}


kbiff'KBiffSetup::readConfig() (./kdenetwork/kbiff/setupdlg.cpp:302)

void KBiffSetup::readConfig(const QString& profile)
{
	QStrList profile_list;

	// open the config file
	KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE, true);
	config->setDollarExpansion(false);

	config->setGroup("General");

	// read in the mailboxes
	int number_of_mailboxes = config->readListEntry("Profiles", profile_list, ',');
	delete config;

	// check if we have any mailboxes to read in
	if (number_of_mailboxes > 0)
	{
		comboProfile->clear();

		// load up the combo box
		comboProfile->insertStrList(&profile_list);

		// read in the data from the first mailbox if we don't have a name
		for (int i = 0; i < comboProfile->count(); i++)
		{
			if (QString(profile) == comboProfile->text(i))
			{
				comboProfile->setCurrentItem(i);
				break;
			}
		}
	}
	else
		comboProfile->insertItem(profile);
}


kbiff'KBiffSetup::getSomeProfile() (./kdenetwork/kbiff/setupdlg.cpp:338)

QString KBiffSetup::getSomeProfile() const
{
TRACEINIT("KBiffSetup::getSomeProfile()");
	QStrList profile_list;

	// open the config file
	KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE, true);
	config->setGroup("General");

	// read in the mailboxes
	int number_of_mailboxes = config->readListEntry("Profiles", profile_list, ',');
	delete config;

TRACEF("first profile = %s", profile_list.getLast());
	// get the first mailbox if it exists
	if (number_of_mailboxes > 0)
		return QString(profile_list.getLast());
	else
		return QString("Inbox");
}


kbiff'KBiffSetup::saveConfig() (./kdenetwork/kbiff/setupdlg.cpp:359)

void KBiffSetup::saveConfig()
{
	// open the config file for writing
	KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE);

	config->setGroup("General");

	// get the list of profiles
	QStrList profile_list;
	for (int i = 0; i < comboProfile->count(); i++)
		profile_list.append(comboProfile->text(i));

	// write the mailboxes
	config->writeEntry("Profiles", profile_list, ',');

	delete config;
}

///////////////////////////////////////////////////////////////////////
// Protected slots
///////////////////////////////////////////////////////////////////////

kbiff'KBiffSetup::slotDone() (./kdenetwork/kbiff/setupdlg.cpp:380)

void KBiffSetup::slotDone()
{
TRACEINIT("KBiffSetup::slotDone()");
	QString profile = comboProfile->currentText();
	saveConfig();
	generalTab->saveConfig(profile);
	newmailTab->saveConfig(profile);
	mailboxTab->saveConfig(profile);
	accept();
}


kbiff'KBiffSetup::slotAddNewProfile() (./kdenetwork/kbiff/setupdlg.cpp:391)

void KBiffSetup::slotAddNewProfile()
{
	KBiffNewDlg dlg;

	// popup the name chooser
	dlg.setCaption(i18n("New Profile"));
	if (dlg.exec())
	{
		QString profile_name = dlg.getName();

		// bail out if we already have this name
		for (int i = 0; i < comboProfile->count(); i++)
		{
			if (profile_name == comboProfile->text(i))
				return;
		}

		// continue only if we received a decent name
		if (profile_name.isEmpty() == false)
		{
			comboProfile->insertItem(profile_name, 0);

			saveConfig();
			readConfig(profile_name);
			generalTab->readConfig(profile_name);
			newmailTab->readConfig(profile_name);
			mailboxTab->readConfig(profile_name);
		}
	}
}


kbiff'KBiffSetup::slotRenameProfile() (./kdenetwork/kbiff/setupdlg.cpp:422)

void KBiffSetup::slotRenameProfile()
{
	KBiffNewDlg dlg;
	QString title;
	QString old_profile = comboProfile->currentText();
	
	title = i18n("Rename Profile: %1").arg(old_profile);
	dlg.setCaption(title);
	// popup the name chooser
	if (dlg.exec())
	{
		QString profile_name = dlg.getName();

		// bail out if we already have this name
		for (int i = 0; i < comboProfile->count(); i++)
		{
			if (profile_name == comboProfile->text(i))
				return;
		}

		// continue only if we received a decent name
		if (profile_name.isNull() == false)
		{
			comboProfile->removeItem(comboProfile->currentItem());
			comboProfile->insertItem(profile_name, 0);

			// remove the reference from the config file
			KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE);
			// nuke the group
			config->deleteGroup(old_profile, true);
			delete config;

			// now save the profile settings
			saveConfig();
			generalTab->saveConfig(profile_name);
			newmailTab->saveConfig(profile_name);
			mailboxTab->saveConfig(profile_name);
		}
	}
}


kbiff'KBiffSetup::slotDeleteProfile() (./kdenetwork/kbiff/setupdlg.cpp:463)

void KBiffSetup::slotDeleteProfile()
{
	QString title, msg;
	QString profile = comboProfile->currentText();
	
	title = i18n("Delete Profile: %1").arg(profile);
	msg = i18n("Are you sure you wish to delete this profile?\n")
	             .arg(profile);
	
	switch (QMessageBox::warning(this, title, msg,
	                             QMessageBox::Yes | QMessageBox::Default,
	                             QMessageBox::No | QMessageBox::Escape))
	{
		case QMessageBox::Yes:
		{
			comboProfile->removeItem(comboProfile->currentItem());

			saveConfig();

			// remove the reference from the config file
			KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE);
			// nuke the group
			config->deleteGroup(profile, true);
			delete config;

			if (comboProfile->count() == 0)
			{
				readConfig("Inbox");
				generalTab->readConfig("Inbox");
				newmailTab->readConfig("Inbox");
				mailboxTab->readConfig("Inbox");
			}
			else
			{
				readConfig(comboProfile->currentText());
				generalTab->readConfig(comboProfile->currentText());
				newmailTab->readConfig(comboProfile->currentText());
				mailboxTab->readConfig(comboProfile->currentText());
			}

			break;
		}
		case QMessageBox::No:
		default:
			break;
	}
}
///////////////////////////////////////////////////////////////////////
// Protected (non-slot) functions
///////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////
// KBiffGeneralTab
///////////////////////////////////////////////////////////////////////