TableSettingsDialog::TableSettingsDialog(QWidget * parent) :
    QDialog(parent),
    ui(new Ui::TableSettingsDialog)
{
    ui->setupUi(this);

    ui->warningLine->clear();
    ui->warningLine->setHidden(true);

    QComboBox * pTableWidthModeComboBox = ui->tableWidthModeComboBox;
    pTableWidthModeComboBox->addItem(QObject::tr("pixels"));
    pTableWidthModeComboBox->addItem(QObject::tr("% of page width"));
    pTableWidthModeComboBox->setCurrentIndex(1);

    QObject::connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(onOkButtonPressed()));
    QObject::connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(onCancelButtonPressed()));
}
IrcConnectionWindow::IrcConnectionWindow(QWidget *parent) :
    QWidget(parent)
{
    layout = new QBoxLayout(QBoxLayout::LeftToRight, this);

    hbox = new QSplitter(this);

    ircNetworkTreeView = new QTreeWidget(this);
    ircConnectionForm = new QWidget(this);
    ircConnectionFormLayout = new QGridLayout(ircConnectionForm);

    ircServerNameLabel = new QLabel(ircConnectionForm);
    ircServerNameInput = new QLineEdit(ircConnectionForm);
    ircServerAddressLabel = new QLabel(ircConnectionForm);
    ircServerAddressInput = new QLineEdit(ircConnectionForm);
    ircNicknameLabel = new QLabel(ircConnectionForm);
    ircNicknameInput = new QLineEdit(ircConnectionForm);
    ircConnectButton = new QPushButton(ircConnectionForm);
    ircCancelButton = new QPushButton(ircConnectionForm);

    QObject::connect(ircConnectButton, SIGNAL(clicked()),
                     this, SLOT(onConnectButtonPressed()));
    QObject::connect(ircCancelButton, SIGNAL(clicked()),
                     this, SLOT(onCancelButtonPressed()));
    QObject::connect(ircServerNameInput, SIGNAL(textChanged(QString)),
                     this, SLOT(onInformationChanged()));
    QObject::connect(ircServerAddressInput, SIGNAL(textChanged(QString)),
                     this, SLOT(onInformationChanged()));
    QObject::connect(ircNicknameInput, SIGNAL(textChanged(QString)),
                     this, SLOT(onInformationChanged()));

    ircServerNameLabel->setText("Server Name: ");
    ircServerAddressLabel->setText("Server Address: ");
    ircNicknameLabel->setText("Nickname: ");
    ircConnectButton->setText("Connect");
    ircConnectButton->setFixedWidth(80);
    ircConnectButton->setEnabled(false);
    ircCancelButton->setText("Cancel");
    ircCancelButton->setFixedWidth(80);

    ircConnectionFormLayout->addWidget(ircServerNameLabel, 0, 0, 1, 4);
    ircConnectionFormLayout->addWidget(ircServerNameInput, 1, 0, 1, 4);
    ircConnectionFormLayout->addWidget(ircServerAddressLabel, 2, 0, 1, 4);
    ircConnectionFormLayout->addWidget(ircServerAddressInput, 3, 0, 1, 4);
    ircConnectionFormLayout->addWidget(ircNicknameLabel, 4, 0, 1, 4);
    ircConnectionFormLayout->addWidget(ircNicknameInput, 5, 0, 1, 4);
    ircConnectionFormLayout->addWidget(ircConnectButton, 7, 1);
    ircConnectionFormLayout->addWidget(ircCancelButton, 7, 2);

    ircConnectionFormLayout->setHorizontalSpacing(80);
    ircConnectionFormLayout->setAlignment(Qt::AlignTop);
    ircConnectionForm->setLayout(ircConnectionFormLayout);

    ircNetworkTreeView->setColumnCount(1);
    ircNetworkTreeView->setHeaderLabel("IRC Servers");

    this->generateServerList();

    QObject::connect(ircNetworkTreeView,
                     SIGNAL(itemClicked(QTreeWidgetItem*,int)),
                     this, SLOT(onServerSelected(QTreeWidgetItem*)));

    ircNicknameInput->setText("Qirc");

    hbox->addWidget(ircNetworkTreeView);
    hbox->addWidget(ircConnectionForm);
    hbox->setStretchFactor(0, 3);
    hbox->setStretchFactor(1, 2);

    layout->addWidget(hbox);
    layout->setMargin(8);
    this->setLayout(layout);
    this->resize(800, 500);
    this->setWindowTitle("New Connection");
    this->setWindowIcon(QIcon("Qirc32.ico"));
}