Ejemplo n.º 1
0
KingaFileManager::KingaFileManager(QWidget* parent) : QWidget(parent)
{
    // Main file manager
    QListWidget* file_list_widget = new QListWidget(this);
    // Change selection style for the list of files
    file_list_widget->setSelectionMode(QAbstractItemView::ContiguousSelection);
    // Enable drag and drop
    file_list_widget->setDragEnabled(true);
    file_list_widget->setDragDropMode(QAbstractItemView::InternalMove);
    file_list_widget->viewport()->setAcceptDrops(true);
    file_list_widget->setDropIndicatorShown(true);
    // Automatically scroll on drag
    file_list_widget->setAutoScroll(true);
    // Container for file actions, and buttons
    QWidget* box_file_buttons = new QWidget(this);
    QPushButton* button_add_files = new QPushButton(tr("Add Files"),this);
    QPushButton* button_add_recursively = new QPushButton(tr("Add Recursively"),this);
    QPushButton* button_file_move_up = new QPushButton(tr("Move Up"),this);
    QPushButton* button_file_move_down = new QPushButton(tr("Move Down"),this);
    QPushButton* button_file_remove = new QPushButton(tr("Remove"),this);

    // Layout: file action buttons
    QVBoxLayout* layout_file_buttons = new QVBoxLayout(box_file_buttons);
    layout_file_buttons->addWidget(button_add_files,0,Qt::AlignTop);
    layout_file_buttons->addWidget(button_add_recursively,0,Qt::AlignTop);
    layout_file_buttons->addWidget(button_file_move_up,0,Qt::AlignTop);
    layout_file_buttons->addWidget(button_file_move_down,0,Qt::AlignTop);
    layout_file_buttons->addWidget(button_file_remove,1,Qt::AlignTop);
    box_file_buttons->setLayout(layout_file_buttons);

    // Layout: main widget
    QHBoxLayout* layout_file_area = new QHBoxLayout(this);
    layout_file_area->addWidget(file_list_widget);
    layout_file_area->addWidget(box_file_buttons);
    setLayout(layout_file_area);

    // Assign create objects to private attributes
    FileListWidget = file_list_widget;
    AddFilesButton = button_add_files;
    AddRecursivelyButton = button_add_recursively;
    MoveUpButton = button_file_move_up;
    MoveDownButton = button_file_move_down;
    RemoveButton = button_file_remove;

    // Disable file buttons at creation
    MoveUpButton->setEnabled(false);
    MoveDownButton->setEnabled(false);
    RemoveButton->setEnabled(false);

    // Connections
    connect(FileListWidget,SIGNAL(itemSelectionChanged()),this,SLOT(OnSelectionChanged()));
    connect(AddFilesButton,SIGNAL(clicked()),this,SLOT(OnAddFilesClicked()));
    connect(AddRecursivelyButton,SIGNAL(clicked()),this,SLOT(OnAddRecursivelyClicked()));
    connect(MoveUpButton,SIGNAL(clicked()),this,SLOT(OnMoveUpClicked()));
    connect(MoveDownButton,SIGNAL(clicked()),this,SLOT(OnMoveDownClicked()));
    connect(RemoveButton,SIGNAL(clicked()),this,SLOT(OnRemoveClicked()));
}
Ejemplo n.º 2
0
   TaskEditor::TaskEditor(QWidget* parent)
      : QDialog(parent)
   {
      //dtUtil::Log::GetInstance("taskeditor.cpp").SetLogLevel(dtUtil::Log::LOG_DEBUG);
      QGroupBox*   group = new QGroupBox(tr("Tasks"));
      QGridLayout* grid  = new QGridLayout(group);

      QVBoxLayout* rightSideLayout = new QVBoxLayout;
      QLabel*      child = new QLabel(tr("Children"));
      grid->addWidget(child, 0, 0);


      mChildrenView = new QTableWidget(NULL);
      mChildrenView->setSelectionMode(QAbstractItemView::SingleSelection);
      mChildrenView->setSelectionBehavior(QAbstractItemView::SelectRows);
      mChildrenView->setAlternatingRowColors(true);
      mChildrenView->setEditTriggers(QAbstractItemView::NoEditTriggers);
      grid->addWidget(mChildrenView, 1, 0);

      mAddExisting = new QPushButton(tr("Add Existing"));

      mComboBox = new QComboBox;
      mComboBox->setEditable(false);

      mShowTasksWithParents = new QCheckBox("Show Tasks With Parents");
      mShowTasksWithParents->setCheckState(Qt::Unchecked);
      mShowTasksWithParents->setTristate(false);

      rightSideLayout->addWidget(mAddExisting);
      rightSideLayout->addWidget(mComboBox);
      rightSideLayout->addWidget(mShowTasksWithParents);
      rightSideLayout->addStretch(1);

      grid->addLayout(rightSideLayout, 0, 1, 2, 1);

      QHBoxLayout* buttonLayout = new QHBoxLayout;
      mMoveUp = new QPushButton(tr("Move Up"));
      mMoveDown = new QPushButton(tr("Move Down"));
      buttonLayout->addWidget(mMoveUp);
      buttonLayout->addStretch(1);
      buttonLayout->addWidget(mMoveDown);
      grid->addLayout(buttonLayout, 2, 0);

      mRemoveChild = new QPushButton(tr("Remove Child"));
      grid->addWidget(mRemoveChild, 3, 0);

      QHBoxLayout* okCancelLayout = new QHBoxLayout;
      QPushButton* ok             = new QPushButton(tr("OK"));
      QPushButton* cancel         = new QPushButton(tr("Cancel"));
      okCancelLayout->addStretch(1);
      okCancelLayout->addWidget(ok);
      okCancelLayout->addStretch(1);
      okCancelLayout->addWidget(cancel);
      okCancelLayout->addStretch(1);

      QVBoxLayout* mainLayout = new QVBoxLayout(this);
      mainLayout->addWidget(group);
      mainLayout->addLayout(okCancelLayout);

      setModal(true);
      setWindowTitle(tr("Task Editor"));
      //setMinimumSize(360, 375);

      connect(mComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnComboSelectionChanged(int)));
      connect(mAddExisting, SIGNAL(clicked()), this, SLOT(AddSelected()));

      connect(mShowTasksWithParents, SIGNAL(stateChanged(int)), this, SLOT(OnShowTasksWithParentsChanged(int)));

      connect(mMoveUp,       SIGNAL(clicked()), this, SLOT(OnMoveUpClicked()));
      connect(mMoveDown,     SIGNAL(clicked()), this, SLOT(OnMoveDownClicked()));
      connect(mRemoveChild,  SIGNAL(clicked()), this, SLOT(OnRemoveChildClicked()));
      connect(ok,            SIGNAL(clicked()), this, SLOT(OnOkClicked()));
      connect(cancel,        SIGNAL(clicked()), this, SLOT(close()));
      connect(mChildrenView, SIGNAL(itemSelectionChanged()), this, SLOT(EnableEditButtons()));

      RefreshComboBox("");
   }