summaryrefslogtreecommitdiffstats
path: root/libkonq/update_tdestringmatcher.cpp
blob: f46447d95dfa02550886fac33ab4de7c32824b02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "update_tdestringmatcher.h"
#include "update_tdestringmatcher_dialog.h"

#include <kdebug.h>

UIresult
getTDEStringMatcherPatternsFromUser(
  TDEStringMatcher *matcher,
  TQString dialogTitle
)
{
  TDEStringMatcher::MatchSpecList matchSpecs = matcher->getMatchSpecs();
  TDEStringMatcher_UI *tsmDialog = new TDEStringMatcher_UI( matchSpecs, dialogTitle );
  tsmDialog->exec();
  UIresult requested_action;
  if ( tsmDialog->result() ) {
    requested_action = tsmDialog->getDialogResult();
  }
  else {
    requested_action = UIresult::NOCHANGE;
  }

  switch ( requested_action ) {
    case UIresult::NOCHANGE :
      TSMTRACE
        << "TDEStringMatcherUI::getMatchPropertiesFromUser: user edit cancelled" << endl;
      return requested_action;
      break;
    case UIresult::RELOAD   :
      TSMTRACE
        << "TDEStringMatcherUI::getMatchPropertiesFromUser: user asking caller to reload stored pattern" << endl;
      return requested_action;
      break;
  }

  if ( matcher->setMatchSpecs( tsmDialog->getMatchSpecs() ) ) {
    TSMTRACE
      << "TDEStringMatcherUI::getMatchPropertiesFromUser: user edits applied:  '"
      << matcher->getMatchSpecString() << "'" << endl;
  }

  else {
    TSMTRACE
      << "TDEStringMatcherUI::getMatchPropertiesFromUser: user edits rejected"  << endl;
    return UIresult::NOCHANGE;
  }


  if ( requested_action == UIresult::RELOAD ) {
    TSMTRACE
      << "TDEStringMatcherUI::getMatchPropertiesFromUser: user asking caller to save updated criteria string" << endl;
  }

  return requested_action;
}