コード例 #1
0
HistoryWindow::HistoryWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::HistoryWindow)
{
    ui->setupUi(this);

    connect(FlowMeterManager::Instance, SIGNAL(PourFinished()), this, SLOT(pourFinishedSlot()));
    connect(this->ui->scrollPane, SIGNAL(SelectionChanged(int)), this, SLOT(setSelectedIndex(int)));

    picIndex = 0;
    selectedIndex = -1;
    selectedPour = NULL;

    QAbstractItemView *view = this->ui->usersComboBox->view();
    view->setItemDelegate(new CustomComboBoxItem(this));
    connect(this->ui->usersComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(userSelectedSlot(int)));

    vector<User*>::iterator iter;
    for (iter = User::UsersList.begin(); iter != User::UsersList.end(); ++iter)
    {
        User* user = (*iter);
        this->ui->usersComboBox->addItem(QString(user->Name.c_str()));
    }
    this->ui->usersComboBox->setCurrentIndex(-1);

    //QtConcurrent::run(this, &HistoryWindow::updateButtons);
}
コード例 #2
0
ファイル: collection-delegate.cpp プロジェクト: KDE/palapeli
Palapeli::CollectionDelegate::CollectionDelegate (QObject* parent)
        : QStyledItemDelegate(parent)
{
    QAbstractItemView* view = qobject_cast<QAbstractItemView*>(parent);
    if (view) {
        view->setItemDelegate(this);
        m_viewport = view->viewport();
    }
}
コード例 #3
0
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
  : QMainWindow(parent, flags), m_activityCompleter(NULL),
    m_tagCompleter(NULL), m_activityCompleterModel(NULL),
    m_tagCompleterModel(NULL), m_trayIconAvailable(false),
    m_showTrayIcon(false), m_trayIconMenu(NULL), m_trayIcon(NULL)
{
  m_ui.setupUi(this);
  setWindowIcon(QIcon(":/icons/hourglass.png"));
  m_ui.actionAbout_Qt->setIcon(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"));

  m_trayIconAvailable = QSystemTrayIcon::isSystemTrayAvailable();
  if (m_trayIconAvailable) {
    m_showTrayIcon = m_settings.value("showTrayIcon", true).toBool();
    if (m_showTrayIcon) {
      createTrayIcon();
    }
  }
  else {
    qDebug() << "Couldn't display tray icon";
  }

  /* Set background of week tab to white */
  QPalette weekPal(m_ui.saContentsWeek->palette());
  weekPal.setColor(QPalette::Background, Qt::white);
  m_ui.saContentsWeek->setPalette(weekPal);

  /* Set background of current activity table to transparent */
  QPalette currentPal(m_ui.tblCurrent->palette());
  currentPal.setColor(QPalette::Base, Qt::transparent);
  m_ui.tblCurrent->setPalette(currentPal);

  /* Setup activity completer */
  m_activityCompleter = new QCompleter(this);
  m_activityCompleterModel = new ActivityNamesListModel(this);
  m_activityCompleter->setModel(m_activityCompleterModel);
  m_activityCompleter->setCompletionMode(QCompleter::PopupCompletion);
  m_activityCompleter->setCaseSensitivity(Qt::CaseInsensitive);

  QAbstractItemView *activityPopup = m_activityCompleter->popup();
  activityPopup->setItemDelegate(new NamesDelegate(activityPopup));
  activityPopup->setFrameShadow(QFrame::Plain);

  m_ui.leActivity->setCompleter(m_activityCompleter);

  /* Setup tag completer */
  m_tagCompleter = new QCompleter(this);
  m_tagCompleterModel = new TagNamesListModel(this);
  m_tagCompleter->setModel(m_tagCompleterModel);
  m_tagCompleter->setCompletionMode(QCompleter::PopupCompletion);
  m_tagCompleter->setCaseSensitivity(Qt::CaseInsensitive);

  QAbstractItemView *tagPopup = m_tagCompleter->popup();
  tagPopup->setItemDelegate(new NamesDelegate(tagPopup));
  tagPopup->setFrameShadow(QFrame::Plain);

  m_ui.leTags->setCompleter(m_tagCompleter);

  /* Set up activity tables */
  m_recordManager = new RecordManager<Activity>;

  m_ui.tblCurrent->setModel(new CurrentActivityTableModel(m_recordManager, this));
  m_ui.tblCurrent->setItemDelegate(new CurrentActivityDelegate(m_ui.tblCurrent));
  connect(this, SIGNAL(activityCreated(QSharedPointer<Activity>)),
      m_ui.tblCurrent->model(), SLOT(created(QSharedPointer<Activity>)));

  setupViews();

  /* Set a timer to go off hourly to check if we should switch days */
  m_dayTimer = new QTimer(this);
  m_dayTimer->setInterval(3600000);
  connect(m_dayTimer, SIGNAL(timeout()), this, SLOT(setupViews()));

  QTime nowTime = QTime::currentTime();
  int msecsToHour = 3600000 - (nowTime.minute() * 60000) -
    (nowTime.second() * 1000) - nowTime.msec();
  QTimer::singleShot(msecsToHour, this, SLOT(setupViews()));
  QTimer::singleShot(msecsToHour, m_dayTimer, SLOT(start()));
}