示例#1
0
message_view::message_view(QWidget* parent, msg_list_window* sub_parent) : QWidget(parent)
{
  m_pmsg=NULL;
  m_content_type_shown = 0;
  m_zoom_factor=1.0;
  m_parent = sub_parent;
  setAutoFillBackground(true);
  QPalette pal = palette();
  pal.setColor(QPalette::Active, QPalette::Background, Qt::white);
  pal.setColor(QPalette::Inactive, QPalette::Background, Qt::white);
  setPalette(pal);

  enable_page_nav(false, false);
  m_bodyv = new body_view();
  QVBoxLayout* top_layout=new QVBoxLayout(this);
  top_layout->setContentsMargins(0,0,0,0);
  top_layout->setSpacing(0);

  top_layout->addWidget(m_bodyv);

  connect(m_bodyv, SIGNAL(loadFinished(bool)), this, SLOT(load_finished(bool)));
  connect(m_bodyv, SIGNAL(external_contents_requested()), this,
	  SLOT(ask_for_external_contents()));
  connect(m_bodyv, SIGNAL(popup_body_context_menu()), SIGNAL(popup_body_context_menu()));
  if (m_parent) {
    connect(m_bodyv->page(),
	    SIGNAL(linkHovered(const QString&,const QString, const QString&)),
	    this, SLOT(display_link(const QString&)));
  }
  connect(m_bodyv, SIGNAL(linkClicked(const QUrl&)), this, SLOT(link_clicked(const QUrl&)));

  QShortcut* t = new QShortcut(QKeySequence(tr("Ctrl+A", "Select all")), this);
  t->setContext(Qt::WidgetWithChildrenShortcut);
  connect(t, SIGNAL(activated()), this, SLOT(select_all_text()));
}
示例#2
0
message_view::message_view(QWidget* parent, msg_list_window* sub_parent) : QScrollArea(parent)
{
  m_pmsg=NULL;
  m_content_type_shown = 0;
  m_zoom_factor=1.0;
  m_parent = sub_parent;
  setAutoFillBackground(true);
  QPalette pal = palette();
  pal.setColor(QPalette::Active, QPalette::Background, Qt::white);
  pal.setColor(QPalette::Inactive, QPalette::Background, Qt::white);
  setPalette(pal);

  enable_page_nav(false, false);
  m_headersv = new headers_view();
  m_bodyv = new body_view();
  QVBoxLayout* top_layout=new QVBoxLayout(this);
  m_frame = new QFrame();
  m_frame->setFrameStyle(QFrame::Box | QFrame::Raised);
  m_frame->setLineWidth(0);
  m_frame->setMinimumSize(QSize(200,200));

//  m_frame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
  top_layout->addWidget(m_frame);
  QVBoxLayout* l =new QVBoxLayout(m_frame);

  l->setContentsMargins(0,0,0,0);
  l->setSpacing(0);
  l->addWidget(m_headersv);
  l->setStretchFactor(m_headersv, 0);

  l->addWidget(m_bodyv);
  l->setStretchFactor(m_bodyv, 1);

  this->setWidget(m_frame);	// for the scrollarea

  connect(m_bodyv, SIGNAL(wheel(QWheelEvent*)), this, SLOT(wheel_body(QWheelEvent*)));
  connect(m_bodyv, SIGNAL(loadFinished(bool)), this, SLOT(load_finished(bool)));
  connect(m_bodyv, SIGNAL(external_contents_requested()), this,
	  SLOT(ask_for_external_contents()));
  connect(m_bodyv, SIGNAL(key_space_pressed()), this, SLOT(page_down()));
  connect(m_bodyv, SIGNAL(popup_body_context_menu()), SIGNAL(popup_body_context_menu()));
  if (m_parent) {
    connect(m_bodyv->page(),
	    SIGNAL(linkHovered(const QString&,const QString, const QString&)),
	    m_parent, SLOT(show_status_message(const QString&)));
  }
  connect(m_headersv, SIGNAL(fetch_ext_contents()), this, SLOT(allow_external_contents()));
  connect(m_headersv, SIGNAL(to_text()), this, SLOT(show_text_part()));
  connect(m_headersv, SIGNAL(to_html()), this, SLOT(show_html_part()));
  connect(m_headersv, SIGNAL(complete_load_request()), this, SLOT(complete_body_load()));
  m_header_has_selection=false;
  connect(m_headersv, SIGNAL(copyAvailable(bool)), this, SLOT(headers_own_selection(bool)));
  connect(m_headersv, SIGNAL(selectionChanged()), this, SLOT(headers_selection_changed()));
  connect(m_headersv, SIGNAL(msg_display_request()), this, SIGNAL(on_demand_show_request()));
  connect(m_bodyv->page(), SIGNAL(selectionChanged()), this, SLOT(body_selection_changed()));
}
void
body_view::contextMenuEvent(QContextMenuEvent* e)
{
  Q_UNUSED(e);
  emit popup_body_context_menu();
}
示例#4
0
void
msg_list_window::add_msgs_page(const msgs_filter* f, bool if_results _UNUSED_)
{
  m_filter = new msgs_filter(*f);
  QFont body_font;
  QFont list_font;
  QByteArray headerview_setup;

  msgs_page* current = m_pages->current_page();
  // current may be null if we're instantiating the first page
  if (current) {
    body_font = m_msgview->font();
    list_font = m_qlist->font();
    if (m_qlist->sender_recipient_swapped())
      m_qlist->swap_sender_recipient(false);    
    headerview_setup = m_qlist->header()->saveState();
  }

  // new splitter
  QStackedWidget* stackw = m_pages->stacked_widget();
  QSplitter* l=new QSplitter(Qt::Vertical, this);
  stackw->addWidget(l);

  m_qlist = new mail_listview(l);
  m_qlist->set_threaded(display_vars.m_threaded);
  m_qlist->m_msg_window=this;
  if (current)
    m_qlist->setFont(list_font);
  m_qlist->init_columns();
  if (current)
    m_qlist->header()->restoreState(headerview_setup);

  if (!m_filter->m_fetched)
    m_filter->fetch(m_qlist);
  else
    m_filter->make_list(m_qlist);
  msg_list_postprocess();

  m_msgview = new message_view(l, this);

  if (current)
    m_msgview->setFont(body_font);

  connect(m_msgview, SIGNAL(on_demand_show_request()), this, SLOT(display_msg_contents()));
  connect(m_msgview, SIGNAL(popup_body_context_menu()), this, SLOT(body_menu()));
  connect(m_msgview, SIGNAL(page_back()), this, SLOT(move_backward()));
  connect(m_msgview, SIGNAL(page_forward()), this, SLOT(move_forward()));

  m_qAttch = new attch_listview(l);
  connect(m_qAttch, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
	  this, SLOT(attch_selected(QTreeWidgetItem*,int)));
  connect(m_qAttch, SIGNAL(init_progress(const QString)),
	  this, SLOT(install_progressbar(const QString)));
  connect(m_qAttch, SIGNAL(progress(int)), this, SLOT(show_progress(int)));
  connect(m_qAttch, SIGNAL(finish_progress()), this, SLOT(uninstall_progressbar()));
  connect(this, SIGNAL(abort_progress()), m_qAttch, SLOT(download_aborted()));

  // splitter for 3 panes: list of messages / body / attachments list
  static const int splitter_default_sizes[3] = {100,400,25};
  QList<int> lsizes;
  if (current) {
    lsizes = current->m_page_splitter->sizes();
    // don't allow any zero size for panels. This is necessary to avoid having the
    // attachment list being almost invisible to the user
    for (int i=0; i<3; i++) {
      if (lsizes.at(i)==0) {
	lsizes.replace(i, splitter_default_sizes[i]);
      }
    }
  }
  else {
    for (int i=0; i<3; i++) {
      int sz;
      QString key;
      key.sprintf("display/msglist/panel%d_size", i+1);
      if (get_config().exists(key)) {
	sz=get_config().get_number(key);
	if (sz==0)
	  sz=splitter_default_sizes[i];
      }
      else
	sz=splitter_default_sizes[i];
      lsizes.append(sz);
    }
  }

  /* avoid changing the listview's height each time the attachments view
     is shown or hidden */
  l->setStretchFactor(l->indexOf(m_qlist), 0);
  l->setStretchFactor(l->indexOf(m_msgview), 1);
  l->setStretchFactor(l->indexOf(m_qAttch), 0);

  l->setSizes(lsizes);
  m_qAttch->hide();
  m_wSearch=NULL;

  connect(m_qlist,SIGNAL(selection_changed()), this,SLOT(mails_selected()));

  connect(m_qlist,SIGNAL(doubleClicked(const QModelIndex&)),
	  this,SLOT(mail_reply_all()));

  connect(m_qlist, SIGNAL(clicked(const QModelIndex&)),
	  this, SLOT(action_click_msg_list(const QModelIndex&)));

  connect(m_qlist, SIGNAL(scroll_page_down()), m_msgview, SLOT(page_down()));

  if (m_pages->next_page()) {
    // we're in the middle of a page list, and asked to go forward.
    // let's remove all the pages that are after the current position
    m_pages->cut_pages(m_pages->next_page());
  }
  int max_pages=get_config().get_number("msg_window_pages");
  if (max_pages<2) max_pages=2;
  if (m_pages->count() >= max_pages) {
    free_msgs_page();
    if (m_pages->count() >= max_pages) {
      // Still no room for a new page? OK, forget it
      DBG_PRINTF(5,"not enough pages!");
      return;
    }
  }

  // allocate and use a new page
  msgs_page* page = new msgs_page();
  page->m_page_filter = m_filter;
  page->m_page_msgview = m_msgview;
  page->m_page_attach = m_qAttch;
  page->m_page_qlist = m_qlist;
  page->m_page_current_item = NULL;
  page->m_page_splitter = l;
  page->m_msgs_window = this;
  page->m_query_lvitem_id = m_query_lv->current_id();
  m_pages->add_page(page);
  m_pages->raise_page(page);
  m_tags_box->reset_tags();
  enable_forward_backward();
}