Exemple #1
0
void ModuleTreeView::slotItemSelected(QListViewItem* item)
{
  if (!item) return;

  if (static_cast<ModuleTreeItem*>(item)->module())
    {
      emit moduleSelected(static_cast<ModuleTreeItem*>(item)->module());
      return;
    }
  else
    {
      emit categorySelected(item);
    }

  setOpen(item, !item->isOpen());

  /*
  else
    {
      QPtrList<QListViewItem> parents;

      QListViewItem* i = item;
      while(i)
        {
          parents.append(i);
          i = i->parent();
        }

      //int oy1 = item->itemPos();
      //int oy2 = mapFromGlobal(QCursor::pos()).y();
      //int offset = oy2 - oy1;

      expandItem(firstChild(), &parents);

      //int x =mapFromGlobal(QCursor::pos()).x();
      //int y = item->itemPos() + offset;
      //QCursor::setPos(mapToGlobal(QPoint(x, y)));
    }
  */
}
eduMAppMenu::eduMAppMenu(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::eduMAppMenu)
{
    ui->setupUi(this);
    this->setWindowFlags(Qt::FramelessWindowHint);

    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(showTime()));
    timer->start(1000);

    showTime();

    //currentDirectory = QDir::current();
    currentDirectory = QDir(qApp->applicationDirPath());
    categoriesNames = currentDirectory.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
    categories_layout = new QHBoxLayout;
    apps_layout= new QGridLayout;
    categoryButtonToButtonName_signalMapper = new QSignalMapper(this);
    appsButtonToButtonName_signalMapper = new QSignalMapper(this);
    categoriesWidget = new QWidget;
    appsWidget = new QWidget;
    appProcess = new QProcess(this);

    QString categoryName;
    QPushButton* button;
    if(!categoriesNames.isEmpty())
        for(int i=0; i<categoriesNames.size(); i++)
        {
            categoryName = categoriesNames.value(i);

            if(categoryName.startsWith("."))
                continue;

            categoriesButtons[categoryName]= new QPushButton(categoryName);

            button = categoriesButtons.value(categoriesNames.value(i));
            button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
            categories_layout->addWidget(button);

            categoryButtonToButtonName_signalMapper->setMapping(button, QString(categoryName));
            QObject::connect(button, SIGNAL(clicked()), categoryButtonToButtonName_signalMapper, SLOT(map()));
        }

    //options_pushButton = new QPushButton("Options");
    //options_pushButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
    //categories_layout->addWidget(options_pushButton);

    //QObject::connect(options_pushButton, SIGNAL(clicked()), this, SLOT(showOptions()));

    QObject::connect(categoryButtonToButtonName_signalMapper, SIGNAL(mapped(QString)), this, SLOT(categorySelected(QString)));
    QObject::connect(appsButtonToButtonName_signalMapper, SIGNAL(mapped(QString)), this, SLOT(appSelected(QString)));

    categoriesWidget->setLayout(categories_layout);
    ui->categories_scrollArea->setWidget(categoriesWidget);

}