Exemplo n.º 1
0
nspGUI::clsAddUserDialog::clsAddUserDialog(
        nspCore::clsUsersEngine *ptrNewUsersEngine,
        QWidget *ptrParent) : QDialog(ptrParent)
{
    ptrUsersEngine = ptrNewUsersEngine;

    ptrNickNameLabel = new QLabel("Никнейм");
    ptrNickNameLineEdit = new QLineEdit;

    ptrAddButton = new QPushButton("Добавить");
    connect(ptrAddButton,
            SIGNAL(clicked()),
            this,
            SLOT(slotAddButtonClicked())
            );

    ptrLayout = new QGridLayout;
    ptrLayout->addWidget(ptrNickNameLabel, 0, 0);
    ptrLayout->addWidget(ptrNickNameLineEdit, 0, 1);
    ptrLayout->addWidget(ptrAddButton, 1, 0, 1, 2);

    this->setLayout(ptrLayout);
    this->setWindowTitle("Добавить пользователя");
}
BookmarksSettingsPage::BookmarksSettingsPage(QWidget*parent) :
    SettingsPageBase(parent),
    m_addButton(0),
    m_removeButton(0),
    m_moveUpButton(0),
    m_moveDownButton(0)
{
    QVBoxLayout* topLayout = new QVBoxLayout(parent, 2, KDialog::spacingHint());

    const int spacing = KDialog::spacingHint();

    QHBox* hBox = new QHBox(parent);
    hBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    hBox->setSpacing(spacing);
    hBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);

    m_listView = new KListView(hBox);
    m_listView->addColumn(i18n("Icon"));
    m_listView->addColumn(i18n("Name"));
    m_listView->addColumn(i18n("Location"));
    m_listView->setResizeMode(QListView::LastColumn);
    m_listView->setColumnAlignment(0, Qt::AlignHCenter);
    m_listView->setAllColumnsShowFocus(true);
    m_listView->setSorting(-1);
    connect(m_listView, SIGNAL(selectionChanged()),
            this, SLOT(updateButtons()));
    connect(m_listView, SIGNAL(pressed(QListViewItem*)),
            this, SLOT(slotBookmarkPressed(QListViewItem*)));
    connect(m_listView, SIGNAL(doubleClicked(QListViewItem*, const QPoint&, int)),
            this, SLOT(slotBookmarkDoubleClicked(QListViewItem*, const QPoint&, int)));

    QVBox* buttonBox = new QVBox(hBox);
    buttonBox->setSpacing(spacing);

    const QSizePolicy buttonSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);

    m_addButton = new KPushButton(i18n("Add..."), buttonBox);
    connect(m_addButton, SIGNAL(clicked()),
            this, SLOT(slotAddButtonClicked()));
    m_addButton->setSizePolicy(buttonSizePolicy);

    m_editButton = new KPushButton(i18n("Edit..."), buttonBox);
    connect(m_editButton, SIGNAL(clicked()),
            this, SLOT(slotEditButtonClicked()));
    m_editButton->setSizePolicy(buttonSizePolicy);

    m_removeButton = new KPushButton(i18n("Remove"), buttonBox);
    connect(m_removeButton, SIGNAL(clicked()),
            this, SLOT(slotRemoveButtonClicked()));
    m_removeButton->setSizePolicy(buttonSizePolicy);

    m_moveUpButton = new KPushButton(i18n("Move Up"), buttonBox);
    connect(m_moveUpButton, SIGNAL(clicked()),
            this, SLOT(slotMoveUpButtonClicked()));
    m_moveUpButton->setSizePolicy(buttonSizePolicy);

    m_moveDownButton = new KPushButton(i18n("Move Down"), buttonBox);
    connect(m_moveDownButton, SIGNAL(clicked()),
            this, SLOT(slotMoveDownButtonClicked()));
    m_moveDownButton->setSizePolicy(buttonSizePolicy);

    // Add a dummy widget with no restriction regarding a vertical resizing.
    // This assures that the spacing between the buttons is not increased.
    new QWidget(buttonBox);

    topLayout->addWidget(hBox);

    // insert all editable bookmarks.
    KBookmarkGroup root = DolphinSettings::instance().bookmarkManager()->root();
    KBookmark bookmark = root.first();

    QListViewItem* prev = 0;
    while (!bookmark.isNull()) {
        QListViewItem* item = new QListViewItem(m_listView);
        item->setPixmap(PixmapIdx, SmallIcon(bookmark.icon()));
        item->setText(NameIdx, bookmark.text());
        item->setText(URLIdx, bookmark.url().prettyURL());

        // add hidden column to be able to retrieve the icon name again
        item->setText(IconIdx, bookmark.icon());

        m_listView->insertItem(item);
        if (prev != 0) {
            item->moveItem(prev);
        }
        prev = item;

        bookmark = root.next(bookmark);
    }
    m_listView->setSelected(m_listView->firstChild(), true);

    updateButtons();
}
Exemplo n.º 3
0
ResourceView::ResourceView( KCal::CalendarResources *calendar, QWidget *parent )
  : CalendarViewExtension( parent ), mCalendar( calendar )
{
  QVBoxLayout *topLayout = new QVBoxLayout( this );
  topLayout->setSpacing( KDialog::spacingHint() );

  QHBoxLayout *buttonBox = new QHBoxLayout();
  buttonBox->setSpacing( KDialog::spacingHint() );
  topLayout->addLayout( buttonBox );

  mListView = new QTreeWidget( this );
  mListView->setWhatsThis(
    i18nc( "@info:whatsthis",
           "This list shows all the calendars currently known to KOrganizer. "
           "Use the associated checkboxes to make a calendar active or inactive. "
           "Use the context menu to add, remove or edit calendars in the list."
           "<p>Events, journal entries and to-dos are retrieved and stored "
           "from their respective calendars. Calendars can be accessed from "
           "groupware servers, local files, etc...</p>"
           "<p>If you have more than one active calendar, you will be "
           "prompted for which calendar to store new items into, unless "
           "configured to always store to the default calendar.</p>" ) );
  mListView->setRootIsDecorated( false );
  mListView->setHeaderLabel( i18n( "Calendars" ) );
  mListView->header()->hide();
  topLayout->addWidget( mListView );

  mSelectedParent = 0;

  connect( mListView, SIGNAL(itemDoubleClicked(QTreeWidgetItem *,int)),
           SLOT(editResource()) );
  connect( mListView, SIGNAL(itemClicked(QTreeWidgetItem *,int)),
           SLOT(slotItemClicked(QTreeWidgetItem *,int)) );
  connect( mListView, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
           SLOT(currentChanged()) );

  mListView->setContextMenuPolicy( Qt::CustomContextMenu );
  connect( mListView, SIGNAL(customContextMenuRequested(const QPoint &)),
           SLOT(showContextMenu(const QPoint &)) );

  QLabel *calLabel = new QLabel( i18n( "Calendars" ), this );
  buttonBox->addWidget( calLabel );
  buttonBox->addStretch( 1 );

  mAddButton = new QToolButton( this );
  mAddButton->setIcon( KIcon( "list-add" ) );
  buttonBox->addWidget( mAddButton );
  mAddButton->setToolTip( i18nc( "@info:tooltip", "Add calendar" ) );
  mAddButton->setWhatsThis(
    i18nc( "@info:whatsthis",
           "Press this button to add a new calendar to KOrganizer. "
           "<p>Events, journal entries and to-dos are retrieved and stored "
           "from their respective calendars. Calendars can be accessed from "
           "groupware servers, local files, etc...</p>"
           "<p>If you have more than one active calendar, you will be "
           "prompted for which calendar to store new items into, unless "
           "configured to always store to the default calendar.</p>" ) );
  mEditButton = new QToolButton( this );
  mEditButton->setIcon( KIcon( "document-properties" ) );
  buttonBox->addWidget( mEditButton );
  mEditButton->setToolTip( i18nc( "@info:tooltip", "Edit calendar settings" ) );
  mEditButton->setWhatsThis(
    i18nc( "@info:whatsthis",
           "Press this button to edit the calendar currently "
           "selected in the list above." ) );
  mDeleteButton = new QToolButton( this );
  mDeleteButton->setIcon( KIcon( "edit-delete" ) );
  buttonBox->addWidget( mDeleteButton );
  mDeleteButton->setToolTip( i18nc( "@info:tooltip", "Remove calendar" ) );
  mDeleteButton->setWhatsThis(
    i18nc( "@info:whatsthis",
           "Press this button to delete the calendar currently "
           "selected in the list above." ) );
  mDeleteButton->setDisabled( true );
  mEditButton->setDisabled( true );

  connect( mAddButton, SIGNAL( clicked() ), SLOT( slotAddButtonClicked() ) );
  connect( mDeleteButton, SIGNAL( clicked() ), SLOT( removeResource() ) );
  connect( mEditButton, SIGNAL( clicked() ), SLOT( editResource() ) );

  setMinimumHeight( 50 );
  mListView->setSortingEnabled( true );

  updateView();
}